[Numpy-discussion] how can one catch a multiarray.error

josef.pktd at gmail.com josef.pktd at gmail.com
Mon Jun 1 23:31:22 EDT 2009


On Mon, Jun 1, 2009 at 11:27 PM, Charles R Harris
<charlesr.harris at gmail.com> wrote:
>
>
> On Mon, Jun 1, 2009 at 8:43 PM, Robert Kern <robert.kern at gmail.com> wrote:
>>
>> On Mon, Jun 1, 2009 at 21:37,  <josef.pktd at gmail.com> wrote:
>> > how do we catch a multiarray.error in a try except clause?
>> >
>> > e.g.
>> >>>> np.argmin([])
>> > Traceback (most recent call last):
>> >  File "<pyshell#147>", line 1, in <module>
>> >    np.argmin([])
>> >  File
>> > "C:\Programs\Python25\Lib\site-packages\numpy\core\fromnumeric.py",
>> > line 631, in argmin
>> >    return _wrapit(a, 'argmin', axis)
>> >  File
>> > "C:\Programs\Python25\Lib\site-packages\numpy\core\fromnumeric.py",
>> > line 37, in _wrapit
>> >    result = getattr(asarray(obj),method)(*args, **kwds)
>> > multiarray.error: attempt to get argmax/argmin of an empty sequence
>>
>> try:
>>   ...
>> except numpy.core.multiarray.error:
>>   ...
>>
>> Unfortunately, that is still a string exception. We should change that.
>
> All the string exception in the core/src are gone. Some remain in
>
> lib/src/_compiled_base.c
> numarray/_capi.c
> fft/fftpack_litemodule.c
> f2py (tons of them)
>
> I will open a ticket.
>

I'm using the official windows installer (I think)
>>> np.version.version
'1.3.0'

I was just surprised that "except Exception" didn't catch the
multiarray.error, and I didn't find a reference/location for it.

Josef



More information about the NumPy-Discussion mailing list