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

Subclassing Numeric arrays.

The Numeric docs state that "Subclassing Numeric arrays is not
possible due to a limitation of Python."

What is this limitation? My first guess is that it is the unsbclassability
of built-in types, which was addressed by the introduction of
new-style classes ... and, indeed, Numeric.ArrayType.__bases__ lists
object, so it looks like a new style class and therefore it seems to
me that it should be subclassable. Yet, if I try to subclass it, I get
told that it is not an acceptable base type.

Now, there is also a UserArray module in the Numeric distribution,
which, supposedly provides a subclassable analogue of the Numeric
arrays. But attempts to subclass it give an identical error message.

So, what am I missing ?
Jul 18 '05 #1
1 1744
Jacek Generowicz <ja**************@cern.ch> writes:
[...]
Now, there is also a UserArray module in the Numeric distribution,
which, supposedly provides a subclassable analogue of the Numeric
arrays. But attempts to subclass it give an identical error message.

So, what am I missing ?


I suppose you subclassed UserArray.array which is the same function as
Numeric.array. Subclassing UserArray.UserArray works:
import UserArray
class MyArray(UserArray.UserArray): pass .... import Numeric
UserArray.array is Numeric.array

True

--

=*= Lukasz Pankowski =*=
Jul 18 '05 #2

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. ...
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...
2
by: BJörn Lindqvist | last post by:
A problem I have occured recently is that I want to subclass builtin types. Especially subclassing list is very troublesome to me. But I can't find the right syntax to use. Take for example this...
3
by: Peter Olsen | last post by:
I want to define a class "point" as a subclass of complex. When I create an instance sample = point(<arglist>) I want "sample" to "be" a complex number, but with its real and imaginary...
5
by: George Sakkis | last post by:
What's the fastest and most elegant equivalent of zip() in Numeric/Numarray between two equally sized 1D arrays ? That is, how to combine two (N,)-shaped arrays to one (N,2) (or (2,N)) shaped ? I...
3
by: daniel.neilson | last post by:
I have two one-dimensional Numeric arrays, and I need to know the indices in the second array of elements from the first. so if i had: a=array() b=array() i want a function match that does...
1
by: Pierre | last post by:
Folks, I'm pretty new to OOP, so I still have problems with inheritance and delegation. I defined 2 Numeric MaskedArray subclasses, as: class Temp(MA,object): def __init__(self,data): self =...
7
by: Sheldon | last post by:
Hi, I have the following loop that I think can be written to run faster in Numeric. I am currently using Numeric. range_va = main.xsize= 600 main.ysize= 600 #msgva is an (600x600) Numeric...
6
by: Sheldon | last post by:
Hi, I am trying to build a large array using concatenate function in python. So as I loop over the number of arrays, of which there are 12 (4 down and 3 across), I create 3 long arrays by...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.