connorferster / handcalcs

Python library for converting Python calculations into rendered latex.
Apache License 2.0
5.59k stars 427 forks source link

Comments in @handcalc function causes error when called #174

Open drewcassidy opened 1 year ago

drewcassidy commented 1 year ago
import forallpeople as si
import handcalcs.render
from handcalcs.decorator import handcalc

si.environment('default')
vit_p = 0.4 * si.V
hys = 5.5e-3 * si.V
vit_n = vit_p - hys

@handcalc(jupyter_display = True)
def res_to_range(r1, r2, r3):
    rtot = r1 + r2 + r3
    a_frac = (r2 + r3) / rtot
    b_frac = r3 / rtot
    # comment
    uv = vit_p / a_frac
    ov = vit_n / b_frac
    return uv, ov

res_to_range(10e3 * si.Ohm, 422 * si.Ohm, 6.56e3 * si.Ohm)

This causes a non-descriptive error Expected == | = | + | - | * | // | / | % | , | <= | < | >= | > | != term, found end of text (at char 4), (line:1, col:5)

DonCammne commented 7 months ago

I encountered this same problem when commenting inside a function. Did you find any solution?

ernest505 commented 7 months ago

I encountered this same problem when commenting inside a function. Did you find any solution?

You could use multi-line comments """ comment """.

DonCammne commented 7 months ago

Thank you very much :)