-
Notifications
You must be signed in to change notification settings - Fork 119
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
Unpin scipy upper version #972
Conversation
besides expected errors there is one that comes from mypy
|
I also think of simplifying this part of code, it has a lot of redundant logic that is already managed by simple diff --git a/pytensor/tensor/elemwise.py b/pytensor/tensor/elemwise.py
index de966f1a7..a0892dfd0 100644
--- a/pytensor/tensor/elemwise.py
+++ b/pytensor/tensor/elemwise.py
@@ -767,31 +767,17 @@ class Elemwise(OpenMPOp):
for i, (variable, storage, nout) in enumerate(
zip(variables, output_storage, node.outputs)
):
- if getattr(variable, "dtype", "") == "object":
- # Since numpy 1.6, function created with numpy.frompyfunc
- # always return an ndarray with dtype object
- variable = np.asarray(variable, dtype=nout.dtype)
+
+ variable = np.asarray(variable, dtype=nout.dtype)
if i in self.inplace_pattern:
odat = inputs[self.inplace_pattern[i]]
odat[...] = variable
storage[0] = odat
- # Sometimes NumPy return a Python type.
- # Some PyTensor op return a different dtype like floor, ceil,
- # trunc, eq, ...
- elif not isinstance(variable, np.ndarray) or variable.dtype != nout.dtype:
- variable = np.asarray(variable, nout.dtype)
- # The next line is needed for numpy 1.9. Otherwise
- # there are tests that fail in DebugMode.
- # Normally we would call pytensor.misc._asarray, but it
- # is faster to inline the code. We know that the dtype
- # are the same string, just different typenum.
- if np.dtype(nout.dtype).num != variable.dtype.num:
- variable = variable.view(dtype=nout.dtype)
- storage[0] = variable
+ storage[0] = variable
# numpy.real return a view!
- elif not variable.flags.owndata:
+ if not variable.flags.owndata:
storage[0] = variable.copy()
- else:
- storage[0] = variable |
@ricardoV94 how are these tests are supposed to pass? pytensor/tests/scalar/test_loop.py Line 198 in 4d0103b
Why did they pass before? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #972 +/- ##
=======================================
Coverage 81.69% 81.69%
=======================================
Files 182 182
Lines 47585 47591 +6
Branches 11584 11586 +2
=======================================
+ Hits 38875 38880 +5
Misses 6518 6518
- Partials 2192 2193 +1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ferrine
What's with mypy? I guess it's not related, but can you fix it? |
@ferrine can you clean the commits into just 2:
|
Yes, will do soon |
fix: cast to elemwise outputs to their respective dtypes fix: Relax scipy dependency, should work in both cases style: black wrap with asarray fix: make elemwise test check against dtype in the graph fix scalar issues Update pytensor/scalar/basic.py Co-authored-by: Ricardo Vieira <[email protected]> fix test add a clarifying comment to checking nan fix: bool is deprecated in numpy deps: bound scipy version improve test
Description
Related Issue
Checklist
Type of change