-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Breaking] Split
utils
into sub-modules, move typing
from utils
…
… to root (`pmv.typing`) (#248) * migrate some * more move * clean up docstring * ptable_hists_plotly | ptable_heatmap_splits_plotly support multiple annotations per element tile * fix test_init.py not wrapping asserts in test function * merge utils/misc.py into utils/__init__.py and utils/image.py into utils/plotting.py * move ExperimentalWarning into __init__ * mv utils/typing.py to typing.py --------- Co-authored-by: Janosh Riebesell <[email protected]>
- Loading branch information
1 parent
0d24ace
commit bc2669b
Showing
32 changed files
with
1,056 additions
and
887 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
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
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
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
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
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,44 @@ | ||
"""Typing related: TypeAlias, generic types and so on.""" | ||
|
||
from __future__ import annotations | ||
|
||
from collections.abc import Sequence | ||
from typing import TYPE_CHECKING, Literal, ParamSpec, TypeVar, get_args | ||
|
||
import matplotlib.pyplot as plt | ||
import pandas as pd | ||
import plotly.graph_objects as go | ||
|
||
|
||
if TYPE_CHECKING: | ||
from typing import TypeAlias | ||
|
||
AxOrFig: TypeAlias = plt.Axes | plt.Figure | go.Figure | ||
|
||
Backend: TypeAlias = Literal["matplotlib", "plotly"] | ||
BACKENDS = MATPLOTLIB, PLOTLY = get_args(Backend) | ||
|
||
ColorElemTypeStrategy: TypeAlias = Literal["symbol", "background", "both", "off"] | ||
VALID_COLOR_ELEM_STRATEGIES = get_args(ColorElemTypeStrategy) | ||
|
||
CrystalSystem: TypeAlias = Literal[ | ||
"triclinic", | ||
"monoclinic", | ||
"orthorhombic", | ||
"tetragonal", | ||
"trigonal", | ||
"hexagonal", | ||
"cubic", | ||
] | ||
|
||
ElemValues: TypeAlias = dict[str | int, float] | pd.Series | Sequence[str] | ||
|
||
T = TypeVar("T") # generic type for input validation | ||
P = ParamSpec("P") # generic type for function parameters | ||
R = TypeVar("R") # generic type for return value | ||
|
||
|
||
VALID_FIG_TYPES = get_args(AxOrFig) | ||
VALID_FIG_NAMES: str = " | ".join( | ||
f"{t.__module__}.{t.__qualname__}" for t in VALID_FIG_TYPES | ||
) |
Oops, something went wrong.