A package for formatting floats into scientific formatted strings.
Project description
Documentation: https://sciform.readthedocs.io/en/stable/
Overview
sciform is used to convert python float objects into strings according to a variety of user-selected scientific formatting options including fixed-pointa and decimal and binary scientific and engineering notations. Where possible, formatting follows documented standards such as those published by BIPM or IEC. sciform provides certain options, such as engineering notation, well-controlled significant figure rounding, and separator customization which are not provided by the python built-in format specification mini-language (FSML).
Installation
Install with pip:
pip install sciform
Usage
sciform provides two primary methods for formatting floats into scientific formatting strings. The first is via the Formatter object and the second is using string formatting and the custom FSML with the sfloat object.
>>> from sciform import Formatter, RoundMode, GroupingSeparator, FormatMode >>> sform = Formatter(round_mode=RoundMode.PREC, ... precision=6, ... upper_separator=GroupingSeparator.SPACE, ... lower_separator=GroupingSeparator.SPACE) >>> print(sform(3.14159265359)) 3.141 593 >>> sform = Formatter(round_mode=RoundMode.SIG_FIG, ... precision=4, ... format_mode=FormatMode.ENGINEERING) >>> print(sform(123456.78)) 123.5e+03
>>> from sciform import sfloat
>>> num = sfloat(123456)
>>> print(f'{num:_!2f}')
120_000
Acknowledgements
sciform was heavily motivated by the prefix formatting provided in the prefixed package and the value +/- uncertainty formatting in the uncertainties package.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sciform-0.11.1.tar.gz.
File metadata
- Download URL: sciform-0.11.1.tar.gz
- Upload date:
- Size: 15.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3af49d296087ba1745c7f5e782bbdfd4002b2de57e2b0899be5718e5f6f2fdd
|
|
| MD5 |
4750a2a5bb50747ea49d91c1ea0fd92f
|
|
| BLAKE2b-256 |
d00472b14bda77144574af922ba356de23dc87c0f46f24511ff5dfa04aec4d75
|
File details
Details for the file sciform-0.11.1-py3-none-any.whl.
File metadata
- Download URL: sciform-0.11.1-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71b1193639dc645f5a131f40ae07538cfca2094733d48d22fdbc6be01efb0d1c
|
|
| MD5 |
73756e227b3c4cde520cf7f044609916
|
|
| BLAKE2b-256 |
7ec8c3109f0ea6e695caace79ae2e4cb86e6d423b86de9853af4c4cc8d738ace
|