diff --git a/hvplot/converter.py b/hvplot/converter.py index 07df543e0..5f7c6bc4d 100644 --- a/hvplot/converter.py +++ b/hvplot/converter.py @@ -417,9 +417,9 @@ def __init__( if self.geo: if self.kind not in self._geo_types: param.main.param.warning( - "geo option cannot be used with kind=%r plot " + f"geo option cannot be used with kind={self.kind!r} plot " "type. Geographic plots are only supported for " - "following plot types: %r" % (self.kind, self._geo_types)) + f"following plot types: {self._geo_types!r}") from cartopy import crs as ccrs from geoviews.util import project_extents @@ -436,7 +436,7 @@ def __init__( else: raise ValueError( "Projection must be defined as cartopy CRS or " - "one of the following CRS string:\n {}".format(all_crs)) + f"one of the following CRS string:\n {all_crs}") projection = projection or (ccrs.GOOGLE_MERCATOR if tiles else self.crs) if tiles and projection != ccrs.GOOGLE_MERCATOR: @@ -664,8 +664,8 @@ def _process_crs(self, data, crs): # only raise error if crs was specified in kwargs if crs: raise ValueError( - "'{}' must be either a valid crs or an reference to " - "a `data.attr` containing a valid crs.".format(crs)) + f"'{crs}' must be either a valid crs or an reference to " + "a `data.attr` containing a valid crs.") def _process_data(self, kind, data, x, y, by, groupby, row, col, use_dask, persist, backlog, label, group_label, @@ -851,14 +851,14 @@ def _process_data(self, kind, data, x, y, by, groupby, row, col, groupby.append(data_dim) self.variables = list(data.coords) + data_vars if groupby and not_found: - raise ValueError('The supplied groupby dimension(s) %s ' + raise ValueError(f'The supplied groupby dimension(s) {not_found} ' 'could not be found, expected one or ' - 'more of: %s' % (not_found, list(data.coords))) + f'more of: {list(data.coords)}') else: if gridded and kind not in ('points', 'dataset'): - raise ValueError('%s plot type requires gridded data, ' + raise ValueError(f'{kind} plot type requires gridded data, ' 'e.g. a NumPy array or xarray Dataset, ' - 'found %s type' % (kind, type(self.data).__name__)) + f'found {type(self.data).__name__} type') if hasattr(data, 'columns') and hasattr(data.columns, 'name') and data.columns.name and not group_label: group_label = data.columns.name @@ -903,9 +903,9 @@ def _process_data(self, kind, data, x, y, by, groupby, row, col, not_found = [g for g in groupby+by_cols if g not in list(self.data.columns)+indexes] not_found, self.data = process_derived_datetime_pandas(self.data, not_found, indexes) if groupby and not_found: - raise ValueError('The supplied groupby dimension(s) %s ' + raise ValueError(f'The supplied groupby dimension(s) {not_found} ' 'could not be found, expected one or ' - 'more of: %s' % (not_found, list(self.data.columns))) + f'more of: {list(self.data.columns)}') if transforms: self.data = Dataset(self.data, indexes).transform(**transforms).data @@ -967,7 +967,7 @@ def _process_data(self, kind, data, x, y, by, groupby, row, col, except Exception as e: if attr_labels is True: param.main.param.warning('Unable to auto label using xarray attrs ' - 'because {e}'.format(e=e)) + f'because {e}') def _process_plot(self): kind = self.kind @@ -1387,8 +1387,7 @@ def _apply_layers(self, obj): if self.tiles: tile_source = 'EsriImagery' if self.tiles == 'ESRI' else self.tiles - warning = ("%s tiles not recognized, must be one of: %s or a tile object" % - (tile_source, sorted(hv.element.tile_sources))) + warning = ("{} tiles not recognized, must be one of: {} or a tile object".format(tile_source, sorted(hv.element.tile_sources))) if tile_source is True: tiles = hv.element.tiles.OSM() elif tile_source in hv.element.tile_sources.keys(): diff --git a/hvplot/plotting/core.py b/hvplot/plotting/core.py index af01da69a..6315ff498 100644 --- a/hvplot/plotting/core.py +++ b/hvplot/plotting/core.py @@ -115,8 +115,8 @@ def __getattribute__(self, name): if "kind" in plot_opts and name in HoloViewsConverter._kind_mapping: param.main.param.warning( "Custom options for existing plot types should not " - "declare the 'kind' argument. The .%s plot method " - "was unexpectedly customized with kind=%r." % (plot_opts["kind"], name) + "declare the 'kind' argument. The .{} plot method " + "was unexpectedly customized with kind={!r}.".format(plot_opts["kind"], name) ) plot_opts["kind"] = name return hvPlotBase(self._data, **dict(self._metadata, **plot_opts)) diff --git a/hvplot/plotting/scatter_matrix.py b/hvplot/plotting/scatter_matrix.py index ecd975f97..17595c003 100644 --- a/hvplot/plotting/scatter_matrix.py +++ b/hvplot/plotting/scatter_matrix.py @@ -82,11 +82,9 @@ def scatter_matrix(data, c=None, chart='scatter', diagonal='hist', data = _hv.Dataset(_convert_col_names_to_str(data)) supported = list(HoloViewsConverter._kind_mapping) if diagonal not in supported: - raise ValueError('diagonal type must be one of: %s, found %s' % - (supported, diagonal)) + raise ValueError(f'diagonal type must be one of: {supported}, found {diagonal}') if chart not in supported: - raise ValueError('Chart type must be one of: %s, found %s' % - (supported, chart)) + raise ValueError(f'Chart type must be one of: {supported}, found {chart}') diagonal = HoloViewsConverter._kind_mapping[diagonal] chart = HoloViewsConverter._kind_mapping[chart] diff --git a/hvplot/util.py b/hvplot/util.py index 90497af16..83043c8f2 100644 --- a/hvplot/util.py +++ b/hvplot/util.py @@ -69,7 +69,7 @@ def check_crs(crs): try: crs_type = pyproj.crs.CRS except AttributeError: - class Dummy(): + class Dummy: pass crs_type = Dummy