Skip to content
Snippets Groups Projects
Unverified Commit bc7139f8 authored by nkoskelo's avatar nkoskelo Committed by GitHub
Browse files

Add an implementation of np.vdot to PytatoPyOpenCLArrayContext (#299)

* Add an implementation of vdot to the PytatoPyOpenCLArrayContext np namespace.

* Remove the tests that are just skipped for scalars.

* Respond to comments.

* Ruff version needed to be updated locally.
parent a88f08da
No related branches found
No related tags found
No related merge requests found
Checking pipeline status
......@@ -239,4 +239,7 @@ class PytatoFakeNumpyNamespace(LoopyBasedFakeNumpyNamespace):
def absolute(self, a):
return self.abs(a)
def vdot(self, a: Array, b: Array):
return rec_multimap_array_container(pt.vdot, a, b)
# }}}
......@@ -271,11 +271,10 @@ def test_array_context_np_workalike(actx_factory, sym_name, n_args, dtype):
assert_close_to_numpy_in_containers(actx, evaluate, args)
if sym_name in ["where", "min", "max", "any", "all", "conj", "vdot", "sum"]:
pytest.skip(f"'{sym_name}' not supported on scalars")
args = [randn(0, dtype)[()] for i in range(n_args)]
assert_close_to_numpy(actx, evaluate, args)
if sym_name not in ["where", "min", "max", "any", "all", "conj", "vdot", "sum"]:
# Scalar arguments are supported.
args = [randn(0, dtype)[()] for i in range(n_args)]
assert_close_to_numpy(actx, evaluate, args)
@pytest.mark.parametrize(("sym_name", "n_args", "dtype"), [
......
......@@ -27,7 +27,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""
import logging
from typing import Optional, cast
from typing import cast
import numpy as np
import pytest
......@@ -63,7 +63,7 @@ def test_dataclass_array_container() -> None:
class ArrayContainerWithOptional:
x: np.ndarray
# Deliberately left as Optional to test compatibility.
y: Optional[np.ndarray] # noqa: UP007
y: np.ndarray | None
with pytest.raises(TypeError, match="Field 'y' union contains non-array"):
# NOTE: cannot have wrapped annotations (here by `Optional`)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment