maidr 1.4.9__py3-none-any.whl → 1.5.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 +7 -2
- maidr/core/maidr.py +1 -1
- maidr/util/environment.py +38 -0
- {maidr-1.4.9.dist-info → maidr-1.5.0.dist-info}/METADATA +3 -1
- {maidr-1.4.9.dist-info → maidr-1.5.0.dist-info}/RECORD +8 -8
- {maidr-1.4.9.dist-info → maidr-1.5.0.dist-info}/WHEEL +0 -0
- {maidr-1.4.9.dist-info → maidr-1.5.0.dist-info}/licenses/LICENSE +0 -0
maidr/__init__.py
CHANGED
maidr/api.py
CHANGED
|
@@ -13,8 +13,13 @@ from maidr.core.figure_manager import FigureManager
|
|
|
13
13
|
|
|
14
14
|
def render(plot: Any) -> Tag:
|
|
15
15
|
ax = FigureManager.get_axes(plot)
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
if isinstance(ax, list):
|
|
17
|
+
for axes in ax:
|
|
18
|
+
maidr = FigureManager.get_maidr(axes.get_figure())
|
|
19
|
+
return maidr.render()
|
|
20
|
+
else:
|
|
21
|
+
maidr = FigureManager.get_maidr(ax.get_figure())
|
|
22
|
+
return maidr.render()
|
|
18
23
|
|
|
19
24
|
|
|
20
25
|
def show(
|
maidr/core/maidr.py
CHANGED
|
@@ -311,7 +311,7 @@ class Maidr:
|
|
|
311
311
|
# Render the plot inside an iframe if in a Jupyter notebook, Google Colab
|
|
312
312
|
# or VSCode notebook. No need for iframe if this is a Quarto document.
|
|
313
313
|
# For TypeScript we will use iframe by default for now
|
|
314
|
-
if use_iframe and (Environment.is_notebook() or Environment.is_shiny()):
|
|
314
|
+
if use_iframe and (Environment.is_flask() or Environment.is_notebook() or Environment.is_shiny()):
|
|
315
315
|
unique_id = "iframe_" + Maidr._unique_id()
|
|
316
316
|
|
|
317
317
|
def generate_iframe_script(unique_id: str) -> str:
|
maidr/util/environment.py
CHANGED
|
@@ -6,6 +6,44 @@ import sys
|
|
|
6
6
|
class Environment:
|
|
7
7
|
_engine = "ts"
|
|
8
8
|
|
|
9
|
+
@staticmethod
|
|
10
|
+
def is_flask() -> bool:
|
|
11
|
+
"""
|
|
12
|
+
Check if the current environment is a Flask application.
|
|
13
|
+
|
|
14
|
+
This method detects Flask applications by checking if Flask's app context
|
|
15
|
+
is available using `flask.has_app_context()`. The app context is Flask's
|
|
16
|
+
way of tracking the current application state and is only available when
|
|
17
|
+
code is running within a Flask application.
|
|
18
|
+
|
|
19
|
+
Returns
|
|
20
|
+
-------
|
|
21
|
+
bool
|
|
22
|
+
True if the environment is a Flask application, False otherwise.
|
|
23
|
+
|
|
24
|
+
Examples
|
|
25
|
+
--------
|
|
26
|
+
>>> from maidr.util.environment import Environment
|
|
27
|
+
>>> Environment.is_flask()
|
|
28
|
+
False # When not in a Flask app
|
|
29
|
+
"""
|
|
30
|
+
try:
|
|
31
|
+
# Import Flask's has_app_context function
|
|
32
|
+
from flask import has_app_context
|
|
33
|
+
|
|
34
|
+
# has_app_context() returns True only when code is running within
|
|
35
|
+
# a Flask application context. This is Flask's built-in mechanism
|
|
36
|
+
# for detecting if the current execution environment is a Flask app.
|
|
37
|
+
#
|
|
38
|
+
# The app context is automatically created by Flask when:
|
|
39
|
+
# - A Flask app is running (app.run())
|
|
40
|
+
# - Code is executed within a Flask request context
|
|
41
|
+
# - The app context is manually pushed
|
|
42
|
+
return has_app_context()
|
|
43
|
+
except ImportError:
|
|
44
|
+
# Flask is not installed, so we're definitely not in a Flask app
|
|
45
|
+
return False
|
|
46
|
+
|
|
9
47
|
@staticmethod
|
|
10
48
|
def is_interactive_shell() -> bool:
|
|
11
49
|
"""Return True if the environment is an interactive shell."""
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: maidr
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: Multimodal Access and Interactive Data Representations
|
|
5
5
|
Project-URL: Homepage, https://xability.github.io/py-maidr
|
|
6
6
|
Project-URL: Repository, https://github.com/xability/py-maidr
|
|
@@ -34,12 +34,14 @@ Provides-Extra: jupyter
|
|
|
34
34
|
Requires-Dist: ipykernel>=6.0.0; extra == 'jupyter'
|
|
35
35
|
Requires-Dist: jupyter<2,>=1.0.0; extra == 'jupyter'
|
|
36
36
|
Provides-Extra: test
|
|
37
|
+
Requires-Dist: flask>=3.0.0; extra == 'test'
|
|
37
38
|
Requires-Dist: jupyter<2,>=1.0.0; extra == 'test'
|
|
38
39
|
Requires-Dist: matplotlib>=3.8; extra == 'test'
|
|
39
40
|
Requires-Dist: pytest-mock<4,>=3.12.0; extra == 'test'
|
|
40
41
|
Requires-Dist: pytest<8,>=7.3.2; extra == 'test'
|
|
41
42
|
Requires-Dist: seaborn>=0.12; extra == 'test'
|
|
42
43
|
Provides-Extra: visualization
|
|
44
|
+
Requires-Dist: flask>=3.0.0; extra == 'visualization'
|
|
43
45
|
Requires-Dist: matplotlib>=3.8; extra == 'visualization'
|
|
44
46
|
Requires-Dist: seaborn>=0.12; extra == 'visualization'
|
|
45
47
|
Requires-Dist: statsmodels>=0.14.4; extra == 'visualization'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
maidr/__init__.py,sha256=
|
|
2
|
-
maidr/api.py,sha256=
|
|
1
|
+
maidr/__init__.py,sha256=8Klcr4EJvP1oYVdBry2bxII4HA4tbuzlTlb5x_295H4,415
|
|
2
|
+
maidr/api.py,sha256=gRNLXqUWpFGdD-I7Nu6J0_LeEni9KRAr0TBHwHaDAsc,1928
|
|
3
3
|
maidr/core/__init__.py,sha256=WgxLpSEYMc4k3OyEOf1shOxfEq0ASzppEIZYmE91ThQ,25
|
|
4
4
|
maidr/core/context_manager.py,sha256=6cT7ZGOApSpC-SLD2XZWWU_H08i-nfv-JUlzXOtvWYw,3374
|
|
5
5
|
maidr/core/figure_manager.py,sha256=jXs-Prkeru1Pahj21hjh8BAwXM9ZFUZ3GFfKUfIRX_M,4117
|
|
6
|
-
maidr/core/maidr.py,sha256=
|
|
6
|
+
maidr/core/maidr.py,sha256=xy-Re6PjzotjSv1J6L2jT5IjsAm3XQo9OJl9xICAuRA,14115
|
|
7
7
|
maidr/core/enum/__init__.py,sha256=9ee78L0dlxEx4ulUGVlD-J23UcUZmrGu0rXms54up3c,93
|
|
8
8
|
maidr/core/enum/library.py,sha256=e8ujT_L-McJWfoVJd1ty9K_2bwITnf1j0GPLsnAcHes,104
|
|
9
9
|
maidr/core/enum/maidr_key.py,sha256=ljG0omqzd8K8Yk213N7i7PXGvG-IOlnE5v7o6RoGJzc,795
|
|
@@ -41,7 +41,7 @@ maidr/patch/regplot.py,sha256=k86ekd0E4XJ_L1u85zObuDnxuXlM83z7tKtyXRTj2rI,3240
|
|
|
41
41
|
maidr/patch/scatterplot.py,sha256=kln6zZwjVsdQzICalo-RnBOJrx1BnIB2xYUwItHvSNY,525
|
|
42
42
|
maidr/util/__init__.py,sha256=eRJZfRpDX-n7UoV3JXw_9Lbfu_qNl_D0W1UTvLL-Iv4,81
|
|
43
43
|
maidr/util/dedup_utils.py,sha256=RpgPL5p-3oULUHaTCZJaQKhPHfyPkvBLHMt8lAGpJ5A,438
|
|
44
|
-
maidr/util/environment.py,sha256
|
|
44
|
+
maidr/util/environment.py,sha256=ZPoXXZsqiDY9jdnxPhgP2KTSTUkoGWek0UJ8uR6F7RQ,6747
|
|
45
45
|
maidr/util/mplfinance_utils.py,sha256=aWNRkNS2IAF4YYEF9w7CcmcKWMGg3KkYJAv0xL8KcyY,14417
|
|
46
46
|
maidr/util/plot_detection.py,sha256=bgLHoDcHSRwOiyKzUK3EqGwdAIhF44ocHW5ox6xYGZw,3883
|
|
47
47
|
maidr/util/regression_line_utils.py,sha256=yFKr-H0whT_su2YVZwNksBLp5EC5s77sr6HUFgNcsyY,2329
|
|
@@ -51,7 +51,7 @@ maidr/util/mixin/extractor_mixin.py,sha256=oHtwpmS5kARvaLrSO3DKTPQxyFUw9nOcKN7rz
|
|
|
51
51
|
maidr/util/mixin/merger_mixin.py,sha256=V0qLw_6DUB7X6CQ3BCMpsCQX_ZuwAhoSTm_E4xAJFKM,712
|
|
52
52
|
maidr/widget/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
53
53
|
maidr/widget/shiny.py,sha256=wrrw2KAIpE_A6CNQGBtNHauR1DjenA_n47qlFXX9_rk,745
|
|
54
|
-
maidr-1.
|
|
55
|
-
maidr-1.
|
|
56
|
-
maidr-1.
|
|
57
|
-
maidr-1.
|
|
54
|
+
maidr-1.5.0.dist-info/METADATA,sha256=JoS1wyXJ3T7pl0YebNOqQ_N1PbLgpzqDeDUyGJiqYz8,3193
|
|
55
|
+
maidr-1.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
56
|
+
maidr-1.5.0.dist-info/licenses/LICENSE,sha256=IwGE9guuL-ryRPEKi6wFPI_zOhg7zDZbTYuHbSt_SAk,35823
|
|
57
|
+
maidr-1.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|