Skip to content

Commit 1360de0

Browse files
committed
tests
Signed-off-by: Justin Chu <[email protected]>
1 parent 84beca1 commit 1360de0

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/onnx_ir/_convenience/_constructors_test.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def test_tensor_handles_empty_sequence_with_dtype(self):
3030
class ValueConstructorTest(unittest.TestCase):
3131
def test_value_minimal_creation(self):
3232
"""Test creating a value with just a name."""
33-
value = _constructors.value("minimal")
33+
value = _constructors.val("minimal")
3434

3535
self.assertEqual(value.name, "minimal")
3636
self.assertIsNone(value.type)
@@ -39,7 +39,7 @@ def test_value_minimal_creation(self):
3939

4040
def test_value_creation_with_sequence_shape(self):
4141
"""Test that shape is correctly converted from sequence to Shape object."""
42-
value = _constructors.value("test", ir.DataType.INT32, [1, 2, 3])
42+
value = _constructors.val("test", ir.DataType.INT32, [1, 2, 3])
4343

4444
self.assertEqual(value.name, "test")
4545
self.assertIsInstance(value.shape, ir.Shape)
@@ -48,7 +48,7 @@ def test_value_creation_with_sequence_shape(self):
4848
def test_value_creation_with_explicit_type(self):
4949
"""Test value creation with explicit type parameter."""
5050
tensor_type = ir.TensorType(ir.DataType.DOUBLE)
51-
value = _constructors.value("y", type=tensor_type, shape=[10])
51+
value = _constructors.val("y", type=tensor_type, shape=[10])
5252

5353
self.assertEqual(value.name, "y")
5454
self.assertEqual(value.type, tensor_type)
@@ -57,7 +57,7 @@ def test_value_creation_with_explicit_type(self):
5757
def test_value_creation_with_const_value(self):
5858
"""Test value creation with const_value (initializer)."""
5959
const_tensor = ir.Tensor(np.array([1.0, 2.0, 3.0], dtype=np.float32), name="const")
60-
value = _constructors.value("initializer", const_value=const_tensor)
60+
value = _constructors.val("initializer", const_value=const_tensor)
6161

6262
self.assertEqual(value.name, "initializer")
6363
self.assertEqual(value.type, ir.TensorType(ir.DataType.FLOAT))
@@ -66,7 +66,7 @@ def test_value_creation_with_const_value(self):
6666

6767
def test_value_creation_with_dtype_only(self):
6868
"""Test value creation with only dtype specified."""
69-
value = _constructors.value("float_value", dtype=ir.DataType.FLOAT)
69+
value = _constructors.val("float_value", dtype=ir.DataType.FLOAT)
7070

7171
self.assertEqual(value.name, "float_value")
7272
self.assertEqual(value.type, ir.TensorType(ir.DataType.FLOAT))
@@ -78,25 +78,25 @@ def test_value_const_value_type_mismatch_error(self):
7878
wrong_type = ir.TensorType(ir.DataType.FLOAT)
7979

8080
with self.assertRaisesRegex(ValueError, "The type does not match the const_value"):
81-
_constructors.value("test", type=wrong_type, const_value=const_tensor)
81+
_constructors.val("test", type=wrong_type, const_value=const_tensor)
8282

8383
def test_value_const_value_dtype_mismatch_error(self):
8484
"""Test that providing mismatched dtype with const_value raises ValueError."""
8585
const_tensor = ir.tensor([1.0, 2.0], dtype=ir.DataType.FLOAT)
8686

8787
with self.assertRaisesRegex(ValueError, "The dtype does not match the const_value"):
88-
_constructors.value("test", dtype=ir.DataType.INT32, const_value=const_tensor)
88+
_constructors.val("test", dtype=ir.DataType.INT32, const_value=const_tensor)
8989

9090
def test_value_const_value_shape_mismatch_error(self):
9191
"""Test that providing mismatched shape with const_value raises ValueError."""
9292
const_tensor = ir.tensor([[1, 2], [3, 4]], dtype=ir.DataType.INT32) # Shape: [2, 2]
9393

9494
with self.assertRaisesRegex(ValueError, "The shape does not match the const_value"):
95-
_constructors.value("test", shape=[3, 3], const_value=const_tensor)
95+
_constructors.val("test", shape=[3, 3], const_value=const_tensor)
9696

9797
def test_value_initialize_with_const_value(self):
9898
const_tensor = ir.tensor(np.array([[1.5, 2.5], [3.5, 4.5]], dtype=np.float64))
99-
value = _constructors.value("test", const_value=const_tensor)
99+
value = _constructors.val("test", const_value=const_tensor)
100100

101101
self.assertEqual(value.name, "test")
102102
self.assertEqual(value.type, ir.TensorType(ir.DataType.DOUBLE))
@@ -105,14 +105,14 @@ def test_value_initialize_with_const_value(self):
105105

106106
def test_value_creation_with_string_dimensions(self):
107107
"""Test value creation with string dimensions in shape."""
108-
value = _constructors.value("dynamic", ir.DataType.FLOAT, ["batch", "seq_len", 768])
108+
value = _constructors.val("dynamic", ir.DataType.FLOAT, ["batch", "seq_len", 768])
109109

110110
self.assertEqual(value.name, "dynamic")
111111
self.assertEqual(value.shape, ir.Shape(["batch", "seq_len", 768]))
112112

113113
def test_value_creation_with_none_dimensions(self):
114114
"""Test value creation with None dimensions in shape."""
115-
value = _constructors.value("unknown", ir.DataType.INT64, [None, 10, None])
115+
value = _constructors.val("unknown", ir.DataType.INT64, [None, 10, None])
116116

117117
self.assertEqual(value.name, "unknown")
118118
self.assertEqual(value.shape, ir.Shape([None, 10, None]))

0 commit comments

Comments
 (0)