Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Floating-point arithmetic limitation in tests #265

Open
NGC2023 opened this issue May 26, 2024 · 0 comments
Open

Floating-point arithmetic limitation in tests #265

NGC2023 opened this issue May 26, 2024 · 0 comments

Comments

@NGC2023
Copy link

NGC2023 commented May 26, 2024

Hi,
I found a floating-point arithmetic limitation in test_get_primal of VariableTestCase in optlang 1.8.1 for Debian. I have created a patch.

--- a/src/optlang/tests/test_glpk_exact_interface.py
+++ b/src/optlang/tests/test_glpk_exact_interface.py
@@ -72,7 +72,7 @@ class VariableTestCase(abstract_test_cas
                          -1.1331887079263237e-29, 17.530865429786694, 0.0, 0.0, 0.0, 4.765319193197458,
                          -4.765319193197457, 21.79949265599876, -21.79949265599876, -3.2148950476847613, 0.0,
                          -2.281503094067127, 2.6784818505075303, 0.0]):
-            self.assertAlmostEqual(i, j)
+            self.assertAlmostEqual(i, j, places=6)
 
     def test_changing_variable_names_is_reflected_in_the_solver(self):
         model = self.interface.Model(problem=glpk_read_cplex(TESTMODELPATH))
--- a/src/optlang/tests/test_glpk_interface.py
+++ b/src/optlang/tests/test_glpk_interface.py
@@ -74,7 +74,7 @@ class VariableTestCase(abstract_test_cas
                          -1.1331887079263237e-29, 17.530865429786694, 0.0, 0.0, 0.0, 4.765319193197458,
                          -4.765319193197457, 21.79949265599876, -21.79949265599876, -3.2148950476847613, 0.0,
                          -2.281503094067127, 2.6784818505075303, 0.0]):
-            self.assertAlmostEqual(i, j)
+            self.assertAlmostEqual(i, j, places=6)
 
     def test_changing_variable_names_is_reflected_in_the_solver(self):
         model = self.interface.Model(problem=glpk_read_cplex(TESTMODELPATH))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant