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

Error in examples/causal_inference/regression_discontinuity.ipynb #725

Open
wd60622 opened this issue Nov 15, 2024 · 0 comments
Open

Error in examples/causal_inference/regression_discontinuity.ipynb #725

wd60622 opened this issue Nov 15, 2024 · 0 comments

Comments

@wd60622
Copy link

wd60622 commented Nov 15, 2024

This could be something with Windows

───────────────────────────────────── Error running examples/causal_inference/regression_discontinuity.ipynb ─────────────────────────────────────

---------------------------------------------------------------------------
Exception encountered at "In [10]":
---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pytensor/link/basic.py:102, in Container.__set__(self, value)
    100 try:
    101     # Use in-place filtering when/if possible
--> 102     self.storage[0] = self.type.filter_inplace(
    103         value, self.storage[0], **kwargs
    104     )
    105 except NotImplementedError:

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pytensor/graph/type.py:128, in Type.filter_inplace(self, value, storage, strict,
allow_downcast)
    109 """Return data or an appropriately wrapped/converted data by converting it in-place.
    110
    111 This method allows one to reuse old allocated memory.  If this method
   (...)
    126 NotImplementedError
    127 """
--> 128 raise NotImplementedError()

NotImplementedError:

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
Cell In[10], line 8
      6 # posterior prediction (see technical note above)
      7 with model:
----> 8     pm.set_data({"x": _x, "treated": _treated})
      9     ppc = pm.sample_posterior_predictive(idata, var_names=["mu", "y"])
     11 # plotting

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pymc/model/core.py:2092, in set_data(new_data, model, coords)
   2089 model = modelcontext(model)
   2091 for variable_name, new_value in new_data.items():
-> 2092     model.set_data(variable_name, new_value, coords=coords)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pymc/model/core.py:1161, in Model.set_data(self, name, values, coords)
   1158         # store it as tuple for immutability as in add_coord
   1159         self._coords = tuple(new_coords)
-> 1161 shared_object.set_value(values)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pytensor/compile/sharedvalue.py:134, in SharedVariable.set_value(self,
new_value, borrow)
    132     self.container.value = new_value
    133 else:
--> 134     self.container.value = copy.deepcopy(new_value)

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pytensor/link/basic.py:106, in Container.__set__(self, value)
    102         self.storage[0] = self.type.filter_inplace(
    103             value, self.storage[0], **kwargs
    104         )
    105     except NotImplementedError:
--> 106         self.storage[0] = self.type.filter(value, **kwargs)
    108 except Exception as e:
    109     e.args = (*e.args, f'Container name "{self.name}"')

File ~/micromamba/envs/pymc-examples/lib/python3.11/site-packages/pytensor/tensor/type.py:204, in TensorType.filter(self, data, strict,
allow_downcast)
    195     if up_dtype != self.dtype:
    196         err_msg = (
    197             f"{self} cannot store a value of dtype {data.dtype} without "
    198             "risking loss of precision. If you do not mind "
   (...)
    202             f'"function". Value: "{data!r}"'
    203         )
--> 204         raise TypeError(err_msg)
    205 elif (
    206     allow_downcast is None
    207     and isinstance(data, float | np.floating)
   (...)
    210     # Special case where we allow downcasting of Python float
    211     # literals to floatX, even when floatX=='float32'
    212     data = _asarray(data, self.dtype)

TypeError: ('Vector(bool, shape=(?,)) cannot store a value of dtype float64 without risking loss of precision. If you do not mind this loss, you
can: 1) explicitly cast your data to bool, or 2) set "allow_input_downcast=True" when calling "function". Value: "array([0., 0., 0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0.,
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n
0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,\n       0., 0., 0., 0., 0., 0., 0.])"', 'Container name "treated"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant