-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from janpipek/rich
Rich
- Loading branch information
Showing
5 changed files
with
1,630 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,6 @@ build: | |
|
||
publish: build | ||
uv publish | ||
|
||
examples: | ||
uv run --extra all python -m physt.examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""Script showing some of the physt examples. | ||
You can run this like: | ||
python -m physt.examples | ||
""" | ||
import importlib | ||
import sys | ||
|
||
from rich.json import JSON | ||
from rich.panel import Panel | ||
|
||
if not importlib.util.find_spec("rich"): | ||
print("Please, install rich or physt[terminal] to view nice terminal output.") | ||
sys.exit(-1) | ||
|
||
from rich.console import Console | ||
|
||
from physt.examples import normal_h1, normal_h2 | ||
|
||
console = Console() | ||
|
||
|
||
h1 = normal_h1() | ||
h2 = normal_h2() | ||
|
||
console.print("[bold]A 1D histogram:[/bold]") | ||
console.print(h1) | ||
|
||
console.print() | ||
console.print("[bold]The associated stats:[/bold]") | ||
console.print(h1.statistics) | ||
|
||
console.print() | ||
console.print("[bold]And the plot:[/bold]") | ||
|
||
h1.plot(backend="ascii", show_values=True) | ||
console.print() | ||
|
||
console.print("[bold]JSON fully describing the histogram:[/bold]") | ||
console.print(Panel(JSON(h1.to_json()), width=min(console.width, 60))) | ||
|
||
console.print("[bold]A 2D histogram:[/bold]") | ||
console.print(h2) | ||
|
||
console.print() | ||
console.print("[bold]And the plot:[/bold]") | ||
h2.plot(backend="ascii") |
Oops, something went wrong.