Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"data type not understood" with readonly array argument #3844

Closed
batterseapower opened this issue Mar 8, 2019 · 3 comments · Fixed by #3845
Closed

"data type not understood" with readonly array argument #3844

batterseapower opened this issue Mar 8, 2019 · 3 comments · Fixed by #3845
Labels

Comments

@batterseapower
Copy link
Contributor

Reporting a bug

The following program should succeed, because astype makes a copy of its argument:

@nb.jit()
def numba_astype(xs):
    ys = xs.astype(nb.float32)
    ys[0] = 1.0
    return ys

xs = np.array([1.0], dtype='f4')
xs.flags.writeable = False
numba_astype(xs)

In fact it just throws TypeError: data type not understood. (This might be related to the fact that the type of the array returned by astype is still marked readonly if the inital array is readonly - i.e. the readonly flag is not being cleared.)

stuartarchibald added a commit to stuartarchibald/numba that referenced this issue Mar 8, 2019
As title. `np.ndarray.astype` always returns a mutable array.

Fixes numba#3844
@stuartarchibald
Copy link
Contributor

Thanks for the report. I can reproduce. Fixed in #3845

@batterseapower
Copy link
Contributor Author

That was impressively fast. Thanks!

@stuartarchibald
Copy link
Contributor

No problem!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants