Skip to content

Commit 13f1a55

Browse files
committed
Remove numpy test dep and rework matrix multiplication tests.
1 parent cf4afc6 commit 13f1a55

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

tests/test_lazy_object_proxy.py

+25-13
Original file line numberDiff line numberDiff line change
@@ -913,23 +913,35 @@ def test_mul(lop):
913913

914914

915915
def test_matmul(lop):
916-
import numpy
916+
class MatmulClass:
917+
def __init__(self, value):
918+
self.value = value
917919

918-
one = numpy.array((1, 2, 3))
919-
two = numpy.array((2, 3, 4))
920-
assert one @ two == 20
920+
def __matmul__(self, other):
921+
return self.value * other.value
921922

922-
one = lop.Proxy(lambda: numpy.array((1, 2, 3)))
923-
two = lop.Proxy(lambda: numpy.array((2, 3, 4)))
924-
assert one @ two == 20
923+
def __rmatmul__(self, other):
924+
return other + self.value
925925

926-
one = lop.Proxy(lambda: numpy.array((1, 2, 3)))
927-
two = numpy.array((2, 3, 4))
928-
assert one @ two == 20
926+
one = MatmulClass(123)
927+
two = MatmulClass(234)
928+
assert one @ two == 28782
929929

930-
one = numpy.array((1, 2, 3))
931-
two = lop.Proxy(lambda: numpy.array((2, 3, 4)))
932-
assert one @ two == 20
930+
one = lop.Proxy(lambda: MatmulClass(123))
931+
two = lop.Proxy(lambda: MatmulClass(234))
932+
assert one @ two == 28782
933+
934+
one = lop.Proxy(lambda: MatmulClass(123))
935+
two = MatmulClass(234)
936+
assert one @ two == 28782
937+
938+
one = 123
939+
two = lop.Proxy(lambda: MatmulClass(234))
940+
assert one @ two == 357
941+
942+
one = lop.Proxy(lambda: 123)
943+
two = lop.Proxy(lambda: MatmulClass(234))
944+
assert one @ two == 357
933945

934946

935947
def test_div(lop):

tox.ini

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ deps =
4242
pytest
4343
pytest-benchmark
4444
Django
45-
numpy
4645
objproxies==0.9.4
4746
hunter
4847
cover: pytest-cov

0 commit comments

Comments
 (0)