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

Units with spaces #866

Merged
merged 4 commits into from
Apr 16, 2024
Merged

Units with spaces #866

merged 4 commits into from
Apr 16, 2024

Conversation

GernotMaier
Copy link
Contributor

#865 introduces an issue for combined units including spaces: e.g., m s is resolved to ['m','s'].

This is solved by applying this only when value is also of list type. Note that this is still not perfect, but works for the current model parameters.

Solves also the missing correct treatment of int type for the string-to-list step (where the type field is now used to identify float entries).

@GernotMaier GernotMaier self-assigned this Apr 15, 2024
@GernotMaier GernotMaier marked this pull request as ready for review April 15, 2024 19:21
data_validator.data_dict["type"] = "int64"
data_validator._prepare_model_parameter()
assert isinstance(data_validator.data_dict["value"][0], int)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe add a test for space separated units? I.e.
data_validator.data_dict["unit"] = "c t"
assert data_validator.data_dict["unit"] == "ct"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point - added a test for this.

But I don't think your assumption is right: in astropy units c t would not resolve to ct but to c*t. So we should to the same thing. But note that this function is just separating the unit string; no other changes are applied.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okey true, thanks for adding the further tests. Looks all good now.

@GernotMaier
Copy link
Contributor Author

Thank you @tobiaskleiner

@GernotMaier GernotMaier merged commit ba8663a into main Apr 16, 2024
12 checks passed
@GernotMaier GernotMaier deleted the units_with_spaces branch April 16, 2024 08:48
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.

2 participants