-
Notifications
You must be signed in to change notification settings - Fork 8
Allow float64 #88
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
base: main
Are you sure you want to change the base?
Allow float64 #88
Conversation
huppd
left a comment
There was a problem hiding this 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.
| if np.isnan(arr).any(): | ||
| return np.where(np.isnan(arr), -999999, arr) | ||
|
|
||
| return arr |
There was a problem hiding this comment.
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.
| 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: | |||
There was a problem hiding this comment.
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:
| if location: | |
| if location is None: |
| 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") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
| 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): |
There was a problem hiding this comment.
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.
This pull request ensures that float64 values are accepted and that no temporary files are created during the tests