[Numpy-discussion] RE: [SciPy-user] [numarray issue] nonzero? Comments on new name solicited

Perry Greenfield perry at stsci.edu
Wed May 7 13:20:20 EDT 2003


Some one suggested that numarray ditch compatibility in this 
area and "do what's right". Namely he suggested that

nonzero --> where
where   --> select

I have to agree that these are far better names than the
existing ones. But compatibilty is important. So what to do?

Here's one suggestion; I'm curious what people think about
this solution. Nothing prevents us from having a module that
people would import for Numeric compatibilty and a different one
that has somewhat different behavior. Before people start throwing
rocks (when you finish reading you can throw them ;-) and say "didn't
you say that customized versions of Numeric or numarray were a 
bad idea?" Yes I did. But I think some customizations are bad
and perhaps some are acceptable.

What I objected to was having array objects with different behavior
Since array objects may be passed between modules that assume
different behaviors, that will cause all sorts of problems
(e.g., module A was written assuming array slices are views
but is passed an array that produces a copy when sliced).

But is there any harm when all that is different are module functions?
These are unlikely to be passed from one module to another and thus
the customization is localized to the user modules. Suppose that
the Numeric-compatible version defines "where" and "nonzero" to have
their current meanings and numarray uses "select", and "where" 
respectively.

There is one case that could arise that might cause problems. About
the only time a problem would occur is if someone did 

from numarray import *
from B import *

And in B.py

from Numericcompatible import *

in which case the numarray "where" is replaced by the Numeric "where"

I don't know if this is a strong enough reason to support two different
flavors, but what do people think of taking this approach? Are there
any other module functions that would benefit from such changes in name
or behavior (For example, the axis order issue)?

Perry Greenfield




More information about the NumPy-Discussion mailing list