Skip to content

Commit bd31ed8

Browse files
committed
rewrite __dir__ for Layout for Py2 compat
1 parent 15cc55b commit bd31ed8

7 files changed

Lines changed: 16 additions & 45 deletions

File tree

_plotly_utils/basevalidators.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
# back-port of fullmatch from Py3.4+
3232
def fullmatch(regex, string, flags=0):
3333
"""Emulate python-3.4 re.fullmatch()."""
34-
return re.match("(?:" + regex.pattern + r")\Z", string, flags=flags)
34+
if 'pattern' in dir(regex):
35+
regex_string = regex.pattern
36+
else:
37+
regex_string = regex
38+
return re.match("(?:" + regex_string + r")\Z", string, flags=flags)
3539

3640

3741
# Utility functions

makefile

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ update_default_schema :
2727
f.close()"
2828
@echo "Auto-generating graph objects based on updated default-schema."
2929
@echo "Warning: Make sure you are running 'make update_default_schema' with Python 3.6.
30-
Code Generation requires 3.6."
31-
#python -c "from codegen import perform_codegen;\
32-
# perform_codegen()"
33-
python setup.py codegen
34-
# python codegen/__init__.py
30+
The code generating scripts requires 3.6 to run."
31+
python codegen/__init__.py
32+
# TODO: fix code breaking with update_default_schema
33+
# python setup.py codegen
3534

3635
install : sync_subs
3736
@echo ""

plotly/basedatatypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3569,7 +3569,8 @@ def __dir__(self):
35693569
Custom __dir__ that handles dynamic subplot properties
35703570
"""
35713571
# Include any active subplot values
3572-
return list(super(BaseLayoutHierarchyType, self).__dir__()) + sorted(self._subplotid_props)
3572+
# return list(super(BaseLayoutHierarchyType, self).__dir__()) + sorted(self._subplotid_props)
3573+
return list(dir(super(BaseLayoutHierarchyType, self))) + sorted(self._subplotid_props)
35733574

35743575

35753576
class BaseTraceHierarchyType(BasePlotlyType):

plotly/tests/test_core/test_offline/test_offline.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ def _read_html(self, file_url):
4646
return f.read()
4747

4848
def test_default_plot_generates_expected_html(self):
49-
# add uid to data_json for regex search
50-
data_json = '\[\{"x": \[1, 2, 3\], "y": \[10, 20, 30\], "type": "scatter", "uid": .+\}\]'
49+
data_json = '[{"y": [10, 20, 30], "x": [1, 2, 3], "type": "scatter"'
5150
layout_json = _json.dumps(
5251
fig['layout'],
5352
cls=plotly.utils.PlotlyJSONEncoder)
@@ -57,7 +56,7 @@ def test_default_plot_generates_expected_html(self):
5756
# I don't really want to test the entire script output, so
5857
# instead just make sure a few of the parts are in here?
5958
self.assertIn('Plotly.newPlot', html) # plot command is in there
60-
self.assertTrue(re.search(data_json, html)) # data is in there
59+
self.assertIn(data_json, html) # data is in there
6160
self.assertIn(layout_json, html) # so is layout
6261
self.assertIn(PLOTLYJS, html) # and the source code
6362
# and it's an <html> doc

plotly/tests/test_optional/temp-plot.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

plotly/tests/test_optional/test_figure_factory/test_figure_factory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1983,8 +1983,10 @@ def test_violin_fig(self):
19831983
exp_violin['data'][i]
19841984
)
19851985

1986+
print(test_violin['layout'])
1987+
print(type(test_violin['layout']))
19861988
self.assert_fig_equal(test_violin['layout'],
1987-
exp_violin['layout'])
1989+
exp_violin['layout'])
19881990

19891991

19901992
class TestFacetGrid(NumpyTestUtilsMixin, TestCase):

temp-plot.html

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)