[Numpy-tickets] [NumPy] #484: random state not portable between 32-bit and 64-bit architectures

NumPy numpy-tickets@scipy....
Wed Mar 28 08:47:00 CDT 2007


#484: random state not portable between 32-bit and 64-bit architectures
--------------------------+-------------------------------------------------
 Reporter:  berkes        |       Owner:  somebody
     Type:  defect        |      Status:  new     
 Priority:  normal        |   Milestone:          
Component:  numpy.random  |     Version:          
 Severity:  normal        |    Keywords:          
--------------------------+-------------------------------------------------
 The random state in the numpy.random module contains an
 array of int32 or int64 depending on the architecture, making
 it not portable. This makes simulations not reproducible on different
 machines.

 For example, try the following on two machines with different
 architecures:


 {{{
 Python 2.4.4 (#2, Jan 13 2007, 17:50:26)
 [GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> import platform
 >>> import pickle
 >>>
 >>> platform.architecture()
 ('32bit', '')
 >>>
 >>> state = numpy.random.get_state()
 >>> pickle.dump(state, file('/tmp/random_state.pic','w'))
 >>> numpy.random.permutation(numpy.arange(10))
 array([8, 6, 3, 1, 0, 5, 7, 4, 2, 9])
 >>>

 Python 2.5 (r25:51908, Mar 19 2007, 13:41:07)
 [GCC 4.1.0 (SUSE Linux)] on linux2
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy
 >>> import platform
 >>> import pickle
 >>>
 >>> platform.architecture()
 ('64bit', 'ELF')
 >>>
 >>> state = pickle.load(file('/tmp/random_state.pic','r'))
 >>> numpy.random.set_state(state)
 >>> numpy.random.permutation(numpy.arange(10))
 array([3, 9, 4, 8, 1, 6, 2, 0, 5, 7])
 >>>


 }}}

-- 
Ticket URL: <http://projects.scipy.org/scipy/numpy/ticket/484>
NumPy <http://projects.scipy.org/scipy/numpy>
The fundamental package needed for scientific computing with Python.


More information about the Numpy-tickets mailing list