473,395 Members | 1,460 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,395 software developers and data experts.

numarray

I have installed python 2.3.3 on my windows machine have have ran
several programs succesfully. I have also installed numarray 1.1 for
my version of python and am now trying to create arrays using the
array command, eg
Import Numeric
a = array([1, 2, 3])
Traceback (most recent call last):
File "<pyshell#1>", line 1, in -toplevel-
a = array([1, 2, 3])
NameError: name 'array' is not defined

if I just enter
Import Numeric
I get


indicating that numarray is installed correctly.

What am I doing wrong?

Thanks in advance

Ben
Jul 18 '05 #1
4 3112
> if I just enter
Import Numeric
I get


indicating that numarray is installed correctly.

What am I doing wrong?


I doubt that that works. "Import" won't do it - it yields a syntax error.

What you meant is

import Numarray

But you have to keep in mind that importing a module that way will not put
it in the global namespace. So you have to qualify function names:

Numarray.array

Or you import them using the "from" syntax, which will bind the Numarray
names in the global namespace:

from Numarray import *
--
Regards,

Diez B. Roggisch
Jul 18 '05 #2
Diez B. Roggisch wrote:
if I just enter

>Import Numeric


I get
indicating that numarray is installed correctly.

What am I doing wrong?

I doubt that that works. "Import" won't do it - it yields a syntax error.

What you meant is

import Numarray


Actually,

import numarray

Note the case. In addition,

import Numeric

will import Numeric, not numarray. But otherwise, Diez is correct.

--
Robert Kern
rk***@ucsd.edu

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
Jul 18 '05 #3
Ben Champion wrote:
I have installed python 2.3.3 on my windows machine have have ran
several programs succesfully. I have also installed numarray 1.1 for
my version of python and am now trying to create arrays using the
array command, eg
Import Numeric
a = array([1, 2, 3])
These are two different modules: numarray is one, and Numeric is the
other. If you installed numarray, you should use:
import numarray
Also note the lowercase 'import'.

As another poster pointed out, the 'array' function is not in the global
namespace. You have to use:
a = numarray.array([1,2,3])
Or alternatively:
from numarray import *
a = array([1,2,3])


What I usually do, since Numeric and numarray are mostly compatible is:

try:
import numarray as N
except ImportError:
import Numeric as N

a = N.array([1,2,3])

This way you'll use numarray if it is available, otherwise you fallback
to Numeric.
Jul 18 '05 #4
>
Actually,

import numarray

Note the case. In addition,

import Numeric

will import Numeric, not numarray. But otherwise, Diez is correct.


I actually _used_ Numeric as that is what is installed on my machine :) So I
couldn't verify that Numarray is not working...

--
Regards,

Diez B. Roggisch
Jul 18 '05 #5

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

Similar topics

0
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out...
3
by: Alexander Schwaigkofler | last post by:
Hi! I have the following problem with numarray. I read the install.txt manual, but it doesn't already work. OS: Microsoft Windows 2000 python: Python 2.2.3 (#42, May 30 2003, 18:12:08) on...
4
by: Marco Bubke | last post by:
Hi I have tried to include numarray in Pyrex but I get allways this error: Traceback (most recent call last): File "gears.py", line 9, in ? import gl File...
4
by: Marco Bubke | last post by:
Hi Ok, I get a reproduceable seqmentation fault. Ok, fist the code: cdef NumArray array_to_double(NumArray array): # maybe here is memoty leak! cdef NumArray flat_array_obj flat_array_obj...
2
by: Marc Schellens | last post by:
Following the NumPy documentation, I took over some C code, but run into an error. Does anybody have a suggestion? Thanks, marc gdlpython.cpp:225: `PyArray_Type' undeclared (first use this...
3
by: SunX | last post by:
I tried to initialize a float point array by: import numarray xur = numarray.fromfunction(lambda x,y,z:x*y*z, (2, 2, 2)) but I ended up with an integer array even though x, y, and z are all...
3
by: Mizrandir | last post by:
I'd like to subclass numarray's array. I'd like to add some methods and override others like __init__. I don't know how to do this and haven't found help searching the manual or the web, can...
0
by: andrewfelch | last post by:
Below is the code to/from Boolean arrays and Unsigned integers. On my Pentium 4, functions such as "bitwise_and" are 32 times faster when run on 32-bit integers instead of the...
10
by: Bryan | last post by:
hi, what is the difference among numeric, numpy and numarray? i'm going to start using matplotlib soon and i'm not sure which one i should use. this page says, "Numarray is a...
0
by: robert | last post by:
just a note - some speed comparisons : 0.60627370238398726 0.42836673376223189 0.36965815487747022 0.016557970357098384 0.15692469294117473 0.01951756438393204
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...

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.