Skip to content

Commit

Permalink
Rename class TrueDiv to TrueDivide for code consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
sudarsan2k5 committed Feb 20, 2023
1 parent b4d4ed3 commit 333fb47
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion aesara/compile/profiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ def print_tips(self, file):
aes.Add,
aes.Mul,
aes.Sub,
aes.TrueDiv,
aes.TrueDivide,
aes.FloorDivide,
aes.Clip,
aes.Second,
Expand Down
4 changes: 2 additions & 2 deletions aesara/link/numba/dispatch/elemwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ScalarMaximum,
ScalarMinimum,
Sub,
TrueDiv,
TrueDivide,
)
from aesara.scalar.basic import add as add_as
from aesara.scalar.basic import scalar_maximum
Expand Down Expand Up @@ -101,7 +101,7 @@ def scalar_in_place_fn_XOR(op, idx, res, arr):
return f"{res}[{idx}] ^= {arr}"


@scalar_in_place_fn.register(TrueDiv)
@scalar_in_place_fn.register(TrueDivide)
def scalar_in_place_fn_TrueDiv(op, idx, res, arr):
return f"{res}[{idx}] /= {arr}"

Expand Down
6 changes: 3 additions & 3 deletions aesara/scalar/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1979,7 +1979,7 @@ def L_op(self, inputs, outputs, gout):
sub = Sub(upcast_out_nobool, name="sub")


class TrueDiv(BinaryScalarOp):
class TrueDivide(BinaryScalarOp):
nfunc_spec = ("true_divide", 2, 1)

def output_types(self, types):
Expand Down Expand Up @@ -2035,7 +2035,7 @@ def grad(self, inputs, gout):
return first_part, second_part


true_divide = TrueDiv(upcast_out, name="true_divide")
true_divide = TrueDivide(upcast_out, name="true_divide")
divide = true_divide


Expand Down Expand Up @@ -4539,7 +4539,7 @@ def __getattr__(name):
"Mean",
"Mul",
"Sub",
"TrueDiv",
"TrueDivide",
"FloorDivide",
"mod_check",
"Mod",
Expand Down
2 changes: 1 addition & 1 deletion aesara/tensor/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def _obj_is_wrappable_as_tensor(x):
aes.Mod,
aes.Mul,
aes.FloorDivide,
aes.TrueDiv,
aes.TrueDivide,
aes.ScalarMinimum,
aes.ScalarMaximum,
)
Expand Down
2 changes: 1 addition & 1 deletion aesara/tensor/rewriting/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -1963,7 +1963,7 @@ def local_intdiv_by_one(fgraph, node):
def local_zero_div(fgraph, node):
"""0 / x -> 0"""
if isinstance(node.op, Elemwise) and isinstance(
node.op.scalar_op, (aes.FloorDivide, aes.TrueDiv)
node.op.scalar_op, (aes.FloorDivide, aes.TrueDivide)
):
if get_constant(node.inputs[0]) == 0:
ret = broadcast_like(0, node.outputs[0], fgraph)
Expand Down
16 changes: 8 additions & 8 deletions tests/scalar/test_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from aesara.scalar.basic import (
FloorDivide,
ScalarType,
TrueDiv,
TrueDivide,
complex64,
float32,
float64,
Expand All @@ -27,13 +27,13 @@ def test_div_types():

assert isinstance((a // b).owner.op, FloorDivide)
assert isinstance((b // a).owner.op, FloorDivide)
assert isinstance((b / d).owner.op, TrueDiv)
assert isinstance((b / f).owner.op, TrueDiv)
assert isinstance((f / a).owner.op, TrueDiv)
assert isinstance((d / b).owner.op, TrueDiv)
assert isinstance((d / f).owner.op, TrueDiv)
assert isinstance((f / c).owner.op, TrueDiv)
assert isinstance((a / c).owner.op, TrueDiv)
assert isinstance((b / d).owner.op, TrueDivide)
assert isinstance((b / f).owner.op, TrueDivide)
assert isinstance((f / a).owner.op, TrueDivide)
assert isinstance((d / b).owner.op, TrueDivide)
assert isinstance((d / f).owner.op, TrueDivide)
assert isinstance((f / c).owner.op, TrueDivide)
assert isinstance((a / c).owner.op, TrueDivide)


def test_filter_float_subclass():
Expand Down
10 changes: 5 additions & 5 deletions tests/tensor/rewriting/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def test_mul_div_cases(self):
assert isinstance(elem[0].op, (Elemwise,))
assert isinstance(
elem[0].op.scalar_op,
(aes.basic.Reciprocal, aes.basic.TrueDiv),
(aes.basic.Reciprocal, aes.basic.TrueDivide),
)
assert out_dtype == out.dtype

Expand Down Expand Up @@ -693,7 +693,7 @@ def test_mul_div_cases(self):
topo = f.maker.fgraph.toposort()
assert len(topo) == 1
assert isinstance(topo[0].op, (Elemwise,))
assert isinstance(topo[0].op.scalar_op, aes.basic.TrueDiv)
assert isinstance(topo[0].op.scalar_op, aes.basic.TrueDivide)
assert len(topo[0].inputs) == 2
assert out_dtype == out.dtype

Expand Down Expand Up @@ -746,7 +746,7 @@ def test_mul_div_cases(self):
assert isinstance(topo[0].op.scalar_op, aes.basic.Mul)
assert len(topo[0].inputs) == 2
assert isinstance(topo[1].op, (Elemwise,))
assert isinstance(topo[1].op.scalar_op, aes.basic.TrueDiv)
assert isinstance(topo[1].op.scalar_op, aes.basic.TrueDivide)
assert len(topo[1].inputs) == 2
assert out_dtype == out.dtype

Expand Down Expand Up @@ -3729,7 +3729,7 @@ def test_local_sum_div_dimshuffle(self):
for i, s in enumerate(sums):
f = function([a, b, c, d], s, mode=self.mode, on_unused_input="ignore")
g = f.maker.fgraph.toposort()
assert isinstance(g[-1].op.scalar_op, aes.basic.TrueDiv)
assert isinstance(g[-1].op.scalar_op, aes.basic.TrueDivide)
f(a_val, b_val, c_val, d_val)

def test_local_prod_div_dimshuffle(self):
Expand Down Expand Up @@ -3820,7 +3820,7 @@ def test_local_prod_div_dimshuffle(self):
aes.basic.Mul,
aes.basic.Composite,
aes.basic.Composite,
aes.basic.TrueDiv,
aes.basic.TrueDivide,
aes.basic.Composite,
aes.basic.Mul,
aes.basic.Composite,
Expand Down
2 changes: 1 addition & 1 deletion tests/tensor/test_math.py
Original file line number Diff line number Diff line change
Expand Up @@ -3042,7 +3042,7 @@ def test_mean_custom_dtype(self):
try:
grad(mean_var.sum(), x, disconnected_inputs="ignore")
except NotImplementedError:
# TrueDiv does not seem to have a gradient when
# TrueDivide does not seem to have a gradient when
# the numerator is complex.
if mean_var.dtype in complex_dtypes:
pass
Expand Down

0 comments on commit 333fb47

Please sign in to comment.