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

ci: add pyodide build #995

Closed
wants to merge 4 commits into from

Conversation

henryiii
Copy link
Member

Testing this.

@henryiii henryiii force-pushed the henryiii/ci/pyodode branch from 5b099df to 3c05e97 Compare May 31, 2024 17:00
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
@henryiii henryiii force-pushed the henryiii/ci/pyodode branch from 3c05e97 to 65ac58e Compare May 31, 2024 17:04
@henryiii henryiii closed this Jun 8, 2024
@henryiii henryiii reopened this Jun 8, 2024
@henryiii
Copy link
Member Author

henryiii commented Jun 8, 2024

This is the only failing part, don't know if it's directly pyodide's fault:

  ______________________ test_NormalConstraint_bad_input_4 _______________________
      def test_NormalConstraint_bad_input_4():
  >       with pytest.raises(ValueError, match="positive definite"):
  E       Failed: DID NOT RAISE <class 'ValueError'>
  /home/runner/work/iminuit/iminuit/tests/test_cost.py:1573: Failed
  ______________________ test_NormalConstraint_bad_input_5 _______________________
      def test_NormalConstraint_bad_input_5():
          n = NormalConstraint(["a", "b"], [1, 2], [[1, 0], [0, 1]])
      
  >       with pytest.raises(ValueError, match="positive definite"):
  E       Failed: DID NOT RAISE <class 'ValueError'>
  /home/runner/work/iminuit/iminuit/tests/test_cost.py:1580: Failed
  ____________________________ test_positive_definite ____________________________
      def test_positive_definite():
          assert util.is_positive_definite([[1, 0], [0, 1]])
  >       assert not util.is_positive_definite([[1, 1], [1, 1]])
  E       assert not True
  E        +  where True = <function is_positive_definite at 0x2898118>([[1, 1], [1, 1]])
  E        +    where <function is_positive_definite at 0x2898118> = util.is_positive_definite
  /home/runner/work/iminuit/iminuit/tests/test_util.py:776: AssertionError

@HDembinski
Copy link
Member

This is the only failing part, don't know if it's directly pyodide's fault:

  ______________________ test_NormalConstraint_bad_input_4 _______________________
      def test_NormalConstraint_bad_input_4():
  >       with pytest.raises(ValueError, match="positive definite"):
  E       Failed: DID NOT RAISE <class 'ValueError'>
  /home/runner/work/iminuit/iminuit/tests/test_cost.py:1573: Failed
  ______________________ test_NormalConstraint_bad_input_5 _______________________
      def test_NormalConstraint_bad_input_5():
          n = NormalConstraint(["a", "b"], [1, 2], [[1, 0], [0, 1]])
      
  >       with pytest.raises(ValueError, match="positive definite"):
  E       Failed: DID NOT RAISE <class 'ValueError'>
  /home/runner/work/iminuit/iminuit/tests/test_cost.py:1580: Failed
  ____________________________ test_positive_definite ____________________________
      def test_positive_definite():
          assert util.is_positive_definite([[1, 0], [0, 1]])
  >       assert not util.is_positive_definite([[1, 1], [1, 1]])
  E       assert not True
  E        +  where True = <function is_positive_definite at 0x2898118>([[1, 1], [1, 1]])
  E        +    where <function is_positive_definite at 0x2898118> = util.is_positive_definite
  /home/runner/work/iminuit/iminuit/tests/test_util.py:776: AssertionError

The two errors seem related to util.is_positive_definite, which is implemented as follows:

    m = np.atleast_2d(m)
    if np.all(m.T == m):
        # maybe check this first https://en.wikipedia.org/wiki/Diagonally_dominant_matrix
        # and only try cholesky if that fails
        try:
            np.linalg.cholesky(m)
        except np.linalg.LinAlgError:
            return False
        return True
    return False

This returns true in those failing cases although it should return false. Apparently, np.linalg.cholesky(m) is not raising LinAlgError on Pyiodide.

@HDembinski
Copy link
Member

Perhaps the line np.linalg.cholesky(m) is non-blocking in Pyiodide. This code assumes it is blocking, like any other normal Python statement.

@henryiii
Copy link
Member Author

henryiii commented Jun 10, 2024

I bet NumPy is compiled with exceptions turned off; maybe this function actually raises the exception from the compiled code?

I'll look into this and report to pyodide with what I find. The snippet above is extremely helpful, thank you!

@HDembinski HDembinski marked this pull request as ready for review July 30, 2024 16:07
@HDembinski
Copy link
Member

@henryiii I made a patch which may work around the failing test in pyodide, but I cannot test it because the pyodide build now fails because of some build-system issue. I am closing this PR now, you can reopen it when you find the time to finish this.

@HDembinski HDembinski closed this Jul 30, 2024
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

Successfully merging this pull request may close these issues.

2 participants