-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
Describe the issue:
Astro 330 is a course given at Harvard (?) based on a series of labs. lab5 is dedicated to find stars velocities based on their measured spectra. The lab comes with a big .fits file of precooked stars spectra (i.e. not the raw data). from it 3 specific stars are chosen based on some keys (line numbers). These spectra are some complicated objects with many columns (like a pandas dataframe).
Extracting some specific x, y vectors (actually wavelength and flux) is simple:
x = star_data['OPT_WAVE'] and y = star_data['OPT_COUNTS']
and they are actually np.arrays. For example:
key = 135
star_data = stars[key]
type(star_data['OPT_WAVE'])
numpy.ndarray
but trying to put them into a container in a model, like:
with pm.Model() as model:
# Container
x = star_data['OPT_WAVE']
x_data = pm.Data("x_data", x)
explodes, giving some hermetically (at least for me) error:
TypeError: Unsupported dtype for TensorType: >f8
Reproduceable code example:
with pm.Model() as model:
# Container
x = star_data['OPT_WAVE']
x_data = pm.Data("x_data", x)
Error message:
KeyError Traceback (most recent call last)
File d:\miniconda3\Lib\site-packages\pytensor\tensor\type.py:306, in TensorType.dtype_specs(self)
305 try:
--> 306 return self.dtype_specs_map[self.dtype]
307 except KeyError:
KeyError: '>f8'
During handling of the above exception, another exception occurred:
TypeError Traceback (most recent call last)
Cell In[40], line 4
1 with pm.Model() as model:
2 # Container
3 x = star_data['OPT_WAVE']
----> 4 x_data = pm.Data("x_data", x)
File d:\miniconda3\Lib\site-packages\pymc\data.py:325, in Data(name, value, dims, coords, infer_dims_and_coords, model, **kwargs)
319 if isinstance(arr, np.ma.MaskedArray):
320 raise NotImplementedError(
321 "Masked arrays or arrays with `nan` entries are not supported. "
322 "Pass them directly to `observed` if you want to trigger auto-imputation"
323 )
--> 325 x = pytensor.shared(arr, name, **kwargs)
327 if isinstance(dims, str):
328 dims = (dims,)
File d:\miniconda3\Lib\site-packages\pytensor\compile\sharedvalue.py:202, in shared(value, name, strict, allow_downcast, **kwargs)
199 raise TypeError("Shared variable values can not be symbolic.")
201 try:
--> 202 var = shared_constructor(
203 value,
204 name=name,
205 strict=strict,
206 allow_downcast=allow_downcast,
207 **kwargs,
208 )
209 add_tag_trace(var)
210 return var
File d:\miniconda3\Lib\functools.py:929, in singledispatch.<locals>.wrapper(*args, **kw)
926 if not args:
927 raise TypeError(f'{funcname} requires at least '
928 '1 positional argument')
--> 929 return dispatch(args[0].__class__)(*args, **kw)
File d:\miniconda3\Lib\site-packages\pytensor\tensor\sharedvar.py:87, in tensor_constructor(value, name, strict, allow_downcast, borrow, shape, broadcastable)
84 if shape is None:
85 shape = (None,) * value.ndim
---> 87 type = TensorType(value.dtype, shape=shape)
89 return TensorSharedVariable(
90 type=type,
91 value=np.array(value, copy=(not borrow)),
(...) 94 name=name,
95 )
File d:\miniconda3\Lib\site-packages\pytensor\tensor\type.py:122, in TensorType.__init__(self, dtype, shape, name, broadcastable)
117 raise ValueError(
118 f"TensorType broadcastable/shape must be a boolean, integer or None, got {type(s)} {s}"
119 )
121 self.shape = tuple(parse_bcast_and_shape(s) for s in shape)
--> 122 self.dtype_specs() # error checking is done there
123 self.name = name
124 self.numpy_dtype = np.dtype(self.dtype)
File d:\miniconda3\Lib\site-packages\pytensor\tensor\type.py:308, in TensorType.dtype_specs(self)
306 return self.dtype_specs_map[self.dtype]
307 except KeyError:
--> 308 raise TypeError(
309 f"Unsupported dtype for {self.__class__.__name__}: {self.dtype}"
310 )
TypeError: Unsupported dtype for TensorType: >f8
PyMC version information:
'5.25.1'
Context for the issue:
No response