-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Infer dims & coords from xarray
variables passed to pm.Data
#5791
Comments
determine_coords
to infer dims & coords from xarray
variables passed to pm.Data
xarray
variables passed to pm.Data
edit: this comment is only for the df part of the function |
I suppose you're referring to these lines, which I recently edited in #5763 exactly to prepare for this issue. Lines 511 to 515 in b5a5b56
But yes, you captured the gist of it. We'll just have to remember to not override non- The |
is this still open? I'd like to take a look at this |
Yes, feel free to take over |
@michaelosthege , could you briefly explain the naming convention here? Because in data.py it seems like we have a bunch of classes, named conventionally with CamelCase, but then we have standalone methods named with nouns, that initialize the "Data" objects. I know it's not meant to be OO but I can't seem to get a hold of which style it goes for |
Yes, so the Technically, since v4 the >>> import pymc as pm
>>> with pm.Model():
... n = pm.Normal("n")
...
>>> isinstance(n, pm.Normal)
False
>>> type(n).__mro__
(<class 'pytensor.tensor.var.TensorVariable'>, <class 'pytensor.tensor.var._tensor_py_operators'>,
<class 'pytensor.graph.basic.Variable'>, <class 'pytensor.graph.basic.Node'>,
<class 'pytensor.graph.utils.MetaObject'>, <class 'typing.Generic'>,
<class 'object'>)
>>> This is because of some There's a still open discussion about refactoring this to actual functions (like |
Thanks! Also since the data.py has changed quite a lot since last updates on this issue I'll just re-write the whole functionality, from what I can see we're down to 200 lines of code less than what it was back then, and I guess it's just easier than adapting the legacy version of the file |
* added dim inference from xarray, deprecation warning and unittest for the new feature * fixed typo in warning * fixed accidental quotation around dim * fixed failing assertions * found and fixed cause of the failing test * changed the coords assertion according to suggested form * fixing mypy type missmatch * working on getting the test to work * removed typecasting to string on dim_name, was causing the mypy to fail * took care locally of mypy errors * Typo/formatting fixes --------- Co-authored-by: Michal Raczycki <[email protected]> Co-authored-by: Michael Osthege <[email protected]>
Description
The internal function
pm.data.determine_coords
is called whenpm.Data(..., export_index_as_coords=True)
is invoked.Right now it can only infer
coords
frompd.Series
, orpd.DataFrame
, but it would be nice (and actually quite simple) to do the same forxarray.DataArray
variables.After all, the
pm.Data
variables becomexarray.DataArray
again, when they're stored in theInferenceData
.Deliverables
dims
from named pandas indexesdims
from DataArrayscoords
from DataArraysexport_index_as_coords
toinfer_dims_and_coords
.The text was updated successfully, but these errors were encountered: