figpack 0.2.6__py3-none-any.whl → 0.2.7__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.
Potentially problematic release.
This version of figpack might be problematic. Click here for more details.
- figpack/__init__.py +1 -1
- figpack/figpack-figure-dist/assets/{index-HXdk2TtM.js → index-CTBd5_Gw.js} +69 -68
- figpack/figpack-figure-dist/index.html +1 -1
- figpack/views/DataFrame.py +109 -0
- figpack/views/__init__.py +1 -0
- {figpack-0.2.6.dist-info → figpack-0.2.7.dist-info}/METADATA +2 -1
- {figpack-0.2.6.dist-info → figpack-0.2.7.dist-info}/RECORD +11 -10
- {figpack-0.2.6.dist-info → figpack-0.2.7.dist-info}/WHEEL +0 -0
- {figpack-0.2.6.dist-info → figpack-0.2.7.dist-info}/entry_points.txt +0 -0
- {figpack-0.2.6.dist-info → figpack-0.2.7.dist-info}/licenses/LICENSE +0 -0
- {figpack-0.2.6.dist-info → figpack-0.2.7.dist-info}/top_level.txt +0 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="./assets/neurosift-logo-CLsuwLMO.png" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>figpack figure</title>
|
|
8
|
-
<script type="module" crossorigin src="./assets/index-
|
|
8
|
+
<script type="module" crossorigin src="./assets/index-CTBd5_Gw.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-Cmae55E4.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"""
|
|
2
|
+
DataFrame view for figpack - displays pandas DataFrames as interactive tables
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any, Dict, Union
|
|
7
|
+
|
|
8
|
+
import numpy as np
|
|
9
|
+
import pandas as pd
|
|
10
|
+
import zarr
|
|
11
|
+
|
|
12
|
+
from ..core.figpack_view import FigpackView
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DataFrame(FigpackView):
|
|
16
|
+
"""
|
|
17
|
+
A DataFrame visualization component for displaying pandas DataFrames as interactive tables
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
def __init__(self, df: pd.DataFrame):
|
|
21
|
+
"""
|
|
22
|
+
Initialize a DataFrame view
|
|
23
|
+
|
|
24
|
+
Args:
|
|
25
|
+
df: The pandas DataFrame to display
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
ValueError: If df is not a pandas DataFrame
|
|
29
|
+
"""
|
|
30
|
+
if not isinstance(df, pd.DataFrame):
|
|
31
|
+
raise ValueError("df must be a pandas DataFrame")
|
|
32
|
+
|
|
33
|
+
self.df = df
|
|
34
|
+
|
|
35
|
+
def _write_to_zarr_group(self, group: zarr.Group) -> None:
|
|
36
|
+
"""
|
|
37
|
+
Write the DataFrame data to a Zarr group
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
group: Zarr group to write data into
|
|
41
|
+
"""
|
|
42
|
+
# Set the view type
|
|
43
|
+
group.attrs["view_type"] = "DataFrame"
|
|
44
|
+
|
|
45
|
+
try:
|
|
46
|
+
# Convert DataFrame to CSV string
|
|
47
|
+
csv_string = self.df.to_csv(index=False)
|
|
48
|
+
|
|
49
|
+
# Convert CSV string to bytes and store in numpy array
|
|
50
|
+
csv_bytes = csv_string.encode("utf-8")
|
|
51
|
+
csv_array = np.frombuffer(csv_bytes, dtype=np.uint8)
|
|
52
|
+
|
|
53
|
+
# Store the CSV data as compressed array
|
|
54
|
+
group.create_dataset(
|
|
55
|
+
"csv_data",
|
|
56
|
+
data=csv_array,
|
|
57
|
+
dtype=np.uint8,
|
|
58
|
+
chunks=True,
|
|
59
|
+
compressor=zarr.Blosc(
|
|
60
|
+
cname="zstd", clevel=3, shuffle=zarr.Blosc.SHUFFLE
|
|
61
|
+
),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
# Store metadata about the DataFrame
|
|
65
|
+
group.attrs["data_size"] = len(csv_bytes)
|
|
66
|
+
group.attrs["row_count"] = len(self.df)
|
|
67
|
+
group.attrs["column_count"] = len(self.df.columns)
|
|
68
|
+
|
|
69
|
+
# Store column information
|
|
70
|
+
column_info = []
|
|
71
|
+
for col in self.df.columns:
|
|
72
|
+
dtype_str = str(self.df[col].dtype)
|
|
73
|
+
# Simplify dtype names for frontend
|
|
74
|
+
if dtype_str.startswith("int"):
|
|
75
|
+
simple_dtype = "integer"
|
|
76
|
+
elif dtype_str.startswith("float"):
|
|
77
|
+
simple_dtype = "float"
|
|
78
|
+
elif dtype_str.startswith("bool"):
|
|
79
|
+
simple_dtype = "boolean"
|
|
80
|
+
elif dtype_str.startswith("datetime"):
|
|
81
|
+
simple_dtype = "datetime"
|
|
82
|
+
elif dtype_str == "object":
|
|
83
|
+
# Check if it's actually strings
|
|
84
|
+
if self.df[col].dtype == "object":
|
|
85
|
+
simple_dtype = "string"
|
|
86
|
+
else:
|
|
87
|
+
simple_dtype = "object"
|
|
88
|
+
else:
|
|
89
|
+
simple_dtype = "string"
|
|
90
|
+
|
|
91
|
+
column_info.append(
|
|
92
|
+
{"name": str(col), "dtype": dtype_str, "simple_dtype": simple_dtype}
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
# Store column info as JSON string
|
|
96
|
+
column_info_json = json.dumps(column_info)
|
|
97
|
+
group.attrs["column_info"] = column_info_json
|
|
98
|
+
|
|
99
|
+
except Exception as e:
|
|
100
|
+
# If DataFrame processing fails, store error information
|
|
101
|
+
group.attrs["error"] = f"Failed to process DataFrame: {str(e)}"
|
|
102
|
+
group.attrs["row_count"] = 0
|
|
103
|
+
group.attrs["column_count"] = 0
|
|
104
|
+
group.attrs["data_size"] = 0
|
|
105
|
+
group.attrs["column_info"] = "[]"
|
|
106
|
+
# Create empty array as placeholder
|
|
107
|
+
group.create_dataset(
|
|
108
|
+
"csv_data", data=np.array([], dtype=np.uint8), dtype=np.uint8
|
|
109
|
+
)
|
figpack/views/__init__.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: figpack
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: A Python package for creating shareable, interactive visualizations in the browser
|
|
5
5
|
Author-email: Jeremy Magland <jmagland@flatironinstitute.org>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -36,6 +36,7 @@ Requires-Dist: spikeinterface; extra == "test"
|
|
|
36
36
|
Requires-Dist: matplotlib; extra == "test"
|
|
37
37
|
Requires-Dist: plotly; extra == "test"
|
|
38
38
|
Requires-Dist: Pillow; extra == "test"
|
|
39
|
+
Requires-Dist: pandas; extra == "test"
|
|
39
40
|
Provides-Extra: dev
|
|
40
41
|
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
41
42
|
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
figpack/__init__.py,sha256=
|
|
1
|
+
figpack/__init__.py,sha256=nCb6Q0Xx4-eGvV5pZeidWcrG1X2wYX3V2bhNXOXAvTo,181
|
|
2
2
|
figpack/cli.py,sha256=xWF7J2BxUqOLvPu-Kje7Q6oGukTroXsLq8WN8vJgyw0,8321
|
|
3
3
|
figpack/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
figpack/core/_bundle_utils.py,sha256=JBZh2LJyu0oYHQBBVw5fF3uUNQJY_2bxVf6V7CN10FM,1884
|
|
@@ -9,9 +9,9 @@ figpack/core/_upload_bundle.py,sha256=54hdWayJJdRZdx7N9V2aH_X33KkR6hImMjN6tkBTLi
|
|
|
9
9
|
figpack/core/_view_figure.py,sha256=o1x1I2VKFrp2W_TStUS3fQblRW8AvGbu7Uy7MgVjofA,4186
|
|
10
10
|
figpack/core/config.py,sha256=oOR7SlP192vuFhYlS-h14HnG-kd_3gaz0vshXch2RNc,173
|
|
11
11
|
figpack/core/figpack_view.py,sha256=peJFkoP6HIqyNATzyucxAIq9HuCnK7SRO_-gE_rbEvg,6130
|
|
12
|
-
figpack/figpack-figure-dist/index.html,sha256=
|
|
12
|
+
figpack/figpack-figure-dist/index.html,sha256=oIpc8fQvHp6xW9SGsqyqJg7kYImJlKrWDDGkoMPFfEk,486
|
|
13
|
+
figpack/figpack-figure-dist/assets/index-CTBd5_Gw.js,sha256=5cp20fBzUQGAXUpWZPBrNQsHe5VnE0oCeXnL_d5sdNM,1602680
|
|
13
14
|
figpack/figpack-figure-dist/assets/index-Cmae55E4.css,sha256=Yg0apcYehJwQvSQIUH13S7tsfqWQDevpJsAho0dDf0g,5499
|
|
14
|
-
figpack/figpack-figure-dist/assets/index-HXdk2TtM.js,sha256=GhqJkoATKYiprLAbc3V5CYUt-MtKteWLx7KUh1fjA_0,1598198
|
|
15
15
|
figpack/figpack-figure-dist/assets/neurosift-logo-CLsuwLMO.png,sha256=g5m-TwrGh5f6-9rXtWV-znH4B0nHgc__0GWclRDLUHs,9307
|
|
16
16
|
figpack/franklab/__init__.py,sha256=HkehqGImJE_sE2vbPDo-HbgtEYaMICb9-230xTYvRTU,56
|
|
17
17
|
figpack/franklab/views/TrackAnimation.py,sha256=3Jv1Ri4FIwTyqNahinqhHsBH1Bv_iZrEGx12w6diJ2M,5636
|
|
@@ -32,6 +32,7 @@ figpack/spike_sorting/views/UnitsTableColumn.py,sha256=zBnuoeILTuiVLDvtcOxqa37E5
|
|
|
32
32
|
figpack/spike_sorting/views/UnitsTableRow.py,sha256=rEb2hMTA_pl2fTW1nOvnGir0ysfNx4uww3aekZzfWjk,720
|
|
33
33
|
figpack/spike_sorting/views/__init__.py,sha256=iRq7xPmyhnQ3GffnPC0GxKGEWnlqXY_8IOxsMqYZ1IM,967
|
|
34
34
|
figpack/views/Box.py,sha256=TfhPFNtVEq71LCucmWk3XX2WxQLdaeRiWGm5BM0k2l4,2236
|
|
35
|
+
figpack/views/DataFrame.py,sha256=VFP-EM_Wnc1G3uimVVMJe08KKWCAZe7DvmYf5e07uTk,3653
|
|
35
36
|
figpack/views/Gallery.py,sha256=sHlZbaqxcktasmNsJnuxe8WmgUQ6iurG50JiChKSMbQ,3314
|
|
36
37
|
figpack/views/GalleryItem.py,sha256=b_upJno5P3ANSulbG-h3t6Xj56tPGJ7iVxqyiZu3zaQ,1244
|
|
37
38
|
figpack/views/Image.py,sha256=hmyAHlRwj0l6fC7aNmHYJFaj-qCqyH67soERm78V5dk,3953
|
|
@@ -44,10 +45,10 @@ figpack/views/Splitter.py,sha256=x9jLCTlIvDy5p9ymVd0X48KDccyD6bJANhXyFgKEmtE,200
|
|
|
44
45
|
figpack/views/TabLayout.py,sha256=5g3nmL95PfqgI0naqZXHMwLVo2ebDlGX01Hy9044bUw,1898
|
|
45
46
|
figpack/views/TabLayoutItem.py,sha256=xmHA0JsW_6naJze4_mQuP_Fy0Nm17p2N7w_AsmVRp8k,880
|
|
46
47
|
figpack/views/TimeseriesGraph.py,sha256=OAaCjO8fo86u_gO_frNfRGxng3tczxGDGKcJEvZo3rE,7469
|
|
47
|
-
figpack/views/__init__.py,sha256=
|
|
48
|
-
figpack-0.2.
|
|
49
|
-
figpack-0.2.
|
|
50
|
-
figpack-0.2.
|
|
51
|
-
figpack-0.2.
|
|
52
|
-
figpack-0.2.
|
|
53
|
-
figpack-0.2.
|
|
48
|
+
figpack/views/__init__.py,sha256=eKN4OMHnFSfrHRZcSskxhe-5s3t3Qpl533P-spTyf24,506
|
|
49
|
+
figpack-0.2.7.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
50
|
+
figpack-0.2.7.dist-info/METADATA,sha256=EKxpIv7ysQYV7yag9mwrhfCvPGBRroAbkUo9Cn_btNA,3616
|
|
51
|
+
figpack-0.2.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
52
|
+
figpack-0.2.7.dist-info/entry_points.txt,sha256=l6d3siH2LxXa8qJGbjAqpIZtI5AkMSyDeoRDCzdrUto,45
|
|
53
|
+
figpack-0.2.7.dist-info/top_level.txt,sha256=lMKGaC5xWmAYBx9Ac1iMokm42KFnJFjmkP2ldyvOo-c,8
|
|
54
|
+
figpack-0.2.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|