FaSt_PUC
FaSt_PUC is a Python package that provides pretty unit conversion with automatic SI prefix selection. It intelligently formats numbers with appropriate metric prefixes (like k, M, G, µ, n, etc.) to make them more readable.
Features
- Automatic selection of SI prefixes from atto (a) to peta (P)
- Support for custom unit strings
- Special formatting options for percentages and decibels
- File name compatible output
- Configurable precision
- Support for NumPy arrays
- No external dependencies except NumPy
Installation
Install using pip:
pip install fast-puc
Basic Usage
Import the package and call the main function:
from fast_puc import puc
# Basic number formatting
puc(1.0001) # "1"
puc(1.0001, "m") # "1m"
puc(0.991e-6, "s") # "991ns"
puc(1030e-9, "m") # "1.03µm"
puc(999.999, "W") # "1kW"
Advanced Features
Custom Separators and Special Formats
# Custom separators
puc(1.0001, " m") # "1 m" # with space separator
puc(1.0001, "_m") # "1_m" # with underscore separator
# Special formats
puc(0.911, "%") # "91.1%" # convert to percent
puc(1001, "dB") # "30dB" # convert to dB
puc(1030e-9, "!m") # "1p03um" # file name compatible with special character !
Precision Control
puc(1.2345, "m", precision=2) # "1.2m"
puc(0.012345, "m", precision=2) # "12mm"
puc(0.000123456, "m", precision=5) # "123460nm"
Advanced Options
The puc function accepts several optional parameters:
puc(value, # Number to format (float or numpy array)
unit="", # Unit string with optional modifiers
precision=3, # Number of significant digits
verbose=False, # Return additional formatting info
filecompatible=False) # Make output safe for filenames
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
Licensed under MIT License. See LICENSE for details.
Author
Written by Fabian Stutzki (fast@fast-apps.de)
For more information, visit https://www.fast-apps.de
Metadata
Release files for fast-puc 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| fast_puc-0.2.1.tar.gz | 21.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fast_puc-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.2 kB
Release files / fast_puc-0.2.1.tar.gz
| Download URL | fast_puc-0.2.1.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe09a3eb2767cdb7e4aec745e3f3450bc13257eee08590d4a33685e97dce3232
|
|
BLAKE2b-256 checksum How to use checksums |
9fafc889c1a5bbd03002f8e628e81df508336de6f822252b7b7c6d37e10174e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.30
|
Release files / fast_puc-0.2.1-py3-none-any.whl
| Download URL | fast_puc-0.2.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d4989501a357890020b47f2d120f561dce3c71d0b6d7706072701dea09da55a6
|
|
BLAKE2b-256 checksum How to use checksums |
09e40b7f8d145437ff28d233e91007e8bc0ab2216b8ee16e922178f5b4945694
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.5.30
|