Pre-release
This is the fifth pre-release of v2.0.0, to get people testing it and using it in real projects. Bugs are expected, so please raise issues.
Install it with pip install "handcalcs>=2.0.0rc5"; a plain pip install handcalcs still installs 1.x until 2.0.0 is released.
Changes since rc4
Features
;grids keep the layout you write: each;line is a row of the grid, soa = 1; b = 2overc = 3; d = 4; e = 5lays out two cells over three. Before, the cells were reflowed three to a row. End a line with;(f = 6;) for a one-cell row.# hc: -c Nnow sets the width of# hc: -ggrids only, which still reflow (details).- SymPy substitution,
# hc: -y:x = f, wherefholds a SymPy expression, runs and renders asx = <the expression>with the values its symbols have when the line runs, so the algebra done in SymPy becomes a calculation, as v1's%%render sympydid. On its own line it applies to every such line until# hc: sympy = False. Works in scripts,%%renderand@handcalc(where the expression may be an argument). SymPy is not a dependency. %%sourceprints a cell's rendered text (LaTeX, Markdown, HTML, plain text) instead of displaying it, to copy into another document.%%source latexuses the LaTeX renderer for that cell, as v1's%%texdid. It takes%%render'sinputs=arguments, and%sourceprints one line.# hc: -ushows unit inputs as values (#353): a line that is a number times units,P = 5 * kN, renders asP = 5 kNinstead ofP = 5 · kN = 5 · 1 kN = 5 kN. Lines that calculate keep every step. Turn it on for what follows, for one line (inline), or everywhere withset_option("units", True)(details).- Stacked fractions in the HTML renderer, with typeset maths: italic names in a serif maths font.
HTMLRenderer(fractions="inline")keeps divisions on one line (details). @handcalc(display=True)shows the render (displayed in Jupyter, printed elsewhere) and returns only the function's result;jupyter_display=Truefrom handcalcs 1 still works (#369, details).- A command line:
handcalcs script.py -o calc.docx(see Command line). - Excel formulas with US units have unit factors only where they are needed. Formulas used to convert every reference to SI and back, so a sheet in US units was full of factors that cancel:
M_u = w_u * L**2 / 8was=w_u*14593.9029372*(L*0.3048)^2/8/1355.81794833. It is now=w_u*L^2/8. A factor is written only where units do not cancel, in its simplest form:DCR = M_u / phi_M_n(kip·ft over kip·in) is=M_u/phi_M_n*12. Factors are exact with forallpeople 3.5 or later, and its newus_structuralenvironment shows mixed-unit results in US units (details). Formulas give the same results as before. Sheets in base SI units are unchanged; with prefixed units the factors fold too (=F*Lfor kN and mm, instead of=F*1000*(L*0.001)). # hc: --boxeddraws a box around a line's result:\boxed{}in LaTeX and Markdown, a framed result in HTML, a boxed formula in Word, a bordered value cell in Excel, and a box drawn with line characters in ASCII. On its own line it boxes the result of every following line (reference).float()andint()in the Excel renderer:float(x)is the value itself andint(x)becomesTRUNC. With units, both match Python: forallpeople gives the magnitude in the displayed unit (float(4 * ksi)is4), and pint the dimensionless value. This means the ACI patternsqrt(float(f_c / psi))now works (details).
Fixes
- A substituted value that is itself a sum is bracketed (#224): a complex number with a real and an imaginary part, or a SymPy sum, product or power, now reads
2 · (3+4j),(3+4j)²and-(3+4j)instead of2 · 3+4j,3+4j²and-3+4j, in every renderer. The LaTeX renderer no longer brackets a SymPy value standing on its own (z = 3 + 4i, notz = (3 + 4i)). - A bare expression under
--checkwhose symbolic and substituted forms are the same (2 <= 3 # hc: --check) showed both (2 ≤ 3 = 2 ≤ 3 ✓); the repeat is now dropped, as for an assignment. round()of a value with units in the Excel renderer gave a different result from Python. forallpeople'sround(x, n)only changes how many digits are shown, but the sheet usedROUNDon the SI value:round(M / P, 3)withM / P = 4.80 mmbecame5 mm(0.0048 m rounded to 0.005 m). The formula now leaves the value unchanged. With pint, it rounds the magnitude in the quantity's own unit, as pint does.- The HTML renderer's tints (the result highlight, parameter grids, block headers, import chips, muted comments) now print in WeasyPrint PDFs.
- A power with an exponent that isn't a number (
a**(1/2)) rendered asa**(1 / 2)in HTML; it is now a superscript. - The test dependencies require forallpeople 3.5.0 (3.4.1 fixed how a value is displayed when its factor matches no defined unit, #352; 3.5 gives the Excel renderer exact unit factors).
- A parameter line (
w = 5) in a mode without the result column, such asmode = "ass sym"(v1's%%render symbolic), showed only its name (w). It now shows its value:w = 5.
Full Changelog: v2.0.0rc4...v2.0.0rc5