-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Open
Description
Currently, lists/tuples of Time instances are special cased in _make_array since the np.array call will give a warning for them in numpy >1.18 that being turned into object arrays is going to change. We should perhaps special-case iterable of Time so it never gets to this place. For more discussion, see #9719 (comment)
EDIT (2022-08-28): the specific case that is a problem is for a combination of scalars and arrays that, perhaps somewhat oddly, we support (i.e., we concatenate inputs):
from astropy.time import Time
t = Time('2000-01-01')
t2 = Time([t, t])
t3 = Time([t, t2])
t3
# <Time object: scale='utc' format='iso' value=['2000-01-01 00:00:00.000' '2000-01-01 00:00:00.000'
'2000-01-01 00:00:00.000']>
np.array([t, t2])
<ipython-input-5-da7e2abbe6df>:1: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
np.array([t, t2])
array([<Time object: scale='utc' format='iso' value=2000-01-01 00:00:00.000>,
<Time object: scale='utc' format='iso' value=['2000-01-01 00:00:00.000' '2000-01-01 00:00:00.000']>],
dtype=object)
np.__version__
# 1.21.5
Reactions are currently unavailable