Skip to content

numpy-dev using a dtype with a subarray field is deprecated #10815

@pllim

Description

@pllim

Description

@astrofrog reported DeprecationWarning: using a dtype with a subarray field is deprecated. warnings using numpy-dev in v4.0.x (example log). Since v4.0.x is installing numpy from master, while master installs from "nightly" (i.e., weekly) wheel, we won't see it until numpy's wheel is updated.

Caused by numpy/numpy#17419

Steps to Reproduce

I think this might trigger the warning:

>>> import numpy as np
>>> from astropy.io.votable import converters, tree
>>> config = {'verify': 'exception'}
>>> field = tree.Field(None, name='c', datatype='floatComplex', arraysize='2x3*', config=config)
>>> c = converters.get_converter(field, config=config)
>>> c._base.format
'(2,)c8'
>>> default = np.array([], dtype=c._base.format)  # Warning?
E       DeprecationWarning: using a dtype with a subarray field is deprecated.
This can lead to inconsistent behaviour due to the resulting dtype being different from the input dtype.
You may try to use `dtype=dtype.base`, which should give the same result for most inputs,
but does not guarantee the output dimensions to match the subarray ones.  (Deprecated NumPy 1.20)

In this case, c._base.format is a string, so I am not sure what dtype.base means in this context. @mhvk , any advise?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions