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

Using handcalcs with pint #203

Open
av1dm opened this issue Jun 6, 2024 · 3 comments
Open

Using handcalcs with pint #203

av1dm opened this issue Jun 6, 2024 · 3 comments

Comments

@av1dm
Copy link

av1dm commented Jun 6, 2024

Hello,

I wanted to share my default setup for using handcalcs together with pint.

Pint can be a useful alternative to forallpeople, if some "advanced" options are needed.
The main reason, I started using pint is to work with fixed prefixes.
Here is my default setup to achieve this:

from handcals import render
from pint import UnitRegistry

ureg = UnitRegistry(autoconvert_to_preferred = True)
preferred_units = [
    ureg.mm,
    ureg.kg,
    ureg.s, 
    ureg.K,
    ureg.kN,
    ureg.W,
    ureg.MPa
]

ureg.default_preferred_units = preferred_units

mm  = ureg.mm
kN  = ureg.kN
MPa = ureg.MPa

handcalcs.set_option("preferred_string_formatter", "~L")
@connorferster
Copy link
Owner

@av1dm Thanks for posting this!

@cream68
Copy link

cream68 commented Oct 22, 2024

I'm having trouble using handcalcs with pint outside of Jupyter Notebooks. Specifically, I cannot import render with from handcalcs import render in my regular Python script, which prevents me from using set_option.

Does handcalcs and pint inside regular python support usage of set_option ? If so, how can I enable this functionality in a standard Python environment?

@av1dm
Copy link
Author

av1dm commented Oct 28, 2024

I'm having trouble using handcalcs with pint outside of Jupyter Notebooks. Specifically, I cannot import render with from handcalcs import render in my regular Python script, which prevents me from using set_option.

Does handcalcs and pint inside regular python support usage of set_option ? If so, how can I enable this functionality in a standard Python environment?

How do you want to render in your regular Python environment?! Handcalcs is for using with Jupyter.

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

3 participants