Skip to content

Releases: jagerber48/sciform

0.37.0

08 Mar 05:39
c83d9fb
Compare
Choose a tag to compare

0.37.0 (2024-03-07)

Added

  • Added support for Python 3.8.

Changed

  • Move ruff configuration out of pyproject.toml into ruff.toml. [#163]

0.36.0

07 Mar 07:49
be346c5
Compare
Choose a tag to compare

0.36.0 (2024-03-07)

Added

  • Added many unit test to supplement the feature existing feature tests. [#102]
  • Added much more input validation and corresponding messaging.
    • Checks on input types and values.
    • Extra translations dictionaries are now checked so that keys must be integers and values must consist of only English alphabetic characters. [#157]

Changed

  • Major code reorganization. [#152]
    • Move modules containing public interfaces into an api sub-package.
    • Break the bulky format_utils module into multiple modules, now in a format_utils sub-package.
    • Collect the main formatting algorithms into a formatting sub-package.
    • Sort tests into feature and unit tests.
  • Some utility code refactoring.

Fixed

  • Fixed a bug where uncertainties between the Particle Data Group uncertainties thresholds would erroneously result in ValueError being raised when formatted with pdg_sig_figs=True. [#164]

0.35.0

17 Feb 06:56
288a3f1
Compare
Choose a tag to compare

0.35.0 (2024-02-16)

Added

  • The Formatter formatting method and the SciNum constructor now accept formatted inputs for the value and optional uncertainty inputs. E.g. formatter("123.456(7)e-03") or SciNum("24 +/- 2") are now valid inputs. [#104]
  • Added the paren_uncertainties_trim option.
    The previous behavior was paren_uncertainties_trim=True. Now paren_uncertainties_trim=False allows a more verbose presentation of the uncertainty in paren_uncertainty mode in which leading zeros and separator characters are not stripped from the string. E.g. paren_uncertainties_trim=True will give
    123.002 3(21)
    while paren_uncertainties_trim=False will give
    123.002 3(0.002 1)
  • Added value and uncertainty attributes to the FormattedNumber class.
  • Added badge for Zenodo.

Removed

  • [BREAKING] Removed the paren_uncertainties_separators option. This option made it possible (when False) to optionally strip all separator characters, including the decimal separator, from the uncertainty in paren_uncertainty mode. This lead to the possibility of value/uncertainty pairs like
    123 456.789 8 ± 123.456 7
    being represented as
    123 456.789 8(1234567)
    sciform will now display this as
    123 456.789 8(123.456 7)
    if paren_uncertainty_strip=False or
    123 456.789 8(123.4567)
    if paren_uncertainty_strip=True, but always retaining the decimal separator. In most cases many fewer significant digits of the uncertainty are displayed and the resulting outputs don't look as egregious when the decimal separator is stripped. Nonetheless, given that more outputs look better when the decimal is retained and that there is no official BIPM guidance on how parentheses should handle cases when the uncertainty digits span decimal or other separator characters, sciform will not presently provide an option to strip the decimal separator character.

Changed

  • Previously, when using paren_uncertainty=True, redundant parentheses were included around the value and uncertainty numbers if there was an ASCII exponent (e.g. e+02) or in percent formatting mode. E.g. outputs would look like (32.4(1.2))e+02 or (32.4(1.2))%. Now these redundant parentheses are excluded so outputs look like 32.4(1.2)e+02 or 32.4(1.2)%. This is consistent with how the uncertainties package handles these cases. The extra parentheses were originally included for increased clarity, but the extra parentheses only clutter the output and there is sufficient clarity without them. This change eliminates an issue where the redundant parentheses were erroneously included or excluded after LaTeX/HTML/ASCII output conversion. [#145]

Fixed

  • Previously, when formatting individual Decimal input values, the values were always normalized at an early stage in formatting. This meant that even if ndigits=AutoDigits then Decimal("1.0") would be formatted the same as Decimal("1.00"). However, for value/uncertainty formatting, Decimal input to the uncertainty was not necessarily normalized at an early stage. This meant that with ndigits=AutoDigits, an uncertainty of Decimal("1.0") would be formatted to the tenths decimal place while an uncertainty of Decimal("1.00") would be formatted to the hundredths place. This behavior was inconsistent and undocumented. Now all Decimal inputs are immediately normalized before any formatting. [#148]
  • Fixed the behavior around the sign symbols for zero and non-finite inputs. Previously 0 was treated as positive for the sake of resolving its sign symbol, the sign of infinite numbers was preserved but +inf did not respect the "+" and " " sign modes, and nan never had a sign but also never had an extra character added for "+" or " " sign modes. Now both 0 and nan are treated as having no sign. In both "+" and " " sign modes 0 and nan are prepended by a space. The sign of infinite numbers is retained as before, but now formatting of these numbers respects the sign mode. [#147]

0.34.1

10 Feb 20:28
525ef88
Compare
Choose a tag to compare

0.34.1 (2024-02-10)

Added

  • Updated the readme to reflect completion of the PyOpenSci review.

0.34.0

04 Feb 07:36
6b21513
Compare
Choose a tag to compare

0.34.0 (2024-02-04)

Added

  • The Formatter now exposes the input_options and populated_options attributes. The input_options attribute holds an InputOptions object which stores a record of the input options passed into the Formatter. The populated_options attribute returns a PopulatedOptions object which shows the complete set of populated options which will be used for formatting after merging with the global options. Note that the populated_options attribute is re-calculated each time it is access so that it reflects the current global options. Both the InputOptions and PopulatedOptions objects can be used to provide string representations of the options, or provide programmatic access to the options via either attribute access or the as_dict() methods. [#110]
  • The PopulatedOptions used during formatting of a given FormattedNumber instance are stored on that instance for future
    reference.
  • Added get_default_global_options().
  • Now integer 0 can be passed into left_pad_char to get the same behavior as string "0". [#128]
  • Added tests for docstrings.

Changed

  • [BREAKING] Renamed functions for configuring global options:

    • set_global_defaults() -> set_global_options()
    • reset_global_defaults() -> reset_global_options()
    • GlobalDefaultsContext() -> GlobalOptionsContext()
  • Refactored backend options handling code. Previously, UserOptions were rendered into RenderedOptions. During rendering the global options were appropriately merged in andsome string literal options were replaced with enums for internal use. These two classes were private. Now there are InputOptions (which try to faithfully record user input), PopulatedOptions (which capture the result of merging the global options into the input options, but still using user-friendly string representations of all options), and FinalizedOptions (which use the internal enum representations ofcertain options). The InputOptions and PopulatedOptions are now public while the FinalizedOptions is still private to shield the enum representations from the users. This sizable refactor was precipitated by the publicizing of the options. [#110]

Removed

  • [BREAKING] Removed print_global_defaults() in favor of get_global_defaults() which now returns a PopulatedOptions object which can be printed by the user if desired.

Fixed

  • Fixed a bug where SciNum formatting resulted in str objects instead of FormattedNumber objects.

0.33.0

31 Jan 21:19
a52f125
Compare
Choose a tag to compare

0.33.0 (2024-01-31)

Added

  • Added the FormattedNumber class. This class is a subclass of str and is now returned by the Formatter instead of str. The FormattedNumber class allows post-conversion to ASCII, HTML, and LaTeX formats. [#114 <https://github.com/jagerber48/sciform/issues/114>_]
  • Added separate flags for code coverage reports for each python version.

Changed

  • In addition to removing the latex option from the Formatter in favor of the introduction of the FormattedNumber class, the LaTeX conversion algorithm has been slightly modified.

    • Left and right parentheses are no longer converted to "\left(" and "\right)" due to introducing strange spacing issues. See Spacing around \\left and \\right <https://tex.stackexchange.com/questions/2607/spacing-around-left-and-right>_.
    • Previously spaces within the sciform output were handled inconsistently and occasionally required confusing extra handling. Now any spaces in the input string are directly and explicitly converted into math mode medium spaces: "\:".
    • "μ" is now included in the math mode \text{} environment and converted to "\textmu".
  • [BREAKING] Renamed fill_char to left_pad_char. [#126 <https://github.com/jagerber48/sciform/issues/126>_]

  • Slimmed down [dev] optional dependencies and created [examples] optional dependencies. The former includes development tools, while the latter includes the heavy-weight requirements needed to run all the examples, including, e.g. jupyter, scipy, etc.

  • Cleaned up and improved github actions for testing and linting/formatting. [#136 <https://github.com/jagerber48/sciform/issues/136>_]

    • Use unittest and coverage instead of pytest.
    • The requirements to run the automation match the [dev] optional dependencies.
    • Cache pip requirements to avoid unnecessarily downloading dependencies.
    • Remove a defunct blackdoc test. Hopefully this can be replaced when ruff provides functionality for formatting .rst files.

Fixed

  • Fixed a bug where value/uncertainty pairs formatted in the "parts_per" format with zero exponent would appear with redundant parentheses, e.g. "(1.2 ± 0.1)". [#130 <https://github.com/jagerber48/sciform/issues/130>_]

Removed

  • [BREAKING] Removed the latex option in favor of the introduction of the FormattedNumber.as_latex() method. This removal simplifies the formatting algorithm by separating LaTeX formatting from other tasks like exponent string resolution. The latex option also introduced a potential confusion with the superscript option, which had no effect when latex=True.

0.32.3

12 Jan 06:57
1d8e287
Compare
Choose a tag to compare

0.32.3 (2024-01-11)

Added

  • Added more PyPi classifiers.

0.32.2

12 Jan 06:33
621a1ef
Compare
Choose a tag to compare

0.32.2 (2024-01-11)

Added

  • Expanded the "Under Construction" section of the readme and the "How to Contribute" section of the project page. Changes included adding links to the sciform feedback survey.
  • Added examples in the documentation demonstrating how sciform formatting can be mapped over collections of numbers. [#120 <https://github.com/jagerber48/sciform/issues/120>_]

Changed

  • Refactor backend mode literal (used for typing) and enum (used internally for tracking options) object names so that e.g. SignMode -> SignModeEnum and UserSignMode -> SignMode. [#111 <https://github.com/jagerber48/sciform/issues/111>_]

0.32.0

10 Jan 10:03
d03eedf
Compare
Choose a tag to compare

0.32.0 (2024-01-10)

Added

  • Previously it was impossible to configure pdg_sig_figs=True together with ndigits!=AutoDigits. This combinations resulted in an exception. Now behavior has been defined and implemented for this combination. For single value formatting the value of pdg_sig_figs is always ignored. For value/uncertainty formatting ndigits is ignored if pdg_sig_figs=True. The behavior for pdg_sig_figs=False is unchanged. [#73]

Removed

  • [BREAKING] Removed global_add_c_prefix, global_add_small_si_prefixes, global_add_ppth_form, global_reset_si_prefixes, global_reset_iec_prefixes, and global_reset_parts_per_forms. These options are redundant with set_global_defaults and GlobalDefaultsContext and make the extra translations dictionaries more confusing to understand. [#97]

Changed

  • [BREAKING] Previously 12.3 would format as "12.3e+00" when using parts per formatting mode. Now, when using parts per formatting mode, the e+00 exponent is translated to be an empty string so that 12.3 would format as "12.3". [#99]

0.31.1

07 Jan 04:02
5aac95c
Compare
Choose a tag to compare

0.31.1 (2024-01-06)

Removed

  • [BREAKING] Removed the SciNumUnc class. Now the SciNum class can be used with an optional second positional argument to specify the uncertainty associated with a number.

  • [BREAKING] Remove separator configuration from the FSML. These options made the FSML to cumbersome and led to confusing (if not incorrect) conflicts with the round mode symbol. Now all separator configuration needs to be done by setting the global format options or using the global format options context manager. [#29]

Added

  • Added annotated examples demonstrating the FSML.
  • Added more documentation for contributing developers.
  • Added `pre-commit (https://pre-commit.com/) configuration.

Changed

  • [BREAKING] Renamed multiple options.

    • top_dig_place renamed to left_pad_dec_place.
    • superscript_exp renamed to superscript.
    • bracket_unc renamed to paren_uncertainty.
    • bracket_unc_remove_seps renamed to
      paren_uncertainty_separators. This change is associated with a
      a reversal of the Boolean logic on the option.
    • val_unc_match_widths renamed to left_pad_matching.
    • unc_pm_whitespace renamed to pm_whitespace.
  • [BREAKING] Previously specifying any left pad decimal place using the sciform FSML resulted in setting left_pad_matching=True so that print(f"{SciNum(123.456, 0.789):0}") resulted in "123.456 ± 000.789". Now the FSML has no impact on left_pad_matching. Now, similar to many other options, the global setting for left_pad_matching will always be used when formatting using the FSML. Under the default global options (left_pad_matching=False) print(f"{SciNum(123.456, 0.789):0}") results in "123.456 ± 0.789".

  • Implemented ruff linting and formatting in codebase and integration automation.

  • Refactored code for adding separators.

  • Refactored formatting and formatting utilities to simplify functions and make the algorithm easier to follow.

  • More aggressively filter JetBrains .idea/ folder from version control.

Fixed

  • Fixed a bug involving removing separators in parentheses uncertainty mode when at least one of the value and uncertainty were non-finite.
  • Fixed a typo that prevented pushing 0.31.0 readme to pypi.