Skip to content

Conversation

@cghielmini
Copy link
Collaborator

@cghielmini cghielmini commented Jan 20, 2026

This pull request ensures that float64 values are accepted and that no temporary files are created during the tests

Copy link
Collaborator

@huppd huppd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for these nice improvement. I am not sure how much of it is still needed with the other changes, so it is not very urgent right now.

Comment on lines +114 to 117
if np.isnan(arr).any():
return np.where(np.isnan(arr), -999999, arr)

return arr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be slightly less efficinet, but more readable.

Suggested change
if np.isnan(arr).any():
return np.where(np.isnan(arr), -999999, arr)
return arr
return np.where(np.isnan(arr), -999999.0, arr)

@@ -217,18 +223,20 @@ def compare_var_and_attr_ds(ds1, ds2, nl, output, location):
if output:
if location:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be safer:

Suggested change
if location:
if location is None:

Comment on lines 227 to +230
else:
script_dir = os.path.dirname(os.path.abspath(__file__))
path_name = os.path.join(script_dir, "differences.csv")
parent_dir = os.path.dirname(script_dir)
path_name = os.path.join(parent_dir, "differences.csv")
Copy link
Collaborator

@huppd huppd Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would remove this functionalty out of this routine into `fof_compare``:

if location is None:
  location = os.path.join(os.getcwd(), 'differences.csv')

For the pytest, the location can be set to the tmp folder. what do you think?

"""
array = fill_nans_for_float32(arr_nan)
array = replace_nan_with_sentinel(arr_nan)
expected = np.array([1.0, -9.99999e05, 3.0, 4.0, -9.99999e05], dtype=np.float32)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't it be now

Suggested change
expected = np.array([1.0, -9.99999e05, 3.0, 4.0, -9.99999e05], dtype=np.float32)
expected = np.array([1.0, -9.99999e05, 3.0, 4.0, -9.99999e05], dtype=np.float64)



def fill_nans_for_float32(arr):
def replace_nan_with_sentinel(arr):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think now it is also casting to 64bit, so I would add it to the name or at least to the doc string.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants