Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2843 +/- ##
==========================================
- Coverage 78.97% 78.97% -0.01%
==========================================
Files 248 248
Lines 50901 50936 +35
Branches 4395 4404 +9
==========================================
+ Hits 40199 40226 +27
- Misses 9904 9909 +5
- Partials 798 801 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
f2e36fa to
171969e
Compare
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
018e9d3 to
10eac67
Compare
FabioLuporini
left a comment
There was a problem hiding this comment.
there's quite a few changes here, but not as many new tests covering them?
| for i in self._args_diff))) | ||
| if not self._args_diff: | ||
| return DimensionTuple() | ||
| # Get indices of all args and merge them |
There was a problem hiding this comment.
nitpicking: blank line
| for a in self._args_diff: | ||
| for d, i in a.indices.getters.items(): | ||
| mapper.setdefault(d, []).append(i) | ||
| # Filter unique indices |
There was a problem hiding this comment.
nitpicking: blank line
| # Filter unique indices | ||
| mapper = {k: v[0] if len(v) == 1 else tuple(filter_ordered(v)) | ||
| for k, v in mapper.items()} | ||
| return DimensionTuple(*mapper.values(), getters=tuple(mapper.keys())) |
There was a problem hiding this comment.
nitpicking: blank line
There was a problem hiding this comment.
nitpicking: can just be getters=tuple(mapper)
| def dimensions(self): | ||
| return tuple(filter_ordered(flatten(getattr(i, 'dimensions', ()) | ||
| for i in self._args_diff))) | ||
| if not self._args_diff: |
There was a problem hiding this comment.
why do we need these two lines? highest_priority(self).dimensions should already return it, or there's something non-consistent about it
There was a problem hiding this comment.
Because a generic Differentiable does not necessarily has an _args_diff. For. example 1/h_x is a Differentiable but it doesn't have any argument that is Differentiable
There was a problem hiding this comment.
but the property is still there, it's not that you are exposing yourself to an AttributeError... so (1/h_x)._args_diff will return the empty tuple and it should just be fine no?
There was a problem hiding this comment.
An empty tuple doesn't have a .staggered or .dimension property. And on top of it (1/h_x)._args_diff will return 1/h_x which wiull be an infinite recursion
|
|
||
| @cached_property | ||
| def staggered(self): | ||
| if not self._args_diff: |
There was a problem hiding this comment.
same story as before, I think
... unless I'm missing something
| def highest_priority(DiffOp): | ||
| if not DiffOp._args_diff: | ||
| return DiffOp | ||
| # We want to get the object with highest priority |
| @@ -475,12 +487,19 @@ def has_free(self, *patterns): | |||
|
|
|||
|
|
|||
| def highest_priority(DiffOp): | |||
There was a problem hiding this comment.
small letters diff_op as it's an instance
|
|
||
| @interp_for_fd.register(Mul) | ||
| def _(expr, x0, **kwargs): | ||
| # For a expression (e.g Mul or Add), we interpolate the whole expression |
There was a problem hiding this comment.
"an expression"
so the comment says "Mul or Add" but the dispatcher only targets Mul. Is it expected?
| # Filter unique indices | ||
| mapper = {k: v[0] if len(v) == 1 else tuple(filter_ordered(v)) | ||
| for k, v in mapper.items()} | ||
| return DimensionTuple(*mapper.values(), getters=tuple(mapper.keys())) |
There was a problem hiding this comment.
nitpicking: can just be getters=tuple(mapper)
|
|
||
| # Split args between those that need interp and those that don't | ||
| def test0(a): | ||
| return all(a.indices[d] is i for d, i in x0.items() if d in a.dimensions) |
| f"'{expr}' must be of type Differentiable, not {type(expr)}" | ||
| ) from None | ||
| except Exception as e: | ||
| raise type(e)(f"Error while computing finite-difference for expr={expr}: " |
There was a problem hiding this comment.
Reporting the type of expr here would make this error message more useful
There was a problem hiding this comment.
Not sure what you mean the message is raise type(e) ... that's type already
10eac67 to
3fc5b91
Compare
No description provided.