github connorferster/handcalcs v2.0.0rc5
Pre-release: v2.0.0rc5

pre-releaseone hour ago

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, so a = 1; b = 2 over c = 3; d = 4; e = 5 lays 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 N now sets the width of # hc: -g grids only, which still reflow (details).
  • SymPy substitution, # hc: -y: x = f, where f holds a SymPy expression, runs and renders as x = <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 sympy did. On its own line it applies to every such line until # hc: sympy = False. Works in scripts, %%render and @handcalc (where the expression may be an argument). SymPy is not a dependency.
  • %%source prints a cell's rendered text (LaTeX, Markdown, HTML, plain text) instead of displaying it, to copy into another document. %%source latex uses the LaTeX renderer for that cell, as v1's %%tex did. It takes %%render's inputs= arguments, and %source prints one line.
  • # hc: -u shows unit inputs as values (#353): a line that is a number times units, P = 5 * kN, renders as P = 5 kN instead of P = 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 with set_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=True from 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 / 8 was =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 new us_structural environment 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*L for kN and mm, instead of =F*1000*(L*0.001)).
  • # hc: --boxed draws 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() and int() in the Excel renderer: float(x) is the value itself and int(x) becomes TRUNC. With units, both match Python: forallpeople gives the magnitude in the displayed unit (float(4 * ksi) is 4), and pint the dimensionless value. This means the ACI pattern sqrt(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 of 2 · 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, not z = (3 + 4i)).
  • A bare expression under --check whose 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's round(x, n) only changes how many digits are shown, but the sheet used ROUND on the SI value: round(M / P, 3) with M / P = 4.80 mm became 5 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 as a**(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 as mode = "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

Don't miss a new handcalcs release

NewReleases is sending notifications on new releases.