spacetelescope / spherical_geometry

A Python package for handling spherical polygons that represent arbitrary regions of the sky
http://spherical-geometry.readthedocs.io/
61 stars 31 forks source link

TST: cp3*macosx_arm64 wheels has test failure, preventing release #262

Closed pllim closed 3 months ago

pllim commented 4 months ago

Example log: https://github.com/spacetelescope/spherical_geometry/actions/runs/8823443975/job/24223897028

I wanted to blame https://github.com/scipy/scipy/issues/20531 but I don't think I can since scipy is not even installed.

Successfully installed PyYAML-6.0.1 astropy-6.0.1 astropy-iers-data-0.2024.4.22.0.29.50 exceptiongroup-1.2.1 iniconfig-2.0.0 numpy-1.26.4 packaging-24.0 pluggy-1.5.0 pyerfa-2.0.1.4 pytest-8.1.1 pytest-astropy-header-0.2.2 spherical-geometry-1.3.1 tomli-2.0.1
...
 _________________________ test_math_util_length_domain _________________________

      @pytest.mark.skipif(math_util is None, reason="math_util C-ext is missing")
      def test_math_util_length_domain():
          with pytest.raises(ValueError):
  >           math_util.length([[np.nan, 0, 0]], [[0, 0, np.inf]])
  E           Failed: DID NOT RAISE <class 'ValueError'>

  spherical_geometry/tests/test_basic.py:535: Failed
  ----------------------------- Captured stderr call -----------------------------
 spherical_geometry/tests/test_basic.py:535: RuntimeWarning: invalid value encountered in length
    math_util.length([[np.nan, 0, 0]], [[0, 0, np.inf]])
pllim commented 4 months ago

From @mcara

The problems appear to be due to import failure of math_util even though math_util...so is built. very strange. If this import fails, the code fallback to the Python code. Probably that code is buggy too and hence the errors. So, two things need to be fixed: Python code and import of the compiled C module build with numpy 2.0.

jhunkeler commented 4 months ago

Here is what I get when I import math_util:

$ uname -s -m  
Darwin arm64
/*
 * Finds the length of the given great circle arc AB
 */
static void
DOUBLE_length([...])
{
    printf("DEFINITELY C CODE\n");
    // [...]
}
pip install -e .
>>> import numpy as np
>>> from spherical_geometry import math_util
>>> from spherical_geometry import great_circle_arc
>>> great_circle_arc.HAS_C_UFUNCS
True

>>> math_util.length([[np.nan, 0, 0]], [[0, 0, np.inf]])
DEFINITELY C CODE
<stdin>:1: RuntimeWarning: invalid value encountered in length
array([0.])
>>> math_util.__file__
'[redacted]/spherical_geometry/math_util.cpython-311-darwin.so'
pllim commented 3 months ago

Mihai fixed it. Mihai is a good man.