[Numpy-discussion] why a[0][0].__mul__(a[0][0]) where a is np.array, gives 'missing 1 required positional argument'?

Robert Kern robert.kern at gmail.com
Tue Jun 27 13:30:46 EDT 2017


On Tue, Jun 27, 2017 at 2:54 AM, Larry Evans <cppljevans at suddenlink.net>
wrote:

> a=
> [[<class '__main__.ShortestNull'> 12.0]
>  [12.0 <0>]]
> a[0]=
> [<class '__main__.ShortestNull'> 12.0]
> a[0][0]=
> <class '__main__.ShortestNull'>
> Traceback (most recent call last):
>   File "shortestPathABC.py", line 123, in <module>
>     a00mul=a[0][0].__mul__(a[0][0])
> TypeError: __mul__() missing 1 required positional argument: 'other'
> Makefile:7: recipe for target 'all' failed
> make: *** [all] Error 1
> --}--cut here--
>
> I don't understand why.  Apparently, a[0][0] is not a ShortestNull
because otherwise, the .__mul__ would have the positional argument,
> 'other' equal to a[0][0].
>
> What am I missing?

> a=np.array([[ShortestNull,ShortestPath(12)],[ShortestPath(
12),ShortestNull()]],dtype=object)

You didn't instantiate ShortestNull but passed the class object instead.

--
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20170627/2c25d432/attachment.html>


More information about the NumPy-Discussion mailing list