Skip to content

Add new method to set default magnitude of Units#35

Merged
chaoming0625 merged 20 commits intomainfrom
set-default-magnitude
Aug 9, 2024
Merged

Add new method to set default magnitude of Units#35
chaoming0625 merged 20 commits intomainfrom
set-default-magnitude

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
Member

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
Member

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
Member

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

@chaoming0625 chaoming0625 merged commit 1abcb73 into main Aug 9, 2024
@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

Development

Successfully merging this pull request may close these issues.

Add new method to set default magnitude of Units to Enhance the ability to handling extremely large or small Units

2 participants