From deaf9c4f99ecceb624fae81b19adf2d3a7341abc Mon Sep 17 00:00:00 2001 From: James McKinney <26463+jpmckinney@users.noreply.github.com> Date: Wed, 29 Jan 2025 01:16:28 -0500 Subject: [PATCH] fix: Table.order_by sorts None as equal to None --- CHANGELOG.rst | 5 +++++ agate/utils.py | 8 ++++---- docs/conf.py | 2 +- setup.py | 2 +- tests/test_table/test_order_py.py | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 14fe789e..11a9e238 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,3 +1,8 @@ +1.13.0 - Jan 29, 2025 +--------------------- + +- fix: :meth:`.Table.order_by` sorts None as equal to None. + 1.12.0 - July 29, 2024 ---------------------- diff --git a/agate/utils.py b/agate/utils.py index 69bb01eb..e63d0630 100644 --- a/agate/utils.py +++ b/agate/utils.py @@ -46,11 +46,11 @@ class NullOrder: def __lt__(self, other): return False - def __gt__(self, other): - if other is None: - return False + def __eq__(self, other): + return isinstance(other, NullOrder) - return True + def __gt__(self, other): + return not isinstance(other, NullOrder) class Quantiles(Sequence): diff --git a/docs/conf.py b/docs/conf.py index c6eb3e7f..1a4d2aaa 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -12,7 +12,7 @@ project = 'agate' copyright = '2017, Christopher Groskopf' -version = '1.12.0' +version = '1.13.0' release = version # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index d8793bd6..0607b90b 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='agate', - version='1.12.0', + version='1.13.0', description='A data analysis library that is optimized for humans instead of machines.', long_description=long_description, long_description_content_type='text/x-rst', diff --git a/tests/test_table/test_order_py.py b/tests/test_table/test_order_py.py index c6bbaa7d..201c2a11 100644 --- a/tests/test_table/test_order_py.py +++ b/tests/test_table/test_order_py.py @@ -131,8 +131,8 @@ def test_order_by_nulls(self): self.assertRows(new_table, [ rows[2], rows[0], - rows[1], - rows[3] + rows[3], + rows[1] ]) def test_order_by_with_row_names(self):