Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Connor Ward <[email protected]>
  • Loading branch information
Ig-dolci and connorjward authored Dec 5, 2024
1 parent e82dfe4 commit b0a2535
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 8 additions & 6 deletions pyop2/types/dat.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,16 +492,18 @@ def norm(self):
from math import sqrt
return sqrt(self.inner(self).real)

def maxpy(self, scalar: list, x: list) -> None:
def maxpy(self, scalar: Sequence, x: Sequence) -> None:

Check failure on line 495 in pyop2/types/dat.py

View workflow job for this annotation

GitHub Actions / Run linter

F821

pyop2/types/dat.py:495:29: F821 undefined name 'Sequence'

Check failure on line 495 in pyop2/types/dat.py

View workflow job for this annotation

GitHub Actions / Run linter

F821

pyop2/types/dat.py:495:42: F821 undefined name 'Sequence'
"""Compute a sequence of axpy operations.
This is equivalent to calling :meth:`axpy` for each pair of
scalars and :class:`Dat` in the input sequences.
:arg scalar: A sequence of scalars.
:arg x: A sequence of :class:`Dat`.
See also :meth:`axpy`.
Parameters
----------
scalar :
A sequence of scalars.
x :
A sequence of :class:`Dat`.
"""
if len(scalar) != len(x):
Expand All @@ -512,7 +514,7 @@ def maxpy(self, scalar: list, x: list) -> None:
def axpy(self, alpha: float, other: 'Dat') -> None:
"""Compute the operation :math:`y = \\alpha x + y`.
On this case, `self` is `y` and `other` is `x`.
In this case, ``self`` is ``y`` and ``other`` is ``x``.
"""
self._check_shape(other)
Expand Down
14 changes: 8 additions & 6 deletions pyop2/types/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,18 @@ def inner(self, other):
assert issubclass(type(other), type(self))
return np.dot(self.data_ro, np.conj(other.data_ro))

def maxpy(self, scalar: list, x: list) -> None:
def maxpy(self, scalar: Sequence, x: Sequence) -> None:

Check failure on line 206 in pyop2/types/glob.py

View workflow job for this annotation

GitHub Actions / Run linter

F821

pyop2/types/glob.py:206:29: F821 undefined name 'Sequence'

Check failure on line 206 in pyop2/types/glob.py

View workflow job for this annotation

GitHub Actions / Run linter

F821

pyop2/types/glob.py:206:42: F821 undefined name 'Sequence'
"""Compute a sequence of axpy operations.
This is equivalent to calling :meth:`axpy` for each pair of
scalars and :class:`Dat` in the input sequences.
:arg scalar: A sequence of scalars.
:arg x: A sequence of :class:`Dat`.
See also :meth:`axpy`.
Parameters
----------
scalar :
A sequence of scalars.
x :
A sequence of `Global`.
"""
if len(scalar) != len(x):
Expand All @@ -223,7 +225,7 @@ def maxpy(self, scalar: list, x: list) -> None:
def axpy(self, alpha: float, other: 'Global') -> None:
"""Compute the operation :math:`y = \\alpha x + y`.
On this case, `self` is `y` and `other` is `x`.
In this case, ``self`` is ``y`` and ``other`` is ``x``.
"""
if isinstance(self._data, np.ndarray):
Expand Down

0 comments on commit b0a2535

Please sign in to comment.