[IPython-user] Parsing issue (maybe).
Andrea Riciputi
ariciputi at pito.com
Thu Jan 12 13:01:45 CST 2006
Hi all,
I've a problem here with ipython 0.6.15. I don't know if the new
version (0.7.0) still exhibits the same problem though. Here it is
the problem. I've defined a class to mimick mathematical functions
and in that class I've defined the special method __and__ to check if
2 functions have the same dimensionality. Here it is a meaningfull
excerpt:
In [1]: import Functions
In [2]: x = Numeric.arange(10)
In [3]: y = Numeric.arange(5)
In [4]: z1 = x[:,Numeric.NewAxis] + y
In [5]: z2 = x[:,Numeric.NewAxis] - y
In [6]: foo = Functions.Function([x,y], z1)
In [7]: bar = Functions.Function([x,y], z2)
In [8]: foo & bar
------> foo(& bar)
------------------------------------------------------------
File "<console>", line 1
foo(& bar)
^
SyntaxError: invalid syntax
In [9]: (foo) & (bar)
Out[9]: True
otherwise if I try
In [1]: foo = 0
In [2]: bar = 1
In [3]: foo & bar
Out[3]: 1
The same piece of code using standard python works correctly:
>>> import Numeric as nu
>>> import Functions
>>> x = nu.arange(10)
>>> y = nu.arange(5)
>>> z1 = x[:,nu.NewAxis] + y
>>> z2 = x[:,nu.NewAxis] - y
>>> foo = Functions.Function([x,y],z1)
>>> bar = Functions.Function([x,y],z2)
>>> foo & bar
True
It seems that there is a problem with the command line in ipython.
Any comments?
Thanks,
Andrea.
More information about the IPython-user
mailing list