Conversation
majosm
commented
Jun 28, 2022
Comment on lines
-1290
to
+1298
| A: Optional[Union[Real, np.ndarray]] = None, # noqa: N803 | ||
| b: Optional[Union[Real, np.ndarray]] = None): | ||
| A: Optional[Union[np.generic, np.ndarray]] = None, # noqa: N803 | ||
| b: Optional[Union[np.generic, np.ndarray]] = None): | ||
| """Apply the affine map :math:`f(x) = A x + b` to the geometry of *mesh*.""" | ||
|
|
||
| if isinstance(A, Real): | ||
| if A is not None and not isinstance(A, np.ndarray): | ||
| A = np.diag([A] * mesh.ambient_dim) # noqa: N806 | ||
|
|
||
| if isinstance(b, Real): | ||
| if b is not None and not isinstance(b, np.ndarray): |
Collaborator
Author
There was a problem hiding this comment.
@inducer I had a little trouble here: the type checking for the numpy functions doesn't like Real. I get this error with the original code:
meshmode/mesh/processing.py:1295: error: Argument 1 to "diag" has incompatible type "List[Real]"; expected "Union[_SupportsArray[dtype[Any]], Sequence[_SupportsArray[dtype[Any]]], Sequence[Sequence[_SupportsArray[dtype[Any]]]], Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]], Sequence[Sequence[Sequence[Sequence[_SupportsArray[dtype[Any]]]]]]]" [arg-type]
The change fixes it, but I'm not sure if there's something more specific I can use instead of np.generic (or if this can be written in a different way to avoid the issue).
Owner
There was a problem hiding this comment.
I think this is OK for now. Mypy is still at war with Python's numerical tower, cf. python/mypy#3186 for example. I expect that this will get better with time.
Owner
|
LGTM, thanks! (And I've marked mypy required.) |
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.
Splitting this out from #308 to keep the discussion separate.