Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve serialization of Pandas DataFrames to ipyvega #346

Merged
merged 164 commits into from
Feb 12, 2023
Merged
Changes from 1 commit
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
01aab0d
data transfer via ipydatawidgets
xtianpoli Jun 7, 2021
162a38e
fix
xtianpoli Jun 8, 2021
d1989f7
Fix heatmap for speed
jdfekete Jun 11, 2021
8813074
Fix heatmap for speed
jdfekete Jun 11, 2021
28ba8e9
init ipydatatablewidget
xtianpoli Jun 11, 2021
44efd02
using NDArray instead of DataUnion
xtianpoli Jun 13, 2021
81e90a4
adding a customized table traitlet
xtianpoli Jun 17, 2021
94c7077
src/widget.ts
xtianpoli Jun 17, 2021
de25ee6
fix
xtianpoli Jun 17, 2021
69c689f
cleanup
xtianpoli Jun 17, 2021
88e5138
adding lz4js decompression
xtianpoli Jun 18, 2021
c2f33c9
fix
xtianpoli Jun 18, 2021
5d58cba
make NumpyAdapter.equals returns always False
xtianpoli Jun 18, 2021
21e9bea
Remove most console.log and add %time and progress bars in notebooks
jdfekete Jun 18, 2021
803a0cb
fixing .gitignore
xtianpoli Jun 18, 2021
3badb98
Add stress tests
jdfekete Jun 18, 2021
b198c04
rename update_histogram2d to update_array2d. Remove console.log pollu…
jdfekete Jun 19, 2021
62eaa47
Improve
jdfekete Jun 21, 2021
aa0b328
Add a definition file to configure Altair. More work needed
jdfekete Jun 21, 2021
c856d7a
compression as string
xtianpoli Jun 28, 2021
258e0aa
fix (naive approach)
xtianpoli Jun 29, 2021
0d6c5d3
adding an adapter for Progressivis tables
xtianpoli Jun 29, 2021
5498083
Merge branch 'vega:master' into master
xtianpoli Jun 29, 2021
a814023
cleanup
jdfekete Jun 29, 2021
283fe75
adding a touch mode
xtianpoli Jul 1, 2021
1941c41
using ipytablewidgets
xtianpoli Jul 12, 2021
ca21ed7
calling update_dataframe() and update_array2d() from update()
xtianpoli Aug 24, 2021
6601ff1
fixes for jupyterlab3 compliance
xtianpoli Aug 25, 2021
3b128ce
adding UI tests
xtianpoli Aug 27, 2021
0b400c6
adding reference outputs for UI tests
xtianpoli Aug 27, 2021
162784f
add ui action
xtianpoli Aug 27, 2021
ad5acc9
fix syntax
xtianpoli Aug 27, 2021
94828b6
another fix
xtianpoli Aug 27, 2021
d672ca7
fix poetry conf
xtianpoli Aug 27, 2021
1e2842b
testing only with python 3.9
xtianpoli Aug 27, 2021
64246db
testing with yarn --no-lockfile
xtianpoli Aug 27, 2021
19ea342
testing only on lab branch for now
xtianpoli Aug 27, 2021
af41998
trusting test notebook
xtianpoli Aug 27, 2021
7499f3f
debug: testing ipytablewidgets presence
xtianpoli Aug 27, 2021
40fd5a6
get a cell as an artifact
xtianpoli Aug 27, 2021
eac30ba
fix syntax
xtianpoli Aug 27, 2021
724129c
if: always()
xtianpoli Aug 27, 2021
b69674b
arfifact test-output instead of ref...
xtianpoli Aug 27, 2021
9fd014a
uploading all .png as an artifact
xtianpoli Aug 27, 2021
c4a8b67
new refs
xtianpoli Aug 27, 2021
cc33cd0
upload artifacts only if: cancelled() to avoid warnings
xtianpoli Aug 27, 2021
fff5fe6
improvement
xtianpoli Aug 30, 2021
defb652
Widget.ipynb modified for use datasets property
xtianpoli Aug 31, 2021
9bb7a22
adding a random.seed()
xtianpoli Aug 31, 2021
9c6ad58
fixes
xtianpoli Sep 1, 2021
e82f971
more ui tests
xtianpoli Sep 1, 2021
534113c
fix: producing artifacts if failure
xtianpoli Sep 1, 2021
4f8250b
fix
xtianpoli Sep 1, 2021
de46fe8
adding new ref
xtianpoli Sep 1, 2021
87a0441
simplifying last tests
xtianpoli Sep 1, 2021
bf4d1ba
resize histogram2d to 32x32
xtianpoli Sep 1, 2021
989d034
adding new refernces
xtianpoli Sep 1, 2021
ddfc9d7
many updates ported from the bench branch
xtianpoli Oct 1, 2021
0fbf69e
add jupyterlab
jdfekete Oct 5, 2021
2d64f00
Introduce vega.altair with the `stream` method to stream altair specs
jdfekete Oct 11, 2021
be82d76
fix bugs and add interactive test
jdfekete Oct 13, 2021
c1dd5a4
Call resize after update in streaming mode, otherwise, the widget is …
jdfekete Oct 15, 2021
89a0a44
Add the resize option to stream and update
jdfekete Oct 16, 2021
e4ff083
fixing resize for pending updates
xtianpoli Oct 18, 2021
9ec8cae
Fix tests
jdfekete Nov 7, 2021
86d885d
Simplify streaming test
jdfekete Nov 8, 2021
58bd0d0
Ready for distribution
jdfekete Nov 8, 2021
34ba868
fix test.yml
xtianpoli Nov 21, 2021
8d0fefe
prettier
jdfekete Nov 21, 2021
05f7bd9
merged with origin
jdfekete Nov 21, 2021
c5815bc
Cleanup
jdfekete Nov 21, 2021
d45d9ce
Fixed spec
jdfekete Nov 21, 2021
4eaba72
Merge branch 'master' into master
jdfekete Dec 7, 2021
320841a
bump to new library versions for yarn and vega
jdfekete Dec 7, 2021
e295597
fix unused packages
jdfekete Dec 7, 2021
5eff2f0
fixing ui tests
xtianpoli Jan 20, 2022
a24a73d
other fixes rlated to the 346 issue
xtianpoli Jan 21, 2022
ee68fe7
cleanup+fix
xtianpoli Jan 21, 2022
52672be
new fixes
xtianpoli Jan 21, 2022
026116d
set nodejs=17
xtianpoli Jan 21, 2022
9aed873
set nodejs=16
xtianpoli Jan 21, 2022
e7a2812
make variables that can be const const
xtianpoli Jan 22, 2022
5e80acf
cleanup
xtianpoli Jan 22, 2022
248bf6d
Add comment for chaining multiple datasets in widget.py. Cleanup decl…
jdfekete Jan 22, 2022
c196c6e
use the latest version of Altair. Print better information in altair.…
jdfekete Jan 23, 2022
127df68
Try lower version of Altair
jdfekete Jan 23, 2022
1dd29cd
trying altair4.1.0+jsonschema3.2.0
xtianpoli Jan 23, 2022
a9615e9
fixing the previous essay
xtianpoli Jan 23, 2022
a65419f
altair back to dev-dependencies
xtianpoli Jan 23, 2022
af4f9c7
alt.renderers.enable('default') instead of 'notebook'
xtianpoli Jan 23, 2022
755ae8a
Add a first cell in AltairStreaming.ipynb to explain to install Altai…
jdfekete Jan 23, 2022
3da3644
UI end-to-end tests without conda
xtianpoli Jan 27, 2022
cd98d68
trying sleep 3
xtianpoli Jan 27, 2022
d021a09
trying py 3.8
xtianpoli Jan 27, 2022
7cfb6b4
py 3.7 ?
xtianpoli Jan 27, 2022
736e035
py 3.6 ?
xtianpoli Jan 27, 2022
9923598
avoid any[]|string
xtianpoli Jan 27, 2022
1d3f5fd
removing touch_mode and touch params
xtianpoli Jan 28, 2022
c3dc68f
removing binder conf
xtianpoli Jan 28, 2022
ca714b3
using a logger instead of print()
xtianpoli Jan 28, 2022
5dee6ff
insert?: any[] | @dataframe | ...
xtianpoli Jan 28, 2022
71e4b0b
clean-up code, add comments, check the need for resize in vega.wiget,…
jdfekete Jan 28, 2022
0c571f5
Altair should be either a dev dependency or a strong dependency, not …
jdfekete Jan 28, 2022
8443355
Add comments to the AltairStreaming.ipynb notebook [skip CI]
jdfekete Jan 29, 2022
8c9dcce
update dependencies
jdfekete Jan 31, 2022
acbba0c
update webpack
jdfekete Jan 31, 2022
f655f5d
Merge branch 'master' into master
jdfekete Jan 31, 2022
4c452b1
altair back to dev dependencies. Update webpack package version.
jdfekete Feb 2, 2022
2a5a051
Update webpack-cli package version.
jdfekete Feb 2, 2022
be9948e
Merge branch 'master' into master
jdfekete Feb 2, 2022
ec18ab7
fix yarn lockfile issue
jdfekete Feb 2, 2022
e4adc30
Apply requested changes, except for moving the dependencies of jupyte…
jdfekete Feb 3, 2022
708d01a
Bump to the newer version of Poetry
jdfekete Feb 9, 2022
b6bccbb
Update src/index.ts
jdfekete Feb 9, 2022
db964af
Rename AllSupportedTypes.ipynb to AllCompressions.ipynb and fix the R…
jdfekete Feb 9, 2022
7f3b1de
Use stable URL for example data
jdfekete Feb 9, 2022
2222e99
adding extension.js labplugin.js
xtianpoli Feb 10, 2022
014494e
removing TimeXXX.ipynb
xtianpoli Feb 10, 2022
09baecb
"adding jupyter nbextension enable" subcommand, removing comment "not…
xtianpoli Feb 10, 2022
991d9c0
Start merging with ipyvega base but the VegaWidget has issues with er…
jdfekete Feb 11, 2022
4ebd98f
Remove unused ISerializers from import in wiget.ts [skip CI]
jdfekete Feb 11, 2022
8868c6a
fixing bug in vega.js, removing src/extension.js (replaced by extensi…
xtianpoli Mar 11, 2022
b12606e
waiting 10s after start-jlab before running UI tests
xtianpoli Mar 11, 2022
3f43bfd
keeping only py3.9
xtianpoli Mar 11, 2022
8c55e03
prettifying .ts files + back to py3.6..3.9
xtianpoli Mar 11, 2022
3b63e9d
a better fix for src/vega.js
xtianpoli Mar 14, 2022
8a54ffc
Merge with upstream
jdfekete Mar 16, 2022
f2ffe37
Merge branch 'vega-master2'
jdfekete Mar 16, 2022
774c696
fix jupyterlab
jdfekete Mar 16, 2022
5fff98b
fix poetry.lock
jdfekete Mar 16, 2022
f57a22d
fix test
jdfekete Mar 16, 2022
9fb8c8e
new fix for test
jdfekete Mar 16, 2022
1b8a2ad
trying pip install for extra jupyterlab
xtianpoli Mar 16, 2022
3004e50
fix syntax error
xtianpoli Mar 16, 2022
3384981
trying poetry without virtualisation
xtianpoli Mar 16, 2022
bf009ae
ipytablewidgets=0.2.4, jupyterlab extra removed
xtianpoli Mar 17, 2022
eb0c920
fixes
xtianpoli Mar 17, 2022
7c75a82
adding forgotten .js
xtianpoli Mar 17, 2022
350d50d
fixes
xtianpoli Mar 17, 2022
4ed20f3
essay
xtianpoli Mar 17, 2022
420449c
many fixes
xtianpoli Mar 21, 2022
4c589bb
Merge branch 'master' into master
jdfekete Jun 23, 2022
b0f3144
adding jupyter-tablewidgets
xtianpoli Jun 23, 2022
14dc3f9
fix
xtianpoli Jun 23, 2022
033e78b
error injection for test
xtianpoli Jun 23, 2022
9b7ca01
fixing UI Tests
xtianpoli Jun 23, 2022
bec53bc
back to the previous fix
xtianpoli Jun 23, 2022
c6f6b43
save widgets rendering as images
xtianpoli Jan 10, 2023
e1b7a58
using poetry 1.3.1
xtianpoli Jan 10, 2023
82b6899
minor improvement
xtianpoli Jan 10, 2023
71fc3ef
serialize static widgets as json
xtianpoli Jan 11, 2023
d5d116b
Regenerate poetry lock file and fix warning in tests
jdfekete Jan 19, 2023
bfc96f6
Update packages and try saving a streamed example
jdfekete Jan 19, 2023
dacf4fb
setting rendered images dims
xtianpoli Jan 19, 2023
6e5fc40
back to @jupyter-widgets/base=4.1.0 because of jupyterlab
xtianpoli Jan 19, 2023
9a067f3
fix
xtianpoli Jan 19, 2023
b0493bb
new fixes+upgraded dependencies
xtianpoli Jan 20, 2023
e70423f
upgrade dev dependency filemanager-webpack-plugin => 7.0.0
xtianpoli Jan 21, 2023
c930fc8
merge upstream
xtianpoli Jan 30, 2023
baca3f0
rm .gitmodules+update poetry.loc
xtianpoli Jan 30, 2023
ba96399
using barley.json instead of barley.csv in all cells
xtianpoli Jan 30, 2023
3adb15a
improvements
xtianpoli Jan 30, 2023
10714a0
Improve documentation to function `stream`
jdfekete Jan 31, 2023
d618580
Fix docstring
jdfekete Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rename update_histogram2d to update_array2d. Remove console.log pollu…
…ting the console. Add python doc.
  • Loading branch information
jdfekete committed Jun 19, 2021
commit b198c0483924dc6b839c8f1601c4d9e02b3ddedd
14 changes: 7 additions & 7 deletions notebooks/VegaHeatmap.ipynb
Original file line number Diff line number Diff line change
@@ -10,14 +10,14 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 1,
"id": "downtown-toronto",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "09e4a8bb037e41b197b25c79d789b3a4",
"model_id": "8e0451479a6a4c33baec24a707fe54a5",
"version_major": 2,
"version_minor": 0
},
@@ -84,14 +84,14 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 2,
"id": "393a3fc4",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "8d3bf786893b4f729f03a4aecd94a0b7",
"model_id": "6c615d73375c442ba0cdb812c801e9bd",
"version_major": 2,
"version_minor": 0
},
@@ -142,7 +142,7 @@
"cov = [[0.01, 0], [0, 0.09]]\n",
"rdata = np.random.multivariate_normal(means, cov, size=(nsamples))\n",
"async def progressive_loop(widget, nbins=nbins):\n",
" hist = np.zeros((nbins,nbins), dtype='float32')\n",
" hist = np.zeros((nbins,nbins), dtype='uint32')\n",
" step = 0\n",
" times = []\n",
" last = 0\n",
@@ -151,14 +151,14 @@
" step += 1\n",
" await aio.sleep(0)\n",
" h, *_ = np.histogram2d(sl[:,0],sl[:,1], bins=nbins, range=((-1.0,1.0),(-1.0,1.0)))\n",
" hist += h\n",
" hist += h.astype('uint32')\n",
" #print(hist.shape)\n",
" widget._displayed = True\n",
" # max = np.max(hist)\n",
" # value = hist/max\n",
" value = hist\n",
" widget._displayed = True\n",
" widget.update_histogram2d(value, ['x', 'y', 'z'], remove=\"true\")\n",
" widget.update_array2d(value, ['x', 'y', 'z'], remove=\"true\")\n",
" now = time.time()\n",
" if last:\n",
" times.append(now - last)\n",
4 changes: 2 additions & 2 deletions src/serializers.ts
Original file line number Diff line number Diff line change
@@ -55,7 +55,7 @@ function JSONToTable(obj: IReceivedSerializedTable | null, manager?: ManagerBase
}
// obj is {shape: list, dtype: string, array: DataView}
// return an ndarray object
console.log("OBJ", obj);
// console.log("OBJ", obj);
var data: IDict<NdArray | string[]> = {};
var size: number = Infinity;
let buffer: ArrayBuffer;
@@ -88,7 +88,7 @@ function JSONToTable(obj: IReceivedSerializedTable | null, manager?: ManagerBase
}
}
var result = {columns: obj.columns, data: data, size: size} as ISendSerializedTable;
console.log("result", result);
// console.log("result", result);
//let objFoo = obj.data.foo;
return result;
}
2 changes: 1 addition & 1 deletion vega/static/widget.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion vega/static/widget.js.map

Large diffs are not rendered by default.

38 changes: 33 additions & 5 deletions vega/widget.py
Original file line number Diff line number Diff line change
@@ -137,7 +137,7 @@ def update(self, key, remove=None, insert=None):
property ``t < 5``.

:param Optional[List[dict]] insert:
jdfekete marked this conversation as resolved.
Show resolved Hide resolved
new items to add to the chat data.
new items to add to the chart data.
"""
update = dict(key=key)

@@ -154,7 +154,19 @@ def update(self, key, remove=None, insert=None):
self._pending_updates.append(update)

def update_dataframe(self, df, remove=None):
"""
"""Update the chart data with a DataFrame.

Updates are only reflected on the client, i.e., after re-displaying
the widget will show the chart specified in its spec property.

:param pd.DataFrame insert:
new items to add to the chart data.

:param Optional[str] remove:
a JavaScript expression of items to remove. The item to test can
be accessed as ``datum``. For example, the call
``update(remove="datum.t < 5")`` removes all items with the
property ``t < 5``.
"""
if isinstance(df, pd.DataFrame):
self._df = PandasAdapter(df)
@@ -167,9 +179,25 @@ def update_dataframe(self, df, remove=None):
update['insert'] = "@dataframe"
self.send(dict(type="update", updates=[update]))

def update_histogram2d(self, arr, columns, remove=None):
"""
NB: the array is wrapped in an one column Table.
def update_array2d(self, arr, columns, remove=None):
"""Update the chart data with a 2d array and their column names.

Updates are only reflected on the client, i.e., after re-displaying
the widget will show the chart specified in its spec property.

:param np.ndarray arr:
new items to add to the chart data as a 2d numpy array.

:param List[str] columns:
list of column names for each column of the array.

:param Optional[str] remove:
a JavaScript expression of items to remove. The item to test can
be accessed as ``datum``. For example, the call
``update(remove="datum.t < 5")`` removes all items with the
property ``t < 5``.

NB: the array will be wrapped as a one column Table.
The unique column (fancy_col below) is built as a comma separated
coords string (i.e. columns param.)
This naming covention is important because javascript will split
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This naming covention is important because javascript will split
This naming covention is important because JavaScript will split