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

fix!: Fix NaN ordering to make NaNs compare greater than any other float, and equal to themselves #12721

Merged
merged 35 commits into from
Nov 30, 2023
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
434a7d7
move TotalOrd to polars-utils
orlp Oct 16, 2023
a309b3b
add polars-compute
orlp Oct 16, 2023
eaed1e7
wip
orlp Oct 17, 2023
c1912d6
remove nans_compare_equal
orlp Nov 23, 2023
913a4f1
remove float comparison exceptions
orlp Nov 23, 2023
d37d9c0
mostly fix broadcasting comparisons
orlp Nov 24, 2023
01fb1bb
remove inconsistent null equality optimization
orlp Nov 27, 2023
33f09b9
add warning to always-null comparisons
orlp Nov 27, 2023
3c5e101
fmt
orlp Nov 27, 2023
14e43eb
fix warnings in tests
orlp Nov 27, 2023
5c4a943
fix _missing comparison ops
orlp Nov 27, 2023
467b7fc
clippy
orlp Nov 27, 2023
d7fb115
remove not_equal_and_validity
orlp Nov 28, 2023
5354923
add new string comparison kernels
orlp Nov 28, 2023
da58d14
define gt/ge in terms of lt/le
orlp Nov 28, 2023
74f4e3f
add _missing kernels
orlp Nov 28, 2023
b6359c4
add array support to comparison kernels
orlp Nov 28, 2023
a50997d
fmt/clippy
orlp Nov 28, 2023
5a2c321
add boolean comparison kernels
orlp Nov 29, 2023
06b9426
expand comparison tests
orlp Nov 29, 2023
80a12d9
fix test
orlp Nov 29, 2023
0b93380
user new string broadcast comparison kernels
orlp Nov 29, 2023
ed030c3
remove old comparison kernels
orlp Nov 29, 2023
ba409a4
clippy
orlp Nov 29, 2023
ea99583
fix bad/outdated tests
orlp Nov 29, 2023
9013166
fix trait bounds
orlp Nov 29, 2023
3c63fec
fix conditional import
orlp Nov 29, 2023
cb4da95
fix another bad test
orlp Nov 29, 2023
1bd4957
fix failing doctest
orlp Nov 29, 2023
ba8c5e2
address review comments
orlp Nov 30, 2023
d58dc7c
fix mypy
orlp Nov 30, 2023
e2e8b85
fix incorrect bitcount
orlp Nov 30, 2023
3b00eb1
add missing inline
orlp Nov 30, 2023
733c634
add missing comment
orlp Nov 30, 2023
7a340e4
fmt
orlp Nov 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove float comparison exceptions
  • Loading branch information
orlp committed Nov 27, 2023
commit 913a4f1169efd791c99677864fa9d1cec44c230a
25 changes: 0 additions & 25 deletions py-polars/polars/testing/asserts/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ def _assert_series_values_equal(
cause=exc,
)

# Handle NaN values (which compare unequal to themselves)
if _comparing_floats(left.dtype, right.dtype):
both_nan = (left.is_nan() & right.is_nan()).fill_null(False)
unequal = unequal & ~both_nan

# Check nested dtypes in separate function
if _comparing_nested_numerics(left.dtype, right.dtype):
try:
Expand Down Expand Up @@ -191,7 +186,6 @@ def _assert_series_values_equal(
)

_assert_series_null_values_match(left, right)
_assert_series_nan_values_match(left, right)
_assert_series_values_within_tolerance(
left,
right,
Expand Down Expand Up @@ -247,25 +241,6 @@ def _assert_series_null_values_match(left: Series, right: Series) -> None:
)


def _assert_series_nan_values_match(
left: Series, right: Series
) -> None:
if not _comparing_floats(left.dtype, right.dtype):
return
nan_value_mismatch = left.is_nan() != right.is_nan()
if nan_value_mismatch.any():
raise_assertion_error(
"Series",
"nan value mismatch - nans compare equal",
left.to_list(),
right.to_list(),
)


def _comparing_floats(left: PolarsDataType, right: PolarsDataType) -> bool:
return left.is_float() and right.is_float()


def _comparing_lists(left: PolarsDataType, right: PolarsDataType) -> bool:
return left in (List, Array) and right in (List, Array)

Expand Down