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 more methods to SINumber #76

Closed
marcosfelt opened this issue Nov 12, 2022 · 3 comments
Closed

Add more methods to SINumber #76

marcosfelt opened this issue Nov 12, 2022 · 3 comments

Comments

@marcosfelt
Copy link

Thanks for this package! The SINumber wrapper in python does not seem to have the same methods as the equivalent object in rust (see here). For example, I cannot call .value on a SINumber. Would it be possible to add that functionality? Below is an example:

from feos.si import *
T = 300*KELVIN
T.value
AttributeError                            Traceback (most recent call last)
[<ipython-input-55-7f7315c6633b>](https://localhost:8080/#) in <module>
      1 from feos.si import *
      2 T = 300*KELVIN
----> 3 T.value

AttributeError: 'si_units.SINumber' object has no attribute 'value'
@g-bauer
Copy link
Contributor

g-bauer commented Nov 12, 2022

Hey, thanks for your interest in FeOs.

You can get a float (or an array of floats) by dividing by the unit, i.e. in your example T / KELVIN would result in 300.0. Of course, that only works if the units cancel out. In Rust with static data types we have to convert a "dimensionless" quantity, and that's where e.g. value can be used.

I don't think value is needed in Python - when performing arithmetic operations that cancel units, we automatically return the underlying data (float or array of floats).

Let me know if that helps!

@marcosfelt
Copy link
Author

That does! Thank you!!

@g-bauer
Copy link
Contributor

g-bauer commented Nov 12, 2022

Great! If you encounter more problems regarding the unit system, there is a tutorial in our documentation.

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

No branches or pull requests

2 participants