diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 806497d..f81e075 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -2,7 +2,12 @@ pyais CHANGELOG ==================== ------------------------------------------------------------------------------- - Version 2.5.9 26 Nov 2023 + Version 2.6.1 20 Jan 2024 +------------------------------------------------------------------------------- +* fixes a logic bug in `NoneFilter` +* https://github.com/M0r13n/pyais/issues/128 +------------------------------------------------------------------------------- + Version 2.6.0 28 Dec 2023 ------------------------------------------------------------------------------- * Initial release of the AIS Filters system. * Basic filtering classes: `NoneFilter`, `MessageTypeFilter`, and `DistanceFilter`. diff --git a/pyais/__init__.py b/pyais/__init__.py index e4c3520..eb9608c 100644 --- a/pyais/__init__.py +++ b/pyais/__init__.py @@ -5,7 +5,7 @@ from pyais.tracker import AISTracker, AISTrack __license__ = 'MIT' -__version__ = '2.6.0' +__version__ = '2.6.1' __author__ = 'Leon Morten Richter' __all__ = ( diff --git a/pyais/filter.py b/pyais/filter.py index d24e0e0..5a7cc76 100644 --- a/pyais/filter.py +++ b/pyais/filter.py @@ -148,7 +148,7 @@ def filter_data(self, data: AIS_STREAM) -> AIS_STREAM: AIS_STREAM: The filtered data stream. """ for msg in data: - if all(getattr(msg, attr, False) is not None for attr in self.attrs): + if all(getattr(msg, attr, None) is not None for attr in self.attrs): yield msg diff --git a/tests/test_filters.py b/tests/test_filters.py index dd40baf..753a7a0 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -24,8 +24,8 @@ def test_filtering_none_attributes(self): self.assertEqual(len(filtered_data), 1) # Only one message should pass through the filter def test_filtering_missing_attributes(self): - # Setup - attrs = ['lat', 'lon', 'foo'] # foo is never an attribute + # Setup - foo is never an attribute + attrs = ['foo'] filter = NoneFilter(*attrs) # Create mock data with varying attributes: some missing, some None, some with value @@ -39,7 +39,7 @@ def test_filtering_missing_attributes(self): filtered_data = list(filter.filter_data(mock_data)) # Assert - self.assertEqual(len(filtered_data), 1) # Only one message with all attributes should pass through + self.assertEqual(len(filtered_data), 0) class TestMessageTypeFilter(unittest.TestCase):