Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grudge
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Klöckner
grudge
Commits
dbcec037
Commit
dbcec037
authored
3 years ago
by
Matt Smith
Browse files
Options
Downloads
Patches
Plain Diff
add back return type hints
parent
2e6b66c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
grudge/reductions.py
+9
-8
9 additions, 8 deletions
grudge/reductions.py
with
9 additions
and
8 deletions
grudge/reductions.py
+
9
−
8
View file @
dbcec037
...
...
@@ -59,6 +59,7 @@ THE SOFTWARE.
from
numbers
import
Number
from
functools
import
reduce
from
typing
import
Any
from
arraycontext
import
make_loopy_program
...
...
@@ -75,7 +76,7 @@ import grudge.dof_desc as dof_desc
# {{{ Nodal reductions
def
_norm
(
dcoll
:
DiscretizationCollection
,
vec
,
p
,
dd
):
def
_norm
(
dcoll
:
DiscretizationCollection
,
vec
,
p
,
dd
)
->
Any
:
if
isinstance
(
vec
,
Number
):
return
np
.
fabs
(
vec
)
if
p
==
2
:
...
...
@@ -94,7 +95,7 @@ def _norm(dcoll: DiscretizationCollection, vec, p, dd):
raise
NotImplementedError
(
"
Unsupported value of p
"
)
def
norm
(
dcoll
:
DiscretizationCollection
,
vec
,
p
,
dd
=
None
):
def
norm
(
dcoll
:
DiscretizationCollection
,
vec
,
p
,
dd
=
None
)
->
Any
:
r
"""
Return the vector p-norm of a function represented
by its vector of degrees of freedom *vec*.
...
...
@@ -130,7 +131,7 @@ def norm(dcoll: DiscretizationCollection, vec, p, dd=None):
return
_norm
(
dcoll
,
vec
,
p
,
dd
)
def
nodal_sum
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
):
def
nodal_sum
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
)
->
Any
:
r
"""
Return the nodal sum of a vector of degrees of freedom *vec*.
:arg dd: a :class:`~grudge.dof_desc.DOFDesc`, or a value
...
...
@@ -150,7 +151,7 @@ def nodal_sum(dcoll: DiscretizationCollection, dd, vec):
comm
.
allreduce
(
actx
.
to_numpy
(
nodal_sum_loc
(
dcoll
,
dd
,
vec
)),
op
=
MPI
.
SUM
))
def
nodal_sum_loc
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
):
def
nodal_sum_loc
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
)
->
Any
:
r
"""
Return the rank-local nodal sum of a vector of degrees of freedom *vec*.
:arg dd: a :class:`~grudge.dof_desc.DOFDesc`, or a value
...
...
@@ -178,7 +179,7 @@ def nodal_sum_loc(dcoll: DiscretizationCollection, dd, vec):
return
sum
([
device_sum
(
grp_ary
)
for
grp_ary
in
vec
])
def
nodal_min
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
):
def
nodal_min
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
)
->
Any
:
r
"""
Return the nodal minimum of a vector of degrees of freedom *vec*.
:arg dd: a :class:`~grudge.dof_desc.DOFDesc`, or a value
...
...
@@ -198,7 +199,7 @@ def nodal_min(dcoll: DiscretizationCollection, dd, vec):
comm
.
allreduce
(
actx
.
to_numpy
(
nodal_min_loc
(
dcoll
,
dd
,
vec
)),
op
=
MPI
.
MIN
))
def
nodal_min_loc
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
):
def
nodal_min_loc
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
)
->
Any
:
r
"""
Return the rank-local nodal minimum of a vector of degrees
of freedom *vec*.
...
...
@@ -232,7 +233,7 @@ def nodal_min_loc(dcoll: DiscretizationCollection, dd, vec):
vec
,
as_device_scalar
(
np
.
inf
))
def
nodal_max
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
):
def
nodal_max
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
)
->
Any
:
r
"""
Return the nodal maximum of a vector of degrees of freedom *vec*.
:arg dd: a :class:`~grudge.dof_desc.DOFDesc`, or a value
...
...
@@ -252,7 +253,7 @@ def nodal_max(dcoll: DiscretizationCollection, dd, vec):
comm
.
allreduce
(
actx
.
to_numpy
(
nodal_max_loc
(
dcoll
,
dd
,
vec
)),
op
=
MPI
.
MAX
))
def
nodal_max_loc
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
):
def
nodal_max_loc
(
dcoll
:
DiscretizationCollection
,
dd
,
vec
)
->
Any
:
r
"""
Return the rank-local nodal maximum of a vector of degrees
of freedom *vec*.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment