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 validation of numeric types #69

Merged
merged 4 commits into from
Sep 25, 2024
Merged

Conversation

Pennycook
Copy link
Contributor

@Pennycook Pennycook commented Sep 13, 2024

Related issues

Closes #43.

Proposed changes

  • Add extra unit tests related to validation of numeric types.
  • Cast columns that we expect to be numeric to numeric before running any operations.

@Pennycook Pennycook added the bug Something isn't working label Sep 13, 2024
@Pennycook Pennycook added this to the 1.0.0 milestone Sep 13, 2024
p3analysis/_utils.py Show resolved Hide resolved
Each of these functions requires some columns to be numeric.

Signed-off-by: John Pennycook <[email protected]>
Whereas _require_numeric simply checked that the values in a DataFrame
could be interpreted as numbers, _cast_to_numeric actually performs the
cast and returns the result.

Signed-off-by: John Pennycook <[email protected]>
Previously, _cast_to_numeric would raise a TypeError if a column was
missing. We now check that a column exists before trying to cast it.

This does result in some redundant checking, as some functions call both
_require_columns and _cast_to_numeric. We may want to consider
refactoring to combine all of this functionality into a single DataFrame
validation step.

Signed-off-by: John Pennycook <[email protected]>
@Pennycook Pennycook merged commit 2a5210e into intel:main Sep 25, 2024
7 checks passed
@Pennycook Pennycook deleted the cast-to-numeric branch September 25, 2024 12:34
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.

Validation does not check column types
2 participants