pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.22k stars 1.95k forks source link

Misleading error message when passing a DataFrame to assert_series_equal, or a Series to assert_frame_equal #14660

Open Wainberg opened 8 months ago

Wainberg commented 8 months ago

Checks

Reproducible example

>>> pl.testing.assert_frame_equal(pl.Series([1]), pl.Series([1]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "polars/testing/asserts/frame.py", line 90, in assert_frame_equal
    lazy = _assert_correct_input_type(left, right)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "polars/testing/asserts/frame.py", line 144, in _assert_correct_input_type
    raise_assertion_error(
  File "polars/testing/asserts/utils.py", line 12, in raise_assertion_error
    raise AssertionError(msg) from cause
AssertionError: inputs are different (unexpected input types)
[left]:  Series
[right]: Series
>>> pl.testing.assert_series_equal(pl.DataFrame([1]), pl.DataFrame([1]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "polars/testing/asserts/series.py", line 89, in assert_series_equal
    raise_assertion_error(
  File "polars/testing/asserts/utils.py", line 12, in raise_assertion_error
    raise AssertionError(msg) from cause
AssertionError: inputs are different (unexpected input types)
[left]:  DataFrame
[right]: DataFrame

Log output

No response

Issue description

The error message implies the inputs are different, even though they're the same - they're just both the wrong type.

Expected behavior

This should probably give a TypeError saying that the first input is not a DataFrame/not a Series.

Installed versions

``` --------Version info--------- Polars: 0.20.9 Index type: UInt32 Platform: Linux-4.4.0-22621-Microsoft-x86_64-with-glibc2.35 Python: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0] ----Optional dependencies---- adbc_driver_manager: cloudpickle: connectorx: deltalake: fsspec: gevent: hvplot: matplotlib: 3.8.3 numpy: 1.26.4 openpyxl: 3.1.2 pandas: 2.2.0 pyarrow: 14.0.2 pydantic: pyiceberg: pyxlsb: sqlalchemy: xlsx2csv: 0.8.1 xlsxwriter: 3.1.9 ```
stinodego commented 8 months ago

Yeah I am not too happy with this message. It should be improved.