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 new method to set default magnitude of Units #35

Merged
merged 20 commits into from
Aug 9, 2024

Conversation

Routhleck
Copy link
Collaborator

>>> set_default_magnitude('n') # Sets the default magnitude to 'nano' (10e-9)
>>> set_default_magnitude(-9) # Alternatively, use an integer to represent the exponent of 10
>>> set_default_magnitude({'m': -3, 'kg': -9}) # Set the default magnitude for 'metre' to 'milli' and 'kilogram' to 'nano'
>>> set_default_magnitude({'m': 'm', 'kg': 'n'}) # Alternatively, use a string to represent the magnitude

More examples at https://github.com/chaoming0625/brainunit/blob/c25506c9ff9c03dc225ba541f8c517b98a7309f3/brainunit/_unit_test.py#L1477-L1570

@Routhleck Routhleck added the enhancement New feature or request label Jul 12, 2024
@Routhleck Routhleck marked this pull request as draft July 12, 2024 15:01
@Routhleck Routhleck marked this pull request as ready for review July 13, 2024 05:48
@chaoming0625
Copy link
Collaborator

Sound very great. I am checking now.

Copy link
Collaborator Author

@Routhleck Routhleck left a comment

Choose a reason for hiding this comment

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

Almost all test cases need to be fixed

python_code: bool = False
) -> str:
@staticmethod
def create(dim: Dimension, name: str, dispname: str, scale: int = 0) -> 'Unit':
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Need to set base

@chaoming0625
Copy link
Collaborator

Almost all test cases need to be fixed

这么吓人?

@Routhleck
Copy link
Collaborator Author

Almost all test cases need to be fixed

这么吓人?

https://github.com/chaoming0625/brainunit/actions/runs/10250404914/job/28356059580
262 failed, 33 passed, 2 warnings in 43.34s

@chaoming0625
Copy link
Collaborator

先不管tests,你先改math,改完后我再看,最后再改tests

@chaoming0625 chaoming0625 merged commit 1abcb73 into main Aug 9, 2024
12 checks passed
@chaoming0625 chaoming0625 deleted the set-default-magnitude branch August 9, 2024 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants