maidr 0.17.0__py3-none-any.whl → 0.19.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- maidr/__init__.py +1 -1
- maidr/api.py +2 -2
- maidr/core/enum/maidr_key.py +4 -4
- maidr/core/maidr.py +58 -15
- maidr/core/plot/maidr_plot.py +3 -0
- maidr/core/plot/scatterplot.py +7 -4
- maidr/patch/scatterplot.py +0 -1
- {maidr-0.17.0.dist-info → maidr-0.19.0.dist-info}/METADATA +1 -1
- {maidr-0.17.0.dist-info → maidr-0.19.0.dist-info}/RECORD +11 -11
- {maidr-0.17.0.dist-info → maidr-0.19.0.dist-info}/LICENSE +0 -0
- {maidr-0.17.0.dist-info → maidr-0.19.0.dist-info}/WHEEL +0 -0
maidr/__init__.py
CHANGED
maidr/api.py
CHANGED
|
@@ -21,7 +21,7 @@ def render(plot: Any) -> Tag:
|
|
|
21
21
|
def show(plot: Any, renderer: Literal["auto", "ipython", "browser"] = "auto") -> object:
|
|
22
22
|
ax = FigureManager.get_axes(plot)
|
|
23
23
|
htmls = []
|
|
24
|
-
if
|
|
24
|
+
if isinstance(ax, list):
|
|
25
25
|
for axes in ax:
|
|
26
26
|
maidr = FigureManager.get_maidr(axes.get_figure())
|
|
27
27
|
htmls.append(maidr.render())
|
|
@@ -36,7 +36,7 @@ def save_html(
|
|
|
36
36
|
) -> str:
|
|
37
37
|
ax = FigureManager.get_axes(plot)
|
|
38
38
|
htmls = []
|
|
39
|
-
if
|
|
39
|
+
if isinstance(ax, list):
|
|
40
40
|
for axes in ax:
|
|
41
41
|
maidr = FigureManager.get_maidr(axes.get_figure())
|
|
42
42
|
htmls.append(maidr.render())
|
maidr/core/enum/maidr_key.py
CHANGED
maidr/core/maidr.py
CHANGED
|
@@ -6,7 +6,7 @@ import os
|
|
|
6
6
|
import tempfile
|
|
7
7
|
import uuid
|
|
8
8
|
import webbrowser
|
|
9
|
-
from typing import Literal
|
|
9
|
+
from typing import Any, Literal
|
|
10
10
|
|
|
11
11
|
from htmltools import HTML, HTMLDocument, Tag, tags
|
|
12
12
|
from lxml import etree
|
|
@@ -139,23 +139,66 @@ class Maidr:
|
|
|
139
139
|
|
|
140
140
|
def _flatten_maidr(self) -> dict | list[dict]:
|
|
141
141
|
"""Return a single plot schema or a list of schemas from the Maidr instance."""
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
# Replace the selector having maidr='true' with maidr={self.maidr_id}
|
|
147
|
-
for plot in maidr:
|
|
148
|
-
if MaidrKey.SELECTOR in plot:
|
|
149
|
-
plot[MaidrKey.SELECTOR] = plot[MaidrKey.SELECTOR].replace(
|
|
150
|
-
"maidr='true'", f"maidr='{self.selector_id}'"
|
|
151
|
-
)
|
|
142
|
+
# To support legacy JS Engine we will just return the format in this way
|
|
143
|
+
# but soon enough this should be deprecated and when we will completely
|
|
144
|
+
# transition to TypeScript :)
|
|
152
145
|
engine = Environment.get_engine()
|
|
153
146
|
if engine == "js":
|
|
147
|
+
if self.plot_type in (PlotType.LINE, PlotType.DODGED, PlotType.STACKED):
|
|
148
|
+
self._plots = [self._plots[0]]
|
|
149
|
+
maidr = [plot.schema for plot in self._plots]
|
|
150
|
+
for plot in maidr:
|
|
151
|
+
if MaidrKey.SELECTOR in plot:
|
|
152
|
+
plot[MaidrKey.SELECTOR] = plot[MaidrKey.SELECTOR].replace(
|
|
153
|
+
"maidr='true'", f"maidr='{self.selector_id}'"
|
|
154
|
+
)
|
|
154
155
|
return maidr if len(maidr) != 1 else maidr[0]
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
|
|
157
|
+
# Now let's start building the maidr object for the newer TypeScript engine
|
|
158
|
+
|
|
159
|
+
plot_schemas = []
|
|
160
|
+
|
|
161
|
+
for plot in self._plots:
|
|
162
|
+
schema = plot.schema
|
|
163
|
+
if MaidrKey.SELECTOR in schema:
|
|
164
|
+
schema[MaidrKey.SELECTOR] = schema[MaidrKey.SELECTOR].replace(
|
|
165
|
+
"maidr='true'", f"maidr='{self.selector_id}'"
|
|
166
|
+
)
|
|
167
|
+
plot_schemas.append(
|
|
168
|
+
{
|
|
169
|
+
"schema": schema,
|
|
170
|
+
"row": getattr(plot, "row_index", 0),
|
|
171
|
+
"col": getattr(plot, "col_index", 0),
|
|
172
|
+
}
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
max_row = max([plot.get("row", 0) for plot in plot_schemas], default=0)
|
|
176
|
+
max_col = max([plot.get("col", 0) for plot in plot_schemas], default=0)
|
|
177
|
+
|
|
178
|
+
subplot_grid: list[list[dict[str, str | list[Any]]]] = [
|
|
179
|
+
[{} for _ in range(max_col + 1)] for _ in range(max_row + 1)
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
position_groups = {}
|
|
183
|
+
for plot in plot_schemas:
|
|
184
|
+
pos = (plot.get("row", 0), plot.get("col", 0))
|
|
185
|
+
if pos not in position_groups:
|
|
186
|
+
position_groups[pos] = []
|
|
187
|
+
position_groups[pos].append(plot["schema"])
|
|
188
|
+
|
|
189
|
+
for (row, col), layers in position_groups.items():
|
|
190
|
+
if subplot_grid[row][col]:
|
|
191
|
+
subplot_grid[row][col]["layers"].append(layers)
|
|
192
|
+
else:
|
|
193
|
+
subplot_grid[row][col] = {"id": Maidr._unique_id(), "layers": layers}
|
|
194
|
+
|
|
195
|
+
for i in range(len(subplot_grid)):
|
|
196
|
+
subplot_grid[i] = [
|
|
197
|
+
cell if cell is not None else {"id": Maidr._unique_id(), "layers": []}
|
|
198
|
+
for cell in subplot_grid[i]
|
|
199
|
+
]
|
|
200
|
+
|
|
201
|
+
return {"id": Maidr._unique_id(), "subplots": subplot_grid}
|
|
159
202
|
|
|
160
203
|
def _get_svg(self) -> HTML:
|
|
161
204
|
"""Extract the chart SVG from ``matplotlib.figure.Figure``."""
|
maidr/core/plot/maidr_plot.py
CHANGED
maidr/core/plot/scatterplot.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import numpy.ma as ma
|
|
4
|
-
|
|
5
4
|
from matplotlib.axes import Axes
|
|
6
5
|
from matplotlib.collections import PathCollection
|
|
7
6
|
|
|
@@ -36,8 +35,12 @@ class ScatterPlot(MaidrPlot, CollectionExtractorMixin):
|
|
|
36
35
|
|
|
37
36
|
return [
|
|
38
37
|
{
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
"points": [
|
|
39
|
+
{
|
|
40
|
+
MaidrKey.X: float(x),
|
|
41
|
+
MaidrKey.Y: float(y),
|
|
42
|
+
}
|
|
43
|
+
for x, y in ma.getdata(plot.get_offsets())
|
|
44
|
+
]
|
|
41
45
|
}
|
|
42
|
-
for x, y in ma.getdata(plot.get_offsets())
|
|
43
46
|
]
|
maidr/patch/scatterplot.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: maidr
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: Multimodal Access and Interactive Data Representations
|
|
5
5
|
License: GPL-3.0-or-later
|
|
6
6
|
Keywords: accessibility,visualization,sonification,braille,tactile,multimodal,data representation,blind,low vision,visual impairments
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
maidr/__init__.py,sha256=
|
|
2
|
-
maidr/api.py,sha256=
|
|
1
|
+
maidr/__init__.py,sha256=9RllXJL4rpu3WSbebir45U3QFkUqf9Wq51Y373ExVhw,369
|
|
2
|
+
maidr/api.py,sha256=m4fkbW2gV9yhHq0uMi5_DW35VWh5v0wFGqT00ceR5Wc,1878
|
|
3
3
|
maidr/core/__init__.py,sha256=WgxLpSEYMc4k3OyEOf1shOxfEq0ASzppEIZYmE91ThQ,25
|
|
4
4
|
maidr/core/context_manager.py,sha256=HSzD4wpiALdI4Vm0QTdWqi1MWR5Uqy8BX_lOlCM3JYY,3463
|
|
5
5
|
maidr/core/enum/__init__.py,sha256=9ee78L0dlxEx4ulUGVlD-J23UcUZmrGu0rXms54up3c,93
|
|
6
6
|
maidr/core/enum/library.py,sha256=e8ujT_L-McJWfoVJd1ty9K_2bwITnf1j0GPLsnAcHes,104
|
|
7
|
-
maidr/core/enum/maidr_key.py,sha256=
|
|
7
|
+
maidr/core/enum/maidr_key.py,sha256=rDNpl7edBAHs869ECw5gMz_AKxetK-BXJ25BIJ-xTNU,736
|
|
8
8
|
maidr/core/enum/plot_type.py,sha256=pyfyIwlq3taqe2Z1sVUSbMsTp5QTvYBlZXsMMMclEVM,293
|
|
9
9
|
maidr/core/figure_manager.py,sha256=rd8XEwqNmfKu1I9zGD1p9g3wVlkMYNCrdLLCg4IzlfQ,3934
|
|
10
|
-
maidr/core/maidr.py,sha256=
|
|
10
|
+
maidr/core/maidr.py,sha256=iEi59R4oLuSIOocEhWzdQCRE3FvvPmzE2LiR5mmZjWk,13811
|
|
11
11
|
maidr/core/plot/__init__.py,sha256=xDIpRGM-4DfaSSL3nKcXrjdMecCHJ6en4K4nA_fPefQ,83
|
|
12
12
|
maidr/core/plot/barplot.py,sha256=b7r0cz3yMZzWwiTJVUy1yWBXhv_oN9rwEb6hfKVg3Zs,2600
|
|
13
13
|
maidr/core/plot/boxplot.py,sha256=roADG8xJYRQlZPYbfGBQSQRw8974lhVnngGKEKXJttk,6090
|
|
@@ -15,9 +15,9 @@ maidr/core/plot/grouped_barplot.py,sha256=tAiOWwtfsWDwyGdUuCdQ6-f8UQxnsDDwpN30Sk
|
|
|
15
15
|
maidr/core/plot/heatmap.py,sha256=_Hn_wXsu-BQBYs4YO440-WRhmXAJ1WeBndBGVEUAP5M,2447
|
|
16
16
|
maidr/core/plot/histogram.py,sha256=QV5W-6ZJQQcZsrM91JJBX-ONktJzH7yg_et5_bBPfQQ,1525
|
|
17
17
|
maidr/core/plot/lineplot.py,sha256=OQQtJb7lmO-lZTQfhqMV4sfztyuEicZfe95y9nIhfTo,3280
|
|
18
|
-
maidr/core/plot/maidr_plot.py,sha256=
|
|
18
|
+
maidr/core/plot/maidr_plot.py,sha256=9z8I_W4o_NWvz-S5QFp1kB0L23AHvt0PDxRhxgeJcmY,3299
|
|
19
19
|
maidr/core/plot/maidr_plot_factory.py,sha256=QGcHK_oquY_M2_KJVEtc5-rBAD-gm7KI1kSD7cduHzg,1691
|
|
20
|
-
maidr/core/plot/scatterplot.py,sha256=
|
|
20
|
+
maidr/core/plot/scatterplot.py,sha256=fre5FNhGVoQkm8V2CP9nxhjHN5ZyzptCrVmse_KCU1Q,1353
|
|
21
21
|
maidr/exception/__init__.py,sha256=PzaXoYBhyZxMDcJkuxJugDx7jZeseI0El6LpxIwXyG4,46
|
|
22
22
|
maidr/exception/extraction_error.py,sha256=rd37Oxa9gn2OWFWt9AOH5fv0hNd3sAWGvpDMFBuJY2I,607
|
|
23
23
|
maidr/patch/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -29,7 +29,7 @@ maidr/patch/heatmap.py,sha256=uxLLg530Ql9KVC5rxk8vnwPHXBWWHwYgJRkyHY-tJzs,1048
|
|
|
29
29
|
maidr/patch/highlight.py,sha256=2DOO1tLDpXDtGd8DAPpnDOtq2_rWViPS7IDn9TbBXyA,925
|
|
30
30
|
maidr/patch/histogram.py,sha256=tnyKkTMuzDXdyQBywhpHZgH3i2mXzOCSyfUSRM0tfUg,1315
|
|
31
31
|
maidr/patch/lineplot.py,sha256=_EyqOp8BcO-kGq9sn8PyNQ8-Bz0FsnHAufXRkTGQzBw,1025
|
|
32
|
-
maidr/patch/scatterplot.py,sha256=
|
|
32
|
+
maidr/patch/scatterplot.py,sha256=kln6zZwjVsdQzICalo-RnBOJrx1BnIB2xYUwItHvSNY,525
|
|
33
33
|
maidr/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
maidr/util/environment.py,sha256=xtfibTH4RXW2GC7R_9OQo119BTe5M3bx0u13eFZaiZs,4554
|
|
35
35
|
maidr/util/mixin/__init__.py,sha256=aGJZNhtWh77yIVPc7ipIZm1OajigjMtCWYKPuDWTC-c,217
|
|
@@ -37,7 +37,7 @@ maidr/util/mixin/extractor_mixin.py,sha256=AjpgCo_dgASdTwFumfgDOoVCVioxDDoqFWpha
|
|
|
37
37
|
maidr/util/mixin/merger_mixin.py,sha256=V0qLw_6DUB7X6CQ3BCMpsCQX_ZuwAhoSTm_E4xAJFKM,712
|
|
38
38
|
maidr/widget/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
39
39
|
maidr/widget/shiny.py,sha256=wrrw2KAIpE_A6CNQGBtNHauR1DjenA_n47qlFXX9_rk,745
|
|
40
|
-
maidr-0.
|
|
41
|
-
maidr-0.
|
|
42
|
-
maidr-0.
|
|
43
|
-
maidr-0.
|
|
40
|
+
maidr-0.19.0.dist-info/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
|
41
|
+
maidr-0.19.0.dist-info/METADATA,sha256=VtQpcXHI79GE85Ab9im8KfodMDr4ZCFte-lsNVY74do,2688
|
|
42
|
+
maidr-0.19.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
|
|
43
|
+
maidr-0.19.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|