+
Skip to content

add error message for function.Array.cast of numpy object array #635

@joostvanzwieten

Description

@joostvanzwieten

The following example

from nutils.function import Array
import numpy
Array.cast(numpy.array(['a', 'b'], dtype=object))

gives the following error message

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
    Array.cast(numpy.array(['a', 'b'], dtype=object))
  File "<stdin>", line 144, in cast
    value = _Constant(value)
  File "<stdin>", line 752, in __init__
    self._value = types.arraydata(value)
  File "<stdin>", line 573, in __call__
    return args[0].__new__(*args, **kwargs)
  File "<stdin>", line 747, in __new__
    dtype = dict(b=bool, u=int, i=int, f=float, c=complex)[array.dtype.kind]
KeyError: 'O'

This is not really helpful. Consider adding a proper error message informing the caller that object arrays are not supported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载