473,385 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Solution for architecure dependence in Numeric ?


Hi,

I have a tricky problem with Numeric. Some time ago, I have generated
a huge and complex data structure, and stored it using the cPickle
module. Now I want to evaluate it quickly again on a workstation
cluster with 64-Bit Opteron CPUs - I have no more than three days to
do this. Compiling Python and running Numeric has been no problem at
all. However, I get an error message when accessing the data pickled
before. (I can load it regularly on 32 bit computers, but it is a
quite complex data object, so I really don't want to store every
element as ASCII data). The problem seems to be with 64 Bit integers
(with 32-bit-floats, no problem was observed).

This looks like that (from the Unix command shell):
jnix@32bithost:~> python ~/python/test_npickle.py -dump test.pck
jnix@32bithost:~> python ~/python/test_npickle.py test.pck
[0 1 2 3 4 5 6 7 8 9]
jnix@32bithost:~> ssh 64bithost python ~/python/test_npickle.py test.pck
Traceback (most recent call last):
File "/home/jnix/python/test_npickle.py", line 16, in ?
a = cPickle.load(file(filename))
File "/home/jnix/lib/python2.4/SuSE-9.0/x86_64/Numeric/Numeric.py", line 520, in array_constructor
x.shape = shape
ValueError: ('total size of new array must be unchanged', <function array_constructor at 0x2a960b0b18>, ((10,), 'l', '\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\ x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x0 6\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\t\x0 0\x00\x00', 1))
also I get:
jnix@32bithost:~> python -c "import Numeric; print Numeric.arange(0).itemsize()"
4
jnix@64bithost:~> python -c "import Numeric; print Numeric.arange(0).itemsize()"
8
The script used to produce the example above is:

-------------------------------------------------------------------------
#/usr/bin/python
# -*- coding: latin1 -*-

import Numeric
import cPickle
import sys

if len(sys.argv) > 1 and sys.argv[1] == '-dump':
filename = sys.argv[2]
binary=1
a = Numeric.arange(10)
cPickle.dump(a, file(filename,'w',binary))

else:
filename = sys.argv[1]
a = cPickle.load(file(filename))
print a
---------------------------------------------------------------------
So what would you suggest ? Can I hack Numeric to assume non-native
32 bit integer numbers ?

Many thanks for any help,

Johannes
Jul 18 '05 #1
2 1813
"Johannes Nix|Johannes.Nix"@uni-oldenburg.de wrote:
Hi,

I have a tricky problem with Numeric. Some time ago, I have generated
a huge and complex data structure, and stored it using the cPickle
module. Now I want to evaluate it quickly again on a workstation
cluster with 64-Bit Opteron CPUs - I have no more than three days to
do this. Compiling Python and running Numeric has been no problem at
all. However, I get an error message when accessing the data pickled
before. (I can load it regularly on 32 bit computers, but it is a
quite complex data object, so I really don't want to store every
element as ASCII data). The problem seems to be with 64 Bit integers
(with 32-bit-floats, no problem was observed).

This looks like that (from the Unix command shell):
jnix@32bithost:~> python ~/python/test_npickle.py -dump test.pck
jnix@32bithost:~> python ~/python/test_npickle.py test.pck
[0 1 2 3 4 5 6 7 8 9]
jnix@32bithost:~> ssh 64bithost python ~/python/test_npickle.py test.pck
Traceback (most recent call last):
File "/home/jnix/python/test_npickle.py", line 16, in ?
a = cPickle.load(file(filename))
File "/home/jnix/lib/python2.4/SuSE-9.0/x86_64/Numeric/Numeric.py", line 520, in array_constructor
x.shape = shape
ValueError: ('total size of new array must be unchanged', <function array_constructor at 0x2a960b0b18>, ((10,), 'l', '\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\ x03\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x0 6\x00\x00\x00\x07\x00\x00\x00\x08\x00\x00\x00\t\x0 0\x00\x00', 1))
also I get:
jnix@32bithost:~> python -c "import Numeric; print Numeric.arange(0).itemsize()"
4
jnix@64bithost:~> python -c "import Numeric; print Numeric.arange(0).itemsize()"
8
The script used to produce the example above is:

-------------------------------------------------------------------------
#/usr/bin/python
# -*- coding: latin1 -*-

import Numeric
import cPickle
import sys

if len(sys.argv) > 1 and sys.argv[1] == '-dump':
filename = sys.argv[2]
binary=1
a = Numeric.arange(10)
cPickle.dump(a, file(filename,'w',binary))

else:
filename = sys.argv[1]
a = cPickle.load(file(filename))
print a
---------------------------------------------------------------------
So what would you suggest ? Can I hack Numeric to assume non-native
32 bit integer numbers ?

Many thanks for any help,

Johannes

It might be worth posting to the Numeric mailing list, mirrored at
http://news.gmane.org/gmane.comp.python.numeric.general

Jul 18 '05 #2
Johannes Nix |J***********@uni-oldenburg.de> writes:
So what would you suggest ? Can I hack Numeric to assume non-native
32 bit integer numbers ?


I think it would be better to fix the pickle/cPickle module to
correctly unpack the 32-bit ints on your 64 bit machine.
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Travis Oliphant | last post by:
Numarray is making great progress and is quite usable for many purposes. An idea that was championed by some is that the Numeric code base would stay static and be replaced entirely by Numarray. ...
1
by: Leslie | last post by:
I have 2 dlls and they reference each other, thus causing the circular dependence error. I have read about other cases and people say use Interfaces to solve the problem with the shared methods. ...
7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
1
by: Ted Theodoropoulos | last post by:
i posted an earlier thread about exporting data from a subform in an ..ADP to an .MDB file. i had only one gracious response but it wouldn't work in the given situation. so i thought i would...
2
by: Pipo | last post by:
Nobody knows how to get the values provided in the client can be read in the user-control? If have made a Web Custom Control with 2 textboxes and 1 dropdownlist. The user fills in my control (the...
0
by: Siphiuel | last post by:
Hi everyone. When using visitor pattern, we have a nasty dependence on the types of visitable objects that is coded way on top on the visitor hierarchy. i mean, like this: class AbstractVisitor...
0
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473 0.01951756438393204
3
by: Jon Slaughter | last post by:
I have created a few classes which depend on other classes but I'm unsure how to go about including the classes so they are visible to each other. Can I just require_once at some point before use...
4
by: Daniel Jeffrey | last post by:
I have created a Resource file that stores common icons used in my projects. I have a solution that contains 2 projects, and I keep getting errors if I add the resource file to both projects. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.