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

Add tuple fix function #1108

Merged
merged 2 commits into from
Aug 22, 2024
Merged

Add tuple fix function #1108

merged 2 commits into from
Aug 22, 2024

Conversation

acordonez
Copy link
Collaborator

@acordonez acordonez commented Aug 22, 2024

When a tuple such as ModUnitsAdjust is read from the command line, it is split by character and not usable in this format.

For example, the tuple (True, 'multiply', 1e-2) gets parsed as ('(', 'T', 'r', 'u', 'e', ',', ' ', "'", 'm', 'u', 'l', 't', 'i', 'p', 'l', 'y', "'", ',', ' ', '1', 'e', '-', '2', ')').

This function re-formats the tuple so that it will be correctly formatted as (True, 'multiply', 0.01). If the tuple is already in this format, the function does nothing.

@acordonez acordonez requested a review from lee1043 August 22, 2024 17:58
@lee1043
Copy link
Contributor

lee1043 commented Aug 22, 2024

Confirmed below both demo returns the same result

Case 1:

t = (True, 'multiply', 1e-2)
fix_tuple(t)

Case 2:

t = "(True, 'multiply', 1e-2)"
fix_tuple(t)

Result:
(True, 'multiply', 0.01)

@lee1043 lee1043 added the bug label Aug 22, 2024
@acordonez acordonez merged commit 601094d into main Aug 22, 2024
5 checks passed
@acordonez acordonez deleted the acordonez-patch-1 branch August 22, 2024 20:52
@acordonez
Copy link
Collaborator Author

Thanks @lee1043!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants