def test_options_record_invalid(self): StoreOptions.start_recording_skipped() with options_policy(skip_invalid=True, warn_on_skip=False): Options('test', allowed_keywords=['kw1'], kw1='value', kw2='val') errors = StoreOptions.stop_recording_skipped() self.assertEqual(len(errors),1) self.assertEqual(errors[0].invalid_keyword,'kw2')
def test_options_record_invalid(self): StoreOptions.start_recording_skipped() with options_policy(skip_invalid=True, warn_on_skip=False): Options('test', allowed_keywords=['kw1'], kw1='value', kw2='val') errors = StoreOptions.stop_recording_skipped() self.assertEqual(len(errors), 1) self.assertEqual(errors[0].invalid_keyword, 'kw2')
def test_full_spec_format(self): out = StoreOptions.merge_options(options={ 'Image': { 'plot': dict(fig_size=150), 'style': dict(cmap='Blues') } }) self.assertEqual(out, self.expected)
def test_mpl_bokeh_mpl(self): img = Image(np.random.rand(10, 10)) # Use blue in matplotlib Store.current_backend = 'matplotlib' StoreOptions.set_options(img, style={'Image': {'cmap': 'Blues'}}) mpl_opts = Store.lookup_options('matplotlib', img, 'style').options self.assertEqual(mpl_opts, {'cmap': 'Blues'}) # Use purple in bokeh Store.current_backend = 'bokeh' StoreOptions.set_options(img, style={'Image': {'cmap': 'Purple'}}) bokeh_opts = Store.lookup_options('bokeh', img, 'style').options self.assertEqual(bokeh_opts, {'cmap': 'Purple'}) # Check it is still blue in matplotlib... Store.current_backend = 'matplotlib' mpl_opts = Store.lookup_options('matplotlib', img, 'style').options self.assertEqual(mpl_opts, {'cmap': 'Blues'}) # And purple in bokeh.. Store.current_backend = 'bokeh' bokeh_opts = Store.lookup_options('bokeh', img, 'style').options self.assertEqual(bokeh_opts, {'cmap': 'Purple'}) return img
def test_mpl_bokeh_mpl(self): img = Image(np.random.rand(10,10)) # Use blue in matplotlib Store.current_backend = 'matplotlib' StoreOptions.set_options(img, style={'Image':{'cmap':'Blues'}}) mpl_opts = Store.lookup_options('matplotlib', img, 'style').options self.assertEqual(mpl_opts, {'cmap':'Blues'}) # Use purple in bokeh Store.current_backend = 'bokeh' StoreOptions.set_options(img, style={'Image':{'cmap':'Purple'}}) bokeh_opts = Store.lookup_options('bokeh', img, 'style').options self.assertEqual(bokeh_opts, {'cmap':'Purple'}) # Check it is still blue in matplotlib... Store.current_backend = 'matplotlib' mpl_opts = Store.lookup_options('matplotlib', img, 'style').options self.assertEqual(mpl_opts, {'cmap':'Blues'}) # And purple in bokeh.. Store.current_backend = 'bokeh' bokeh_opts = Store.lookup_options('bokeh', img, 'style').options self.assertEqual(bokeh_opts, {'cmap':'Purple'}) return img
def test_partitioned_format(self): out = StoreOptions.merge_options( plot={'Image':dict(fig_size=150)}, style={'Image':dict(cmap='Blues')}) self.assertEqual(out, self.expected)
def test_full_spec_format(self): out = StoreOptions.merge_options(options={ 'Image':{'plot':dict(fig_size=150), 'style': dict(cmap='Blues')}}) self.assertEqual(out, self.expected)
def test_partitioned_format(self): out = StoreOptions.merge_options(['plot', 'style'], plot={'Image': dict(fig_size=150)}, style={'Image': dict(cmap='Blues')}) self.assertEqual(out, self.expected)
def test_partitioned_format(self): out = StoreOptions.merge_options( ["plot", "style"], plot={"Image": dict(fig_size=150)}, style={"Image": dict(cmap="Blues")} ) self.assertEqual(out, self.expected)
def test_full_spec_format(self): out = StoreOptions.merge_options( ["plot", "style"], options={"Image": {"plot": dict(fig_size=150), "style": dict(cmap="Blues")}} ) self.assertEqual(out, self.expected)