Formatting of objects
Reference
measured.formatting
dimension_mathml(dimension: Dimension) -> str
Formats the given Dimension as a MathML expression
Source code in src/measured/formatting.py
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
dimension_pretty(dimension: Dimension, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Dimension to the provided pretty printer
Source code in src/measured/formatting.py
98 99 100 101 102 103 104 105 106 107 108 109 | |
dimension_repr(dimension: Dimension) -> str
Formats the given Dimension as a Python repr
Source code in src/measured/formatting.py
73 74 75 76 77 78 79 80 | |
dimension_str(dimension: Dimension) -> str
Formats the given Dimension as a plaintext string
Source code in src/measured/formatting.py
83 84 85 86 87 88 89 90 91 92 93 94 95 | |
from_superscript(string: str) -> int
Given a Unicode superscript string, return it as an integer.
Source code in src/measured/formatting.py
53 54 55 | |
level_mathml(level: Level) -> str
Formats the given Level as a MathML expression
Source code in src/measured/formatting.py
520 521 522 523 524 525 526 527 528 | |
level_pretty(level: Level, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Level to the provided pretty printer
Source code in src/measured/formatting.py
507 508 509 510 511 512 513 514 515 516 517 | |
level_repr(level: Level) -> str
Formats the given Level as a Python repr
Source code in src/measured/formatting.py
497 498 499 | |
level_str(level: Level) -> str
Formats the given Level as a plaintext string
Source code in src/measured/formatting.py
502 503 504 | |
logarithm_mathml(logarithm: Logarithm) -> str
Formats the given Logarithm as a MathML expression
Source code in src/measured/formatting.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 | |
logarithm_pretty(logarithm: Logarithm, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Logarithm to the provided pretty printer
Source code in src/measured/formatting.py
420 421 422 423 424 425 426 427 428 | |
logarithm_repr(logarithm: Logarithm) -> str
Formats the given Logarithm as a Python repr
Source code in src/measured/formatting.py
399 400 401 402 403 404 405 406 407 408 | |
logarithm_str(logarithm: Logarithm) -> str
Formats the given Logarithm as a plaintext string
Source code in src/measured/formatting.py
411 412 413 414 415 416 417 | |
logarithmic_unit_mathml(logarithmic_unit: LogarithmicUnit) -> str
Formats the given LogarithmicUnit as a MathML expression
Source code in src/measured/formatting.py
483 484 485 486 487 488 489 490 491 492 493 494 | |
logarithmic_unit_pretty(logarithmic_unit: LogarithmicUnit, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given LogarithmicUnit to the provided pretty printer
Source code in src/measured/formatting.py
472 473 474 475 476 477 478 479 480 | |
logarithmic_unit_repr(logarithmic_unit: LogarithmicUnit) -> str
Formats the given LogarithmicUnit as a Python repr
Source code in src/measured/formatting.py
454 455 456 457 458 459 460 461 | |
logarithmic_unit_str(logarithmic_unit: LogarithmicUnit) -> str
Formats the given LogarithmicUnit as a plaintext string
Source code in src/measured/formatting.py
464 465 466 467 468 469 | |
mathml(function: Callable[[M], str]) -> Callable[[M], str]
Wraps the given MathML-producing function to produce a self-contained MathML tag. This allows for composable MathML functions that can produce both expressions and root MathML tag.
Source code in src/measured/formatting.py
61 62 63 64 65 66 67 68 69 70 | |
measurement_format(measurement: Measurement, format_specifier: str) -> str
Formats the given Measurement as a plaintext string, using the provided format specifier to control the output
Source code in src/measured/formatting.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 | |
measurement_mathml(measurement: Measurement) -> str
Formats the given Measurement as a MathML expression
Source code in src/measured/formatting.py
588 589 590 591 592 593 594 595 596 597 598 | |
measurement_pretty(measurement: Measurement, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Measurement to the provided pretty printer
Source code in src/measured/formatting.py
571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 | |
measurement_repr(measurement: Measurement) -> str
Formats the given Measurement as a Python repr
Source code in src/measured/formatting.py
531 532 533 534 535 536 537 538 | |
measurement_str(measurement: Measurement) -> str
Formats the given Measurement as a plaintext string
Source code in src/measured/formatting.py
541 542 543 | |
prefix_mathml(prefix: Prefix) -> str
Formats the given Prefix as a MathML expression
Source code in src/measured/formatting.py
178 179 180 181 182 183 184 185 186 | |
prefix_pretty(prefix: Prefix, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Prefix to the provided pretty printer
Source code in src/measured/formatting.py
165 166 167 168 169 170 171 172 173 174 175 | |
prefix_repr(prefix: Prefix) -> str
Formats the given Prefix as a Python repr
Source code in src/measured/formatting.py
151 152 153 | |
prefix_str(prefix: Prefix) -> str
Formats the given Prefix as a plaintext string
Source code in src/measured/formatting.py
156 157 158 159 160 161 162 | |
quantity_format(quantity: Quantity, format_specifier: str) -> str
Formats the given Quantity as a plaintext string, using the provided format specifier to control the output
Source code in src/measured/formatting.py
353 354 355 356 357 358 359 | |
quantity_mathml(quantity: Quantity) -> str
Formats the given Quantity as a MathML expression
Source code in src/measured/formatting.py
377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 | |
quantity_pretty(quantity: Quantity, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Quantity to the provided pretty printer
Source code in src/measured/formatting.py
362 363 364 365 366 367 368 369 370 371 372 373 374 | |
quantity_repr(quantity: Quantity) -> str
Formats the given Quantity as a Python repr
Source code in src/measured/formatting.py
333 334 335 | |
quantity_str(quantity: Quantity) -> str
Formats the given Quantity as a plaintext string
Source code in src/measured/formatting.py
338 339 340 341 342 343 344 345 346 347 348 349 350 | |
superscript(exponent: Numeric) -> str
Given a signed integer exponent, returns the Unicode superscript string for it
Examples:
>>> f"x{superscript(123)}"
'x¹²³'
>>> f"x{superscript(0)}"
'x⁰'
>>> f"x{superscript(-1)}"
'x⁻¹'
>>> f"x{superscript(1)}"
'x'
Source code in src/measured/formatting.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | |
unit_format(unit: Unit, format_specifier: str) -> str
Formats the given Unit as a plaintext string, using the provided format specifier to control the output
Source code in src/measured/formatting.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
unit_mathml(unit: Unit) -> str
Formats the given Unit as a MathML expression
Source code in src/measured/formatting.py
324 325 326 327 328 329 330 | |
unit_pretty(unit: Unit, pretty: RepresentationPrinter, cycle: bool) -> None
Formats the given Unit to the provided pretty printer
Source code in src/measured/formatting.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
unit_repr(unit: Unit) -> str
Formats the given Unit as a Python repr
Source code in src/measured/formatting.py
189 190 191 192 193 194 195 196 197 198 199 200 201 | |
unit_str(unit: Unit) -> str
Formats the given Unit as a plaintext string
Source code in src/measured/formatting.py
236 237 238 239 240 241 242 243 244 245 246 247 | |