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

Test failures with NumPy 2.0.0 #210

Open
mgorny opened this issue Jun 28, 2024 · 0 comments
Open

Test failures with NumPy 2.0.0 #210

mgorny opened this issue Jun 28, 2024 · 0 comments

Comments

@mgorny
Copy link

mgorny commented Jun 28, 2024

After upgrading to NumPy 2.0.0, 6 tests fail:

$ tox -e py312
.pkg: _optional_hooks> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: prepare_metadata_for_build_wheel> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
.pkg: build_sdist> python /usr/lib/python3.12/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
py312: install_package> python -I -m pip install --force-reinstall --no-deps /tmp/patsy/.tox/.tmp/package/2/patsy-0.5.6.tar.gz
py312: commands[0]> pytest -vv --cov=patsy --cov-config=/tmp/patsy/.coveragerc --cov-report=term-missing --cov-report=xml --cov-report=html:/tmp/patsy/.tox/coverage/py312
========================================================= test session starts =========================================================
platform linux -- Python 3.12.3, pytest-8.2.2, pluggy-1.5.0 -- /tmp/patsy/.tox/py312/bin/python
cachedir: .tox/py312/.pytest_cache
rootdir: /tmp/patsy
configfile: setup.cfg
testpaths: patsy
plugins: cov-5.0.0
collected 148 items                                                                                                                   

patsy/build.py::test__max_allowed_dim PASSED                                                                                    [  0%]
patsy/build.py::test__eval_factor_numerical PASSED                                                                              [  1%]
patsy/build.py::test__eval_factor_categorical PASSED                                                                            [  2%]
patsy/build.py::test__column_combinations PASSED                                                                                [  2%]
patsy/build.py::test__subterm_column_names_iter_and__build_subterm PASSED                                                       [  3%]
patsy/build.py::test__factors_memorize PASSED                                                                                   [  4%]
patsy/build.py::test__examine_factor_types PASSED                                                                               [  4%]
patsy/builtins.py::test_I PASSED                                                                                                [  5%]
patsy/builtins.py::test_Q PASSED                                                                                                [  6%]
patsy/categorical.py::test_C PASSED                                                                                             [  6%]
patsy/categorical.py::test_guess_categorical PASSED                                                                             [  7%]
patsy/categorical.py::test_CategoricalSniffer PASSED                                                                            [  8%]
patsy/categorical.py::test_categorical_to_int PASSED                                                                            [  8%]
patsy/constraint.py::test_LinearConstraint PASSED                                                                               [  9%]
patsy/constraint.py::test_LinearConstraint_combine PASSED                                                                       [ 10%]
patsy/constraint.py::test__tokenize_constraint PASSED                                                                           [ 10%]
patsy/constraint.py::test_linear_constraint PASSED                                                                              [ 11%]
patsy/constraint.py::test_eval_errors PASSED                                                                                    [ 12%]
patsy/contrasts.py::test_ContrastMatrix PASSED                                                                                  [ 12%]
patsy/contrasts.py::test__obj_to_readable_str PASSED                                                                            [ 13%]
patsy/contrasts.py::test__name_levels PASSED                                                                                    [ 14%]
patsy/contrasts.py::test__get_level PASSED                                                                                      [ 14%]
patsy/contrasts.py::test_Treatment PASSED                                                                                       [ 15%]
patsy/contrasts.py::test_Poly PASSED                                                                                            [ 16%]
patsy/contrasts.py::test_Sum PASSED                                                                                             [ 16%]
patsy/contrasts.py::test_Helmert PASSED                                                                                         [ 17%]
patsy/contrasts.py::test_diff PASSED                                                                                            [ 18%]
patsy/desc.py::test_Term PASSED                                                                                                 [ 18%]
patsy/desc.py::test_ModelDesc PASSED                                                                                            [ 19%]
patsy/desc.py::test_ModelDesc_from_formula PASSED                                                                               [ 20%]
patsy/desc.py::test_eval_formula PASSED                                                                                         [ 20%]
patsy/desc.py::test_eval_formula_error_reporting PASSED                                                                         [ 21%]
patsy/desc.py::test_formula_factor_origin PASSED                                                                                [ 22%]
patsy/design_info.py::test_FactorInfo PASSED                                                                                    [ 22%]
patsy/design_info.py::test_SubtermInfo PASSED                                                                                   [ 23%]
patsy/design_info.py::test_DesignInfo PASSED                                                                                    [ 24%]
patsy/design_info.py::test_DesignInfo_from_array PASSED                                                                         [ 25%]
patsy/design_info.py::test_DesignInfo_linear_constraint PASSED                                                                  [ 25%]
patsy/design_info.py::test_DesignInfo_deprecated_attributes PASSED                                                              [ 26%]
patsy/design_info.py::test__format_float_column PASSED                                                                          [ 27%]
patsy/design_info.py::test_design_matrix PASSED                                                                                 [ 27%]
patsy/eval.py::test_VarLookupDict PASSED                                                                                        [ 28%]
patsy/eval.py::test_ast_names PASSED                                                                                            [ 29%]
patsy/eval.py::test_ast_names_disallowed_nodes PASSED                                                                           [ 29%]
patsy/eval.py::test_EvalEnvironment_capture_namespace PASSED                                                                    [ 30%]
patsy/eval.py::test_EvalEnvironment_capture_flags PASSED                                                                        [ 31%]
patsy/eval.py::test_EvalEnvironment_eval_namespace PASSED                                                                       [ 31%]
patsy/eval.py::test_EvalEnvironment_eval_flags PASSED                                                                           [ 32%]
patsy/eval.py::test_EvalEnvironment_subset PASSED                                                                               [ 33%]
patsy/eval.py::test_EvalEnvironment_eq PASSED                                                                                   [ 33%]
patsy/eval.py::test_EvalFactor_basics PASSED                                                                                    [ 34%]
patsy/eval.py::test_EvalFactor_memorize_passes_needed PASSED                                                                    [ 35%]
patsy/eval.py::test_EvalFactor_end_to_end PASSED                                                                                [ 35%]
patsy/eval.py::test_annotated_tokens PASSED                                                                                     [ 36%]
patsy/eval.py::test_replace_bare_funcalls PASSED                                                                                [ 37%]
patsy/eval.py::test_capture_obj_method_calls PASSED                                                                             [ 37%]
patsy/infix_parser.py::test_infix_parse PASSED                                                                                  [ 38%]
patsy/mgcv_cubic_splines.py::test__map_cyclic PASSED                                                                            [ 39%]
patsy/mgcv_cubic_splines.py::test__map_cyclic_errors PASSED                                                                     [ 39%]
patsy/mgcv_cubic_splines.py::test__row_tensor_product_errors PASSED                                                             [ 40%]
patsy/mgcv_cubic_splines.py::test__row_tensor_product PASSED                                                                    [ 41%]
patsy/mgcv_cubic_splines.py::test__get_all_sorted_knots PASSED                                                                  [ 41%]
patsy/mgcv_cubic_splines.py::test_crs_errors PASSED                                                                             [ 42%]
patsy/mgcv_cubic_splines.py::test_crs_compat PASSED                                                                             [ 43%]
patsy/mgcv_cubic_splines.py::test_crs_with_specific_constraint PASSED                                                           [ 43%]
patsy/mgcv_cubic_splines.py::test_te_errors PASSED                                                                              [ 44%]
patsy/mgcv_cubic_splines.py::test_te_1smooth PASSED                                                                             [ 45%]
patsy/mgcv_cubic_splines.py::test_te_2smooths PASSED                                                                            [ 45%]
patsy/mgcv_cubic_splines.py::test_te_3smooths PASSED                                                                            [ 46%]
patsy/missing.py::test_NAAction_basic PASSED                                                                                    [ 47%]
patsy/missing.py::test_NAAction_NA_types_numerical PASSED                                                                       [ 47%]
patsy/missing.py::test_NAAction_NA_types_categorical PASSED                                                                     [ 48%]
patsy/missing.py::test_NAAction_drop PASSED                                                                                     [ 49%]
patsy/missing.py::test_NAAction_raise PASSED                                                                                    [ 50%]
patsy/origin.py::test_Origin PASSED                                                                                             [ 50%]
patsy/parse_formula.py::test__tokenize_formula PASSED                                                                           [ 51%]
patsy/parse_formula.py::test_parse_formula PASSED                                                                               [ 52%]
patsy/parse_formula.py::test_parse_origin PASSED                                                                                [ 52%]
patsy/parse_formula.py::test_parse_errors PASSED                                                                                [ 53%]
patsy/parse_formula.py::test_parse_extra_op PASSED                                                                              [ 54%]
patsy/redundancy.py::test__Subterm PASSED                                                                                       [ 54%]
patsy/redundancy.py::test__subsets_sorted PASSED                                                                                [ 55%]
patsy/redundancy.py::test__simplify_subterms PASSED                                                                             [ 56%]
patsy/redundancy.py::test_pick_contrasts_for_term PASSED                                                                        [ 56%]
patsy/splines.py::test__R_compat_quantile PASSED                                                                                [ 57%]
patsy/splines.py::test_bs_compat PASSED                                                                                         [ 58%]
patsy/splines.py::test_bs_0degree PASSED                                                                                        [ 58%]
patsy/splines.py::test_bs_errors PASSED                                                                                         [ 59%]
patsy/test_build.py::test_assert_full_rank PASSED                                                                               [ 60%]
patsy/test_build.py::test_simple PASSED                                                                                         [ 60%]
patsy/test_build.py::test_R_bugs PASSED                                                                                         [ 61%]
patsy/test_build.py::test_redundancy_thoroughly PASSED                                                                          [ 62%]
patsy/test_build.py::test_data_types PASSED                                                                                     [ 62%]
patsy/test_build.py::test_build_design_matrices_dtype PASSED                                                                    [ 63%]
patsy/test_build.py::test_return_type PASSED                                                                                    [ 64%]
patsy/test_build.py::test_NA_action PASSED                                                                                      [ 64%]
patsy/test_build.py::test_NA_drop_preserves_levels PASSED                                                                       [ 65%]
patsy/test_build.py::test_return_type_pandas PASSED                                                                             [ 66%]
patsy/test_build.py::test_data_mismatch PASSED                                                                                  [ 66%]
patsy/test_build.py::test_data_independent_builder PASSED                                                                       [ 67%]
patsy/test_build.py::test_same_factor_in_two_matrices PASSED                                                                    [ 68%]
patsy/test_build.py::test_eval_env_type_builder PASSED                                                                          [ 68%]
patsy/test_build.py::test_categorical PASSED                                                                                    [ 69%]
patsy/test_build.py::test_contrast PASSED                                                                                       [ 70%]
patsy/test_build.py::test_DesignInfo_subset PASSED                                                                              [ 70%]
patsy/test_highlevel.py::test_formula_likes FAILED                                                                              [ 71%]
patsy/test_highlevel.py::test_return_pandas PASSED                                                                              [ 72%]
patsy/test_highlevel.py::test_term_info PASSED                                                                                  [ 72%]
patsy/test_highlevel.py::test_data_types PASSED                                                                                 [ 73%]
patsy/test_highlevel.py::test_categorical PASSED                                                                                [ 74%]
patsy/test_highlevel.py::test_builtins FAILED                                                                                   [ 75%]
patsy/test_highlevel.py::test_incremental FAILED                                                                                [ 75%]
patsy/test_highlevel.py::test_env_transform PASSED                                                                              [ 76%]
patsy/test_highlevel.py::test_term_order PASSED                                                                                 [ 77%]
patsy/test_highlevel.py::test_future PASSED                                                                                     [ 77%]
patsy/test_highlevel.py::test_multicolumn PASSED                                                                                [ 78%]
patsy/test_highlevel.py::test_dmatrix_dmatrices_no_data PASSED                                                                  [ 79%]
patsy/test_highlevel.py::test_designinfo_describe PASSED                                                                        [ 79%]
patsy/test_highlevel.py::test_evalfactor_reraise PASSED                                                                         [ 80%]
patsy/test_highlevel.py::test_dmatrix_NA_action PASSED                                                                          [ 81%]
patsy/test_highlevel.py::test_0d_data PASSED                                                                                    [ 81%]
patsy/test_highlevel.py::test_env_not_saved_in_builder PASSED                                                                   [ 82%]
patsy/test_highlevel.py::test_C_and_pandas_categorical PASSED                                                                   [ 83%]
patsy/test_regressions.py::test_issue_11 PASSED                                                                                 [ 83%]
patsy/test_state.py::test_Center FAILED                                                                                         [ 84%]
patsy/test_state.py::test_stateful_transform_wrapper FAILED                                                                     [ 85%]
patsy/test_state.py::test_Standardize PASSED                                                                                    [ 85%]
patsy/tokens.py::test_python_tokenize PASSED                                                                                    [ 86%]
patsy/tokens.py::test_pretty_untokenize_and_normalize_token_spacing PASSED                                                      [ 87%]
patsy/user_util.py::test_balanced PASSED                                                                                        [ 87%]
patsy/user_util.py::test_demo_data PASSED                                                                                       [ 88%]
patsy/user_util.py::test_LookupFactor PASSED                                                                                    [ 89%]
patsy/util.py::test_asarray_or_pandas FAILED                                                                                    [ 89%]
patsy/util.py::test_atleast_2d_column_default PASSED                                                                            [ 90%]
patsy/util.py::test_pandas_friendly_reshape PASSED                                                                              [ 91%]
patsy/util.py::test_to_uniqueify_list PASSED                                                                                    [ 91%]
patsy/util.py::test_wide_dtype_for_and_widen PASSED                                                                             [ 92%]
patsy/util.py::test_PushbackAdapter PASSED                                                                                      [ 93%]
patsy/util.py::test_repr_pretty PASSED                                                                                          [ 93%]
patsy/util.py::test_SortAnythingKey PASSED                                                                                      [ 94%]
patsy/util.py::test_safe_scalar_isnan PASSED                                                                                    [ 95%]
patsy/util.py::test_safe_isnan PASSED                                                                                           [ 95%]
patsy/util.py::test_iterable PASSED                                                                                             [ 96%]
patsy/util.py::test_pandas_Categorical_from_codes PASSED                                                                        [ 97%]
patsy/util.py::test_pandas_Categorical_accessors PASSED                                                                         [ 97%]
patsy/util.py::test_safe_is_pandas_categorical PASSED                                                                           [ 98%]
patsy/util.py::test_safe_issubdtype PASSED                                                                                      [ 99%]
patsy/util.py::test_safe_string_eq PASSED                                                                                       [100%]

============================================================== FAILURES ===============================================================
_________________________________________________________ test_formula_likes __________________________________________________________

    def test_formula_likes():
        # Plain array-like, rhs only
>       t([[1, 2, 3], [4, 5, 6]], {}, 0,
          False,
          [[1, 2, 3], [4, 5, 6]], ["x0", "x1", "x2"])

patsy/test_highlevel.py:150: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/test_highlevel.py:104: in t
    rhs = f(formula_like, data, depth)
patsy/highlevel.py:290: in dmatrix
    (lhs, rhs) = _do_highlevel_design(formula_like, data, eval_env,
patsy/highlevel.py:181: in _do_highlevel_design
    (lhs, rhs) = (None, asarray_or_pandas(formula_like, subok=True))
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = [[1, 2, 3], [4, 5, 6]], copy = False, dtype = None, subok = True

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   https://github.com/pydata/pandas/issues/1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError
____________________________________________________________ test_builtins ____________________________________________________________

msg = 'Error evaluating factor', origin = EvalFactor('center(x)')
f = <bound method EvalEnvironment.eval of <patsy.eval.EvalEnvironment object at 0x7f14286b5fd0>>
args = ('_patsy_stobj0__center__.transform(x)',)
kwargs = {'inner_namespace': VarLookupDict([{}, {'x': [1, 2, 3], 'y': [4, 5, 6], 'a b c': [10, 20, 30]}, {'_patsy_stobj0__center__': <patsy.state.Center object at 0x7f14286b4a40>}])}
new_exc = PatsyError('Error evaluating factor: ValueError: Unable to avoid copy while creating an array as requested.\nIf using ...r more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.')

    def call_and_wrap_exc(msg, origin, f, *args, **kwargs):
        try:
>           return f(*args, **kwargs)

patsy/compat.py:36: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/eval.py:169: in eval
    return eval(code, {}, VarLookupDict([inner_namespace]
patsy/state.py:106: in transform
    x = asarray_or_pandas(x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = [1, 2, 3], copy = False, dtype = None, subok = False

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   https://github.com/pydata/pandas/issues/1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError

The above exception was the direct cause of the following exception:

    def test_builtins():
        data = {"x": [1, 2, 3],
                "y": [4, 5, 6],
                "a b c": [10, 20, 30]}
        t("0 + I(x + y)", data, 0,
          True,
          [[1], [2], [3], [4], [5], [6]], ["I(x + y)"])
        t("Q('a b c')", data, 0,
          True,
          [[1, 10], [1, 20], [1, 30]], ["Intercept", "Q('a b c')"])
>       t("center(x)", data, 0,
          True,
          [[1, -1], [1, 0], [1, 1]], ["Intercept", "center(x)"])

patsy/test_highlevel.py:498: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/test_highlevel.py:83: in t
    builder = incr_dbuilder(formula_like, data_iter_maker, depth)
patsy/highlevel.py:111: in incr_dbuilder
    design_infos = _try_incr_builders(formula_like, data_iter_maker, eval_env,
patsy/highlevel.py:66: in _try_incr_builders
    return design_matrix_builders([formula_like.lhs_termlist,
patsy/build.py:693: in design_matrix_builders
    cat_levels_contrasts) = _examine_factor_types(all_factors,
patsy/build.py:443: in _examine_factor_types
    value = factor.eval(factor_states[factor], data)
patsy/eval.py:568: in eval
    return self._eval(memorize_state["eval_code"],
patsy/eval.py:551: in _eval
    return call_and_wrap_exc("Error evaluating factor",
patsy/compat.py:43: in call_and_wrap_exc
    exec("raise new_exc from e")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   patsy.PatsyError: Error evaluating factor: ValueError: Unable to avoid copy while creating an array as requested.
E   If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E   For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
E       center(x)
E       ^^^^^^^^^

<string>:1: PatsyError
__________________________________________________________ test_incremental ___________________________________________________________

msg = 'Error evaluating factor', origin = EvalFactor('center(np.sin(center(x)))')
f = <bound method EvalEnvironment.eval of <patsy.eval.EvalEnvironment object at 0x7f14286ba8a0>>
args = ('_patsy_stobj0__center__.memorize_chunk(np.sin(_patsy_stobj1__center__.transform(x)))',)
kwargs = {'inner_namespace': VarLookupDict([{}, {'a': ['a2', 'a2', 'a2'], 'x': [1, 2, 3]}, {'_patsy_stobj0__center__': <patsy.state.Center object at 0x7f14286b8f50>, '_patsy_stobj1__center__': <patsy.state.Center object at 0x7f14286b9d00>}])}
new_exc = PatsyError('Error evaluating factor: ValueError: Unable to avoid copy while creating an array as requested.\nIf using ...r more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.')

    def call_and_wrap_exc(msg, origin, f, *args, **kwargs):
        try:
>           return f(*args, **kwargs)

patsy/compat.py:36: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/eval.py:169: in eval
    return eval(code, {}, VarLookupDict([inner_namespace]
patsy/state.py:106: in transform
    x = asarray_or_pandas(x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = [1, 2, 3], copy = False, dtype = None, subok = False

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   https://github.com/pydata/pandas/issues/1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError

The above exception was the direct cause of the following exception:

    def test_incremental():
        # incr_dbuilder(s)
        # stateful transformations
        datas = [
            {"a": ["a2", "a2", "a2"],
             "x": [1, 2, 3]},
            {"a": ["a2", "a2", "a1"],
             "x": [4, 5, 6]},
            ]
        x = np.asarray([1, 2, 3, 4, 5, 6])
        sin_center_x = np.sin(x - np.mean(x))
        x_col = sin_center_x - np.mean(sin_center_x)
        def data_iter_maker():
            return iter(datas)
>       builders = incr_dbuilders("1 ~ a + center(np.sin(center(x)))",
                                  data_iter_maker)

patsy/test_highlevel.py:516: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/highlevel.py:129: in incr_dbuilders
    design_infos = _try_incr_builders(formula_like, data_iter_maker, eval_env,
patsy/highlevel.py:66: in _try_incr_builders
    return design_matrix_builders([formula_like.lhs_termlist,
patsy/build.py:689: in design_matrix_builders
    factor_states = _factors_memorize(all_factors, data_iter_maker, eval_env)
patsy/build.py:368: in _factors_memorize
    factor.memorize_chunk(state, which_pass, data)
patsy/eval.py:559: in memorize_chunk
    self._eval(state["memorize_code"][obj_name],
patsy/eval.py:551: in _eval
    return call_and_wrap_exc("Error evaluating factor",
patsy/compat.py:43: in call_and_wrap_exc
    exec("raise new_exc from e")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

>   ???
E   patsy.PatsyError: Error evaluating factor: ValueError: Unable to avoid copy while creating an array as requested.
E   If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E   For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
E       1 ~ a + center(np.sin(center(x)))
E               ^^^^^^^^^^^^^^^^^^^^^^^^^

<string>:1: PatsyError
_____________________________________________________________ test_Center _____________________________________________________________

    def test_Center():
>       check_stateful(Center, True, [1, 2, 3], [-1, 0, 1])

patsy/test_state.py:117: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/test_state.py:81: in check_stateful
    output_chunk = t.transform(input_chunk, *args, **kwargs)
patsy/state.py:106: in transform
    x = asarray_or_pandas(x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = np.int64(1), copy = False, dtype = None, subok = False

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   https://github.com/pydata/pandas/issues/1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError
-------------------------------------------------------- Captured stdout call ---------------------------------------------------------
[array([1, 2, 3])]
[1 2 3]
___________________________________________________ test_stateful_transform_wrapper ___________________________________________________

    def test_stateful_transform_wrapper():
>       assert np.allclose(center([1, 2, 3]), [-1, 0, 1])

patsy/test_state.py:124: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
patsy/state.py:48: in stateful_transform_wrapper
    return transform.transform(*args, **kwargs)
patsy/state.py:106: in transform
    x = asarray_or_pandas(x)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = [1, 2, 3], copy = False, dtype = None, subok = False

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   https://github.com/pydata/pandas/issues/1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError
_______________________________________________________ test_asarray_or_pandas ________________________________________________________

    def test_asarray_or_pandas():
        import warnings
>       assert type(asarray_or_pandas([1, 2, 3])) is np.ndarray

patsy/util.py:72: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

a = [1, 2, 3], copy = False, dtype = None, subok = False

    def asarray_or_pandas(a, copy=False, dtype=None, subok=False):
        if have_pandas:
            if isinstance(a, (pandas.Series, pandas.DataFrame)):
                # The .name attribute on Series is discarded when passing through
                # the constructor:
                #   https://github.com/pydata/pandas/issues/1578
                extra_args = {}
                if hasattr(a, "name"):
                    extra_args["name"] = a.name
                return a.__class__(a, copy=copy, dtype=dtype, **extra_args)
>       return np.array(a, copy=copy, dtype=dtype, subok=subok)
E       ValueError: Unable to avoid copy while creating an array as requested.
E       If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
E       For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.

patsy/util.py:67: ValueError

---------- coverage: platform linux, python 3.12.3-final-0 -----------
Name                             Stmts   Miss Branch BrPart  Cover   Missing
----------------------------------------------------------------------------
patsy/__init__.py                   58      0     12      2  97.1%   15->20, 58->exit
patsy/build.py                     314     16    168     10  93.8%   30, 683->685, 791->795, 869, 878->exit, 880-881, 896, 916-920, 926, 954-960
patsy/builtins.py                   20      0      0      0 100.0%
patsy/categorical.py               115     11     58      6  87.9%   52, 127, 194-195, 313-319, 338-339, 368
patsy/compat.py                     18      4      6      2  66.7%   29, 48-50
patsy/compat_ordereddict.py          9      1      0      0  88.9%   15
patsy/constraint.py                198      4     68      0  98.5%   15-16, 425-426
patsy/contrasts.py                 163      4     36      1  97.5%   78-81
patsy/desc.py                      205      2     56      2  98.5%   397, 407
patsy/design_info.py               322      2    172      2  99.2%   688, 1134
patsy/eval.py                      236      1     72      2  99.0%   106->109, 501
patsy/highlevel.py                 103     48     56     10  48.4%   28, 42, 44-46, 52-55, 116, 133-135, 157, 160, 173-177, 189-223, 293
patsy/infix_parser.py              140      2     54      0  99.0%   45, 95
patsy/mgcv_cubic_splines.py        282      4    118      4  97.5%   17, 683-685, 713->716, 743->746
patsy/missing.py                    52      0     26      0 100.0%
patsy/origin.py                     36      2     10      0  95.7%   85, 88
patsy/parse_formula.py              92      1     38      1  98.5%   142
patsy/redundancy.py                 91      2     28      0  98.3%   67, 105
patsy/splines.py                   100      4     48      2  94.6%   16, 243-245
patsy/state.py                      65      1     14      1  97.5%   114
patsy/test_build.py                 45      2      8      2  92.5%   25, 30
patsy/test_highlevel.py             28      9      4      0  59.4%   29, 59-62, 65-68
patsy/test_regressions.py            1      0      0      0 100.0%
patsy/test_splines_bs_data.py        4      0      0      0 100.0%
patsy/test_splines_crs_data.py       4      0      0      0 100.0%
patsy/test_state.py                 59     16     32      4  73.6%   42-63, 86-87, 102, 111
patsy/tokens.py                     78      1     36      1  98.2%   39
patsy/user_util.py                  69      0     22      0 100.0%
patsy/util.py                      224     49     86     11  69.0%   37, 46-51, 59-66, 158-161, 238-248, 296->295, 302->301, 446-447, 529, 612-620, 634-639, 646-651, 669, 675-679, 706
patsy/version.py                     1      0      0      0 100.0%
----------------------------------------------------------------------------
TOTAL                             3132    186   1228     63  92.4%
Coverage HTML written to dir /tmp/patsy/.tox/coverage/py312
Coverage XML written to file coverage.xml

======================================================= short test summary info =======================================================
FAILED patsy/test_highlevel.py::test_formula_likes - ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
FAILED patsy/test_highlevel.py::test_builtins - patsy.PatsyError: Error evaluating factor: ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
    center(x)
    ^^^^^^^^^
FAILED patsy/test_highlevel.py::test_incremental - patsy.PatsyError: Error evaluating factor: ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
    1 ~ a + center(np.sin(center(x)))
            ^^^^^^^^^^^^^^^^^^^^^^^^^
FAILED patsy/test_state.py::test_Center - ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
FAILED patsy/test_state.py::test_stateful_transform_wrapper - ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
FAILED patsy/util.py::test_asarray_or_pandas - ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
============================================== 6 failed, 142 passed in 92.74s (0:01:32) ===============================================
py312: exit 1 (93.68 seconds) /tmp/patsy> pytest -vv --cov=patsy --cov-config=/tmp/patsy/.coveragerc --cov-report=term-missing --cov-report=xml --cov-report=html:/tmp/patsy/.tox/coverage/py312 pid=193436
  py312: FAIL code 1 (97.18=setup[3.49]+cmd[93.68] seconds)
  evaluation failed :( (97.26 seconds)

This is with 8546450 (v0.5.6).

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

No branches or pull requests

1 participant