Skip to content

v3.0.7

Compare
Choose a tag to compare
@nicholas12392 nicholas12392 released this 20 Nov 02:33
· 27 commits to main since this release
7c1f5b6

New features

Added a getting started with unit calculations guide in the README file.

mathpar.parser(), unitpar.unit_parser(), modules.NumAn

It is now possible to specify how many significant figures should be displayed when using cprint with the optional argument sf (for NumAn - this is a kwarg for unit_parser() and parser()). If set to None there is made no attempt to change the significant figures, otherwise if set to an int, an attempt will be made to conform to that significant figure. This feature is based on the mpmath workdps function. Note that for NumAn, this can also be specified per calculation (.calc(sf=)). The default for NumAn is 4. For the other functions it is None.

Changes

modules.NumAn

Changed how added constants got put in a bracket, to ensure correct computation with units.

.del_cns()

Now works with *args, rather than a single argument. Thus, multiple constants can be deleted by just adding more constants to the expression, e.g. .del_cns('A', 'lambda') will delete both constants 'A' and 'lambda' (before .del_cns(('A', 'lambda'))). Note that .del_cns('A, lambda') will work in the same way (here the delimiter ';' may be used instead of ',' if desired).

.calc()

Changed the way constants are displayed after computations. In addition, now the script saves computed constants as input, so that they do not have to be computed every time they are used in an expression. This should increase efficiency slightly.

Changed the way constants are checked regarding being an expression or a value. This new method should be much more accurate.

Changed cprint to kwarg rather than parameter.

mathpar.parser()

Removed rare instances of pi-prettifying.

Bug fixes

mathpar.parser()

Fixed instances where the unit 'amu' was unintendedly swapped by the prettifier to 'aµ'.

modules.NumAn

Fixed an issue where units were unintendedly swapped with defined constants, if the constants were in the unit, bricking calculations from that point and onwards.

.calc()

Fixed a potential issue in the way computed constants were saved.

Fixed unintended display of defined constants, if they were part of a function such as cos(), exp(), etc., but not in the expression itself.

Fixed issues, where cprint=None was read as defined from __init__() rather than as the option None.