Merged
Conversation
Member
Author
|
besides expected errors there is one that comes from mypy |
ricardoV94
reviewed
Aug 13, 2024
Member
Author
|
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 |
Closed
Member
Author
|
@ricardoV94 how are these tests are supposed to pass? pytensor/tests/scalar/test_loop.py Line 198 in 4d0103b Why did they pass before? |
ricardoV94
reviewed
Aug 13, 2024
Member
Author
ricardoV94
reviewed
Aug 14, 2024
ricardoV94
reviewed
Aug 14, 2024
11 tasks
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
|
Member
|
What's with mypy? I guess it's not related, but can you fix it? |
Member
|
@ferrine can you clean the commits into just 2:
|
Member
Author
|
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 <28983449+ricardoV94@users.noreply.github.com> fix test add a clarifying comment to checking nan fix: bool is deprecated in numpy deps: bound scipy version improve test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Related Issue
Checklist
Type of change