Skip to content

Commit b960fc0

Browse files
Fix EllipsoidalSet.scale setter
1 parent 5da80fc commit b960fc0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pyomo/contrib/pyros/tests/test_uncertainty_sets.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,9 @@ def test_normal_construction_and_update(self):
18651865
scale, eset.scale, err_msg="EllipsoidalSet scale not as expected"
18661866
)
18671867
np.testing.assert_allclose(
1868-
sp.stats.chi2.cdf(scale**0.5, df=2),
1868+
# evaluate chisquare CDF for 2 degrees of freedom
1869+
# using simplified formula
1870+
1 - np.exp(-scale / 2),
18691871
eset.chi_sq_conf_lvl,
18701872
err_msg="EllipsoidalSet chi-squared confidence level not as expected",
18711873
)
@@ -1893,7 +1895,9 @@ def test_normal_construction_and_update(self):
18931895
new_scale, eset.scale, err_msg="EllipsoidalSet scale update not as expected"
18941896
)
18951897
np.testing.assert_allclose(
1896-
sp.stats.chi2.cdf(new_scale**0.5, df=2),
1898+
# evaluate chisquare CDF for 2 degrees of freedom
1899+
# using simplified formula
1900+
1 - np.exp(-new_scale / 2),
18971901
eset.chi_sq_conf_lvl,
18981902
err_msg="EllipsoidalSet chi-square confidence level update not as expected",
18991903
)

pyomo/contrib/pyros/uncertainty_sets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2599,7 +2599,7 @@ def scale(self, val):
25992599
)
26002600

26012601
self._scale = val
2602-
self._chi_sq_conf_lvl = sp.stats.chi2.cdf(x=val**0.5, df=self.dim)
2602+
self._chi_sq_conf_lvl = sp.stats.chi2.cdf(x=val, df=self.dim)
26032603

26042604
@property
26052605
def chi_sq_conf_lvl(self):

0 commit comments

Comments
 (0)