From: Didrik P. <dp...@it...> - 2005-07-27 09:33:59
|
Le mercredi 27 juillet 2005 =E0 11:03 +0200, Dimitri D'Or a =E9crit : > Didrik, >=20 > What do you propose as a solution for this potential bug with "rank"? >=20 > I frequently use "rank" to test the dimensionality of a matrix or a vec= tor. > Should I replace it by "len(A.shape)" or import it as Nrank? >=20 > The second solution seems to be clearer for me. But then how do I have = to > import the modules? >=20 > from scipy import * > from scipy import rank as Nrank > from pylab import * >=20 > Another solution would be to import "rank" as "dim" to match the Matlab > function name. >=20 > Or >=20 > from scipy import * > from scipy import Numeric as N > from pylab import * >=20 > With this last import scheme, N.rank should be used to test dimensional= ity > while rank gives the rank of a matrix (from pylab). >=20 > Which would be the best way to import the modules? >=20 > Dimitri Here is how i've solved the problem. Considering that Matplotlib should only be used for graphical rendering and specific functions, i have constrained the import of matplotlib defining only the functions I need to use. For example, in statlib : -------------------------------------------------------------------------= ----------------------- from scipy import * from types import FunctionType from pylab import find,bar,subplot,plot,hold,ishold,axis,xlabel,ylabel,ti= tle,gca,subplots_adjust import BMEmatlab import warnings -------------------------------------------------------------------------= ----------------------- In that case, I am sure to use only the scipy rank function. If we need both functions, I do think that importing scipy rank as dim is= a good idea [1]. BUT I do think we have to go on with constrained imports of pylab functions. As an example, here is the imports for statlib : -------------------------------------------------------------------------= ----------------------- from scipy import * from scipy import rank as dim from types import FunctionType from pylab import find,bar,subplot,plot,hold,ishold,axis,xlabel,ylabel,ti= tle,gca,subplots_adjust, rank import BMEmatlab import warnings -------------------------------------------------------------------------= ----------------------- Didrik [1] If we use dim in one of the file, we need to check all the modules an= d check that dim is used everywhere. |