|
6 | 6 |
|
7 | 7 | # pyre-strict |
8 | 8 |
|
9 | | -from ax.core.parameter import ChoiceParameter, ParameterType, RangeParameter |
10 | | -from ax.core.parameter_constraint import ( |
11 | | - ComparisonOp, |
12 | | - ParameterConstraint, |
13 | | - SumConstraint, |
14 | | -) |
| 9 | +from ax.core.parameter_constraint import ParameterConstraint |
15 | 10 | from ax.exceptions.core import UserInputError |
16 | 11 | from ax.utils.common.testutils import TestCase |
17 | 12 |
|
@@ -127,68 +122,3 @@ def test_Sortable(self) -> None: |
127 | 122 | inequality="2 * x - 3 * y <= 6.0", |
128 | 123 | ) |
129 | 124 | self.assertTrue(constraint1 < constraint2) |
130 | | - |
131 | | - |
132 | | -class SumConstraintTest(TestCase): |
133 | | - def setUp(self) -> None: |
134 | | - super().setUp() |
135 | | - self.x = RangeParameter("x", ParameterType.INT, lower=-5, upper=5) |
136 | | - self.y = RangeParameter("y", ParameterType.INT, lower=-5, upper=5) |
137 | | - self.constraint1 = SumConstraint( |
138 | | - parameters=[self.x, self.y], is_upper_bound=True, bound=5 |
139 | | - ) |
140 | | - self.constraint2 = SumConstraint( |
141 | | - parameters=[self.x, self.y], is_upper_bound=False, bound=-5 |
142 | | - ) |
143 | | - |
144 | | - self.constraint_repr1 = "SumConstraint(x + y <= 5.0)" |
145 | | - self.constraint_repr2 = "SumConstraint(x + y >= -5.0)" |
146 | | - |
147 | | - def test_BadConstruct(self) -> None: |
148 | | - with self.assertRaises(ValueError): |
149 | | - SumConstraint(parameters=[self.x, self.x], is_upper_bound=False, bound=-5.0) |
150 | | - z = ChoiceParameter("z", ParameterType.STRING, ["a", "b", "c"]) |
151 | | - with self.assertRaises(ValueError): |
152 | | - # pyre-fixme[16]: `SumConstraintTest` has no attribute `constraint`. |
153 | | - self.constraint = SumConstraint( |
154 | | - parameters=[self.x, z], is_upper_bound=False, bound=-5.0 |
155 | | - ) |
156 | | - |
157 | | - def test_Properties(self) -> None: |
158 | | - self.assertEqual(self.constraint1.op, ComparisonOp.LEQ) |
159 | | - self.assertTrue(self.constraint1._is_upper_bound) |
160 | | - |
161 | | - self.assertEqual(self.constraint2.op, ComparisonOp.GEQ) |
162 | | - self.assertFalse(self.constraint2._is_upper_bound) |
163 | | - |
164 | | - def test_Repr(self) -> None: |
165 | | - self.assertEqual(str(self.constraint1), self.constraint_repr1) |
166 | | - self.assertEqual(str(self.constraint2), self.constraint_repr2) |
167 | | - |
168 | | - def test_Validate(self) -> None: |
169 | | - self.assertTrue(self.constraint1.check({"x": 1, "y": 4})) |
170 | | - self.assertTrue(self.constraint1.check({"x": 4, "y": 1})) |
171 | | - self.assertFalse(self.constraint1.check({"x": 1, "y": 5})) |
172 | | - |
173 | | - self.assertTrue(self.constraint2.check({"x": -4, "y": -1})) |
174 | | - self.assertTrue(self.constraint2.check({"x": -1, "y": -4})) |
175 | | - self.assertFalse(self.constraint2.check({"x": -5, "y": -1})) |
176 | | - |
177 | | - def test_Clone(self) -> None: |
178 | | - constraint_clone = self.constraint1.clone() |
179 | | - self.assertEqual(self.constraint1.bound, constraint_clone.bound) |
180 | | - |
181 | | - constraint_clone._bound = 7.0 |
182 | | - self.assertNotEqual(self.constraint1.bound, constraint_clone.bound) |
183 | | - |
184 | | - constraint_clone_2 = self.constraint2.clone() |
185 | | - self.assertEqual(self.constraint2.bound, constraint_clone_2.bound) |
186 | | - |
187 | | - def test_CloneWithTransformedParameters(self) -> None: |
188 | | - constraint_clone = self.constraint1.clone_with_transformed_parameters( |
189 | | - transformed_parameters={p.name: p for p in self.constraint1.parameters} |
190 | | - ) |
191 | | - self.assertEqual(self.constraint1.bound, constraint_clone.bound) |
192 | | - |
193 | | - constraint_clone._bound = 7.0 |
194 | | - self.assertNotEqual(self.constraint1.bound, constraint_clone.bound) |
0 commit comments