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

marray failures in scipy.stats #71

Open
lucascolley opened this issue Dec 31, 2024 · 13 comments
Open

marray failures in scipy.stats #71

lucascolley opened this issue Dec 31, 2024 · 13 comments

Comments

@lucascolley
Copy link
Collaborator

https://github.com/lucascolley/scipy/tree/c7124c86e97540c60731b3414e5456edfc2cecb8

failures: https://gist.github.com/lucascolley/932b227d170e736589e04b5aac8690f0

There are about 10 extra failures for marray.array_api_strict using https://github.com/lucascolley/scipy/tree/159424172b34c7d513bbcda3b3a8f11f44a61dd8.

@mdhaber
Copy link
Owner

mdhaber commented Dec 31, 2024

I see a lot of places where it will be skipped where strict would also be skipped because the code relies on non-array API calls. There are also places it will be skipped because it can't be converted to a regular array for special function evaluation. And some of these are places that we can/should fix in SciPy, like using xp.broadcast_shapes, which can rely on NumPy regardless of backend, or using np.isfinite instead of xp.isfinite, which shouldn't rely on NumPy.

Adding some new standard functions like take_along_axis will help. It might also help to define the usual channels for it to be converted to a regular array where the mask is all False, since we fall back to NumPy sometimes.

I'll work on this a bit this morning. Here are some things I'm coming across that I'll come back to later:

  • consider adding a special case in xp_assert_allclose/xp_assert_equal

@lucascolley
Copy link
Collaborator Author

down to these now

FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_input_validation[marray.numpy] - TypeError: Unrecognized array input
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape0-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape0-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape0-complex64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape0-complex128-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape1-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape1-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape1-complex64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape1-complex128-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape2-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape2-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape2-complex64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape2-complex128-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape3-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape3-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape3-complex64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_basic[shape3-complex128-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape0-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape0-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape1-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape1-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape2-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape2-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape3-float32-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_log[shape3-float64-marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_maxiter[marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_eps[marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_feval[marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_status[marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_continued_fraction.py::TestContinuedFraction::test_special_cases[marray.numpy] - AttributeError: module 'marray.numpy' has no attribute 'broadcast_shapes'. Did you mean: 'broadcast_arrays'?
FAILED scipy/stats/tests/test_entropy.py::TestDifferentialEntropy::test_consistency[correa-marray.numpy] - IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
FAILED scipy/stats/tests/test_entropy.py::TestDifferentialEntropy::test_rmse_std[dist0-correa-marray.numpy] - IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
FAILED scipy/stats/tests/test_entropy.py::TestDifferentialEntropy::test_rmse_std[dist1-correa-marray.numpy] - IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
FAILED scipy/stats/tests/test_entropy.py::TestDifferentialEntropy::test_dtypes_gh21192[None-correa-marray.numpy] - IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
FAILED scipy/stats/tests/test_entropy.py::TestDifferentialEntropy::test_dtypes_gh21192[float32-correa-marray.numpy] - IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
FAILED scipy/stats/tests/test_entropy.py::TestDifferentialEntropy::test_dtypes_gh21192[float64-correa-marray.numpy] - IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boolean arrays are valid indices
FAILED scipy/stats/tests/test_morestats.py::TestBartlett::test_empty_arg[marray.numpy] - RuntimeWarning: divide by zero encountered in log
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case0-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case1-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case2-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case3-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestKstat::test_moments_normal_distribution[marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestKstat::test_empty_input[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestKstatVar::test_empty_input[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_circmean_axis[circmean-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_circmean_axis[circvar-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_circmean_axis[circstd-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_empty[circmean-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_empty[circvar-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_empty[circstd-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestTrimmedStats::test_tmin[marray.numpy] - AttributeError: 'MArray' object has no attribute 'reshape'. Did you mean: '_shape'?
FAILED scipy/stats/tests/test_stats.py::TestZmapZscore::test_zscore_constant_input_2d[marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::TestSkew::test_empty_1d[skew-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestSkew::test_empty_1d[kurtosis-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestMoments::test_moment[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat3-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat0-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestStudentTest::test_1samp_ci_1d[two-sided-marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat4-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat0-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestStudentTest::test_1samp_ci_1d[less-marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat4-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat1-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestStudentTest::test_1samp_ci_1d[greater-marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat1-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat2-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-True-greater-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat2-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-False-two-sided-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat3-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-False-less-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_with_uneq_var[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-False-greater-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_zero_division[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_axis_size_zero[b0-expected_shape0-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-True-two-sided-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_axis_size_zero[b1-expected_shape1-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-True-less-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_from_stats_inputs_zero[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestJarqueBera::test_axis[marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::test_ttest_uniform_pvalues[marray.numpy] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED scipy/stats/tests/test_stats.py::test_ttest_1samp_popmean_array[marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_variation.py::TestVariation::test_2d_size_zero_with_axis[0-expected0-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::TestXP_Mean::test_empty[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_variation.py::TestVariation::test_2d_size_zero_with_axis[1-expected1-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::TestXP_Var::test_empty[marray.numpy] - AssertionError: 
========================================================= 87 failed, 10253 passed, 925 skipped, 45 xfailed in 66.46s (0:01:06) =========================================================

@mdhaber
Copy link
Owner

mdhaber commented Dec 31, 2024

I already have the PR for broadcast_shapes to submit to SciPy, which will cut out the first half.

@mdhaber
Copy link
Owner

mdhaber commented Dec 31, 2024

Cool. Can you merge the latest in SciPy and MArray and run more time?

@lucascolley
Copy link
Collaborator Author

FAILED scipy/stats/tests/test_morestats.py::TestBartlett::test_empty_arg[marray.numpy] - RuntimeWarning: divide by zero encountered in log
FAILED scipy/stats/tests/test_morestats.py::TestKstat::test_moments_normal_distribution[marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestKstat::test_empty_input[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestKstatVar::test_empty_input[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_circmean_axis[circmean-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_circmean_axis[circvar-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_circmean_axis[circstd-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_empty[circmean-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_empty[circvar-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCircFuncs::test_empty[circstd-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case0-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case1-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case2-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_morestats.py::TestCommonAxis::test_axis[case3-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::TestZmapZscore::test_zscore_constant_input_2d[marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::TestMoments::test_moment[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestSkew::test_empty_1d[skew-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestSkew::test_empty_1d[kurtosis-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestStudentTest::test_1samp_ci_1d[two-sided-marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestStudentTest::test_1samp_ci_1d[less-marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestStudentTest::test_1samp_ci_1d[greater-marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat0-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat0-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat1-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat1-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat2-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat2-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat3-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat3-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat4-case0-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestPowerDivergence::test_empty_cases[lambda_stat4-case1-marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-False-two-sided-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-False-less-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-False-greater-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-True-two-sided-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-True-less-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::Test_ttest_CI::test_confidence_interval[0-True-greater-marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_with_uneq_var[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_zero_division[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_axis_size_zero[b0-expected_shape0-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_axis_size_zero[b1-expected_shape1-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::test_ttest_ind_from_stats_inputs_zero[marray.numpy] - TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::test_ttest_uniform_pvalues[marray.numpy] - ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
FAILED scipy/stats/tests/test_stats.py::test_ttest_1samp_popmean_array[marray.numpy] - TypeError: ufunc 'stdtrit' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
FAILED scipy/stats/tests/test_stats.py::TestJarqueBera::test_axis[marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_stats.py::TestXP_Mean::test_empty[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_stats.py::TestXP_Var::test_empty[marray.numpy] - AssertionError: 
FAILED scipy/stats/tests/test_variation.py::TestVariation::test_2d_size_zero_with_axis[0-expected0-marray.numpy] - AssertionError: dtypes do not match.
FAILED scipy/stats/tests/test_variation.py::TestVariation::test_2d_size_zero_with_axis[1-expected1-marray.numpy] - AssertionError: dtypes do not match.

@mdhaber
Copy link
Owner

mdhaber commented Jan 1, 2025

scipy/scipy#22222 will fix the stdtrit issues. They might be replaced by others.

@mdhaber
Copy link
Owner

mdhaber commented Jan 1, 2025

I think a lot of the remaining errors about non-matching dtype are caused when mxp.full gets a masked array for the fill value. This masked array gets passed to the backend's fill implementation, and for NumPy backend, it produces an object array rather than raising an error.

@lucascolley
Copy link
Collaborator Author

Really? The fillvalue is supposed to be a scalar, https://data-apis.org/array-api/draft/API_specification/generated/array_api.full.html

@lucascolley
Copy link
Collaborator Author

Related to data-apis/array-api-strict#55 then

@mdhaber
Copy link
Owner

mdhaber commented Jan 1, 2025

Well, it's a 0d array. I think that's reasonable because otherwise the dtype has to be specified manually.

@lucascolley
Copy link
Collaborator Author

Yeah, but torch does not accept 0-D arrays

@mdhaber
Copy link
Owner

mdhaber commented Jan 1, 2025

Maybe torch is skipped? I'll take a closer look.

Two other things:
The standard does not allow use of asarray on an iterable of arrays, but some backends support it and do the same thing as stack. marray.numpy ends up with an object array. To fix this for general nested sequences, some of which might be MArrays, we'd have to recurse through to see which are MArrays that need to be separated into data and mask before passing into the underlying library's asarray. Just an observation. Maybe we ignore it and don't try to do "better" than the standard?

A lot of failures arise when an input sample is empty. The result for most statistics is NaN, but for MArrays, the result is often a masked element. (Think mean/var of an array with all masked elements; mean/var of an array with zero elements masked or otherwise.)

In many cases I think this is what we'd expect, although I'm not sure how that should be reflected in the tests. The obvious thing is to special case the assertion of each of these tests. Another possibility is for the assert_ functions to treat a masked element and a NaN as equal.

However, I saw that bartlett, which accepts an arbitrary number of input samples, puts the variance of each sample into an array and sums them. For other array types, the variance of a sample is NaN and the NaN is propagated. For MArray, the variance of a sample is masked, and the sum ignores it. I think once we actually go through and correct the statistic to be NaN aware, it will get the same result as if the empty sample were never present. But it brings up the fact that even when all masks are False, tests may produce finite, non-masked results with MArrays where other array types would produce NaNs.

All that brings up something I've thought about that is a bit inconsistent with masked arrays: if y is masked, x + y is masked but mxp.sum(mxp.stack([x, y])) is x. In many cases, this works out to be the desired thing, but it's unusual and I don't think the discrepancy can be reconciled - it's a fundamental difference between binary and reducing operations that would be equivalent without masks involved (unless we want to rethink how masks work in binary operations).

@lucascolley
Copy link
Collaborator Author

Maybe we ignore it and don't try to do "better" than the standard?

That seems reasonable, at least for now!

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

2 participants