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

Skip subsitution step with forallpeople integration #183

Open
cslotboom opened this issue Oct 10, 2023 · 2 comments
Open

Skip subsitution step with forallpeople integration #183

cslotboom opened this issue Oct 10, 2023 · 2 comments

Comments

@cslotboom
Copy link

Hey, I'd like to skip unit substitution when there is a lone unit with forallpeople.
Right now handcalcs will write out all the calculations steps if you write something like 200*si.mm. This is especially noticeable for unit-less equations.

It would look much cleaner if something like 200*si.mm is rendered as 200 mm, without the distribution, similar to how unitless quantities are just rendered.

An alternatively, if there was a way to flag lines to be skipped so they don't render, that would also be great! If I could declare blim but not render it, that would also be a solution to clean up these equations.

See examples below.

image

@handcalc('long', precision = 1)
def summarizeMoment(F_b, b, d, L, k_net, k_L = 1):
    phi = 0.9
    
    S_eff = b*d**2 / 6
    blim = 130*si.mm
    k_Zbg = min((((130*si.mm)/b)**0.1)*((610/d)**0.1)*((9100/L)**0.1), 1.3)
    k_eff = min(k_Zbg, k_L)
    
    Mr = (phi*F_b*S_eff*k_eff*k_net).to('Nm')
@connorferster
Copy link
Owner

Heyo!

Put any calculation in parentheses to prevent the substitution step from rendering.

@cslotboom
Copy link
Author

Hey, okay perfect! Good to note and it did help my use case.
Do you think it is feasible to have a tag that will suppress certain lines, or would that be quite tricky? Even with the substitution suppressed, there is a lot of real estate being taken up by extra definitions. I often find myself doing gymnastics (like defining variables in other places) to save room and have cleaner substitutions.

image

That or the ability to suppress the substitution for definitions in multi-line expressions, such as below where 130*si.mm is used. This seems like a much harder task however.

It might seem like a small thing, but the extra substitution step might be confusing for a layperson who is trying to read a calculation.

image

@handcalc('long', precision = 2)
def summarizeMoment(F_b, b, d, L, k_net, k_L = 1):
    phi = 0.9
    d_lim = (610*si.mm)
    L_lim = (9100*si.mm)
    
    S_eff = b*d**2 / 6
    k_Zbg = min(((((130*si.mm)/b)*(d_lim/d)*(L_lim/L))**0.1), 1.3)
    k_eff = min(k_Zbg, k_L)
    
    M_r = (phi*F_b*S_eff*k_eff*k_net).to('Nm')

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