Skip to content

Commit 1408968

Browse files
committed
Rename get_unique_value to get_unique_constant_value
1 parent 5c87d74 commit 1408968

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

pytensor/scan/rewriting.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
get_slice_elements,
7070
set_subtensor,
7171
)
72-
from pytensor.tensor.var import TensorConstant, get_unique_value
72+
from pytensor.tensor.var import TensorConstant, get_unique_constant_value
7373

7474

7575
list_opt_slice = [
@@ -136,7 +136,7 @@ def remove_constants_and_unused_inputs_scan(fgraph, node):
136136
node_inp = node.inputs[idx + 1]
137137
if (
138138
isinstance(node_inp, TensorConstant)
139-
and get_unique_value(node_inp) is not None
139+
and get_unique_constant_value(node_inp) is not None
140140
):
141141
try:
142142
# This works if input is a constant that has all entries

pytensor/tensor/basic.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
uint_dtypes,
6363
values_eq_approx_always_true,
6464
)
65-
from pytensor.tensor.var import TensorConstant, TensorVariable, get_unique_value
65+
from pytensor.tensor.var import (
66+
TensorConstant,
67+
TensorVariable,
68+
get_unique_constant_value,
69+
)
6670

6771

6872
if TYPE_CHECKING:
@@ -323,7 +327,7 @@ def get_underlying_scalar_constant_value(
323327
raise NotScalarConstantError()
324328

325329
if isinstance(v, Constant):
326-
unique_value = get_unique_value(v)
330+
unique_value = get_unique_constant_value(v)
327331
if unique_value is not None:
328332
data = unique_value
329333
else:

pytensor/tensor/rewriting/math.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@
101101
values_eq_approx_remove_inf_nan,
102102
values_eq_approx_remove_nan,
103103
)
104-
from pytensor.tensor.var import TensorConstant, get_unique_value
104+
from pytensor.tensor.var import TensorConstant, get_unique_constant_value
105105

106106

107107
def scalarconsts_rest(inputs, elemwise=True, only_process_constants=False):
@@ -133,7 +133,7 @@ def get_constant(v):
133133
134134
"""
135135
if isinstance(v, Constant):
136-
unique_value = get_unique_value(v)
136+
unique_value = get_unique_constant_value(v)
137137
if unique_value is not None:
138138
data = unique_value
139139
else:

pytensor/tensor/var.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ def no_nan(self):
986986
return self._no_nan
987987

988988

989-
def get_unique_value(x: TensorVariable) -> Optional[Number]:
989+
def get_unique_constant_value(x: TensorVariable) -> Optional[Number]:
990990
"""Return the unique value of a tensor, if there is one"""
991991
if isinstance(x, Constant):
992992
data = x.data

0 commit comments

Comments
 (0)