diff --git a/HISTORY.rst b/HISTORY.rst index 2ace1a9..8063f30 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,6 +1,10 @@ ======= History ======= +2024.6.5 -- Bugfix: Handling of duplicates in lists + * Roundoff in floating point numbers caused some duplicates to be missed. The code + now checks for duplicates in a more robust way. + 2024.4.30 -- Added utility for handling list definitions * Add list_definition.py with parse_list() * Updated makefile for doctests. diff --git a/seamm_util/list_definition.py b/seamm_util/list_definition.py index 1f837d8..a916f52 100644 --- a/seamm_util/list_definition.py +++ b/seamm_util/list_definition.py @@ -131,8 +131,12 @@ def parse_list(input, duplicates=True, sort=False, **kwargs): # Add a very small number for roundoff in floats while sign * (stop - value + stop / 1.0e8) >= 0: - if not duplicates and value in result: - pass + if not duplicates: + for tmp in result: + if abs(value - tmp) < 1.0e-8: + break + else: + result.append(value) else: result.append(value) value += step