Other Utilities¶
theme
¶
Colors and plotly themes of mesqual.
colors
module-attribute
¶
colors = ColorPalette
The color groups of the mesqual theme, for example colors.primary.teal.
plotly_theme_dark
module-attribute
¶
plotly_theme_dark = PlotlyTheme(default_colorway=QualitativeColors.default, font=dict(family='Inter, sans-serif', size=12, color=DarkGreyColors.text), paper_color=DarkGreyColors.background, background_color=DarkGreyColors.background, xaxis=dict(gridcolor=DarkGreyColors.gridlines, linecolor=DarkGreyColors.borders, zerolinecolor=DarkGreyColors.borders), yaxis=dict(gridcolor=DarkGreyColors.gridlines, linecolor=DarkGreyColors.borders, zerolinecolor=DarkGreyColors.borders), legend=dict(bgcolor='rgba(0,0,0,0)'))
Dark plotly theme: DarkGreyColors, the font Inter and the colorway QualitativeColors.default.
plotly_theme_light
module-attribute
¶
plotly_theme_light = PlotlyTheme(default_colorway=QualitativeColors.default, font=dict(family='Arial, sans-serif', size=12, color=LightGreyColors.text), paper_color=LightGreyColors.paper, background_color=LightGreyColors.background, xaxis=dict(gridcolor=LightGreyColors.gridlines, linecolor=LightGreyColors.borders, zerolinecolor=LightGreyColors.borders), yaxis=dict(gridcolor=LightGreyColors.gridlines, linecolor=LightGreyColors.borders, zerolinecolor=LightGreyColors.borders), legend=dict(bgcolor='rgba(255,255,255,0.6)'))
Light plotly theme: LightGreyColors, the font Arial and the colorway QualitativeColors.default.
PrimaryColors
¶
Bases: ConstantsIterable
The primary colors of the mesqual theme.
Attributes:
| Name | Type | Description |
|---|---|---|
sky_blue |
|
|
teal |
|
|
amber |
|
|
violet |
|
|
rose |
|
|
green |
|
Source code in src/mesqual/utils/theme.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
SequentialColors
¶
Bases: ConstantsIterable
Sequential color scales from light to dark, seven hex colors each.
Attributes:
| Name | Type | Description |
|---|---|---|
sky_blue |
Scale around |
|
teal |
Scale around |
|
amber |
Scale around |
|
violet |
Scale around |
|
rose |
Scale around |
|
green |
Scale around |
|
default |
|
Source code in src/mesqual/utils/theme.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
DarkGreyColors
¶
Bases: ConstantsIterable
Greys of the dark theme.
Attributes:
| Name | Type | Description |
|---|---|---|
background |
Paper and plot background. |
|
gridlines |
Grid lines. |
|
borders |
Axis lines and zero lines. |
|
text |
Font color. |
Source code in src/mesqual/utils/theme.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
LightGreyColors
¶
Bases: ConstantsIterable
Greys of the light theme.
Attributes:
| Name | Type | Description |
|---|---|---|
background |
Plot background. |
|
paper |
Paper background. |
|
gridlines |
Grid lines. |
|
borders |
Axis lines and zero lines. |
|
text |
Font color. |
Source code in src/mesqual/utils/theme.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
DivergingColors
¶
Bases: ConstantsIterable
Diverging color scales: one sequential scale reversed, followed by another one.
Attributes:
| Name | Type | Description |
|---|---|---|
teal_amber |
Teal from dark to light, then amber from light to dark. |
|
violet_green |
Violet from dark to light, then green from light to dark. |
|
default |
|
Source code in src/mesqual/utils/theme.py
82 83 84 85 86 87 88 89 90 91 92 93 | |
CyclicalColors
¶
Bases: ConstantsIterable
Cyclical color scales. The theme defines none.
Attributes:
| Name | Type | Description |
|---|---|---|
default |
|
Source code in src/mesqual/utils/theme.py
96 97 98 99 100 101 102 103 | |
QualitativeColors
¶
Bases: ConstantsIterable
Colors for categories.
Attributes:
| Name | Type | Description |
|---|---|---|
default |
Sky blue, teal, amber, violet, green and rose from
|
Source code in src/mesqual/utils/theme.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
ColorPalette
¶
All color groups of the mesqual theme. The module constant colors is this class.
Attributes:
| Name | Type | Description |
|---|---|---|
primary |
|
|
greys_light |
|
|
greys_dark |
|
|
sequential |
|
|
diverging |
|
|
cyclical |
|
|
qualitative |
|
Source code in src/mesqual/utils/theme.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | |
str_to_bool
¶
Conversion of strings and other values to bool.
any_to_bool
¶
any_to_bool(value) -> bool
Convert a value to a bool: a string with str_to_bool, any other value by its truth value.
So None gives False, and NaN gives True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value. |
required |
Source code in src/mesqual/utils/str_to_bool.py
4 5 6 7 8 9 10 11 12 13 14 15 16 | |
str_to_bool
¶
str_to_bool(text: str) -> bool
Return False for false, f, 0, no, n, off or an empty string, in any case; True for any other string.
Source code in src/mesqual/utils/str_to_bool.py
19 20 21 | |
pair_combiner
¶
Names and tuples of pairs, for example of borders.
PairCombiner
¶
Builds names and tuples of pairs: as given, reversed or sorted, for example 'C1 - C2' for a border from C1 to C2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
separator
|
str
|
Text between the two parts of a pair name. |
' - '
|
Source code in src/mesqual/utils/pair_combiner.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | |
get_combo_as_str
¶
get_combo_as_str(a: str, b: str) -> str
Return a and b joined by the separator, for example 'C1 - C2'.
Source code in src/mesqual/utils/pair_combiner.py
14 15 16 | |
get_combo_as_tuple
¶
get_combo_as_tuple(a: str, b: str) -> tuple[str, str]
Return (a, b).
Source code in src/mesqual/utils/pair_combiner.py
18 19 20 | |
get_opposite_combo_as_str
¶
get_opposite_combo_as_str(a: str, b: str) -> str
Return b and a joined by the separator, for example 'C2 - C1' for a='C1'.
Source code in src/mesqual/utils/pair_combiner.py
22 23 24 | |
get_opposite_combo_as_tuple
¶
get_opposite_combo_as_tuple(a: str, b: str) -> tuple[str, str]
Return (b, a).
Source code in src/mesqual/utils/pair_combiner.py
26 27 28 | |
get_sorted_combo_as_str
¶
get_sorted_combo_as_str(a: str, b: str) -> str
Return a and b in sorted order joined by the separator, so both orders give the same name.
Source code in src/mesqual/utils/pair_combiner.py
30 31 32 | |
get_sorted_combo_as_tuple
¶
get_sorted_combo_as_tuple(a: str, b: str) -> tuple[str, str]
Return a and b as a tuple in sorted order.
Source code in src/mesqual/utils/pair_combiner.py
34 35 36 | |
set_aggregations
¶
Intersection and union of several iterables.
nested_intersection
¶
nested_intersection(iterable_of_iterables: Iterable[Iterable[T]]) -> set[T]
Intersection of all iterables. An empty input gives an empty set. A generator input works.
Source code in src/mesqual/utils/set_aggregations.py
8 9 10 11 12 13 | |
nested_union
¶
nested_union(iterable_of_iterables: Iterable[Iterable[T]]) -> set[T]
Union of all iterables. An empty input gives an empty set. A generator input works.
Source code in src/mesqual/utils/set_aggregations.py
16 17 18 | |
intersect_dicts
¶
The key/value pairs that several dicts have in common.
get_intersection_of_dicts
¶
get_intersection_of_dicts(dict_list: Iterable[dict]) -> dict
Returns a dictionary with key/value pairs that all provided dictionaries have in common.
Source code in src/mesqual/utils/intersect_dicts.py
6 7 8 9 10 11 12 13 | |
check_all_same
¶
Check whether all items are the same object.
all_same_object
¶
all_same_object(items: Iterable) -> bool
True if all items are the same object. An empty input gives True. A generator input works.
Source code in src/mesqual/utils/check_all_same.py
6 7 8 9 | |
common_base_key_finder
¶
Base keys that appear with each of several tags.
CommonBaseKeyFinder
¶
Find the base keys that appear with each of several association tags.
The base key of a key is the key without the tag. A tag can be anywhere in the key, not only at the end.
Examples:
>>> finder = CommonBaseKeyFinder('_from', '_to')
>>> keys = ['node_from', 'node_to', 'node_via', 'country_from', 'country_to', 'capacity']
>>> sorted(finder.get_keys_for_which_all_association_tags_appear(keys))
['country', 'node']
Source code in src/mesqual/utils/multi_key_utils/common_base_key_finder.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
get_keys_for_which_all_association_tags_appear
¶
get_keys_for_which_all_association_tags_appear(keys: list[str]) -> list[str]
Return the base keys that appear with each tag, in no fixed order.
The base key of a key is the key with all occurrences of a tag
removed. The tag can be anywhere in the key, so 'x_from_y' gives
the base key 'x_y' for the tag '_from'.
Source code in src/mesqual/utils/multi_key_utils/common_base_key_finder.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |