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

minor test fixes for ipyplotly_integration #975

Merged
merged 145 commits into from
Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
145 commits
Select commit Hold shift + click to select a range
77b50f3
Update CHANGELOG.md
Kully Feb 18, 2018
fafcabf
(matplotlylib) Make convert_dash more robust to changes in matplotlib.
Feb 18, 2018
cbf037d
commit
Kully Feb 19, 2018
065e59c
remove unnecessary data files in tests and robust data-path searching
Kully Feb 19, 2018
9502440
pep-8: l -> L variable name
Kully Feb 19, 2018
f2ba912
bump version number up
Kully Feb 19, 2018
a15b744
Merge pull request #939 from plotly/rewrite-changelog-choro
Kully Feb 19, 2018
5818d2b
remove shapefiles from folders and delete folders
Kully Feb 20, 2018
6a7e7f2
removed data/ folder and modified choropleth code to match file names
Kully Feb 20, 2018
6319d63
Merge pull request #940 from plotly/fix-choropleth
Kully Feb 20, 2018
c7bff98
changelog for fixed 2.4.1
Kully Feb 21, 2018
3d8cd07
chelsea's comments
Kully Feb 21, 2018
cb71b64
Merge pull request #943 from plotly/changelog-for-fixed-choropleth
Kully Feb 21, 2018
1b09e21
added fill_percent to params for insert, swap and remove
Kully Feb 23, 2018
b149e0d
html preview not working
Kully Feb 26, 2018
9705dde
HTML preview now reflects the fill_percent param settings
Kully Feb 26, 2018
c26b763
tests are working
Kully Feb 26, 2018
38f88ef
make update_default_schema
Kully Feb 26, 2018
1991c7f
udpated changelog, removed TODOs, PEP-8 79 char line limit
Kully Feb 27, 2018
35716d6
Merge branch 'master' into dashboard-percent
Kully Feb 27, 2018
004bbb0
turn off hover for the lines
Kully Feb 28, 2018
c3682d3
0-padding
Kully Feb 28, 2018
8f557c7
changelog
Kully Feb 28, 2018
a85cb8b
update changelog and version number for 2.5.0
Kully Feb 28, 2018
8517f3f
change fill_percent example in doc to fill_percent=20
Kully Feb 28, 2018
3c0d337
sort all node generators to make HTML output consistent for py2 + py3
Kully Feb 28, 2018
8def60c
add choropleth files back
Kully Feb 28, 2018
524a8a0
Merge pull request #938 from nburrus/convert-dash
jackparmer Mar 1, 2018
b091aaf
dashboards now autosize based on GUI
Kully Mar 2, 2018
14a6a02
update dash workshop announcement
cldougl Mar 2, 2018
e994e55
Merge pull request #953 from plotly/announcement_update
cldougl Mar 5, 2018
85d7549
version num to 2.5.0
Kully Mar 5, 2018
f898892
4 equal height vertical stacked example in doc string
Kully Mar 5, 2018
2c07b12
rename box_1 to box_a, etc
Kully Mar 5, 2018
736c42d
remove shapefiles in tests dir
Kully Mar 5, 2018
7f08843
change version back for testing purposes
Kully Mar 5, 2018
97213c9
version to 2.5.0
Kully Mar 5, 2018
0482dce
try bumping npm v in circle.yml to 6.0.0
Kully Mar 6, 2018
edbd796
Don't crash if figure_factory is imported but pandas isn't installed.…
dpryan79 Mar 6, 2018
8e7c112
Merge pull request #958 from dpryan79/fix941
Kully Mar 6, 2018
c43c436
pr for #958 PR
Kully Mar 6, 2018
e406bef
add PR reference
Kully Mar 6, 2018
fbaaba2
remove a comment
Kully Mar 7, 2018
8c7eb17
Merge pull request #947 from plotly/offline_mode_choropleth
Kully Mar 7, 2018
8bde810
Merge branch 'master' into dashboard-percent
Kully Mar 7, 2018
d6d777b
Merge pull request #946 from plotly/dashboard-percent
Kully Mar 7, 2018
56de411
Merge branch 'master' into changelog-ff-crash
Kully Mar 8, 2018
98feab6
Merge pull request #959 from plotly/changelog-ff-crash
Kully Mar 8, 2018
cbc1779
update plotlyjs for offline
cldougl Mar 12, 2018
2f59570
Merge pull request #971 from plotly/bump_pjs_1352
cldougl Mar 12, 2018
70f82c4
moved py2.7 test env to last in core environments
Kully Mar 15, 2018
1d4f440
remove ipyplotly folder
Kully Mar 15, 2018
f39a85b
fixed assert Scatter() == dict(type='scatter')
Kully Mar 15, 2018
f3f6811
fixed test_access_top_level in test_figure
Kully Mar 15, 2018
07c0977
more in test_figures fixes
Kully Mar 15, 2018
36ed3aa
merged to ipyplotly integration
Kully Mar 16, 2018
425c36a
remove junk in test_figure.py from before base merge
Kully Mar 16, 2018
b2f5064
BaseFigure and BasePlotlyType inherit from PlotlyBase class
Kully Mar 16, 2018
de95849
remove commented validation function
Kully Mar 16, 2018
c611a23
comment out validate error in test_scatter
Kully Mar 19, 2018
e714499
add histogram2dcontour back to graph_reference TRACES
Kully Mar 19, 2018
9ce82b4
FigureWidget to OLD_CLASS_NAMES
Kully Mar 19, 2018
234b979
add update to Data def in graph_objs//remove to_string in test_update
Kully Mar 19, 2018
55969d9
fixed test_offline in optional
Kully Mar 20, 2018
6f822cd
test_plotl_mpl fixed
Kully Mar 20, 2018
bb90864
add py36 to core and optional test envs
Kully Mar 21, 2018
41a63ff
break up datetime tests into multiple ones for better test control
Kully Mar 21, 2018
871341c
fixed JSONEncoding errors
Kully Mar 22, 2018
7a9aa99
last assert test in test_utils
Kully Mar 22, 2018
d2ca807
print statements for testing xaxis1
Kully Mar 23, 2018
de5d242
construct paths to choropleth files intelligently
Kully Mar 26, 2018
183a6fa
update the changelog
Kully Mar 26, 2018
53d57ca
bump version
Kully Mar 26, 2018
2260054
changelog comments
Kully Mar 26, 2018
0bde4e1
Merge pull request #980 from plotly/windows-choropleth
Kully Mar 26, 2018
4a977cd
merge from Jon's PR
Kully Mar 27, 2018
c154dd6
merge from ipyplotly_integration
Kully Mar 27, 2018
f332e29
revert to current basedatatypes from #942
Kully Mar 28, 2018
4397815
write in helper function for assert_dict_equal
Kully Mar 28, 2018
6988d08
fix trisurf: hoverinfo needs 'none', not 'None'
Kully Mar 28, 2018
0ea9e14
finished a few more classes in figure_factory tests
Kully Mar 28, 2018
0f04191
remove comment
Kully Mar 29, 2018
274b003
change error msg for pip installs in choropleth
Kully Mar 29, 2018
f982427
changelog update
Kully Mar 29, 2018
77cf63f
fixed facet grid - annotations now tuples - FacetGrid tests in test_o…
Kully Mar 29, 2018
588f7dd
remove DeprecationWarning from _dendrogram.py
Kully Mar 29, 2018
24ef193
remove unneeded comments in facet_grid
Kully Mar 29, 2018
8386272
change height, width default to np.inf in _Dendogram
Kully Mar 29, 2018
b256334
fixed all tests in optional figure_factory
Kully Mar 29, 2018
b8d04a6
PEP8 to greyscale list
Kully Mar 29, 2018
e890a4a
fix Quiver tests; remove commented TestDisplot for duplicate
Kully Mar 31, 2018
100ef19
minor test fixes in test_tools resolved
Kully Apr 2, 2018
89c4d38
playing around with matplotlylib - no success
Kully Apr 2, 2018
51cd9bc
chelsea's comment
Kully Apr 2, 2018
9f85771
fixed test_validate tests in test_core
Kully Apr 3, 2018
c4d1795
fixed offline tests
Kully Apr 3, 2018
cff0312
change assert error in decorator
Kully Apr 3, 2018
399c2dc
flawed annotations dont return error, so not checking for one
Kully Apr 3, 2018
98e2f54
fix minor tests in test_data
Kully Apr 3, 2018
330d99b
fix test_error_bars
Kully Apr 3, 2018
760b36a
null changes
Kully Apr 3, 2018
9ffc488
added white space
Kully Apr 4, 2018
0d96800
Merge branch 'ipyplotly_integration' into rebased-test-fixes
Kully Apr 4, 2018
cbd1304
rework mock import for Py3.3+ compat
Kully Apr 4, 2018
efd4c2a
deepcopy in assert_fig_equal
Kully Apr 4, 2018
f87a8b8
fixed all but one test in make_subplots
Kully Apr 4, 2018
924501b
merge from ipyplotly-branch
Kully Apr 5, 2018
c90fe9c
Merge branch 'rebased-test-fixes' of https://github.com/plotly/plotly…
Kully Apr 5, 2018
0bf48c2
fixed test_api - mock compatib issue
Kully Apr 5, 2018
8fd5985
change errortype to ValueError to fix test
Kully Apr 5, 2018
a4d6c5d
fix merge for rebase continue
Kully Apr 5, 2018
0505070
reverted back to old test in test_figure
Kully Apr 5, 2018
c937f8e
Merge branch 'ipyplotly_integration' of https://github.com/plotly/plo…
Kully Apr 5, 2018
3e53c10
merge to ipyplotly
Kully Apr 5, 2018
7a0ad41
Merge pull request #984 from plotly/better-geopandas-msg
Kully Apr 5, 2018
d93772d
validators update
Kully Apr 5, 2018
1d5db95
Merge branch 'ipyplotly_integration' of https://github.com/plotly/plo…
Kully Apr 6, 2018
56d0e5f
merging from ipyplotly_integration for up-to-date rebase
Kully Apr 6, 2018
46c9186
fix test_graph_objs.py in test_core
Kully Apr 6, 2018
3140f29
fix scatter.py
Kully Apr 6, 2018
7fa119a
fix self.assert_fig_equal(ohlc.to_plotly_json()['data'][0],
Kully Apr 6, 2018
a3e3508
assert_dict_equal typo
Kully Apr 6, 2018
3aaa3ed
fix PotlyError -> ValueError for TestTable class
Kully Apr 6, 2018
f6f7aaf
middle of putting .to_plotly_json in assert_fig_equal
Kully Apr 6, 2018
35bf539
Merge branch 'master' of https://github.com/plotly/plotly.py into ipy…
Kully Apr 12, 2018
06fec5c
Merge branch 'ipyplotly_integration' of https://github.com/plotly/plo…
Kully Apr 12, 2018
0e53bd0
Merge branch 'ipyplotly_integration' into rebased-test-fixes
Kully Apr 12, 2018
a59c0c2
updated test_tools - numpy arrays to lists
Kully Apr 12, 2018
8f1e212
test_datetimes fixes
Kully Apr 12, 2018
365edce
Fix typo (agruments)
simon04 Apr 13, 2018
e932378
Merge pull request #989 from simon04/agruments
Kully Apr 13, 2018
b981e72
test_offline changes
Kully Apr 13, 2018
23646ca
do not strip fig of invalid elements wen running .get_figure\nthis is…
Kully Apr 13, 2018
5740d73
pull from maste
Kully Apr 16, 2018
eeb7f7e
merge from ipyplotly_integration
Kully Apr 16, 2018
ec5cc2c
xaxis -> xaxis1 in make_subplots
Kully Apr 16, 2018
a561275
Merge branch 'ipyplotly_integration' of https://github.com/plotly/plo…
Kully Apr 16, 2018
02ad817
Merge branch 'ipyplotly_integration' into rebased-test-fixes
Kully Apr 16, 2018
2d9cc9e
xaxis -> xaxis1
Kully Apr 17, 2018
41b0d03
test_plot
Kully Apr 17, 2018
46051e9
fixed test_figure
Kully Apr 17, 2018
499f29f
fixed test_append_trace - added assert_fig_equal func clone in test_core
Kully Apr 17, 2018
de4e6c6
fixed TestDistplot tests
Kully Apr 17, 2018
5b0d607
removed test_plotly_base_classes test as PlotlyDict/PlotlyList are re…
Kully Apr 17, 2018
42e2462
fixed tests in test_ff in optional
Kully Apr 17, 2018
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
2 changes: 1 addition & 1 deletion plotly/plotly/plotly.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def get_figure(file_owner_or_url, file_id=None, raw=False):

if raw:
return figure
return tools.get_valid_graph_obj(figure, obj_type='Figure')
Copy link
Contributor Author

@Kully Kully Apr 13, 2018

Choose a reason for hiding this comment

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

@chriddyp @jmmease
The purpose of this commit is to refactor get_valid_graph_obj function to not remove invalid properties of a figure when .get_figure() is called. I think this is important because:

  • it is consistent with Jon's preference to validation over coercing to default attributes as a default (which I agree with)
  • if a user does want to bypass validation errors, setting raw=True is still an option in the get_figure function
  • one step on the road to finishing Remove graph_objs dependency from tools.py #283 fwiw

What do y'all think?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like this. The user will either get a dict with whatever was on the server (raw=True) or a fully valid Figure.

Do you think the stripping of invalid properties is something that regular users are going to need? I'm not clear on why we end up with figures with invalid properties on the server in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wondered the same thing. In refactoring these tests I noticed that a few of the example figures I pulled from were 4 years old and contained params that are no longer part of the valid params.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd be inclined to update the test data, but I'll leave it to you and @chriddyp to decide whether we need to support some kind of legacy property removal.

return tools.get_graph_obj(figure, obj_type='Figure')


@utils.template_doc(**tools.get_config_file())
Expand Down
15 changes: 12 additions & 3 deletions plotly/tests/test_core/test_get_figure/test_get_figure.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ class GetFigureTest(PlotlyTestCase):
def test_get_figure(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
file_id = 2
file_id = 13183
py.sign_in(un, ak)
py.get_figure('PlotlyImageTest', str(file_id))

@attr('slow')
def test_get_figure_with_url(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/2/"
url = "https://plot.ly/~PlotlyImageTest/13183/"
py.sign_in(un, ak)
py.get_figure(url)

Expand All @@ -71,6 +71,15 @@ def test_get_figure_invalid_2(self):
with self.assertRaises(exceptions.PlotlyError):
py.get_figure(url)

# demonstrates error if fig has invalid parts
def test_get_figure_invalid_3(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/2/"
py.sign_in(un, ak)
with self.assertRaises(ValueError):
py.get_figure(url)

@attr('slow')
def test_get_figure_does_not_exist(self):
un = 'PlotlyImageTest'
Expand All @@ -95,6 +104,6 @@ class TestBytesVStrings(TestCase):
def test_proper_escaping(self):
un = 'PlotlyImageTest'
ak = '786r5mecv0'
url = "https://plot.ly/~PlotlyImageTest/91/"
url = "https://plot.ly/~PlotlyImageTest/13185/"
py.sign_in(un, ak)
py.get_figure(url)
13 changes: 6 additions & 7 deletions plotly/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,23 +1351,22 @@ def _pad(s, cell_len=cell_len):
return fig


def get_valid_graph_obj(obj, obj_type=None):
"""Returns a new graph object that won't raise.

CAREFUL: this will *silently* strip out invalid pieces of the object.
def get_graph_obj(obj, obj_type=None):
"""Returns a new graph object.

OLD FUNCTION: this will *silently* strip out invalid pieces of the object.
NEW FUNCTION: no striping of invalid pieces anymore - only raises error
on unrecognized graph_objs
"""
# TODO: Deprecate or move. #283
from plotly.graph_objs import graph_objs
try:
print(graph_objs)
print(obj_type)
cls = getattr(graph_objs, obj_type)
except (AttributeError, KeyError):
raise exceptions.PlotlyError(
"'{}' is not a recognized graph_obj.".format(obj_type)
)
return cls(obj, _raise=False)
return cls(obj)


def validate(obj, obj_type):
Expand Down