Hello - When I am doing from numpy import * It does not import the min() function, but when I do from numpy import min it does import the min() function Does that make sense? I know, I should probably use a.min() rather than min(a), but why does min() not get imported on an import * ? Thanks, Mark
On Tue, Sep 18, 2007 at 10:33:29AM -0000, mark wrote:
Does that make sense? I know, I should probably use a.min() rather than min(a), but why does min() not get imported on an import * ?
Because min isn't in numpy.__all__. Python imports only identifiers listed in __all__ if __all__ is present. Gaël
On Tue, 18 Sep 2007 13:07:29 +0200, Gael Varoquaux
On Tue, Sep 18, 2007 at 10:33:29AM -0000, mark wrote:
Does that make sense? I know, I should probably use a.min() rather than min(a), but why does min() not get imported on an import * ?
Because min isn't in numpy.__all__. Python imports only identifiers listed in __all__ if __all__ is present.
The rationale behind this is to prevent you from overwriting the built-in max function. Sooner or later that would cause trouble. Use import numpy as N N.max(...) or, as you said, import max explicitly. Cheers Stéfan
stefan wrote:
On Tue, 18 Sep 2007 13:07:29 +0200, Gael Varoquaux
wrote: Does that make sense? I know, I should probably use a.min() rather than min(a), but why does min() not get imported on an import * ? Because min isn't in numpy.__all__. Python imports only identifiers
On Tue, Sep 18, 2007 at 10:33:29AM -0000, mark wrote: listed in __all__ if __all__ is present.
The rationale behind this is to prevent you from overwriting the built-in max function. Sooner or later that would cause trouble.
Use
import numpy as N N.max(...)
or, as you said, import max explicitly.
Or use numpy.amin and numpy.amax, which are included in numpy.__all__, just as you use numpy.arange in place of range. Eric
Thanks guys. I personally like the amin, amax idea best. But that is just me, Mark
or, as you said, import max explicitly.
Or use numpy.amin and numpy.amax, which are included in numpy.__all__, just as you use numpy.arange in place of range.
Eric _______________________________________________ Numpy-discussion mailing list Numpy-discuss...@scipy.orghttp://projects.scipy.org/mailman/listinfo/numpy-discussion
participants (4)
-
Eric Firing
-
Gael Varoquaux
-
mark
-
stefan