From dbcec037251e12f538480738583d53a0d5dab6a1 Mon Sep 17 00:00:00 2001 From: Matthew Smith <mjsmith6@illinois.edu> Date: Wed, 20 Oct 2021 11:37:35 -0500 Subject: [PATCH] add back return type hints --- grudge/reductions.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/grudge/reductions.py b/grudge/reductions.py index 2cde556d..c5a6fbea 100644 --- a/grudge/reductions.py +++ b/grudge/reductions.py @@ -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*. -- GitLab