mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 23:24:55 -05:00
Run quartodoc build against the refactored package (engine/ extracted from core/, infra->infrastructure): regenerate the API reference so every stub points at the new paths. Adds engine.*/infrastructure.* stubs, removes the 41 stale core.solver.* / core.engine.* / core.scenarios.* / core.config.* / core.evaluation.* / infra*.qmd orphans, and refreshes the package pages (core now primitives-only) + index. Verified: all 47 documented symbols resolve in the new package; every index link resolves; zero stale mlsysim.core.<engine-mod> / mlsysim.infra references anywhere in docs/. (objects.json inventory is gitignored -- regenerated at build.)
22 lines
940 B
Plaintext
22 lines
940 B
Plaintext
# fmt.fmt { #mlsysim.fmt.fmt }
|
|
|
|
```python
|
|
fmt.fmt(quantity, unit=None, precision=1, commas=True, prefix='', suffix='')
|
|
```
|
|
|
|
Format a Pint Quantity (or plain number) for narrative text.
|
|
Returns a MarkdownStr so Quarto inserts the value verbatim (no escape).
|
|
|
|
The prefix and suffix arguments collapse the old MarkdownStr(f"...")
|
|
escape-hatch idiom into a single canonical helper. Common uses:
|
|
|
|
fmt(price, precision=0, prefix="$") # "$1,000"
|
|
fmt(rate * 100, precision=1, commas=False, suffix="%") # "12.4%"
|
|
fmt(bw_mb_s, precision=1, commas=False, suffix=" MB/s") # "2.4 MB/s"
|
|
fmt(speedup, precision=0, commas=False, suffix="x") # "8x"
|
|
|
|
Safety: Raises ValueError if formatting would hide meaningful magnitude:
|
|
non-zero values displayed as ``0``, non-integers displayed with
|
|
``precision=0``, or integer-like values shown with spurious decimals
|
|
(``512.0``). Use ``fmt_int(...)`` when integer display is intentional.
|