github connorferster/handcalcs v1.6.0

22 months ago

handcalcs v1.6.0

This is a major new release for handcalcs and introduces the global configuration feature. This allows users to have control over several options of how handcalcs works. The configuration options, with their default values, are as follow:

  • decimal_separator = "."
  • latex_block_start = "\\["
  • latex_block_end = "\\]"
  • math_environment_start = "aligned"
  • math_environment_end = "aligned"
  • line_break = "\\\\[10pt]"
  • use_scientific_notation = False
  • display_precision = 3
  • underscore_subscripts = True
  • greek_exclusions = []
  • param_columns = 3
  • preferred_string_formatter = "L"

Config API

import handcalcs.render

handcalcs.set_option("display_precision", 4)
handcalcs.set_option("param_columns", 5) 
handcalcs.set_option("line_break", "\\\\[20pt]") 
handcalcs.set_option("greek_exclusions", ["psi"]) # etc...

These changes now affect all cells rendered in the current session. If you want to permanently update the config.json file with these changes (so handcalcs will always load up with these options), you can then call handcalcs.save_config() and the changes will be saved.

The auto-complete in the handcalcs.set_option() function demonstrates which options are available and what values they take.

Scientific notation

Previously, handcalcs had a sketchy "guess" at determining if a value should be rendered in scientific notation to make it more readable. This behaviour has now been removed and requires the user to explicitly set whether scientific notation should be used. This can be set as a global option with handcalcs.set_option('use_scientific_notation', True) and it can also be toggled at the cell level with the new sci_not cell override command. If the global configuration is set to True, the toggle will turn scientific notation OFF in that cell. If the global configuration is set to False, the toggle will turn scientific notation ON in that cell.

%%render sci_not 5
a = 32.902939
b = 0.0923

image

NBConvert Exporters

Previously, there was a problem with the "noinput" exporters that come bundled with handcalcs. The "noinput" exporters would turn off inputs for both the regular exporters and the handcalcs exporters. This has been fixed. If you use Jupyter with different kernels, the controlling kernel for the exporters seems to be the "base" environment (if you use conda) so be sure to install v1.6.0 into your base environment to have access to the udpated exporters (which have a slightly new name, e.g. "HTML_NoInput" instead of "HTML_noinput", etc._)

Bug Fixes

This release also fixes several bugs. Some of these are from the new global config feature but others were independent bugs.

Fixes:

  • #125 (Double ## comments not working in 'long' setting)
  • #121 (How to not use engineering notation)
  • #114 (Commented line with comment at the end)
  • #113 (Pint and siunitx)
  • #111 (Broken output when using forallpeople)
  • #101 #97 (Provide options for subscripts; optionally disable subscripting)
  • #90 ("psi" renders as a greek character)

Coming soon

  • More tests for these new features (I am in a bit of a rush right now; lots on my plate)
  • Official documentation

Don't miss a new handcalcs release

NewReleases is sending notifications on new releases.