matthewwardrop / formulaic

A high-performance implementation of Wilkinson formulas for Python.
MIT License
336 stars 24 forks source link

2 tests fail #140

Closed yurivict closed 1 year ago

yurivict commented 1 year ago
=============================================================================================== FAILURES ================================================================================================
_________________________________________________________________________________________ TestPoly.test_degree __________________________________________________________________________________________

self = <tests.transforms.test_poly.TestPoly object at 0x92b0eba60>
data = array([0.  , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 ,
       0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1.  ])

    def test_degree(self, data):
        state = {}
        V = poly(data, degree=3, _state=state)

        assert V.shape[1] == 3

        # Comparison data copied from R output of:
        # > data = seq(from=0, to=1, by=0.05)
        # > poly(data, 3)
        r_reference = numpy.array(
            [
                [-3.603750e-01, 0.42285541, -4.332979e-01],
                [-3.243375e-01, 0.29599879, -1.733191e-01],
                [-2.883000e-01, 0.18249549, 1.824412e-02],
                [-2.522625e-01, 0.08234553, 1.489937e-01],
                [-2.162250e-01, -0.00445111, 2.265312e-01],
                [-1.801875e-01, -0.07789442, 2.584584e-01],
                [-1.441500e-01, -0.13798440, 2.523770e-01],
                [-1.081125e-01, -0.18472105, 2.158888e-01],
                [-7.207500e-02, -0.21810437, 1.565954e-01],
                [-3.603750e-02, -0.23813436, 8.209854e-02],
                [-3.000725e-17, -0.24481103, -4.395626e-17],
                [3.603750e-02, -0.23813436, -8.209854e-02],
                [7.207500e-02, -0.21810437, -1.565954e-01],
                [1.081125e-01, -0.18472105, -2.158888e-01],
                [1.441500e-01, -0.13798440, -2.523770e-01],
                [1.801875e-01, -0.07789442, -2.584584e-01],
                [2.162250e-01, -0.00445111, -2.265312e-01],
                [2.522625e-01, 0.08234553, -1.489937e-01],
                [2.883000e-01, 0.18249549, -1.824412e-02],
                [3.243375e-01, 0.29599879, 1.733191e-01],
                [3.603750e-01, 0.42285541, 4.332979e-01],
            ]
        )

        assert numpy.allclose(
            V,
            r_reference,
        )

>       assert pytest.approx(state["alpha"], {0: 0.5, 1: 0.5, 2: 0.5})
E       AssertionError: approx() is not supported in a boolean context.
E       Did you mean: `assert a == approx(b)`?

tests/transforms/test_poly.py:98: AssertionError
__________________________________________________________________________________________ TestPoly.test_basic __________________________________________________________________________________________

self = <tests.transforms.test_poly.TestPoly object at 0x92b0eb910>
data = array([0.  , 0.05, 0.1 , 0.15, 0.2 , 0.25, 0.3 , 0.35, 0.4 , 0.45, 0.5 ,
       0.55, 0.6 , 0.65, 0.7 , 0.75, 0.8 , 0.85, 0.9 , 0.95, 1.  ])

    def test_basic(self, data):
        state = {}
        V = poly(data, _state=state)

        assert V.shape[1] == 1

        # Comparison data copied from R output of:
        # > data = seq(from=0, to=1, by=0.05)
        # > poly(data)
        r_reference = [
            -3.603750e-01,
            -3.243375e-01,
            -2.883000e-01,
            -2.522625e-01,
            -2.162250e-01,
            -1.801875e-01,
            -1.441500e-01,
            -1.081125e-01,
            -7.207500e-02,
            -3.603750e-02,
            -3.000725e-17,
            3.603750e-02,
            7.207500e-02,
            1.081125e-01,
            1.441500e-01,
            1.801875e-01,
            2.162250e-01,
            2.522625e-01,
            2.883000e-01,
            3.243375e-01,
            3.603750e-01,
        ]

        assert numpy.allclose(
            V[:, 0],
            r_reference,
        )

>       assert pytest.approx(state["alpha"], {0: 0.5})
E       AssertionError: approx() is not supported in a boolean context.
E       Did you mean: `assert a == approx(b)`?

tests/transforms/test_poly.py:50: AssertionError
=========================================================================================== warnings summary ============================================================================================
tests/test_formula.py::TestFormula::test_get_model_matrix
tests/test_formula.py::TestFormula::test_get_model_matrix
tests/test_formula.py::TestFormula::test_get_model_matrix
tests/test_formula.py::TestFormula::test_get_model_matrix
  /usr/ports/math/py-formulaic/work-py39/formulaic-0.5.2/formulaic/materializers/pandas.py:119: DeprecationWarning: The __array_wrap__ method of DataFrame and Series will be removed in a future version
    ":".join(solo_factors): functools.reduce(

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
======================================================================================== short test summary info ========================================================================================
SKIPPED [4] tests/materializers/test_arrow.py:63: PyArrow is required to run the arrow tests.
SKIPPED [4] tests/materializers/test_arrow.py:51: PyArrow is required to run the arrow tests.
SKIPPED [1] tests/materializers/test_arrow.py:94: PyArrow is required to run the arrow tests.
SKIPPED [1] tests/materializers/test_arrow.py:79: PyArrow is required to run the arrow tests.
========================================================================= 2 failed, 306 passed, 10 skipped, 4 warnings in 5.10s =========================================================================

Version: 0.5.2 Python-3.9 FreeBSD 13.2

matthewwardrop commented 1 year ago

Hi @yurivict ! Thanks for reporting. This has already been fixed in main, and will be released shortly in v0.6.0