Re: Numpy problem: Arrays in a list of dictionaries

2007-04-23 Thread ZMY
Dear Robert,

So how should I do this? I tried

>>>> d1 = {1: array([2, 3, 4]).copy(), 2: ''}
>>>> l1 = []
>>>> for i in range(3): l1.append(d1.copy())

and it still doesn't work.

I think my problem is: how to create a new array every time I append
it to the list...

Thanks in advance,

- ZMY


On Apr 17, 12:36 pm, Robert Kern <[EMAIL PROTECTED]> wrote:
> ZMYwrote:
> > I am new to Numpy/Pylab, and I am trying to construct a list of
> > dictionaries with arrays as the items, for example:
>
> >>>> dict = {1: array([2, 3, 4]), 2: ''}
> >>>> list1 = []
> >>>> for i in range(3): list1.append(dict.copy())
> > ...
> >>>> list1
> > [{1: array([2, 3, 4]), 2: ''}, {1: array([2, 3, 4]), 2: ''}, {1:
> > array([2, 3, 4]), 2: ''}]
> >>>> list1[0][1][1]=100
> >>>> list1
> > [{1: array([  2, 100,   4]), 2: ''}, {1: array([  2, 100,   4]), 2:
> > ''}, {1: array([  2, 100,   4]), 2: ''}]
>
> >>>> list1[0][2]='Jack'
> >>>> list1
> > [{1: array([  2, 100,   4]), 2: 'Jack'}, {1: array([  2, 100,   4]),
> > 2: ''}, {1: array([  2, 100,   4]), 2: ''}]
>
> > So the strings can be assigned seperately but arrays can not. What is
> > the problem here?
>
> When you call dict.copy(), all it does is make a copy of the dictionary; each
> copy of the dictionary still refers to the same objects.
>
> list1[i][1] refers to the same array for all i, so when you modify it in-place
> like you did, you will see the modifications in every reference to that 
> object.
>
> list[i][2] also referred to the same string for all i until you *replaced* the
> entry in the 0'th dictionary.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco


-- 
http://mail.python.org/mailman/listinfo/python-list


Does Numpy work on QNX 4.25 with Python 2.2?

2007-03-26 Thread ZMY
I am trying to convert some old Fortran code into Python program and
get them work on a QNX 4.25 system. Since the program requires speed,
I think using Numpy is really necessary. But I haven't found anything
on web about using numpy on QNX 4.25 (especially the for python
version 2.2).

Do any of you have experience on this problem?

Thanks a lot in advance!

- Zhonghua

-- 
http://mail.python.org/mailman/listinfo/python-list


python installation destination directory

2007-04-02 Thread ZMY
Hi all,

I am installing python 2.2 on QNX4.25 but can't get it into /usr/local/
bin/ directory. Here is what I did:

1) untar Python-2.2 into directory /openqnx/Python-2.2/

2) use command:
CONFIG_SHELL=/usr/local/bin/bash CC=cc RANLIB=:
./configure --verbose --without-gcc --with-libm=""

3) Enabled array, math, os, struct, time, cmath modules

4) use command:
make SHELL=/usr/local/bin/bash

and I got a python excutable in directory
 /openqnx/Python-2.2/

which works well with all the modules. But I really want to have it
at /usr/local/bin

I checked the Makefile, and it seems python should be installed in /
usr/local/bin instead, since I got following lines in Makefile:

# Install prefix for architecture-independent files
prefix= /usr/local

# Install prefix for architecture-dependent files
exec_prefix=${prefix}

Do any of you know what the problem is?

Thanks a lot in advance.

- ZMY

-- 
http://mail.python.org/mailman/listinfo/python-list


Numeric compiling problem under QNX 4.25

2007-04-02 Thread ZMY
Dear all,

I am a real newbie for both python and QNX, but I am still trying to
compile Numeric-24.2 under QNX4.25 with python 2.2. I got following
error message:


$ sudo python setup.py install
Password:
running install
...
building '_numpy' extension
skipping Src/_numpymodule.c (build/temp.qnx-O-PCI-2.2/_numpymodule.o
up-to-date)
skipping Src/arrayobject.c (build/temp.qnx-O-PCI-2.2/arrayobject.o up-
to-date)
skipping Src/ufuncobject.c (build/temp.qnx-O-PCI-2.2/ufuncobject.o up-
to-date)
ld build/temp.qnx-O-PCI-2.2/_numpymodule.o build/temp.qnx-O-PCI-2.2/
arrayobject.o build/temp.qnx-O-PCI-2.2/ufuncobject.o -o build/lib.qnx-
O-PCI-2.2/_numpy.so
unable to execute ld: No such file or directory
error: command 'ld' failed with exit status 1



I looked at directory /build/temp.qnx-O-PCI-2.2/ and found following
object files:

_numpymodule.o, arrayobject.o, ufuncobject.o

So it looks that ld got all files before linking them - or is it??

Thanks a lot for any suggestions,

- ZMY

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numeric compiling problem under QNX 4.25

2007-04-03 Thread ZMY
On Apr 3, 10:22 am, Robert Kern <[EMAIL PROTECTED]> wrote:
> ZMY wrote:
> > Dear all,
>
> > I am a real newbie for both python and QNX, but I am still trying to
> > compile Numeric-24.2 under QNX4.25 with python 2.2. I got following
> > error message:
>
> > $ sudo python setup.py install
> > Password:
> > running install
> > ...
> > building '_numpy' extension
> > skipping Src/_numpymodule.c (build/temp.qnx-O-PCI-2.2/_numpymodule.o
> > up-to-date)
> > skipping Src/arrayobject.c (build/temp.qnx-O-PCI-2.2/arrayobject.o up-
> > to-date)
> > skipping Src/ufuncobject.c (build/temp.qnx-O-PCI-2.2/ufuncobject.o up-
> > to-date)
> > ld build/temp.qnx-O-PCI-2.2/_numpymodule.o build/temp.qnx-O-PCI-2.2/
> > arrayobject.o build/temp.qnx-O-PCI-2.2/ufuncobject.o -o build/lib.qnx-
> > O-PCI-2.2/_numpy.so
> > unable to execute ld: No such file or directory
> > error: command 'ld' failed with exit status 1
>
> It looks like it can't find the command ld. Can you compile any other 
> extension
> modules?
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco

Is "ld" part of make command? I am not familiar with compiling with
make in general.

Most other extensions (including math, os, struct, cPickle) from
Python 2.2 works when I install python on QNX.

Thanks a lot to all of you.

-ZMY

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python installation destination directory

2007-04-03 Thread ZMY
On Apr 3, 6:26 am, "Kushal Kumaran" <[EMAIL PROTECTED]> wrote:
> On Apr 3, 9:33 am, "ZMY" <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi all,
>
> > I am installing python 2.2 on QNX4.25 but can't get it into /usr/local/
> > bin/ directory. Here is what I did:
>
> > 1) untar Python-2.2 into directory /openqnx/Python-2.2/
>
> > 2) use command:
> > CONFIG_SHELL=/usr/local/bin/bash CC=cc RANLIB=:
> > ./configure --verbose --without-gcc --with-libm=""
>
> > 3) Enabled array, math, os, struct, time, cmath modules
>
> > 4) use command:
> > make SHELL=/usr/local/bin/bash
>
> > and I got a python excutable in directory
> >  /openqnx/Python-2.2/
>
> > which works well with all the modules. But I really want to have it
> > at /usr/local/bin
>
> > I checked the Makefile, and it seems python should be installed in /
> > usr/local/bin instead, since I got following lines in Makefile:
>
> > # Install prefix for architecture-independent files
> > prefix= /usr/local
>
> > # Install prefix for architecture-dependent files
> > exec_prefix=${prefix}
>
> > Do any of you know what the problem is?
>
> You need to do a make install.
>
> --
> Kushal

Thanks. It works.

-ZMY

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numeric compiling problem under QNX 4.25

2007-04-03 Thread ZMY
On Apr 3, 10:51 am, Robert Kern <[EMAIL PROTECTED]> wrote:
> ZMY wrote:
> > Is "ld" part of make command? I am not familiar with compiling with
> > make in general.
>
> No, it's the linker. I takes the object files (.o) which are generated by the
> compiler (cc, I imagine) and links them together into the shared library 
> (.so).
> make is a program that can automate builds given instructions, but Numeric
> doesn't use it, nor do most other Python packages.
>
> > Most other extensions (including math, os, struct, cPickle) from
> > Python 2.2 works when I install python on QNX.
>
> No, I was wondering if you could build any other third-party extension 
> modules.
> Did you install Python from source? When building extension modules, Python 
> uses
> whatever linker was used to build itself.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto E

Dear Robert,

Looks like you are right. Here is what I got when I compile the
Python2.2 from source (or I believe so):

$ sudo make SHELL=/usr/local/bin/bash
Password:
case $MAKEFLAGS in \
*-s*) CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E //6/openqnx/
Python-2.2/setup.py -q build;; \
*) CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E //6/openqnx/
Python-2.2/setup.py build;; \
esac
running build
running build_ext
building 'regex' extension
skipping //6/openqnx/Python-2.2/Modules/regexmodule.c (build/temp.qnx-
O-PCI-2.2/regexmodule.o up-to-date)
skipping //6/openqnx/Python-2.2/Modules/regexpr.c (build/temp.qnx-O-
PCI-2.2/regexpr.o up-to-date)
ld build/temp.qnx-O-PCI-2.2/regexmodule.o build/temp.qnx-O-PCI-2.2/
regexpr.o -L/usr/local/lib -o build/lib.qnx-O-PCI-2.2/regex.so
unable to execute ld: No such file or directory


If there is no 'ld' linker, what should be used instead??

BTW, the reason I am still using QNX4.25 is because I was trying to
install python on this legacy system. We can't move to QNX6 unless we
want to redo all other code as well, which took 3 years of a good
programmer :-(

- ZMY

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numeric compiling problem under QNX 4.25

2007-04-03 Thread ZMY
On Apr 3, 1:33 pm, "ZMY" <[EMAIL PROTECTED]> wrote:
> On Apr 3, 10:51 am, Robert Kern <[EMAIL PROTECTED]> wrote:
>
>
>
> >ZMYwrote:
> > > Is "ld" part of make command? I am not familiar with compiling with
> > > make in general.
>
> > No, it's the linker. I takes the object files (.o) which are generated by 
> > the
> > compiler (cc, I imagine) and links them together into the shared library 
> > (.so).
> > make is a program that can automate builds given instructions, but Numeric
> > doesn't use it, nor do most other Python packages.
>
> > > Most other extensions (including math, os, struct, cPickle) from
> > > Python 2.2 works when I install python on QNX.
>
> > No, I was wondering if you could build any other third-party extension 
> > modules.
> > Did you install Python from source? When building extension modules, Python 
> > uses
> > whatever linker was used to build itself.
>
> > --
> > Robert Kern
>
> > "I have come to believe that the whole world is an enigma, a harmless enigma
> >  that is made terrible by our own mad attempt to interpret it as though it 
> > had
> >  an underlying truth."
> >   -- Umberto E
>
> Dear Robert,
>
> Looks like you are right. Here is what I got when I compile the
> Python2.2 from source (or I believe so):
>
> $ sudo make SHELL=/usr/local/bin/bash
> Password:
> case $MAKEFLAGS in \
> *-s*) CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E //6/openqnx/
> Python-2.2/setup.py -q build;; \
> *) CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E //6/openqnx/
> Python-2.2/setup.py build;; \
> esac
> running build
> running build_ext
> building 'regex' extension
> skipping //6/openqnx/Python-2.2/Modules/regexmodule.c (build/temp.qnx-
> O-PCI-2.2/regexmodule.o up-to-date)
> skipping //6/openqnx/Python-2.2/Modules/regexpr.c (build/temp.qnx-O-
> PCI-2.2/regexpr.o up-to-date)
> ld build/temp.qnx-O-PCI-2.2/regexmodule.o build/temp.qnx-O-PCI-2.2/
> regexpr.o -L/usr/local/lib -o build/lib.qnx-O-PCI-2.2/regex.so
> unable to execute ld: No such file or directory
> 
>
> If there is no 'ld' linker, what should be used instead??
>
> BTW, the reason I am still using QNX4.25 is because I was trying to
> install python on this legacy system. We can't move to QNX6 unless we
> want to redo all other code as well, which took 3 years of a good
> programmer :-(
>
> -ZMY

I have tried to use Watcom linker 'wlink' in QNX instead of the 'ld'
linker, but I still got problem with _numpymodule.o

Do you have any experience with this??

...
building '_numpy' extension
cc -DNDEBUG -O -IInclude -IPackages/FFT/Include -IPackages/RNG/Include
-I/usr/local/include/python2.2 -c Src/_numpymodule.c -o build/temp.qnx-
O-PCI-2.2/_numpymodule.o
/usr/watcom/10.6/bin/wcc386 -zq -d+ -dNDEBUG -oil -i=Include -
i=Packages/FFT/Include -i=Packages/RNG/Include -i=/usr/local/include/
python2.2 -ms -fo=build/temp.qnx-O-PCI-2.2/_numpymodule.o -4r -i=/usr/
watcom/10.6/usr/include -i=/usr/include Src/_numpymodule.c
cc -DNDEBUG -O -IInclude -IPackages/FFT/Include -IPackages/RNG/Include
-I/usr/local/include/python2.2 -c Src/arrayobject.c -o build/temp.qnx-
O-PCI-2.2/arrayobject.o
/usr/watcom/10.6/bin/wcc386 -zq -d+ -dNDEBUG -oil -i=Include -
i=Packages/FFT/Include -i=Packages/RNG/Include -i=/usr/local/include/
python2.2 -ms -fo=build/temp.qnx-O-PCI-2.2/arrayobject.o -4r -i=/usr/
watcom/10.6/usr/include -i=/usr/include Src/arrayobject.c
Src/arrayobject.c(527): Warning! W124: Comparison result always 0
cc -DNDEBUG -O -IInclude -IPackages/FFT/Include -IPackages/RNG/Include
-I/usr/local/include/python2.2 -c Src/ufuncobject.c -o build/temp.qnx-
O-PCI-2.2/ufuncobject.o
/usr/watcom/10.6/bin/wcc386 -zq -d+ -dNDEBUG -oil -i=Include -
i=Packages/FFT/Include -i=Packages/RNG/Include -i=/usr/local/include/
python2.2 -ms -fo=build/temp.qnx-O-PCI-2.2/ufuncobject.o -4r -i=/usr/
watcom/10.6/usr/include -i=/usr/include Src/ufuncobject.c
wlink build/temp.qnx-O-PCI-2.2/_numpymodule.o build/temp.qnx-O-PCI-2.2/
arrayobject.o build/temp.qnx-O-PCI-2.2/ufuncobject.o -o build/lib.qnx-
O-PCI-2.2/_numpy.so
WATCOM Linker Version 10.6
Copyright by WATCOM International Corp. 1985, 1996. All rights
reserved.
WATCOM is a trademark of WATCOM International Corp.
Error(3033): directive error near 'build/temp.qnx-O-PCI-2.2/
_numpymodule.o'
error: command 'wlink' failed with exit status 1


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Numeric compiling problem under QNX 4.25

2007-04-04 Thread ZMY
On Apr 3, 2:52 pm, Robert Kern <[EMAIL PROTECTED]> wrote:
> ZMY wrote:
> > On Apr 3, 10:51 am, Robert Kern <[EMAIL PROTECTED]> wrote:
> >> ZMY wrote:
> >>> Is "ld" part of make command? I am not familiar with compiling with
> >>> make in general.
> >> No, it's the linker. I takes the object files (.o) which are generated by 
> >> the
> >> compiler (cc, I imagine) and links them together into the shared library 
> >> (.so).
> >> make is a program that can automate builds given instructions, but Numeric
> >> doesn't use it, nor do most other Python packages.
>
> >>> Most other extensions (including math, os, struct, cPickle) from
> >>> Python 2.2 works when I install python on QNX.
> >> No, I was wondering if you could build any other third-party extension 
> >> modules.
> >> Did you install Python from source? When building extension modules, 
> >> Python uses
> >> whatever linker was used to build itself.
>
> >> --
> >> Robert Kern
>
> >> "I have come to believe that the whole world is an enigma, a harmless 
> >> enigma
> >>  that is made terrible by our own mad attempt to interpret it as though it 
> >> had
> >>  an underlying truth."
> >>   -- Umberto E
>
> > Dear Robert,
>
> > Looks like you are right. Here is what I got when I compile the
> > Python2.2 from source (or I believe so):
>
> > $ sudo make SHELL=/usr/local/bin/bash
> > Password:
> > case $MAKEFLAGS in \
> > *-s*) CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E //6/openqnx/
> > Python-2.2/setup.py -q build;; \
> > *) CC='cc' LDSHARED='ld' OPT='-DNDEBUG -O' ./python -E //6/openqnx/
> > Python-2.2/setup.py build;; \
> > esac
> > running build
> > running build_ext
> > building 'regex' extension
> > skipping //6/openqnx/Python-2.2/Modules/regexmodule.c (build/temp.qnx-
> > O-PCI-2.2/regexmodule.o up-to-date)
> > skipping //6/openqnx/Python-2.2/Modules/regexpr.c (build/temp.qnx-O-
> > PCI-2.2/regexpr.o up-to-date)
> > ld build/temp.qnx-O-PCI-2.2/regexmodule.o build/temp.qnx-O-PCI-2.2/
> > regexpr.o -L/usr/local/lib -o build/lib.qnx-O-PCI-2.2/regex.so
> > unable to execute ld: No such file or directory
> > 
>
> > If there is no 'ld' linker, what should be used instead??
>
> I don't know. I've never used QNX. It looks like the Python binaries were 
> built
> with a linker that you don't have on your system. Usually, you have to use the
> same compiler/linker combination to build extension modules that you used to
> build Python itself.
>
> --
> Robert Kern
>
> "I have come to believe that the whole world is an enigma, a harmless enigma
>  that is made terrible by our own mad attempt to interpret it as though it had
>  an underlying truth."
>   -- Umberto Eco

Dear All,

I finally figured out how to install Numeric Python on QNX4. To my
understanding of a QNX programmer's lecture, the problem of QNX4 is
that it doesn't support dynamic linking, so the linker can't link the
new compiled object files with existing python binary. The new module
must be built together with python itself.

What I did was:

1) copy every file in /Lib, /Src, /Include from Numeric/ into the
corresponding directories in /openqnx/Python2.2/ (I put *object files
in /Object)

2) change Modules/Setup to include following (ranlib and arraytypes
don't work, but I got modules I need)

  _numpy _numpymodule.c arrayobject.c ufuncobject.c
  #ranlib ranlibmodule.c ranlib.c
  umath umathmodule.c
  multiarray multiarraymodule.c
  # arraytypes arraytypes.c
  arrayfns arrayfnsmodule.c

3) install from source by make


Thanks a lot for all your help again!

-- 
http://mail.python.org/mailman/listinfo/python-list


Numpy problem: Arrays in a list of dictionaries

2007-04-17 Thread ZMY
I am new to Numpy/Pylab, and I am trying to construct a list of
dictionaries with arrays as the items, for example:

>>> dict = {1: array([2, 3, 4]), 2: ''}
>>> list1 = []
>>> for i in range(3): list1.append(dict.copy())
...
>>> list1
[{1: array([2, 3, 4]), 2: ''}, {1: array([2, 3, 4]), 2: ''}, {1:
array([2, 3, 4]), 2: ''}]
>>> list1[0][1][1]=100
>>> list1
[{1: array([  2, 100,   4]), 2: ''}, {1: array([  2, 100,   4]), 2:
''}, {1: array([  2, 100,   4]), 2: ''}]

>>> list1[0][2]='Jack'
>>> list1
[{1: array([  2, 100,   4]), 2: 'Jack'}, {1: array([  2, 100,   4]),
2: ''}, {1: array([  2, 100,   4]), 2: ''}]

So the strings can be assigned seperately but arrays can not. What is
the problem here?

I am using python2.4+Numpy1.0.1 on Fedora

Thanks a lot in advance.

- ZMY

-- 
http://mail.python.org/mailman/listinfo/python-list