Skip to content

Commit

Permalink
Merge pull request #38 from adtzlr/add-divide-by-tensor
Browse files Browse the repository at this point in the history
Add divide by tensor
  • Loading branch information
adtzlr authored Jan 2, 2023
2 parents 6d758c4 + 429f98c commit 3f447b6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tensortrax/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
tensorTRAX: Math on (Hyper-Dual) Tensors with Trailing Axes.
"""

__version__ = "0.2.8"
__version__ = "0.2.9"
7 changes: 1 addition & 6 deletions tensortrax/_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions tests/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3f447b6

Please sign in to comment.