Skip to content
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

Fix dtypes related to floating point precision #254

Merged
merged 14 commits into from
Jun 4, 2024
Merged

Fix dtypes related to floating point precision #254

merged 14 commits into from
Jun 4, 2024

Conversation

Scienfitz
Copy link
Collaborator

@Scienfitz Scienfitz commented May 29, 2024

Since floating point precision can be controlled via env vars (#226) various problems have surfaced letting tests fail in single precision.
This PR fixes those. They were mostly related to the way values and comp_df were created for parameters, selection was treated in SubSelectionCondition and a lookup in a different float precision being used in a simulation.

The only remaining issues with test in single precision are numerical instabilities (out of scope)

@Scienfitz Scienfitz added the bug Something isn't working label May 29, 2024
@Scienfitz Scienfitz self-assigned this May 29, 2024
Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

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

Hi @Scienfitz, thanks for the PR. Here a few comments to discuss

CHANGELOG.md Outdated Show resolved Hide resolved
baybe/constraints/base.py Show resolved Hide resolved
baybe/utils/chemistry.py Show resolved Hide resolved
baybe/parameters/categorical.py Show resolved Hide resolved
baybe/parameters/numerical.py Show resolved Hide resolved
@AdrianSosic AdrianSosic changed the title Fix dtypes realted to floating point precision Fix dtypes related to floating point precision May 29, 2024
@Scienfitz Scienfitz force-pushed the fix/dtypes branch 2 times, most recently from 7946692 to b735ef2 Compare May 29, 2024 11:46
Copy link
Collaborator

@AdrianSosic AdrianSosic left a comment

Choose a reason for hiding this comment

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

Last few comments, I hope 🙃

# could also be implemented for approximate matches
elif isinstance(lookup, pd.DataFrame):
# Enforce correct float precision in the lookup dataframe
float_cols = lookup.select_dtypes(include=["float"]).columns
lookup[float_cols] = lookup[float_cols].astype(DTypeFloatNumpy)
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 is problematic since you mutate the incoming object, i.e. this will also affect the object outside the scope of this function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ok changed it and also moved to simulate_experiment where it creates a copy before modifying, this should also do the modifications fewer times which possibly affects speed

baybe/constraints/conditions.py Outdated Show resolved Hide resolved
@Scienfitz Scienfitz merged commit 95f7f25 into main Jun 4, 2024
9 of 10 checks passed
@Scienfitz Scienfitz deleted the fix/dtypes branch June 4, 2024 12:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants