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

Failed test: test_overlap #252

Closed Hellseher closed 10 months ago

Hellseher commented 10 months ago

Hi!

version: 1.2.22

I tried to enable as much test as possible while preparing update for Guix and faced only with one failed test:

_________________________________ test_overlap _________________________________

    def test_overlap():
        def build_polygon(offset):
            points = []
            corners = [(0.0, 0.0), (0.0, 10.0), (10.0, 10.0), (10.0, 0.0)]
            for corner in corners:
                point = np.asarray(corner)
                point[0] += offset
                points.append(np.asarray(vector.lonlat_to_vector(point[0],
                                                                 point[1])))
            poly = polygon.SphericalPolygon(points)
            return poly

        first_poly = build_polygon(0.0)
        for i in range(11):
            offset = float(i)
            second_poly = build_polygon(offset)
>           overlap_area = first_poly.overlap(second_poly)

spherical_geometry/tests/test_basic.py:176:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
spherical_geometry/polygon.py:687: in overlap
    intersection = self.intersection(other)
spherical_geometry/polygon.py:1209: in intersection
    subpolygons = polya.intersection(polyb)
spherical_geometry/polygon.py:664: in intersection
    return g.intersection()
spherical_geometry/graph.py:444: in intersection
    self._sanity_check("intersection: remove cut lines")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <spherical_geometry.graph.Graph object at 0x7fff72d3e9b0>
msg = 'intersection: remove cut lines', node_is_2 = False

    def _sanity_check(self, msg, node_is_2=False):
        """
        For debugging purposes: assert that edges and nodes are
        connected to each other correctly and there are no orphaned
        edges or nodes.
        """
        if not DEBUG:
            return

        unique_edges = set()
        for edge in self._edges:
            for node in edge._nodes:
                if edge not in node._edges or node not in self._nodes:
                    raise MalformedPolygonError(msg)
            edge_repr = [tuple(x._point) for x in edge._nodes]
            edge_repr.sort()
            edge_repr = tuple(edge_repr)
            # assert edge_repr not in unique_edges
            unique_edges.add(edge_repr)

        for node in self._nodes:
            if node_is_2:
                if len(node._edges) % 2 != 0:
                    raise MalformedPolygonError(msg)
            else:
                if not len(node._edges) >= 2:
>                   raise MalformedPolygonError(msg)
E                   spherical_geometry.polygon.MalformedPolygonError: intersection: remove cut lines

spherical_geometry/graph.py:392: MalformedPolygonError
=============================== warnings summary ===============================
../../../gnu/store/06cjgrygh79bxbsr0x44ryx1wy1pwvh4-python-setuptools-67.6.1/lib/python3.10/site-packages/pkg_resources/__init__.py:121
  /gnu/store/06cjgrygh79bxbsr0x44ryx1wy1pwvh4-python-setuptools-67.6.1/lib/python3.10/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
    warnings.warn("pkg_resources is deprecated as an API", DeprecationWarning)
    spherical_geometry/tests/test_intersection.py::test4
spherical_geometry/tests/test_union.py::test5
spherical_geometry/tests/test_union.py::test7
  /gnu/store/sflwbnc30p1g0fs9wfvbwsrbmlvbngl1-python-astropy-5.3.3/lib/python3.10/site-packages/astropy/wcs/wcs.py:551: FITSFixedWarning: CPERROR1= 0.0 / Maximum error of NPOL correction for axis 1
  keyword looks very much like CPERRja but isn't.
    wcsprm = _wcs.Wcsprm(

spherical_geometry/tests/test_intersection.py::test4
spherical_geometry/tests/test_union.py::test5
spherical_geometry/tests/test_union.py::test7
  /gnu/store/sflwbnc30p1g0fs9wfvbwsrbmlvbngl1-python-astropy-5.3.3/lib/python3.10/site-packages/astropy/wcs/wcs.py:551: FITSFixedWarning: CPERROR2= 0.0 / Maximum error of NPOL correction for axis 2
  keyword looks very much like CPERRja but isn't.
    wcsprm = _wcs.Wcsprm(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED spherical_geometry/tests/test_basic.py::test_overlap - spherical_geome...
======= 1 failed, 47 passed, 1 skipped, 7 warnings in 255.79s (0:04:15) ========

Used inputs:

mcara commented 10 months ago

I am not familiar with Guix. I run tests with all these versions (however, using the included version of qd with the spherical_geometry version 1.2.22) and I was unable to reproduce this failure.

pllim commented 10 months ago

@Hellseher , does GUIX provide any image that can be used in GitHub Actions so we can try to reproduce this failure in the CI? Or anything close enough at https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources or https://github.com/uraimo/run-on-arch-action ?

pllim commented 10 months ago

By the way, how did you get qd 2.3.23? I cannot find it on GitHub. The closest I found was https://github.com/scibuilder/QD and that one was from 8 years ago at 2.3.17.

pllim commented 10 months ago

Also maybe relevant: https://github.com/spacetelescope/spherical_geometry/issues/227#issuecomment-1783769741

Universebenzene commented 10 months ago

By the way, how did you get qd 2.3.23? I cannot find it on GitHub. The closest I found was https://github.com/scibuilder/QD and that one was from 8 years ago at 2.3.17.

Here on the offical page

Hellseher commented 10 months ago

Hi @pllim,

There is GHA available which provides Guix https://github.com/PromyLOPh/guix-install-action Example on how it's implemented in CI: https://github.com/artyom-poptsov/guile-ssh/blob/master/.github/workflows/guix.yml

The code was pulled from author's home page: Used source in Guix: https://crd-legacy.lbl.gov/~dhbailey/mpdist/qd-2.3.23.tar.gz Link to the package on home page: https://www.davidhbailey.com/dhbsoftware/qd-2.3.23.tar.gz Author's home page: https://www.davidhbailey.com/dhbsoftware/

Thanks, Oleg

pllim commented 10 months ago

Thanks, @Hellseher ! There is now a separate but related discussion on whether system qd is even supported, please see https://github.com/spacetelescope/spherical_geometry/issues/255 .

pllim commented 10 months ago

Re: https://github.com/spacetelescope/spherical_geometry/issues/252#issuecomment-1789754559

@Hellseher , I am not familiar with GUIX at all so it is unclear to me how this package can model after https://github.com/artyom-poptsov/guile-ssh/blob/master/.github/workflows/guix.yml . We have no plans to ship nor maintain any guix.scm file. Is it not possible to do a normal pip install in GUIX? Is there an image that comes with your system qd already available?

Hellseher commented 10 months ago

Hi @pllim

I agree that Guix is not in top mainstream of GNU/Linux distributions. You don't need to provide guix.scm in the project to build with newer version of any inputs. If it helps it comes as ready to use package in Debian and Ubuntu.

pip is available, but it does not guaranty reproducibility on other machines with different system wide libraries.

I'm not sure which image you refer to, there are ISO and Qemu images availalbe on homepage https://guix.gnu.org/en/download/

I would expect this issue will be resolved after new release with latest qd version (#227, #255 ).

If it would be actual after all related dependencies are updated I'll prepare reducible GitHub Actions script.

Thanks, Oleg

pllim commented 10 months ago

OK looks like it won't be trivial to add GUIX to our CI and I don't think this is an issue anymore now that there is a qd 2.3.24, so closing. Thanks!