From f34af7a10e83ca4b95f2ebd9f9e48904be3a2bc5 Mon Sep 17 00:00:00 2001 From: Andreas Dutzler Date: Mon, 2 Jan 2023 09:12:59 +0100 Subject: [PATCH 1/2] add divide by tensor --- tensortrax/_tensor.py | 7 +------ tests/test_math.py | 3 +-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tensortrax/_tensor.py b/tensortrax/_tensor.py index ab7d493..981d839 100644 --- a/tensortrax/_tensor.py +++ b/tensortrax/_tensor.py @@ -127,12 +127,7 @@ def __mul__(self, B): def __truediv__(self, B): A = self - if isinstance(B, Tensor): - raise NotImplementedError("Divide by Tensor is not supported.") - else: - return Tensor( - x=f(A) / B, δx=δ(A) / B, Δx=Δ(A) / B, Δδx=Δδ(A) / B, ntrax=A.ntrax - ) + return A * B**-1 def __rtruediv__(self, B): A = self diff --git a/tests/test_math.py b/tests/test_math.py index 113dfdc..33a0659 100644 --- a/tests/test_math.py +++ b/tests/test_math.py @@ -25,8 +25,7 @@ def test_math(): assert isinstance(T / F, tr.Tensor) assert isinstance(F / T, tr.Tensor) - with pytest.raises(NotImplementedError): - T / T + assert isinstance(T / T, tr.Tensor) assert isinstance(T + F, tr.Tensor) assert isinstance(F + T, tr.Tensor) From 429f98cc24d05b4262273e16f7c9e98c5ff16a30 Mon Sep 17 00:00:00 2001 From: Andreas Dutzler Date: Mon, 2 Jan 2023 09:13:18 +0100 Subject: [PATCH 2/2] Update __about__.py --- tensortrax/__about__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensortrax/__about__.py b/tensortrax/__about__.py index fc73106..29b1604 100644 --- a/tensortrax/__about__.py +++ b/tensortrax/__about__.py @@ -2,4 +2,4 @@ tensorTRAX: Math on (Hyper-Dual) Tensors with Trailing Axes. """ -__version__ = "0.2.8" +__version__ = "0.2.9"