Skip to content

Commit

Permalink
truediv
Browse files Browse the repository at this point in the history
  • Loading branch information
adityagoel4512 committed Jul 10, 2024
1 parent 9eb981a commit ef0ac77
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion ndonnx/_core/_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ def cosh(self, x):
return _unary_op(x, opx.cosh, dtypes.float32)

def divide(self, x, y):
return _variadic_op([x, y], opx.div, via_dtype=dtypes.float64)
return _variadic_op(
[x, y], opx.div, via_dtype=dtypes.float64, cast_return=False
)

def equal(self, x, y) -> Array:
x, y = promote(x, y)
Expand Down
8 changes: 8 additions & 0 deletions tests/ndonnx/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,11 @@ def test_searchsorted_raises():
b = ndx.array(shape=(3,), dtype=ndx.int64)

ndx.searchsorted(a, b, side="middle") # type: ignore[arg-type]


def test_truediv():
x = ndx.asarray([1, 2, 3], dtype=ndx.int64)
y = ndx.asarray([2, 3, 3], dtype=ndx.int64)
z = x / y
assert isinstance(z.dtype, ndx.Floating)
np.testing.assert_array_equal(z.to_numpy(), np.array([0.5, 2 / 3, 1.0]))

0 comments on commit ef0ac77

Please sign in to comment.