-
Notifications
You must be signed in to change notification settings - Fork 17
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
Return device scalars from nodal_sum
/nodal_min
/nodal_max
#170
Return device scalars from nodal_sum
/nodal_min
/nodal_max
#170
Conversation
fb65e9c
to
8b00650
Compare
2609903
to
7a1b391
Compare
6902796
to
e5f8d9d
Compare
e5f8d9d
to
ea69dec
Compare
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 for doing this @majosm --- I saw no major issues after scanning through this PR. How should we proceed forward with respect to illinois-ceesd/mirgecom#518? Probably merge this first, followed immediately with the mirgecom PR? If so, let's coordinate so we can time this right.
Yeah, I think we would merge this, then remove the |
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.
Left a couple of comments for some things I'm not quite sure about, but overall 👍!
I haven't been keeping up with grudge
and maybe some of them aren't relevant, so feel free to ignore as needed!
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.
Sorry @majosm but I sort of had a change of heart with regard to type annotations using Any
grudge/dt_utils.py
Outdated
@@ -158,7 +159,7 @@ def dt_non_geometric_factors( | |||
|
|||
@memoize_on_first_arg | |||
def h_max_from_volume( | |||
dcoll: DiscretizationCollection, dim=None, dd=None) -> float: | |||
dcoll: DiscretizationCollection, dim=None, dd=None) -> Any: |
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.
Actually I feel like type annotating with Any
is not very helpful. In fact, I feel it just sorta raises more questions. I'd rather just remove the return annotation (at least for h_max
and h_min
here).
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.
Maybe try a DeviceScalar = Any
type alias?
https://www.python.org/dev/peps/pep-0484/#type-aliases
Mypy shouldn't be bothered, but I don't know if it'll render nicely in Sphinx.
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.
You should be able to trick sphinx into it too using autodoc_type_aliases
.
That seems to require from __future__ import annotations
, which is a >=3.7 thing, so probably needs to be hidden behind an if BUILDING_DOCS
or something?
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.
from __future__ import annotations
should be unnecessary if you make the annotation a string. (I think)
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.
What about using the ArrayT
type hint from arraycontext? Something like: majosm@0e1be13?
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.
From the point of view of the type checker, they're probably interchangable here. Using a single unbound TypeVar
in a function definition doesn't actually constrain anything, you need something like
def function(x: T) -> Sequence[T]: ...
i.e. it should tie in more than one input + output, for it to do something. (at least that's my understanding of it)
Since this is mostly for documentation at this point, either one is fine from my point of view (at least can't think of any particular downside?)
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.
Added the DeviceScalar
thing directly in arraycontext
in inducer/arraycontext#117, since other code may want to use it too.
Without from __future__ import annotations
, sphinx seems to be quite limited about where it allows type aliases, but pylint
and mypy
work as expected.
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.
inducer/arraycontext#117 is in.
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.
Am I doing this right? (e8fd358)
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.
👍 It seems to be rendering just fine on my machine too.
1778902
to
214e865
Compare
not needed anymore after pyopencl update
… is only referenced once again
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.
LGTM!
grudge/dt_utils.py
Outdated
@@ -158,7 +159,7 @@ def dt_non_geometric_factors( | |||
|
|||
@memoize_on_first_arg | |||
def h_max_from_volume( | |||
dcoll: DiscretizationCollection, dim=None, dd=None) -> float: | |||
dcoll: DiscretizationCollection, dim=None, dd=None) -> Any: |
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.
Maybe try a DeviceScalar = Any
type alias?
https://www.python.org/dev/peps/pep-0484/#type-aliases
Mypy shouldn't be bothered, but I don't know if it'll render nicely in Sphinx.
ed86d15
to
a9477fe
Compare
a9477fe
to
a2c54f0
Compare
(Looks like I don't have merge permissions for grudge.) |
Added you. |
Closes #168.