-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Use plotly.js base64
API to store and pass typed arrays declared by numpy, pandas, etc.
#4470
Merged
Merged
Changes from all commits
Commits
Show all changes
128 commits
Select commit
Hold shift + click to select a range
1f3e605
revisit validator
archmoj a627c9e
pass numpy conversions as typed array spec
archmoj c363f3e
adjust validators
archmoj 61aa4ea
add b64 file for tests
archmoj 730c0dd
adjust test_dataarray_validator.py
archmoj 7c31dc1
adjust test_pandas_series_input.py
archmoj d4c3162
adjust test_xarray_input.py
archmoj d1b4706
adjust test_figure_factory.py
archmoj 2b33199
adjust test_imshow.py
archmoj f2c8d66
adjust test_px.py
archmoj b4d23b5
adjust test_px_functions.py
archmoj 03aa9e0
adjust test_px_input.py
archmoj 4514e92
adjust test_px_wide.py
archmoj 048455e
adjust test_trendline.py
archmoj 520e9bf
adjust test_figure_factory.py
archmoj c48f3ce
adjust test_utils.py
archmoj dcb6b91
skip test_fast_track_finite_arrays
archmoj 9b1cbfd
skip test_violin_fig on CI
archmoj bd7e9dc
skip few mocks in compare pandas v1 vs v2
archmoj 124f12d
remove clean_float which is not necessary
archmoj 82c8199
add examples using base64
archmoj f200767
Update packages/python/plotly/_plotly_utils/basevalidators.py
archmoj 5fb9ee3
Merge remote-tracking branch 'origin/master' into pass-b64_dev
archmoj b31dc27
Merge branch 'master' into pass-b64
archmoj 0323215
Merge branch 'master' into pass-b64
archmoj 99ebbbc
Merge branch 'master' into pass-b64
archmoj 7c7ef30
Merge branch 'master' into pass-b64
archmoj f5df6db
also check for dtype in is_typed_array_spec function
archmoj f332922
remove print
archmoj 5947221
Add performance test for b64
marthacryan 62d9aa7
Add tests for size
marthacryan e5c24fe
Add test for array_ok and b64 together in IntegerValidator:
marthacryan 8430c52
Black
marthacryan baeedc9
Change the time difference to be larger between b64 and raw array
marthacryan 4f63296
Add random seed
marthacryan a566543
Change numpy array to python list before comparison
marthacryan 3d63fa2
Remove unnecessary casting to np array
marthacryan 7fbb701
specify width and height and fix logic of time comparison
marthacryan 6e53e51
Add hard-coded margins
marthacryan dd1aba8
Add uint8 and float32 tests
marthacryan b6f9d14
Update performance margin to be a little smaller
marthacryan 555d960
Black
marthacryan b301d99
Fix size performance tests and add graph object tests
marthacryan 4323c28
Remove print statements
marthacryan c1e6728
Add numpy as a requirement for core tests
marthacryan 7822635
Black
marthacryan 58d4844
update requirements for python 3.12
marthacryan 43de1cb
Update packages/python/plotly/plotly/tests/test_core/test_graph_objs/…
marthacryan 1105328
Update names
marthacryan 65f0dad
Update variables used in tests
marthacryan da100bc
Lower threshold for passing
marthacryan 554f5cb
Use different version of setuptools
marthacryan 024f3c1
Black
marthacryan 8a051a3
Update tests to remove conversion to base64 before passing numpy arrays
marthacryan ece3e3d
remove setuptools from requirements
marthacryan 0675f5b
Add setup tools install before requirements
marthacryan 2fc29f8
Remove pin on numpy version
marthacryan d8924c5
Try removing the setuptools from config
marthacryan e1f91cd
Update performance thresholds
marthacryan 98f2541
Parametrize functions and lower performance thresholds
marthacryan 3702686
Code format
marthacryan 4932cdb
Remove px tests (duplicates)
marthacryan ddbc3f1
Remove px tests (duplicates)
marthacryan 0b83ebd
Add back in max_value and parameterize the count
marthacryan dabbcb8
Remove numpy requirement after moving performance tests back to optional
marthacryan 6c01e6a
Use scattergl instead of scatter
marthacryan a056d7e
Add verbose flag to debug ci
marthacryan 6d82e48
Only run performance tests for debugging
marthacryan 8823a8c
Try commenting out all but one test
marthacryan 25f6ccf
Print pio.renderers to debug
marthacryan b931fd5
Debug
marthacryan addfd47
Try rendering as png
marthacryan ef51cce
Add back in other tests and update renderer default
marthacryan 3142c62
Black
marthacryan 72e9ad0
Update failing performance threshold
marthacryan 2d4ad05
Update failing performance threshold
marthacryan 9d3b50d
Update thresholds
marthacryan 63335d2
Update thresholds
marthacryan 644992f
Merge pull request #4695 from marthacryan/add-tests-b64
marthacryan 0f68aff
Add validator test to basetraces validator
marthacryan 2a81d2a
Add more validator tests
marthacryan 1c0b48e
black
marthacryan e500e38
Add more base64 array_ok tests
marthacryan c2453d3
Add other int types to integer validator tests
marthacryan c8d35b4
Add more integer types to the validation
marthacryan 8861451
black
marthacryan 8afa4d8
remove unused imports
marthacryan 69729db
Remove unnecessary usage of numpy dtypes to prevent throwing error
marthacryan c52e9f4
Merge pull request #4707 from plotly/validator_tests
marthacryan c6390f4
Add test for geojson not converting to b64
marthacryan a3940ee
Simplify tests
marthacryan 259d509
Add tests for layers and range keys
marthacryan d201b58
Code format
marthacryan f018291
Update packages/python/plotly/plotly/tests/test_optional/test_graph_o…
marthacryan 8d7edf6
Merge branch 'master' of github.com:plotly/plotly.py into pass-b64
marthacryan d59ceb0
Merge branch 'pass-b64' of github.com:plotly/plotly.py into add-skipp…
marthacryan 40166bb
Potential fix to conversion bug
marthacryan 17b531c
Refactor logic to be clearer
marthacryan 2fa09e5
remove todo
marthacryan 4452868
Black
marthacryan 02fb3a4
Merge pull request #4727 from plotly/add-skipped-key-tests
marthacryan a8995b7
Merge branch 'master' of github.com:plotly/plotly.py into pass-b64
marthacryan 12ff7f3
remove failing orca tests to prevent confusion while waiting on updat…
marthacryan ca4340b
Remove another part of config that we're removing to prevent CI failure
marthacryan dd9379a
Add base64 to the changelog
marthacryan 9362db3
Remove examples that over-complicate the usage of base64 spec
marthacryan 6364d4e
Remove base64 documentation
marthacryan 61e9178
Convert base64 in validate_coerce_fig_to_dict instead of validate_coerce
marthacryan 066564e
Update logic to be recursive
marthacryan fb036c7
Move conversion to to_dict function
marthacryan 4b289e9
Fix import path
marthacryan aabfa6e
Consolidate import statemenets
marthacryan de2bcb5
Merge pull request #4784 from plotly/b64-before-render
archmoj 0d0dad2
Revert changes to validator tests
marthacryan 9c5d112
Revert changes to tests that check data field
marthacryan 5e50d8c
Merge with master
marthacryan 8fff9c5
Remove performance tests
marthacryan bd0a2d3
Update base64 tests to reflect new approach
marthacryan b3ed838
Fix failing tests
marthacryan 7bd7993
Merge with master
marthacryan cd8e0be
Revert changes to to_json_plotly tests
marthacryan f60b122
revert changes to percy compare pandas
marthacryan 9d6b0c7
Remove unused util
marthacryan 960adb9
Revert changes to validators
marthacryan 12ab42a
Revert changes to circleci config
marthacryan 59fe206
Address review
marthacryan 60c73a8
fix doctsring
marthacryan f481af7
update skipped keys to include layers
marthacryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/python/plotly/plotly/tests/test_optional/test_graph_objs/test_skipped_b64_keys.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import json | ||
from unittest import TestCase | ||
import numpy as np | ||
from plotly.tests.test_optional.optional_utils import NumpyTestUtilsMixin | ||
import plotly.graph_objs as go | ||
|
||
|
||
class TestShouldNotUseBase64InUnsupportedKeys(NumpyTestUtilsMixin, TestCase): | ||
def test_np_geojson(self): | ||
normal_coordinates = [ | ||
[ | ||
[-87, 35], | ||
[-87, 30], | ||
[-85, 30], | ||
[-85, 35], | ||
] | ||
] | ||
|
||
numpy_coordinates = np.array(normal_coordinates) | ||
|
||
data = [ | ||
{ | ||
"type": "choropleth", | ||
"locations": ["AL"], | ||
"featureidkey": "properties.id", | ||
"z": np.array([10]), | ||
"geojson": { | ||
"type": "Feature", | ||
"properties": {"id": "AL"}, | ||
"geometry": {"type": "Polygon", "coordinates": numpy_coordinates}, | ||
}, | ||
} | ||
] | ||
|
||
fig = go.Figure(data=data) | ||
|
||
assert ( | ||
json.loads(fig.to_json())["data"][0]["geojson"]["geometry"]["coordinates"] | ||
== normal_coordinates | ||
) | ||
|
||
def test_np_layers(self): | ||
layout = { | ||
"mapbox": { | ||
"layers": [ | ||
{ | ||
"sourcetype": "geojson", | ||
"type": "line", | ||
"line": {"dash": np.array([2.5, 1])}, | ||
"source": { | ||
"type": "FeatureCollection", | ||
"features": [ | ||
{ | ||
"type": "Feature", | ||
"geometry": { | ||
"type": "LineString", | ||
"coordinates": np.array( | ||
[[0.25, 52], [0.75, 50]] | ||
), | ||
}, | ||
} | ||
], | ||
}, | ||
}, | ||
], | ||
"center": {"lon": 0.5, "lat": 51}, | ||
}, | ||
} | ||
data = [{"type": "scattermapbox"}] | ||
|
||
fig = go.Figure(data=data, layout=layout) | ||
|
||
assert (fig.layout["mapbox"]["layers"][0]["line"]["dash"] == (2.5, 1)).all() | ||
|
||
assert json.loads(fig.to_json())["layout"]["mapbox"]["layers"][0]["source"][ | ||
"features" | ||
][0]["geometry"]["coordinates"] == [[0.25, 52], [0.75, 50]] | ||
|
||
def test_np_range(self): | ||
layout = {"xaxis": {"range": np.array([0, 1])}} | ||
|
||
fig = go.Figure(data=[{"type": "scatter"}], layout=layout) | ||
|
||
assert json.loads(fig.to_json())["layout"]["xaxis"]["range"] == [0, 1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marthacryan
Could we revert this change now or we should drop the test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this because it was failing. Presumably it's just faster now?