giotto-tda icon indicating copy to clipboard operation
giotto-tda copied to clipboard

gtda/mapper/tests/test_visualization.py tests failed

Open beew opened this issue 1 year ago • 6 comments

Running pytest gtda produces two failed tests.

FAILED gtda/mapper/tests/test_visualization.py::test_pipeline_cloned[False] - AssertionError
FAILED gtda/mapper/tests/test_visualization.py::test_pipeline_cloned[True] - AssertionError

More detailed outputs

==================================================================================================== FAILURES =====================================================================================================
___________________________________________________________________________________________ test_pipeline_cloned[False] ___________________________________________________________________________________________

clone_pipeline = False

    @pytest.mark.parametrize("clone_pipeline", [False, True])
    def test_pipeline_cloned(clone_pipeline):
        """Verify that the pipeline is changed on interaction if and only if
        `clone_pipeline` is False."""
        # TODO: Monitor development of the ipytest project to convert these into
        # true notebook tests integrated with pytest
        params = {
            "cover": {
                "initial": {"n_intervals": 10, "kind": "uniform",
                            "overlap_frac": 0.1},
                "new": {"n_intervals": 15, "kind": "balanced", "overlap_frac": 0.2}
                },
            "clusterer": {
                "initial": {"affinity": "euclidean"},
                "new": {"affinity": "manhattan"}
                },
            "contract_nodes": {"initial": True, "new": False},
            "min_intersection": {"initial": 4, "new": 1},
            }
    
        pipe = make_mapper_pipeline(
            cover=CubicalCover(**params["cover"]["initial"]),
            clusterer=FirstSimpleGap(**params["clusterer"]["initial"]),
            contract_nodes=params["contract_nodes"]["initial"],
            min_intersection=params["min_intersection"]["initial"]
            )
        fig = plot_interactive_mapper_graph(pipe, X_arr,
                                            clone_pipeline=clone_pipeline)
    
        # Get relevant widgets and change their states, then check final values
        for step, values in params.items():
            if step in ["cover", "clusterer"]:
                for param_name, initial_param_value in values["initial"].items():
                    new_param_value = values["new"][param_name]
>                   widgets = _get_widgets_by_trait(fig, "description", param_name)

gtda/mapper/tests/test_visualization.py:432: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gtda/mapper/tests/test_visualization.py:336: in _get_widgets_by_trait
    for k, v in getattr(fig, widgets_attr).items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ipywidgets.widgets.widget._staticproperty object at 0x7f8810bfd780>
owner_self = VBox(children=(HBox(children=(VBox(children=(HTML(value='<b>Cover parameters</b>'), Text(value='uniform', continuous_u...escriptionStyle(description_width='100px')), Checkbox(value=False, description='Show logs: ', indent=False), Output()))
owner_cls = <class 'ipywidgets.widgets.widget_box.VBox'>

    def __get__(self, owner_self, owner_cls):
>       assert owner_self is None
E       AssertionError

../../opt/python310/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:295: AssertionError
___________________________________________________________________________________________ test_pipeline_cloned[True] ____________________________________________________________________________________________

clone_pipeline = True

    @pytest.mark.parametrize("clone_pipeline", [False, True])
    def test_pipeline_cloned(clone_pipeline):
        """Verify that the pipeline is changed on interaction if and only if
        `clone_pipeline` is False."""
        # TODO: Monitor development of the ipytest project to convert these into
        # true notebook tests integrated with pytest
        params = {
            "cover": {
                "initial": {"n_intervals": 10, "kind": "uniform",
                            "overlap_frac": 0.1},
                "new": {"n_intervals": 15, "kind": "balanced", "overlap_frac": 0.2}
                },
            "clusterer": {
                "initial": {"affinity": "euclidean"},
                "new": {"affinity": "manhattan"}
                },
            "contract_nodes": {"initial": True, "new": False},
            "min_intersection": {"initial": 4, "new": 1},
            }
    
        pipe = make_mapper_pipeline(
            cover=CubicalCover(**params["cover"]["initial"]),
            clusterer=FirstSimpleGap(**params["clusterer"]["initial"]),
            contract_nodes=params["contract_nodes"]["initial"],
            min_intersection=params["min_intersection"]["initial"]
            )
        fig = plot_interactive_mapper_graph(pipe, X_arr,
                                            clone_pipeline=clone_pipeline)
    
        # Get relevant widgets and change their states, then check final values
        for step, values in params.items():
            if step in ["cover", "clusterer"]:
                for param_name, initial_param_value in values["initial"].items():
                    new_param_value = values["new"][param_name]
>                   widgets = _get_widgets_by_trait(fig, "description", param_name)

gtda/mapper/tests/test_visualization.py:432: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
gtda/mapper/tests/test_visualization.py:336: in _get_widgets_by_trait
    for k, v in getattr(fig, widgets_attr).items():
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ipywidgets.widgets.widget._staticproperty object at 0x7f8810bfd780>
owner_self = VBox(children=(HBox(children=(VBox(children=(HTML(value='<b>Cover parameters</b>'), Text(value='uniform', continuous_u...escriptionStyle(description_width='100px')), Checkbox(value=False, description='Show logs: ', indent=False), Output()))
owner_cls = <class 'ipywidgets.widgets.widget_box.VBox'>

    def __get__(self, owner_self, owner_cls):
>       assert owner_self is None
E       AssertionError

../../opt/python310/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:295: AssertionError

import platform; print(platform.platform()) Linux-5.15.0-60-generic-x86_64-with-glibc2.35

import sys; print("Python", sys.version) Python 3.10.9 (main, Feb 7 2023, 22:43:20) [GCC 11.3.0]

import numpy; print("NumPy", numpy.version) NumPy 1.23.5

import scipy; print("SciPy", scipy.version) SciPy 1.10.0

import joblib; print("Joblib", joblib.version) Joblib 1.2.0

import sklearn; print("Scikit-learn", sklearn.version) Scikit-learn 1.2.1

import gtda; print("Giotto-tda", gtda.version) Giotto-tda 0.6.0

beew avatar Feb 26 '23 03:02 beew