diff --git a/_plotly_future_/__init__.py b/_plotly_future_/__init__.py index 8b4b558d993..64b17e6c194 100644 --- a/_plotly_future_/__init__.py +++ b/_plotly_future_/__init__.py @@ -1,7 +1,18 @@ import warnings import functools -_future_flags = set() +# Initialize _future_flags with all future flags that are now always in +# effect. +_future_flags = { + 'renderer_defaults', + 'template_defaults', + 'extract_chart_studio', + 'remove_deprecations', + 'v4_subplots', + 'orca_defaults', + 'timezones', + 'trace_uids', +} def _assert_plotly_not_imported(): @@ -19,13 +30,20 @@ def _assert_plotly_not_imported(): def _chart_studio_warning(submodule): - if 'extract_chart_studio' in _future_flags: - warnings.warn( - 'The plotly.{submodule} module is deprecated, ' - 'please use chart_studio.{submodule} instead' - .format(submodule=submodule), - DeprecationWarning, - stacklevel=2) + warnings.warn( + 'The plotly.{submodule} module is deprecated, ' + 'please use chart_studio.{submodule} instead' + .format(submodule=submodule), + DeprecationWarning, + stacklevel=2) + + +def _chart_studio_error(submodule): + raise ImportError(""" +The plotly.{submodule} module is deprecated, +please install the chart_studio package and use the +chart_studio.{submodule} module instead. +""".format(submodule=submodule)) def _chart_studio_deprecation(fn): @@ -43,15 +61,14 @@ def _chart_studio_deprecation(fn): @functools.wraps(fn) def wrapper(*args, **kwargs): - if 'extract_chart_studio' in _future_flags: - warnings.warn( - msg, - DeprecationWarning, - stacklevel=2) + warnings.warn( + msg, + DeprecationWarning, + stacklevel=2) return fn(*args, **kwargs) return wrapper -__all__ = ['_future_flags', '_chart_studio_warning'] +__all__ = ['_future_flags', '_chart_studio_error'] diff --git a/_plotly_future_/extract_chart_studio.py b/_plotly_future_/extract_chart_studio.py index a3de7eca345..e69de29bb2d 100644 --- a/_plotly_future_/extract_chart_studio.py +++ b/_plotly_future_/extract_chart_studio.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('extract_chart_studio') diff --git a/_plotly_future_/orca_defaults.py b/_plotly_future_/orca_defaults.py index b63282fb6a1..e69de29bb2d 100644 --- a/_plotly_future_/orca_defaults.py +++ b/_plotly_future_/orca_defaults.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('orca_defaults') diff --git a/_plotly_future_/remove_deprecations.py b/_plotly_future_/remove_deprecations.py index 3e47048038d..e69de29bb2d 100644 --- a/_plotly_future_/remove_deprecations.py +++ b/_plotly_future_/remove_deprecations.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('remove_deprecations') diff --git a/_plotly_future_/renderer_defaults.py b/_plotly_future_/renderer_defaults.py index 1ee0e54301b..e69de29bb2d 100644 --- a/_plotly_future_/renderer_defaults.py +++ b/_plotly_future_/renderer_defaults.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('renderer_defaults') diff --git a/_plotly_future_/template_defaults.py b/_plotly_future_/template_defaults.py index 82c0f52ff2d..e69de29bb2d 100644 --- a/_plotly_future_/template_defaults.py +++ b/_plotly_future_/template_defaults.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('template_defaults') diff --git a/_plotly_future_/timezones.py b/_plotly_future_/timezones.py index e6437b4a232..e69de29bb2d 100644 --- a/_plotly_future_/timezones.py +++ b/_plotly_future_/timezones.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('timezones') diff --git a/_plotly_future_/trace_uids.py b/_plotly_future_/trace_uids.py index d110359e5dc..e69de29bb2d 100644 --- a/_plotly_future_/trace_uids.py +++ b/_plotly_future_/trace_uids.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('trace_uids') diff --git a/_plotly_future_/v4.py b/_plotly_future_/v4.py index 58cf0698ac6..e69de29bb2d 100644 --- a/_plotly_future_/v4.py +++ b/_plotly_future_/v4.py @@ -1,12 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import ( - renderer_defaults, - template_defaults, - extract_chart_studio, - remove_deprecations, - v4_subplots, - orca_defaults, - timezones, - trace_uids, -) - diff --git a/_plotly_future_/v4_subplots.py b/_plotly_future_/v4_subplots.py index 4aaba5cdf11..e69de29bb2d 100644 --- a/_plotly_future_/v4_subplots.py +++ b/_plotly_future_/v4_subplots.py @@ -1,5 +0,0 @@ -from __future__ import absolute_import -from _plotly_future_ import _future_flags, _assert_plotly_not_imported - -_assert_plotly_not_imported() -_future_flags.add('v4_subplots') diff --git a/_plotly_utils/utils.py b/_plotly_utils/utils.py index 10ae668946e..eda9df70cf2 100644 --- a/_plotly_utils/utils.py +++ b/_plotly_utils/utils.py @@ -4,7 +4,6 @@ import sys import re import pytz -from _plotly_future_ import _future_flags from _plotly_utils.optional_imports import get_module @@ -104,9 +103,7 @@ def default(self, obj): self.encode_as_sage, self.encode_as_numpy, self.encode_as_pandas, - (self.encode_as_datetime_v4 - if 'timezones' in _future_flags - else self.encode_as_datetime), + self.encode_as_datetime_v4, self.encode_as_date, self.encode_as_list, # because some values have `tolist` do last. self.encode_as_decimal diff --git a/chart_studio/tests/test_optional/test_utils/test_utils.py b/chart_studio/tests/test_optional/test_utils/test_utils.py index 49e16cadc16..0af99a87be4 100644 --- a/chart_studio/tests/test_optional/test_utils/test_utils.py +++ b/chart_studio/tests/test_optional/test_utils/test_utils.py @@ -1,4 +1,5 @@ import json as _json +from unittest import TestCase import _plotly_utils.utils from chart_studio.grid_objs import Column @@ -7,19 +8,21 @@ mixed_list, np_list -def test_column_json_encoding(): - columns = [ - Column(numeric_list, 'col 1'), - Column(mixed_list, 'col 2'), - Column(np_list, 'col 3') - ] - json_columns = _json.dumps( - columns, cls=_plotly_utils.utils.PlotlyJSONEncoder, sort_keys=True - ) - assert('[{"data": [1, 2, 3], "name": "col 1"}, ' - '{"data": [1, "A", "2014-01-05", ' - '"2014-01-05 01:01:01", ' - '"2014-01-05 01:01:01.000001"], ' - '"name": "col 2"}, ' - '{"data": [1, 2, 3, null, null, null, ' - '"2014-01-05"], "name": "col 3"}]' == json_columns) \ No newline at end of file +class TestJSONEncoder(TestCase): + def test_column_json_encoding(self): + columns = [ + Column(numeric_list, 'col 1'), + Column(mixed_list, 'col 2'), + Column(np_list, 'col 3') + ] + json_columns = _json.dumps( + columns, cls=_plotly_utils.utils.PlotlyJSONEncoder, sort_keys=True + ) + print(json_columns) + assert('[{"data": [1, 2, 3], "name": "col 1"}, ' + '{"data": [1, "A", "2014-01-05T00:00:00", ' + '"2014-01-05T01:01:01", ' + '"2014-01-05T01:01:01.000001"], ' + '"name": "col 2"}, ' + '{"data": [1, 2, 3, null, null, null, ' + '"2014-01-05T00:00:00"], "name": "col 3"}]' == json_columns) diff --git a/codegen/figure.py b/codegen/figure.py index e4cf108e860..42820dad2bd 100644 --- a/codegen/figure.py +++ b/codegen/figure.py @@ -57,7 +57,6 @@ def build_figure_py(trace_node, base_package, base_classname, fig_classname, # ### Import trace graph_obj classes ### trace_types_csv = ', '.join([n.name_datatype_class for n in trace_nodes]) buffer.write(f'from plotly.graph_objs import ({trace_types_csv})\n') - buffer.write("from plotly.subplots import _validate_v4_subplots\n") # Write class definition # ---------------------- @@ -253,8 +252,6 @@ def select_{plural_name}( Generator that iterates through all of the {singular_name} objects that satisfy all of the specified selection criteria \"\"\" - if row is not None or col is not None: - _validate_v4_subplots('select_{plural_name}') return self._select_layout_subplots_by_prefix( '{singular_name}', selector, row, col{secondary_y_2}) diff --git a/plotly/__init__.py b/plotly/__init__.py index a71bea8e1ad..0bef71adc6e 100644 --- a/plotly/__init__.py +++ b/plotly/__init__.py @@ -27,7 +27,6 @@ """ from __future__ import absolute_import -from _plotly_future_ import _future_flags from plotly import ( graph_objs, @@ -41,16 +40,5 @@ from plotly.version import __version__ -if ('extract_chart_studio' not in _future_flags - and 'remove_deprecations' not in _future_flags): - from plotly import ( - plotly, - dashboard_objs, - grid_objs, - session) - - # Set default template here to make sure import process is complete -if 'template_defaults' in _future_flags: - # Set _default to skip validation - io.templates._default = 'plotly' +io.templates._default = 'plotly' diff --git a/plotly/api/utils.py b/plotly/api/utils.py index 29f1d3f6d0c..d4ba3ad2d60 100644 --- a/plotly/api/utils.py +++ b/plotly/api/utils.py @@ -1,4 +1,3 @@ -# Deprecations -from _plotly_future_ import _future_flags -if 'remove_deprecations' not in _future_flags: - from chart_studio.api.utils import * +from __future__ import absolute_import +from _plotly_future_ import _chart_studio_error +_chart_studio_error('api.utils') diff --git a/plotly/api/v1.py b/plotly/api/v1.py index 7d91adb2eec..6c940530f07 100644 --- a/plotly/api/v1.py +++ b/plotly/api/v1.py @@ -1,9 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('api.v1') - from chart_studio.api.v1 import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('api.v1') diff --git a/plotly/api/v2.py b/plotly/api/v2.py index 82851d4b5ff..a14c603af76 100644 --- a/plotly/api/v2.py +++ b/plotly/api/v2.py @@ -1,9 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('api.v2') - from chart_studio.api.v2 import * \ No newline at end of file +from _plotly_future_ import _chart_studio_error +_chart_studio_error('api.v2') diff --git a/plotly/basedatatypes.py b/plotly/basedatatypes.py index 8bcbe279c15..1d631763ea0 100644 --- a/plotly/basedatatypes.py +++ b/plotly/basedatatypes.py @@ -13,8 +13,7 @@ from plotly.subplots import ( _set_trace_grid_reference, _get_grid_subplot, - _get_subplot_ref_for_trace, - _validate_v4_subplots) + _get_subplot_ref_for_trace) from .optional_imports import get_module from _plotly_utils.basevalidators import ( @@ -26,8 +25,6 @@ from plotly.utils import ElidedPrettyPrinter from .validators import (DataValidator, LayoutValidator, FramesValidator) -from _plotly_future_ import _future_flags - # Create Undefined sentinel value # - Setting a property to None removes any existing value # - Setting a property to Undefined leaves existing value unmodified @@ -51,7 +48,7 @@ class BaseFigure(object): 'plot_bgcolor': 'plot-bgcolor' } - _set_trace_uid = 'trace_uids' not in _future_flags + _set_trace_uid = False # Constructor # ----------- @@ -683,7 +680,6 @@ def select_traces( selector = {} if row is not None or col is not None or secondary_y is not None: - _validate_v4_subplots('select_traces') grid_ref = self._validate_get_grid_ref() filter_by_subplot = True @@ -1610,41 +1606,8 @@ def append_trace(self, trace, row, col): def _set_trace_grid_position( self, trace, row, col, secondary_y=False): grid_ref = self._validate_get_grid_ref() - - from _plotly_future_ import _future_flags - if 'v4_subplots' in _future_flags: - return _set_trace_grid_reference( - trace, self.layout, grid_ref, row, col, secondary_y) - - if row <= 0: - raise Exception("Row value is out of range. " - "Note: the starting cell is (1, 1)") - if col <= 0: - raise Exception("Col value is out of range. " - "Note: the starting cell is (1, 1)") - try: - ref = grid_ref[row - 1][col - 1] - except IndexError: - raise Exception("The (row, col) pair sent is out of " - "range. Use Figure.print_grid to view the " - "subplot grid. ") - if 'scene' in ref[0]: - trace['scene'] = ref[0] - if ref[0] not in self['layout']: - raise Exception("Something went wrong. " - "The scene object for ({r},{c}) " - "subplot cell " - "got deleted.".format(r=row, c=col)) - else: - xaxis_key = "xaxis{ref}".format(ref=ref[0][1:]) - yaxis_key = "yaxis{ref}".format(ref=ref[1][1:]) - if (xaxis_key not in self['layout'] - or yaxis_key not in self['layout']): - raise Exception("Something went wrong. " - "An axis object for ({r},{c}) subplot " - "cell got deleted.".format(r=row, c=col)) - trace['xaxis'] = ref[0] - trace['yaxis'] = ref[1] + return _set_trace_grid_reference( + trace, self.layout, grid_ref, row, col, secondary_y) def _validate_get_grid_ref(self): try: diff --git a/plotly/config.py b/plotly/config.py index ca1c72c1f6b..86a36b24075 100644 --- a/plotly/config.py +++ b/plotly/config.py @@ -1,5 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _chart_studio_warning -_chart_studio_warning('config') -from chart_studio.config import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('config') diff --git a/plotly/dashboard_objs.py b/plotly/dashboard_objs.py index c060c9978cf..42dc89418a2 100644 --- a/plotly/dashboard_objs.py +++ b/plotly/dashboard_objs.py @@ -1,9 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('dashboard_objs') - from chart_studio.dashboard_objs import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('dashboard_objs') diff --git a/plotly/exceptions.py b/plotly/exceptions.py index 9c2ee01c258..f2ddd9f5d2e 100644 --- a/plotly/exceptions.py +++ b/plotly/exceptions.py @@ -1,6 +1,2 @@ +from __future__ import absolute_import from _plotly_utils.exceptions import * - -# Deprecations -from _plotly_future_ import _future_flags -if 'remove_deprecations' not in _future_flags: - from chart_studio.exceptions import * diff --git a/plotly/figure_factory/_facet_grid.py b/plotly/figure_factory/_facet_grid.py index f1a73a2c4f6..ea4b8c4f745 100644 --- a/plotly/figure_factory/_facet_grid.py +++ b/plotly/figure_factory/_facet_grid.py @@ -3,7 +3,7 @@ from plotly import exceptions, optional_imports import plotly.colors as clrs from plotly.figure_factory import utils -from plotly.tools import make_subplots +from plotly.subplots import make_subplots import math from numbers import Number diff --git a/plotly/files.py b/plotly/files.py index 453d17a3f29..0c305183e96 100644 --- a/plotly/files.py +++ b/plotly/files.py @@ -1,6 +1,2 @@ +from __future__ import absolute_import from _plotly_utils.files import * - -# Deprecations -from _plotly_future_ import _future_flags -if 'remove_deprecations' not in _future_flags: - from chart_studio.files import * diff --git a/plotly/graph_objs/_figure.py b/plotly/graph_objs/_figure.py index dc3508a928c..b54dd10490b 100644 --- a/plotly/graph_objs/_figure.py +++ b/plotly/graph_objs/_figure.py @@ -8,7 +8,6 @@ Scatterternary, Splom, Streamtube, Sunburst, Surface, Table, Violin, Volume, Waterfall ) -from plotly.subplots import _validate_v4_subplots class Figure(BaseFigure): @@ -14241,8 +14240,6 @@ def select_coloraxes(self, selector=None, row=None, col=None): Generator that iterates through all of the coloraxis objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_coloraxes') return self._select_layout_subplots_by_prefix( 'coloraxis', selector, row, col @@ -14341,8 +14338,6 @@ def select_geos(self, selector=None, row=None, col=None): Generator that iterates through all of the geo objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_geos') return self._select_layout_subplots_by_prefix( 'geo', selector, row, col @@ -14441,8 +14436,6 @@ def select_mapboxes(self, selector=None, row=None, col=None): Generator that iterates through all of the mapbox objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_mapboxes') return self._select_layout_subplots_by_prefix( 'mapbox', selector, row, col @@ -14541,8 +14534,6 @@ def select_polars(self, selector=None, row=None, col=None): Generator that iterates through all of the polar objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_polars') return self._select_layout_subplots_by_prefix( 'polar', selector, row, col @@ -14641,8 +14632,6 @@ def select_scenes(self, selector=None, row=None, col=None): Generator that iterates through all of the scene objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_scenes') return self._select_layout_subplots_by_prefix( 'scene', selector, row, col @@ -14741,8 +14730,6 @@ def select_ternaries(self, selector=None, row=None, col=None): Generator that iterates through all of the ternary objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_ternaries') return self._select_layout_subplots_by_prefix( 'ternary', selector, row, col @@ -14841,8 +14828,6 @@ def select_xaxes(self, selector=None, row=None, col=None): Generator that iterates through all of the xaxis objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_xaxes') return self._select_layout_subplots_by_prefix( 'xaxis', selector, row, col @@ -14955,8 +14940,6 @@ def select_yaxes( Generator that iterates through all of the yaxis objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_yaxes') return self._select_layout_subplots_by_prefix( 'yaxis', selector, row, col, secondary_y=secondary_y diff --git a/plotly/graph_objs/_figurewidget.py b/plotly/graph_objs/_figurewidget.py index 53a04101e9c..0ae9705e360 100644 --- a/plotly/graph_objs/_figurewidget.py +++ b/plotly/graph_objs/_figurewidget.py @@ -8,7 +8,6 @@ Scatterternary, Splom, Streamtube, Sunburst, Surface, Table, Violin, Volume, Waterfall ) -from plotly.subplots import _validate_v4_subplots class FigureWidget(BaseFigureWidget): @@ -14241,8 +14240,6 @@ def select_coloraxes(self, selector=None, row=None, col=None): Generator that iterates through all of the coloraxis objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_coloraxes') return self._select_layout_subplots_by_prefix( 'coloraxis', selector, row, col @@ -14341,8 +14338,6 @@ def select_geos(self, selector=None, row=None, col=None): Generator that iterates through all of the geo objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_geos') return self._select_layout_subplots_by_prefix( 'geo', selector, row, col @@ -14441,8 +14436,6 @@ def select_mapboxes(self, selector=None, row=None, col=None): Generator that iterates through all of the mapbox objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_mapboxes') return self._select_layout_subplots_by_prefix( 'mapbox', selector, row, col @@ -14541,8 +14534,6 @@ def select_polars(self, selector=None, row=None, col=None): Generator that iterates through all of the polar objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_polars') return self._select_layout_subplots_by_prefix( 'polar', selector, row, col @@ -14641,8 +14632,6 @@ def select_scenes(self, selector=None, row=None, col=None): Generator that iterates through all of the scene objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_scenes') return self._select_layout_subplots_by_prefix( 'scene', selector, row, col @@ -14741,8 +14730,6 @@ def select_ternaries(self, selector=None, row=None, col=None): Generator that iterates through all of the ternary objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_ternaries') return self._select_layout_subplots_by_prefix( 'ternary', selector, row, col @@ -14841,8 +14828,6 @@ def select_xaxes(self, selector=None, row=None, col=None): Generator that iterates through all of the xaxis objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_xaxes') return self._select_layout_subplots_by_prefix( 'xaxis', selector, row, col @@ -14955,8 +14940,6 @@ def select_yaxes( Generator that iterates through all of the yaxis objects that satisfy all of the specified selection criteria """ - if row is not None or col is not None: - _validate_v4_subplots('select_yaxes') return self._select_layout_subplots_by_prefix( 'yaxis', selector, row, col, secondary_y=secondary_y diff --git a/plotly/grid_objs.py b/plotly/grid_objs.py index 939d8ff469f..181f26ca03c 100644 --- a/plotly/grid_objs.py +++ b/plotly/grid_objs.py @@ -1,9 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('grid_objs') - from chart_studio.grid_objs import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('grid_objs') diff --git a/plotly/io/_orca.py b/plotly/io/_orca.py index 19bb51b432b..a66f9686239 100644 --- a/plotly/io/_orca.py +++ b/plotly/io/_orca.py @@ -22,8 +22,6 @@ psutil = get_module('psutil') -from _plotly_future_ import _future_flags - # Valid image format constants # ---------------------------- valid_formats = ('png', 'jpeg', 'webp', 'svg', 'pdf', 'eps') @@ -671,7 +669,7 @@ def mapbox_access_token(self, val): @property def use_xvfb(self): - dflt = 'auto' if 'orca_defaults' in _future_flags else False + dflt = 'auto' return self._props.get('use_xvfb', dflt) @use_xvfb.setter diff --git a/plotly/io/_renderers.py b/plotly/io/_renderers.py index a396e54c817..5ff06e5ea14 100644 --- a/plotly/io/_renderers.py +++ b/plotly/io/_renderers.py @@ -7,7 +7,6 @@ import os from plotly import optional_imports -from _plotly_future_ import _future_flags from plotly.io._base_renderers import ( MimetypeRenderer, ExternalRenderer, PlotlyRenderer, NotebookRenderer, @@ -397,53 +396,54 @@ def show(fig, renderer=None, validate=True, **kwargs): # Set default renderer # -------------------- -if 'renderer_defaults' in _future_flags: - # Version 4 renderer configuration - default_renderer = None - - # Handle the PLOTLY_RENDERER environment variable - env_renderer = os.environ.get('PLOTLY_RENDERER', None) - if env_renderer: - try: - renderers._validate_coerce_renderers(env_renderer) - except ValueError: - raise ValueError(""" +# Version 4 renderer configuration +default_renderer = None + +# Handle the PLOTLY_RENDERER environment variable +env_renderer = os.environ.get('PLOTLY_RENDERER', None) +if env_renderer: + try: + renderers._validate_coerce_renderers(env_renderer) + except ValueError: + raise ValueError(""" Invalid named renderer(s) specified in the 'PLOTLY_RENDERER' environment variable: {env_renderer}""".format(env_renderer=env_renderer)) - default_renderer = env_renderer - elif ipython and ipython.get_ipython(): - # Try to detect environment so that we can enable a useful - # default renderer - if not default_renderer: - try: - import google.colab - - default_renderer = 'colab' - except ImportError: - pass - - # Check if we're running in a Kaggle notebook - if not default_renderer and os.path.exists('/kaggle/input'): - default_renderer = 'kaggle' - - # Check if we're running in VSCode - if not default_renderer and 'VSCODE_PID' in os.environ: - default_renderer = 'vscode' - - # Fallback to renderer combination that will work automatically - # in the classic notebook (offline), jupyterlab, nteract, vscode, and - # nbconvert HTML export. - if not default_renderer: - default_renderer = 'plotly_mimetype+notebook' - else: - # If ipython isn't available, try to display figures in the default - # browser - default_renderer = 'browser' + default_renderer = env_renderer +elif ipython and ipython.get_ipython(): + # Try to detect environment so that we can enable a useful + # default renderer + if not default_renderer: + try: + import google.colab - renderers.render_on_display = True - renderers.default = default_renderer + default_renderer = 'colab' + except ImportError: + pass + + # Check if we're running in a Kaggle notebook + if not default_renderer and os.path.exists('/kaggle/input'): + default_renderer = 'kaggle' + + # Check if we're running in VSCode + if not default_renderer and 'VSCODE_PID' in os.environ: + default_renderer = 'vscode' + + # Fallback to renderer combination that will work automatically + # in the classic notebook (offline), jupyterlab, nteract, vscode, and + # nbconvert HTML export. + if not default_renderer: + default_renderer = 'plotly_mimetype+notebook' else: - # Version 3 defaults - renderers.render_on_display = False - renderers.default = 'plotly_mimetype' + # If ipython isn't available, try to display figures in the default + # browser + import webbrowser + try: + webbrowser.get() + default_renderer = 'browser' + except webbrowser.Error: + # Default browser could not be loaded + pass + +renderers.render_on_display = True +renderers.default = default_renderer diff --git a/plotly/io/_templates.py b/plotly/io/_templates.py index 71fe33333d1..17a2518534b 100644 --- a/plotly/io/_templates.py +++ b/plotly/io/_templates.py @@ -8,10 +8,6 @@ import json from functools import reduce -from six import string_types - -from _plotly_future_ import _future_flags - try: from math import gcd except ImportError: @@ -68,13 +64,6 @@ def __getitem__(self, item): template_dict = json.loads(template_str) template = Template(template_dict) - if ('template_defaults' in _future_flags - and isinstance(item, string_types) - and item in ('plotly', 'plotly_white', 'plotly_dark') - ): - template = self.merge_templates( - template, self['plotly_v4_colors']) - self._templates[item] = template return template diff --git a/plotly/offline/offline.py b/plotly/offline/offline.py index f3e6730fb88..b3d765c3a0d 100644 --- a/plotly/offline/offline.py +++ b/plotly/offline/offline.py @@ -105,7 +105,7 @@ def _build_mathjax_script(url): .format(url=url)) -def _get_jconfig(config): +def _get_jconfig(config=None): configkeys = ( 'staticPlot', @@ -316,10 +316,10 @@ def iplot(figure_or_data, show_link=False, link_text='Export to plot.ly', `show_link` and `link_text` set the associated options in this dictionary if it doesn't contain them already. auto_play (default=True) -- Whether to automatically start the animation - sequence on page load, if the figure contains frames. Has no effect if + sequence on page load, if the figure contains frames. Has no effect if the figure does not contain frames. - animation_opts (default=None) -- Dict of custom animation parameters that - are used for the automatically started animation on page load. This + animation_opts (default=None) -- Dict of custom animation parameters that + are used for the automatically started animation on page load. This dict is passed to the function Plotly.animate in Plotly.js. See https://github.com/plotly/plotly.js/blob/master/src/plots/animation_attributes.js for available options. Has no effect if the figure @@ -493,8 +493,8 @@ def plot(figure_or_data, show_link=False, link_text='Export to plot.ly', auto_play (default=True) -- Whether to automatically start the animation sequence on page load if the figure contains frames. Has no effect if the figure does not contain frames. - animation_opts (default=None) -- Dict of custom animation parameters that - are used for the automatically started animation on page load. This + animation_opts (default=None) -- Dict of custom animation parameters that + are used for the automatically started animation on page load. This dict is passed to the function Plotly.animate in Plotly.js. See https://github.com/plotly/plotly.js/blob/master/src/plots/animation_attributes.js for available options. Has no effect if the figure diff --git a/plotly/package_data/templates/ggplot2.json b/plotly/package_data/templates/ggplot2.json index a715065e0ec..ae816964cfb 100644 --- a/plotly/package_data/templates/ggplot2.json +++ b/plotly/package_data/templates/ggplot2.json @@ -1 +1 @@ -{"layout": {"colorway": ["#F8766D", "#A3A500", "#00BF7D", "#00B0F6", "#E76BF3"], "font": {"color": "rgb(51,51,51)"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "rgb(237,237,237)", "polar": {"bgcolor": "rgb(237,237,237)", "angularaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "radialaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}}, "ternary": {"bgcolor": "rgb(237,237,237)", "aaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "baxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "caxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}}, "colorscale": {"sequential": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]], "sequentialminus": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}, "xaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "automargin": true}, "yaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "automargin": true}, "scene": {"xaxis": {"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "gridwidth": 2}, "yaxis": {"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "gridwidth": 2}, "zaxis": {"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "black", "line": {"width": 0}, "opacity": 0.3}, "annotationdefaults": {"arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "white", "landcolor": "rgb(237,237,237)", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "bar": [{"marker": {"line": {"color": "rgb(237,237,237)", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatter3d": [{"type": "scatter3d", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "carpet": [{"aaxis": {"endlinecolor": "rgb(51,51,51)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(51,51,51)"}, "baxis": {"endlinecolor": "rgb(51,51,51)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(51,51,51)"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "rgb(237,237,237)"}, "line": {"color": "white"}}, "header": {"fill": {"color": "rgb(217,217,217)"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "rgb(237,237,237)", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file +{"layout": {"colorway": ["#F8766D", "#A3A500", "#00BF7D", "#00B0F6", "#E76BF3"], "font": {"color": "rgb(51,51,51)"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "rgb(237,237,237)", "polar": {"bgcolor": "rgb(237,237,237)", "angularaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "radialaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}}, "ternary": {"bgcolor": "rgb(237,237,237)", "aaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "baxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}, "caxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside"}}, "colorscale": {"sequential": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]], "sequentialminus": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}, "xaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "automargin": true}, "yaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "automargin": true}, "scene": {"xaxis": {"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "gridwidth": 2}, "yaxis": {"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "gridwidth": 2}, "zaxis": {"backgroundcolor": "rgb(237,237,237)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "tickcolor": "rgb(51,51,51)", "ticks": "outside", "zerolinecolor": "white", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "black", "line": {"width": 0}, "opacity": 0.3}, "annotationdefaults": {"arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "white", "landcolor": "rgb(237,237,237)", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}, "colorscale": [[0, "rgb(20,44,66)"], [1, "rgb(90,179,244)"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "bar": [{"marker": {"line": {"color": "rgb(237,237,237)", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatter3d": [{"type": "scatter3d", "line": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}, "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(237,237,237)", "ticklen": 6, "ticks": "inside"}}}], "carpet": [{"aaxis": {"endlinecolor": "rgb(51,51,51)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(51,51,51)"}, "baxis": {"endlinecolor": "rgb(51,51,51)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(51,51,51)"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "rgb(237,237,237)"}, "line": {"color": "white"}}, "header": {"fill": {"color": "rgb(217,217,217)"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "rgb(237,237,237)", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file diff --git a/plotly/package_data/templates/plotly.json b/plotly/package_data/templates/plotly.json index 9c49d073e3d..5b3c9b75c6e 100644 --- a/plotly/package_data/templates/plotly.json +++ b/plotly/package_data/templates/plotly.json @@ -1 +1 @@ -{"layout": {"colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#19d3f3", "#e763fa", "#FECB52", "#FFA15A", "#FF6692", "#B6E880"], "font": {"color": "#2a3f5f"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": {"bgcolor": "#E5ECF6", "angularaxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}, "radialaxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}}, "ternary": {"bgcolor": "#E5ECF6", "aaxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}, "baxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}, "caxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}}, "colorscale": {"sequential": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]], "sequentialminus": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]], "diverging": [[0, "#8e0152"], [0.1, "#c51b7d"], [0.2, "#de77ae"], [0.3, "#f1b6da"], [0.4, "#fde0ef"], [0.5, "#f7f7f7"], [0.6, "#e6f5d0"], [0.7, "#b8e186"], [0.8, "#7fbc41"], [0.9, "#4d9221"], [1, "#276419"]]}, "xaxis": {"gridcolor": "white", "linecolor": "white", "ticks": "", "zerolinecolor": "white", "automargin": true, "zerolinewidth": 2}, "yaxis": {"gridcolor": "white", "linecolor": "white", "ticks": "", "zerolinecolor": "white", "automargin": true, "zerolinewidth": 2}, "scene": {"xaxis": {"backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "yaxis": {"backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "zaxis": {"backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "#506784", "line": {"width": 0}, "opacity": 0.4}, "annotationdefaults": {"arrowcolor": "#506784", "arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "white", "landcolor": "#E5ECF6", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white"}, "title": {"x": 0.05}, "mapbox": {"style": "light"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "bar": [{"marker": {"line": {"color": "#E5ECF6", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatter3d": [{"type": "scatter3d", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "carpet": [{"aaxis": {"endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f"}, "baxis": {"endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "#EBF0F8"}, "line": {"color": "white"}}, "header": {"fill": {"color": "#C8D4E3"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "#E5ECF6", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file +{"layout": {"colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52"], "font": {"color": "#2a3f5f"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "#E5ECF6", "polar": {"bgcolor": "#E5ECF6", "angularaxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}, "radialaxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}}, "ternary": {"bgcolor": "#E5ECF6", "aaxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}, "baxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}, "caxis": {"gridcolor": "white", "linecolor": "white", "ticks": ""}}, "colorscale": {"sequential": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "sequentialminus": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "diverging": [[0, "#8e0152"], [0.1, "#c51b7d"], [0.2, "#de77ae"], [0.3, "#f1b6da"], [0.4, "#fde0ef"], [0.5, "#f7f7f7"], [0.6, "#e6f5d0"], [0.7, "#b8e186"], [0.8, "#7fbc41"], [0.9, "#4d9221"], [1, "#276419"]]}, "xaxis": {"gridcolor": "white", "linecolor": "white", "ticks": "", "zerolinecolor": "white", "automargin": true, "zerolinewidth": 2}, "yaxis": {"gridcolor": "white", "linecolor": "white", "ticks": "", "zerolinecolor": "white", "automargin": true, "zerolinewidth": 2}, "scene": {"xaxis": {"backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "yaxis": {"backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "zaxis": {"backgroundcolor": "#E5ECF6", "gridcolor": "white", "linecolor": "white", "showbackground": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "#506784", "line": {"width": 0}, "opacity": 0.4}, "annotationdefaults": {"arrowcolor": "#506784", "arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "white", "landcolor": "#E5ECF6", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white"}, "title": {"x": 0.05}, "mapbox": {"style": "light"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "bar": [{"marker": {"line": {"color": "#E5ECF6", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatter3d": [{"type": "scatter3d", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}, "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "carpet": [{"aaxis": {"endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f"}, "baxis": {"endlinecolor": "#2a3f5f", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "#2a3f5f"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "#EBF0F8"}, "line": {"color": "white"}}, "header": {"fill": {"color": "#C8D4E3"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "#E5ECF6", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file diff --git a/plotly/package_data/templates/plotly_dark.json b/plotly/package_data/templates/plotly_dark.json index f59ac58ae26..145412fed48 100644 --- a/plotly/package_data/templates/plotly_dark.json +++ b/plotly/package_data/templates/plotly_dark.json @@ -1 +1 @@ -{"layout": {"colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#19d3f3", "#e763fa", "#FECB52", "#FFA15A", "#FF6692", "#B6E880"], "font": {"color": "#f2f5fa"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "rgb(17,17,17)", "plot_bgcolor": "rgb(17,17,17)", "polar": {"bgcolor": "rgb(17,17,17)", "angularaxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "radialaxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}}, "ternary": {"bgcolor": "rgb(17,17,17)", "aaxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "baxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "caxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}}, "colorscale": {"sequential": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]], "sequentialminus": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]], "diverging": [[0, "#8e0152"], [0.1, "#c51b7d"], [0.2, "#de77ae"], [0.3, "#f1b6da"], [0.4, "#fde0ef"], [0.5, "#f7f7f7"], [0.6, "#e6f5d0"], [0.7, "#b8e186"], [0.8, "#7fbc41"], [0.9, "#4d9221"], [1, "#276419"]]}, "xaxis": {"gridcolor": "#283442", "linecolor": "#506784", "ticks": "", "zerolinecolor": "#283442", "automargin": true, "zerolinewidth": 2}, "yaxis": {"gridcolor": "#283442", "linecolor": "#506784", "ticks": "", "zerolinecolor": "#283442", "automargin": true, "zerolinewidth": 2}, "scene": {"xaxis": {"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3", "gridwidth": 2}, "yaxis": {"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3", "gridwidth": 2}, "zaxis": {"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "#f2f5fa", "line": {"width": 0}, "opacity": 0.4}, "annotationdefaults": {"arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "rgb(17,17,17)", "landcolor": "rgb(17,17,17)", "subunitcolor": "#506784", "showland": true, "showlakes": true, "lakecolor": "rgb(17,17,17)"}, "title": {"x": 0.05}, "updatemenudefaults": {"bgcolor": "#506784", "borderwidth": 0}, "sliderdefaults": {"bgcolor": "#C8D4E3", "borderwidth": 1, "bordercolor": "rgb(17,17,17)", "tickwidth": 0}, "mapbox": {"style": "dark"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "scatter": [{"marker": {"line": {"color": "#283442"}}, "type": "scatter"}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "bar": [{"marker": {"line": {"color": "rgb(17,17,17)", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattergl": [{"marker": {"line": {"color": "#283442"}}, "type": "scattergl"}], "scatter3d": [{"type": "scatter3d", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "carpet": [{"aaxis": {"endlinecolor": "#A2B1C6", "gridcolor": "#506784", "linecolor": "#506784", "minorgridcolor": "#506784", "startlinecolor": "#A2B1C6"}, "baxis": {"endlinecolor": "#A2B1C6", "gridcolor": "#506784", "linecolor": "#506784", "minorgridcolor": "#506784", "startlinecolor": "#A2B1C6"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "#506784"}, "line": {"color": "rgb(17,17,17)"}}, "header": {"fill": {"color": "#2a3f5f"}, "line": {"color": "rgb(17,17,17)"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "rgb(17,17,17)", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file +{"layout": {"colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52"], "font": {"color": "#f2f5fa"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "rgb(17,17,17)", "plot_bgcolor": "rgb(17,17,17)", "polar": {"bgcolor": "rgb(17,17,17)", "angularaxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "radialaxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}}, "ternary": {"bgcolor": "rgb(17,17,17)", "aaxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "baxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}, "caxis": {"gridcolor": "#506784", "linecolor": "#506784", "ticks": ""}}, "colorscale": {"sequential": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "sequentialminus": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "diverging": [[0, "#8e0152"], [0.1, "#c51b7d"], [0.2, "#de77ae"], [0.3, "#f1b6da"], [0.4, "#fde0ef"], [0.5, "#f7f7f7"], [0.6, "#e6f5d0"], [0.7, "#b8e186"], [0.8, "#7fbc41"], [0.9, "#4d9221"], [1, "#276419"]]}, "xaxis": {"gridcolor": "#283442", "linecolor": "#506784", "ticks": "", "zerolinecolor": "#283442", "automargin": true, "zerolinewidth": 2}, "yaxis": {"gridcolor": "#283442", "linecolor": "#506784", "ticks": "", "zerolinecolor": "#283442", "automargin": true, "zerolinewidth": 2}, "scene": {"xaxis": {"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3", "gridwidth": 2}, "yaxis": {"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3", "gridwidth": 2}, "zaxis": {"backgroundcolor": "rgb(17,17,17)", "gridcolor": "#506784", "linecolor": "#506784", "showbackground": true, "ticks": "", "zerolinecolor": "#C8D4E3", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "#f2f5fa", "line": {"width": 0}, "opacity": 0.4}, "annotationdefaults": {"arrowcolor": "#f2f5fa", "arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "rgb(17,17,17)", "landcolor": "rgb(17,17,17)", "subunitcolor": "#506784", "showland": true, "showlakes": true, "lakecolor": "rgb(17,17,17)"}, "title": {"x": 0.05}, "updatemenudefaults": {"bgcolor": "#506784", "borderwidth": 0}, "sliderdefaults": {"bgcolor": "#C8D4E3", "borderwidth": 1, "bordercolor": "rgb(17,17,17)", "tickwidth": 0}, "mapbox": {"style": "dark"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "scatter": [{"marker": {"line": {"color": "#283442"}}, "type": "scatter"}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "bar": [{"marker": {"line": {"color": "rgb(17,17,17)", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattergl": [{"marker": {"line": {"color": "#283442"}}, "type": "scattergl"}], "scatter3d": [{"type": "scatter3d", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}, "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "carpet": [{"aaxis": {"endlinecolor": "#A2B1C6", "gridcolor": "#506784", "linecolor": "#506784", "minorgridcolor": "#506784", "startlinecolor": "#A2B1C6"}, "baxis": {"endlinecolor": "#A2B1C6", "gridcolor": "#506784", "linecolor": "#506784", "minorgridcolor": "#506784", "startlinecolor": "#A2B1C6"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "#506784"}, "line": {"color": "rgb(17,17,17)"}}, "header": {"fill": {"color": "#2a3f5f"}, "line": {"color": "rgb(17,17,17)"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "rgb(17,17,17)", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file diff --git a/plotly/package_data/templates/plotly_v4_colors.json b/plotly/package_data/templates/plotly_v4_colors.json deleted file mode 100644 index 2bec43ee816..00000000000 --- a/plotly/package_data/templates/plotly_v4_colors.json +++ /dev/null @@ -1 +0,0 @@ -{"layout": {"colorscale": {"sequential": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}, "colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52"]}, "data": {"heatmap": [{"colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "type": "heatmap"}], "histogram2d": [{"colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "type": "histogram2d"}], "histogram2dcontour": [{"colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "type": "histogram2dcontour"}], "contour": [{"colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "type": "contour"}]}} \ No newline at end of file diff --git a/plotly/package_data/templates/plotly_white.json b/plotly/package_data/templates/plotly_white.json index 754523c79d6..e170444c68a 100644 --- a/plotly/package_data/templates/plotly_white.json +++ b/plotly/package_data/templates/plotly_white.json @@ -1 +1 @@ -{"layout": {"colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#19d3f3", "#e763fa", "#FECB52", "#FFA15A", "#FF6692", "#B6E880"], "font": {"color": "#2a3f5f"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "white", "polar": {"bgcolor": "white", "angularaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": ""}, "radialaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": ""}}, "ternary": {"bgcolor": "white", "aaxis": {"gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": ""}, "baxis": {"gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": ""}, "caxis": {"gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": ""}}, "colorscale": {"sequential": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]], "sequentialminus": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]], "diverging": [[0, "#8e0152"], [0.1, "#c51b7d"], [0.2, "#de77ae"], [0.3, "#f1b6da"], [0.4, "#fde0ef"], [0.5, "#f7f7f7"], [0.6, "#e6f5d0"], [0.7, "#b8e186"], [0.8, "#7fbc41"], [0.9, "#4d9221"], [1, "#276419"]]}, "xaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "", "zerolinecolor": "#EBF0F8", "automargin": true, "zerolinewidth": 2}, "yaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "", "zerolinecolor": "#EBF0F8", "automargin": true, "zerolinewidth": 2}, "scene": {"xaxis": {"backgroundcolor": "white", "gridcolor": "#DFE8F3", "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8", "gridwidth": 2}, "yaxis": {"backgroundcolor": "white", "gridcolor": "#DFE8F3", "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8", "gridwidth": 2}, "zaxis": {"backgroundcolor": "white", "gridcolor": "#DFE8F3", "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "#506784", "line": {"width": 0}, "opacity": 0.4}, "annotationdefaults": {"arrowcolor": "#506784", "arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "white", "landcolor": "white", "subunitcolor": "#C8D4E3", "showland": true, "showlakes": true, "lakecolor": "white"}, "title": {"x": 0.05}, "mapbox": {"style": "light"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0508b8"], [0.0893854748603352, "#1910d8"], [0.1787709497206704, "#3c19f0"], [0.2681564245810056, "#6b1cfb"], [0.3575418994413408, "#981cfd"], [0.44692737430167595, "#bf1cfd"], [0.5363128491620112, "#dd2bfd"], [0.6256983240223464, "#f246fe"], [0.7150837988826816, "#fc67fd"], [0.8044692737430168, "#fe88fc"], [0.8938547486033519, "#fea5fd"], [0.9832402234636871, "#febefe"], [1.0, "#fec3fe"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "bar": [{"marker": {"line": {"color": "white", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatter3d": [{"type": "scatter3d", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "carpet": [{"aaxis": {"endlinecolor": "#2a3f5f", "gridcolor": "#C8D4E3", "linecolor": "#C8D4E3", "minorgridcolor": "#C8D4E3", "startlinecolor": "#2a3f5f"}, "baxis": {"endlinecolor": "#2a3f5f", "gridcolor": "#C8D4E3", "linecolor": "#C8D4E3", "minorgridcolor": "#C8D4E3", "startlinecolor": "#2a3f5f"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "#EBF0F8"}, "line": {"color": "white"}}, "header": {"fill": {"color": "#C8D4E3"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "white", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file +{"layout": {"colorway": ["#636efa", "#EF553B", "#00cc96", "#ab63fa", "#FFA15A", "#19d3f3", "#FF6692", "#B6E880", "#FF97FF", "#FECB52"], "font": {"color": "#2a3f5f"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "white", "polar": {"bgcolor": "white", "angularaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": ""}, "radialaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": ""}}, "ternary": {"bgcolor": "white", "aaxis": {"gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": ""}, "baxis": {"gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": ""}, "caxis": {"gridcolor": "#DFE8F3", "linecolor": "#A2B1C6", "ticks": ""}}, "colorscale": {"sequential": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "sequentialminus": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]], "diverging": [[0, "#8e0152"], [0.1, "#c51b7d"], [0.2, "#de77ae"], [0.3, "#f1b6da"], [0.4, "#fde0ef"], [0.5, "#f7f7f7"], [0.6, "#e6f5d0"], [0.7, "#b8e186"], [0.8, "#7fbc41"], [0.9, "#4d9221"], [1, "#276419"]]}, "xaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "", "zerolinecolor": "#EBF0F8", "automargin": true, "zerolinewidth": 2}, "yaxis": {"gridcolor": "#EBF0F8", "linecolor": "#EBF0F8", "ticks": "", "zerolinecolor": "#EBF0F8", "automargin": true, "zerolinewidth": 2}, "scene": {"xaxis": {"backgroundcolor": "white", "gridcolor": "#DFE8F3", "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8", "gridwidth": 2}, "yaxis": {"backgroundcolor": "white", "gridcolor": "#DFE8F3", "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8", "gridwidth": 2}, "zaxis": {"backgroundcolor": "white", "gridcolor": "#DFE8F3", "linecolor": "#EBF0F8", "showbackground": true, "ticks": "", "zerolinecolor": "#EBF0F8", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "#506784", "line": {"width": 0}, "opacity": 0.4}, "annotationdefaults": {"arrowcolor": "#506784", "arrowhead": 0, "arrowwidth": 1}, "geo": {"bgcolor": "white", "landcolor": "white", "subunitcolor": "#C8D4E3", "showland": true, "showlakes": true, "lakecolor": "white"}, "title": {"x": 0.05}, "mapbox": {"style": "light"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "ticks": ""}, "colorscale": [[0.0, "#0d0887"], [0.1111111111111111, "#46039f"], [0.2222222222222222, "#7201a8"], [0.3333333333333333, "#9c179e"], [0.4444444444444444, "#bd3786"], [0.5555555555555556, "#d8576b"], [0.6666666666666666, "#ed7953"], [0.7777777777777778, "#fb9f3a"], [0.8888888888888888, "#fdca26"], [1.0, "#f0f921"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "ticks": ""}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "bar": [{"marker": {"line": {"color": "white", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatter3d": [{"type": "scatter3d", "line": {"colorbar": {"outlinewidth": 0, "ticks": ""}}, "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "ticks": ""}}}], "carpet": [{"aaxis": {"endlinecolor": "#2a3f5f", "gridcolor": "#C8D4E3", "linecolor": "#C8D4E3", "minorgridcolor": "#C8D4E3", "startlinecolor": "#2a3f5f"}, "baxis": {"endlinecolor": "#2a3f5f", "gridcolor": "#C8D4E3", "linecolor": "#C8D4E3", "minorgridcolor": "#C8D4E3", "startlinecolor": "#2a3f5f"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "#EBF0F8"}, "line": {"color": "white"}}, "header": {"fill": {"color": "#C8D4E3"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "white", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file diff --git a/plotly/package_data/templates/seaborn.json b/plotly/package_data/templates/seaborn.json index 30be664ef06..53daf56d134 100644 --- a/plotly/package_data/templates/seaborn.json +++ b/plotly/package_data/templates/seaborn.json @@ -1 +1 @@ -{"layout": {"colorway": ["rgb(76,114,176)", "rgb(221,132,82)", "rgb(85,168,104)", "rgb(196,78,82)", "rgb(129,114,179)", "rgb(147,120,96)", "rgb(218,139,195)", "rgb(140,140,140)", "rgb(204,185,116)", "rgb(100,181,205)"], "font": {"color": "rgb(36,36,36)"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "rgb(234,234,242)", "polar": {"bgcolor": "rgb(234,234,242)", "angularaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "radialaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}}, "ternary": {"bgcolor": "rgb(234,234,242)", "aaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "baxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "caxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}}, "colorscale": {"sequential": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]], "sequentialminus": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}, "xaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": "", "zerolinecolor": "white", "automargin": true}, "yaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": "", "zerolinecolor": "white", "automargin": true}, "scene": {"xaxis": {"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "yaxis": {"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "zaxis": {"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "rgb(67,103,167)", "line": {"width": 0}, "opacity": 0.5}, "annotationdefaults": {"arrowcolor": "rgb(67,103,167)"}, "geo": {"bgcolor": "white", "landcolor": "rgb(234,234,242)", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "bar": [{"marker": {"line": {"color": "rgb(234,234,242)", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatter3d": [{"type": "scatter3d", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "carpet": [{"aaxis": {"endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)"}, "baxis": {"endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "rgb(231,231,240)"}, "line": {"color": "white"}}, "header": {"fill": {"color": "rgb(183,183,191)"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "rgb(234,234,242)", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file +{"layout": {"colorway": ["rgb(76,114,176)", "rgb(221,132,82)", "rgb(85,168,104)", "rgb(196,78,82)", "rgb(129,114,179)", "rgb(147,120,96)", "rgb(218,139,195)", "rgb(140,140,140)", "rgb(204,185,116)", "rgb(100,181,205)"], "font": {"color": "rgb(36,36,36)"}, "hovermode": "closest", "hoverlabel": {"align": "left"}, "paper_bgcolor": "white", "plot_bgcolor": "rgb(234,234,242)", "polar": {"bgcolor": "rgb(234,234,242)", "angularaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "radialaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}}, "ternary": {"bgcolor": "rgb(234,234,242)", "aaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "baxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}, "caxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": ""}}, "colorscale": {"sequential": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]], "sequentialminus": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}, "xaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": "", "zerolinecolor": "white", "automargin": true}, "yaxis": {"gridcolor": "white", "linecolor": "white", "showgrid": true, "ticks": "", "zerolinecolor": "white", "automargin": true}, "scene": {"xaxis": {"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "yaxis": {"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}, "zaxis": {"backgroundcolor": "rgb(234,234,242)", "gridcolor": "white", "linecolor": "white", "showbackground": true, "showgrid": true, "ticks": "", "zerolinecolor": "white", "gridwidth": 2}}, "shapedefaults": {"fillcolor": "rgb(67,103,167)", "line": {"width": 0}, "opacity": 0.5}, "annotationdefaults": {"arrowcolor": "rgb(67,103,167)"}, "geo": {"bgcolor": "white", "landcolor": "rgb(234,234,242)", "subunitcolor": "white", "showland": true, "showlakes": true, "lakecolor": "white"}}, "data": {"histogram2dcontour": [{"type": "histogram2dcontour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "choropleth": [{"type": "choropleth", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "histogram2d": [{"type": "histogram2d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "heatmap": [{"type": "heatmap", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "heatmapgl": [{"type": "heatmapgl", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "contourcarpet": [{"type": "contourcarpet", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "contour": [{"type": "contour", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}, "colorscale": [[0.0, "rgb(2,4,25)"], [0.06274509803921569, "rgb(24,15,41)"], [0.12549019607843137, "rgb(47,23,57)"], [0.18823529411764706, "rgb(71,28,72)"], [0.25098039215686274, "rgb(97,30,82)"], [0.3137254901960784, "rgb(123,30,89)"], [0.3764705882352941, "rgb(150,27,91)"], [0.4392156862745098, "rgb(177,22,88)"], [0.5019607843137255, "rgb(203,26,79)"], [0.5647058823529412, "rgb(223,47,67)"], [0.6274509803921569, "rgb(236,76,61)"], [0.6901960784313725, "rgb(242,107,73)"], [0.7529411764705882, "rgb(244,135,95)"], [0.8156862745098039, "rgb(245,162,122)"], [0.8784313725490196, "rgb(246,188,153)"], [0.9411764705882353, "rgb(247,212,187)"], [1.0, "rgb(250,234,220)"]]}], "surface": [{"type": "surface", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "mesh3d": [{"type": "mesh3d", "colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}], "scatter": [{"type": "scatter", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "parcoords": [{"type": "parcoords", "line": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatterpolargl": [{"type": "scatterpolargl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "bar": [{"marker": {"line": {"color": "rgb(234,234,242)", "width": 0.5}}, "type": "bar"}], "scattergeo": [{"type": "scattergeo", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatterpolar": [{"type": "scatterpolar", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "histogram": [{"type": "histogram", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scattergl": [{"type": "scattergl", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatter3d": [{"type": "scatter3d", "line": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}, "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scattermapbox": [{"type": "scattermapbox", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scatterternary": [{"type": "scatterternary", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "scattercarpet": [{"type": "scattercarpet", "marker": {"colorbar": {"outlinewidth": 0, "tickcolor": "rgb(36,36,36)", "ticklen": 8, "ticks": "outside", "tickwidth": 2}}}], "carpet": [{"aaxis": {"endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)"}, "baxis": {"endlinecolor": "rgb(36,36,36)", "gridcolor": "white", "linecolor": "white", "minorgridcolor": "white", "startlinecolor": "rgb(36,36,36)"}, "type": "carpet"}], "table": [{"cells": {"fill": {"color": "rgb(231,231,240)"}, "line": {"color": "white"}}, "header": {"fill": {"color": "rgb(183,183,191)"}, "line": {"color": "white"}}, "type": "table"}], "barpolar": [{"marker": {"line": {"color": "rgb(234,234,242)", "width": 0.5}}, "type": "barpolar"}]}} \ No newline at end of file diff --git a/plotly/plotly/__init__.py b/plotly/plotly/__init__.py index ebc18caf8f2..fe71bf4ac05 100644 --- a/plotly/plotly/__init__.py +++ b/plotly/plotly/__init__.py @@ -1,8 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('plotly') - from chart_studio.plotly import * \ No newline at end of file +from _plotly_future_ import _chart_studio_error +_chart_studio_error('plotly') diff --git a/plotly/plotly/chunked_requests.py b/plotly/plotly/chunked_requests.py index a2ec4e4179b..971501a06b4 100644 --- a/plotly/plotly/chunked_requests.py +++ b/plotly/plotly/chunked_requests.py @@ -1,5 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _chart_studio_warning -_chart_studio_warning('plotly.chunked_requests') -from chart_studio.plotly.chunked_requests import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('plotly.chunked_requests') diff --git a/plotly/presentation_objs.py b/plotly/presentation_objs.py index d176ccc1de0..6e9ed0186bd 100644 --- a/plotly/presentation_objs.py +++ b/plotly/presentation_objs.py @@ -1,5 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _chart_studio_warning -_chart_studio_warning('presentation_objs') -from chart_studio.presentation_objs import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('presentation_objs') diff --git a/plotly/session.py b/plotly/session.py index 410e26ff7d5..cd5d3cba005 100644 --- a/plotly/session.py +++ b/plotly/session.py @@ -1,9 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('session') - from chart_studio.session import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('session') diff --git a/plotly/subplots.py b/plotly/subplots.py index dcb94138b03..5bc933cba1c 100644 --- a/plotly/subplots.py +++ b/plotly/subplots.py @@ -313,8 +313,6 @@ def make_subplots( ... cols=[1, 2, 1, 2]) """ - _validate_v4_subplots('plotly.subplots.make_subplots') - import plotly.graph_objs as go # Handle backward compatibility @@ -793,20 +791,6 @@ def _checks(item, defaults): return fig -def _validate_v4_subplots(method_name): - # Make sure we're in future subplots mode - from _plotly_future_ import _future_flags - if 'v4_subplots' not in _future_flags: - raise ValueError(""" -{method_name} may only be used in the -v4_subplots _plotly_future_ mode. To try it out, run - ->>> from _plotly_future_ import v4_subplots - -before importing plotly. -""".format(method_name=method_name)) - - def _configure_shared_axes(layout, grid_ref, specs, x_or_y, shared, row_dir): rows = len(grid_ref) cols = len(grid_ref[0]) @@ -1346,18 +1330,6 @@ def _set_trace_grid_reference( def _get_grid_subplot(fig, row, col, secondary_y=False): - # Make sure we're in future subplots mode - from _plotly_future_ import _future_flags - if 'v4_subplots' not in _future_flags: - raise ValueError(""" -plotly.subplots.get_subplots may only be used in the -v4_subplots _plotly_future_ mode. To try it out, run - ->>> from _plotly_future_ import v4_subplots - -before importing plotly. - """) - try: grid_ref = fig._grid_ref except AttributeError: diff --git a/plotly/tests/test_core/test_figure_messages/test_add_traces.py b/plotly/tests/test_core/test_figure_messages/test_add_traces.py index 839cc1ff2ff..3d85dceee7b 100644 --- a/plotly/tests/test_core/test_figure_messages/test_add_traces.py +++ b/plotly/tests/test_core/test_figure_messages/test_add_traces.py @@ -32,9 +32,8 @@ def test_add_trace(self): self.assertEqual(self.figure.data[-1].arrangement, 'snap') # Check message - new_uid = self.figure.data[-1].uid self.figure._send_addTraces_msg.assert_called_once_with( - [{'type': 'sankey', 'arrangement': 'snap', 'uid': new_uid}]) + [{'type': 'sankey', 'arrangement': 'snap'}]) def test_add_traces(self): @@ -55,8 +54,6 @@ def test_add_traces(self): new_uid2 = self.figure.data[-1].uid self.figure._send_addTraces_msg.assert_called_once_with( [{'type': 'sankey', - 'arrangement': 'snap', - 'uid': new_uid1}, + 'arrangement': 'snap'}, {'type': 'histogram2dcontour', - 'line': {'color': 'cyan'}, - 'uid': new_uid2}]) + 'line': {'color': 'cyan'}}]) diff --git a/plotly/tests/test_core/test_graph_objs/test_figure.py b/plotly/tests/test_core/test_graph_objs/test_figure.py index 8e39160ff4e..c38cef4a9fc 100644 --- a/plotly/tests/test_core/test_graph_objs/test_figure.py +++ b/plotly/tests/test_core/test_graph_objs/test_figure.py @@ -1,11 +1,10 @@ from __future__ import absolute_import -from unittest import TestCase - import plotly.graph_objs as go +from plotly.tests.utils import TestCaseNoTemplate -class FigureTest(TestCase): +class FigureTest(TestCaseNoTemplate): def test_instantiation(self): diff --git a/plotly/tests/test_core/test_graph_objs/test_figure_properties.py b/plotly/tests/test_core/test_graph_objs/test_figure_properties.py index 4df64690b5f..f601b0f7070 100644 --- a/plotly/tests/test_core/test_graph_objs/test_figure_properties.py +++ b/plotly/tests/test_core/test_graph_objs/test_figure_properties.py @@ -1,11 +1,14 @@ from unittest import TestCase import plotly.graph_objs as go from nose.tools import raises - +import plotly.io as pio class TestFigureProperties(TestCase): def setUp(self): + # Disable default template + pio.templates.default = None + # Construct initial scatter object self.figure = go.Figure(data=[go.Scatter(y=[3, 2, 1], marker={'color': 'green'})], @@ -14,6 +17,10 @@ def setUp(self): layout={'yaxis': {'title': 'f1'}})]) + def tearDown(self): + # Reenable default template + pio.templates.default = 'plotly' + def test_attr_access(self): scatt_uid = self.figure.data[0].uid self.assertEqual(self.figure.data, @@ -174,8 +181,6 @@ def test_update_data_empty(self): # Compute expected figure dict (pop uids for comparison) result = figure.to_dict() - del result['data'][0]['uid'] - del result['data'][1]['uid'] # Perform comparison self.assertEqual(result, expected) diff --git a/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py b/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py index 1530db58ab8..cff47b2aec9 100644 --- a/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py +++ b/plotly/tests/test_core/test_graph_objs/test_layout_subplots.py @@ -1,6 +1,7 @@ from unittest import TestCase import plotly.graph_objs as go from nose.tools import raises +import plotly.io as pio class TestLayoutSubplots(TestCase): @@ -9,6 +10,11 @@ def setUp(self): # Construct initial scatter object self.layout = go.Layout() + pio.templates.default = None + + def tearDown(self): + pio.templates.default = 'plotly' + def test_initial_access_subplots(self): # It should be possible to access base subplots initially @@ -217,7 +223,6 @@ def test_bug_1462(self): layout_dict = { 'grid': {'xaxes': ['x', 'x2'], 'yaxes': ['y']}, - # 'xaxis': {'title': 'total_bill'}, 'xaxis2': {'matches': 'x', 'title': {'text': 'total_bill'}} } diff --git a/plotly/tests/test_core/test_graph_objs/test_template.py b/plotly/tests/test_core/test_graph_objs/test_template.py index a5068e15b43..53560452e2e 100644 --- a/plotly/tests/test_core/test_graph_objs/test_template.py +++ b/plotly/tests/test_core/test_graph_objs/test_template.py @@ -6,6 +6,7 @@ import plotly.io as pio import plotly.graph_objs as go +from plotly.tests.utils import TestCaseNoTemplate class TemplateTest(TestCase): @@ -15,6 +16,7 @@ class TemplateTest(TestCase): def setUp(self): pio.templates['test_template'] = { 'layout': {'font': {'family': 'Rockwell'}}} + pio.templates.default = None def tearDown(self): try: @@ -22,6 +24,8 @@ def tearDown(self): except KeyError: pass + pio.templates.default = 'plotly' + # template graph_objs tests # ------------------------- def test_starts_as_empty(self): @@ -166,7 +170,7 @@ def test_template_iter(self): self.assertIn('test_template', set(pio.templates)) -class TestToTemplated(TestCase): +class TestToTemplated(TestCaseNoTemplate): def test_move_layout_nested_properties(self): fig = go.Figure(layout={'font': {'family': 'Courier New'}, diff --git a/plotly/tests/test_core/test_graph_objs/test_to_ordered_dict.py b/plotly/tests/test_core/test_graph_objs/test_to_ordered_dict.py index 20593f82392..9f14b46c601 100644 --- a/plotly/tests/test_core/test_graph_objs/test_to_ordered_dict.py +++ b/plotly/tests/test_core/test_graph_objs/test_to_ordered_dict.py @@ -1,11 +1,11 @@ from __future__ import absolute_import -from unittest import TestCase import plotly.graph_objs as go from collections import OrderedDict +from plotly.tests.utils import TestCaseNoTemplate -class FigureTest(TestCase): +class FigureTest(TestCaseNoTemplate): def test_to_ordered_dict(self): diff --git a/plotly/tests/test_core/test_graph_reference/test_graph_reference.py b/plotly/tests/test_core/test_graph_reference/test_graph_reference.py index 05db9127ad3..f16d1521673 100644 --- a/plotly/tests/test_core/test_graph_reference/test_graph_reference.py +++ b/plotly/tests/test_core/test_graph_reference/test_graph_reference.py @@ -4,40 +4,15 @@ """ from __future__ import absolute_import -import os from unittest import TestCase -from nose.plugins.attrib import attr -import json as _json - from plotly import graph_reference as gr -from plotly.api import v2 from plotly.graph_reference import string_to_class_name, get_role -from plotly.tests.utils import PlotlyTestCase FAKE_API_DOMAIN = 'https://api.am.not.here.ly' -#class TestGraphReferenceCaching(PlotlyTestCase): - - # @attr('slow') - # def test_default_schema_is_up_to_date(self): - # response = v2.plot_schema.retrieve('') - # schema = response.json()['schema'] - - # path = os.path.join('package_data', 'plot-schema.json') - # s = resource_string('plotly', path).decode('utf-8') - # default_schema = _json.loads(s) - - # msg = ( - # 'The default, hard-coded plot schema we ship with pip is out of ' - # 'sync with the prod plot schema!\n' - # 'Run `make update_default_schema` to fix it!' - # ) - # self.assertEqual(schema, default_schema, msg=msg) - - -class TestStringToClass(PlotlyTestCase): +class TestStringToClass(TestCase): def test_capitalize_first_letter(self): diff --git a/plotly/tests/test_core/test_offline/test_offline.py b/plotly/tests/test_core/test_offline/test_offline.py index ea3d1e155c1..540ba7b3c4d 100644 --- a/plotly/tests/test_core/test_offline/test_offline.py +++ b/plotly/tests/test_core/test_offline/test_offline.py @@ -11,6 +11,7 @@ import json as _json import plotly +import plotly.io as pio import json @@ -76,8 +77,12 @@ def tearDown(self): class PlotlyOfflineTestCase(PlotlyOfflineBaseTestCase): + def setUp(self): - pass + pio.templates.default = None + + def tearDown(self): + pio.templates.default = 'plotly' def _read_html(self, file_url): """ Read and return the HTML contents from a file_url diff --git a/plotly/tests/test_core/test_subplots/test_get_subplot.py b/plotly/tests/test_core/test_subplots/test_get_subplot.py index 412657e40aa..cf98eaadd16 100644 --- a/plotly/tests/test_core/test_subplots/test_get_subplot.py +++ b/plotly/tests/test_core/test_subplots/test_get_subplot.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from _plotly_future_ import _future_flags from unittest import TestCase from plotly.graph_objs import Figure @@ -9,13 +8,6 @@ class TestGetSubplot(TestCase): - def setUp(self): - # Use v4_subplots mode - _future_flags.add('v4_subplots') - - def tearDown(self): - _future_flags.remove('v4_subplots') - def test_get_subplot(self): # Make Figure with subplot types fig = subplots.make_subplots( diff --git a/plotly/tests/test_core/test_subplots/test_make_subplots.py b/plotly/tests/test_core/test_subplots/test_make_subplots.py index 9d97184cd98..9317490e12a 100644 --- a/plotly/tests/test_core/test_subplots/test_make_subplots.py +++ b/plotly/tests/test_core/test_subplots/test_make_subplots.py @@ -1,5 +1,4 @@ from __future__ import absolute_import -from _plotly_future_ import _future_flags from unittest import TestCase from plotly.graph_objs import (Annotation, Annotations, Data, Figure, Font, @@ -15,13 +14,6 @@ class TestMakeSubplots(TestCase): In version 4, change this to test plotly.subplots.make_subplots directly """ - def setUp(self): - # Use v4_subplots mode - _future_flags.add('v4_subplots') - - def tearDown(self): - _future_flags.remove('v4_subplots') - def test_non_integer_rows(self): with self.assertRaises(Exception): tls.make_subplots(rows=2.1) diff --git a/plotly/tests/test_core/test_tools/test_configuration.py b/plotly/tests/test_core/test_tools/test_configuration.py deleted file mode 100644 index 0e657638101..00000000000 --- a/plotly/tests/test_core/test_tools/test_configuration.py +++ /dev/null @@ -1,16 +0,0 @@ -from __future__ import absolute_import - -from unittest import TestCase - -from plotly.files import CONFIG_FILE, FILE_CONTENT -from plotly.tools import get_config_defaults - - -class TestGetConfigDefaults(TestCase): - - def test_config_dict_is_equivalent_copy(self): - - original = FILE_CONTENT[CONFIG_FILE] - copy = get_config_defaults() - self.assertIsNot(copy, original) - self.assertEqual(copy, original) diff --git a/plotly/tests/test_core/test_tools/test_file_tools.py b/plotly/tests/test_core/test_tools/test_file_tools.py deleted file mode 100644 index c0a434ca71a..00000000000 --- a/plotly/tests/test_core/test_tools/test_file_tools.py +++ /dev/null @@ -1,105 +0,0 @@ -from plotly import tools, session -from plotly.tests.utils import PlotlyTestCase - -import warnings - - -class FileToolsTest(PlotlyTestCase): - - def test_set_config_file_all_entries(self): - - # Check set_config and get_config return the same values - - domain, streaming_domain, api, sharing = ('this', 'thing', - 'that', 'private') - ssl_verify, proxy_auth, world_readable, auto_open = (True, True, - False, False) - tools.set_config_file(plotly_domain=domain, - plotly_streaming_domain=streaming_domain, - plotly_api_domain=api, - plotly_ssl_verification=ssl_verify, - plotly_proxy_authorization=proxy_auth, - world_readable=world_readable, - auto_open=auto_open) - config = tools.get_config_file() - self.assertEqual(config['plotly_domain'], domain) - self.assertEqual(config['plotly_streaming_domain'], streaming_domain) - self.assertEqual(config['plotly_api_domain'], api) - self.assertEqual(config['plotly_ssl_verification'], ssl_verify) - self.assertEqual(config['plotly_proxy_authorization'], proxy_auth) - self.assertEqual(config['world_readable'], world_readable) - self.assertEqual(config['sharing'], sharing) - self.assertEqual(config['auto_open'], auto_open) - tools.reset_config_file() - - def test_set_config_file_two_entries(self): - - # Check set_config and get_config given only two entries return the - # same values - - domain, streaming_domain = 'this', 'thing' - tools.set_config_file(plotly_domain=domain, - plotly_streaming_domain=streaming_domain) - config = tools.get_config_file() - self.assertEqual(config['plotly_domain'], domain) - self.assertEqual(config['plotly_streaming_domain'], streaming_domain) - tools.reset_config_file() - - def test_set_config_file_world_readable(self): - - # Return TypeError when world_readable type is not a bool - - kwargs = {'world_readable': 'True'} - self.assertRaises(TypeError, tools.set_config_file, **kwargs) - - def test_set_config_expected_warning_msg(self): - - # Check that UserWarning is being called with http plotly_domain - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - kwargs = {'plotly_domain': 'http://www.foo-bar.com'} - tools.set_config_file(**kwargs) - assert len(w) == 1 - assert issubclass(w[-1].category, UserWarning) - assert "plotly_domain" in str(w[-1].message) - - - def test_set_config_no_warning_msg_if_plotly_domain_is_https(self): - - # Check that no UserWarning is being called with https plotly_domain - - with warnings.catch_warnings(record=True) as w: - warnings.simplefilter("always") - kwargs = {'plotly_domain': 'https://www.foo-bar.com'} - tools.set_config_file(**kwargs) - assert len(w) == 0 - - - def test_reset_config_file(self): - - # Check reset_config and get_config return the same values - - tools.reset_config_file() - config = tools.get_config_file() - self.assertEqual(config['plotly_domain'], 'https://plot.ly') - self.assertEqual(config['plotly_streaming_domain'], 'stream.plot.ly') - - def test_get_credentials_file(self): - - # Check get_credentials returns all the keys - - original_creds = tools.get_credentials_file() - expected = ['username', 'stream_ids', 'api_key', 'proxy_username', - 'proxy_password'] - self.assertTrue(all(x in original_creds for x in expected)) - - def test_reset_credentials_file(self): - - # Check get_cred return all the keys - - tools.reset_credentials_file() - reset_creds = tools.get_credentials_file() - expected = ['username', 'stream_ids', 'api_key', 'proxy_username', - 'proxy_password'] - self.assertTrue(all(x in reset_creds for x in expected)) diff --git a/plotly/tests/test_core/test_tools/test_get_embed.py b/plotly/tests/test_core/test_tools/test_get_embed.py deleted file mode 100644 index 6b23f3aed7b..00000000000 --- a/plotly/tests/test_core/test_tools/test_get_embed.py +++ /dev/null @@ -1,45 +0,0 @@ -from __future__ import absolute_import - -from unittest import TestCase - -from nose.tools import raises - -import plotly.tools as tls -from plotly.exceptions import PlotlyError - - -def test_get_valid_embed(): - url = 'https://plot.ly/~PlotBot/82/' - tls.get_embed(url) - - -@raises(PlotlyError) -def test_get_invalid_embed(): - url = 'https://plot.ly/~PlotBot/a/' - tls.get_embed(url) - - -class TestGetEmbed(TestCase): - - def test_get_embed_url_with_share_key(self): - - # Check the embed url for url with share_key included - - get_embed_return = tls.get_embed('https://plot.ly/~neda/6572' + - '?share_key=AH4MyPlyDyDWYA2cM2kj2m') - expected_get_embed = ("").format(plotly_rest_url="https://" + - "plot.ly", - file_owner="neda", - file_id="6572", - share_key="AH4MyPlyDyDWYA2" + - "cM2kj2m", - iframe_height=525, - iframe_width="100%") - self.assertEqual(get_embed_return, expected_get_embed) diff --git a/plotly/tests/test_core/test_tools/test_get_subplots.py b/plotly/tests/test_core/test_tools/test_get_subplots.py deleted file mode 100644 index 5ae2d756f7c..00000000000 --- a/plotly/tests/test_core/test_tools/test_get_subplots.py +++ /dev/null @@ -1,649 +0,0 @@ -from __future__ import absolute_import - -from nose.tools import raises - -from plotly.graph_objs import (Data, Figure, Layout, XAxis, YAxis) -import plotly.tools as tls - - -@raises(Exception) -def test_non_integer_rows(): - tls.get_subplots(rows=2.1) - - -@raises(Exception) -def test_less_than_zero_rows(): - tls.make_subplots(rows=-2) - - -@raises(Exception) -def test_non_integer_columns(): - tls.get_subplots(columns=2/3) - - -@raises(Exception) -def test_less_than_zero_cols(): - tls.make_subplots(columns=-10) - - -@raises(Exception) -def test_wrong_kwarg(): - tls.get_subplots(stuff='no gonna work') - - -def test_get_single_plot(): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y1' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x1' - ) - ) - ) - assert tls.get_subplots() == expected - - -def test_two_row(): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y1' - ), - xaxis2=XAxis( - domain=[0.0, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x1' - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='x2' - ) - ) - ) - assert tls.get_subplots(2) == expected - - -def test_two_column(): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y1' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x1' - ), - yaxis2=YAxis( - domain=[0.0, 1.0], - anchor='x2' - ) - ) - ) - - assert tls.get_subplots(1, 2) == expected - - -def test_a_lot(): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.05714285714285713], - anchor='y1' - ), - xaxis10=XAxis( - domain=[0.3142857142857143, 0.3714285714285714], - anchor='y10' - ), - xaxis11=XAxis( - domain=[0.4714285714285714, 0.5285714285714286], - anchor='y11' - ), - xaxis12=XAxis( - domain=[0.6285714285714286, 0.6857142857142857], - anchor='y12' - ), - xaxis13=XAxis( - domain=[0.7857142857142857, 0.8428571428571429], - anchor='y13' - ), - xaxis14=XAxis( - domain=[0.9428571428571428, 1.0], - anchor='y14' - ), - xaxis15=XAxis( - domain=[0.0, 0.05714285714285713], - anchor='y15' - ), - xaxis16=XAxis( - domain=[0.15714285714285714, 0.21428571428571427], - anchor='y16' - ), - xaxis17=XAxis( - domain=[0.3142857142857143, 0.3714285714285714], - anchor='y17' - ), - xaxis18=XAxis( - domain=[0.4714285714285714, 0.5285714285714286], - anchor='y18' - ), - xaxis19=XAxis( - domain=[0.6285714285714286, 0.6857142857142857], - anchor='y19' - ), - xaxis2=XAxis( - domain=[0.15714285714285714, 0.21428571428571427], - anchor='y2' - ), - xaxis20=XAxis( - domain=[0.7857142857142857, 0.8428571428571429], - anchor='y20' - ), - xaxis21=XAxis( - domain=[0.9428571428571428, 1.0], - anchor='y21' - ), - xaxis22=XAxis( - domain=[0.0, 0.05714285714285713], - anchor='y22' - ), - xaxis23=XAxis( - domain=[0.15714285714285714, 0.21428571428571427], - anchor='y23' - ), - xaxis24=XAxis( - domain=[0.3142857142857143, 0.3714285714285714], - anchor='y24' - ), - xaxis25=XAxis( - domain=[0.4714285714285714, 0.5285714285714286], - anchor='y25' - ), - xaxis26=XAxis( - domain=[0.6285714285714286, 0.6857142857142857], - anchor='y26' - ), - xaxis27=XAxis( - domain=[0.7857142857142857, 0.8428571428571429], - anchor='y27' - ), - xaxis28=XAxis( - domain=[0.9428571428571428, 1.0], - anchor='y28' - ), - xaxis3=XAxis( - domain=[0.3142857142857143, 0.3714285714285714], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.4714285714285714, 0.5285714285714286], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.6285714285714286, 0.6857142857142857], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7857142857142857, 0.8428571428571429], - anchor='y6' - ), - xaxis7=XAxis( - domain=[0.9428571428571428, 1.0], - anchor='y7' - ), - xaxis8=XAxis( - domain=[0.0, 0.05714285714285713], - anchor='y8' - ), - xaxis9=XAxis( - domain=[0.15714285714285714, 0.21428571428571427], - anchor='y9' - ), - yaxis1=YAxis( - domain=[0.0, 0.1375], - anchor='x1' - ), - yaxis10=YAxis( - domain=[0.2875, 0.425], - anchor='x10' - ), - yaxis11=YAxis( - domain=[0.2875, 0.425], - anchor='x11' - ), - yaxis12=YAxis( - domain=[0.2875, 0.425], - anchor='x12' - ), - yaxis13=YAxis( - domain=[0.2875, 0.425], - anchor='x13' - ), - yaxis14=YAxis( - domain=[0.2875, 0.425], - anchor='x14' - ), - yaxis15=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x15' - ), - yaxis16=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x16' - ), - yaxis17=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x17' - ), - yaxis18=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x18' - ), - yaxis19=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x19' - ), - yaxis2=YAxis( - domain=[0.0, 0.1375], - anchor='x2' - ), - yaxis20=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x20' - ), - yaxis21=YAxis( - domain=[0.575, 0.7124999999999999], - anchor='x21' - ), - yaxis22=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x22' - ), - yaxis23=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x23' - ), - yaxis24=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x24' - ), - yaxis25=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x25' - ), - yaxis26=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x26' - ), - yaxis27=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x27' - ), - yaxis28=YAxis( - domain=[0.8624999999999999, 1.0], - anchor='x28' - ), - yaxis3=YAxis( - domain=[0.0, 0.1375], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.1375], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.1375], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.0, 0.1375], - anchor='x6' - ), - yaxis7=YAxis( - domain=[0.0, 0.1375], - anchor='x7' - ), - yaxis8=YAxis( - domain=[0.2875, 0.425], - anchor='x8' - ), - yaxis9=YAxis( - domain=[0.2875, 0.425], - anchor='x9' - ) - ) - ) - - fig = tls.get_subplots(4, 7, horizontal_spacing=0.1, vertical_spacing=0.15) - - assert fig == expected - - -def test_spacing(): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.3], - anchor='y1' - ), - xaxis2=XAxis( - domain=[0.35, 0.6499999999999999], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.0, 0.3], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.35, 0.6499999999999999], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7, 1.0], - anchor='y6' - ), - yaxis1=YAxis( - domain=[0.0, 0.45], - anchor='x1' - ), - yaxis2=YAxis( - domain=[0.0, 0.45], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.45], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.55, 1.0], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.55, 1.0], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.55, 1.0], - anchor='x6' - ) - ) - ) - - fig = tls.get_subplots(2, 3, - horizontal_spacing=.05, - vertical_spacing=.1) - - assert fig == expected - - -def test_default_spacing(): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.16799999999999998], - anchor='y1' - ), - xaxis10=XAxis( - domain=[0.832, 1.0], - anchor='y10' - ), - xaxis11=XAxis( - domain=[0.0, 0.16799999999999998], - anchor='y11' - ), - xaxis12=XAxis( - domain=[0.208, 0.376], - anchor='y12' - ), - xaxis13=XAxis( - domain=[0.416, 0.584], - anchor='y13' - ), - xaxis14=XAxis( - domain=[0.624, 0.792], - anchor='y14' - ), - xaxis15=XAxis( - domain=[0.832, 1.0], - anchor='y15' - ), - xaxis16=XAxis( - domain=[0.0, 0.16799999999999998], - anchor='y16' - ), - xaxis17=XAxis( - domain=[0.208, 0.376], - anchor='y17' - ), - xaxis18=XAxis( - domain=[0.416, 0.584], - anchor='y18' - ), - xaxis19=XAxis( - domain=[0.624, 0.792], - anchor='y19' - ), - xaxis2=XAxis( - domain=[0.208, 0.376], - anchor='y2' - ), - xaxis20=XAxis( - domain=[0.832, 1.0], - anchor='y20' - ), - xaxis21=XAxis( - domain=[0.0, 0.16799999999999998], - anchor='y21' - ), - xaxis22=XAxis( - domain=[0.208, 0.376], - anchor='y22' - ), - xaxis23=XAxis( - domain=[0.416, 0.584], - anchor='y23' - ), - xaxis24=XAxis( - domain=[0.624, 0.792], - anchor='y24' - ), - xaxis25=XAxis( - domain=[0.832, 1.0], - anchor='y25' - ), - xaxis26=XAxis( - domain=[0.0, 0.16799999999999998], - anchor='y26' - ), - xaxis27=XAxis( - domain=[0.208, 0.376], - anchor='y27' - ), - xaxis28=XAxis( - domain=[0.416, 0.584], - anchor='y28' - ), - xaxis29=XAxis( - domain=[0.624, 0.792], - anchor='y29' - ), - xaxis3=XAxis( - domain=[0.416, 0.584], - anchor='y3' - ), - xaxis30=XAxis( - domain=[0.832, 1.0], - anchor='y30' - ), - xaxis4=XAxis( - domain=[0.624, 0.792], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.832, 1.0], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.0, 0.16799999999999998], - anchor='y6' - ), - xaxis7=XAxis( - domain=[0.208, 0.376], - anchor='y7' - ), - xaxis8=XAxis( - domain=[0.416, 0.584], - anchor='y8' - ), - xaxis9=XAxis( - domain=[0.624, 0.792], - anchor='y9' - ), - yaxis1=YAxis( - domain=[0.0, 0.125], - anchor='x1' - ), - yaxis10=YAxis( - domain=[0.175, 0.3], - anchor='x10' - ), - yaxis11=YAxis( - domain=[0.35, 0.475], - anchor='x11' - ), - yaxis12=YAxis( - domain=[0.35, 0.475], - anchor='x12' - ), - yaxis13=YAxis( - domain=[0.35, 0.475], - anchor='x13' - ), - yaxis14=YAxis( - domain=[0.35, 0.475], - anchor='x14' - ), - yaxis15=YAxis( - domain=[0.35, 0.475], - anchor='x15' - ), - yaxis16=YAxis( - domain=[0.5249999999999999, 0.6499999999999999], - anchor='x16' - ), - yaxis17=YAxis( - domain=[0.5249999999999999, 0.6499999999999999], - anchor='x17' - ), - yaxis18=YAxis( - domain=[0.5249999999999999, 0.6499999999999999], - anchor='x18' - ), - yaxis19=YAxis( - domain=[0.5249999999999999, 0.6499999999999999], - anchor='x19' - ), - yaxis2=YAxis( - domain=[0.0, 0.125], - anchor='x2' - ), - yaxis20=YAxis( - domain=[0.5249999999999999, 0.6499999999999999], - anchor='x20' - ), - yaxis21=YAxis( - domain=[0.7, 0.825], - anchor='x21' - ), - yaxis22=YAxis( - domain=[0.7, 0.825], - anchor='x22' - ), - yaxis23=YAxis( - domain=[0.7, 0.825], - anchor='x23' - ), - yaxis24=YAxis( - domain=[0.7, 0.825], - anchor='x24' - ), - yaxis25=YAxis( - domain=[0.7, 0.825], - anchor='x25' - ), - yaxis26=YAxis( - domain=[0.875, 1.0], - anchor='x26' - ), - yaxis27=YAxis( - domain=[0.875, 1.0], - anchor='x27' - ), - yaxis28=YAxis( - domain=[0.875, 1.0], - anchor='x28' - ), - yaxis29=YAxis( - domain=[0.875, 1.0], - anchor='x29' - ), - yaxis3=YAxis( - domain=[0.0, 0.125], - anchor='x3' - ), - yaxis30=YAxis( - domain=[0.875, 1.0], - anchor='x30' - ), - yaxis4=YAxis( - domain=[0.0, 0.125], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.125], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.175, 0.3], - anchor='x6' - ), - yaxis7=YAxis( - domain=[0.175, 0.3], - anchor='x7' - ), - yaxis8=YAxis( - domain=[0.175, 0.3], - anchor='x8' - ), - yaxis9=YAxis( - domain=[0.175, 0.3], - anchor='x9' - ) - ) - ) - - fig = tls.get_subplots(rows=6, columns=5) - - assert fig == expected diff --git a/plotly/tests/test_core/test_tools/test_make_subplots.py b/plotly/tests/test_core/test_tools/test_make_subplots.py deleted file mode 100644 index 5e78e18f247..00000000000 --- a/plotly/tests/test_core/test_tools/test_make_subplots.py +++ /dev/null @@ -1,2266 +0,0 @@ -from __future__ import absolute_import - -from unittest import TestCase - -from plotly.graph_objs import (Annotation, Annotations, Data, Figure, Font, - Layout, layout, Scene, XAxis, YAxis) -import plotly.tools as tls - - -class TestMakeSubplots(TestCase): - - def test_non_integer_rows(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2.1) - - def test_less_than_zero_rows(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=-2) - - def test_non_integer_cols(self): - with self.assertRaises(Exception): - tls.make_subplots(cols=2/3) - - def test_less_than_zero_cols(self): - with self.assertRaises(Exception): - tls.make_subplots(cols=-10) - - def test_wrong_kwarg(self): - with self.assertRaises(Exception): - tls.make_subplots(stuff='no gonna work') - - def test_start_cell_wrong_values(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, cols=2, start_cell='not gonna work') - - def test_specs_wrong_type(self): - with self.assertRaises(Exception): - tls.make_subplots(specs="not going to work") - - def test_specs_wrong_inner_type(self): - with self.assertRaises(Exception): - tls.make_subplots(specs=[{}]) - - def test_specs_wrong_item_type(self): - with self.assertRaises(Exception): - tls.make_subplots(specs=[[('not', 'going to work')]]) - - def test_specs_wrong_item_key(self): - with self.assertRaises(Exception): - tls.make_subplots(specs=[{'not': "going to work"}]) - - def test_specs_underspecified(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, specs=[{}]) - tls.make_subplots(rows=2, cols=2, specs=[[{}, {}], [{}]]) - - def test_specs_overspecified(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, specs=[[{}], [{}], [{}]]) - tls.make_subplots(cols=2, specs=[{}, {}, {}]) - - def test_specs_colspan_too_big(self): - with self.assertRaises(Exception): - tls.make_subplots(cols=3, specs=[[{}, None, {'colspan': 2}]]) - - def test_specs_rowspan_too_big(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=3, specs=[[{}], [None], [{'rowspan': 2}]]) - - def test_insets_wrong_type(self): - with self.assertRaises(Exception): - tls.make_subplots(insets="not going to work") - - def test_insets_wrong_item(self): - with self.assertRaises(Exception): - tls.make_subplots(insets=[{'not': "going to work"}]) - - def test_insets_wrong_cell_row(self): - with self.assertRaises(Exception): - tls.make_subplots(insets=([{'cell': (0, 1)}])) - - def test_insets_wrong_cell_col(self): - with self.assertRaises(Exception): - tls.make_subplots(insets=([{'cell': (1, 0)}])) - - def test_column_width_not_list(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, cols=2, column_width='not gonna work') - - def test_column_width_not_list_of_correct_numbers(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, cols=2, column_width=[0]) - - def test_row_width_not_list(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, cols=2, row_width='not gonna work') - - def test_row_width_not_list_of_correct_numbers(self): - with self.assertRaises(Exception): - tls.make_subplots(rows=2, cols=2, row_width=[1]) - - def test_single_plot(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x' - ) - ) - ) - self.assertEqual(tls.make_subplots().to_plotly_json(), - expected.to_plotly_json()) - - def test_two_row(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ) - ) - ) - self.assertEqual(tls.make_subplots(rows=2).to_plotly_json(), expected.to_plotly_json()) - - def test_two_row_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=layout.XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=layout.XAxis( - domain=[0.0, 1.0], - anchor='y2' - ), - yaxis1=layout.YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=layout.YAxis( - domain=[0.575, 1.0], - anchor='x2' - ), - ) - ) - fig = tls.make_subplots(rows=2, start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_two_column(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 1.0], - anchor='x2' - ) - ) - ) - self.assertEqual(tls.make_subplots(cols=2).to_plotly_json(), expected.to_plotly_json()) - - def test_a_lot(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y' - ), - xaxis10=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y10' - ), - xaxis11=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y11' - ), - xaxis12=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y12' - ), - xaxis13=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y13' - ), - xaxis14=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y14' - ), - xaxis15=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y15' - ), - xaxis16=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y16' - ), - xaxis17=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y17' - ), - xaxis18=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y18' - ), - xaxis19=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y19' - ), - xaxis2=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y2' - ), - xaxis20=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y20' - ), - xaxis21=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y21' - ), - xaxis22=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y22' - ), - xaxis23=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y23' - ), - xaxis24=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y24' - ), - xaxis25=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y25' - ), - xaxis26=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y26' - ), - xaxis27=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y27' - ), - xaxis28=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y28' - ), - xaxis3=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y6' - ), - xaxis7=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y7' - ), - xaxis8=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y8' - ), - xaxis9=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y9' - ), - yaxis1=YAxis( - domain=[0.80625, 1.0], - anchor='x' - ), - yaxis10=YAxis( - domain=[0.5375, 0.73125], - anchor='x10' - ), - yaxis11=YAxis( - domain=[0.5375, 0.73125], - anchor='x11' - ), - yaxis12=YAxis( - domain=[0.5375, 0.73125], - anchor='x12' - ), - yaxis13=YAxis( - domain=[0.5375, 0.73125], - anchor='x13' - ), - yaxis14=YAxis( - domain=[0.5375, 0.73125], - anchor='x14' - ), - yaxis15=YAxis( - domain=[0.26875, 0.4625], - anchor='x15' - ), - yaxis16=YAxis( - domain=[0.26875, 0.4625], - anchor='x16' - ), - yaxis17=YAxis( - domain=[0.26875, 0.4625], - anchor='x17' - ), - yaxis18=YAxis( - domain=[0.26875, 0.4625], - anchor='x18' - ), - yaxis19=YAxis( - domain=[0.26875, 0.4625], - anchor='x19' - ), - yaxis2=YAxis( - domain=[0.80625, 1.0], - anchor='x2' - ), - yaxis20=YAxis( - domain=[0.26875, 0.4625], - anchor='x20' - ), - yaxis21=YAxis( - domain=[0.26875, 0.4625], - anchor='x21' - ), - yaxis22=YAxis( - domain=[0.0, 0.19375], - anchor='x22' - ), - yaxis23=YAxis( - domain=[0.0, 0.19375], - anchor='x23' - ), - yaxis24=YAxis( - domain=[0.0, 0.19375], - anchor='x24' - ), - yaxis25=YAxis( - domain=[0.0, 0.19375], - anchor='x25' - ), - yaxis26=YAxis( - domain=[0.0, 0.19375], - anchor='x26' - ), - yaxis27=YAxis( - domain=[0.0, 0.19375], - anchor='x27' - ), - yaxis28=YAxis( - domain=[0.0, 0.19375], - anchor='x28' - ), - yaxis3=YAxis( - domain=[0.80625, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.80625, 1.0], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.80625, 1.0], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.80625, 1.0], - anchor='x6' - ), - yaxis7=YAxis( - domain=[0.80625, 1.0], - anchor='x7' - ), - yaxis8=YAxis( - domain=[0.5375, 0.73125], - anchor='x8' - ), - yaxis9=YAxis( - domain=[0.5375, 0.73125], - anchor='x9' - ) - ) - ) - fig = tls.make_subplots(rows=4, cols=7) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_a_lot_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y' - ), - xaxis10=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y10' - ), - xaxis11=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y11' - ), - xaxis12=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y12' - ), - xaxis13=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y13' - ), - xaxis14=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y14' - ), - xaxis15=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y15' - ), - xaxis16=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y16' - ), - xaxis17=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y17' - ), - xaxis18=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y18' - ), - xaxis19=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y19' - ), - xaxis2=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y2' - ), - xaxis20=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y20' - ), - xaxis21=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y21' - ), - xaxis22=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y22' - ), - xaxis23=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y23' - ), - xaxis24=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y24' - ), - xaxis25=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y25' - ), - xaxis26=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y26' - ), - xaxis27=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y27' - ), - xaxis28=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y28' - ), - xaxis3=XAxis( - domain=[0.29387755102040813, 0.4122448979591836], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.4408163265306122, 0.5591836734693877], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.5877551020408163, 0.7061224489795918], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7346938775510204, 0.8530612244897959], - anchor='y6' - ), - xaxis7=XAxis( - domain=[0.8816326530612244, 0.9999999999999999], - anchor='y7' - ), - xaxis8=XAxis( - domain=[0.0, 0.1183673469387755], - anchor='y8' - ), - xaxis9=XAxis( - domain=[0.14693877551020407, 0.26530612244897955], - anchor='y9' - ), - yaxis1=YAxis( - domain=[0.0, 0.19375], - anchor='x' - ), - yaxis10=YAxis( - domain=[0.26875, 0.4625], - anchor='x10' - ), - yaxis11=YAxis( - domain=[0.26875, 0.4625], - anchor='x11' - ), - yaxis12=YAxis( - domain=[0.26875, 0.4625], - anchor='x12' - ), - yaxis13=YAxis( - domain=[0.26875, 0.4625], - anchor='x13' - ), - yaxis14=YAxis( - domain=[0.26875, 0.4625], - anchor='x14' - ), - yaxis15=YAxis( - domain=[0.5375, 0.73125], - anchor='x15' - ), - yaxis16=YAxis( - domain=[0.5375, 0.73125], - anchor='x16' - ), - yaxis17=YAxis( - domain=[0.5375, 0.73125], - anchor='x17' - ), - yaxis18=YAxis( - domain=[0.5375, 0.73125], - anchor='x18' - ), - yaxis19=YAxis( - domain=[0.5375, 0.73125], - anchor='x19' - ), - yaxis2=YAxis( - domain=[0.0, 0.19375], - anchor='x2' - ), - yaxis20=YAxis( - domain=[0.5375, 0.73125], - anchor='x20' - ), - yaxis21=YAxis( - domain=[0.5375, 0.73125], - anchor='x21' - ), - yaxis22=YAxis( - domain=[0.80625, 1.0], - anchor='x22' - ), - yaxis23=YAxis( - domain=[0.80625, 1.0], - anchor='x23' - ), - yaxis24=YAxis( - domain=[0.80625, 1.0], - anchor='x24' - ), - yaxis25=YAxis( - domain=[0.80625, 1.0], - anchor='x25' - ), - yaxis26=YAxis( - domain=[0.80625, 1.0], - anchor='x26' - ), - yaxis27=YAxis( - domain=[0.80625, 1.0], - anchor='x27' - ), - yaxis28=YAxis( - domain=[0.80625, 1.0], - anchor='x28' - ), - yaxis3=YAxis( - domain=[0.0, 0.19375], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.19375], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.19375], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.0, 0.19375], - anchor='x6' - ), - yaxis7=YAxis( - domain=[0.0, 0.19375], - anchor='x7' - ), - yaxis8=YAxis( - domain=[0.26875, 0.4625], - anchor='x8' - ), - yaxis9=YAxis( - domain=[0.26875, 0.4625], - anchor='x9' - ) - ) - ) - fig = tls.make_subplots(rows=4, cols=7, start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_spacing(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.3], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35, 0.6499999999999999], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.0, 0.3], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.35, 0.6499999999999999], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7, 1.0], - anchor='y6' - ), - yaxis1=YAxis( - domain=[0.55, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.55, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.55, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.45], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.45], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.0, 0.45], - anchor='x6' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=3, - horizontal_spacing=.05, - vertical_spacing=.1) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y4' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.425], - anchor='x4' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=3, - specs=[[{}, None, None], - [{}, {}, {}]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y4' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.575, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.575, 1.0], - anchor='x4' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=3, - specs=[[{}, None, None], - [{}, {}, {}]], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_colspan(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 0.45], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.55, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.0, 0.45], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.55, 1.0], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x5' - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=2, - specs=[[{'colspan': 2}, None], - [{}, {}], - [{}, {}]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_rowspan(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.35555555555555557, 1.0], - anchor='y6' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x6' - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=3, - specs=[[{'rowspan': 3}, {}, {}], - [None, {}, {}], [None, {'colspan': 2}, None]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_rowspan2(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.0, 0.6444444444444445], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.0, 1.0], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.36666666666666664, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x5' - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=3, specs=[[{}, {}, {'rowspan': 2}], - [{'colspan': 2}, None, None], - [{'colspan': 3}, None, None]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_colspan_rowpan(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.6444444444444445], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y6' - ), - yaxis1=YAxis( - domain=[0.36666666666666664, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x6' - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=3, - specs=[[{'colspan': 2, 'rowspan': 2}, None, {}], - [None, None, {}], [{}, {}, {}]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_colspan_rowpan_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.6444444444444445], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y5' - ), - xaxis6=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y6' - ), - yaxis1=YAxis( - domain=[0.0, 0.6333333333333333], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x5' - ), - yaxis6=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='x6' - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=3, - specs=[[{'colspan': 2, 'rowspan': 2}, None, {}], - [None, None, {}], [{}, {}, {}]], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_is_3d(self): - expected = Figure( - data=Data(), - layout=Layout( - scene=Scene( - domain={'y': [0.575, 1.0], 'x': [0.0, 0.45]} - ), - scene2=Scene( - domain={'y': [0.0, 0.425], 'x': [0.0, 0.45]} - ), - xaxis1=XAxis( - domain=[0.55, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, specs=[[{'is_3d': True}, {}], - [{'is_3d': True}, {}]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_padding(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.1, 0.5], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.5, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.0, 0.5], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.5, 0.9], - anchor='y4' - ), - yaxis1=YAxis( - domain=[0.5, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.7, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.3], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.5], - anchor='x4' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, horizontal_spacing=0, - vertical_spacing=0, - specs=[[{'l': 0.1}, {'b': 0.2}], - [{'t': 0.2}, {'r': 0.1}]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_specs_padding_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.1, 0.5], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.5, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.0, 0.5], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.5, 0.9], - anchor='y4' - ), - yaxis1=YAxis( - domain=[0.0, 0.5], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.2, 0.5], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.5, 0.8], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.5, 1.0], - anchor='x4' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, - horizontal_spacing=0, vertical_spacing=0, - specs=[[{'l': 0.1}, {'b': 0.2}], - [{'t': 0.2}, {'r': 0.1}]], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_xaxes(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y4' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y5' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y6' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.0 - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.35555555555555557 - ), - yaxis3=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.7111111111111111 - ), - yaxis4=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis5=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ), - yaxis6=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=3, shared_xaxes=True) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_xaxes_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.0 - ), - yaxis5=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.35555555555555557 - ), - yaxis6=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.7111111111111111 - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=3, - shared_xaxes=True, start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_yaxes(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis10=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.0 - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.848 - ), - xaxis3=XAxis( - domain=[0.0, 0.45], - anchor='y2' - ), - xaxis4=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.6359999999999999 - ), - xaxis5=XAxis( - domain=[0.0, 0.45], - anchor='y3' - ), - xaxis6=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.424 - ), - xaxis7=XAxis( - domain=[0.0, 0.45], - anchor='y4' - ), - xaxis8=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.212 - ), - xaxis9=XAxis( - domain=[0.0, 0.45], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.848, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.6359999999999999, 0.7879999999999999], - anchor='x3' - ), - yaxis3=YAxis( - domain=[0.424, 0.576], - anchor='x5' - ), - yaxis4=YAxis( - domain=[0.212, 0.364], - anchor='x7' - ), - yaxis5=YAxis( - domain=[0.0, 0.152], - anchor='x9' - ) - ) - ) - fig = tls.make_subplots(rows=5, cols=2, shared_yaxes=True) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_xaxes_yaxes(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y3' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='free', - position=0.0 - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='free', - position=0.0 - ), - yaxis1=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='free', - position=0.0 - ), - yaxis2=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='free', - position=0.0 - ), - yaxis3=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x' - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=3, - shared_xaxes=True, shared_yaxes=True) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_xaxes_yaxes_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='free', - position=0.0 - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='free', - position=0.0 - ), - yaxis1=YAxis( - domain=[0.0, 0.26666666666666666], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.36666666666666664, 0.6333333333333333], - anchor='free', - position=0.0 - ), - yaxis3=YAxis( - domain=[0.7333333333333333, 1.0], - anchor='free', - position=0.0 - ) - ) - ) - fig = tls.make_subplots(rows=3, cols=3, - shared_xaxes=True, shared_yaxes=True, - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_axes_list(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.575 - ), - xaxis3=XAxis( - domain=[0.55, 1.0], - anchor='y3' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='free', - position=0.0 - ), - yaxis3=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, shared_xaxes=[(1, 1), (2, 1)], - shared_yaxes=[(1, 1), (1, 2)]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_axes_list_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.0 - ), - xaxis3=XAxis( - domain=[0.55, 1.0], - anchor='y3' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.0 - ), - yaxis3=YAxis( - domain=[0.575, 1.0], - anchor='x3' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, shared_xaxes=[(1, 1), (2, 1)], - shared_yaxes=[(1, 1), (1, 2)], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_axes_list_of_lists(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.575, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.425], - anchor='free', - position=0.0 - ), - yaxis5=YAxis( - domain=[0.0, 0.425], - anchor='x4' - ), - yaxis6=YAxis( - domain=[0.0, 0.425], - anchor='free', - position=0.7111111111111111 - ) - ) - ) - fig = tls.make_subplots( - rows=2, cols=3, shared_xaxes=[[(1, 1), (2, 1)], [(1, 3), (2, 3)]] - ) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_shared_axes_list_of_lists_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.0 - ), - yaxis5=YAxis( - domain=[0.575, 1.0], - anchor='x4' - ), - yaxis6=YAxis( - domain=[0.575, 1.0], - anchor='free', - position=0.7111111111111111 - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=3, shared_xaxes=[[(1, 1), (2, 1)], - [(1, 3), (2, 3)]], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_insets(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.0, 0.45], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.55, 1.0], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.865, 0.955], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.425], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.085, 0.2975], - anchor='x5' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, - insets=[{'cell': (2, 2), 'l': 0.7, 'w': 0.2, - 'b': 0.2, 'h': 0.5}]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_insets_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.0, 0.45], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.55, 1.0], - anchor='y4' - ), - xaxis5=XAxis( - domain=[0.865, 0.955], - anchor='y5' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.575, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.575, 1.0], - anchor='x4' - ), - yaxis5=YAxis( - domain=[0.6599999999999999, 0.8724999999999999], - anchor='x5' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, - insets=[{'cell': (2, 2), 'l': 0.7, 'w': 0.2, - 'b': 0.2, 'h': 0.5}], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_insets_multiple(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.8, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.8, 1.0], - anchor='y4' - ), - yaxis1=YAxis( - domain=[0.575, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.425], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.575, 1.0], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.0, 0.425], - anchor='x4' - ) - ) - ) - fig = tls.make_subplots(rows=2, insets=[{'cell': (1, 1), 'l': 0.8}, - {'cell': (2, 1), 'l': 0.8}]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_insets_multiple_bottom_left(self): - expected = Figure( - data=Data(), - layout=Layout( - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.8, 1.0], - anchor='y3' - ), - xaxis4=XAxis( - domain=[0.8, 1.0], - anchor='y4' - ), - yaxis1=YAxis( - domain=[0.0, 0.425], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.575, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.425], - anchor='x3' - ), - yaxis4=YAxis( - domain=[0.575, 1.0], - anchor='x4' - ) - ) - ) - fig = tls.make_subplots(rows=2, - insets=[{'cell': (1, 1), 'l': 0.8}, - {'cell': (2, 1), 'l': 0.8}], - start_cell='bottom-left') - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_subplot_titles_2x1(self): - # make a title for each subplot when the layout is 2 rows and 1 column - expected = Figure( - data=Data(), - layout=Layout( - annotations=Annotations([ - Annotation( - x=0.5, - y=1.0, - xref='paper', - yref='paper', - text='Title 1', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.5, - y=0.375, - xref='paper', - yref='paper', - text='Title 2', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ) - ]), - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.0, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.625, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 0.375], - anchor='x2' - ) - ) - ) - fig = tls.make_subplots(rows=2, subplot_titles=('Title 1', 'Title 2')) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_subplot_titles_1x3(self): - # make a title for each subplot when the layout is 1 row and 3 columns - expected = Figure( - data=Data(), - layout=Layout( - annotations=Annotations([ - Annotation( - x=0.14444444444444446, - y=1.0, - xref='paper', - yref='paper', - text='Title 1', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.5, - y=1.0, - xref='paper', - yref='paper', - text='Title 2', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.8555555555555556, - y=1.0, - xref='paper', - yref='paper', - text='Title 3', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ) - ]), - xaxis1=XAxis( - domain=[0.0, 0.2888888888888889], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.35555555555555557, 0.6444444444444445], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.7111111111111111, 1.0], - anchor='y3' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.0, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 1.0], - anchor='x3' - ) - ) - ) - fig = tls.make_subplots(cols=3, - subplot_titles=('Title 1', 'Title 2', 'Title 3')) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_subplot_titles_shared_axes(self): - # make a title for each subplot when the layout is 1 row and 3 columns - expected = Figure( - data=Data(), - layout=Layout( - annotations=Annotations([ - Annotation( - x=0.225, - y=1.0, - xref='paper', - yref='paper', - text='Title 1', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.775, - y=1.0, - xref='paper', - yref='paper', - text='Title 2', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.225, - y=0.375, - xref='paper', - yref='paper', - text='Title 3', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.775, - y=0.375, - xref='paper', - yref='paper', - text='Title 4', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ) - ]), - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y2' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='free', - position=0.0 - ), - yaxis1=YAxis( - domain=[0.625, 1.0], - anchor='free', - position=0.0 - ), - yaxis2=YAxis( - domain=[0.0, 0.375], - anchor='x' - ) - ) - ) - - fig = tls.make_subplots(rows=2, cols=2, - subplot_titles=('Title 1', 'Title 2', - 'Title 3', 'Title 4'), - shared_xaxes=True, shared_yaxes=True) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_subplot_titles_irregular_layout(self): - # make a title for each subplot when the layout is irregular: - expected = Figure( - data=Data(), - layout=Layout( - annotations=Annotations([ - Annotation( - x=0.225, - y=1.0, - xref='paper', - yref='paper', - text='Title 1', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.775, - y=1.0, - xref='paper', - yref='paper', - text='Title 2', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ), - Annotation( - x=0.5, - y=0.375, - xref='paper', - yref='paper', - text='Title 3', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ) - ]), - xaxis1=XAxis( - domain=[0.0, 0.45], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.55, 1.0], - anchor='y2' - ), - xaxis3=XAxis( - domain=[0.0, 1.0], - anchor='y3' - ), - yaxis1=YAxis( - domain=[0.625, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.625, 1.0], - anchor='x2' - ), - yaxis3=YAxis( - domain=[0.0, 0.375], - anchor='x3' - ) - ) - ) - fig = tls.make_subplots(rows=2, cols=2, - subplot_titles=('Title 1', 'Title 2', 'Title 3'), - specs=[[{}, {}], [{'colspan': 2}, None]]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_subplot_titles_insets(self): - # This should make a title for the inset plot - # and no title for the main plot. - expected = Figure( - data=Data(), - layout=Layout( - annotations=Annotations([ - Annotation( - x=0.85, - y=1.0, - xref='paper', - yref='paper', - text='Inset', - showarrow=False, - font=Font(size=16), - xanchor='center', - yanchor='bottom' - ) - ]), - xaxis1=XAxis( - domain=[0.0, 1.0], - anchor='y' - ), - xaxis2=XAxis( - domain=[0.7, 1.0], - anchor='y2' - ), - yaxis1=YAxis( - domain=[0.0, 1.0], - anchor='x' - ), - yaxis2=YAxis( - domain=[0.3, 1.0], - anchor='x2' - ) - ) - ) - fig = tls.make_subplots(insets=[{'cell': (1, 1), 'l': 0.7, 'b': 0.3}], - subplot_titles=("", 'Inset')) - self.assertEqual(fig, expected) - - def test_large_columns_no_errors(self): - """ - Test that creating subplots with a large number of columns, and - zero vertical spacing doesn't result in domain values that are out - of range. - - Here is the error that was reported in GH1031 - - ValueError: - Invalid value of type 'builtins.float' received for the - 'domain[1]' property of layout.yaxis - Received value: 1.0000000000000007 - - The 'domain[1]' property is a number and may be specified as: - - An int or float in the interval [0, 1] - - """ - v_space = 0.0 - - # 2D - fig = tls.make_subplots(100, 1, vertical_spacing=v_space) - - # 3D - fig = tls.make_subplots(100, 1, - vertical_spacing=v_space, - specs=[[{'is_3d': True}] for _ in range(100)]) - - def test_row_width_and_column_width(self): - - expected = Figure({ - 'data': [], - 'layout': {'annotations': [{'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 1', - 'x': 0.405, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 1.0, - 'yanchor': 'bottom', - 'yref': 'paper'}, - {'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 2', - 'x': 0.9550000000000001, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 1.0, - 'yanchor': 'bottom', - 'yref': 'paper'}, - {'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 3', - 'x': 0.405, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 0.1875, - 'yanchor': 'bottom', - 'yref': 'paper'}, - {'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 4', - 'x': 0.9550000000000001, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 0.1875, - 'yanchor': 'bottom', - 'yref': 'paper'}], - 'xaxis': {'anchor': 'y', 'domain': [0.0, 0.81]}, - 'xaxis2': {'anchor': 'y2', 'domain': [0.91, 1.0]}, - 'xaxis3': {'anchor': 'y3', 'domain': [0.0, 0.81]}, - 'xaxis4': {'anchor': 'y4', 'domain': [0.91, 1.0]}, - 'yaxis': {'anchor': 'x', 'domain': [0.4375, 1.0]}, - 'yaxis2': {'anchor': 'x2', 'domain': [0.4375, 1.0]}, - 'yaxis3': {'anchor': 'x3', 'domain': [0.0, 0.1875]}, - 'yaxis4': {'anchor': 'x4', 'domain': [0.0, 0.1875]}} - }) - fig = tls.make_subplots(rows=2, cols=2, - subplot_titles=('Title 1', 'Title 2', 'Title 3', 'Title 4'), - row_width=[1, 3], column_width=[9, 1]) - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - def test_row_width_and_shared_yaxes(self): - - expected = Figure({ - 'data': [], - 'layout': {'annotations': [{'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 1', - 'x': 0.225, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 1.0, - 'yanchor': 'bottom', - 'yref': 'paper'}, - {'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 2', - 'x': 0.775, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 1.0, - 'yanchor': 'bottom', - 'yref': 'paper'}, - {'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 3', - 'x': 0.225, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 0.1875, - 'yanchor': 'bottom', - 'yref': 'paper'}, - {'font': {'size': 16}, - 'showarrow': False, - 'text': 'Title 4', - 'x': 0.775, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 0.1875, - 'yanchor': 'bottom', - 'yref': 'paper'}], - 'xaxis': {'anchor': 'y', 'domain': [0.0, 0.45]}, - 'xaxis2': {'anchor': 'free', 'domain': [0.55, 1.0], 'position': 0.4375}, - 'xaxis3': {'anchor': 'y2', 'domain': [0.0, 0.45]}, - 'xaxis4': {'anchor': 'free', 'domain': [0.55, 1.0], 'position': 0.0}, - 'yaxis': {'anchor': 'x', 'domain': [0.4375, 1.0]}, - 'yaxis2': {'anchor': 'x3', 'domain': [0.0, 0.1875]}} - }) - - fig = tls.make_subplots(rows=2, cols=2, row_width=[1, 3], shared_yaxes=True, - subplot_titles=('Title 1', 'Title 2', 'Title 3', 'Title 4')) - - self.assertEqual(fig.to_plotly_json(), expected.to_plotly_json()) - - # def test_row_width_and_shared_yaxes(self): \ No newline at end of file diff --git a/plotly/tests/test_core/test_update_objects/test_update_subplots.py b/plotly/tests/test_core/test_update_objects/test_update_subplots.py index bea73c2d3a6..6256188f851 100644 --- a/plotly/tests/test_core/test_update_objects/test_update_subplots.py +++ b/plotly/tests/test_core/test_update_objects/test_update_subplots.py @@ -6,14 +6,11 @@ import plotly.graph_objs as go from plotly.graph_objs import Figure from plotly.subplots import make_subplots -from _plotly_future_ import _future_flags class TestSelectForEachUpdateSubplots(TestCase): def setUp(self): - _future_flags.add('v4_subplots') - fig = make_subplots( rows=3, cols=3, @@ -47,9 +44,6 @@ def setUp(self): self.fig = fig self.fig_no_grid = go.Figure(self.fig.to_dict()) - def tearDown(self): - _future_flags.remove('v4_subplots') - def assert_select_subplots( self, subplot_type, subplots_name, expected_nums, selector=None, row=None, col=None, secondary_y=None, diff --git a/plotly/tests/test_core/test_update_objects/test_update_traces.py b/plotly/tests/test_core/test_update_objects/test_update_traces.py index fc48168785d..2b395e460e9 100644 --- a/plotly/tests/test_core/test_update_objects/test_update_traces.py +++ b/plotly/tests/test_core/test_update_objects/test_update_traces.py @@ -5,13 +5,11 @@ import plotly.graph_objs as go from plotly.subplots import make_subplots -from _plotly_future_ import _future_flags class TestSelectForEachUpdateTraces(TestCase): def setUp(self): - _future_flags.add('v4_subplots') fig = make_subplots( rows=3, cols=2, @@ -118,9 +116,6 @@ def setUp(self): self.fig = fig self.fig_no_grid = go.Figure(self.fig.to_dict()) - def tearDown(self): - _future_flags.remove('v4_subplots') - # select_traces and for_each_trace # -------------------------------- def assert_select_traces( diff --git a/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py b/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py index c9b69ef209f..e9c1fa9a662 100644 --- a/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py +++ b/plotly/tests/test_optional/test_figure_factory/test_figure_factory.py @@ -2,11 +2,13 @@ from plotly import optional_imports from plotly.graph_objs import graph_objs as go from plotly.exceptions import PlotlyError +import plotly.io as pio import plotly.figure_factory as ff from plotly.tests.test_optional.optional_utils import NumpyTestUtilsMixin import numpy as np +from plotly.tests.utils import TestCaseNoTemplate from scipy.spatial import Delaunay import pandas as pd @@ -16,7 +18,7 @@ sk_measure = optional_imports.get_module('skimage.measure') -class TestDistplot(NumpyTestUtilsMixin, TestCase): +class TestDistplot(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_wrong_curve_type(self): @@ -362,7 +364,7 @@ def test_distplot_binsize_array_prob_density(self): self.assert_fig_equal(dp['data'][1], expected_dp_data_hist_2) -class TestStreamline(TestCase): +class TestStreamline(TestCaseNoTemplate): def test_wrong_arrow_scale(self): @@ -453,7 +455,7 @@ def test_simple_streamline(self): expected_strln_0_100['x']) -class TestDendrogram(NumpyTestUtilsMixin, TestCase): +class TestDendrogram(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_default_dendrogram(self): X = np.array([[1, 2, 3, 4], [1, 1, 3, 4], [1, 2, 1, 4], [1, 2, 3, 1]]) @@ -788,7 +790,8 @@ def test_dendrogram_ticklabels(self): self.assertEqual(len(dendro.layout.xaxis.ticktext), 4) self.assertEqual(len(dendro.layout.xaxis.tickvals), 4) -class TestTrisurf(NumpyTestUtilsMixin, TestCase): + +class TestTrisurf(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_vmin_and_vmax(self): @@ -988,7 +991,7 @@ def test_trisurf_all_args(self): str)) -class TestScatterPlotMatrix(NumpyTestUtilsMixin, TestCase): +class TestScatterPlotMatrix(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_dataframe_input(self): @@ -1314,7 +1317,7 @@ def test_scatter_plot_matrix_kwargs(self): exp_scatter_plot_matrix['layout']) -class TestGantt(NumpyTestUtilsMixin, TestCase): +class TestGantt(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_df_dataframe(self): @@ -1405,7 +1408,7 @@ def test_df_dataframe_all_args(self): exp_gantt_chart['layout']) -class TestViolin(NumpyTestUtilsMixin, TestCase): +class TestViolin(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_colors_validation(self): @@ -1996,7 +1999,7 @@ def test_violin_fig(self): exp_violin['layout']) -class TestFacetGrid(NumpyTestUtilsMixin, TestCase): +class TestFacetGrid(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_data_must_be_dataframe(self): data = [] @@ -2116,96 +2119,106 @@ def test_valid_facet_grid_fig(self): ) exp_facet_grid = { - 'data': [ - {'marker': {'color': 'rgb(31, 119, 180)', - 'line': {'color': 'darkgrey', 'width': 1}, - 'size': 8}, - 'mode': 'markers', - 'opacity': 0.6, - 'type': 'scatter', - 'x': [1.8, 1.8, 2.0, 2.0, 1.8, 1.8, 2.0], - 'xaxis': 'x', - 'y': [18, 18, 20, 21, 18, 16, 20], - 'yaxis': 'y'}, - {'marker': {'color': 'rgb(31, 119, 180)', - 'line': {'color': 'darkgrey', 'width': 1}, - 'size': 8}, - 'mode': 'markers', - 'opacity': 0.6, - 'type': 'scatter', - 'x': [2.8, 2.8, 3.1], - 'xaxis': 'x2', - 'y': [16, 18, 18], - 'yaxis': 'y'}], - 'layout': {'annotations': [{'font': {'color': '#0f0f0f', 'size': 13}, - 'showarrow': False, - 'text': '4', - 'textangle': 0, - 'x': 0.24625, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 1.03, - 'yanchor': 'middle', - 'yref': 'paper'}, - {'font': {'color': '#0f0f0f', 'size': 13}, - 'showarrow': False, - 'text': '6', - 'textangle': 0, - 'x': 0.7537499999999999, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 1.03, - 'yanchor': 'middle', - 'yref': 'paper'}, - {'font': {'color': '#000000', 'size': 12}, - 'showarrow': False, - 'text': 'displ', - 'textangle': 0, - 'x': 0.5, - 'xanchor': 'center', - 'xref': 'paper', - 'y': -0.1, - 'yanchor': 'middle', - 'yref': 'paper'}, - {'font': {'color': '#000000', 'size': 12}, - 'showarrow': False, - 'text': 'cty', - 'textangle': -90, - 'x': -0.1, - 'xanchor': 'center', - 'xref': 'paper', - 'y': 0.5, - 'yanchor': 'middle', - 'yref': 'paper'}], - 'height': 600, - 'legend': {'bgcolor': '#efefef', - 'borderwidth': 1, - 'x': 1.05, - 'y': 1, - 'yanchor': 'top'}, - 'paper_bgcolor': 'rgb(251, 251, 251)', - 'showlegend': False, - 'title': {'text': ''}, - 'width': 600, - 'xaxis': {'anchor': 'y', - 'domain': [0.0, 0.4925], - 'dtick': 0.0, - 'range': [0.85, 4.1575], - 'ticklen': 0, - 'zeroline': False}, - 'xaxis2': {'anchor': 'free', - 'domain': [0.5075, 1.0], - 'dtick': 0.0, - 'position': 0.0, - 'range': [0.85, 4.1575], - 'ticklen': 0, - 'zeroline': False}, - 'yaxis': {'anchor': 'x', - 'domain': [0.0, 1.0], - 'dtick': 1.0, - 'range': [15.75, 21.2625], - 'ticklen': 0, - 'zeroline': False}}} + 'data': [{'marker': {'color': 'rgb(31, 119, 180)', + 'line': {'color': 'darkgrey', 'width': 1}, + 'size': 8}, + 'mode': 'markers', + 'opacity': 0.6, + 'type': 'scatter', + 'x': [1.8, 1.8, 2.0, 2.0, 1.8, 1.8, 2.0], + 'xaxis': 'x', + 'y': [18, 18, 20, 21, 18, 16, 20], + 'yaxis': 'y'}, + {'marker': {'color': 'rgb(31, 119, 180)', + 'line': {'color': 'darkgrey', 'width': 1}, + 'size': 8}, + 'mode': 'markers', + 'opacity': 0.6, + 'type': 'scatter', + 'x': [2.8, 2.8, 3.1], + 'xaxis': 'x2', + 'y': [16, 18, 18], + 'yaxis': 'y2'}], + 'layout': {'annotations': [{'font': {'color': '#0f0f0f', + 'size': 13}, + 'showarrow': False, + 'text': '4', + 'textangle': 0, + 'x': 0.24625, + 'xanchor': 'center', + 'xref': 'paper', + 'y': 1.03, + 'yanchor': 'middle', + 'yref': 'paper'}, + {'font': {'color': '#0f0f0f', + 'size': 13}, + 'showarrow': False, + 'text': '6', + 'textangle': 0, + 'x': 0.7537499999999999, + 'xanchor': 'center', + 'xref': 'paper', + 'y': 1.03, + 'yanchor': 'middle', + 'yref': 'paper'}, + {'font': {'color': '#000000', + 'size': 12}, + 'showarrow': False, + 'text': 'displ', + 'textangle': 0, + 'x': 0.5, + 'xanchor': 'center', + 'xref': 'paper', + 'y': -0.1, + 'yanchor': 'middle', + 'yref': 'paper'}, + {'font': {'color': '#000000', + 'size': 12}, + 'showarrow': False, + 'text': 'cty', + 'textangle': -90, + 'x': -0.1, + 'xanchor': 'center', + 'xref': 'paper', + 'y': 0.5, + 'yanchor': 'middle', + 'yref': 'paper'}], + 'height': 600, + 'legend': {'bgcolor': '#efefef', + 'borderwidth': 1, + 'x': 1.05, + 'y': 1, + 'yanchor': 'top'}, + 'paper_bgcolor': 'rgb(251, 251, 251)', + 'showlegend': False, + 'title': {'text': ''}, + 'width': 600, + 'xaxis': {'anchor': 'y', + 'domain': [0.0, 0.4925], + 'dtick': 0, + 'range': [0.85, 4.1575], + 'ticklen': 0, + 'zeroline': False}, + 'xaxis2': {'anchor': 'y2', + 'domain': [0.5075, 1.0], + 'dtick': 0, + 'range': [0.85, 4.1575], + 'ticklen': 0, + 'zeroline': False}, + 'yaxis': {'anchor': 'x', + 'domain': [0.0, 1.0], + 'dtick': 1, + 'range': [15.75, 21.2625], + 'ticklen': 0, + 'zeroline': False}, + 'yaxis2': {'anchor': 'x2', + 'domain': [0.0, 1.0], + 'dtick': 1, + 'matches': 'y', + 'range': [15.75, 21.2625], + 'showticklabels': False, + 'ticklen': 0, + 'zeroline': False}}} for j in [0, 1]: self.assert_fig_equal( @@ -2219,7 +2232,7 @@ def test_valid_facet_grid_fig(self): ) -class TestBullet(NumpyTestUtilsMixin, TestCase): +class TestBullet(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_df_as_list(self): df = [ @@ -2757,7 +2770,7 @@ def test_full_bullet(self): exp_fig['data'][i]) -class TestChoropleth(NumpyTestUtilsMixin, TestCase): +class TestChoropleth(NumpyTestUtilsMixin, TestCaseNoTemplate): # run tests if required packages are installed if shapely and shapefile and gp: @@ -2860,7 +2873,7 @@ def test_full_choropleth(self): self.assertEqual(fig['data'][2]['x'][:50], exp_fig_head) -class TestQuiver(TestCase): +class TestQuiver(TestCaseNoTemplate): def test_scaleratio_param(self): x,y = np.meshgrid(np.arange(0.5, 3.5, .5), np.arange(0.5, 4.5, .5)) @@ -2873,25 +2886,25 @@ def test_scaleratio_param(self): fig = ff.create_quiver(x, y, u, v, scale = 1, scaleratio = 0.5) exp_fig_head = [( - 0.5, - 0.5883883476483185, + 0.5, + 0.5883883476483185, + None, + 1.0, + 1.1118033988749896, + None, + 1.5, + 1.6185854122563141, None, - 1.0, - 1.1118033988749896, - None, - 1.5, - 1.6185854122563141, - None, 2.0), (0.5, 0.6767766952966369, None, - 0.5, - 0.6118033988749895, - None, - 0.5, - 0.5790569415042095, - None, + 0.5, + 0.6118033988749895, + None, + 0.5, + 0.5790569415042095, + None, 0.5)] fig_head = [fig['data'][0]['x'][:10], fig['data'][0]['y'][:10]] @@ -2899,7 +2912,7 @@ def test_scaleratio_param(self): self.assertEqual(fig_head, exp_fig_head) -class TestTernarycontour(NumpyTestUtilsMixin, TestCase): +class TestTernarycontour(NumpyTestUtilsMixin, TestCaseNoTemplate): def test_wrong_coordinates(self): a, b = np.mgrid[0:1:20j, 0:1:20j] diff --git a/plotly/tests/test_optional/test_grid/__init__.py b/plotly/tests/test_optional/test_grid/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_optional/test_grid/test_grid.py b/plotly/tests/test_optional/test_grid/test_grid.py deleted file mode 100644 index dcac3211a05..00000000000 --- a/plotly/tests/test_optional/test_grid/test_grid.py +++ /dev/null @@ -1,32 +0,0 @@ -""" -test_grid: -========== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -from unittest import TestCase - -from plotly.exceptions import InputError -from plotly.grid_objs import Grid - -import pandas as pd - - -class TestDataframeToGrid(TestCase): - - # Test duplicate columns - def test_duplicate_columns(self): - df = pd.DataFrame([[1, 'a'], [2, 'b']], - columns=['col_1', 'col_1']) - - expected_message = ( - "Yikes, plotly grids currently " - "can't have duplicate column names. Rename " - "the column \"{}\" and try again.".format('col_1') - ) - - with self.assertRaisesRegexp(InputError, expected_message): - Grid(df) diff --git a/plotly/tests/test_optional/test_ipython/__init__.py b/plotly/tests/test_optional/test_ipython/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_optional/test_ipython/test_widgets.py b/plotly/tests/test_optional/test_ipython/test_widgets.py deleted file mode 100644 index 548ffe6dbcd..00000000000 --- a/plotly/tests/test_optional/test_ipython/test_widgets.py +++ /dev/null @@ -1,14 +0,0 @@ -""" -Module for testing IPython widgets - -""" -from __future__ import absolute_import - -from unittest import TestCase - -from plotly.widgets import GraphWidget - -class TestWidgets(TestCase): - - def test_instantiate_graph_widget(self): - widget = GraphWidget diff --git a/plotly/tests/test_optional/test_matplotlylib/test_plot_mpl.py b/plotly/tests/test_optional/test_matplotlylib/test_plot_mpl.py deleted file mode 100644 index 74a42e3bca4..00000000000 --- a/plotly/tests/test_optional/test_matplotlylib/test_plot_mpl.py +++ /dev/null @@ -1,54 +0,0 @@ -""" -test_plot_mpl: -============== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -from nose.plugins.attrib import attr -from nose.tools import raises - -from plotly import exceptions, optional_imports -from plotly.plotly import plotly as py -from unittest import TestCase - -matplotlylib = optional_imports.get_module('plotly.matplotlylib') - -if matplotlylib: - import matplotlib.pyplot as plt - - -@attr('matplotlib') -class PlotMPLTest(TestCase): - def setUp(self): - py.sign_in('PlotlyImageTest', '786r5mecv0', - plotly_domain='https://plot.ly') - - @raises(exceptions.PlotlyGraphObjectError) - def test_update_type_error(self): - fig, ax = plt.subplots() - ax.plot([1, 2, 3]) - update = [] - py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False) - - @raises(KeyError) - def test_update_validation_error(self): - fig, ax = plt.subplots() - ax.plot([1, 2, 3]) - update = {'invalid': 'anything'} - py.plot_mpl(fig, update=update, filename="nosetests", auto_open=False) - - @attr('slow') - def test_update(self): - fig, ax = plt.subplots() - ax.plot([1, 2, 3]) - title = 'new title' - update = {'layout': {'title': title}} - url = py.plot_mpl(fig, update=update, filename="nosetests", - auto_open=False) - un = url.replace("https://plot.ly/~", "").split('/')[0] - fid = url.replace("https://plot.ly/~", "").split('/')[1] - pfig = py.get_figure(un, fid) - assert pfig['layout']['title']['text'] == title diff --git a/plotly/tests/test_optional/test_tools/test_figure_factory.py b/plotly/tests/test_optional/test_tools/test_figure_factory.py index 655be1570f8..4f0c27e4f7b 100644 --- a/plotly/tests/test_optional/test_tools/test_figure_factory.py +++ b/plotly/tests/test_optional/test_tools/test_figure_factory.py @@ -3,13 +3,15 @@ import datetime import plotly.figure_factory as ff +import plotly.io as pio from plotly.exceptions import PlotlyError from plotly.tests.test_optional.optional_utils import NumpyTestUtilsMixin from plotly.graph_objs import graph_objs +from plotly.tests.utils import TestCaseNoTemplate -class TestQuiver(TestCase, NumpyTestUtilsMixin): +class TestQuiver(TestCaseNoTemplate, NumpyTestUtilsMixin): def test_unequal_xy_length(self): @@ -124,7 +126,7 @@ def test_more_kwargs(self): expected_quiver['layout']) -class TestFinanceCharts(TestCase, NumpyTestUtilsMixin): +class TestFinanceCharts(TestCaseNoTemplate, NumpyTestUtilsMixin): def test_unequal_ohlc_length(self): @@ -712,7 +714,7 @@ def test_datetime_candlestick(self): self.assert_fig_equal(candle['layout'], exp_candle['layout']) -class TestAnnotatedHeatmap(TestCase, NumpyTestUtilsMixin): +class TestAnnotatedHeatmap(TestCaseNoTemplate, NumpyTestUtilsMixin): def test_unequal_z_text_size(self): @@ -1058,7 +1060,7 @@ def test_bug_1300(self): self.assert_fig_equal(fig, expected) -class TestTable(TestCase, NumpyTestUtilsMixin): +class TestTable(TestCaseNoTemplate, NumpyTestUtilsMixin): def test_fontcolor_input(self): @@ -1763,7 +1765,7 @@ def test_gantt_all_args(self): exp_gantt_chart['layout']) -class Test2D_Density(TestCase, NumpyTestUtilsMixin): +class Test2D_Density(TestCaseNoTemplate, NumpyTestUtilsMixin): def test_validate_2D_density(self): diff --git a/plotly/tests/test_optional/test_utils/test_utils.py b/plotly/tests/test_optional/test_utils/test_utils.py index 84e3c92a30f..b008beb7c91 100644 --- a/plotly/tests/test_optional/test_utils/test_utils.py +++ b/plotly/tests/test_optional/test_utils/test_utils.py @@ -19,7 +19,7 @@ from plotly import optional_imports, utils from plotly.graph_objs import Scatter, Scatter3d, Figure, Data -from plotly.grid_objs import Column + matplotlylib = optional_imports.get_module('plotly.matplotlylib') @@ -28,6 +28,21 @@ from plotly.matplotlylib import Exporter, PlotlyRenderer +## JSON encoding +numeric_list = [1, 2, 3] +np_list = np.array([1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)]) +mixed_list = [1, 'A', dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), + dt(2014, 1, 5, 1, 1, 1, 1)] +dt_list = [dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), + dt(2014, 1, 5, 1, 1, 1, 1)] + +df = pd.DataFrame(columns=['col 1'], + data=[1, 2, 3, dt(2014, 1, 5), pd.NaT, np.NaN, np.Inf]) + +rng = pd.date_range('1/1/2011', periods=2, freq='H') +ts = pd.Series([1.5, 2.5], index=rng) + + class TestJSONEncoder(TestCase): def test_encode_as_plotly(self): @@ -161,122 +176,100 @@ def test_encode_as_decimal(self): self.assertAlmostEqual(res, 1.023452) # Checks upto 7 decimal places self.assertIsInstance(res, float) -## JSON encoding -numeric_list = [1, 2, 3] -np_list = np.array([1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)]) -mixed_list = [1, 'A', dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), - dt(2014, 1, 5, 1, 1, 1, 1)] -dt_list = [dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), - dt(2014, 1, 5, 1, 1, 1, 1)] -df = pd.DataFrame(columns=['col 1'], - data=[1, 2, 3, dt(2014, 1, 5), pd.NaT, np.NaN, np.Inf]) + def test_figure_json_encoding(self): + df = pd.DataFrame(columns=['col 1'], data=[1, 2, 3]) + s1 = Scatter3d(x=numeric_list, y=np_list, z=mixed_list) + s2 = Scatter(x=df['col 1']) + data = Data([s1, s2]) + figure = Figure(data=data) -rng = pd.date_range('1/1/2011', periods=2, freq='H') -ts = pd.Series([1.5, 2.5], index=rng) + js1 = _json.dumps(s1, cls=utils.PlotlyJSONEncoder, sort_keys=True) + js2 = _json.dumps(s2, cls=utils.PlotlyJSONEncoder, sort_keys=True) + assert(js1 == '{"type": "scatter3d", "x": [1, 2, 3], ' + '"y": [1, 2, 3, null, null, null, "2014-01-05T00:00:00"], ' + '"z": [1, "A", "2014-01-05T00:00:00", ' + '"2014-01-05T01:01:01", "2014-01-05T01:01:01.000001"]}') + assert(js2 == '{"type": "scatter", "x": [1, 2, 3]}') -def test_column_json_encoding(): - columns = [ - Column(numeric_list, 'col 1'), - Column(mixed_list, 'col 2'), - Column(np_list, 'col 3') - ] - json_columns = _json.dumps( - columns, cls=utils.PlotlyJSONEncoder, sort_keys=True - ) - assert('[{"data": [1, 2, 3], "name": "col 1"}, ' - '{"data": [1, "A", "2014-01-05", ' - '"2014-01-05 01:01:01", ' - '"2014-01-05 01:01:01.000001"], ' - '"name": "col 2"}, ' - '{"data": [1, 2, 3, null, null, null, ' - '"2014-01-05"], "name": "col 3"}]' == json_columns) - - -def test_figure_json_encoding(): - df = pd.DataFrame(columns=['col 1'], data=[1, 2, 3]) - s1 = Scatter3d(x=numeric_list, y=np_list, z=mixed_list) - s2 = Scatter(x=df['col 1']) - data = Data([s1, s2]) - figure = Figure(data=data) - - js1 = _json.dumps(s1, cls=utils.PlotlyJSONEncoder, sort_keys=True) - js2 = _json.dumps(s2, cls=utils.PlotlyJSONEncoder, sort_keys=True) - - assert(js1 == '{"type": "scatter3d", "x": [1, 2, 3], ' - '"y": [1, 2, 3, null, null, null, "2014-01-05"], ' - '"z": [1, "A", "2014-01-05", ' - '"2014-01-05 01:01:01", "2014-01-05 01:01:01.000001"]}') - assert(js2 == '{"type": "scatter", "x": [1, 2, 3]}') - - # Test JSON encoding works - _json.dumps(data, cls=utils.PlotlyJSONEncoder, sort_keys=True) - _json.dumps(figure, cls=utils.PlotlyJSONEncoder, sort_keys=True) - - # Test data wasn't mutated - np_array = np.array( - [1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)] - ) - for k in range(len(np_array)): - if k in [3, 4]: - # check NaN - assert np.isnan(np_list[k]) and np.isnan(np_array[k]) - else: - # non-NaN - assert np_list[k] == np_array[k] - - assert(set(data[0]['z']) == - set([1, 'A', dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), - dt(2014, 1, 5, 1, 1, 1, 1)])) - - -def test_datetime_json_encoding(): - j1 = _json.dumps(dt_list, cls=utils.PlotlyJSONEncoder) - assert(j1 == '["2014-01-05", ' - '"2014-01-05 01:01:01", ' - '"2014-01-05 01:01:01.000001"]') - j2 = _json.dumps({"x": dt_list}, cls=utils.PlotlyJSONEncoder) - assert(j2 == '{"x": ["2014-01-05", ' - '"2014-01-05 01:01:01", ' - '"2014-01-05 01:01:01.000001"]}') - - -def test_pandas_json_encoding(): - j1 = _json.dumps(df['col 1'], cls=utils.PlotlyJSONEncoder) - print(j1) - print('\n') - assert(j1 == '[1, 2, 3, "2014-01-05", null, null, null]') - - # Test that data wasn't mutated - assert_series_equal(df['col 1'], - pd.Series([1, 2, 3, dt(2014, 1, 5), - pd.NaT, np.NaN, np.Inf], name='col 1')) - - j2 = _json.dumps(df.index, cls=utils.PlotlyJSONEncoder) - assert(j2 == '[0, 1, 2, 3, 4, 5, 6]') - - nat = [pd.NaT] - j3 = _json.dumps(nat, cls=utils.PlotlyJSONEncoder) - assert(j3 == '[null]') - assert(nat[0] is pd.NaT) - - j4 = _json.dumps(rng, cls=utils.PlotlyJSONEncoder) - assert(j4 == '["2011-01-01", "2011-01-01 01:00:00"]') - - j5 = _json.dumps(ts, cls=utils.PlotlyJSONEncoder) - assert(j5 == '[1.5, 2.5]') - assert_series_equal(ts, pd.Series([1.5, 2.5], index=rng)) - - j6 = _json.dumps(ts.index, cls=utils.PlotlyJSONEncoder) - assert(j6 == '["2011-01-01", "2011-01-01 01:00:00"]') - - -def test_numpy_masked_json_encoding(): - l = [1, 2, np.ma.core.masked] - j1 = _json.dumps(l, cls=utils.PlotlyJSONEncoder) - print(j1) - assert(j1 == '[1, 2, null]') + # Test JSON encoding works + _json.dumps(data, cls=utils.PlotlyJSONEncoder, sort_keys=True) + _json.dumps(figure, cls=utils.PlotlyJSONEncoder, sort_keys=True) + + # Test data wasn't mutated + np_array = np.array( + [1, 2, 3, np.NaN, np.NAN, np.Inf, dt(2014, 1, 5)] + ) + for k in range(len(np_array)): + if k in [3, 4]: + # check NaN + assert np.isnan(np_list[k]) and np.isnan(np_array[k]) + else: + # non-NaN + assert np_list[k] == np_array[k] + + assert(set(data[0]['z']) == + set([1, 'A', dt(2014, 1, 5), dt(2014, 1, 5, 1, 1, 1), + dt(2014, 1, 5, 1, 1, 1, 1)])) + + def test_datetime_json_encoding(self): + j1 = _json.dumps(dt_list, cls=utils.PlotlyJSONEncoder) + assert(j1 == '["2014-01-05T00:00:00", ' + '"2014-01-05T01:01:01", ' + '"2014-01-05T01:01:01.000001"]') + j2 = _json.dumps({"x": dt_list}, cls=utils.PlotlyJSONEncoder) + assert(j2 == '{"x": ["2014-01-05T00:00:00", ' + '"2014-01-05T01:01:01", ' + '"2014-01-05T01:01:01.000001"]}') + + def test_pandas_json_encoding(self): + j1 = _json.dumps(df['col 1'], cls=utils.PlotlyJSONEncoder) + print(j1) + print('\n') + assert(j1 == '[1, 2, 3, "2014-01-05T00:00:00", null, null, null]') + + # Test that data wasn't mutated + assert_series_equal(df['col 1'], + pd.Series([1, 2, 3, dt(2014, 1, 5), + pd.NaT, np.NaN, np.Inf], name='col 1')) + + j2 = _json.dumps(df.index, cls=utils.PlotlyJSONEncoder) + assert(j2 == '[0, 1, 2, 3, 4, 5, 6]') + + nat = [pd.NaT] + j3 = _json.dumps(nat, cls=utils.PlotlyJSONEncoder) + assert(j3 == '[null]') + assert(nat[0] is pd.NaT) + + j4 = _json.dumps(rng, cls=utils.PlotlyJSONEncoder) + assert(j4 == '["2011-01-01T00:00:00", "2011-01-01T01:00:00"]') + + j5 = _json.dumps(ts, cls=utils.PlotlyJSONEncoder) + assert(j5 == '[1.5, 2.5]') + assert_series_equal(ts, pd.Series([1.5, 2.5], index=rng)) + + j6 = _json.dumps(ts.index, cls=utils.PlotlyJSONEncoder) + assert(j6 == '["2011-01-01T00:00:00", "2011-01-01T01:00:00"]') + + def test_numpy_masked_json_encoding(self): + l = [1, 2, np.ma.core.masked] + j1 = _json.dumps(l, cls=utils.PlotlyJSONEncoder) + print(j1) + assert(j1 == '[1, 2, null]') + + def test_numpy_dates(self): + a = np.arange(np.datetime64('2011-07-11'), np.datetime64('2011-07-18')) + j1 = _json.dumps(a, cls=utils.PlotlyJSONEncoder) + assert(j1 == '["2011-07-11", "2011-07-12", "2011-07-13", ' + '"2011-07-14", "2011-07-15", "2011-07-16", ' + '"2011-07-17"]') + + + def test_datetime_dot_date(self): + a = [datetime.date(2014, 1, 1), datetime.date(2014, 1, 2)] + j1 = _json.dumps(a, cls=utils.PlotlyJSONEncoder) + assert(j1 == '["2014-01-01", "2014-01-02"]') if matplotlylib: @@ -308,15 +301,3 @@ def test_masked_constants_example(): assert(array == [-398.11793027, -398.11792966, -398.11786308, None]) -def test_numpy_dates(): - a = np.arange(np.datetime64('2011-07-11'), np.datetime64('2011-07-18')) - j1 = _json.dumps(a, cls=utils.PlotlyJSONEncoder) - assert(j1 == '["2011-07-11", "2011-07-12", "2011-07-13", ' - '"2011-07-14", "2011-07-15", "2011-07-16", ' - '"2011-07-17"]') - - -def test_datetime_dot_date(): - a = [datetime.date(2014, 1, 1), datetime.date(2014, 1, 2)] - j1 = _json.dumps(a, cls=utils.PlotlyJSONEncoder) - assert(j1 == '["2014-01-01", "2014-01-02"]') diff --git a/plotly/tests/test_orca/test_image_renderers.py b/plotly/tests/test_orca/test_image_renderers.py index d04bab8e99b..afaff69b0dd 100644 --- a/plotly/tests/test_orca/test_image_renderers.py +++ b/plotly/tests/test_orca/test_image_renderers.py @@ -7,7 +7,8 @@ from plotly import io as pio import plotly.graph_objs as go -from plotly.config import get_config + +from plotly.offline.offline import _get_jconfig if sys.version_info.major == 3 and sys.version_info.minor >= 3: import unittest.mock as mock @@ -119,7 +120,7 @@ def test_mimetype_combination(fig1): pio.to_json(fig1, remove_uids=False)) plotly_mimetype_dict['config'] = { - 'plotlyServerURL': get_config()['plotly_domain']} + 'plotlyServerURL': _get_jconfig()['plotlyServerURL']} # Build expected bundle expected = { @@ -132,4 +133,4 @@ def test_mimetype_combination(fig1): pio.renderers.render_on_display = True bundle = fig1._repr_mimebundle_(None, None) - assert bundle == expected \ No newline at end of file + assert bundle == expected diff --git a/plotly/tests/test_orca/test_to_image.py b/plotly/tests/test_orca/test_to_image.py index ce54b0e6654..5d3f19a170c 100644 --- a/plotly/tests/test_orca/test_to_image.py +++ b/plotly/tests/test_orca/test_to_image.py @@ -58,7 +58,8 @@ def format(request): @pytest.fixture() def fig1(): - return go.Figure(data=[ + pio.templates.default = None + yield go.Figure(data=[ go.Bar(y=[2, 1, 4], marker=go.bar.Marker(color='purple', opacity=0.7)), @@ -69,10 +70,12 @@ def fig1(): 'yaxis': {'showticklabels': False}, 'showlegend': False }) + pio.templates.default = 'plotly' @pytest.fixture() def topofig(): + pio.templates.default = None for col in topo_df.columns: topo_df[col] = topo_df[col].astype(str) @@ -115,11 +118,13 @@ def topofig(): font={'family': 'Arial', 'size': 12}, ) - return dict(data=data, layout=layout) + yield dict(data=data, layout=layout) + pio.templates.default = 'plotly' @pytest.fixture() def latexfig(): + pio.templates.default = None trace1 = go.Scatter( x=[1, 2, 3, 4], y=[1, 4, 9, 16], @@ -142,7 +147,8 @@ def latexfig(): font={'family': 'Arial', 'size': 12} ) fig = go.Figure(data=data, layout=layout) - return fig + yield fig + pio.templates.default = 'plotly' # Utilities diff --git a/plotly/tests/test_plot_ly/__init__.py b/plotly/tests/test_plot_ly/__init__.py deleted file mode 100644 index 8b137891791..00000000000 --- a/plotly/tests/test_plot_ly/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/plotly/tests/test_plot_ly/test_api/__init__.py b/plotly/tests/test_plot_ly/test_api/__init__.py deleted file mode 100644 index 688eb8c8b88..00000000000 --- a/plotly/tests/test_plot_ly/test_api/__init__.py +++ /dev/null @@ -1,66 +0,0 @@ -from __future__ import absolute_import - -from requests import Response - -from plotly.session import sign_in -from plotly.tests.utils import PlotlyTestCase - -import sys - -# import from mock -if sys.version_info.major == 3 and sys.version_info.minor >= 3: - from unittest.mock import patch -else: - from mock import patch - - -class PlotlyApiTestCase(PlotlyTestCase): - - def mock(self, path_string): - patcher = patch(path_string) - new_mock = patcher.start() - self.addCleanup(patcher.stop) - return new_mock - - def setUp(self): - - super(PlotlyApiTestCase, self).setUp() - - self.username = 'foo' - self.api_key = 'bar' - - self.proxy_username = 'cnet' - self.proxy_password = 'hoopla' - self.stream_ids = ['heyThere'] - - self.plotly_api_domain = 'https://api.do.not.exist' - self.plotly_domain = 'https://who.am.i' - self.plotly_proxy_authorization = False - self.plotly_streaming_domain = 'stream.does.not.exist' - self.plotly_ssl_verification = True - - sign_in( - username=self.username, - api_key=self.api_key, - proxy_username=self.proxy_username, - proxy_password=self.proxy_password, - stream_ids=self.stream_ids, - plotly_domain=self.plotly_domain, - plotly_api_domain=self.plotly_api_domain, - plotly_streaming_domain=self.plotly_streaming_domain, - plotly_proxy_authorization=self.plotly_proxy_authorization, - plotly_ssl_verification=self.plotly_ssl_verification - ) - - def to_bytes(self, string): - try: - return string.encode('utf-8') - except AttributeError: - return string - - def get_response(self, content=b'', status_code=200): - response = Response() - response.status_code = status_code - response._content = content - response.encoding = 'utf-8' - return response diff --git a/plotly/tests/test_plot_ly/test_api/test_v1/__init__.py b/plotly/tests/test_plot_ly/test_api/test_v1/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_api/test_v1/test_clientresp.py b/plotly/tests/test_plot_ly/test_api/test_v1/test_clientresp.py deleted file mode 100644 index eba5e2f4294..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v1/test_clientresp.py +++ /dev/null @@ -1,62 +0,0 @@ -from __future__ import absolute_import - -from plotly import version -from plotly.api.v1 import clientresp -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class Duck(object): - def to_plotly_json(self): - return 'what else floats?' - - -class ClientrespTest(PlotlyApiTestCase): - - def setUp(self): - super(ClientrespTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v1.utils.requests.request') - self.request_mock.return_value = self.get_response(b'{}', 200) - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v1.utils.validate_response') - - def test_data_only(self): - data = [{'y': [3, 5], 'name': Duck()}] - clientresp(data) - assert self.request_mock.call_count == 1 - - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual(url, '{}/clientresp'.format(self.plotly_domain)) - expected_data = ({ - 'origin': 'plot', - 'args': '[{"name": "what else floats?", "y": [3, 5]}]', - 'platform': 'python', 'version': version.stable_semver(), 'key': 'bar', - 'kwargs': '{}', 'un': 'foo' - }) - self.assertEqual(kwargs['data'], expected_data) - self.assertTrue(kwargs['verify']) - self.assertEqual(kwargs['headers'], {}) - - def test_data_and_kwargs(self): - data = [{'y': [3, 5], 'name': Duck()}] - clientresp_kwargs = {'layout': {'title': 'mah plot'}, 'filename': 'ok'} - clientresp(data, **clientresp_kwargs) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual(url, '{}/clientresp'.format(self.plotly_domain)) - expected_data = ({ - 'origin': 'plot', - 'args': '[{"name": "what else floats?", "y": [3, 5]}]', - 'platform': 'python', 'version': version.stable_semver(), 'key': 'bar', - 'kwargs': '{"filename": "ok", "layout": {"title": "mah plot"}}', - 'un': 'foo' - }) - self.assertEqual(kwargs['data'], expected_data) - self.assertTrue(kwargs['verify']) - self.assertEqual(kwargs['headers'], {}) diff --git a/plotly/tests/test_plot_ly/test_api/test_v1/test_utils.py b/plotly/tests/test_plot_ly/test_api/test_v1/test_utils.py deleted file mode 100644 index 151ba0419bc..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v1/test_utils.py +++ /dev/null @@ -1,182 +0,0 @@ -from __future__ import absolute_import - -from unittest import TestCase - -from requests import Response -import json as _json -from requests.exceptions import ConnectionError - -from plotly.api.utils import to_native_utf8_string -from plotly.api.v1 import utils -from plotly.exceptions import PlotlyError, PlotlyRequestError -from plotly.session import sign_in -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase -from plotly.tests.utils import PlotlyTestCase - -import sys - -# import from mock, MagicMock -if sys.version_info.major == 3 and sys.version_info.minor >= 3: - from unittest.mock import MagicMock, patch -else: - from mock import patch, MagicMock - - -class ValidateResponseTest(PlotlyApiTestCase): - - def test_validate_ok(self): - try: - utils.validate_response(self.get_response(content=b'{}')) - except PlotlyRequestError: - self.fail('Expected this to pass!') - - def test_validate_not_ok(self): - bad_status_codes = (400, 404, 500) - for bad_status_code in bad_status_codes: - response = self.get_response(content=b'{}', - status_code=bad_status_code) - self.assertRaises(PlotlyRequestError, utils.validate_response, - response) - - def test_validate_no_content(self): - - # We shouldn't flake if the response has no content. - - response = self.get_response(content=b'', status_code=200) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, 'No Content') - self.assertEqual(e.status_code, 200) - self.assertEqual(e.content, b'') - else: - self.fail('Expected this to raise!') - - def test_validate_non_json_content(self): - response = self.get_response(content=b'foobar', status_code=200) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, 'foobar') - self.assertEqual(e.status_code, 200) - self.assertEqual(e.content, b'foobar') - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_array(self): - content = self.to_bytes(_json.dumps([1, 2, 3])) - response = self.get_response(content=content, status_code=200) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, to_native_utf8_string(content)) - self.assertEqual(e.status_code, 200) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_dict_no_error(self): - content = self.to_bytes(_json.dumps({'foo': 'bar'})) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, to_native_utf8_string(content)) - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_dict_error_empty(self): - content = self.to_bytes(_json.dumps({'error': ''})) - response = self.get_response(content=content, status_code=200) - try: - utils.validate_response(response) - except PlotlyRequestError: - self.fail('Expected this not to raise!') - - def test_validate_json_content_dict_one_error_ok(self): - content = self.to_bytes(_json.dumps({'error': 'not ok!'})) - response = self.get_response(content=content, status_code=200) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, 'not ok!') - self.assertEqual(e.status_code, 200) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - -class GetHeadersTest(PlotlyTestCase): - - def setUp(self): - super(GetHeadersTest, self).setUp() - self.domain = 'https://foo.bar' - self.username = 'hodor' - self.api_key = 'secret' - sign_in(self.username, self.api_key, proxy_username='kleen-kanteen', - proxy_password='hydrated', plotly_proxy_authorization=False) - - def test_normal_auth(self): - headers = utils.get_headers() - expected_headers = {} - self.assertEqual(headers, expected_headers) - - def test_proxy_auth(self): - sign_in(self.username, self.api_key, plotly_proxy_authorization=True) - headers = utils.get_headers() - expected_headers = { - 'authorization': 'Basic a2xlZW4ta2FudGVlbjpoeWRyYXRlZA==' - } - self.assertEqual(headers, expected_headers) - - -class RequestTest(PlotlyTestCase): - - def setUp(self): - super(RequestTest, self).setUp() - self.domain = 'https://foo.bar' - self.username = 'hodor' - self.api_key = 'secret' - sign_in(self.username, self.api_key, proxy_username='kleen-kanteen', - proxy_password='hydrated', plotly_proxy_authorization=False) - - # Mock the actual api call, we don't want to do network tests here. - patcher = patch('plotly.api.v1.utils.requests.request') - self.request_mock = patcher.start() - self.addCleanup(patcher.stop) - self.request_mock.return_value = MagicMock(Response) - - # Mock the validation function since we test that elsewhere. - patcher = patch('plotly.api.v1.utils.validate_response') - self.validate_response_mock = patcher.start() - self.addCleanup(patcher.stop) - - self.method = 'get' - self.url = 'https://foo.bar.does.not.exist.anywhere' - - def test_request_with_json(self): - - # You can pass along non-native objects in the `json` kwarg for a - # requests.request, however, V1 packs up json objects a little - # differently, so we don't allow such requests. - - self.assertRaises(PlotlyError, utils.request, self.method, - self.url, json={}) - - def test_request_with_ConnectionError(self): - - # requests can flake out and not return a response object, we want to - # make sure we remain consistent with our errors. - - self.request_mock.side_effect = ConnectionError() - self.assertRaises(PlotlyRequestError, utils.request, self.method, - self.url) - - def test_request_validate_response(self): - - # Finally, we check details elsewhere, but make sure we do validate. - - utils.request(self.method, self.url) - assert self.validate_response_mock.call_count == 1 diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/__init__.py b/plotly/tests/test_plot_ly/test_api/test_v2/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_files.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_files.py deleted file mode 100644 index 3ef68bf5cce..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_files.py +++ /dev/null @@ -1,104 +0,0 @@ -from __future__ import absolute_import - -from plotly.api.v2 import files -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class FilesTest(PlotlyApiTestCase): - - def setUp(self): - super(FilesTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_retrieve(self): - files.retrieve('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/files/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {}) - - def test_retrieve_share_key(self): - files.retrieve('hodor:88', share_key='foobar') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/files/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'share_key': 'foobar'}) - - def test_update(self): - new_filename = '..zzZ ..zzZ' - files.update('hodor:88', body={'filename': new_filename}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'put') - self.assertEqual( - url, '{}/v2/files/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['data'], - '{{"filename": "{}"}}'.format(new_filename)) - - def test_trash(self): - files.trash('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/files/hodor:88/trash'.format(self.plotly_api_domain) - ) - - def test_restore(self): - files.restore('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/files/hodor:88/restore'.format(self.plotly_api_domain) - ) - - def test_permanent_delete(self): - files.permanent_delete('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'delete') - self.assertEqual( - url, - '{}/v2/files/hodor:88/permanent_delete' - .format(self.plotly_api_domain) - ) - - def test_lookup(self): - - # requests does urlencode, so don't worry about the `' '` character! - - path = '/mah plot' - parent = 43 - user = 'someone' - exists = True - files.lookup(path=path, parent=parent, user=user, exists=exists) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - expected_params = {'path': path, 'parent': parent, 'exists': 'true', - 'user': user} - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/files/lookup'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], expected_params) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_folders.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_folders.py deleted file mode 100644 index 1775c57839a..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_folders.py +++ /dev/null @@ -1,114 +0,0 @@ -from __future__ import absolute_import - -from plotly.api.v2 import folders -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class FoldersTest(PlotlyApiTestCase): - - def setUp(self): - super(FoldersTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_create(self): - path = '/foo/man/bar/' - folders.create({'path': path}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual(url, '{}/v2/folders'.format(self.plotly_api_domain)) - self.assertEqual(kwargs['data'], '{{"path": "{}"}}'.format(path)) - - def test_retrieve(self): - folders.retrieve('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/folders/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {}) - - def test_retrieve_share_key(self): - folders.retrieve('hodor:88', share_key='foobar') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/folders/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'share_key': 'foobar'}) - - def test_update(self): - new_filename = '..zzZ ..zzZ' - folders.update('hodor:88', body={'filename': new_filename}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'put') - self.assertEqual( - url, '{}/v2/folders/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['data'], - '{{"filename": "{}"}}'.format(new_filename)) - - def test_trash(self): - folders.trash('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/folders/hodor:88/trash'.format(self.plotly_api_domain) - ) - - def test_restore(self): - folders.restore('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/folders/hodor:88/restore'.format(self.plotly_api_domain) - ) - - def test_permanent_delete(self): - folders.permanent_delete('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'delete') - self.assertEqual( - url, - '{}/v2/folders/hodor:88/permanent_delete' - .format(self.plotly_api_domain) - ) - - def test_lookup(self): - - # requests does urlencode, so don't worry about the `' '` character! - - path = '/mah folder' - parent = 43 - user = 'someone' - exists = True - folders.lookup(path=path, parent=parent, user=user, exists=exists) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - expected_params = {'path': path, 'parent': parent, 'exists': 'true', - 'user': user} - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/folders/lookup'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], expected_params) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_grids.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_grids.py deleted file mode 100644 index c356bf928d8..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_grids.py +++ /dev/null @@ -1,185 +0,0 @@ -from __future__ import absolute_import - -import json as _json - -from plotly.api.v2 import grids -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class GridsTest(PlotlyApiTestCase): - - def setUp(self): - super(GridsTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_create(self): - filename = 'a grid' - grids.create({'filename': filename}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual(url, '{}/v2/grids'.format(self.plotly_api_domain)) - self.assertEqual( - kwargs['data'], '{{"filename": "{}"}}'.format(filename) - ) - - def test_retrieve(self): - grids.retrieve('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/grids/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {}) - - def test_retrieve_share_key(self): - grids.retrieve('hodor:88', share_key='foobar') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/grids/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'share_key': 'foobar'}) - - def test_update(self): - new_filename = '..zzZ ..zzZ' - grids.update('hodor:88', body={'filename': new_filename}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'put') - self.assertEqual( - url, '{}/v2/grids/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['data'], - '{{"filename": "{}"}}'.format(new_filename)) - - def test_trash(self): - grids.trash('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/grids/hodor:88/trash'.format(self.plotly_api_domain) - ) - - def test_restore(self): - grids.restore('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/grids/hodor:88/restore'.format(self.plotly_api_domain) - ) - - def test_permanent_delete(self): - grids.permanent_delete('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'delete') - self.assertEqual( - url, - '{}/v2/grids/hodor:88/permanent_delete' - .format(self.plotly_api_domain) - ) - - def test_lookup(self): - - # requests does urlencode, so don't worry about the `' '` character! - - path = '/mah grid' - parent = 43 - user = 'someone' - exists = True - grids.lookup(path=path, parent=parent, user=user, exists=exists) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - expected_params = {'path': path, 'parent': parent, 'exists': 'true', - 'user': user} - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/grids/lookup'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], expected_params) - - def test_col_create(self): - cols = [ - {'name': 'foo', 'data': [1, 2, 3]}, - {'name': 'bar', 'data': ['b', 'a', 'r']}, - ] - body = {'cols': _json.dumps(cols, sort_keys=True)} - grids.col_create('hodor:88', body) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/grids/hodor:88/col'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['data'], _json.dumps(body, sort_keys=True)) - - def test_col_retrieve(self): - grids.col_retrieve('hodor:88', 'aaaaaa,bbbbbb') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/grids/hodor:88/col'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'uid': 'aaaaaa,bbbbbb'}) - - def test_col_update(self): - cols = [ - {'name': 'foo', 'data': [1, 2, 3]}, - {'name': 'bar', 'data': ['b', 'a', 'r']}, - ] - body = {'cols': _json.dumps(cols, sort_keys=True)} - grids.col_update('hodor:88', 'aaaaaa,bbbbbb', body) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'put') - self.assertEqual( - url, '{}/v2/grids/hodor:88/col'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'uid': 'aaaaaa,bbbbbb'}) - self.assertEqual(kwargs['data'], _json.dumps(body, sort_keys=True)) - - def test_col_delete(self): - grids.col_delete('hodor:88', 'aaaaaa,bbbbbb') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'delete') - self.assertEqual( - url, '{}/v2/grids/hodor:88/col'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'uid': 'aaaaaa,bbbbbb'}) - - def test_row(self): - body = {'rows': [[1, 'A'], [2, 'B']]} - grids.row('hodor:88', body) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/grids/hodor:88/row'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['data'], _json.dumps(body, sort_keys=True)) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_images.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_images.py deleted file mode 100644 index bc43f9776fe..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_images.py +++ /dev/null @@ -1,41 +0,0 @@ -from __future__ import absolute_import - -import json as _json - -from plotly.api.v2 import images -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class ImagesTest(PlotlyApiTestCase): - - def setUp(self): - super(ImagesTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_create(self): - - body = { - "figure": { - "data": [{"y": [10, 10, 2, 20]}], - "layout": {"width": 700} - }, - "width": 1000, - "height": 500, - "format": "png", - "scale": 4, - "encoded": False - } - - images.create(body) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual(url, '{}/v2/images'.format(self.plotly_api_domain)) - self.assertEqual(kwargs['data'], _json.dumps(body, sort_keys=True)) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_plot_schema.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_plot_schema.py deleted file mode 100644 index 77b5d805ecd..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_plot_schema.py +++ /dev/null @@ -1,30 +0,0 @@ -from __future__ import absolute_import - -from plotly.api.v2 import plot_schema -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class PlotSchemaTest(PlotlyApiTestCase): - - def setUp(self): - super(PlotSchemaTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_retrieve(self): - - plot_schema.retrieve('some-hash', timeout=400) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/plot-schema'.format(self.plotly_api_domain) - ) - self.assertTrue(kwargs['timeout']) - self.assertEqual(kwargs['params'], {'sha1': 'some-hash'}) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_plots.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_plots.py deleted file mode 100644 index 17f243ae8e1..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_plots.py +++ /dev/null @@ -1,116 +0,0 @@ -from __future__ import absolute_import - -from plotly.api.v2 import plots -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class PlotsTest(PlotlyApiTestCase): - - def setUp(self): - super(PlotsTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_create(self): - filename = 'a plot' - plots.create({'filename': filename}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual(url, '{}/v2/plots'.format(self.plotly_api_domain)) - self.assertEqual( - kwargs['data'], '{{"filename": "{}"}}'.format(filename) - ) - - def test_retrieve(self): - plots.retrieve('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/plots/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {}) - - def test_retrieve_share_key(self): - plots.retrieve('hodor:88', share_key='foobar') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/plots/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], {'share_key': 'foobar'}) - - def test_update(self): - new_filename = '..zzZ ..zzZ' - plots.update('hodor:88', body={'filename': new_filename}) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'put') - self.assertEqual( - url, '{}/v2/plots/hodor:88'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['data'], - '{{"filename": "{}"}}'.format(new_filename)) - - def test_trash(self): - plots.trash('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/plots/hodor:88/trash'.format(self.plotly_api_domain) - ) - - def test_restore(self): - plots.restore('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'post') - self.assertEqual( - url, '{}/v2/plots/hodor:88/restore'.format(self.plotly_api_domain) - ) - - def test_permanent_delete(self): - plots.permanent_delete('hodor:88') - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'delete') - self.assertEqual( - url, - '{}/v2/plots/hodor:88/permanent_delete' - .format(self.plotly_api_domain) - ) - - def test_lookup(self): - - # requests does urlencode, so don't worry about the `' '` character! - - path = '/mah plot' - parent = 43 - user = 'someone' - exists = True - plots.lookup(path=path, parent=parent, user=user, exists=exists) - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - expected_params = {'path': path, 'parent': parent, 'exists': 'true', - 'user': user} - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/plots/lookup'.format(self.plotly_api_domain) - ) - self.assertEqual(kwargs['params'], expected_params) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_users.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_users.py deleted file mode 100644 index b5a69212d22..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_users.py +++ /dev/null @@ -1,28 +0,0 @@ -from __future__ import absolute_import - -from plotly.api.v2 import users -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class UsersTest(PlotlyApiTestCase): - - def setUp(self): - super(UsersTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.mock('plotly.api.v2.utils.validate_response') - - def test_current(self): - users.current() - assert self.request_mock.call_count == 1 - args, kwargs = self.request_mock.call_args - method, url = args - self.assertEqual(method, 'get') - self.assertEqual( - url, '{}/v2/users/current'.format(self.plotly_api_domain) - ) - self.assertNotIn('params', kwargs) diff --git a/plotly/tests/test_plot_ly/test_api/test_v2/test_utils.py b/plotly/tests/test_plot_ly/test_api/test_v2/test_utils.py deleted file mode 100644 index 96721fe621e..00000000000 --- a/plotly/tests/test_plot_ly/test_api/test_v2/test_utils.py +++ /dev/null @@ -1,252 +0,0 @@ -from __future__ import absolute_import - -import json as _json -from requests.exceptions import ConnectionError - -from plotly import version -from plotly.api.utils import to_native_utf8_string -from plotly.api.v2 import utils -from plotly.exceptions import PlotlyRequestError -from plotly.session import sign_in -from plotly.tests.test_plot_ly.test_api import PlotlyApiTestCase - - -class MakeParamsTest(PlotlyApiTestCase): - - def test_make_params(self): - params = utils.make_params(foo='FOO', bar=None) - self.assertEqual(params, {'foo': 'FOO'}) - - def test_make_params_empty(self): - params = utils.make_params(foo=None, bar=None) - self.assertEqual(params, {}) - - -class BuildUrlTest(PlotlyApiTestCase): - - def test_build_url(self): - url = utils.build_url('cats') - self.assertEqual(url, '{}/v2/cats'.format(self.plotly_api_domain)) - - def test_build_url_id(self): - url = utils.build_url('cats', id='MsKitty') - self.assertEqual( - url, '{}/v2/cats/MsKitty'.format(self.plotly_api_domain) - ) - - def test_build_url_route(self): - url = utils.build_url('cats', route='about') - self.assertEqual( - url, '{}/v2/cats/about'.format(self.plotly_api_domain) - ) - - def test_build_url_id_route(self): - url = utils.build_url('cats', id='MsKitty', route='de-claw') - self.assertEqual( - url, '{}/v2/cats/MsKitty/de-claw'.format(self.plotly_api_domain) - ) - - -class ValidateResponseTest(PlotlyApiTestCase): - - def test_validate_ok(self): - try: - utils.validate_response(self.get_response()) - except PlotlyRequestError: - self.fail('Expected this to pass!') - - def test_validate_not_ok(self): - bad_status_codes = (400, 404, 500) - for bad_status_code in bad_status_codes: - response = self.get_response(status_code=bad_status_code) - self.assertRaises(PlotlyRequestError, utils.validate_response, - response) - - def test_validate_no_content(self): - - # We shouldn't flake if the response has no content. - - response = self.get_response(content=b'', status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, u'No Content') - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content.decode('utf-8'), u'') - else: - self.fail('Expected this to raise!') - - def test_validate_non_json_content(self): - response = self.get_response(content=b'foobar', status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, 'foobar') - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, b'foobar') - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_array(self): - content = self.to_bytes(_json.dumps([1, 2, 3])) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, to_native_utf8_string(content)) - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_dict_no_errors(self): - content = self.to_bytes(_json.dumps({'foo': 'bar'})) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, to_native_utf8_string(content)) - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_dict_one_error_bad(self): - content = self.to_bytes(_json.dumps({'errors': [{}]})) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, to_native_utf8_string(content)) - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - content = self.to_bytes(_json.dumps({'errors': [{'message': ''}]})) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, to_native_utf8_string(content)) - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_dict_one_error_ok(self): - content = self.to_bytes(_json.dumps( - {'errors': [{'message': 'not ok!'}]})) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, 'not ok!') - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - def test_validate_json_content_dict_multiple_errors(self): - content = self.to_bytes(_json.dumps({'errors': [ - {'message': 'not ok!'}, {'message': 'bad job...'} - ]})) - response = self.get_response(content=content, status_code=400) - try: - utils.validate_response(response) - except PlotlyRequestError as e: - self.assertEqual(e.message, 'not ok!\nbad job...') - self.assertEqual(e.status_code, 400) - self.assertEqual(e.content, content) - else: - self.fail('Expected this to raise!') - - -class GetHeadersTest(PlotlyApiTestCase): - - def test_normal_auth(self): - headers = utils.get_headers() - expected_headers = { - 'plotly-client-platform': 'python {}'.format(version.stable_semver()), - 'authorization': 'Basic Zm9vOmJhcg==', - 'content-type': 'application/json' - } - self.assertEqual(headers, expected_headers) - - def test_proxy_auth(self): - sign_in(self.username, self.api_key, plotly_proxy_authorization=True) - headers = utils.get_headers() - expected_headers = { - 'plotly-client-platform': 'python {}'.format(version.stable_semver()), - 'authorization': 'Basic Y25ldDpob29wbGE=', - 'plotly-authorization': 'Basic Zm9vOmJhcg==', - 'content-type': 'application/json' - } - self.assertEqual(headers, expected_headers) - - -class RequestTest(PlotlyApiTestCase): - - def setUp(self): - super(RequestTest, self).setUp() - - # Mock the actual api call, we don't want to do network tests here. - self.request_mock = self.mock('plotly.api.v2.utils.requests.request') - self.request_mock.return_value = self.get_response() - - # Mock the validation function since we can test that elsewhere. - self.validate_response_mock = self.mock( - 'plotly.api.v2.utils.validate_response') - - self.method = 'get' - self.url = 'https://foo.bar.does.not.exist.anywhere' - - def test_request_with_params(self): - - # urlencode transforms `True` --> `'True'`, which isn't super helpful, - # Our backend accepts the JS `true`, so we want `True` --> `'true'`. - - params = {'foo': True, 'bar': 'True', 'baz': False, 'zap': 0} - utils.request(self.method, self.url, params=params) - args, kwargs = self.request_mock.call_args - method, url = args - expected_params = {'foo': 'true', 'bar': 'True', 'baz': 'false', - 'zap': 0} - self.assertEqual(method, self.method) - self.assertEqual(url, self.url) - self.assertEqual(kwargs['params'], expected_params) - - def test_request_with_non_native_objects(self): - - # We always send along json, but it may contain non-native objects like - # a pandas array or a Column reference. Make sure that's handled in one - # central place. - - class Duck(object): - def to_plotly_json(self): - return 'what else floats?' - - utils.request(self.method, self.url, json={'foo': [Duck(), Duck()]}) - args, kwargs = self.request_mock.call_args - method, url = args - expected_data = '{"foo": ["what else floats?", "what else floats?"]}' - self.assertEqual(method, self.method) - self.assertEqual(url, self.url) - self.assertEqual(kwargs['data'], expected_data) - self.assertNotIn('json', kwargs) - - def test_request_with_ConnectionError(self): - - # requests can flake out and not return a response object, we want to - # make sure we remain consistent with our errors. - - self.request_mock.side_effect = ConnectionError() - self.assertRaises(PlotlyRequestError, utils.request, self.method, - self.url) - - def test_request_validate_response(self): - - # Finally, we check details elsewhere, but make sure we do validate. - - utils.request(self.method, self.url) - assert self.request_mock.call_count == 1 diff --git a/plotly/tests/test_plot_ly/test_dashboard/__init__.py b/plotly/tests/test_plot_ly/test_dashboard/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_dashboard/test_dashboard.py b/plotly/tests/test_plot_ly/test_dashboard/test_dashboard.py deleted file mode 100644 index a9f1c10fe53..00000000000 --- a/plotly/tests/test_plot_ly/test_dashboard/test_dashboard.py +++ /dev/null @@ -1,141 +0,0 @@ -""" -test_dashboard: -========== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -from unittest import TestCase -from plotly.exceptions import PlotlyError -import plotly.dashboard_objs as dashboard - - -class TestDashboard(TestCase): - - def test_invalid_path(self): - - my_box = { - 'type': 'box', - 'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1' - } - dash = dashboard.Dashboard() - - message = ( - "Invalid path. Your 'path' list must only contain " - "the strings 'first' and 'second'." - ) - - self.assertRaisesRegexp(PlotlyError, message, - dash._insert, my_box, 'third') - - def test_box_id_none(self): - - my_box = { - 'type': 'box', - 'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1' - } - - dash = dashboard.Dashboard() - dash.insert(my_box, 'above', None) - - message = ( - "Make sure the box_id is specfied if there is at least " - "one box in your dashboard." - ) - - self.assertRaisesRegexp(PlotlyError, message, dash.insert, - my_box, 'above', None) - - def test_id_not_valid(self): - my_box = { - 'type': 'box', - 'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1' - } - - message = ( - "Your box_id must be a number in your dashboard. To view a " - "representation of your dashboard run get_preview()." - ) - - dash = dashboard.Dashboard() - dash.insert(my_box, 'above', 1) - - # insert box - self.assertRaisesRegexp(PlotlyError, message, dash.insert, my_box, - 'above', 0) - # get box by id - self.assertRaisesRegexp(PlotlyError, message, dash.get_box, 0) - - # remove box - self.assertRaisesRegexp(PlotlyError, message, dash.remove, 0) - - def test_invalid_side(self): - my_box = { - 'type': 'box', - 'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1' - } - - message = ( - "If there is at least one box in your dashboard, you " - "must specify a valid side value. You must choose from " - "'above', 'below', 'left', and 'right'." - ) - - dash = dashboard.Dashboard() - dash.insert(my_box, 'above', 0) - - self.assertRaisesRegexp(PlotlyError, message, dash.insert, - my_box, 'somewhere', 1) - - def test_dashboard_dict(self): - my_box = { - 'type': 'box', - 'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1' - } - - dash = dashboard.Dashboard() - dash.insert(my_box) - dash.insert(my_box, 'above', 1) - - expected_dashboard = { - 'layout': {'direction': 'vertical', - 'first': {'direction': 'vertical', - 'first': {'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1', - 'type': 'box'}, - 'second': {'boxType': 'plot', - 'fileId': 'AdamKulidjian:327', - 'shareKey': None, - 'title': 'box 1', - 'type': 'box'}, - 'size': 50, - 'sizeUnit': '%', - 'type': 'split'}, - 'second': {'boxType': 'empty', 'type': 'box'}, - 'size': 1500, - 'sizeUnit': 'px', - 'type': 'split'}, - 'settings': {}, - 'version': 2 - } - - self.assertEqual(dash['layout'], expected_dashboard['layout']) diff --git a/plotly/tests/test_plot_ly/test_file/__init__.py b/plotly/tests/test_plot_ly/test_file/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_file/test_file.py b/plotly/tests/test_plot_ly/test_file/test_file.py deleted file mode 100644 index 6761336eb65..00000000000 --- a/plotly/tests/test_plot_ly/test_file/test_file.py +++ /dev/null @@ -1,55 +0,0 @@ -""" -test_meta: -========== - -A module intended for use with Nose. - -""" -import random -import string - -from nose.plugins.attrib import attr - -import plotly.plotly as py -from plotly.exceptions import PlotlyRequestError -from plotly.tests.utils import PlotlyTestCase - - -@attr('slow') -class FolderAPITestCase(PlotlyTestCase): - - def setUp(self): - super(FolderAPITestCase, self).setUp() - py.sign_in('PythonTest', 'xnyU0DEwvAQQCwHVseIL') - - def _random_filename(self): - choice_chars = string.ascii_letters + string.digits - random_chars = [random.choice(choice_chars) for _ in range(10)] - unique_filename = 'Valid Folder ' + ''.join(random_chars) - return unique_filename - - def test_create_folder(self): - try: - py.file_ops.mkdirs(self._random_filename()) - except PlotlyRequestError as e: - self.fail('Expected this *not* to fail! Status: {}' - .format(e.status_code)) - - def test_create_nested_folders(self): - first_folder = self._random_filename() - nested_folder = '{0}/{1}'.format(first_folder, self._random_filename()) - try: - py.file_ops.mkdirs(nested_folder) - except PlotlyRequestError as e: - self.fail('Expected this *not* to fail! Status: {}' - .format(e.status_code)) - - def test_duplicate_folders(self): - first_folder = self._random_filename() - py.file_ops.mkdirs(first_folder) - try: - py.file_ops.mkdirs(first_folder) - except PlotlyRequestError as e: - pass - else: - self.fail('Expected this to fail!') diff --git a/plotly/tests/test_plot_ly/test_get_figure/__init__.py b/plotly/tests/test_plot_ly/test_get_figure/__init__.py deleted file mode 100644 index 1118eb01e82..00000000000 --- a/plotly/tests/test_plot_ly/test_get_figure/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import warnings - - -def setup_package(): - warnings.filterwarnings('ignore') diff --git a/plotly/tests/test_plot_ly/test_get_figure/test_get_figure.py b/plotly/tests/test_plot_ly/test_get_figure/test_get_figure.py deleted file mode 100644 index 368835a80c9..00000000000 --- a/plotly/tests/test_plot_ly/test_get_figure/test_get_figure.py +++ /dev/null @@ -1,109 +0,0 @@ -""" -test_get_figure: -================= - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -from unittest import TestCase, skipIf - -import six -from nose.plugins.attrib import attr - -from plotly import exceptions -from plotly.plotly import plotly as py -from plotly.tests.utils import PlotlyTestCase - - -def is_trivial(obj): - if isinstance(obj, (dict, list)): - if len(obj): - if isinstance(obj, dict): - tests = (is_trivial(obj[key]) for key in obj) - return all(tests) - elif isinstance(obj, list): - tests = (is_trivial(entry) for entry in obj) - return all(tests) - else: - return False - else: - return True - elif obj is None: - return True - else: - return False - - -class GetFigureTest(PlotlyTestCase): - - @attr('slow') - def test_get_figure(self): - un = 'PlotlyImageTest' - ak = '786r5mecv0' - 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/13183/" - py.sign_in(un, ak) - py.get_figure(url) - - def test_get_figure_invalid_1(self): - un = 'PlotlyImageTest' - ak = '786r5mecv0' - url = "https://plot.ly/~PlotlyImageTest/a/" - py.sign_in(un, ak) - with self.assertRaises(exceptions.PlotlyError): - py.get_figure(url) - - @attr('slow') - def test_get_figure_invalid_2(self): - un = 'PlotlyImageTest' - ak = '786r5mecv0' - url = "https://plot.ly/~PlotlyImageTest/-1/" - py.sign_in(un, ak) - 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' - ak = '786r5mecv0' - url = "https://plot.ly/~PlotlyImageTest/1000000000/" - py.sign_in(un, ak) - with self.assertRaises(exceptions.PlotlyError): - py.get_figure(url) - - @attr('slow') - def test_get_figure_raw(self): - un = 'PlotlyImageTest' - ak = '786r5mecv0' - file_id = 2 - py.sign_in(un, ak) - py.get_figure('PlotlyImageTest', str(file_id), raw=True) - - -class TestBytesVStrings(PlotlyTestCase): - - @skipIf(not six.PY3, 'Decoding and missing escapes only seen in PY3') - def test_proper_escaping(self): - un = 'PlotlyImageTest' - ak = '786r5mecv0' - url = "https://plot.ly/~PlotlyImageTest/13185/" - py.sign_in(un, ak) - py.get_figure(url) diff --git a/plotly/tests/test_plot_ly/test_get_requests/__init__.py b/plotly/tests/test_plot_ly/test_get_requests/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_get_requests/test_get_requests.py b/plotly/tests/test_plot_ly/test_get_requests/test_get_requests.py deleted file mode 100644 index b796f4883cd..00000000000 --- a/plotly/tests/test_plot_ly/test_get_requests/test_get_requests.py +++ /dev/null @@ -1,142 +0,0 @@ -""" -test_get_requests: -================== - -A module intended for use with Nose. - -""" -import copy - -import requests -import six -from nose.plugins.attrib import attr -import json as _json - -from plotly.tests.utils import PlotlyTestCase - -default_headers = {'plotly-username': '', - 'plotly-apikey': '', - 'plotly-version': '2.0', - 'plotly-platform': 'pythonz'} - -server = "https://plot.ly" - - -class GetRequestsTest(PlotlyTestCase): - - @attr('slow') - def test_user_does_not_exist(self): - username = 'user_does_not_exist' - api_key = 'invalid-apikey' - file_owner = 'get_test_user' - file_id = 0 - hd = copy.copy(default_headers) - hd['plotly-username'] = username - hd['plotly-apikey'] = api_key - resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id) - response = requests.get(server + resource, headers=hd) - if six.PY3: - content = _json.loads(response.content.decode('unicode_escape')) - else: - content = _json.loads(response.content) - error_message = ("Aw, snap! We don't have an account for {0}. Want to " - "try again? Sign in is not case sensitive." - .format(username)) - self.assertEqual(response.status_code, 404) - self.assertEqual(content['error'], error_message) - - @attr('slow') - def test_file_does_not_exist(self): - username = 'PlotlyImageTest' - api_key = '786r5mecv0' - file_owner = 'get_test_user' - file_id = 1000 - hd = copy.copy(default_headers) - hd['plotly-username'] = username - hd['plotly-apikey'] = api_key - resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id) - response = requests.get(server + resource, headers=hd) - if six.PY3: - content = _json.loads(response.content.decode('unicode_escape')) - else: - content = _json.loads(response.content) - error_message = ("Aw, snap! It looks like this file does " - "not exist. Want to try again?") - self.assertEqual(response.status_code, 404) - self.assertEqual(content['error'], error_message) - - @attr('slow') - def test_wrong_api_key(self): # TODO: does this test the right thing? - username = 'PlotlyImageTest' - api_key = 'invalid-apikey' - file_owner = 'get_test_user' - file_id = 0 - hd = copy.copy(default_headers) - hd['plotly-username'] = username - hd['plotly-apikey'] = api_key - resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id) - response = requests.get(server + resource, headers=hd) - self.assertEqual(response.status_code, 401) - # TODO: check error message? - - # Locked File - # TODO - - @attr('slow') - def test_private_permission_defined(self): - username = 'PlotlyImageTest' - api_key = '786r5mecv0' - file_owner = 'get_test_user' - file_id = 1 # 1 is a private file - hd = copy.copy(default_headers) - hd['plotly-username'] = username - hd['plotly-apikey'] = api_key - resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id) - response = requests.get(server + resource, headers=hd) - if six.PY3: - content = _json.loads(response.content.decode('unicode_escape')) - else: - content = _json.loads(response.content) - self.assertEqual(response.status_code, 403) - - # Private File that is shared - # TODO - - @attr('slow') - def test_missing_headers(self): - file_owner = 'get_test_user' - file_id = 0 - resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id) - headers = list(default_headers.keys()) - for header in headers: - hd = copy.copy(default_headers) - del hd[header] - response = requests.get(server + resource, headers=hd) - if six.PY3: - content = _json.loads(response.content.decode('unicode_escape')) - else: - content = _json.loads(response.content) - self.assertEqual(response.status_code, 422) - - @attr('slow') - def test_valid_request(self): - username = 'PlotlyImageTest' - api_key = '786r5mecv0' - file_owner = 'get_test_user' - file_id = 0 - hd = copy.copy(default_headers) - hd['plotly-username'] = username - hd['plotly-apikey'] = api_key - resource = "/apigetfile/{0}/{1}/".format(file_owner, file_id) - response = requests.get(server + resource, headers=hd) - if six.PY3: - content = _json.loads(response.content.decode('unicode_escape')) - else: - content = _json.loads(response.content) - self.assertEqual(response.status_code, 200) - # content = _json.loads(res.content) - # response_payload = content['payload'] - # figure = response_payload['figure'] - # if figure['data'][0]['x'] != [u'1', u'2', u'3']: - # print('ERROR') - # return res diff --git a/plotly/tests/test_plot_ly/test_grid/__init__.py b/plotly/tests/test_plot_ly/test_grid/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_grid/test_grid.py b/plotly/tests/test_plot_ly/test_grid/test_grid.py deleted file mode 100644 index 9260e51c936..00000000000 --- a/plotly/tests/test_plot_ly/test_grid/test_grid.py +++ /dev/null @@ -1,183 +0,0 @@ -""" -test_grid: -========== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -import random -import string -from unittest import skip - -from nose.plugins.attrib import attr - -import plotly.plotly as py -from plotly.exceptions import InputError, PlotlyRequestError, PlotlyError -from plotly.graph_objs import Scatter -from plotly.grid_objs import Column, Grid -from plotly.plotly import parse_grid_id_args -from plotly.tests.utils import PlotlyTestCase - - -def random_filename(): - choice_chars = string.ascii_letters + string.digits - random_chars = [random.choice(choice_chars) for _ in range(10)] - unique_filename = 'Valid Grid ' + ''.join(random_chars) - return unique_filename - - -class GridTest(PlotlyTestCase): - - # Test grid args - _grid_id = 'chris:3043' - _grid = Grid([]) - _grid.id = _grid_id - _grid_url = 'https://plot.ly/~chris/3043/my-grid' - - def setUp(self): - super(GridTest, self).setUp() - py.sign_in('PythonTest', 'xnyU0DEwvAQQCwHVseIL') - - def get_grid(self): - c1 = Column([1, 2, 3, 4], 'first column') - c2 = Column(['a', 'b', 'c', 'd'], 'second column') - g = Grid([c1, c2]) - return g - - def upload_and_return_grid(self): - g = self.get_grid() - unique_filename = random_filename() - py.grid_ops.upload(g, unique_filename, auto_open=False) - return g - - # Nominal usage - @attr('slow') - def test_grid_upload(self): - self.upload_and_return_grid() - - @attr('slow') - def test_grid_upload_in_new_folder(self): - g = self.get_grid() - path = ( - 'new folder: {0}/grid in folder {1}' - .format(random_filename(), random_filename()) - ) - py.grid_ops.upload(g, path, auto_open=False) - - @attr('slow') - def test_grid_upload_in_existing_folder(self): - g = self.get_grid() - folder = random_filename() - filename = random_filename() - py.file_ops.mkdirs(folder) - path = ( - 'existing folder: {0}/grid in folder {1}' - .format(folder, filename) - ) - py.grid_ops.upload(g, path, auto_open=False) - - @attr('slow') - def test_column_append(self): - g = self.upload_and_return_grid() - new_col = Column([1, 5, 3], 'new col') - py.grid_ops.append_columns([new_col], grid=g) - - @attr('slow') - def test_row_append(self): - g = self.upload_and_return_grid() - new_rows = [[1, 2], [10, 20]] - py.grid_ops.append_rows(new_rows, grid=g) - - @attr('slow') - def test_plot_from_grid(self): - g = self.upload_and_return_grid() - url = py.plot([Scatter(xsrc=g[0].id, ysrc=g[1].id)], - auto_open=False, filename='plot from grid') - return url, g - - @attr('slow') - def test_get_figure_from_references(self): - url, g = self.test_plot_from_grid() - fig = py.get_figure(url) - data = fig['data'] - trace = data[0] - assert(tuple(g[0].data) == tuple(trace['x'])) - assert(tuple(g[1].data) == tuple(trace['y'])) - - def test_grid_id_args(self): - self.assertEqual(parse_grid_id_args(self._grid, None), - parse_grid_id_args(None, self._grid_url)) - - def test_no_grid_id_args(self): - with self.assertRaises(InputError): - parse_grid_id_args(None, None) - - def test_overspecified_grid_args(self): - with self.assertRaises(InputError): - parse_grid_id_args(self._grid, self._grid_url) - - # not broken anymore since plotly 3.0.0 - # def test_scatter_from_non_uploaded_grid(self): - # c1 = Column([1, 2, 3, 4], 'first column') - # c2 = Column(['a', 'b', 'c', 'd'], 'second column') - # g = Grid([c1, c2]) - # with self.assertRaises(ValueError): - # Scatter(xsrc=g[0], ysrc=g[1]) - - def test_column_append_of_non_uploaded_grid(self): - c1 = Column([1, 2, 3, 4], 'first column') - c2 = Column(['a', 'b', 'c', 'd'], 'second column') - g = Grid([c1]) - with self.assertRaises(PlotlyError): - py.grid_ops.append_columns([c2], grid=g) - - def test_row_append_of_non_uploaded_grid(self): - c1 = Column([1, 2, 3, 4], 'first column') - rows = [[1], [2]] - g = Grid([c1]) - with self.assertRaises(PlotlyError): - py.grid_ops.append_rows(rows, grid=g) - - # Input Errors - @attr('slow') - def test_unequal_length_rows(self): - g = self.upload_and_return_grid() - rows = [[1, 2], ['to', 'many', 'cells']] - with self.assertRaises(InputError): - py.grid_ops.append_rows(rows, grid=g) - - # Test duplicate columns - def test_duplicate_columns(self): - c1 = Column([1, 2, 3, 4], 'first column') - c2 = Column(['a', 'b', 'c', 'd'], 'first column') - with self.assertRaises(InputError): - Grid([c1, c2]) - - # Test delete - @attr('slow') - def test_delete_grid(self): - g = self.get_grid() - fn = random_filename() - py.grid_ops.upload(g, fn, auto_open=False) - py.grid_ops.delete(g) - py.grid_ops.upload(g, fn, auto_open=False) - - # Plotly failures - @skip('adding this for now so test_file_tools pass, more info' + - 'https://github.com/plotly/python-api/issues/262') - def test_duplicate_filenames(self): - c1 = Column([1, 2, 3, 4], 'first column') - g = Grid([c1]) - - random_chars = [random.choice(string.ascii_uppercase) - for _ in range(5)] - unique_filename = 'Valid Grid ' + ''.join(random_chars) - py.grid_ops.upload(g, unique_filename, auto_open=False) - try: - py.grid_ops.upload(g, unique_filename, auto_open=False) - except PlotlyRequestError as e: - pass - else: - self.fail('Expected this to fail!') diff --git a/plotly/tests/test_plot_ly/test_image/__init__.py b/plotly/tests/test_plot_ly/test_image/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_image/test_image.py b/plotly/tests/test_plot_ly/test_image/test_image.py deleted file mode 100644 index 343486ab64a..00000000000 --- a/plotly/tests/test_plot_ly/test_image/test_image.py +++ /dev/null @@ -1,77 +0,0 @@ -from __future__ import absolute_import - -import imghdr -import tempfile -import os -import itertools -import warnings - -from nose.plugins.attrib import attr - -from plotly import exceptions -from plotly.plotly import plotly as py -from plotly.tests.utils import PlotlyTestCase - - -@attr('slow') -class TestImage(PlotlyTestCase): - - def setUp(self): - super(TestImage, self).setUp() - py.sign_in('PlotlyImageTest', '786r5mecv0') - self.data = [{'x': [1, 2, 3], 'y': [3, 1, 6]}] - - -def _generate_image_get_returns_valid_image_test(image_format, - width, height, scale): - def test(self): - # TODO: better understand why this intermittently fails. See #649 - num_attempts = 5 - for i in range(num_attempts): - if i > 0: - warnings.warn('image test intermittently failed, retrying...') - try: - image = py.image.get(self.data, image_format, width, height, - scale) - if image_format in ['png', 'jpeg']: - assert imghdr.what('', image) == image_format - return - except (KeyError, exceptions.PlotlyError): - if i == num_attempts - 1: - raise - - return test - - -def _generate_image_save_as_saves_valid_image(image_format, - width, height, scale): - def _test(self): - f, filename = tempfile.mkstemp('.{}'.format(image_format)) - py.image.save_as(self.data, filename, format=image_format, - width=width, height=height, scale=scale) - if image_format in ['png', 'jpeg']: - assert imghdr.what(filename) == image_format - else: - assert os.path.getsize(filename) > 0 - - os.remove(filename) - - return _test - -kwargs = { - 'format': ['png', 'jpeg', 'pdf', 'svg', 'emf'], - 'width': [None, 300], - 'height': [None, 300], - 'scale': [None, 5] -} - -for args in itertools.product(kwargs['format'], kwargs['width'], - kwargs['height'], kwargs['scale']): - for test_generator in [_generate_image_get_returns_valid_image_test, - _generate_image_save_as_saves_valid_image]: - - _test = test_generator(*args) - arg_string = ', '.join([str(a) for a in args]) - test_name = test_generator.__name__.replace('_generate', 'test') - test_name += '({})'.format(arg_string) - setattr(TestImage, test_name, _test) diff --git a/plotly/tests/test_plot_ly/test_meta/__init__.py b/plotly/tests/test_plot_ly/test_meta/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_meta/test_meta.py b/plotly/tests/test_plot_ly/test_meta/test_meta.py deleted file mode 100644 index 65a0ba5122d..00000000000 --- a/plotly/tests/test_plot_ly/test_meta/test_meta.py +++ /dev/null @@ -1,63 +0,0 @@ -""" -test_meta: -========== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -import random -import string - -from nose.plugins.attrib import attr -from unittest import skip - -import plotly.plotly as py -from plotly.exceptions import PlotlyRequestError -from plotly.grid_objs import Column, Grid -from plotly.tests.utils import PlotlyTestCase - - -class MetaTest(PlotlyTestCase): - - _grid = grid = Grid([Column([1, 2, 3, 4], 'first column')]) - _meta = {"settings": {"scope1": {"model": "Unicorn Finder", "voltage": 4}}} - - def setUp(self): - super(MetaTest, self).setUp() - py.sign_in('PythonTest', 'xnyU0DEwvAQQCwHVseIL') - - def random_filename(self): - random_chars = [random.choice(string.ascii_uppercase) for _ in range(5)] - unique_filename = 'Valid Grid with Meta '+''.join(random_chars) - return unique_filename - - @attr('slow') - def test_upload_meta(self): - unique_filename = self.random_filename() - grid_url = py.grid_ops.upload(self._grid, unique_filename, - auto_open=False) - - # Add some Metadata to that grid - py.meta_ops.upload(self._meta, grid_url=grid_url) - - @attr('slow') - def test_upload_meta_with_grid(self): - c1 = Column([1, 2, 3, 4], 'first column') - Grid([c1]) - - unique_filename = self.random_filename() - - py.grid_ops.upload( - self._grid, - unique_filename, - meta=self._meta, - auto_open=False) - - @skip('adding this for now so test_file_tools pass, more info' + - 'https://github.com/plotly/python-api/issues/263') - def test_metadata_to_nonexistent_grid(self): - non_exist_meta_url = 'https://local.plot.ly/~GridTest/999999999' - with self.assertRaises(PlotlyRequestError): - py.meta_ops.upload(self._meta, grid_url=non_exist_meta_url) diff --git a/plotly/tests/test_plot_ly/test_plotly/__init__.py b/plotly/tests/test_plot_ly/test_plotly/__init__.py deleted file mode 100644 index 1118eb01e82..00000000000 --- a/plotly/tests/test_plot_ly/test_plotly/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -import warnings - - -def setup_package(): - warnings.filterwarnings('ignore') diff --git a/plotly/tests/test_plot_ly/test_plotly/test_credentials.py b/plotly/tests/test_plot_ly/test_plotly/test_credentials.py deleted file mode 100644 index f826b7768ba..00000000000 --- a/plotly/tests/test_plot_ly/test_plotly/test_credentials.py +++ /dev/null @@ -1,93 +0,0 @@ -from __future__ import absolute_import - -import plotly.plotly as py -import chart_studio.session as session -import plotly.tools as tls -from plotly import exceptions -from plotly.tests.utils import PlotlyTestCase - -import sys - -# import from mock -if sys.version_info.major == 3 and sys.version_info.minor >= 3: - from unittest.mock import patch -else: - from mock import patch - - -class TestSignIn(PlotlyTestCase): - - def setUp(self): - super(TestSignIn, self).setUp() - patcher = patch('chart_studio.api.v2.users.current') - self.users_current_mock = patcher.start() - self.addCleanup(patcher.stop) - - def test_get_credentials(self): - session_credentials = session.get_session_credentials() - if 'username' in session_credentials: - del session._session['credentials']['username'] - if 'api_key' in session_credentials: - del session._session['credentials']['api_key'] - creds = py.get_credentials() - file_creds = tls.get_credentials_file() - self.assertEqual(creds, file_creds) - - def test_sign_in(self): - un = 'anyone' - ak = 'something' - # TODO, add this! - # si = ['this', 'and-this'] - py.sign_in(un, ak) - creds = py.get_credentials() - self.assertEqual(creds['username'], un) - self.assertEqual(creds['api_key'], ak) - # TODO, and check it! - # assert creds['stream_ids'] == si - - def test_get_config(self): - plotly_domain = 'test domain' - plotly_streaming_domain = 'test streaming domain' - config1 = py.get_config() - session._session['config']['plotly_domain'] = plotly_domain - config2 = py.get_config() - session._session['config']['plotly_streaming_domain'] = ( - plotly_streaming_domain - ) - config3 = py.get_config() - self.assertEqual(config2['plotly_domain'], plotly_domain) - self.assertNotEqual( - config2['plotly_streaming_domain'], plotly_streaming_domain - ) - self.assertEqual( - config3['plotly_streaming_domain'], plotly_streaming_domain - ) - - def test_sign_in_with_config(self): - username = 'place holder' - api_key = 'place holder' - plotly_domain = 'test domain' - plotly_streaming_domain = 'test streaming domain' - plotly_ssl_verification = False - py.sign_in( - username, - api_key, - plotly_domain=plotly_domain, - plotly_streaming_domain=plotly_streaming_domain, - plotly_ssl_verification=plotly_ssl_verification - ) - config = py.get_config() - self.assertEqual(config['plotly_domain'], plotly_domain) - self.assertEqual( - config['plotly_streaming_domain'], plotly_streaming_domain - ) - self.assertEqual( - config['plotly_ssl_verification'], plotly_ssl_verification - ) - - def test_sign_in_cannot_validate(self): - self.users_current_mock.side_effect = exceptions.PlotlyRequestError( - 'msg', 400, 'foobar' - ) - with self.assertRaisesRegexp(exceptions.PlotlyError, 'Sign in failed'): - py.sign_in('foo', 'bar') diff --git a/plotly/tests/test_plot_ly/test_plotly/test_plot.py b/plotly/tests/test_plot_ly/test_plotly/test_plot.py deleted file mode 100644 index 6e1c62315d4..00000000000 --- a/plotly/tests/test_plot_ly/test_plotly/test_plot.py +++ /dev/null @@ -1,440 +0,0 @@ -""" -test_plot: -========== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -import requests -import six -import sys -import json as _json -import warnings - -from nose.plugins.attrib import attr - -import plotly.tools as tls -from chart_studio import session -from plotly.tests.utils import PlotlyTestCase -from plotly.plotly import plotly as py -from plotly.exceptions import PlotlyError, PlotlyEmptyDataError -from plotly.files import CONFIG_FILE - - -# import from mock -if sys.version_info.major == 3 and sys.version_info.minor >= 3: - from unittest.mock import patch -else: - from mock import patch - - -class TestPlot(PlotlyTestCase): - - def setUp(self): - super(TestPlot, self).setUp() - py.sign_in('PlotlyImageTest', '786r5mecv0') - self.simple_figure = {'data': [{'x': [1, 2, 3], 'y': [2, 1, 2]}]} - - @attr('slow') - def test_plot_valid(self): - fig = { - 'data': [ - { - 'x': (1, 2, 3), - 'y': (2, 1, 2) - } - ], - 'layout': {'title': {'text': 'simple'}} - } - url = py.plot(fig, auto_open=False, filename='plot_valid') - saved_fig = py.get_figure(url) - self.assertEqual(saved_fig['data'][0]['x'], fig['data'][0]['x']) - self.assertEqual(saved_fig['data'][0]['y'], fig['data'][0]['y']) - self.assertEqual(saved_fig['layout']['title']['text'], - fig['layout']['title']['text']) - - def test_plot_invalid(self): - fig = { - 'data': [ - { - 'x': [1, 2, 3], - 'y': [2, 1, 2], - 'z': [3, 4, 1] - } - ] - } - with self.assertRaises(ValueError): - py.plot(fig, auto_open=False, filename='plot_invalid') - - def test_plot_invalid_args_1(self): - with self.assertRaises(TypeError): - py.plot(x=[1, 2, 3], y=[2, 1, 2], auto_open=False, - filename='plot_invalid') - - def test_plot_invalid_args_2(self): - with self.assertRaises(ValueError): - py.plot([1, 2, 3], [2, 1, 2], auto_open=False, - filename='plot_invalid') - - def test_plot_empty_data(self): - self.assertRaises(PlotlyEmptyDataError, py.plot, [], - filename='plot_invalid') - - def test_plot_sharing_invalid_argument(self): - - # Raise an error if sharing argument is incorrect - # correct arguments {'public, 'private', 'secret'} - - kwargs = {'filename': 'invalid-sharing-argument', - 'sharing': 'privste'} - - with self.assertRaisesRegexp( - PlotlyError, - "The 'sharing' argument only accepts"): - py.plot(self.simple_figure, **kwargs) - - def test_plot_world_readable_sharing_conflict_1(self): - - # Raise an error if world_readable=False but sharing='public' - - kwargs = {'filename': 'invalid-privacy-setting', - 'world_readable': False, - 'sharing': 'public'} - - with self.assertRaisesRegexp( - PlotlyError, - 'setting your plot privacy to both public and private.'): - py.plot(self.simple_figure, **kwargs) - - def test_plot_world_readable_sharing_conflict_2(self): - - # Raise an error if world_readable=True but sharing='secret' - - kwargs = {'filename': 'invalid-privacy-setting', - 'world_readable': True, - 'sharing': 'secret'} - - with self.assertRaisesRegexp( - PlotlyError, - 'setting your plot privacy to both public and private.'): - py.plot(self.simple_figure, **kwargs) - - def test_plot_option_logic_only_world_readable_given(self): - - # If sharing is not given and world_readable=False, - # sharing should be set to private - - kwargs = {'filename': 'test', - 'auto_open': True, - 'fileopt': 'overwrite', - 'validate': True, - 'world_readable': False} - - plot_option_logic = py._plot_option_logic(kwargs) - - expected_plot_option_logic = {'filename': 'test', - 'auto_open': True, - 'fileopt': 'overwrite', - 'validate': True, - 'world_readable': False, - 'sharing': 'private'} - self.assertEqual(plot_option_logic, expected_plot_option_logic) - - def test_plot_option_logic_only_sharing_given(self): - - # If world_readable is not given and sharing ='private', - # world_readable should be set to False - - kwargs = {'filename': 'test', - 'auto_open': True, - 'fileopt': 'overwrite', - 'validate': True, - 'sharing': 'private'} - - plot_option_logic = py._plot_option_logic(kwargs) - - expected_plot_option_logic = {'filename': 'test', - 'auto_open': True, - 'fileopt': 'overwrite', - 'validate': True, - 'world_readable': False, - 'sharing': 'private'} - self.assertEqual(plot_option_logic, expected_plot_option_logic) - - def test_plot_option_fileopt_deprecations(self): - - # Make sure DeprecationWarnings aren't filtered out by nose - warnings.filterwarnings('default', category=DeprecationWarning) - - # If filename is not given and fileopt is not 'new', - # raise a deprecation warning - kwargs = {'auto_open': True, - 'fileopt': 'overwrite', - 'validate': True, - 'sharing': 'private'} - - with warnings.catch_warnings(record=True) as w: - plot_option_logic = py._plot_option_logic(kwargs) - assert w[0].category == DeprecationWarning - - expected_plot_option_logic = {'filename': 'plot from API', - 'auto_open': True, - 'fileopt': 'overwrite', - 'validate': True, - 'world_readable': False, - 'sharing': 'private'} - self.assertEqual(plot_option_logic, expected_plot_option_logic) - - # If filename is given and fileopt is not 'overwrite', - # raise a depreacation warning - kwargs = {'filename': 'test', - 'auto_open': True, - 'fileopt': 'append', - 'validate': True, - 'sharing': 'private'} - - with warnings.catch_warnings(record=True) as w: - plot_option_logic = py._plot_option_logic(kwargs) - assert w[0].category == DeprecationWarning - - expected_plot_option_logic = {'filename': 'test', - 'auto_open': True, - 'fileopt': 'append', - 'validate': True, - 'world_readable': False, - 'sharing': 'private'} - self.assertEqual(plot_option_logic, expected_plot_option_logic) - - @attr('slow') - def test_plot_url_given_sharing_key(self): - - # Give share_key is requested, the retun url should contain - # the share_key - - validate = True - fig = tls.return_figure_from_figure_or_data(self.simple_figure, - validate) - kwargs = {'filename': 'is_share_key_included', - 'fileopt': 'overwrite', - 'world_readable': False, - 'sharing': 'secret'} - response = py._send_to_plotly(fig, **kwargs) - plot_url = response['url'] - - self.assertTrue('share_key=' in plot_url) - - @attr('slow') - def test_plot_url_response_given_sharing_key(self): - - # Given share_key is requested, get request of the url should - # be 200 - - kwargs = {'filename': 'is_share_key_included', - 'fileopt': 'overwrite', - 'auto_open': False, - 'world_readable': False, - 'sharing': 'secret'} - - plot_url = py.plot(self.simple_figure, **kwargs) - # shareplot basically always gives a 200 if even if permission denied - # embedplot returns an actual 404 - embed_url = plot_url.split('?')[0] + '.embed?' + plot_url.split('?')[1] - response = requests.get(embed_url) - - self.assertEqual(response.status_code, 200) - - @attr('slow') - def test_private_plot_response_with_and_without_share_key(self): - - # The json file of the private plot should be 404 and once - # share_key is added it should be 200 - - kwargs = {'filename': 'is_share_key_included', - 'fileopt': 'overwrite', - 'world_readable': False, - 'sharing': 'private'} - - private_plot_url = py._send_to_plotly(self.simple_figure, - **kwargs)['url'] - private_plot_response = requests.get(private_plot_url + ".json") - - # The json file of the private plot should be 404 - self.assertEqual(private_plot_response.status_code, 404) - - secret_plot_url = py.add_share_key_to_url(private_plot_url) - urlsplit = six.moves.urllib.parse.urlparse(secret_plot_url) - secret_plot_json_file = six.moves.urllib.parse.urljoin( - urlsplit.geturl(), "?.json" + urlsplit.query) - secret_plot_response = requests.get(secret_plot_json_file) - - # The json file of the secret plot should be 200 - self.assertTrue(secret_plot_response.status_code, 200) - - -class TestPlotOptionLogic(PlotlyTestCase): - conflicting_option_set = ( - {'world_readable': True, 'sharing': 'secret'}, - {'world_readable': True, 'sharing': 'private'}, - {'world_readable': False, 'sharing': 'public'} - ) - - def setUp(self): - super(TestPlotOptionLogic, self).setUp() - - # Make sure we don't hit sign-in validation failures. - patcher = patch('chart_studio.api.v2.users.current') - self.users_current_mock = patcher.start() - self.addCleanup(patcher.stop) - - # Some tests specifically check how *file-level* plot options alter - # plot option logic. In order not to re-write that, we simply clear the - # *session* information since it would take precedent. The _session is - # set when you `sign_in`. - session._session['plot_options'].clear() - - def test_default_options(self): - options = py._plot_option_logic({}) - config_options = tls.get_config_file() - for key in options: - if key != 'fileopt' and key in config_options: - self.assertEqual(options[key], config_options[key]) - - def test_conflicting_plot_options_in_plot_option_logic(self): - for plot_options in self.conflicting_option_set: - self.assertRaises(PlotlyError, py._plot_option_logic, - plot_options) - - def test_set_config_updates_plot_options(self): - original_config = tls.get_config_file() - new_options = { - 'world_readable': not original_config['world_readable'], - 'auto_open': not original_config['auto_open'], - 'sharing': ('public' if original_config['world_readable'] is False - else 'secret') - } - tls.set_config_file(**new_options) - options = py._plot_option_logic({}) - for key in new_options: - self.assertEqual(new_options[key], options[key]) - - -def generate_conflicting_plot_options_in_signin(): - """sign_in overrides the default plot options. - conflicting options aren't raised until plot or iplot is called, - through _plot_option_logic - """ - def gen_test(plot_options): - def test(self): - py.sign_in('username', 'key', **plot_options) - self.assertRaises(PlotlyError, py._plot_option_logic, {}) - return test - - for i, plot_options in enumerate(TestPlotOptionLogic.conflicting_option_set): - setattr(TestPlotOptionLogic, - 'test_conflicting_plot_options_in_signin_{}'.format(i), - gen_test(plot_options)) -generate_conflicting_plot_options_in_signin() - - -def generate_conflicting_plot_options_in_tools_dot_set_config(): - """tls.set_config overrides the default plot options. - conflicting options are actually raised when the options are saved, - because we push out default arguments for folks, and we don't want to - require users to specify both world_readable and secret *and* we don't - want to raise an error if they specified only one of these options - and didn't know that a default option was being saved for them. - """ - def gen_test(plot_options): - def test(self): - self.assertRaises(PlotlyError, tls.set_config_file, - **plot_options) - return test - - for i, plot_options in enumerate(TestPlotOptionLogic.conflicting_option_set): - setattr(TestPlotOptionLogic, - 'test_conflicting_plot_options_in_' - 'tools_dot_set_config{}'.format(i), - gen_test(plot_options)) -generate_conflicting_plot_options_in_tools_dot_set_config() - - -def generate_conflicting_plot_options_with_json_writes_of_config(): - """ if the user wrote their own options in the config file, - then we'll raise the error when the call plot or iplot through - _plot_option_logic - """ - def gen_test(plot_options): - def test(self): - config = _json.load(open(CONFIG_FILE)) - with open(CONFIG_FILE, 'w') as f: - config.update(plot_options) - f.write(_json.dumps(config)) - self.assertRaises(PlotlyError, py._plot_option_logic, {}) - return test - - for i, plot_options in enumerate(TestPlotOptionLogic.conflicting_option_set): - setattr(TestPlotOptionLogic, - 'test_conflicting_plot_options_with_' - 'json_writes_of_config{}'.format(i), - gen_test(plot_options)) -generate_conflicting_plot_options_with_json_writes_of_config() - - -def generate_private_sharing_and_public_world_readable_precedence(): - """ Test that call signature arguments applied through _plot_option_logic - overwrite options supplied through py.sign_in which overwrite options - set through tls.set_config - """ - plot_option_sets = ( - { - 'parent': {'world_readable': True, 'auto_open': False}, - 'child': {'sharing': 'secret', 'auto_open': True}, - 'expected_output': {'world_readable': False, - 'sharing': 'secret', - 'auto_open': True} - }, - { - 'parent': {'world_readable': True, 'auto_open': True}, - 'child': {'sharing': 'private', 'auto_open': False}, - 'expected_output': {'world_readable': False, - 'sharing': 'private', - 'auto_open': False} - }, - { - 'parent': {'world_readable': False, 'auto_open': False}, - 'child': {'sharing': 'public', 'auto_open': True}, - 'expected_output': {'world_readable': True, - 'sharing': 'public', - 'auto_open': True} - } - ) - - def gen_test_signin(plot_options): - def test(self): - py.sign_in('username', 'key', **plot_options['parent']) - options = py._plot_option_logic(plot_options['child']) - for option, value in plot_options['expected_output'].items(): - self.assertEqual(options[option], value) - return test - - def gen_test_config(plot_options): - def test(self): - tls.set_config(**plot_options['parent']) - options = py._plot_option_logic(plot_options['child']) - for option, value in plot_options['expected_output'].items(): - self.assertEqual(options[option], value) - - for i, plot_options in enumerate(plot_option_sets): - setattr(TestPlotOptionLogic, - 'test_private_sharing_and_public_' - 'world_readable_precedence_signin{}'.format(i), - gen_test_signin(plot_options)) - - setattr(TestPlotOptionLogic, - 'test_private_sharing_and_public_' - 'world_readable_precedence_config{}'.format(i), - gen_test_config(plot_options)) - -generate_private_sharing_and_public_world_readable_precedence() diff --git a/plotly/tests/test_plot_ly/test_session/__init__.py b/plotly/tests/test_plot_ly/test_session/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_session/test_session.py b/plotly/tests/test_plot_ly/test_session/test_session.py deleted file mode 100644 index addea310a8e..00000000000 --- a/plotly/tests/test_plot_ly/test_session/test_session.py +++ /dev/null @@ -1,34 +0,0 @@ -from __future__ import absolute_import - -from plotly.tests.utils import PlotlyTestCase - -from chart_studio import session -from plotly.session import update_session_plot_options, SHARING_OPTIONS -from plotly.exceptions import PlotlyError - - -class TestSession(PlotlyTestCase): - - def setUp(self): - super(TestSession, self).setUp() - session._session['plot_options'].clear() - - def test_update_session_plot_options_invalid_sharing_argument(self): - - # Return PlotlyError when sharing arguement is not - # 'public', 'private' or 'secret' - - kwargs = {'sharing': 'priva'} - self.assertRaises(PlotlyError, update_session_plot_options, **kwargs) - - def test_update_session_plot_options_valid_sharing_argument(self): - - # _session['plot_options'] should contain sharing key after - # update_session_plot_options is called by correct arguments - # 'public, 'private' or 'secret' - from chart_studio.session import _session - for key in SHARING_OPTIONS: - kwargs = {'sharing': key} - update_session_plot_options(**kwargs) - - self.assertEqual(_session['plot_options'], kwargs) diff --git a/plotly/tests/test_plot_ly/test_spectacle_presentation/__init__.py b/plotly/tests/test_plot_ly/test_spectacle_presentation/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_spectacle_presentation/test_spectacle_presentation.py b/plotly/tests/test_plot_ly/test_spectacle_presentation/test_spectacle_presentation.py deleted file mode 100644 index 1f0392acbfe..00000000000 --- a/plotly/tests/test_plot_ly/test_spectacle_presentation/test_spectacle_presentation.py +++ /dev/null @@ -1,362 +0,0 @@ -""" -test_spectacle_presentation: -========== - -A module intended for use with Nose. - -""" -from __future__ import absolute_import - -from unittest import TestCase -from plotly.exceptions import PlotlyError -import plotly.presentation_objs as pres - - -class TestPresentation(TestCase): - - def test_invalid_style(self): - markdown_string = """ - # one slide - """ - - self.assertRaisesRegexp( - PlotlyError, pres.presentation_objs.STYLE_ERROR, - pres.Presentation, markdown_string, style='foo' - ) - - def test_open_code_block(self): - markdown_string = """ - # one slide - - ```python - x = 2 + 2 - print x - """ - - self.assertRaisesRegexp( - PlotlyError, pres.presentation_objs.CODE_ENV_ERROR, - pres.Presentation, markdown_string, style='moods' - ) - - def test_invalid_code_language(self): - markdown_string = """ - ```foo - x = 2 + 2 - print x - ``` - """ - - self.assertRaisesRegexp( - PlotlyError, pres.presentation_objs.LANG_ERROR, pres.Presentation, - markdown_string, style='moods' - ) - - def test_expected_pres(self): - markdown_string = "# title\n---\ntransition: zoom, fade, fade\n# Colors\nColors are everywhere around us.\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nImage(https://raw.githubusercontent.com/jackparmer/gradient-backgrounds/master/moods1.png)\n```python\nx=1\n```\n---\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\nPlotly(https://plot.ly/~AdamKulidjian/3564/)\n---\n" - - my_pres = pres.Presentation( - markdown_string, style='moods', imgStretch=True - ) - - exp_pres = {'presentation': {'paragraphStyles': {'Body': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 16, - 'fontStyle': 'normal', - 'fontWeight': 100, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'textAlign': 'center', - 'textDecoration': 'none', - 'wordBreak': 'break-word'}, - 'Body Small': {'color': '#3d3d3d', - 'fontFamily': 'Open Sans', - 'fontSize': 10, - 'fontStyle': 'normal', - 'fontWeight': 400, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'textAlign': 'center', - 'textDecoration': 'none'}, - 'Caption': {'color': '#3d3d3d', - 'fontFamily': 'Open Sans', - 'fontSize': 11, - 'fontStyle': 'italic', - 'fontWeight': 400, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'textAlign': 'center', - 'textDecoration': 'none'}, - 'Heading 1': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 55, - 'fontStyle': 'normal', - 'fontWeight': 900, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'textAlign': 'center', - 'textDecoration': 'none'}, - 'Heading 2': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 36, - 'fontStyle': 'normal', - 'fontWeight': 900, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'textAlign': 'center', - 'textDecoration': 'none'}, - 'Heading 3': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 30, - 'fontStyle': 'normal', - 'fontWeight': 900, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'textAlign': 'center', - 'textDecoration': 'none'}}, - 'slidePreviews': [None for _ in range(496)], - 'slides': [{'children': [{'children': ['title'], - 'defaultHeight': 36, - 'defaultWidth': 52, - 'id': 'CfaAzcSZE', - 'props': {'isQuote': False, - 'listType': None, - 'paragraphStyle': 'Heading 1', - 'size': 4, - 'style': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 55, - 'fontStyle': 'normal', - 'fontWeight': 900, - 'height': 140.0, - 'left': 0.0, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'position': 'absolute', - 'textAlign': 'center', - 'textDecoration': 'none', - 'top': 350.0, - 'width': 1000.0}}, - 'resizeVertical': False, - 'type': 'Text'}], - 'id': 'ibvfOQeNy', - 'props': {'style': {'backgroundColor': '#F7F7F7'}, - 'transition': ['slide']}}, - {'children': [{'children': ['Colors'], - 'defaultHeight': 36, - 'defaultWidth': 52, - 'id': 'YcGQJ21AY', - 'props': {'isQuote': False, - 'listType': None, - 'paragraphStyle': 'Heading 1', - 'size': 4, - 'style': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 55, - 'fontStyle': 'normal', - 'fontWeight': 900, - 'height': 140.0, - 'left': 0.0, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'position': 'absolute', - 'textAlign': 'center', - 'textDecoration': 'none', - 'top': 0.0, - 'width': 1000.0}}, - 'resizeVertical': False, - 'type': 'Text'}, - {'children': ['Colors are everywhere around us.'], - 'defaultHeight': 36, - 'defaultWidth': 52, - 'id': 'G0tcGP89U', - 'props': {'isQuote': False, - 'listType': None, - 'paragraphStyle': 'Body', - 'size': 4, - 'style': {'color': '#000016', - 'fontFamily': 'Roboto', - 'fontSize': 16, - 'fontStyle': 'normal', - 'fontWeight': 100, - 'height': 14.0, - 'left': 25.0, - 'lineHeight': 'normal', - 'minWidth': 20, - 'opacity': 1, - 'position': 'absolute', - 'textAlign': 'left', - 'textDecoration': 'none', - 'top': 663.0810810810812, - 'width': 950.0000000000001, - 'wordBreak': 'break-word'}}, - 'resizeVertical': False, - 'type': 'Text'}, - {'children': [], - 'id': 'c4scRvuIe', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 280.0, - 'left': 0.0, - 'position': 'absolute', - 'top': 70.0, - 'width': 330.66666666666663}}, - 'type': 'Plotly'}, - {'children': [], - 'id': 'yScDKejKG', - 'props': {'height': 512, - 'imageName': None, - 'src': 'https://raw.githubusercontent.com/jackparmer/gradient-backgrounds/master/moods1.png', - 'style': {'height': 280.0, - 'left': 334.66666666666663, - 'opacity': 1, - 'position': 'absolute', - 'top': 70.0, - 'width': 330.66666666666663}, - 'width': 512}, - 'type': 'Image'}, - {'children': [], - 'defaultText': 'Code', - 'id': 'fuUrIyVrv', - 'props': {'language': 'python', - 'source': 'x=1\n', - 'style': {'fontFamily': "Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace", - 'fontSize': 13, - 'height': 280.0, - 'left': 669.3333333333333, - 'margin': 0, - 'position': 'absolute', - 'textAlign': 'left', - 'top': 70.0, - 'width': 330.66666666666663}, - 'theme': 'tomorrowNight'}, - 'type': 'CodePane'}], - 'id': '7eG6TvKqU', - 'props': {'style': {'backgroundColor': '#FFFFFF'}, - 'transition': ['zoom', 'fade']}}, - {'children': [{'children': [], - 'id': '83EtFjFKM', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 0.0, - 'width': 600.0}}, - 'type': 'Plotly'}, - {'children': [], - 'id': 'V9vJYk8bF', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 100.57142857142856, - 'width': 600.0}}, - 'type': 'Plotly'}, - {'children': [], - 'id': 'DzCfXMyhv', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 201.1428571428571, - 'width': 600.0}}, - 'type': 'Plotly'}, - {'children': [], - 'id': 'YFf7M2BON', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 301.71428571428567, - 'width': 600.0}}, - 'type': 'Plotly'}, - {'children': [], - 'id': 'CARvApdzw', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 402.2857142857142, - 'width': 600.0}}, - 'type': 'Plotly'}, - {'children': [], - 'id': '194ZxaSko', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 502.85714285714283, - 'width': 600.0}}, - 'type': 'Plotly'}, - {'children': [], - 'id': 'SOwRH1rLV', - 'props': {'frameBorder': 0, - 'scrolling': 'no', - 'src': 'https://plot.ly/~AdamKulidjian/3564/.embed?link=false', - 'style': {'height': 96.57142857142857, - 'left': 400.0, - 'position': 'absolute', - 'top': 603.4285714285713, - 'width': 600.0}}, - 'type': 'Plotly'}], - 'id': 'S6VmZlI5Q', - 'props': {'style': {'backgroundColor': '#FFFFFF'}, - 'transition': ['slide']}}], - 'version': '0.1.3'}} - - for k in ['version', 'paragraphStyles', 'slidePreviews']: - self.assertEqual( - my_pres['presentation'][k], - exp_pres['presentation'][k] - ) - - self.assertEqual( - len(my_pres['presentation']['slides']), - len(exp_pres['presentation']['slides']) - ) - - for slide_idx in range(len(my_pres['presentation']['slides'])): - childs = my_pres['presentation']['slides'][slide_idx]['children'] - # transitions and background color - self.assertEqual( - my_pres['presentation']['slides'][slide_idx]['props'], - exp_pres['presentation']['slides'][slide_idx]['props'] - ) - for child_idx in range(len(childs)): - # check urls - if (my_pres['presentation']['slides'][slide_idx]['children'] - [child_idx]['type'] in ['Image', 'Plotly']): - self.assertEqual( - (my_pres['presentation']['slides'][slide_idx] - ['children'][child_idx]['props']), - (exp_pres['presentation']['slides'][slide_idx] - ['children'][child_idx]['props']) - ) - - # styles in children - self.assertEqual( - (my_pres['presentation']['slides'][slide_idx] - ['children'][child_idx]['props']), - (exp_pres['presentation']['slides'][slide_idx] - ['children'][child_idx]['props']) - ) diff --git a/plotly/tests/test_plot_ly/test_stream/__init__.py b/plotly/tests/test_plot_ly/test_stream/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/plotly/tests/test_plot_ly/test_stream/test_stream.py b/plotly/tests/test_plot_ly/test_stream/test_stream.py deleted file mode 100644 index 94a6d12230b..00000000000 --- a/plotly/tests/test_plot_ly/test_stream/test_stream.py +++ /dev/null @@ -1,166 +0,0 @@ -""" -Streaming tests. - -""" -from __future__ import absolute_import - -import time - -from nose.plugins.attrib import attr - -import plotly.plotly as py -from plotly.graph_objs import (Layout, Scatter, Stream) -from plotly.tests.utils import PlotlyTestCase - -un = 'PythonAPI' -ak = 'ubpiol2cve' -tk = 'vaia8trjjb' -config = {'plotly_domain': 'https://plot.ly', - 'plotly_streaming_domain': 'stream.plot.ly', - 'plotly_api_domain': 'https://api.plot.ly', - 'plotly_ssl_verification': False} - - -class TestStreaming(PlotlyTestCase): - - def setUp(self): - super(TestStreaming, self).setUp() - py.sign_in(un, ak, **config) - - #@attr('slow') - def test_initialize_stream_plot(self): - py.sign_in(un, ak) - stream = Stream(token=tk, maxpoints=50) - url = py.plot([Scatter(x=[], y=[], mode='markers', stream=stream)], - auto_open=False, - world_readable=True, - filename='stream-test') - assert url == 'https://plot.ly/~PythonAPI/461' - time.sleep(.5) - - @attr('slow') - def test_stream_single_points(self): - py.sign_in(un, ak) - stream = Stream(token=tk, maxpoints=50) - res = py.plot([Scatter(x=[], y=[], mode='markers', stream=stream)], - auto_open=False, - world_readable=True, - filename='stream-test') - time.sleep(.5) - my_stream = py.Stream(tk) - my_stream.open() - my_stream.write(Scatter(x=[1], y=[10])) - time.sleep(.5) - my_stream.close() - - @attr('slow') - def test_stream_multiple_points(self): - py.sign_in(un, ak) - stream = Stream(token=tk, maxpoints=50) - url = py.plot([Scatter(x=[], y=[], mode='markers', stream=stream)], - auto_open=False, - world_readable=True, - filename='stream-test') - time.sleep(.5) - my_stream = py.Stream(tk) - my_stream.open() - my_stream.write(Scatter(x=[1, 2, 3, 4], y=[2, 1, 2, 5])) - time.sleep(.5) - my_stream.close() - - @attr('slow') - def test_stream_layout(self): - py.sign_in(un, ak) - stream = Stream(token=tk, maxpoints=50) - url = py.plot([Scatter(x=[], y=[], mode='markers', stream=stream)], - auto_open=False, - world_readable=True, - filename='stream-test') - time.sleep(.5) - title_0 = "some title i picked first" - title_1 = "this other title i picked second" - my_stream = py.Stream(tk) - my_stream.open() - my_stream.write(Scatter(x=[1], y=[10]), layout=Layout(title=title_0)) - time.sleep(.5) - my_stream.close() - my_stream.open() - my_stream.write(Scatter(x=[1], y=[10]), layout=Layout(title=title_1)) - my_stream.close() - - @attr('slow') - def test_stream_unstreamable(self): - - # even though `name` isn't streamable, we don't validate it --> pass - - py.sign_in(un, ak) - my_stream = py.Stream(tk) - my_stream.open() - my_stream.write(Scatter(x=[1], y=[10], name='nope')) - my_stream.close() - - def test_stream_no_scheme(self): - - # If no scheme is used in the plotly_streaming_domain, port 80 - # should be used for streaming and ssl_enabled should be False - - py.sign_in(un, ak, **{'plotly_streaming_domain': 'stream.plot.ly'}) - my_stream = py.Stream(tk) - expected_streaming_specs = { - 'server': 'stream.plot.ly', - 'port': 80, - 'ssl_enabled': False, - 'ssl_verification_enabled': False, - 'headers': { - 'Host': 'stream.plot.ly', - 'plotly-streamtoken': tk - } - } - actual_streaming_specs = my_stream.get_streaming_specs() - self.assertEqual(expected_streaming_specs, actual_streaming_specs) - - def test_stream_http(self): - - # If the http scheme is used in the plotly_streaming_domain, port 80 - # should be used for streaming and ssl_enabled should be False - - py.sign_in(un, ak, - **{'plotly_streaming_domain': 'http://stream.plot.ly'}) - my_stream = py.Stream(tk) - expected_streaming_specs = { - 'server': 'stream.plot.ly', - 'port': 80, - 'ssl_enabled': False, - 'ssl_verification_enabled': False, - 'headers': { - 'Host': 'stream.plot.ly', - 'plotly-streamtoken': tk - } - } - actual_streaming_specs = my_stream.get_streaming_specs() - self.assertEqual(expected_streaming_specs, actual_streaming_specs) - - def test_stream_https(self): - - # If the https scheme is used in the plotly_streaming_domain, port 443 - # should be used for streaming, ssl_enabled should be True, - # and ssl_verification_enabled should equal plotly_ssl_verification - - ssl_stream_config = { - 'plotly_streaming_domain': 'https://stream.plot.ly', - 'plotly_ssl_verification': True - } - py.sign_in(un, ak, **ssl_stream_config) - my_stream = py.Stream(tk) - expected_streaming_specs = { - 'server': 'stream.plot.ly', - 'port': 443, - 'ssl_enabled': True, - 'ssl_verification_enabled': True, - 'headers': { - 'Host': 'stream.plot.ly', - 'plotly-streamtoken': tk - } - } - actual_streaming_specs = my_stream.get_streaming_specs() - self.assertEqual(expected_streaming_specs, actual_streaming_specs) diff --git a/plotly/tests/utils.py b/plotly/tests/utils.py index 8ca85cc75aa..8bd84f747ce 100644 --- a/plotly/tests/utils.py +++ b/plotly/tests/utils.py @@ -1,56 +1,15 @@ import copy from numbers import Number as Num from unittest import TestCase +import plotly.io as pio -from plotly import files, session, utils - - -class PlotlyTestCase(TestCase): - - # parent test case to assist with clean up of local credentials/config - - def __init__(self, *args, **kwargs): - self._credentials = None - self._config = None - self._graph_reference = None - self._session = None - super(PlotlyTestCase, self).__init__(*args, **kwargs) - - @classmethod - def setUpClass(cls): - session._session = { - 'credentials': {}, - 'config': {}, - 'plot_options': {} - } +class TestCaseNoTemplate(TestCase): def setUp(self): - self.stash_session() - self.stash_files() - defaults = dict(files.FILE_CONTENT[files.CREDENTIALS_FILE], - **files.FILE_CONTENT[files.CONFIG_FILE]) - session.sign_in(**defaults) + pio.templates.default = None def tearDown(self): - self.restore_files() - self.restore_session() - - def stash_files(self): - self._credentials = utils.load_json_dict(files.CREDENTIALS_FILE) - self._config = utils.load_json_dict(files.CONFIG_FILE) - - def restore_files(self): - if self._credentials and files.ensure_writable_plotly_dir(): - utils.save_json_dict(files.CREDENTIALS_FILE, self._credentials) - if self._config and files.ensure_writable_plotly_dir(): - utils.save_json_dict(files.CONFIG_FILE, self._config) - - def stash_session(self): - self._session = copy.deepcopy(session._session) - - def restore_session(self): - session._session.clear() # clear and update to preserve references. - session._session.update(self._session) + pio.templates.default = 'plotly' def compare_dict(dict1, dict2, equivalent=True, msg='', tol=10e-8): diff --git a/plotly/tools.py b/plotly/tools.py index 7e695b30997..a9f0db2901d 100644 --- a/plotly/tools.py +++ b/plotly/tools.py @@ -443,608 +443,28 @@ def make_subplots(rows=1, cols=1, cols=2, the domains for each row from top to botton would be [0. 0.75] and [0.75, 1] """ - - from _plotly_future_ import _future_flags - if 'v4_subplots' in _future_flags: - import plotly.subplots - return plotly.subplots.make_subplots( - rows=rows, - cols=cols, - shared_xaxes=shared_xaxes, - shared_yaxes=shared_yaxes, - start_cell=start_cell, - print_grid=print_grid, - **kwargs - ) - - # Handle default print_grid - if print_grid is None: - print_grid = True - - # TODO: protected until #282 - from plotly.graph_objs import graph_objs - - # Throw exception for non-integer rows and cols - if not isinstance(rows, int) or rows <= 0: - raise Exception("Keyword argument 'rows' " - "must be an int greater than 0") - if not isinstance(cols, int) or cols <= 0: - raise Exception("Keyword argument 'cols' " - "must be an int greater than 0") - - # Dictionary of things start_cell - START_CELL_all = { - 'bottom-left': { - # 'natural' setup where x & y domains increase monotonically - 'col_dir': 1, - 'row_dir': 1 - }, - 'top-left': { - # 'default' setup visually matching the 'specs' list of lists - 'col_dir': 1, - 'row_dir': -1 - } - # TODO maybe add 'bottom-right' and 'top-right' - } - - # Throw exception for invalid 'start_cell' values - try: - START_CELL = START_CELL_all[start_cell] - except KeyError: - raise Exception("Invalid 'start_cell' value") - - # Throw exception if non-valid kwarg is sent - VALID_KWARGS = ['horizontal_spacing', 'vertical_spacing', - 'specs', 'insets', 'subplot_titles', 'column_width', - 'row_width'] - for key in kwargs.keys(): - if key not in VALID_KWARGS: - raise Exception("Invalid keyword argument: '{0}'".format(key)) - - # Set 'subplot_titles' - subplot_titles = kwargs.get('subplot_titles', [""] * rows * cols) - - # Set 'horizontal_spacing' / 'vertical_spacing' w.r.t. rows / cols - try: - horizontal_spacing = float(kwargs['horizontal_spacing']) - except KeyError: - horizontal_spacing = 0.2 / cols - try: - vertical_spacing = float(kwargs['vertical_spacing']) - except KeyError: - if 'subplot_titles' in kwargs: - vertical_spacing = 0.5 / rows - else: - vertical_spacing = 0.3 / rows - - # Sanitize 'specs' (must be a list of lists) - exception_msg = "Keyword argument 'specs' must be a list of lists" - try: - specs = kwargs['specs'] - if not isinstance(specs, list): - raise Exception(exception_msg) - else: - for spec_row in specs: - if not isinstance(spec_row, list): - raise Exception(exception_msg) - except KeyError: - specs = [[{} - for c in range(cols)] - for r in range(rows)] # default 'specs' - - # Throw exception if specs is over or under specified - if len(specs) != rows: - raise Exception("The number of rows in 'specs' " - "must be equal to 'rows'") - for r, spec_row in enumerate(specs): - if len(spec_row) != cols: - raise Exception("The number of columns in 'specs' " - "must be equal to 'cols'") - - # Sanitize 'insets' - try: - insets = kwargs['insets'] - if not isinstance(insets, list): - raise Exception("Keyword argument 'insets' must be a list") - except KeyError: - insets = False - - # Throw exception if non-valid key / fill in defaults - def _check_keys_and_fill(name, arg, defaults): - def _checks(item, defaults): - if item is None: - return - if not isinstance(item, dict): - raise Exception("Items in keyword argument '{name}' must be " - "dictionaries or None".format(name=name)) - for k in item.keys(): - if k not in defaults.keys(): - raise Exception("Invalid key '{k}' in keyword " - "argument '{name}'".format(k=k, name=name)) - for k in defaults.keys(): - if k not in item.keys(): - item[k] = defaults[k] - for arg_i in arg: - if isinstance(arg_i, list): - for arg_ii in arg_i: - _checks(arg_ii, defaults) - elif isinstance(arg_i, dict): - _checks(arg_i, defaults) - - # Default spec key-values - SPEC_defaults = dict( - is_3d=False, - colspan=1, - rowspan=1, - l=0.0, - r=0.0, - b=0.0, - t=0.0 - # TODO add support for 'w' and 'h' + import plotly.subplots + warnings.warn( + 'plotly.tools.make_subplots is deprecated, ' + 'please use plotly.subplots.make_subplots instead', + DeprecationWarning, + stacklevel=1) + + return plotly.subplots.make_subplots( + rows=rows, + cols=cols, + shared_xaxes=shared_xaxes, + shared_yaxes=shared_yaxes, + start_cell=start_cell, + print_grid=print_grid, + **kwargs ) - _check_keys_and_fill('specs', specs, SPEC_defaults) - - # Default inset key-values - if insets: - INSET_defaults = dict( - cell=(1, 1), - is_3d=False, - l=0.0, - w='to_end', - b=0.0, - h='to_end' - ) - _check_keys_and_fill('insets', insets, INSET_defaults) - # set heights (with 'column_width') - try: - column_width = kwargs['column_width'] - if not isinstance(column_width, list) or len(column_width) != cols: - raise Exception( - "Keyword argument 'column_width' must be a list with {} " - "numbers in it, the number of subplot cols.".format(cols) - ) - except KeyError: - column_width = None - - if column_width: - cum_sum = float(sum(column_width)) - widths = [] - for w in column_width: - widths.append( - (1. - horizontal_spacing * (cols - 1)) * (w / cum_sum) - ) - else: - widths = [(1. - horizontal_spacing * (cols - 1)) / cols] * cols - # set widths (with 'row_width') - try: - row_width = kwargs['row_width'] - if not isinstance(row_width, list) or len(row_width) != rows: - raise Exception( - "Keyword argument 'row_width' must be a list with {} " - "numbers in it, the number of subplot rows.".format(rows) - ) - except KeyError: - row_width = None - - if row_width: - cum_sum = float(sum(row_width)) - heights = [] - for h in row_width: - heights.append( - (1. - vertical_spacing * (rows - 1)) * (h / cum_sum) - ) - else: - heights = [(1. - vertical_spacing * (rows - 1)) / rows] * rows - - # Built row/col sequence using 'row_dir' and 'col_dir' - COL_DIR = START_CELL['col_dir'] - ROW_DIR = START_CELL['row_dir'] - col_seq = range(cols)[::COL_DIR] - row_seq = range(rows)[::ROW_DIR] - - # [grid] Build subplot grid (coord tuple of cell) - grid = [ - [ - ( - (sum(widths[:c]) + c * horizontal_spacing), - (sum(heights[:r]) + r * vertical_spacing) - ) for c in col_seq - ] for r in row_seq - ] - # [grid_ref] Initialize the grid and insets' axis-reference lists - grid_ref = [[None for c in range(cols)] for r in range(rows)] - insets_ref = [None for inset in range(len(insets))] if insets else None - - layout = graph_objs.Layout() # init layout object - - # Function handling logic around 2d axis labels - # Returns 'x{}' | 'y{}' - def _get_label(x_or_y, r, c, cnt, shared_axes): - # Default label (given strictly by cnt) - label = "{x_or_y}{cnt}".format(x_or_y=x_or_y, cnt=cnt) - - if isinstance(shared_axes, bool): - if shared_axes: - if x_or_y == 'x': - label = "{x_or_y}{c}".format(x_or_y=x_or_y, c=c + 1) - if x_or_y == 'y': - label = "{x_or_y}{r}".format(x_or_y=x_or_y, r=r + 1) - - if isinstance(shared_axes, list): - if isinstance(shared_axes[0], tuple): - shared_axes = [shared_axes] # TODO put this elsewhere - for shared_axis in shared_axes: - if (r + 1, c + 1) in shared_axis: - label = { - 'x': "x{0}".format(shared_axis[0][1]), - 'y': "y{0}".format(shared_axis[0][0]) - }[x_or_y] - - return label - - # Row in grid of anchor row if shared_xaxes=True - ANCHOR_ROW = 0 if ROW_DIR > 0 else rows - 1 - - # Function handling logic around 2d axis anchors - # Return 'x{}' | 'y{}' | 'free' | False - def _get_anchors(r, c, x_cnt, y_cnt, shared_xaxes, shared_yaxes): - # Default anchors (give strictly by cnt) - x_anchor = "y{y_cnt}".format(y_cnt=y_cnt) - y_anchor = "x{x_cnt}".format(x_cnt=x_cnt) - - if isinstance(shared_xaxes, bool): - if shared_xaxes: - if r != ANCHOR_ROW: - x_anchor = False - y_anchor = 'free' - if shared_yaxes and c != 0: # TODO covers all cases? - y_anchor = False - return x_anchor, y_anchor - - elif isinstance(shared_xaxes, list): - if isinstance(shared_xaxes[0], tuple): - shared_xaxes = [shared_xaxes] # TODO put this elsewhere - for shared_xaxis in shared_xaxes: - if (r + 1, c + 1) in shared_xaxis[1:]: - x_anchor = False - y_anchor = 'free' # TODO covers all cases? - - if isinstance(shared_yaxes, bool): - if shared_yaxes: - if c != 0: - y_anchor = False - x_anchor = 'free' - if shared_xaxes and r != ANCHOR_ROW: # TODO all cases? - x_anchor = False - return x_anchor, y_anchor - - elif isinstance(shared_yaxes, list): - if isinstance(shared_yaxes[0], tuple): - shared_yaxes = [shared_yaxes] # TODO put this elsewhere - for shared_yaxis in shared_yaxes: - if (r + 1, c + 1) in shared_yaxis[1:]: - y_anchor = False - x_anchor = 'free' # TODO covers all cases? - - return x_anchor, y_anchor - - list_of_domains = [] # added for subplot titles - - # Function pasting x/y domains in layout object (2d case) - def _add_domain(layout, x_or_y, label, domain, anchor, position): - name = label[0] + 'axis' + label[1:] - - # Clamp domain elements between [0, 1]. - # This is only needed to combat numerical precision errors - # See GH1031 - axis = {'domain': [max(0.0, domain[0]), min(1.0, domain[1])]} - if anchor: - axis['anchor'] = anchor - if isinstance(position, float): - axis['position'] = position - layout[name] = axis - list_of_domains.append(domain) # added for subplot titles - - # Function pasting x/y domains in layout object (3d case) - def _add_domain_is_3d(layout, s_label, x_domain, y_domain): - scene = dict( - domain={'x': [max(0.0, x_domain[0]), min(1.0, x_domain[1])], - 'y': [max(0.0, y_domain[0]), min(1.0, y_domain[1])]}) - layout[s_label] = scene - - x_cnt = y_cnt = s_cnt = 1 # subplot axis/scene counters - - # Loop through specs -- (r, c) <-> (row, col) - for r, spec_row in enumerate(specs): - for c, spec in enumerate(spec_row): - - if spec is None: # skip over None cells - continue - - c_spanned = c + spec['colspan'] - 1 # get spanned c - r_spanned = r + spec['rowspan'] - 1 # get spanned r - - # Throw exception if 'colspan' | 'rowspan' is too large for grid - if c_spanned >= cols: - raise Exception("Some 'colspan' value is too large for " - "this subplot grid.") - if r_spanned >= rows: - raise Exception("Some 'rowspan' value is too large for " - "this subplot grid.") - - # Get x domain using grid and colspan - x_s = grid[r][c][0] + spec['l'] - x_e = grid[r][c_spanned][0] + widths[c] - spec['r'] - x_domain = [x_s, x_e] - - # Get y domain (dep. on row_dir) using grid & r_spanned - if ROW_DIR > 0: - y_s = grid[r][c][1] + spec['b'] - y_e = grid[r_spanned][c][1] + heights[-1 - r] - spec['t'] - else: - y_s = grid[r_spanned][c][1] + spec['b'] - y_e = grid[r][c][1] + heights[-1 - r] - spec['t'] - y_domain = [y_s, y_e] - - if spec['is_3d']: - - # Add scene to layout - s_label = 'scene{0}'.format(s_cnt) - _add_domain_is_3d(layout, s_label, x_domain, y_domain) - grid_ref[r][c] = (s_label, ) - s_cnt += 1 - - else: - - # Get axis label and anchor - x_label = _get_label('x', r, c, x_cnt, shared_xaxes) - y_label = _get_label('y', r, c, y_cnt, shared_yaxes) - x_anchor, y_anchor = _get_anchors(r, c, - x_cnt, y_cnt, - shared_xaxes, - shared_yaxes) - - # Add a xaxis to layout (N.B anchor == False -> no axis) - if x_anchor: - if x_anchor == 'free': - x_position = y_domain[0] - else: - x_position = False - _add_domain(layout, 'x', x_label, x_domain, - x_anchor, x_position) - x_cnt += 1 - - # Add a yaxis to layout (N.B anchor == False -> no axis) - if y_anchor: - if y_anchor == 'free': - y_position = x_domain[0] - else: - y_position = False - _add_domain(layout, 'y', y_label, y_domain, - y_anchor, y_position) - y_cnt += 1 - - grid_ref[r][c] = (x_label, y_label) # fill in ref - - # Loop through insets - if insets: - for i_inset, inset in enumerate(insets): - - r = inset['cell'][0] - 1 - c = inset['cell'][1] - 1 - - # Throw exception if r | c is out of range - if not (0 <= r < rows): - raise Exception("Some 'cell' row value is out of range. " - "Note: the starting cell is (1, 1)") - if not (0 <= c < cols): - raise Exception("Some 'cell' col value is out of range. " - "Note: the starting cell is (1, 1)") - - # Get inset x domain using grid - x_s = grid[r][c][0] + inset['l'] * widths[c] - if inset['w'] == 'to_end': - x_e = grid[r][c][0] + widths[c] - else: - x_e = x_s + inset['w'] * widths[c] - x_domain = [x_s, x_e] - - # Get inset y domain using grid - y_s = grid[r][c][1] + inset['b'] * heights[-1 - r] - if inset['h'] == 'to_end': - y_e = grid[r][c][1] + heights[-1 - r] - else: - y_e = y_s + inset['h'] * heights[-1 - r] - y_domain = [y_s, y_e] - - if inset['is_3d']: - - # Add scene to layout - s_label = 'scene{0}'.format(s_cnt) - _add_domain_is_3d(layout, s_label, x_domain, y_domain) - insets_ref[i_inset] = (s_label, ) - s_cnt += 1 - - else: - - # Get axis label and anchor - x_label = _get_label('x', False, False, x_cnt, False) - y_label = _get_label('y', False, False, y_cnt, False) - x_anchor, y_anchor = _get_anchors(r, c, - x_cnt, y_cnt, - False, False) - - # Add a xaxis to layout (N.B insets always have anchors) - _add_domain(layout, 'x', x_label, x_domain, x_anchor, False) - x_cnt += 1 - - # Add a yayis to layout (N.B insets always have anchors) - _add_domain(layout, 'y', y_label, y_domain, y_anchor, False) - y_cnt += 1 - - insets_ref[i_inset] = (x_label, y_label) # fill in ref - - # [grid_str] Set the grid's string representation - sp = " " # space between cell - s_str = "[ " # cell start string - e_str = " ]" # cell end string - colspan_str = ' -' # colspan string - rowspan_str = ' |' # rowspan string - empty_str = ' (empty) ' # empty cell string - - # Init grid_str with intro message - grid_str = "This is the format of your plot grid:\n" - - # Init tmp list of lists of strings (sorta like 'grid_ref' but w/ strings) - _tmp = [['' for c in range(cols)] for r in range(rows)] - - # Define cell string as function of (r, c) and grid_ref - def _get_cell_str(r, c, ref): - return '({r},{c}) {ref}'.format(r=r + 1, c=c + 1, ref=','.join(ref)) - - # Find max len of _cell_str, add define a padding function - cell_len = max([len(_get_cell_str(r, c, ref)) - for r, row_ref in enumerate(grid_ref) - for c, ref in enumerate(row_ref) - if ref]) + len(s_str) + len(e_str) - - def _pad(s, cell_len=cell_len): - return ' ' * (cell_len - len(s)) - - # Loop through specs, fill in _tmp - for r, spec_row in enumerate(specs): - for c, spec in enumerate(spec_row): - - ref = grid_ref[r][c] - if ref is None: - if _tmp[r][c] == '': - _tmp[r][c] = empty_str + _pad(empty_str) - continue - - cell_str = s_str + _get_cell_str(r, c, ref) - - if spec['colspan'] > 1: - for cc in range(1, spec['colspan'] - 1): - _tmp[r][c + cc] = colspan_str + _pad(colspan_str) - _tmp[r][c + spec['colspan'] - 1] = ( - colspan_str + _pad(colspan_str + e_str)) + e_str - else: - cell_str += e_str - - if spec['rowspan'] > 1: - for rr in range(1, spec['rowspan'] - 1): - _tmp[r + rr][c] = rowspan_str + _pad(rowspan_str) - for cc in range(spec['colspan']): - _tmp[r + spec['rowspan'] - 1][c + cc] = ( - rowspan_str + _pad(rowspan_str)) - - _tmp[r][c] = cell_str + _pad(cell_str) - - # Append grid_str using data from _tmp in the correct order - for r in row_seq[::-1]: - grid_str += sp.join(_tmp[r]) + '\n' - - # Append grid_str to include insets info - if insets: - grid_str += "\nWith insets:\n" - for i_inset, inset in enumerate(insets): - - r = inset['cell'][0] - 1 - c = inset['cell'][1] - 1 - ref = grid_ref[r][c] - - grid_str += ( - s_str + ','.join(insets_ref[i_inset]) + e_str + - ' over ' + - s_str + _get_cell_str(r, c, ref) + e_str + '\n' - ) - - # Add subplot titles - - # If shared_axes is False (default) use list_of_domains - # This is used for insets and irregular layouts - if not shared_xaxes and not shared_yaxes: - x_dom = list_of_domains[::2] - y_dom = list_of_domains[1::2] - subtitle_pos_x = [] - subtitle_pos_y = [] - for x_domains in x_dom: - subtitle_pos_x.append(sum(x_domains) / 2) - for y_domains in y_dom: - subtitle_pos_y.append(y_domains[1]) - - # If shared_axes is True the domin of each subplot is not returned so the - # title position must be calculated for each subplot - else: - x_dom_vals = [k for k in layout.to_plotly_json().keys() if 'xaxis' in k] - y_dom_vals = [k for k in layout.to_plotly_json().keys() if 'yaxis' in k] - - # sort xaxis and yaxis layout keys - r = re.compile('\d+') - - def key_func(m): - try: - return int(r.search(m).group(0)) - except AttributeError: - return 0 - - xaxies_labels_sorted = sorted(x_dom_vals, key=key_func) - yaxies_labels_sorted = sorted(y_dom_vals, key=key_func) - - x_dom = [layout[k]['domain'] for k in xaxies_labels_sorted] - y_dom = [layout[k]['domain'] for k in yaxies_labels_sorted] - - for index in range(cols): - subtitle_pos_x = [] - for x_domains in x_dom: - subtitle_pos_x.append(sum(x_domains) / 2) - subtitle_pos_x *= rows - - if shared_yaxes: - for index in range(rows): - subtitle_pos_y = [] - for y_domain in y_dom: - subtitle_pos_y.append(y_domain[1]) - subtitle_pos_y *= cols - subtitle_pos_y = sorted(subtitle_pos_y, reverse=True) - - else: - for index in range(rows): - subtitle_pos_y = [] - for y_domain in y_dom: - subtitle_pos_y.append(y_domain[1]) - subtitle_pos_y = sorted(subtitle_pos_y, reverse=True) - subtitle_pos_y *= cols - - plot_titles = [] - for index in range(len(subplot_titles)): - if not subplot_titles[index]: - pass - else: - plot_titles.append({'y': subtitle_pos_y[index], - 'xref': 'paper', - 'x': subtitle_pos_x[index], - 'yref': 'paper', - 'text': subplot_titles[index], - 'showarrow': False, - 'font': dict(size=16), - 'xanchor': 'center', - 'yanchor': 'bottom' - }) - - layout['annotations'] = plot_titles - - if print_grid: - print(grid_str) - - fig = graph_objs.Figure(layout=layout) - - fig.__dict__['_grid_ref'] = grid_ref - fig.__dict__['_grid_str'] = grid_str - - return fig +warnings.filterwarnings( + 'default', r'plotly\.tools\.make_subplots is deprecated', + DeprecationWarning +) def get_graph_obj(obj, obj_type=None): @@ -1286,59 +706,3 @@ def get_config_plotly_server_url(): config_dict = {} return config_dict.get('plotly_domain', default_server_url) - - -# get_config_defaults -from _plotly_future_ import _future_flags - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_deprecation - - from chart_studio.tools import (get_config_defaults) - get_config_defaults = _chart_studio_deprecation( - get_config_defaults) - - # ensure_local_plotly_files - from chart_studio.tools import ensure_local_plotly_files - ensure_local_plotly_files = _chart_studio_deprecation( - ensure_local_plotly_files) - - # set_credentials_file - from chart_studio.tools import set_credentials_file - set_credentials_file = _chart_studio_deprecation( - set_credentials_file) - - # get_credentials_file - from chart_studio.tools import get_credentials_file - get_credentials_file = _chart_studio_deprecation( - get_credentials_file) - - # reset_credentials_file - from chart_studio.tools import reset_credentials_file - reset_credentials_file = _chart_studio_deprecation( - reset_credentials_file) - - # set_config_file - from chart_studio.tools import set_config_file - set_config_file = _chart_studio_deprecation( - set_config_file) - - # get_config_file - from chart_studio.tools import get_config_file - get_config_file = _chart_studio_deprecation( - get_config_file) - - # reset_config_file - from chart_studio.tools import reset_config_file - reset_config_file = _chart_studio_deprecation( - reset_config_file) - - # get_embed - from chart_studio.tools import get_embed - get_embed = _chart_studio_deprecation( - get_embed) - - # embed - from chart_studio.tools import embed - embed = _chart_studio_deprecation( - embed) diff --git a/plotly/utils.py b/plotly/utils.py index 6dbaf9e568e..b830aef95ca 100644 --- a/plotly/utils.py +++ b/plotly/utils.py @@ -254,9 +254,3 @@ def _default_memoize_key_function(*args, **kwargs): return args, frozenset(kwargs.items()) else: return args - - -# Deprecations -from _plotly_future_ import _future_flags -if 'remove_deprecations' not in _future_flags: - from chart_studio.utils import * diff --git a/plotly/widgets.py b/plotly/widgets.py index d20b73cbf49..32081012a92 100644 --- a/plotly/widgets.py +++ b/plotly/widgets.py @@ -1,9 +1,3 @@ from __future__ import absolute_import - -from _plotly_future_ import _future_flags - - -if 'remove_deprecations' not in _future_flags: - from _plotly_future_ import _chart_studio_warning - _chart_studio_warning('widgets') - from chart_studio.widgets import * +from _plotly_future_ import _chart_studio_error +_chart_studio_error('widgets') diff --git a/templategen/definitions.py b/templategen/definitions.py index d1dcdff14c1..3894d71abf6 100644 --- a/templategen/definitions.py +++ b/templategen/definitions.py @@ -222,6 +222,28 @@ def seaborn(): [i/(len(bmw_subset)-1), clr] for i, clr in enumerate(bmw_subset) if i % 16 == 0 or i == (len(bmw_subset)-1)] + +# Plasma colorscale +# ----------------- +# Get this from plotly_express logic after integration +plasma_colors = [ + "#0d0887", + "#46039f", + "#7201a8", + "#9c179e", + "#bd3786", + "#d8576b", + "#ed7953", + "#fb9f3a", + "#fdca26", + "#f0f921", +] + +plasma = [ + [(1.0 * i) / (1.0 * (len(plasma_colors) - 1)), x] + for i, x in enumerate(plasma_colors) +] + jupyterlab_output_clr = 'rgb(17,17,17)' plotly_diverging = [ @@ -239,22 +261,23 @@ def seaborn(): ] plotly_colorway = [ - plotly_clrs['Cornflower'], - plotly_clrs['Sienna'], - plotly_clrs['Emerald'], - plotly_clrs['Lavender Shade'], - plotly_clrs['Aqua Shade'], - plotly_clrs['Lavender'], - '#FECB52', - '#FFA15A', - '#FF6692', - '#B6E880' + plotly_clrs['Cornflower'], + plotly_clrs['Sienna'], + plotly_clrs['Emerald'], + plotly_clrs['Lavender Shade'], + '#FFA15A', + plotly_clrs['Aqua Shade'], + '#FF6692', + '#B6E880', + '#FF97FF', + '#FECB52', ] + def plotly(): # Define colors # ------------- - colorscale = linear_bmw_5_95_c86_n256 + colorscale = plasma # Set colorbar_common colorbar_common = dict( @@ -326,7 +349,7 @@ def plotly(): def plotly_white(): # Define colors # ------------- - colorscale = linear_bmw_5_95_c86_n256 + colorscale = plasma # Set colorbar_common colorbar_common = dict( @@ -406,7 +429,7 @@ def plotly_white(): def plotly_dark(): # Define colors # ------------- - colorscale = linear_bmw_5_95_c86_n256 + colorscale = plasma # Set colorbar_common colorbar_common = dict( @@ -496,56 +519,6 @@ def plotly_dark(): builders['plotly_dark'] = plotly_dark -def plotly_v4_colors(): - template = Template() - - # Plasma colorscale - # ----------------- - # Get this from plotly_express logic after integration - colorscale = [ - "#0d0887", - "#46039f", - "#7201a8", - "#9c179e", - "#bd3786", - "#d8576b", - "#ed7953", - "#fb9f3a", - "#fdca26", - "#f0f921", - ] - d = len(colorscale) - 1 - colorscale = [ - [(1.0 * i) / (1.0 * d), x] - for i, x in enumerate(colorscale) - ] - - template.layout.colorscale.sequential = colorscale - template.data.heatmap = [dict(colorscale = colorscale)] - template.data.histogram2d = [dict(colorscale = colorscale)] - template.data.histogram2dcontour = [dict(colorscale = colorscale)] - template.data.contour = [dict(colorscale = colorscale)] - - colorway = [ - plotly_clrs['Cornflower'], - plotly_clrs['Sienna'], - plotly_clrs['Emerald'], - plotly_clrs['Lavender Shade'], - '#FFA15A', - plotly_clrs['Aqua Shade'], - '#FF6692', - '#B6E880', - '#FF97FF', - '#FECB52' - ] - template.layout.colorway = colorway - - return template - - -builders['plotly_v4_colors'] = plotly_v4_colors - - def presentation(): """ Template that increases the size of text and markers/lines for certain diff --git a/tox.ini b/tox.ini index 4a8d0d19135..e0d19d64ac6 100644 --- a/tox.ini +++ b/tox.ini @@ -157,7 +157,6 @@ basepython={env:PLOTLY_TOX_PYTHON_27:} commands= python --version nosetests {posargs} -x chart_studio/tests/ - nosetests {posargs} -x plotly/tests/test_plot_ly [testenv:py35-plot_ly] basepython={env:PLOTLY_TOX_PYTHON_35:} @@ -170,4 +169,3 @@ basepython={env:PLOTLY_TOX_PYTHON_37:} commands= python --version nosetests {posargs} -x chart_studio/tests/ - nosetests {posargs} -x plotly/tests/test_plot_ly