473,756 Members | 5,955 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(fi le(filename))
File "/home/jnix/lib/python2.4/SuSE-9.0/x86_64/Numeric/Numeric.py", line 520, in array_construct or
x.shape = shape
ValueError: ('total size of new array must be unchanged', <function array_construct or at 0x2a960b0b18>, ((10,), 'l', '\x00\x00\x00\x 00\x01\x00\x00\ x00\x02\x00\x00 \x00\x03\x00\x0 0\x00\x04\x00\x 00\x00\x05\x00\ x00\x00\x06\x00 \x00\x00\x07\x0 0\x00\x00\x08\x 00\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(fi le(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 1830
"Johannes Nix|Johannes.Ni x"@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(fi le(filename))
File "/home/jnix/lib/python2.4/SuSE-9.0/x86_64/Numeric/Numeric.py", line 520, in array_construct or
x.shape = shape
ValueError: ('total size of new array must be unchanged', <function array_construct or at 0x2a960b0b18>, ((10,), 'l', '\x00\x00\x00\x 00\x01\x00\x00\ x00\x02\x00\x00 \x00\x03\x00\x0 0\x00\x04\x00\x 00\x00\x05\x00\ x00\x00\x06\x00 \x00\x00\x07\x0 0\x00\x00\x08\x 00\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(fi le(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***********@u ni-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
1418
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. However, Numeric is currently used in a large installed base. In particular SciPy uses Numeric as its core array. While no doubt numarray arrays will be supported in the future, the speed of the less bulky Numeric arrays and the typical case...
1
1436
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. My case is getting the error, not because methods need shared, but because forms need shared. Example: A.DLL has form TestA1, TestA2 B.DLL has form TestB TestA1 navigates to display TestB, thus A.DLL needs to reference B.DLL so the form will...
7
3266
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)) CType(local4, Short) = CType(src, Short)
1
2688
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 share the code with you that i wrote to solve the problem. certainly nothing sophisticated but it would have been very helpful to me had i gotten ahold of it when i started out to tackle the problem. i welcome any feedback. the solution uses a...
2
1698
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 textboxes and the dropdownlist) and lots more stuff on the page. When the user wants to save the page he'll click the save button. The server gets the postback but I can read out the filled in controls (in my control). The textboxes text = ""...
0
1918
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 { public: virtual void visit(Object_type_1 *); virtual void visit(Object_type_2 *)
0
1997
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473 0.01951756438393204
3
1487
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 and make sure the order is correct? or can I insert the require_once in the class itself(which then I'm worried about forcing the location)? How does one normally go about this? Thanks, Jon
4
3797
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. It complains about duplicates etc etc. I have tried adding it to the Solution, but then it doesn't appear in the Designer under resources in the Project.
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3806
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.