diff --git a/holoviews/__init__.py b/holoviews/__init__.py index 440d1e8840..c90aa18dcd 100644 --- a/holoviews/__init__.py +++ b/holoviews/__init__.py @@ -120,7 +120,7 @@ def __call__(self, *args, **opts): # noqa (dummy signature) raise Exception("Jupyter notebook not available: use hv.extension instead.") if '_pyodide' in sys.modules: - from .pyodide import pyodide_extension, in_jupyterlite + from .pyodide import in_jupyterlite, pyodide_extension # The notebook_extension is needed inside jupyterlite, # so the override is only done if we are not inside jupyterlite. if in_jupyterlite(): diff --git a/holoviews/annotators.py b/holoviews/annotators.py index caf14e6d51..aa111a76b5 100644 --- a/holoviews/annotators.py +++ b/holoviews/annotators.py @@ -1,18 +1,21 @@ import sys - from inspect import getmro import param - -from panel.pane import PaneBase from panel.layout import Row, Tabs +from panel.pane import PaneBase from panel.util import param_name -from .core import DynamicMap, HoloMap, ViewableElement, Element, Layout, Overlay, Store +from .core import DynamicMap, Element, HoloMap, Layout, Overlay, Store, ViewableElement from .core.util import isscalar -from .element import Rectangles, Path, Polygons, Points, Table, Curve -from .plotting.links import VertexTableLink, DataLink, RectanglesTableLink, SelectionLink -from .streams import BoxEdit, PolyDraw, PolyEdit, Selection1D, PointDraw, CurveEdit +from .element import Curve, Path, Points, Polygons, Rectangles, Table +from .plotting.links import ( + DataLink, + RectanglesTableLink, + SelectionLink, + VertexTableLink, +) +from .streams import BoxEdit, CurveEdit, PointDraw, PolyDraw, PolyEdit, Selection1D def preprocess(function, current=[]): diff --git a/holoviews/core/__init__.py b/holoviews/core/__init__.py index 185c4373c5..90df314d05 100644 --- a/holoviews/core/__init__.py +++ b/holoviews/core/__init__.py @@ -6,14 +6,14 @@ from .data import * from .dimension import * from .element import * +from .io import FileArchive from .layout import * from .operation import * from .overlay import * from .sheetcoords import * from .spaces import * from .tree import * -from .util import config # noqa (API import) -from .io import FileArchive +from .util import config # noqa (API import) archive = FileArchive() diff --git a/holoviews/core/accessors.py b/holoviews/core/accessors.py index adcf062da0..bb31843e9b 100644 --- a/holoviews/core/accessors.py +++ b/holoviews/core/accessors.py @@ -3,7 +3,6 @@ """ import copy import sys - from functools import wraps from types import FunctionType @@ -25,7 +24,10 @@ def __new__(mcs, classname, bases, classdict): def pipelined(mcs, __call__): @wraps(__call__) def pipelined_call(*args, **kwargs): - from ..operation.element import method as method_op, factory + from ..operation.element import ( + factory, + method as method_op, + ) from .data import Dataset, MultiDimensionalMapping inst = args[0] @@ -131,11 +133,11 @@ def __call__(self, apply_function, streams=[], link_inputs=True, A new object where the function was applied to all contained (Nd)Overlay or Element objects. """ + from ..util import Dynamic from .data import Dataset from .dimension import ViewableElement from .element import Element - from .spaces import HoloMap, DynamicMap - from ..util import Dynamic + from .spaces import DynamicMap, HoloMap if isinstance(self._obj, DynamicMap) and dynamic == False: samples = tuple(d.values for d in self._obj.kdims) @@ -226,8 +228,8 @@ def opts(self, *args, **kwargs): See :py:meth:`Dimensioned.opts` and :py:meth:`Apply.__call__` for more information. """ - from ..util.transform import dim from ..streams import Params + from ..util.transform import dim params = {} for arg in kwargs.values(): if isinstance(arg, dim): @@ -271,8 +273,8 @@ def transform(self, *args, **kwargs): See :py:meth:`Dataset.transform` and :py:meth:`Apply.__call__` for more information. """ - from ..util.transform import dim from ..streams import Params + from ..util.transform import dim params = {} for _, arg in list(args)+list(kwargs.items()): if isinstance(arg, dim): @@ -357,8 +359,8 @@ def _transform_dimension(self, kdims, vdims, dimension): return dimension def _create_expression_transform(self, kdims, vdims, exclude=[]): - from .dimension import dimension_name from ..util.transform import dim + from .dimension import dimension_name def _transform_expression(expression): if dimension_name(expression.dimension) in exclude: @@ -502,7 +504,7 @@ def get(self, group=None, backend=None, defaults=True): Options object associated with the object containing the applied option keywords. """ - from .options import Store, Options + from .options import Options, Store keywords = {} groups = Options._option_groups if group is None else [group] backend = backend if backend else Store.current_backend diff --git a/holoviews/core/boundingregion.py b/holoviews/core/boundingregion.py index 942a962c85..741865b54f 100644 --- a/holoviews/core/boundingregion.py +++ b/holoviews/core/boundingregion.py @@ -9,8 +9,9 @@ ### import param from param.parameterized import get_occupied_slots -from .util import datetime_types + from ..util.warnings import deprecated +from .util import datetime_types class BoundingRegion: diff --git a/holoviews/core/data/__init__.py b/holoviews/core/data/__init__.py index f2f82c3ba5..f74549aca4 100644 --- a/holoviews/core/data/__init__.py +++ b/holoviews/core/data/__init__.py @@ -1,37 +1,38 @@ -import types import copy - +import types from contextlib import contextmanager from functools import wraps import numpy as np +import pandas as pd # noqa import param -import pandas as pd # noqa - from param.parameterized import ParameterizedMetaclass +from .. import util as core_util from ..accessors import Redim from ..dimension import ( - Dimension, Dimensioned, LabelledData, dimension_name, process_dimensions + Dimension, + Dimensioned, + LabelledData, + dimension_name, + process_dimensions, ) from ..element import Element from ..ndmapping import MultiDimensionalMapping -from ..spaces import HoloMap, DynamicMap -from .. import util as core_util - +from ..spaces import DynamicMap, HoloMap from .array import ArrayInterface -from .cudf import cuDFInterface # noqa (API import) -from .dask import DaskInterface # noqa (API import) -from .dictionary import DictInterface # noqa (API import) -from .grid import GridInterface # noqa (API import) -from .ibis import IbisInterface # noqa (API import) +from .cudf import cuDFInterface # noqa (API import) +from .dask import DaskInterface # noqa (API import) +from .dictionary import DictInterface # noqa (API import) +from .grid import GridInterface # noqa (API import) +from .ibis import IbisInterface # noqa (API import) +from .image import ImageInterface # noqa (API import) from .interface import Interface, iloc, ndloc -from .multipath import MultiInterface # noqa (API import) -from .image import ImageInterface # noqa (API import) -from .pandas import PandasAPI, PandasInterface # noqa (API import) -from .spatialpandas import SpatialPandasInterface # noqa (API import) -from .spatialpandas_dask import DaskSpatialPandasInterface # noqa (API import) -from .xarray import XArrayInterface # noqa (API import) +from .multipath import MultiInterface # noqa (API import) +from .pandas import PandasAPI, PandasInterface # noqa (API import) +from .spatialpandas import SpatialPandasInterface # noqa (API import) +from .spatialpandas_dask import DaskSpatialPandasInterface # noqa (API import) +from .xarray import XArrayInterface # noqa (API import) default_datatype = 'dataframe' @@ -289,7 +290,8 @@ class to each underlying element. def __init__(self, data, kdims=None, vdims=None, **kwargs): from ...operation.element import ( - chain as chain_op, factory + chain as chain_op, + factory, ) self._in_method = False input_data = data @@ -785,7 +787,7 @@ def sample(self, samples=[], bounds=None, closest=True, **kwargs): # Note: Special handling sampling of gridded 2D data as Curve # may be replaced with more general handling # see https://github.com/holoviz/holoviews/issues/1173 - from ...element import Table, Curve + from ...element import Curve, Table datatype = ['dataframe', 'dictionary', 'dask', 'ibis', 'cuDF'] if len(samples) == 1: sel = {kd.name: s for kd, s in zip(self.kdims, samples[0])} diff --git a/holoviews/core/data/array.py b/holoviews/core/data/array.py index d96e07d71f..8dc7a4fa12 100644 --- a/holoviews/core/data/array.py +++ b/holoviews/core/data/array.py @@ -1,10 +1,10 @@ import numpy as np -from .interface import Interface, DataError +from .. import util from ..dimension import dimension_name from ..element import Element from ..ndmapping import NdMapping, item_check, sorted_context -from .. import util +from .interface import DataError, Interface class ArrayInterface(Interface): diff --git a/holoviews/core/data/cudf.py b/holoviews/core/data/cudf.py index 52edbf0e43..e9fd4d77bc 100644 --- a/holoviews/core/data/cudf.py +++ b/holoviews/core/data/cudf.py @@ -1,6 +1,5 @@ import sys import warnings - from itertools import product import numpy as np diff --git a/holoviews/core/data/dictionary.py b/holoviews/core/data/dictionary.py index 07c54073a1..b89b940502 100644 --- a/holoviews/core/data/dictionary.py +++ b/holoviews/core/data/dictionary.py @@ -2,13 +2,12 @@ import numpy as np -from .interface import Interface, DataError +from .. import util from ..dimension import dimension_name from ..element import Element from ..ndmapping import NdMapping, item_check, sorted_context from ..util import isscalar -from .. import util - +from .interface import DataError, Interface class DictInterface(Interface): diff --git a/holoviews/core/data/grid.py b/holoviews/core/data/grid.py index b6152779f5..42389ad4c9 100644 --- a/holoviews/core/data/grid.py +++ b/holoviews/core/data/grid.py @@ -2,14 +2,13 @@ import numpy as np -from .dictionary import DictInterface -from .interface import Interface, DataError +from .. import util from ..dimension import dimension_name from ..element import Element from ..ndmapping import NdMapping, item_check, sorted_context -from .. import util -from .util import finite_range, is_dask, dask_array_module, get_array_types - +from .dictionary import DictInterface +from .interface import DataError, Interface +from .util import dask_array_module, finite_range, get_array_types, is_dask class GridInterface(DictInterface): diff --git a/holoviews/core/data/ibis.py b/holoviews/core/data/ibis.py index 16e17f7976..d1270ca93a 100644 --- a/holoviews/core/data/ibis.py +++ b/holoviews/core/data/ibis.py @@ -1,14 +1,15 @@ import sys -import numpy as np from collections.abc import Iterable from functools import lru_cache + +import numpy as np from packaging.version import Version from .. import util from ..element import Element from ..ndmapping import NdMapping, item_check, sorted_context -from .interface import Interface from . import pandas +from .interface import Interface from .util import cached diff --git a/holoviews/core/data/image.py b/holoviews/core/data/image.py index 5e556af243..7865c6d8b1 100644 --- a/holoviews/core/data/image.py +++ b/holoviews/core/data/image.py @@ -1,13 +1,13 @@ import numpy as np +from .. import util from ..boundingregion import BoundingBox from ..dimension import dimension_name from ..element import Element -from ..ndmapping import NdMapping, item_check -from ..sheetcoords import Slice, SheetCoordinateSystem -from .. import util +from ..ndmapping import NdMapping, item_check +from ..sheetcoords import SheetCoordinateSystem, Slice from .grid import GridInterface -from .interface import Interface, DataError +from .interface import DataError, Interface from .util import finite_range diff --git a/holoviews/core/data/interface.py b/holoviews/core/data/interface.py index 62050a4429..0a60552f9b 100644 --- a/holoviews/core/data/interface.py +++ b/holoviews/core/data/interface.py @@ -1,8 +1,8 @@ import sys import warnings -import param import numpy as np +import param from .. import util from ..element import Element @@ -24,8 +24,8 @@ def __init__(self, dataset): self.dataset = dataset def __getitem__(self, index): - from ..data import Dataset from ...operation.element import method + from ..data import Dataset in_method = self.dataset._in_method if not in_method: self.dataset._in_method = True diff --git a/holoviews/core/data/multipath.py b/holoviews/core/data/multipath.py index 3e261b51c3..f0e5287b77 100644 --- a/holoviews/core/data/multipath.py +++ b/holoviews/core/data/multipath.py @@ -4,7 +4,7 @@ from ..element import Element from ..ndmapping import NdMapping, item_check, sorted_context from .dictionary import DictInterface -from .interface import Interface, DataError +from .interface import DataError, Interface class MultiInterface(Interface): @@ -31,7 +31,7 @@ class MultiInterface(Interface): @classmethod def init(cls, eltype, data, kdims, vdims): - from ...element import Polygons, Path + from ...element import Path, Polygons new_data = [] dims = {'kdims': eltype.kdims, 'vdims': eltype.vdims} @@ -101,7 +101,7 @@ def validate(cls, dataset, vdims=True): @classmethod def geom_type(cls, dataset): - from holoviews.element import Polygons, Path, Points + from holoviews.element import Path, Points, Polygons if isinstance(dataset, type): eltype = dataset else: diff --git a/holoviews/core/data/pandas.py b/holoviews/core/data/pandas.py index 55fbffb3b4..fc38e19c96 100644 --- a/holoviews/core/data/pandas.py +++ b/holoviews/core/data/pandas.py @@ -1,14 +1,13 @@ -from packaging.version import Version - import numpy as np import pandas as pd +from packaging.version import Version from pandas.api.types import is_numeric_dtype -from .interface import Interface, DataError -from ..dimension import dimension_name, Dimension +from .. import util +from ..dimension import Dimension, dimension_name from ..element import Element from ..ndmapping import NdMapping, item_check, sorted_context -from .. import util +from .interface import DataError, Interface from .util import finite_range diff --git a/holoviews/core/data/spatialpandas.py b/holoviews/core/data/spatialpandas.py index 69bc506953..0dfe4799a1 100644 --- a/holoviews/core/data/spatialpandas.py +++ b/holoviews/core/data/spatialpandas.py @@ -1,12 +1,11 @@ import sys - from collections import defaultdict import numpy as np import pandas as pd from ..dimension import dimension_name -from ..util import isscalar, unique_iterator, unique_array +from ..util import isscalar, unique_array, unique_iterator from .interface import DataError, Interface from .multipath import MultiInterface, ensure_ring from .pandas import PandasInterface @@ -142,7 +141,10 @@ def dtype(cls, dataset, dimension): @classmethod def has_holes(cls, dataset): from spatialpandas.geometry import ( - MultiPolygonDtype, PolygonDtype, Polygon, MultiPolygon + MultiPolygon, + MultiPolygonDtype, + Polygon, + PolygonDtype, ) col = cls.geo_column(dataset.data) series = dataset.data[col] @@ -387,6 +389,7 @@ def values(cls, dataset, dimension, expanded=True, flat=True, compute=True, keep @classmethod def split(cls, dataset, start, end, datatype, **kwargs): from spatialpandas import GeoDataFrame, GeoSeries + from ...element import Polygons objs = [] @@ -459,8 +462,13 @@ def get_geom_type(gdf, col): A string representing the type of geometry """ from spatialpandas.geometry import ( - PointDtype, MultiPointDtype, LineDtype, MultiLineDtype, - PolygonDtype, MultiPolygonDtype, RingDtype + LineDtype, + MultiLineDtype, + MultiPointDtype, + MultiPolygonDtype, + PointDtype, + PolygonDtype, + RingDtype, ) column = gdf[col] @@ -486,7 +494,12 @@ def geom_to_array(geom, index=None, multi=False, geom_type=None): Array or list of arrays. """ from spatialpandas.geometry import ( - Point, Polygon, Line, Ring, MultiPolygon, MultiPoint + Line, + MultiPoint, + MultiPolygon, + Point, + Polygon, + Ring, ) if isinstance(geom, Point): if index is None: @@ -533,7 +546,7 @@ def geom_array_to_array(geom_array, index, expand=False, geom_type=None): Returns: Flattened array """ - from spatialpandas.geometry import PointArray, MultiPointArray + from spatialpandas.geometry import MultiPointArray, PointArray if isinstance(geom_array, PointArray): return geom_array.y if index else geom_array.x arrays = [] @@ -557,7 +570,7 @@ def geom_array_to_array(geom_array, index, expand=False, geom_type=None): def geom_length(geom): - from spatialpandas.geometry import Polygon, Ring, MultiPolygon, MultiLine + from spatialpandas.geometry import MultiLine, MultiPolygon, Polygon, Ring if isinstance(geom, Polygon): offset = 0 exterior = geom.data[0] @@ -644,7 +657,7 @@ def geom_to_holes(geom): Returns: List of arrays representing holes """ - from spatialpandas.geometry import Polygon, MultiPolygon + from spatialpandas.geometry import MultiPolygon, Polygon if isinstance(geom, Polygon): holes = [] for i, hole in enumerate(geom.data): @@ -683,11 +696,21 @@ def to_spatialpandas(data, xdim, ydim, columns=[], geom='point'): Returns: A spatialpandas.GeoDataFrame version of the data """ - from spatialpandas import GeoSeries, GeoDataFrame + from spatialpandas import GeoDataFrame, GeoSeries from spatialpandas.geometry import ( - Point, Line, Polygon, Ring, LineArray, PolygonArray, PointArray, - MultiLineArray, MultiPolygonArray, MultiPointArray, RingArray + Line, + LineArray, + MultiLineArray, + MultiPointArray, + MultiPolygonArray, + Point, + PointArray, + Polygon, + PolygonArray, + Ring, + RingArray, ) + from ...element import Polygons poly = any(Polygons._hole_key in d for d in data) or geom == 'Polygon' if poly: @@ -870,8 +893,8 @@ def from_shapely(data): A GeoDataFrame containing the shapely geometry data. """ - from spatialpandas import GeoDataFrame, GeoSeries from shapely.geometry.base import BaseGeometry + from spatialpandas import GeoDataFrame, GeoSeries if not data: pass diff --git a/holoviews/core/data/xarray.py b/holoviews/core/data/xarray.py index 9014edcb1a..1dcb07d971 100644 --- a/holoviews/core/data/xarray.py +++ b/holoviews/core/data/xarray.py @@ -1,16 +1,15 @@ import sys import types - import numpy as np import pandas as pd from .. import util from ..dimension import Dimension, asdim, dimension_name -from ..ndmapping import NdMapping, item_check, sorted_context from ..element import Element +from ..ndmapping import NdMapping, item_check, sorted_context from .grid import GridInterface -from .interface import Interface, DataError +from .interface import DataError, Interface from .util import dask_array_module, finite_range diff --git a/holoviews/core/decollate.py b/holoviews/core/decollate.py index 0cc42d32e7..96da93bca5 100644 --- a/holoviews/core/decollate.py +++ b/holoviews/core/decollate.py @@ -1,13 +1,21 @@ +from collections import namedtuple + import param -from .operation import OperationCallable + from .. import ( - Layout, DynamicMap, Element, Callable, Overlay, GridSpace, NdOverlay, HoloMap + Callable, + DynamicMap, + Element, + GridSpace, + HoloMap, + Layout, + NdOverlay, + Overlay, ) -from . import ViewableTree, AdjointLayout -from collections import namedtuple -from ..streams import Stream, Derived - from ..plotting.util import initialize_dynamic +from ..streams import Derived, Stream +from . import AdjointLayout, ViewableTree +from .operation import OperationCallable Expr = namedtuple("HoloviewsExpr", ["fn", "args", "kwargs"]) StreamIndex = namedtuple("StreamIndex", ["index"]) diff --git a/holoviews/core/dimension.py b/holoviews/core/dimension.py index d0a77ff36a..200a3ed374 100644 --- a/holoviews/core/dimension.py +++ b/holoviews/core/dimension.py @@ -4,22 +4,21 @@ baseclass for classes that accept Dimension values. """ import builtins -import re import datetime as dt +import re import weakref - -from operator import itemgetter -from collections import defaultdict, Counter -from itertools import chain -from functools import partial +from collections import Counter, defaultdict from collections.abc import Iterable +from functools import partial +from itertools import chain +from operator import itemgetter -import param import numpy as np +import param from . import util -from .accessors import Opts, Apply, Redim -from .options import Store, Options, cleanup_custom_options +from .accessors import Apply, Opts, Redim +from .options import Options, Store, cleanup_custom_options from .pprint import PrettyPrinter from .tree import AttrTree from .util import bytes_to_unicode diff --git a/holoviews/core/element.py b/holoviews/core/element.py index b496a8b36b..d7d3f7f691 100644 --- a/holoviews/core/element.py +++ b/holoviews/core/element.py @@ -1,14 +1,14 @@ from itertools import groupby -import numpy as np -import param +import numpy as np import pandas as pd +import param from .dimension import Dimensioned, ViewableElement, asdim from .layout import Composable, Layout, NdLayout from .ndmapping import NdMapping -from .overlay import Overlayable, NdOverlay, CompositeOverlay -from .spaces import HoloMap, GridSpace +from .overlay import CompositeOverlay, NdOverlay, Overlayable +from .spaces import GridSpace, HoloMap from .tree import AttrTree from .util import get_param_values diff --git a/holoviews/core/io.py b/holoviews/core/io.py index 43a21385d1..38f53d9c40 100644 --- a/holoviews/core/io.py +++ b/holoviews/core/io.py @@ -12,29 +12,28 @@ objects for a report then generating a PDF or collecting HoloViews objects to dump to HDF5. """ -import re +import itertools import os -import time +import pickle +import re +import shutil import string -import zipfile import tarfile -import shutil -import itertools -import pickle +import time +import zipfile from collections import defaultdict - -from io import BytesIO from hashlib import sha256 +from io import BytesIO import param from param.parameterized import bothmethod from .dimension import LabelledData from .element import Collator, Element -from .overlay import Overlay, Layout from .ndmapping import NdMapping, UniformNdMapping from .options import Store -from .util import unique_iterator, group_sanitizer, label_sanitizer +from .overlay import Layout, Overlay +from .util import group_sanitizer, label_sanitizer, unique_iterator def sanitizer(name, replacements=[(':','_'), ('/','_'), ('\\','_')]): diff --git a/holoviews/core/layout.py b/holoviews/core/layout.py index 727321cb7a..46a5137313 100644 --- a/holoviews/core/layout.py +++ b/holoviews/core/layout.py @@ -5,12 +5,12 @@ to act as supplementary elements. """ -import param import numpy as np +import param +from . import traversal from .dimension import Dimension, Dimensioned, ViewableElement, ViewableTree from .ndmapping import NdMapping, UniformNdMapping -from . import traversal class Layoutable: diff --git a/holoviews/core/ndmapping.py b/holoviews/core/ndmapping.py index 3c0e36ef18..d00fa03b1a 100644 --- a/holoviews/core/ndmapping.py +++ b/holoviews/core/ndmapping.py @@ -6,18 +6,23 @@ from itertools import cycle from operator import itemgetter + import numpy as np import pandas as pd - import param from . import util from .dimension import Dimension, Dimensioned, ViewableElement, asdim from .util import ( - unique_iterator, sanitize_identifier, dimension_sort, wrap_tuple, - process_ellipses, get_ndmapping_label + dimension_sort, + get_ndmapping_label, + process_ellipses, + sanitize_identifier, + unique_iterator, + wrap_tuple, ) + class item_check: """ Context manager to allow creating NdMapping types without diff --git a/holoviews/core/operation.py b/holoviews/core/operation.py index e8b63e7edc..ab0c4899b4 100644 --- a/holoviews/core/operation.py +++ b/holoviews/core/operation.py @@ -4,13 +4,13 @@ """ import param +from . import Dataset, util from .dimension import ViewableElement from .element import Element from .layout import Layout from .options import Store from .overlay import NdOverlay, Overlay from .spaces import Callable, HoloMap -from . import util, Dataset class Operation(param.ParameterizedFunction): diff --git a/holoviews/core/options.py b/holoviews/core/options.py index fce740032d..9e5e519807 100644 --- a/holoviews/core/options.py +++ b/holoviews/core/options.py @@ -36,19 +36,16 @@ import inspect import pickle import traceback - -from contextlib import contextmanager from collections import defaultdict +from contextlib import contextmanager import numpy as np import param -from .accessors import Opts # noqa (clean up in 2.0) -from .tree import AttrTree -from .util import ( - group_sanitizer, label_sanitizer, sanitize_identifier -) +from .accessors import Opts # noqa (clean up in 2.0) from .pprint import InfoPrinter +from .tree import AttrTree +from .util import group_sanitizer, label_sanitizer, sanitize_identifier def cleanup_custom_options(id, weakref=None): @@ -926,7 +923,7 @@ def collapse_element(cls, overlay, ranges=None, mode='data', backend=None): Finds any applicable compositor and applies it. """ from .element import Element - from .overlay import Overlay, CompositeOverlay + from .overlay import CompositeOverlay, Overlay unpack = False if not isinstance(overlay, CompositeOverlay): overlay = Overlay([overlay]) diff --git a/holoviews/core/overlay.py b/holoviews/core/overlay.py index 2146880abe..6abb271695 100644 --- a/holoviews/core/overlay.py +++ b/holoviews/core/overlay.py @@ -8,13 +8,14 @@ """ from functools import reduce -import numpy as np +import numpy as np import param + from .dimension import Dimension, Dimensioned, ViewableElement, ViewableTree +from .layout import AdjointLayout, Composable, Layout, Layoutable from .ndmapping import UniformNdMapping -from .layout import Composable, Layout, AdjointLayout, Layoutable -from .util import sanitize_identifier, unique_array, dimensioned_streams +from .util import dimensioned_streams, sanitize_identifier, unique_array class Overlayable: diff --git a/holoviews/core/pprint.py b/holoviews/core/pprint.py index 7ca8dd600b..72845aa93c 100644 --- a/holoviews/core/pprint.py +++ b/holoviews/core/pprint.py @@ -15,14 +15,12 @@ import textwrap import param - from param.ipython import ParamPager from param.parameterized import bothmethod from .util import group_sanitizer, label_sanitizer - class ParamFilter(param.ParameterizedFunction): """ Given a parameterized object, return a proxy parameterized object @@ -358,7 +356,7 @@ def element_info(cls_or_slf, node, siblings, level, value_dims): def option_info(cls_or_slf, node): if not cls_or_slf.show_options: return None - from .options import Store, Options + from .options import Options, Store options = {} for g in Options._option_groups: gopts = Store.lookup_options(Store.current_backend, node, g, diff --git a/holoviews/core/sheetcoords.py b/holoviews/core/sheetcoords.py index 07c91571f8..a6e8d163cc 100644 --- a/holoviews/core/sheetcoords.py +++ b/holoviews/core/sheetcoords.py @@ -76,10 +76,10 @@ """ import numpy as np + from .boundingregion import BoundingBox from .util import datetime_types - # Note about the 'bounds-master' approach we have adopted # ======================================================= # diff --git a/holoviews/core/spaces.py b/holoviews/core/spaces.py index 93dea46d12..c654aa2891 100644 --- a/holoviews/core/spaces.py +++ b/holoviews/core/spaces.py @@ -1,25 +1,23 @@ import itertools import types - -from numbers import Number -from itertools import groupby -from functools import partial from collections import defaultdict from contextlib import contextmanager +from functools import partial +from itertools import groupby +from numbers import Number from types import FunctionType import numpy as np import param +from ..streams import Params, Stream, streams_list_from_dict from . import traversal, util from .accessors import Opts, Redim from .dimension import Dimension, ViewableElement -from .layout import Layout, AdjointLayout, NdLayout, Empty, Layoutable -from .ndmapping import UniformNdMapping, NdMapping, item_check -from .overlay import Overlay, CompositeOverlay, NdOverlay, Overlayable +from .layout import AdjointLayout, Empty, Layout, Layoutable, NdLayout +from .ndmapping import NdMapping, UniformNdMapping, item_check from .options import Store, StoreOptions -from ..streams import Stream, Params, streams_list_from_dict - +from .overlay import CompositeOverlay, NdOverlay, Overlay, Overlayable class HoloMap(Layoutable, UniformNdMapping, Overlayable): diff --git a/holoviews/core/util.py b/holoviews/core/util.py index f3683e6ff9..4791f460d3 100644 --- a/holoviews/core/util.py +++ b/holoviews/core/util.py @@ -1,29 +1,28 @@ import builtins -import sys -import warnings -import operator +import datetime as dt import hashlib +import inspect +import itertools import json -import time -import types import numbers +import operator import pickle -import inspect -import itertools import string +import sys +import time +import types import unicodedata -import datetime as dt - +import warnings from collections import defaultdict, namedtuple from contextlib import contextmanager -from packaging.version import Version from functools import partial -from threading import Thread, Event +from threading import Event, Thread from types import FunctionType import numpy as np import pandas as pd import param +from packaging.version import Version # Python 2 builtins basestring = str @@ -57,16 +56,19 @@ try: if pandas_version >= Version('1.3.0'): from pandas.core.dtypes.dtypes import DatetimeTZDtype as DatetimeTZDtypeType - from pandas.core.dtypes.generic import ABCSeries, ABCIndex as ABCIndexClass + from pandas.core.dtypes.generic import ( + ABCIndex as ABCIndexClass, + ABCSeries, + ) elif pandas_version >= Version('0.24.0'): from pandas.core.dtypes.dtypes import DatetimeTZDtype as DatetimeTZDtypeType - from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass + from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries elif pandas_version > Version('0.20.0'): from pandas.core.dtypes.dtypes import DatetimeTZDtypeType - from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass + from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries else: from pandas.types.dtypes import DatetimeTZDtypeType - from pandas.types.dtypes.generic import ABCSeries, ABCIndexClass + from pandas.types.dtypes.generic import ABCIndexClass, ABCSeries pandas_datetime_types = (pd.Timestamp, DatetimeTZDtypeType, pd.Period) pandas_timedelta_types = (pd.Timedelta,) datetime_types = datetime_types + pandas_datetime_types diff --git a/holoviews/element/__init__.py b/holoviews/element/__init__.py index 43482ff454..bab108c0fb 100644 --- a/holoviews/element/__init__.py +++ b/holoviews/element/__init__.py @@ -1,9 +1,9 @@ from ..core import HoloMap -from ..core.data import Dataset, DataConversion +from ..core.data import DataConversion, Dataset from .annotation import * from .chart import * -from .geom import * from .chart3d import * +from .geom import * from .graphs import * from .path import * from .raster import * diff --git a/holoviews/element/annotation.py b/holoviews/element/annotation.py index aa5cce91e3..0d06fcc3c4 100644 --- a/holoviews/element/annotation.py +++ b/holoviews/element/annotation.py @@ -1,11 +1,11 @@ from numbers import Number + import numpy as np import param -from ..core.util import datetime_types -from ..core import Dimension, Element2D, Element +from ..core import Dimension, Element, Element2D from ..core.data import Dataset - +from ..core.util import datetime_types class VectorizedAnnotation(Dataset, Element2D): diff --git a/holoviews/element/chart.py b/holoviews/element/chart.py index c74df8aa9e..6b5f52b547 100644 --- a/holoviews/element/chart.py +++ b/holoviews/element/chart.py @@ -1,10 +1,13 @@ import numpy as np import param -from ..core import util -from ..core import Dimension, Dataset, Element2D, NdOverlay, Overlay +from ..core import Dataset, Dimension, Element2D, NdOverlay, Overlay, util from ..core.dimension import process_dimensions -from .geom import Rectangles, Points, VectorField # noqa: F401 backward compatible import +from .geom import ( # noqa: F401 backward compatible import + Points, + Rectangles, + VectorField, +) from .selection import Selection1DExpr diff --git a/holoviews/element/comparison.py b/holoviews/element/comparison.py index 2009294c44..94f8395255 100644 --- a/holoviews/element/comparison.py +++ b/holoviews/element/comparison.py @@ -19,19 +19,31 @@ """ import contextlib from functools import partial +from unittest import TestCase +from unittest.util import safe_repr + import numpy as np import pandas as pd -from unittest.util import safe_repr -from unittest import TestCase -from numpy.testing import assert_array_equal, assert_array_almost_equal - -from . import * # noqa (All Elements need to support comparison) -from ..core import (Element, Empty, AdjointLayout, Overlay, Dimension, - HoloMap, Dimensioned, Layout, NdLayout, NdOverlay, - GridSpace, DynamicMap, GridMatrix) -from ..core.options import Options, Cycle -from ..core.util import (cast_array_to_int64, datetime_types, dt_to_int, - is_float) +from numpy.testing import assert_array_almost_equal, assert_array_equal + +from ..core import ( + AdjointLayout, + Dimension, + Dimensioned, + DynamicMap, + Element, + Empty, + GridMatrix, + GridSpace, + HoloMap, + Layout, + NdLayout, + NdOverlay, + Overlay, +) +from ..core.options import Cycle, Options +from ..core.util import cast_array_to_int64, datetime_types, dt_to_int, is_float +from . import * # noqa (All Elements need to support comparison) class ComparisonInterface: diff --git a/holoviews/element/geom.py b/holoviews/element/geom.py index f3ea3238f3..52d8af596d 100644 --- a/holoviews/element/geom.py +++ b/holoviews/element/geom.py @@ -1,8 +1,7 @@ import numpy as np - import param -from ..core import Dimension, Dataset, Element2D +from ..core import Dataset, Dimension, Element2D from .selection import Selection2DExpr, SelectionGeomExpr diff --git a/holoviews/element/graphs.py b/holoviews/element/graphs.py index beeebf6339..10111a3c4f 100644 --- a/holoviews/element/graphs.py +++ b/holoviews/element/graphs.py @@ -1,18 +1,23 @@ -from types import FunctionType from collections import defaultdict +from types import FunctionType -import param import numpy as np import pandas as pd +import param -from ..core import Dimension, Dataset, Element2D +from ..core import Dataset, Dimension, Element2D from ..core.accessors import Redim -from ..core.util import is_dataframe, max_range, search_indices from ..core.operation import Operation +from ..core.util import is_dataframe, max_range, search_indices from .chart import Points from .path import Path -from .util import (split_path, circular_layout, - connect_edges_pd, quadratic_bezier, connect_tri_edges_pd) +from .util import ( + circular_layout, + connect_edges_pd, + connect_tri_edges_pd, + quadratic_bezier, + split_path, +) class RedimGraph(Redim): diff --git a/holoviews/element/path.py b/holoviews/element/path.py index f5bd295979..6838da9ebe 100644 --- a/holoviews/element/path.py +++ b/holoviews/element/path.py @@ -6,8 +6,8 @@ """ import numpy as np - import param + from ..core import Dataset from ..core.data import MultiInterface from ..core.dimension import Dimension diff --git a/holoviews/element/raster.py b/holoviews/element/raster.py index 15ca5f4334..eb746edc47 100644 --- a/holoviews/element/raster.py +++ b/holoviews/element/raster.py @@ -1,21 +1,21 @@ +import colorsys from copy import deepcopy from operator import itemgetter import numpy as np -import colorsys import param -from ..core import util, config, Dimension, Element2D, Overlay, Dataset +from ..core import Dataset, Dimension, Element2D, Overlay, config, util +from ..core.boundingregion import BoundingBox, BoundingRegion from ..core.data import ImageInterface from ..core.data.interface import DataError from ..core.dimension import dimension_name -from ..core.boundingregion import BoundingRegion, BoundingBox from ..core.sheetcoords import SheetCoordinateSystem, Slice from .chart import Curve from .geom import Selection2DExpr from .graphs import TriMesh from .tabular import Table -from .util import compute_slice_bounds, categorical_aggregate2d +from .util import categorical_aggregate2d, compute_slice_bounds class Raster(Element2D): diff --git a/holoviews/element/sankey.py b/holoviews/element/sankey.py index 00e23de04b..fe0219ef8a 100644 --- a/holoviews/element/sankey.py +++ b/holoviews/element/sankey.py @@ -2,17 +2,16 @@ from functools import cmp_to_key from itertools import cycle -import param import numpy as np +import param -from ..core.dimension import Dimension from ..core.data import Dataset +from ..core.dimension import Dimension from ..core.operation import Operation from ..core.util import get_param_values, unique_array -from .graphs import Graph, Nodes, EdgePaths +from .graphs import EdgePaths, Graph, Nodes from .util import quadratic_bezier - _Y_N_DECIMAL_DIGITS = 6 _Y_EPS = 10 ** -_Y_N_DECIMAL_DIGITS diff --git a/holoviews/element/selection.py b/holoviews/element/selection.py index 19b34d1ace..367ab0ec0e 100644 --- a/holoviews/element/selection.py +++ b/holoviews/element/selection.py @@ -9,7 +9,7 @@ import pandas as pd from ..core import Dataset, NdOverlay, util -from ..streams import SelectionXY, Selection1D, Lasso +from ..streams import Lasso, Selection1D, SelectionXY from ..util.transform import dim from .annotation import HSpan, VSpan @@ -63,8 +63,8 @@ def _merge_regions(region1, region2, operation): def spatial_select_gridded(xvals, yvals, geometry): rectilinear = (np.diff(xvals, axis=0) == 0).all() if rectilinear: - from .raster import Image from .path import Polygons + from .raster import Image try: from ..operation.datashader import rasterize except ImportError: @@ -120,7 +120,7 @@ def spatial_select_columnar(xvals, yvals, geometry): masked_xvals = xvals[sel_mask] masked_yvals = yvals[sel_mask] try: - from spatialpandas.geometry import Polygon, PointArray + from spatialpandas.geometry import PointArray, Polygon points = PointArray((masked_xvals.astype('float'), masked_yvals.astype('float'))) poly = Polygon([np.concatenate([geometry, geometry[:1]]).flatten()]) geom_mask = points.intersects(poly) @@ -148,7 +148,7 @@ def spatial_select(xvals, yvals, geometry): def spatial_geom_select(x0vals, y0vals, x1vals, y1vals, geometry): try: - from shapely.geometry import box, Polygon + from shapely.geometry import Polygon, box boxes = (box(x0, y0, x1, y1) for x0, y0, x1, y1 in zip(x0vals, y0vals, x1vals, y1vals)) poly = Polygon(geometry) diff --git a/holoviews/element/stats.py b/holoviews/element/stats.py index 9e0b9ef6e3..daaebf1113 100644 --- a/holoviews/element/stats.py +++ b/holoviews/element/stats.py @@ -1,8 +1,8 @@ -import param import numpy as np +import param -from ..core.dimension import Dimension, process_dimensions from ..core.data import Dataset +from ..core.dimension import Dimension, process_dimensions from ..core.element import Element, Element2D from ..core.util import get_param_values, unique_iterator from .selection import Selection1DExpr, Selection2DExpr diff --git a/holoviews/element/tabular.py b/holoviews/element/tabular.py index 93882acbe3..1e02607f3e 100644 --- a/holoviews/element/tabular.py +++ b/holoviews/element/tabular.py @@ -1,9 +1,8 @@ import numpy as np - import param -from ..core import Element, Dataset, Tabular +from ..core import Dataset, Element, Tabular from ..core.dimension import Dimension, dimension_name from .selection import SelectionIndexExpr diff --git a/holoviews/element/tiles.py b/holoviews/element/tiles.py index d7bff043ad..66e1f44cc6 100644 --- a/holoviews/element/tiles.py +++ b/holoviews/element/tiles.py @@ -1,11 +1,11 @@ from types import FunctionType -import param import numpy as np +import param from ..core.dimension import Dimension from ..core.element import Element2D -from ..util.transform import lon_lat_to_easting_northing, easting_northing_to_lon_lat +from ..util.transform import easting_northing_to_lon_lat, lon_lat_to_easting_northing class Tiles(Element2D): diff --git a/holoviews/element/util.py b/holoviews/element/util.py index ad31e9beca..19d47ba5ef 100644 --- a/holoviews/element/util.py +++ b/holoviews/element/util.py @@ -1,21 +1,24 @@ import itertools -import param import numpy as np import pandas as pd +import param from ..core import Dataset from ..core.boundingregion import BoundingBox -from ..core.data import default_datatype, PandasInterface +from ..core.data import PandasInterface, default_datatype from ..core.operation import Operation from ..core.sheetcoords import Slice from ..core.util import ( - cartesian_product, datetime_types, is_cyclic, is_nan, - one_to_one, sort_topologically + cartesian_product, + datetime_types, + is_cyclic, + is_nan, + one_to_one, + sort_topologically, ) - def split_path(path): """ Split a Path type containing a single NaN separated path into diff --git a/holoviews/ipython/__init__.py b/holoviews/ipython/__init__.py index ece8d26099..581693f19b 100644 --- a/holoviews/ipython/__init__.py +++ b/holoviews/ipython/__init__.py @@ -2,22 +2,20 @@ from unittest import SkipTest import param -import holoviews as hv - from IPython.core.completer import IPCompleter from IPython.display import HTML, publish_display_data from param import ipython as param_ext +import holoviews as hv + from ..core.dimension import LabelledData -from ..core.tree import AttrTree from ..core.options import Store +from ..core.tree import AttrTree from ..element.comparison import ComparisonTestCase -from ..util import extension from ..plotting.renderer import Renderer +from ..util import extension +from .display_hooks import display, png_display, pprint_display, svg_display from .magics import load_magics -from .display_hooks import display -from .display_hooks import pprint_display, png_display, svg_display - AttrTree._disabled_prefixes = ['_repr_','_ipython_canary_method_should_not_exist'] diff --git a/holoviews/ipython/archive.py b/holoviews/ipython/archive.py index b506a772ad..c6e35ce3ab 100644 --- a/holoviews/ipython/archive.py +++ b/holoviews/ipython/archive.py @@ -3,23 +3,20 @@ and export it to disk via the display hooks. """ -import time -import sys import os +import sys +import time import traceback +import param from IPython.display import Javascript, display -from .preprocessors import Substitute - -from nbformat import reader -from nbconvert import HTMLExporter - +from nbconvert import HTMLExporter, NotebookExporter from nbconvert.preprocessors.clearoutput import ClearOutputPreprocessor -from nbconvert import NotebookExporter +from nbformat import reader -import param from ..core.io import FileArchive, Pickler from ..plotting.renderer import HTML_TAGS, MIME_TYPES +from .preprocessors import Substitute class NotebookArchive(FileArchive): diff --git a/holoviews/ipython/display_hooks.py b/holoviews/ipython/display_hooks.py index 0b892f98ee..23ac45c705 100644 --- a/holoviews/ipython/display_hooks.py +++ b/holoviews/ipython/display_hooks.py @@ -1,25 +1,32 @@ """ Definition and registration of display hooks for the IPython Notebook. """ -from functools import wraps -from contextlib import contextmanager - import sys import traceback +from contextlib import contextmanager +from functools import wraps import IPython from IPython import get_ipython from IPython.display import HTML import holoviews as hv -from ..core.options import (Store, StoreOptions, SkipRendering, - AbbreviatedException) + from ..core import ( - ViewableElement, HoloMap, AdjointLayout, NdLayout, GridSpace, - Layout, CompositeOverlay, DynamicMap, Dimensioned, Empty + AdjointLayout, + CompositeOverlay, + Dimensioned, + DynamicMap, + Empty, + GridSpace, + HoloMap, + Layout, + NdLayout, + ViewableElement, ) -from ..core.traversal import unique_dimkeys from ..core.io import FileArchive +from ..core.options import AbbreviatedException, SkipRendering, Store, StoreOptions +from ..core.traversal import unique_dimkeys from ..core.util import mimebundle_to_html from ..plotting import Plot from ..plotting.renderer import MIME_TYPES diff --git a/holoviews/ipython/magics.py b/holoviews/ipython/magics.py index 6b61703845..801d45bbd5 100644 --- a/holoviews/ipython/magics.py +++ b/holoviews/ipython/magics.py @@ -1,13 +1,11 @@ -import time import sys +import time -from IPython.core.magic import Magics, magics_class, line_magic, line_cell_magic - +from IPython.core.magic import Magics, line_cell_magic, line_magic, magics_class +from IPython.display import HTML, display from ..core.options import Options, Store, StoreOptions, options_policy from ..core.pprint import InfoPrinter - -from IPython.display import display, HTML from ..operation import Compositor #========# @@ -20,14 +18,14 @@ except ImportError: pyparsing = None else: - from holoviews.util.parser import CompositorSpec - from holoviews.util.parser import OptsSpec + from holoviews.util.parser import CompositorSpec, OptsSpec # Set to True to automatically run notebooks. STORE_HISTORY = False from IPython.core import page + InfoPrinter.store = Store diff --git a/holoviews/ipython/preprocessors.py b/holoviews/ipython/preprocessors.py index aa87263ada..3a20a659e6 100644 --- a/holoviews/ipython/preprocessors.py +++ b/holoviews/ipython/preprocessors.py @@ -4,6 +4,7 @@ python holoviews/ipython/convert.py Conversion_Example.ipynb | python """ import ast + from nbconvert.preprocessors import Preprocessor diff --git a/holoviews/ipython/widgets.py b/holoviews/ipython/widgets.py index c7e894e7dc..8a21e3c754 100644 --- a/holoviews/ipython/widgets.py +++ b/holoviews/ipython/widgets.py @@ -1,9 +1,10 @@ -import sys import math +import sys import time -from IPython.core.display import clear_output import param +from IPython.core.display import clear_output + from ..core.util import ProgressIndicator diff --git a/holoviews/operation/__init__.py b/holoviews/operation/__init__.py index fcf44316f1..3ca0db3352 100644 --- a/holoviews/operation/__init__.py +++ b/holoviews/operation/__init__.py @@ -1,8 +1,8 @@ +from ..core import Overlay # noqa (API import) from ..core.operation import Operation from ..core.options import Compositor - from .element import * -from ..core import Overlay # noqa (API import) + def public(obj): if not isinstance(obj, type): return False diff --git a/holoviews/operation/datashader.py b/holoviews/operation/datashader.py index 3df528381c..a6439b2afd 100644 --- a/holoviews/operation/datashader.py +++ b/holoviews/operation/datashader.py @@ -1,41 +1,69 @@ import warnings - from collections.abc import Callable, Iterable from functools import partial -import param -import numpy as np -import pandas as pd -import xarray as xr +import dask.dataframe as dd import datashader as ds import datashader.reductions as rd import datashader.transfer_functions as tf -import dask.dataframe as dd - +import numpy as np +import pandas as pd +import param +import xarray as xr from datashader.colors import color_lookup -from param.parameterized import bothmethod from packaging.version import Version +from param.parameterized import bothmethod try: - from datashader.bundling import (directly_connect_edges as connect_edges, - hammer_bundle) + from datashader.bundling import ( + directly_connect_edges as connect_edges, + hammer_bundle, + ) except ImportError: hammer_bundle, connect_edges = object, object from ..core import ( - CompositeOverlay, Dimension, Element, Operation, Overlay, NdOverlay, Store + CompositeOverlay, + Dimension, + Element, + NdOverlay, + Operation, + Overlay, + Store, ) from ..core.data import ( - Dataset, PandasInterface, XArrayInterface, DaskInterface, cuDFInterface + DaskInterface, + Dataset, + PandasInterface, + XArrayInterface, + cuDFInterface, ) from ..core.util import ( - cast_array_to_int64, cftime_types, cftime_to_timestamp, - datetime_types, dt_to_int, get_param_values + cast_array_to_int64, + cftime_to_timestamp, + cftime_types, + datetime_types, + dt_to_int, + get_param_values, ) from ..element import ( - Image, ImageStack, Path, Curve, RGB, Graph, TriMesh, QuadMesh, - Contours, Spikes, Area, Rectangles, Spread, Segments, Scatter, - Points, Polygons + RGB, + Area, + Contours, + Curve, + Graph, + Image, + ImageStack, + Path, + Points, + Polygons, + QuadMesh, + Rectangles, + Scatter, + Segments, + Spikes, + Spread, + TriMesh, ) from ..element.util import connect_tri_edges_pd from ..streams import PointerXY diff --git a/holoviews/operation/downsample.py b/holoviews/operation/downsample.py index 1ed44d5aa2..f7b2e75c82 100644 --- a/holoviews/operation/downsample.py +++ b/holoviews/operation/downsample.py @@ -34,9 +34,9 @@ import numpy as np import param -from .resample import ResampleOperation1D from ..core import NdOverlay, Overlay from ..element.chart import Area +from .resample import ResampleOperation1D def _argmax_area(prev_x, prev_y, avg_next_x, avg_next_y, x_bucket, y_bucket): diff --git a/holoviews/operation/element.py b/holoviews/operation/element.py index dcade0b2ee..50fea80769 100644 --- a/holoviews/operation/element.py +++ b/holoviews/operation/element.py @@ -6,22 +6,37 @@ import numpy as np import param - from packaging.version import Version from param import _is_number -from ..core import (Operation, NdOverlay, Overlay, GridMatrix, - HoloMap, Dataset, Element, Collator, Dimension) +from ..core import ( + Collator, + Dataset, + Dimension, + Element, + GridMatrix, + HoloMap, + NdOverlay, + Operation, + Overlay, +) from ..core.data import ArrayInterface, DictInterface, PandasInterface, default_datatype from ..core.data.util import dask_array_module from ..core.util import ( - group_sanitizer, label_sanitizer, datetime_types, isfinite, - dt_to_int, isdatetime, is_dask_array, is_cupy_array, is_ibis_expr + datetime_types, + dt_to_int, + group_sanitizer, + is_cupy_array, + is_dask_array, + is_ibis_expr, + isdatetime, + isfinite, + label_sanitizer, ) from ..element.chart import Histogram, Scatter -from ..element.raster import Image, RGB from ..element.path import Contours, Polygons -from ..element.util import categorical_aggregate2d # noqa (API import) +from ..element.raster import RGB, Image +from ..element.util import categorical_aggregate2d # noqa (API import) from ..streams import RangeXY column_interfaces = [ArrayInterface, DictInterface, PandasInterface] @@ -545,10 +560,10 @@ class contours(Operation): def _process(self, element, key=None): try: - from matplotlib.contour import QuadContourSet from matplotlib.axes import Axes + from matplotlib.contour import QuadContourSet + from matplotlib.dates import date2num, num2date from matplotlib.figure import Figure - from matplotlib.dates import num2date, date2num except ImportError: raise ImportError("contours operation requires matplotlib.") extent = element.range(0) + element.range(1)[::-1] diff --git a/holoviews/operation/normalization.py b/holoviews/operation/normalization.py index 16d94b92e9..3f6a28da6b 100644 --- a/holoviews/operation/normalization.py +++ b/holoviews/operation/normalization.py @@ -14,10 +14,11 @@ """ import param -from ..core.operation import Operation -from ..element import Raster + from ..core import Overlay +from ..core.operation import Operation from ..core.util import match_spec +from ..element import Raster class Normalization(Operation): diff --git a/holoviews/operation/resample.py b/holoviews/operation/resample.py index 2f867c02e2..8a53431018 100644 --- a/holoviews/operation/resample.py +++ b/holoviews/operation/resample.py @@ -1,12 +1,11 @@ import numpy as np import param - from param.parameterized import bothmethod from ..core import Dataset, Operation from ..core.util import datetime_types, dt_to_int, isfinite, max_range from ..element import Image -from ..streams import RangeX, RangeXY, PlotSize +from ..streams import PlotSize, RangeX, RangeXY class LinkableOperation(Operation): diff --git a/holoviews/operation/stats.py b/holoviews/operation/stats.py index f85a28d18c..dbe9c7b246 100644 --- a/holoviews/operation/stats.py +++ b/holoviews/operation/stats.py @@ -1,12 +1,10 @@ -import param import numpy as np +import param -from ..core import Dimension, Dataset, NdOverlay +from ..core import Dataset, Dimension, NdOverlay from ..core.operation import Operation from ..core.util import cartesian_product, isfinite -from ..element import (Curve, Area, Image, Distribution, Bivariate, - Contours, Polygons) - +from ..element import Area, Bivariate, Contours, Curve, Distribution, Image, Polygons from .element import contours diff --git a/holoviews/operation/timeseries.py b/holoviews/operation/timeseries.py index b5d347dcb8..c076e9db01 100644 --- a/holoviews/operation/timeseries.py +++ b/holoviews/operation/timeseries.py @@ -1,11 +1,11 @@ -import param import numpy as np import pandas as pd +import param from packaging.version import Version -from ..core import Operation, Element +from ..core import Element, Operation from ..core.data import PandasInterface -from ..core.util import pandas_version, _PANDAS_FUNC_LOOKUP +from ..core.util import _PANDAS_FUNC_LOOKUP, pandas_version from ..element import Scatter diff --git a/holoviews/plotting/__init__.py b/holoviews/plotting/__init__.py index d74dcf1033..ec1c68d591 100644 --- a/holoviews/plotting/__init__.py +++ b/holoviews/plotting/__init__.py @@ -5,13 +5,13 @@ This file defines the HTML tags used to wrap rendered output for display in the IPython Notebook (optional). """ -from ..core.options import Cycle, Compositor -from ..element import Area, Image, ImageStack, QuadMesh, Polygons, Raster, RGB -from ..element.sankey import _layout_sankey, Sankey +from ..core.options import Compositor, Cycle +from ..element import RGB, Area, Image, ImageStack, Polygons, QuadMesh, Raster +from ..element.sankey import Sankey, _layout_sankey +from ..operation.stats import bivariate_kde, univariate_kde from .plot import Plot -from .renderer import Renderer, HTML_TAGS # noqa (API import) -from .util import apply_nodata, flatten_stack, list_cmaps # noqa (API import) -from ..operation.stats import univariate_kde, bivariate_kde +from .renderer import HTML_TAGS, Renderer # noqa (API import) +from .util import apply_nodata, flatten_stack, list_cmaps # noqa (API import) Compositor.register(Compositor("Image", apply_nodata, None, 'data', transfer_options=True, diff --git a/holoviews/plotting/bokeh/__init__.py b/holoviews/plotting/bokeh/__init__.py index 96f4b5b350..838bec2c9f 100644 --- a/holoviews/plotting/bokeh/__init__.py +++ b/holoviews/plotting/bokeh/__init__.py @@ -1,50 +1,121 @@ import sys import numpy as np - from bokeh.palettes import all_palettes from param import concrete_descendents -from ...core import (Store, Overlay, NdOverlay, Layout, AdjointLayout, - GridSpace, GridMatrix, NdLayout, config) -from ...element import (Curve, Points, Scatter, Image, Raster, Path, - RGB, Histogram, Spread, HeatMap, Contours, Bars, - Box, Bounds, Ellipse, Polygons, BoxWhisker, Arrow, - ErrorBars, Text, HLine, VLine, HSpan, VSpan, Spline, Spikes, - Table, ItemTable, Area, HSV, QuadMesh, VectorField, - Graph, Nodes, EdgePaths, Distribution, Bivariate, - TriMesh, Violin, Chord, Div, HexTiles, Labels, Sankey, - Tiles, Segments, Slope, Rectangles, VLines, VSpans, HLines, HSpans, ImageStack) -from ...core.options import Options, Cycle, Palette - -from .annotation import ( - TextPlot, LineAnnotationPlot, VLinesAnnotationPlot, VSpansAnnotationPlot, - HLinesAnnotationPlot, HSpansAnnotationPlot, BoxAnnotationPlot, SplinePlot, ArrowPlot, - DivPlot, LabelsPlot, SlopePlot +from ...core import ( + AdjointLayout, + GridMatrix, + GridSpace, + Layout, + NdLayout, + NdOverlay, + Overlay, + Store, + config, +) +from ...core.options import Cycle, Options, Palette +from ...element import ( + HSV, + RGB, + Area, + Arrow, + Bars, + Bivariate, + Bounds, + Box, + BoxWhisker, + Chord, + Contours, + Curve, + Distribution, + Div, + EdgePaths, + Ellipse, + ErrorBars, + Graph, + HeatMap, + HexTiles, + Histogram, + HLine, + HLines, + HSpan, + HSpans, + Image, + ImageStack, + ItemTable, + Labels, + Nodes, + Path, + Points, + Polygons, + QuadMesh, + Raster, + Rectangles, + Sankey, + Scatter, + Segments, + Slope, + Spikes, + Spline, + Spread, + Table, + Text, + Tiles, + TriMesh, + VectorField, + Violin, + VLine, + VLines, + VSpan, + VSpans, ) - from ..plot import PlotSelector from ..util import fire -from .callbacks import Callback # noqa (API import) -from .element import OverlayPlot, ElementPlot -from .chart import (PointPlot, CurvePlot, SpreadPlot, ErrorPlot, HistogramPlot, - SideHistogramPlot, BarPlot, SpikesPlot, SideSpikesPlot, - AreaPlot, VectorFieldPlot) -from .geometry import SegmentPlot, RectanglesPlot -from .graphs import GraphPlot, NodePlot, TriMeshPlot, ChordPlot +from .annotation import ( + ArrowPlot, + BoxAnnotationPlot, + DivPlot, + HLinesAnnotationPlot, + HSpansAnnotationPlot, + LabelsPlot, + LineAnnotationPlot, + SlopePlot, + SplinePlot, + TextPlot, + VLinesAnnotationPlot, + VSpansAnnotationPlot, +) +from .callbacks import Callback # noqa (API import) +from .chart import ( + AreaPlot, + BarPlot, + CurvePlot, + ErrorPlot, + HistogramPlot, + PointPlot, + SideHistogramPlot, + SideSpikesPlot, + SpikesPlot, + SpreadPlot, + VectorFieldPlot, +) +from .element import ElementPlot, OverlayPlot +from .geometry import RectanglesPlot, SegmentPlot +from .graphs import ChordPlot, GraphPlot, NodePlot, TriMeshPlot from .heatmap import HeatMapPlot, RadialHeatMapPlot from .hex_tiles import HexTilesPlot -from .links import LinkCallback # noqa (API import) -from .path import PathPlot, PolygonPlot, ContourPlot -from .plot import GridPlot, LayoutPlot, AdjointLayoutPlot -from .raster import RasterPlot, RGBPlot, HSVPlot, QuadMeshPlot, ImageStackPlot +from .links import LinkCallback # noqa (API import) +from .path import ContourPlot, PathPlot, PolygonPlot +from .plot import AdjointLayoutPlot, GridPlot, LayoutPlot +from .raster import HSVPlot, ImageStackPlot, QuadMeshPlot, RasterPlot, RGBPlot from .renderer import BokehRenderer from .sankey import SankeyPlot -from .stats import DistributionPlot, BivariatePlot, BoxWhiskerPlot, ViolinPlot +from .stats import BivariatePlot, BoxWhiskerPlot, DistributionPlot, ViolinPlot from .tabular import TablePlot from .tiles import TilePlot -from .util import bokeh_version # noqa (API import) - +from .util import bokeh_version # noqa (API import) Store.renderers['bokeh'] = BokehRenderer.instance() diff --git a/holoviews/plotting/bokeh/annotation.py b/holoviews/plotting/bokeh/annotation.py index 02d142a532..78308a0ef7 100644 --- a/holoviews/plotting/bokeh/annotation.py +++ b/holoviews/plotting/bokeh/annotation.py @@ -2,23 +2,20 @@ from collections import defaultdict from html import escape -import param import numpy as np - -from bokeh.models import BoxAnnotation, Span, Arrow, Slope -from panel.models import HTML - -from bokeh.models import TeeHead, NormalHead +import param +from bokeh.models import Arrow, BoxAnnotation, NormalHead, Slope, Span, TeeHead from bokeh.transform import dodge +from panel.models import HTML from ...core.util import datetime_types, dimension_sanitizer -from ...element import HLine, VLine, VSpan, HLines, VLines, HSpans, VSpans +from ...element import HLine, HLines, HSpans, VLine, VLines, VSpan, VSpans from ..plot import GenericElementPlot from .element import AnnotationPlot, ColorbarPlot, CompositeElementPlot, ElementPlot +from .plot import BokehPlot from .selection import BokehOverlaySelectionDisplay from .styles import base_properties, fill_properties, line_properties, text_properties -from .plot import BokehPlot -from .util import date_to_integer, bokeh32 +from .util import bokeh32, date_to_integer arrow_start = {'<->': NormalHead, '<|-|>': NormalHead} arrow_end = {'->': NormalHead, '-[': TeeHead, '-|>': NormalHead, diff --git a/holoviews/plotting/bokeh/callbacks.py b/holoviews/plotting/bokeh/callbacks.py index 62251b5aac..9fb01af5ea 100644 --- a/holoviews/plotting/bokeh/callbacks.py +++ b/holoviews/plotting/bokeh/callbacks.py @@ -1,32 +1,61 @@ import asyncio import base64 import time - from collections import defaultdict import numpy as np - from bokeh.models import ( - CustomJS, FactorRange, DatetimeAxis, Range1d, DataRange1d, - PolyDrawTool, PolyEditTool, FreehandDrawTool, - PointDrawTool, BoxEditTool + BoxEditTool, + CustomJS, + DataRange1d, + DatetimeAxis, + FactorRange, + FreehandDrawTool, + PointDrawTool, + PolyDrawTool, + PolyEditTool, + Range1d, ) from panel.io.state import state from ...core.options import CallbackError -from ...core.util import ( - datetime_types, dimension_sanitizer, dt64_to_dt, isequal -) +from ...core.util import datetime_types, dimension_sanitizer, dt64_to_dt, isequal from ...element import Table from ...streams import ( - Stream, PointerXY, RangeXY, Selection1D, RangeX, RangeY, PointerX, - PointerY, BoundsX, BoundsY, Tap, SingleTap, DoubleTap, MouseEnter, - MouseLeave, PressUp, PanEnd, PlotSize, Draw, BoundsXY, PlotReset, - BoxEdit, PointDraw, PolyDraw, PolyEdit, CDSStream, FreehandDraw, - CurveEdit, SelectionXY, Lasso, SelectMode + BoundsX, + BoundsXY, + BoundsY, + BoxEdit, + CDSStream, + CurveEdit, + DoubleTap, + Draw, + FreehandDraw, + Lasso, + MouseEnter, + MouseLeave, + PanEnd, + PlotReset, + PlotSize, + PointDraw, + PointerX, + PointerXY, + PointerY, + PolyDraw, + PolyEdit, + PressUp, + RangeX, + RangeXY, + RangeY, + Selection1D, + SelectionXY, + SelectMode, + SingleTap, + Stream, + Tap, ) -from .util import bokeh33, convert_timestamp from ...util.warnings import warn +from .util import bokeh33, convert_timestamp class Callback: diff --git a/holoviews/plotting/bokeh/chart.py b/holoviews/plotting/bokeh/chart.py index 993194082c..a38ad94bf2 100644 --- a/holoviews/plotting/bokeh/chart.py +++ b/holoviews/plotting/bokeh/chart.py @@ -2,27 +2,26 @@ import numpy as np import param - -from bokeh.models import ( - CategoricalColorMapper, CustomJS, FactorRange, Range1d, Whisker -) +from bokeh.models import CategoricalColorMapper, CustomJS, FactorRange, Range1d, Whisker from bokeh.models.tools import BoxSelectTool from bokeh.transform import jitter from ...core.data import Dataset from ...core.dimension import dimension_name -from ...core.util import ( - dimension_sanitizer, isfinite -) +from ...core.util import dimension_sanitizer, isfinite from ...operation import interpolate_curve from ...util.transform import dim from ..mixins import AreaMixin, BarsMixin, SpikesMixin from ..util import compute_sizes, get_min_distance -from .element import ElementPlot, ColorbarPlot, LegendPlot, OverlayPlot +from .element import ColorbarPlot, ElementPlot, LegendPlot, OverlayPlot from .selection import BokehOverlaySelectionDisplay from .styles import ( - expand_batched_style, base_properties, line_properties, fill_properties, - mpl_to_bokeh, rgb2hex + base_properties, + expand_batched_style, + fill_properties, + line_properties, + mpl_to_bokeh, + rgb2hex, ) from .util import categorize_array diff --git a/holoviews/plotting/bokeh/element.py b/holoviews/plotting/bokeh/element.py index c5ee44675c..34c1c57a2e 100644 --- a/holoviews/plotting/bokeh/element.py +++ b/holoviews/plotting/bokeh/element.py @@ -1,66 +1,94 @@ import warnings - from itertools import chain from types import FunctionType -import param -import numpy as np import bokeh import bokeh.plotting +import numpy as np +import param from bokeh.core.properties import value from bokeh.document.events import ModelChangedEvent from bokeh.models import ( - BinnedTicker, ColorBar, ColorMapper, CustomJS, EqHistColorMapper, - GlyphRenderer, Legend, Renderer, Title, tools, + BinnedTicker, + ColorBar, + ColorMapper, + CustomJS, + EqHistColorMapper, + GlyphRenderer, + Legend, + Renderer, + Title, + tools, ) from bokeh.models.axes import CategoricalAxis, DatetimeAxis from bokeh.models.formatters import ( - TickFormatter, MercatorTickFormatter + CustomJSTickFormatter, + MercatorTickFormatter, + TickFormatter, ) -from bokeh.models.layouts import Tabs +from bokeh.models.layouts import TabPanel, Tabs from bokeh.models.mappers import ( - LinearColorMapper, LogColorMapper, CategoricalColorMapper + CategoricalColorMapper, + LinearColorMapper, + LogColorMapper, ) +from bokeh.models.ranges import DataRange1d, FactorRange, Range1d from bokeh.models.scales import LogScale -from bokeh.models.ranges import Range1d, DataRange1d, FactorRange from bokeh.models.tickers import ( - Ticker, BasicTicker, FixedTicker, LogTicker, MercatorTicker + BasicTicker, + FixedTicker, + LogTicker, + MercatorTicker, + Ticker, ) from bokeh.models.tools import Tool - from packaging.version import Version -from ...core import DynamicMap, CompositeOverlay, Element, Dimension, Dataset -from ...core.options import abbreviated_exception, Keywords, SkipRendering -from ...core import util -from ...element import ( - Annotation, Contours, Graph, Path, Tiles, VectorField -) -from ...streams import Buffer, RangeXY, PlotSize +from ...core import CompositeOverlay, Dataset, Dimension, DynamicMap, Element, util +from ...core.options import Keywords, SkipRendering, abbreviated_exception +from ...element import Annotation, Contours, Graph, Path, Tiles, VectorField +from ...streams import Buffer, PlotSize, RangeXY from ...util.transform import dim from ..plot import GenericElementPlot, GenericOverlayPlot -from ..util import ( - dim_axis_label, process_cmap, color_intervals, dim_range_key -) +from ..util import color_intervals, dim_axis_label, dim_range_key, process_cmap from .plot import BokehPlot from .styles import ( - base_properties, legend_dimensions, line_properties, mpl_to_bokeh, - property_prefixes, rgba_tuple, text_properties, validate + base_properties, + legend_dimensions, + line_properties, + mpl_to_bokeh, + property_prefixes, + rgba_tuple, + text_properties, + validate, ) from .tabular import TablePlot from .util import ( - TOOL_TYPES, bokeh_version, bokeh32, date_to_integer, - decode_bytes, get_tab_title, glyph_order, py2js_tickformatter, - recursive_model_update, theme_attr_json, cds_column_replace, - hold_policy, match_dim_specs, compute_layout_properties, - wrap_formatter, match_ax_type, match_yaxis_type_to_range, - prop_is_none, remove_legend, property_to_dict, dtype_fix_hook, - get_scale, get_axis_class + TOOL_TYPES, + bokeh32, + bokeh_version, + cds_column_replace, + compute_layout_properties, + date_to_integer, + decode_bytes, + dtype_fix_hook, + get_axis_class, + get_scale, + get_tab_title, + glyph_order, + hold_policy, + match_ax_type, + match_dim_specs, + match_yaxis_type_to_range, + prop_is_none, + property_to_dict, + py2js_tickformatter, + recursive_model_update, + remove_legend, + theme_attr_json, + wrap_formatter, ) -from bokeh.models.formatters import CustomJSTickFormatter -from bokeh.models.layouts import TabPanel - try: TOOLS_MAP = Tool._known_aliases except Exception: diff --git a/holoviews/plotting/bokeh/graphs.py b/holoviews/plotting/bokeh/graphs.py index 7f591ef8e1..4c37b971cc 100644 --- a/holoviews/plotting/bokeh/graphs.py +++ b/holoviews/plotting/bokeh/graphs.py @@ -1,10 +1,15 @@ from collections import defaultdict -import param import numpy as np +import param from bokeh.models import ( - StaticLayoutProvider, NodesAndLinkedEdges, EdgesAndLinkedNodes, - Patches, Bezier, ColumnDataSource, NodesOnly + Bezier, + ColumnDataSource, + EdgesAndLinkedNodes, + NodesAndLinkedEdges, + NodesOnly, + Patches, + StaticLayoutProvider, ) from ...core.data import Dataset @@ -12,12 +17,15 @@ from ...core.util import dimension_sanitizer, unique_array from ...util.transform import dim from ..mixins import ChordMixin, GraphMixin -from ..util import process_cmap, get_directed_graph_paths +from ..util import get_directed_graph_paths, process_cmap from .chart import ColorbarPlot, PointPlot from .element import CompositeElementPlot, LegendPlot from .styles import ( - base_properties, line_properties, fill_properties, text_properties, - rgba_tuple + base_properties, + fill_properties, + line_properties, + rgba_tuple, + text_properties, ) diff --git a/holoviews/plotting/bokeh/heatmap.py b/holoviews/plotting/bokeh/heatmap.py index c8088ec8be..0fcf891713 100644 --- a/holoviews/plotting/bokeh/heatmap.py +++ b/holoviews/plotting/bokeh/heatmap.py @@ -1,16 +1,13 @@ -import param import numpy as np - +import param from bokeh.models.glyphs import AnnularWedge from ...core.data import GridInterface -from ...core.util import is_nan, dimension_sanitizer from ...core.spaces import HoloMap +from ...core.util import dimension_sanitizer, is_nan from .element import ColorbarPlot, CompositeElementPlot from .selection import BokehOverlaySelectionDisplay -from .styles import ( - base_properties, line_properties, fill_properties, text_properties -) +from .styles import base_properties, fill_properties, line_properties, text_properties class HeatMapPlot(ColorbarPlot): diff --git a/holoviews/plotting/bokeh/hex_tiles.py b/holoviews/plotting/bokeh/hex_tiles.py index 7a46957997..adcb473c25 100644 --- a/holoviews/plotting/bokeh/hex_tiles.py +++ b/holoviews/plotting/bokeh/hex_tiles.py @@ -1,8 +1,7 @@ from collections.abc import Callable -import param import numpy as np - +import param from bokeh.util.hex import cartesian_to_axial from ...core import Dimension, Operation @@ -12,7 +11,7 @@ from ...util.transform import dim as dim_transform from .element import ColorbarPlot from .selection import BokehOverlaySelectionDisplay -from .styles import base_properties, line_properties, fill_properties +from .styles import base_properties, fill_properties, line_properties class hex_binning(Operation): diff --git a/holoviews/plotting/bokeh/links.py b/holoviews/plotting/bokeh/links.py index 154cfb3974..bae1590569 100644 --- a/holoviews/plotting/bokeh/links.py +++ b/holoviews/plotting/bokeh/links.py @@ -1,13 +1,15 @@ import numpy as np - -from bokeh.models import CustomJS +from bokeh.models import CustomJS, Toolbar from bokeh.models.tools import RangeTool -from bokeh.models import Toolbar from ...core.util import isscalar from ..links import ( - Link, RectanglesTableLink, DataLink, RangeToolLink, - SelectionLink, VertexTableLink + DataLink, + Link, + RangeToolLink, + RectanglesTableLink, + SelectionLink, + VertexTableLink, ) from ..plot import GenericElementPlot, GenericOverlayPlot diff --git a/holoviews/plotting/bokeh/path.py b/holoviews/plotting/bokeh/path.py index 589dea09bb..d331d3dc7b 100644 --- a/holoviews/plotting/bokeh/path.py +++ b/holoviews/plotting/bokeh/path.py @@ -1,7 +1,7 @@ from collections import defaultdict -import param import numpy as np +import param from ...core import util from ...element import Contours, Polygons @@ -10,8 +10,12 @@ from .element import ColorbarPlot, LegendPlot, OverlayPlot from .selection import BokehOverlaySelectionDisplay from .styles import ( - expand_batched_style, base_properties, line_properties, fill_properties, - mpl_to_bokeh, validate + base_properties, + expand_batched_style, + fill_properties, + line_properties, + mpl_to_bokeh, + validate, ) from .util import multi_polygons_data diff --git a/holoviews/plotting/bokeh/plot.py b/holoviews/plotting/bokeh/plot.py index ccc01aa4f5..b1afe956f6 100644 --- a/holoviews/plotting/bokeh/plot.py +++ b/holoviews/plotting/bokeh/plot.py @@ -1,41 +1,69 @@ -from itertools import groupby from collections import defaultdict +from itertools import groupby import numpy as np import param - from bokeh.layouts import gridplot from bokeh.models import ( - ColumnDataSource, Column, Row, Div, Title, Legend, Axis, ColorBar + Axis, + ColorBar, + Column, + ColumnDataSource, + Div, + Legend, + Row, + Title, ) -from bokeh.models.layouts import Tabs +from bokeh.models.layouts import TabPanel, Tabs -from ...selection import NoOpSelectionDisplay from ...core import ( - Store, AdjointLayout, NdLayout, Layout, Empty, - GridSpace, HoloMap, Element + AdjointLayout, + Element, + Empty, + GridSpace, + HoloMap, + Layout, + NdLayout, + Store, ) from ...core.options import SkipRendering from ...core.util import ( - cftime_to_timestamp, cftime_types, get_method_owner, - is_param_method, unique_iterator, wrap_tuple, wrap_tuple_streams, - _STANDARD_CALENDARS + _STANDARD_CALENDARS, + cftime_to_timestamp, + cftime_types, + get_method_owner, + is_param_method, + unique_iterator, + wrap_tuple, + wrap_tuple_streams, ) +from ...selection import NoOpSelectionDisplay from ..links import Link from ..plot import ( - DimensionedPlot, GenericCompositePlot, GenericLayoutPlot, - GenericElementPlot, GenericOverlayPlot, GenericAdjointLayoutPlot, - CallbackPlot + CallbackPlot, + DimensionedPlot, + GenericAdjointLayoutPlot, + GenericCompositePlot, + GenericElementPlot, + GenericLayoutPlot, + GenericOverlayPlot, ) -from ..util import attach_streams, displayable, collate +from ..util import attach_streams, collate, displayable from .links import LinkCallback from .util import ( - filter_toolboxes, make_axis, sync_legends, update_shared_sources, empty_plot, - decode_bytes, theme_attr_json, cds_column_replace, get_default, merge_tools, select_legends + cds_column_replace, + decode_bytes, + empty_plot, + filter_toolboxes, + get_default, + make_axis, + merge_tools, + select_legends, + sync_legends, + theme_attr_json, + update_shared_sources, ) -from bokeh.models.layouts import TabPanel - class BokehPlot(DimensionedPlot, CallbackPlot): """ diff --git a/holoviews/plotting/bokeh/raster.py b/holoviews/plotting/bokeh/raster.py index 080d3b99f1..9d959190e7 100644 --- a/holoviews/plotting/bokeh/raster.py +++ b/holoviews/plotting/bokeh/raster.py @@ -2,8 +2,7 @@ import numpy as np import param - -from bokeh.models import DatetimeAxis, CustomJSHover +from bokeh.models import CustomJSHover, DatetimeAxis from ...core.util import cartesian_product, dimension_sanitizer, isfinite from ...element import Raster diff --git a/holoviews/plotting/bokeh/renderer.py b/holoviews/plotting/bokeh/renderer.py index 4668d65144..3f2f76a4d2 100644 --- a/holoviews/plotting/bokeh/renderer.py +++ b/holoviews/plotting/bokeh/renderer.py @@ -2,9 +2,8 @@ import logging from io import BytesIO -import param import bokeh - +import param from bokeh.document import Document from bokeh.io import curdoc from bokeh.models import Model @@ -13,12 +12,11 @@ from panel.io.state import state from param.parameterized import bothmethod -from ...core import Store, HoloMap +from ...core import HoloMap, Store from ..plot import Plot -from ..renderer import Renderer, MIME_TYPES, HTML_TAGS +from ..renderer import HTML_TAGS, MIME_TYPES, Renderer from .util import compute_plot_size - default_theme = Theme(json={ 'attrs': { 'Title': {'text_color': 'black', 'text_font_size': '12pt'} diff --git a/holoviews/plotting/bokeh/sankey.py b/holoviews/plotting/bokeh/sankey.py index a4a01682db..7a0d76ac53 100644 --- a/holoviews/plotting/bokeh/sankey.py +++ b/holoviews/plotting/bokeh/sankey.py @@ -1,15 +1,13 @@ -import param import numpy as np - +import param from bokeh.models import Patches from ...core.data import Dataset -from ...core.util import max_range, dimension_sanitizer +from ...core.util import dimension_sanitizer, max_range from ...util.transform import dim from .graphs import GraphPlot - class SankeyPlot(GraphPlot): labels = param.ClassSelector(class_=(str, dim), doc=""" diff --git a/holoviews/plotting/bokeh/stats.py b/holoviews/plotting/bokeh/stats.py index 807dd53c53..4251e4ddda 100644 --- a/holoviews/plotting/bokeh/stats.py +++ b/holoviews/plotting/bokeh/stats.py @@ -1,25 +1,28 @@ from collections import defaultdict from functools import partial -import param import numpy as np +import param +from bokeh.models import Circle, FactorRange, HBar, VBar -from bokeh.models import FactorRange, Circle, VBar, HBar - -from .selection import BokehOverlaySelectionDisplay from ...core import NdOverlay from ...core.dimension import Dimension, Dimensioned from ...core.ndmapping import sorted_context from ...core.util import ( - dimension_sanitizer, wrap_tuple, unique_iterator, isfinite, - is_dask_array, is_cupy_array + dimension_sanitizer, + is_cupy_array, + is_dask_array, + isfinite, + unique_iterator, + wrap_tuple, ) from ...operation.stats import univariate_kde from ...util.transform import dim from ..mixins import MultiDistributionMixin from .chart import AreaPlot -from .element import CompositeElementPlot, ColorbarPlot, LegendPlot +from .element import ColorbarPlot, CompositeElementPlot, LegendPlot from .path import PolygonPlot +from .selection import BokehOverlaySelectionDisplay from .styles import base_properties, fill_properties, line_properties from .util import decode_bytes diff --git a/holoviews/plotting/bokeh/styles.py b/holoviews/plotting/bokeh/styles.py index 095b06ae7d..357127de04 100644 --- a/holoviews/plotting/bokeh/styles.py +++ b/holoviews/plotting/bokeh/styles.py @@ -3,13 +3,18 @@ """ import numpy as np - from bokeh.core.properties import ( - Angle, Color, DashPattern, FontSize, MarkerType, Percent, Size + Angle, + Color, + DashPattern, + FontSize, + MarkerType, + Percent, + Size, ) try: - from matplotlib import colors, cm + from matplotlib import cm, colors except ImportError: cm, colors = None, None diff --git a/holoviews/plotting/bokeh/tabular.py b/holoviews/plotting/bokeh/tabular.py index a1a9b71b83..58237f0cf9 100644 --- a/holoviews/plotting/bokeh/tabular.py +++ b/holoviews/plotting/bokeh/tabular.py @@ -1,15 +1,21 @@ import param - from bokeh.models import Column from bokeh.models.widgets import ( - DataTable, TableColumn, NumberEditor, NumberFormatter, DateFormatter, - DateEditor, StringFormatter, StringEditor, IntEditor + DataTable, + DateEditor, + DateFormatter, + IntEditor, + NumberEditor, + NumberFormatter, + StringEditor, + StringFormatter, + TableColumn, ) from ...core import Dataset, Dimension +from ...core.util import dimension_sanitizer, isdatetime from ...element import ItemTable from ...streams import Buffer -from ...core.util import dimension_sanitizer, isdatetime from ..plot import GenericElementPlot from .plot import BokehPlot from .selection import TabularSelectionDisplay diff --git a/holoviews/plotting/bokeh/tiles.py b/holoviews/plotting/bokeh/tiles.py index c050b864bf..441e3a8bbf 100644 --- a/holoviews/plotting/bokeh/tiles.py +++ b/holoviews/plotting/bokeh/tiles.py @@ -1,6 +1,5 @@ import numpy as np - -from bokeh.models import WMTSTileSource, BBoxTileSource, QUADKEYTileSource +from bokeh.models import BBoxTileSource, QUADKEYTileSource, WMTSTileSource from ...core.options import SkipRendering from ...element.tiles import _ATTRIBUTIONS diff --git a/holoviews/plotting/bokeh/util.py b/holoviews/plotting/bokeh/util.py index 7d5cd3c94b..6ba380ac28 100644 --- a/holoviews/plotting/bokeh/util.py +++ b/holoviews/plotting/bokeh/util.py @@ -3,51 +3,69 @@ import inspect import re import time - from collections import defaultdict from contextlib import contextmanager from itertools import permutations from types import FunctionType -import param import bokeh import numpy as np import pandas as pd - -from bokeh.core.json_encoder import serialize_json # noqa (API import) +import param +from bokeh.core.json_encoder import serialize_json # noqa (API import) from bokeh.core.property.datetime import Datetime from bokeh.core.validation import silence -from bokeh.layouts import Row, Column -from bokeh.models import tools +from bokeh.layouts import Column, Row, group_tools from bokeh.models import ( - Model, DataRange1d, FactorRange, Range1d, Plot, Spacer, CustomJS, - GridBox, DatetimeAxis, CategoricalAxis, LinearAxis, LogAxis, MercatorAxis + CategoricalAxis, + CopyTool, + CustomJS, + DataRange1d, + DatetimeAxis, + ExamineTool, + FactorRange, + FullscreenTool, + GridBox, + GridPlot, + LayoutDOM, + LinearAxis, + LogAxis, + MercatorAxis, + Model, + Plot, + Range1d, + SaveTool, + Spacer, + Tabs, + Toolbar, + tools, ) from bokeh.models.formatters import ( - TickFormatter, PrintfTickFormatter + CustomJSTickFormatter, + PrintfTickFormatter, + TickFormatter, ) from bokeh.models.scales import CategoricalScale, LinearScale, LogScale from bokeh.models.widgets import DataTable, Div -from bokeh.themes.theme import Theme -from bokeh.themes import built_in_themes -from bokeh.layouts import group_tools -from bokeh.models.formatters import CustomJSTickFormatter -from bokeh.models import Toolbar, Tabs, GridPlot, SaveTool, CopyTool, ExamineTool, FullscreenTool, LayoutDOM from bokeh.plotting import figure +from bokeh.themes import built_in_themes +from bokeh.themes.theme import Theme from packaging.version import Version from ...core.layout import Layout from ...core.ndmapping import NdMapping -from ...core.overlay import Overlay, NdOverlay +from ...core.overlay import NdOverlay, Overlay +from ...core.spaces import DynamicMap, get_nested_dmaps from ...core.util import ( - arraylike_types, callable_name, cftime_types, - cftime_to_timestamp, isnumeric, unique_array + arraylike_types, + callable_name, + cftime_to_timestamp, + cftime_types, + isnumeric, + unique_array, ) -from ...core.spaces import get_nested_dmaps, DynamicMap -from ...util.warnings import warn +from ...util.warnings import deprecated, warn from ..util import dim_axis_label -from ...util.warnings import deprecated - bokeh_version = Version(bokeh.__version__) bokeh32 = bokeh_version >= Version("3.2") diff --git a/holoviews/plotting/links.py b/holoviews/plotting/links.py index 1c23862ec2..dbe4d6c000 100644 --- a/holoviews/plotting/links.py +++ b/holoviews/plotting/links.py @@ -1,5 +1,4 @@ import weakref - from collections import defaultdict import param diff --git a/holoviews/plotting/mixins.py b/holoviews/plotting/mixins.py index 78f6f3d34f..2c940b9543 100644 --- a/holoviews/plotting/mixins.py +++ b/holoviews/plotting/mixins.py @@ -1,6 +1,6 @@ import numpy as np -from ..core import util, Dataset, Dimension +from ..core import Dataset, Dimension, util from ..element import Bars, Graph from ..element.util import categorical_aggregate2d from .util import get_axis_padding diff --git a/holoviews/plotting/mpl/__init__.py b/holoviews/plotting/mpl/__init__.py index ae91c0accf..675f9d2559 100644 --- a/holoviews/plotting/mpl/__init__.py +++ b/holoviews/plotting/mpl/__init__.py @@ -1,13 +1,13 @@ import os -from matplotlib import rc_params_from_file -from matplotlib.colors import ListedColormap, LinearSegmentedColormap -from param import concrete_descendents from colorcet import kbc, register_cmap +from matplotlib import rc_params_from_file +from matplotlib.colors import LinearSegmentedColormap, ListedColormap from packaging.version import Version +from param import concrete_descendents -from ...core import Layout, Collator, GridMatrix, config -from ...core.options import Cycle, Palette, Options +from ...core import Collator, GridMatrix, Layout, config +from ...core.options import Cycle, Options, Palette from ...core.overlay import NdOverlay, Overlay from ...element import * from ..plot import PlotSelector @@ -23,13 +23,11 @@ from .path import * from .plot import * from .raster import * +from .renderer import MPLRenderer from .sankey import * from .stats import * from .tabular import * -from .renderer import MPLRenderer - - mpl_ge_150 = Version(mpl.__version__) >= Version('1.5.0') try: diff --git a/holoviews/plotting/mpl/annotation.py b/holoviews/plotting/mpl/annotation.py index 91092486c8..19a7f93ec5 100644 --- a/holoviews/plotting/mpl/annotation.py +++ b/holoviews/plotting/mpl/annotation.py @@ -1,15 +1,14 @@ -import param -import numpy as np import matplotlib as mpl - +import numpy as np +import param from matplotlib import patches from matplotlib.lines import Line2D -from ...core.util import match_spec from ...core.options import abbreviated_exception -from .element import ElementPlot, ColorbarPlot +from ...core.util import match_spec +from ...element import HLines, HSpans, VLines, VSpans +from .element import ColorbarPlot, ElementPlot from .plot import mpl_rc_context -from ...element import HLines, VLines, HSpans, VSpans class ABLine2D(Line2D): diff --git a/holoviews/plotting/mpl/chart.py b/holoviews/plotting/mpl/chart.py index 3b6dbe5bb2..5508200f14 100644 --- a/holoviews/plotting/mpl/chart.py +++ b/holoviews/plotting/mpl/chart.py @@ -1,31 +1,35 @@ -import param -import numpy as np import matplotlib as mpl -from packaging.version import Version - +import numpy as np +import param from matplotlib import cm from matplotlib.collections import LineCollection from matplotlib.dates import DateFormatter, date2num +from packaging.version import Version from ...core.dimension import Dimension, dimension_name from ...core.options import Store, abbreviated_exception from ...core.util import ( - match_spec, isfinite, dt_to_int, dt64_to_dt, search_indices, - unique_array, isscalar, isdatetime + dt64_to_dt, + dt_to_int, + isdatetime, + isfinite, + isscalar, + match_spec, + search_indices, + unique_array, ) -from ...element import Raster, HeatMap +from ...element import HeatMap, Raster from ...operation import interpolate_curve from ...util.transform import dim -from ..plot import PlotSelector from ..mixins import AreaMixin, BarsMixin, SpikesMixin -from ..util import compute_sizes, get_sideplot_ranges, get_min_distance -from .element import ElementPlot, ColorbarPlot, LegendPlot -from .path import PathPlot +from ..plot import PlotSelector +from ..util import compute_sizes, get_min_distance, get_sideplot_ranges +from .element import ColorbarPlot, ElementPlot, LegendPlot +from .path import PathPlot from .plot import AdjoinedPlot, mpl_rc_context from .util import mpl_version - class ChartPlot(ElementPlot): """ Baseclass to plot Chart elements. diff --git a/holoviews/plotting/mpl/chart3d.py b/holoviews/plotting/mpl/chart3d.py index 7dd517d07e..215efc489c 100644 --- a/holoviews/plotting/mpl/chart3d.py +++ b/holoviews/plotting/mpl/chart3d.py @@ -8,8 +8,8 @@ from ...core.options import abbreviated_exception from ...util.transform import dim as dim_expr from ..util import map_colors -from .element import ColorbarPlot from .chart import PointPlot +from .element import ColorbarPlot from .path import PathPlot from .util import mpl_version diff --git a/holoviews/plotting/mpl/element.py b/holoviews/plotting/mpl/element.py index 0a67081c82..f370dc8d97 100644 --- a/holoviews/plotting/mpl/element.py +++ b/holoviews/plotting/mpl/element.py @@ -3,24 +3,29 @@ import warnings from types import FunctionType -import param -import numpy as np import matplotlib.colors as mpl_colors - +import numpy as np +import param from matplotlib import ticker from matplotlib.dates import date2num from matplotlib.image import AxesImage from packaging.version import Version -from ...core import util -from ...core import (NdOverlay, DynamicMap, Dataset, - CompositeOverlay, Element3D, Element) -from ...core.options import abbreviated_exception, Keywords +from ...core import ( + CompositeOverlay, + Dataset, + DynamicMap, + Element, + Element3D, + NdOverlay, + util, +) +from ...core.options import Keywords, abbreviated_exception from ...element import Graph, Path from ...streams import Stream from ...util.transform import dim from ..plot import GenericElementPlot, GenericOverlayPlot -from ..util import process_cmap, color_intervals, dim_range_key +from ..util import color_intervals, dim_range_key, process_cmap from .plot import MPLPlot, mpl_rc_context from .util import EqHistNormalize, mpl_version, validate, wrap_formatter diff --git a/holoviews/plotting/mpl/geometry.py b/holoviews/plotting/mpl/geometry.py index a54a424e63..f3d8573932 100644 --- a/holoviews/plotting/mpl/geometry.py +++ b/holoviews/plotting/mpl/geometry.py @@ -1,5 +1,4 @@ import numpy as np - from matplotlib.collections import LineCollection, PatchCollection from matplotlib.patches import Rectangle diff --git a/holoviews/plotting/mpl/graphs.py b/holoviews/plotting/mpl/graphs.py index cab4288583..bfe7c44a0e 100644 --- a/holoviews/plotting/mpl/graphs.py +++ b/holoviews/plotting/mpl/graphs.py @@ -1,16 +1,15 @@ import warnings -import param import numpy as np - +import param from matplotlib.collections import LineCollection, PolyCollection from ...core.data import Dataset from ...core.options import Cycle, abbreviated_exception -from ...core.util import unique_array, search_indices, is_number, isscalar +from ...core.util import is_number, isscalar, search_indices, unique_array from ...util.transform import dim from ..mixins import ChordMixin, GraphMixin -from ..util import process_cmap, get_directed_graph_paths +from ..util import get_directed_graph_paths, process_cmap from .element import ColorbarPlot from .util import filter_styles diff --git a/holoviews/plotting/mpl/heatmap.py b/holoviews/plotting/mpl/heatmap.py index 2cb853594f..67cf98fb61 100644 --- a/holoviews/plotting/mpl/heatmap.py +++ b/holoviews/plotting/mpl/heatmap.py @@ -2,13 +2,12 @@ import numpy as np import param - -from matplotlib.patches import Wedge, Circle from matplotlib.collections import LineCollection, PatchCollection +from matplotlib.patches import Circle, Wedge from ...core.data import GridInterface -from ...core.util import dimension_sanitizer, is_nan from ...core.spaces import HoloMap +from ...core.util import dimension_sanitizer, is_nan from ..mixins import HeatMapMixin from .element import ColorbarPlot from .raster import QuadMeshPlot diff --git a/holoviews/plotting/mpl/hex_tiles.py b/holoviews/plotting/mpl/hex_tiles.py index 73ca18ba34..6431588f34 100644 --- a/holoviews/plotting/mpl/hex_tiles.py +++ b/holoviews/plotting/mpl/hex_tiles.py @@ -1,5 +1,5 @@ -import param import numpy as np +import param from .element import ColorbarPlot diff --git a/holoviews/plotting/mpl/path.py b/holoviews/plotting/mpl/path.py index cfba072604..5685d374db 100644 --- a/holoviews/plotting/mpl/path.py +++ b/holoviews/plotting/mpl/path.py @@ -1,8 +1,7 @@ -import param import numpy as np - -from matplotlib.collections import PatchCollection, LineCollection -from matplotlib.dates import date2num, DateFormatter +import param +from matplotlib.collections import LineCollection, PatchCollection +from matplotlib.dates import DateFormatter, date2num from ...core import util from ...core.dimension import Dimension diff --git a/holoviews/plotting/mpl/plot.py b/holoviews/plotting/mpl/plot.py index b3d8356d67..8a8ac75a01 100644 --- a/holoviews/plotting/mpl/plot.py +++ b/holoviews/plotting/mpl/plot.py @@ -1,22 +1,39 @@ -from itertools import chain from contextlib import contextmanager +from itertools import chain -import param -import numpy as np import matplotlib as mpl - -from mpl_toolkits.mplot3d import Axes3D # noqa (For 3D plots) -from matplotlib import pyplot as plt -from matplotlib import gridspec, animation, rcParams +import numpy as np +import param +from matplotlib import ( + animation, + gridspec, + pyplot as plt, + rcParams, +) from matplotlib.font_manager import font_scalings +from mpl_toolkits.mplot3d import Axes3D # noqa (For 3D plots) -from ...core import (HoloMap, AdjointLayout, NdLayout, - GridSpace, Element, CompositeOverlay, Empty, - Collator, GridMatrix, Layout) -from ...core.options import Store, SkipRendering -from ...core.util import int_to_roman, int_to_alpha, wrap_tuple_streams -from ..plot import (DimensionedPlot, GenericLayoutPlot, GenericCompositePlot, - GenericElementPlot, GenericAdjointLayoutPlot) +from ...core import ( + AdjointLayout, + Collator, + CompositeOverlay, + Element, + Empty, + GridMatrix, + GridSpace, + HoloMap, + Layout, + NdLayout, +) +from ...core.options import SkipRendering, Store +from ...core.util import int_to_alpha, int_to_roman, wrap_tuple_streams +from ..plot import ( + DimensionedPlot, + GenericAdjointLayoutPlot, + GenericCompositePlot, + GenericElementPlot, + GenericLayoutPlot, +) from ..util import attach_streams, collate, displayable from .util import compute_ratios, fix_aspect, get_old_rcparams diff --git a/holoviews/plotting/mpl/raster.py b/holoviews/plotting/mpl/raster.py index 3d524241e5..23b752f09a 100644 --- a/holoviews/plotting/mpl/raster.py +++ b/holoviews/plotting/mpl/raster.py @@ -1,17 +1,16 @@ import sys -import param import numpy as np +import param from packaging.version import Version -from ...core import CompositeOverlay, Element -from ...core import traversal +from ...core import CompositeOverlay, Element, traversal from ...core.util import isfinite, match_spec, max_range, unique_iterator -from ...element.raster import Image, Raster, RGB +from ...element.raster import RGB, Image, Raster from ..util import categorical_legend from .chart import PointPlot -from .element import ElementPlot, ColorbarPlot, LegendPlot, OverlayPlot -from .plot import MPLPlot, GridPlot, mpl_rc_context +from .element import ColorbarPlot, ElementPlot, LegendPlot, OverlayPlot +from .plot import GridPlot, MPLPlot, mpl_rc_context from .util import get_raster_array, mpl_version diff --git a/holoviews/plotting/mpl/renderer.py b/holoviews/plotting/mpl/renderer.py index 72f1d169fd..d0c05082d3 100644 --- a/holoviews/plotting/mpl/renderer.py +++ b/holoviews/plotting/mpl/renderer.py @@ -1,22 +1,20 @@ -import os import base64 - -from io import BytesIO -from tempfile import NamedTemporaryFile +import os from contextlib import contextmanager +from io import BytesIO from itertools import chain - -import param +from tempfile import NamedTemporaryFile import matplotlib as mpl - +import param from matplotlib import pyplot as plt from param.parameterized import bothmethod from ...core import HoloMap from ...core.options import Store -from ..renderer import Renderer, MIME_TYPES, HTML_TAGS -from .util import get_tight_bbox, get_old_rcparams +from ..renderer import HTML_TAGS, MIME_TYPES, Renderer +from .util import get_old_rcparams, get_tight_bbox + class OutputWarning(param.Parameterized):pass outputwarning = OutputWarning(name='Warning') diff --git a/holoviews/plotting/mpl/sankey.py b/holoviews/plotting/mpl/sankey.py index 7efa97b147..40fe39f3e4 100644 --- a/holoviews/plotting/mpl/sankey.py +++ b/holoviews/plotting/mpl/sankey.py @@ -1,7 +1,6 @@ import param - -from matplotlib.patches import Rectangle from matplotlib.collections import PatchCollection +from matplotlib.patches import Rectangle from ...core.util import max_range from ...util.transform import dim diff --git a/holoviews/plotting/mpl/stats.py b/holoviews/plotting/mpl/stats.py index 4d66f6f0e4..f728404c3b 100644 --- a/holoviews/plotting/mpl/stats.py +++ b/holoviews/plotting/mpl/stats.py @@ -1,5 +1,5 @@ -import param import numpy as np +import param from ...core.ndmapping import sorted_context from ..mixins import MultiDistributionMixin diff --git a/holoviews/plotting/mpl/tabular.py b/holoviews/plotting/mpl/tabular.py index c13115a62a..122d57156d 100644 --- a/holoviews/plotting/mpl/tabular.py +++ b/holoviews/plotting/mpl/tabular.py @@ -1,7 +1,6 @@ from collections import defaultdict import param - from matplotlib.font_manager import FontProperties from matplotlib.table import Table as mpl_Table @@ -9,7 +8,6 @@ from .plot import mpl_rc_context - class TablePlot(ElementPlot): """ A TablePlot can plot both TableViews and ViewMaps which display diff --git a/holoviews/plotting/mpl/util.py b/holoviews/plotting/mpl/util.py index 6fd5662705..b6e90967b6 100644 --- a/holoviews/plotting/mpl/util.py +++ b/holoviews/plotting/mpl/util.py @@ -2,39 +2,38 @@ import re import warnings -import numpy as np import matplotlib as mpl - -from matplotlib import units as munits -from matplotlib import ticker +import numpy as np +from matplotlib import ( + ticker, + units as munits, +) from matplotlib.colors import Normalize, cnames from matplotlib.lines import Line2D from matplotlib.markers import MarkerStyle from matplotlib.patches import Path, PathPatch -from matplotlib.transforms import Bbox, TransformedBbox, Affine2D -from matplotlib.rcsetup import ( - validate_fontsize, validate_fonttype, validate_hatch) +from matplotlib.rcsetup import validate_fontsize, validate_fonttype, validate_hatch +from matplotlib.transforms import Affine2D, Bbox, TransformedBbox from packaging.version import Version try: # starting Matplotlib 3.4.0 - from matplotlib._enums import CapStyle as validate_capstyle - from matplotlib._enums import JoinStyle as validate_joinstyle + from matplotlib._enums import ( + CapStyle as validate_capstyle, + JoinStyle as validate_joinstyle, + ) except ImportError: # before Matplotlib 3.4.0 - from matplotlib.rcsetup import ( - validate_capstyle, validate_joinstyle) + from matplotlib.rcsetup import validate_capstyle, validate_joinstyle try: - from nc_time_axis import NetCDFTimeConverter, CalendarDateTime + from nc_time_axis import CalendarDateTime, NetCDFTimeConverter nc_axis_available = True except ImportError: from matplotlib.dates import DateConverter NetCDFTimeConverter = DateConverter nc_axis_available = False -from ...core.util import ( - arraylike_types, cftime_types, is_number -) -from ...element import Raster, RGB, Polygons +from ...core.util import arraylike_types, cftime_types, is_number +from ...element import RGB, Polygons, Raster from ..util import COLOR_ALIASES, RGB_HEX_REGEX mpl_version = Version(mpl.__version__) diff --git a/holoviews/plotting/plot.py b/holoviews/plotting/plot.py index 4450ca0ef8..7fd8b38edb 100644 --- a/holoviews/plotting/plot.py +++ b/holoviews/plotting/plot.py @@ -5,7 +5,6 @@ """ import uuid import warnings - from ast import literal_eval from collections import Counter, defaultdict from functools import partial @@ -13,33 +12,43 @@ import numpy as np import param - from panel.config import config from panel.io.document import unlocked from panel.io.notebook import push from panel.io.state import state from pyviz_comms import JupyterComm -from ..selection import NoOpSelectionDisplay -from ..core import util, traversal + +from ..core import traversal, util from ..core.data import Dataset, disable_pipeline from ..core.element import Element, Element3D -from ..core.overlay import Overlay, CompositeOverlay -from ..core.layout import Empty, NdLayout, Layout -from ..core.options import Store, Compositor, SkipRendering, lookup_options -from ..core.overlay import NdOverlay -from ..core.spaces import HoloMap, DynamicMap -from ..core.util import stream_parameters, isfinite -from ..element import Table, Graph -from ..streams import Stream, RangeXY, RangeX, RangeY +from ..core.layout import Empty, Layout, NdLayout +from ..core.options import Compositor, SkipRendering, Store, lookup_options +from ..core.overlay import CompositeOverlay, NdOverlay, Overlay +from ..core.spaces import DynamicMap, HoloMap +from ..core.util import isfinite, stream_parameters +from ..element import Graph, Table +from ..selection import NoOpSelectionDisplay +from ..streams import RangeX, RangeXY, RangeY, Stream from ..util.transform import dim from .util import ( - get_dynamic_mode, initialize_unbounded, dim_axis_label, - attach_streams, traverse_setter, get_nested_streams, - compute_overlayable_zorders, get_nested_plot_frame, - split_dmap_overlay, get_axis_padding, get_range, get_minimum_span, - get_plot_frame, scale_fontsize, dynamic_update + attach_streams, + compute_overlayable_zorders, + dim_axis_label, + dynamic_update, + get_axis_padding, + get_dynamic_mode, + get_minimum_span, + get_nested_plot_frame, + get_nested_streams, + get_plot_frame, + get_range, + initialize_unbounded, + scale_fontsize, + split_dmap_overlay, + traverse_setter, ) + class Plot(param.Parameterized): """ Base class of all Plot classes in HoloViews, designed to be diff --git a/holoviews/plotting/plotly/__init__.py b/holoviews/plotting/plotly/__init__.py index e95b9cfca4..00dae53961 100644 --- a/holoviews/plotting/plotly/__init__.py +++ b/holoviews/plotting/plotly/__init__.py @@ -1,30 +1,25 @@ import plotly - -from param import concrete_descendents from packaging.version import Version +from param import concrete_descendents -from ...core import ( - Overlay, NdOverlay, Layout, NdLayout, GridSpace, GridMatrix, config -) -from ...core.options import Store, Cycle, Options +from ...core import GridMatrix, GridSpace, Layout, NdLayout, NdOverlay, Overlay, config +from ...core.options import Cycle, Options, Store from ...core.util import VersionError from ...element import * - -from .element import ElementPlot -from .renderer import PlotlyRenderer - from .annotation import * -from .tiles import * -from .element import * +from .callbacks import * from .chart import * from .chart3d import * -from .raster import * +from .element import * +from .element import ElementPlot +from .images import * from .plot import * +from .raster import * +from .renderer import PlotlyRenderer +from .shapes import * from .stats import * from .tabular import * -from .callbacks import * -from .shapes import * -from .images import * +from .tiles import * if Version(plotly.__version__) < Version('4.0.0'): raise VersionError( diff --git a/holoviews/plotting/plotly/annotation.py b/holoviews/plotting/plotly/annotation.py index 56843e5912..0b330b7ad1 100644 --- a/holoviews/plotting/plotly/annotation.py +++ b/holoviews/plotting/plotly/annotation.py @@ -1,7 +1,7 @@ import param -from .chart import ScatterPlot from ...element import Tiles +from .chart import ScatterPlot class LabelPlot(ScatterPlot): diff --git a/holoviews/plotting/plotly/callbacks.py b/holoviews/plotting/plotly/callbacks.py index 1f52c9cbf1..56e0c0d670 100644 --- a/holoviews/plotting/plotly/callbacks.py +++ b/holoviews/plotting/plotly/callbacks.py @@ -1,14 +1,19 @@ from weakref import WeakValueDictionary +from ...element import Tiles from ...streams import ( - Stream, Selection1D, RangeXY, RangeX, RangeY, BoundsXY, BoundsX, BoundsY, - SelectionXY + BoundsX, + BoundsXY, + BoundsY, + RangeX, + RangeXY, + RangeY, + Selection1D, + SelectionXY, + Stream, ) - from .util import _trace_to_subplot -from ...element import Tiles - class PlotlyCallbackMetaClass(type): """ diff --git a/holoviews/plotting/plotly/chart.py b/holoviews/plotting/plotly/chart.py index 8f65bf3049..dbf47863a9 100644 --- a/holoviews/plotting/plotly/chart.py +++ b/holoviews/plotting/plotly/chart.py @@ -1,10 +1,10 @@ -import param import numpy as np +import param -from ...operation import interpolate_curve from ...element import Tiles +from ...operation import interpolate_curve from ..mixins import AreaMixin, BarsMixin -from .element import ElementPlot, ColorbarPlot +from .element import ColorbarPlot, ElementPlot from .selection import PlotlyOverlaySelectionDisplay diff --git a/holoviews/plotting/plotly/chart3d.py b/holoviews/plotting/plotly/chart3d.py index e5e13619f2..e0ace1380d 100644 --- a/holoviews/plotting/plotly/chart3d.py +++ b/holoviews/plotting/plotly/chart3d.py @@ -1,13 +1,12 @@ -import param import numpy as np - +import param from plotly import colors from plotly.figure_factory._trisurf import trisurf as trisurface -from .selection import PlotlyOverlaySelectionDisplay from ...core.options import SkipRendering -from .element import ElementPlot, ColorbarPlot -from .chart import ScatterPlot, CurvePlot +from .chart import CurvePlot, ScatterPlot +from .element import ColorbarPlot, ElementPlot +from .selection import PlotlyOverlaySelectionDisplay class Chart3DPlot(ElementPlot): diff --git a/holoviews/plotting/plotly/dash.py b/holoviews/plotting/plotly/dash.py index c90d863a26..008f070189 100644 --- a/holoviews/plotting/plotly/dash.py +++ b/holoviews/plotting/plotly/dash.py @@ -1,23 +1,31 @@ # standard library imports -import uuid +import base64 import copy -from collections import namedtuple import pickle -import base64 +import uuid +from collections import namedtuple + +from dash.exceptions import PreventUpdate # Holoviews imports import holoviews as hv -from dash.exceptions import PreventUpdate -from holoviews.plotting.plotly import PlotlyRenderer, DynamicMap -from holoviews.plotting.plotly.util import clean_internal_figure_properties from holoviews.core.decollate import ( - initialize_dynamic, to_expr_extract_streams, expr_to_fn_of_stream_contents + expr_to_fn_of_stream_contents, + initialize_dynamic, + to_expr_extract_streams, ) -from holoviews.streams import Derived, History +from holoviews.plotting.plotly import DynamicMap, PlotlyRenderer from holoviews.plotting.plotly.callbacks import ( - Selection1DCallback, RangeXYCallback, RangeXCallback, RangeYCallback, - BoundsXYCallback, BoundsXCallback, BoundsYCallback + BoundsXCallback, + BoundsXYCallback, + BoundsYCallback, + RangeXCallback, + RangeXYCallback, + RangeYCallback, + Selection1DCallback, ) +from holoviews.plotting.plotly.util import clean_internal_figure_properties +from holoviews.streams import Derived, History # Dash imports try: @@ -25,11 +33,10 @@ except ImportError: import dash_core_components as dcc import dash_html_components as html -from dash import callback_context -from dash.dependencies import Output, Input, State - # plotly.py imports import plotly.graph_objects as go +from dash import callback_context +from dash.dependencies import Input, Output, State # Activate plotly as current HoloViews extension hv.extension("plotly") diff --git a/holoviews/plotting/plotly/element.py b/holoviews/plotting/plotly/element.py index 9cdf9630ea..504c7dcdea 100644 --- a/holoviews/plotting/plotly/element.py +++ b/holoviews/plotting/plotly/element.py @@ -1,7 +1,8 @@ +import re import uuid + import numpy as np import param -import re from ... import Tiles from ...core import util @@ -13,7 +14,12 @@ from ..util import dim_range_key from .plot import PlotlyPlot from .util import ( - STYLE_ALIASES, get_colorscale, merge_figure, legend_trace_types, merge_layout) + STYLE_ALIASES, + get_colorscale, + legend_trace_types, + merge_figure, + merge_layout, +) class ElementPlot(PlotlyPlot, GenericElementPlot): diff --git a/holoviews/plotting/plotly/images.py b/holoviews/plotting/plotly/images.py index bb55caac29..53fb928e60 100644 --- a/holoviews/plotting/plotly/images.py +++ b/holoviews/plotting/plotly/images.py @@ -1,5 +1,4 @@ import numpy as np - from plotly.graph_objs.layout import Image as _Image from ...core.util import VersionError diff --git a/holoviews/plotting/plotly/plot.py b/holoviews/plotting/plotly/plot.py index 9803ef61b1..ea77114517 100644 --- a/holoviews/plotting/plotly/plot.py +++ b/holoviews/plotting/plotly/plot.py @@ -1,16 +1,20 @@ import param from holoviews.plotting.util import attach_streams -from ...core import (NdLayout, AdjointLayout, Empty, - HoloMap, GridSpace, GridMatrix) -from ...element import Histogram + +from ...core import AdjointLayout, Empty, GridMatrix, GridSpace, HoloMap, NdLayout from ...core.options import Store from ...core.util import wrap_tuple +from ...element import Histogram from ..plot import ( - DimensionedPlot, GenericLayoutPlot, GenericCompositePlot, - GenericElementPlot, GenericAdjointLayoutPlot, CallbackPlot + CallbackPlot, + DimensionedPlot, + GenericAdjointLayoutPlot, + GenericCompositePlot, + GenericElementPlot, + GenericLayoutPlot, ) -from .util import figure_grid, configure_matching_axes_from_dims +from .util import configure_matching_axes_from_dims, figure_grid class PlotlyPlot(DimensionedPlot, CallbackPlot): diff --git a/holoviews/plotting/plotly/renderer.py b/holoviews/plotting/plotly/renderer.py index 73c8827d2b..dcb94a8b94 100644 --- a/holoviews/plotting/plotly/renderer.py +++ b/holoviews/plotting/plotly/renderer.py @@ -1,19 +1,16 @@ import base64 - from io import BytesIO -import param import panel as pn - +import param from param.parameterized import bothmethod -from ..renderer import Renderer, MIME_TYPES, HTML_TAGS -from ...core.options import Store from ...core import HoloMap +from ...core.options import Store +from ..renderer import HTML_TAGS, MIME_TYPES, Renderer from .callbacks import callbacks from .util import clean_internal_figure_properties - with param.logging_level('CRITICAL'): import plotly.graph_objs as go @@ -93,7 +90,6 @@ def get_plot_state(self_or_cls, obj, doc=None, renderer=None, **kwargs): def _figure_data(self, plot, fmt, as_script=False, **kwargs): if fmt == 'gif': import plotly.io as pio - from PIL import Image from plotly.io.orca import ensure_server, shutdown_server, status diff --git a/holoviews/plotting/plotly/selection.py b/holoviews/plotting/plotly/selection.py index 49c82ed5ba..243cb0b30a 100644 --- a/holoviews/plotting/plotly/selection.py +++ b/holoviews/plotting/plotly/selection.py @@ -1,7 +1,6 @@ +from ...core.options import Store from ...core.overlay import NdOverlay, Overlay - from ...selection import OverlaySelectionDisplay -from ...core.options import Store class PlotlyOverlaySelectionDisplay(OverlaySelectionDisplay): diff --git a/holoviews/plotting/plotly/shapes.py b/holoviews/plotting/plotly/shapes.py index 2865148141..f4e7a53705 100644 --- a/holoviews/plotting/plotly/shapes.py +++ b/holoviews/plotting/plotly/shapes.py @@ -1,7 +1,7 @@ -import param import numpy as np +import param -from ...element import HLine, VLine, HSpan, VSpan, Tiles +from ...element import HLine, HSpan, Tiles, VLine, VSpan from ..mixins import GeomMixin from .element import ElementPlot diff --git a/holoviews/plotting/plotly/stats.py b/holoviews/plotting/plotly/stats.py index 4d4f7946d1..2907d7653d 100644 --- a/holoviews/plotting/plotly/stats.py +++ b/holoviews/plotting/plotly/stats.py @@ -1,9 +1,9 @@ import param from ..mixins import MultiDistributionMixin -from .selection import PlotlyOverlaySelectionDisplay from .chart import ChartPlot -from .element import ElementPlot, ColorbarPlot +from .element import ColorbarPlot, ElementPlot +from .selection import PlotlyOverlaySelectionDisplay class BivariatePlot(ChartPlot, ColorbarPlot): diff --git a/holoviews/plotting/plotly/tiles.py b/holoviews/plotting/plotly/tiles.py index 6ecede77dd..cfa6b6a079 100644 --- a/holoviews/plotting/plotly/tiles.py +++ b/holoviews/plotting/plotly/tiles.py @@ -1,7 +1,8 @@ -from holoviews.plotting.plotly import ElementPlot -from holoviews.plotting.plotly.util import STYLE_ALIASES import numpy as np + from holoviews.element.tiles import _ATTRIBUTIONS +from holoviews.plotting.plotly import ElementPlot +from holoviews.plotting.plotly.util import STYLE_ALIASES class TilePlot(ElementPlot): diff --git a/holoviews/plotting/renderer.py b/holoviews/plotting/renderer.py index 7a2af71a1b..62fc5a2611 100644 --- a/holoviews/plotting/renderer.py +++ b/holoviews/plotting/renderer.py @@ -4,43 +4,42 @@ """ import base64 import os - -from io import BytesIO, StringIO from contextlib import contextmanager from functools import partial +from io import BytesIO, StringIO -import param import panel as pn - +import param from bokeh.document import Document -from bokeh.io import curdoc from bokeh.embed import file_html +from bokeh.io import curdoc from bokeh.resources import CDN, INLINE from packaging.version import Version from panel import config -from panel.io.notebook import ipywidget, load_notebook, render_model, render_mimebundle +from panel.io.notebook import ipywidget, load_notebook, render_mimebundle, render_model from panel.io.state import state from panel.models.comm_manager import CommManager as PnCommManager from panel.pane import HoloViews as HoloViewsPane -from panel.widgets.player import PlayerBase from panel.viewable import Viewable +from panel.widgets.player import PlayerBase from pyviz_comms import CommManager + try: # Added in Panel 1.0 to support JS -> Python binary comms from panel.io.notebook import JupyterCommManagerBinary as JupyterCommManager except ImportError: from pyviz_comms import JupyterCommManager -from ..core import Layout, HoloMap, AdjointLayout, DynamicMap +from param.parameterized import bothmethod + +from ..core import AdjointLayout, DynamicMap, HoloMap, Layout from ..core.data import disable_pipeline from ..core.io import Exporter -from ..core.options import Store, StoreOptions, SkipRendering, Compositor +from ..core.options import Compositor, SkipRendering, Store, StoreOptions from ..core.util import unbound_dimensions from ..streams import Stream from . import Plot -from .util import displayable, collate, initialize_dynamic - -from param.parameterized import bothmethod +from .util import collate, displayable, initialize_dynamic panel_version = Version(pn.__version__) diff --git a/holoviews/plotting/util.py b/holoviews/plotting/util.py index 518507eb50..ebfd856491 100644 --- a/holoviews/plotting/util.py +++ b/holoviews/plotting/util.py @@ -1,26 +1,38 @@ +import bisect import re import traceback import warnings -import bisect - from collections import defaultdict, namedtuple -from packaging.version import Version import numpy as np import param +from packaging.version import Version from ..core import ( - HoloMap, DynamicMap, CompositeOverlay, Layout, Overlay, GridSpace, - NdLayout, NdOverlay, AdjointLayout + AdjointLayout, + CompositeOverlay, + DynamicMap, + GridSpace, + HoloMap, + Layout, + NdLayout, + NdOverlay, + Overlay, ) -from ..core.options import CallbackError, Cycle -from ..core.operation import Operation from ..core.ndmapping import item_check +from ..core.operation import Operation +from ..core.options import CallbackError, Cycle from ..core.spaces import get_nested_streams from ..core.util import ( - match_spec, wrap_tuple, get_overlay_spec, unique_iterator, - closest_match, is_number, isfinite, disable_constant, - arraylike_types + arraylike_types, + closest_match, + disable_constant, + get_overlay_spec, + is_number, + isfinite, + match_spec, + unique_iterator, + wrap_tuple, ) from ..element import Points from ..streams import LinkedStream, Params @@ -722,7 +734,7 @@ def info(provider,names): pass if 'colorcet' in provider: try: - from colorcet import palette_n, glasbey_hv + from colorcet import glasbey_hv, palette_n cet_maps = palette_n.copy() cet_maps['glasbey_hv'] = glasbey_hv # Add special hv-specific map cmaps += info('colorcet', cet_maps) @@ -1310,7 +1322,8 @@ class categorical_legend(Operation): def _process(self, element, key=None): import datashader as ds - from ..operation.datashader import shade, rasterize, datashade + + from ..operation.datashader import datashade, rasterize, shade rasterize_op = element.pipeline.find(rasterize, skip_nonlinked=False) if isinstance(rasterize_op, datashade): shade_op = rasterize_op diff --git a/holoviews/pyodide.py b/holoviews/pyodide.py index 70e02613bd..dfb1b7b56b 100644 --- a/holoviews/pyodide.py +++ b/holoviews/pyodide.py @@ -1,7 +1,6 @@ import asyncio import sys - from bokeh.document import Document from bokeh.embed.elements import script_for_render_items from bokeh.embed.util import standalone_docs_json_and_render_items @@ -13,7 +12,6 @@ from .core.options import Store from .util import extension as _extension - #----------------------------------------------------------------------------- # Private API #----------------------------------------------------------------------------- diff --git a/holoviews/selection.py b/holoviews/selection.py index 7daae65aec..9c1ff57cf2 100644 --- a/holoviews/selection.py +++ b/holoviews/selection.py @@ -2,18 +2,22 @@ import numpy as np import param - from param.parameterized import bothmethod from .core.data import Dataset from .core.element import Element, Layout +from .core.layout import AdjointLayout from .core.options import CallbackError, Store from .core.overlay import NdOverlay, Overlay -from .core.layout import AdjointLayout from .core.spaces import GridSpace from .streams import ( - Stream, SelectionExprSequence, CrossFilterSet, - Derived, PlotReset, SelectMode, Pipe + CrossFilterSet, + Derived, + Pipe, + PlotReset, + SelectionExprSequence, + SelectMode, + Stream, ) from .util import DynamicMap diff --git a/holoviews/streams.py b/holoviews/streams.py index 41ee8924d9..ed827f08a9 100644 --- a/holoviews/streams.py +++ b/holoviews/streams.py @@ -6,17 +6,17 @@ import sys import weakref -from numbers import Number from collections import defaultdict from contextlib import contextmanager from functools import partial from itertools import groupby +from numbers import Number from types import FunctionType -from packaging.version import Version -import param -import pandas as pd import numpy as np +import pandas as pd +import param +from packaging.version import Version from .core import util from .core.ndmapping import UniformNdMapping @@ -554,7 +554,10 @@ def __init__(self, data, length=1000, index=True, following=True, **params): loaded = True except ImportError: try: - from streamz.dataframe import DataFrame as StreamingDataFrame, Series as StreamingSeries + from streamz.dataframe import ( + DataFrame as StreamingDataFrame, + Series as StreamingSeries, + ) loaded = True except ImportError: loaded = False @@ -988,8 +991,8 @@ class SelectionExpr(Derived): region_element = param.Parameter(default=None, constant=True) def __init__(self, source, include_region=True, **params): - from .element import Element from .core.spaces import DynamicMap + from .element import Element from .plotting.util import initialize_dynamic self._index_cols = params.pop('index_cols', None) @@ -1821,7 +1824,7 @@ def __init__(self, empty_value=None, num_objects=0, styles={}, tooltip=None, **p @property def element(self): - from .element import Rectangles, Polygons + from .element import Polygons, Rectangles source = self.source if isinstance(source, UniformNdMapping): source = source.last diff --git a/holoviews/tests/conftest.py b/holoviews/tests/conftest.py index 5cf5dfa645..b00a3ffe76 100644 --- a/holoviews/tests/conftest.py +++ b/holoviews/tests/conftest.py @@ -1,8 +1,13 @@ import contextlib import pytest - -from panel.tests.conftest import server_cleanup, port, pytest_addoption, pytest_configure, optional_markers # noqa +from panel.tests.conftest import ( # noqa + optional_markers, + port, + pytest_addoption, + pytest_configure, + server_cleanup, +) def pytest_collection_modifyitems(config, items): diff --git a/holoviews/tests/core/data/base.py b/holoviews/tests/core/data/base.py index 172aa45224..ed8121688e 100644 --- a/holoviews/tests/core/data/base.py +++ b/holoviews/tests/core/data/base.py @@ -5,18 +5,16 @@ import datetime import numpy as np +import pandas as pd -from holoviews import Dataset, HoloMap, Dimension +from holoviews import Dataset, Dimension, HoloMap from holoviews.core.data import concat from holoviews.core.data.interface import DataError -from holoviews.element import Scatter, Curve +from holoviews.element import Curve, Scatter from holoviews.element.comparison import ComparisonTestCase from holoviews.util.transform import dim -import pandas as pd - - class DatatypeContext: def __init__(self, datatypes, dataset_type=Dataset): diff --git a/holoviews/tests/core/data/test_binneddatasets.py b/holoviews/tests/core/data/test_binneddatasets.py index db4c1e4ae7..5744cc0422 100644 --- a/holoviews/tests/core/data/test_binneddatasets.py +++ b/holoviews/tests/core/data/test_binneddatasets.py @@ -6,10 +6,10 @@ import numpy as np -from holoviews.core.dimension import Dimension -from holoviews.core.spaces import HoloMap from holoviews.core.data import Dataset from holoviews.core.data.interface import DataError +from holoviews.core.dimension import Dimension +from holoviews.core.spaces import HoloMap from holoviews.element import Histogram, QuadMesh from holoviews.element.comparison import ComparisonTestCase from holoviews.util.transform import dim diff --git a/holoviews/tests/core/data/test_cudfinterface.py b/holoviews/tests/core/data/test_cudfinterface.py index 5bf9bdd9e5..cdb6c19014 100644 --- a/holoviews/tests/core/data/test_cudfinterface.py +++ b/holoviews/tests/core/data/test_cudfinterface.py @@ -1,5 +1,4 @@ import logging - from unittest import SkipTest import numpy as np diff --git a/holoviews/tests/core/data/test_daskinterface.py b/holoviews/tests/core/data/test_daskinterface.py index cf20f94ca3..006395202e 100644 --- a/holoviews/tests/core/data/test_daskinterface.py +++ b/holoviews/tests/core/data/test_daskinterface.py @@ -1,5 +1,5 @@ -from unittest import SkipTest import unittest +from unittest import SkipTest import numpy as np import pandas as pd @@ -11,8 +11,8 @@ raise SkipTest("Could not import dask, skipping DaskInterface tests.") from holoviews.core.data import Dataset -from holoviews.util.transform import dim from holoviews.core.util import pandas_version +from holoviews.util.transform import dim from .test_pandasinterface import BasePandasInterfaceTests diff --git a/holoviews/tests/core/data/test_dictinterface.py b/holoviews/tests/core/data/test_dictinterface.py index 70f84afde2..56dcd9c6bb 100644 --- a/holoviews/tests/core/data/test_dictinterface.py +++ b/holoviews/tests/core/data/test_dictinterface.py @@ -2,7 +2,7 @@ from holoviews.core.data import Dataset -from .base import HeterogeneousColumnTests, ScalarColumnTests, InterfaceTests +from .base import HeterogeneousColumnTests, InterfaceTests, ScalarColumnTests class DictDatasetTest(HeterogeneousColumnTests, ScalarColumnTests, InterfaceTests): diff --git a/holoviews/tests/core/data/test_gridinterface.py b/holoviews/tests/core/data/test_gridinterface.py index 216df44ce7..1fc7b4825b 100644 --- a/holoviews/tests/core/data/test_gridinterface.py +++ b/holoviews/tests/core/data/test_gridinterface.py @@ -1,14 +1,14 @@ import datetime as dt - from itertools import product from unittest import SkipTest import numpy as np import pandas as pd + from holoviews.core.data import Dataset from holoviews.core.data.interface import DataError from holoviews.core.util import date_range -from holoviews.element import Image, Curve, RGB, HSV +from holoviews.element import HSV, RGB, Curve, Image from holoviews.util.transform import dim try: @@ -18,11 +18,15 @@ from .base import ( - GriddedInterfaceTests, InterfaceTests, HomogeneousColumnTests, DatatypeContext + DatatypeContext, + GriddedInterfaceTests, + HomogeneousColumnTests, + InterfaceTests, ) from .test_imageinterface import ( - BaseImageElementInterfaceTests, BaseRGBElementInterfaceTests, - BaseHSVElementInterfaceTests + BaseHSVElementInterfaceTests, + BaseImageElementInterfaceTests, + BaseRGBElementInterfaceTests, ) diff --git a/holoviews/tests/core/data/test_ibisinterface.py b/holoviews/tests/core/data/test_ibisinterface.py index ee83d605c7..3f0b4d1773 100644 --- a/holoviews/tests/core/data/test_ibisinterface.py +++ b/holoviews/tests/core/data/test_ibisinterface.py @@ -1,7 +1,6 @@ import sqlite3 -from unittest import SkipTest - from tempfile import NamedTemporaryFile +from unittest import SkipTest try: import ibis @@ -13,10 +12,10 @@ import pandas as pd from holoviews.core.data import Dataset -from holoviews.core.spaces import HoloMap from holoviews.core.data.ibis import IbisInterface +from holoviews.core.spaces import HoloMap -from .base import HeterogeneousColumnTests, ScalarColumnTests, InterfaceTests +from .base import HeterogeneousColumnTests, InterfaceTests, ScalarColumnTests def create_temp_db(df, name, index=False): diff --git a/holoviews/tests/core/data/test_imageinterface.py b/holoviews/tests/core/data/test_imageinterface.py index bacd0fe18b..71630c05f5 100644 --- a/holoviews/tests/core/data/test_imageinterface.py +++ b/holoviews/tests/core/data/test_imageinterface.py @@ -2,9 +2,10 @@ from unittest import SkipTest import numpy as np -from holoviews import Dimension, Image, Curve, RGB, HSV, Dataset, Table -from holoviews.core.util import date_range + +from holoviews import HSV, RGB, Curve, Dataset, Dimension, Image, Table from holoviews.core.data.interface import DataError +from holoviews.core.util import date_range from .base import DatatypeContext, GriddedInterfaceTests, InterfaceTests diff --git a/holoviews/tests/core/data/test_multiinterface.py b/holoviews/tests/core/data/test_multiinterface.py index 50dc21baf4..10d972ff09 100644 --- a/holoviews/tests/core/data/test_multiinterface.py +++ b/holoviews/tests/core/data/test_multiinterface.py @@ -6,11 +6,11 @@ import numpy as np import pandas as pd +from param import get_logger from holoviews.core.data import Dataset, MultiInterface from holoviews.element import Path, Points, Polygons from holoviews.element.comparison import ComparisonTestCase -from param import get_logger try: import dask.dataframe as dd diff --git a/holoviews/tests/core/data/test_pandasinterface.py b/holoviews/tests/core/data/test_pandasinterface.py index 37cbb3443e..37b7c0ae28 100644 --- a/holoviews/tests/core/data/test_pandasinterface.py +++ b/holoviews/tests/core/data/test_pandasinterface.py @@ -1,12 +1,11 @@ import numpy as np import pandas as pd -from holoviews.core.dimension import Dimension from holoviews.core.data import Dataset from holoviews.core.data.interface import DataError +from holoviews.core.dimension import Dimension from holoviews.core.spaces import HoloMap -from holoviews.element import Scatter, Points, Distribution - +from holoviews.element import Distribution, Points, Scatter from .base import HeterogeneousColumnTests, InterfaceTests diff --git a/holoviews/tests/core/data/test_spatialpandas.py b/holoviews/tests/core/data/test_spatialpandas.py index aaa5c49ddb..b7791a736b 100644 --- a/holoviews/tests/core/data/test_spatialpandas.py +++ b/holoviews/tests/core/data/test_spatialpandas.py @@ -8,8 +8,13 @@ try: import spatialpandas from spatialpandas.geometry import ( - MultiPolygonArray, LineDtype, PointDtype, PolygonDtype, - MultiLineDtype, MultiPointDtype, MultiPolygonDtype + LineDtype, + MultiLineDtype, + MultiPointDtype, + MultiPolygonArray, + MultiPolygonDtype, + PointDtype, + PolygonDtype, ) except ImportError: spatialpandas = None @@ -20,7 +25,9 @@ dd = None from holoviews.core.data import ( - Dataset, SpatialPandasInterface, DaskSpatialPandasInterface + DaskSpatialPandasInterface, + Dataset, + SpatialPandasInterface, ) from holoviews.core.data.interface import DataError from holoviews.element import Path, Points, Polygons diff --git a/holoviews/tests/core/data/test_xarrayinterface.py b/holoviews/tests/core/data/test_xarrayinterface.py index 1dfbfeffb2..b30013da4c 100644 --- a/holoviews/tests/core/data/test_xarrayinterface.py +++ b/holoviews/tests/core/data/test_xarrayinterface.py @@ -1,5 +1,4 @@ import datetime as dt - from unittest import SkipTest import numpy as np @@ -10,16 +9,17 @@ except ImportError: raise SkipTest("Could not import xarray, skipping XArrayInterface tests.") -from holoviews.core.data import Dataset, concat, XArrayInterface +from holoviews.core.data import Dataset, XArrayInterface, concat from holoviews.core.dimension import Dimension from holoviews.core.spaces import HoloMap -from holoviews.element import Image, RGB, HSV, QuadMesh, ImageStack +from holoviews.element import HSV, RGB, Image, ImageStack, QuadMesh +from .test_gridinterface import BaseGridInterfaceTests from .test_imageinterface import ( - BaseImageElementInterfaceTests, BaseRGBElementInterfaceTests, - BaseHSVElementInterfaceTests + BaseHSVElementInterfaceTests, + BaseImageElementInterfaceTests, + BaseRGBElementInterfaceTests, ) -from .test_gridinterface import BaseGridInterfaceTests class XArrayInterfaceTests(BaseGridInterfaceTests): diff --git a/holoviews/tests/core/test_apply.py b/holoviews/tests/core/test_apply.py index 5457977b38..974b5a10fa 100644 --- a/holoviews/tests/core/test_apply.py +++ b/holoviews/tests/core/test_apply.py @@ -2,7 +2,6 @@ import pandas as pd import param import pytest - from panel.widgets import IntSlider, RadioButtonGroup, TextInput from holoviews import Dataset, util diff --git a/holoviews/tests/core/test_archives.py b/holoviews/tests/core/test_archives.py index 2e8b02bd7e..f8a44fc379 100644 --- a/holoviews/tests/core/test_archives.py +++ b/holoviews/tests/core/test_archives.py @@ -2,14 +2,16 @@ Unit test of the archive system, namely FileArchive with different exporters (not including renderers). """ +import json import os import shutil -import json -import zipfile import tarfile +import zipfile + import numpy as np + from holoviews import Image -from holoviews.core.io import Serializer, FileArchive +from holoviews.core.io import FileArchive, Serializer from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/core/test_boundingregion.py b/holoviews/tests/core/test_boundingregion.py index b14574ce81..6b65bf9152 100644 --- a/holoviews/tests/core/test_boundingregion.py +++ b/holoviews/tests/core/test_boundingregion.py @@ -4,7 +4,8 @@ import unittest -from holoviews.core import BoundingBox, AARectangle +from holoviews.core import AARectangle, BoundingBox + class TestAARectangle(unittest.TestCase): def setUp(self): diff --git a/holoviews/tests/core/test_callable.py b/holoviews/tests/core/test_callable.py index 8f00b5f15e..1e01d1b0eb 100644 --- a/holoviews/tests/core/test_callable.py +++ b/holoviews/tests/core/test_callable.py @@ -6,15 +6,16 @@ import param -from holoviews.element.comparison import ComparisonTestCase -from holoviews.element import Scatter from holoviews import streams -from holoviews.core.spaces import Callable, Generator, DynamicMap from holoviews.core.operation import OperationCallable +from holoviews.core.spaces import Callable, DynamicMap, Generator +from holoviews.element import Scatter +from holoviews.element.comparison import ComparisonTestCase from holoviews.operation import contours from ..utils import LoggingComparisonTestCase + class CallableClass: @staticmethod diff --git a/holoviews/tests/core/test_collation.py b/holoviews/tests/core/test_collation.py index d19adee48f..76d8e924a4 100644 --- a/holoviews/tests/core/test_collation.py +++ b/holoviews/tests/core/test_collation.py @@ -2,9 +2,10 @@ Test cases for Collator """ import itertools + import numpy as np -from holoviews.core import Collator, HoloMap, NdOverlay, Overlay, GridSpace +from holoviews.core import Collator, GridSpace, HoloMap, NdOverlay, Overlay from holoviews.element import Curve from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/core/test_composites.py b/holoviews/tests/core/test_composites.py index 305b75146c..371b9bee89 100644 --- a/holoviews/tests/core/test_composites.py +++ b/holoviews/tests/core/test_composites.py @@ -3,7 +3,7 @@ and Overlay (does *not* test HoloMaps). """ -from holoviews import Element, Layout, Overlay, HoloMap +from holoviews import Element, HoloMap, Layout, Overlay from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/core/test_datasetproperty.py b/holoviews/tests/core/test_datasetproperty.py index 6ce698feab..a8b98cace1 100644 --- a/holoviews/tests/core/test_datasetproperty.py +++ b/holoviews/tests/core/test_datasetproperty.py @@ -8,13 +8,13 @@ except ImportError: dd = None -from holoviews import Dataset, Curve, Dimension, Scatter, Distribution +from holoviews import Curve, Dataset, Dimension, Distribution, Scatter from holoviews.core import Apply, Redim from holoviews.element.comparison import ComparisonTestCase -from holoviews.operation import histogram, function +from holoviews.operation import function, histogram try: - from holoviews.operation.datashader import dynspread, datashade, rasterize + from holoviews.operation.datashader import datashade, dynspread, rasterize except ImportError: dynspread = datashade = rasterize = None diff --git a/holoviews/tests/core/test_decollation.py b/holoviews/tests/core/test_decollation.py index 9cd02c9c1e..ffc3106027 100644 --- a/holoviews/tests/core/test_decollation.py +++ b/holoviews/tests/core/test_decollation.py @@ -2,13 +2,13 @@ import param -from holoviews.core import HoloMap, NdOverlay, Overlay, GridSpace, DynamicMap +from holoviews.core import DynamicMap, GridSpace, HoloMap, NdOverlay, Overlay from holoviews.element import Points from holoviews.element.comparison import ComparisonTestCase -from holoviews.streams import Stream, PlotSize, RangeXY +from holoviews.streams import PlotSize, RangeXY, Stream try: - from holoviews.operation.datashader import spread, datashade + from holoviews.operation.datashader import datashade, spread except ImportError: spread = datashade = None diff --git a/holoviews/tests/core/test_dimensioned.py b/holoviews/tests/core/test_dimensioned.py index dbd4743bc9..90b896f2fb 100644 --- a/holoviews/tests/core/test_dimensioned.py +++ b/holoviews/tests/core/test_dimensioned.py @@ -1,8 +1,9 @@ import gc -from holoviews.core.spaces import HoloMap from holoviews.core.element import Element -from holoviews.core.options import Store, Keywords, Options, OptionTree +from holoviews.core.options import Keywords, Options, OptionTree, Store +from holoviews.core.spaces import HoloMap + from ..utils import LoggingComparisonTestCase diff --git a/holoviews/tests/core/test_dimensions.py b/holoviews/tests/core/test_dimensions.py index f6ae6bb86a..06f77066b9 100644 --- a/holoviews/tests/core/test_dimensions.py +++ b/holoviews/tests/core/test_dimensions.py @@ -1,12 +1,14 @@ """ Test cases for Dimension and Dimensioned object behaviour. """ -from holoviews.core import Dimensioned, Dimension +import numpy as np +import pandas as pd + +from holoviews.core import Dimension, Dimensioned from holoviews.element.comparison import ComparisonTestCase + from ..utils import LoggingComparisonTestCase -import numpy as np -import pandas as pd class DimensionNameLabelTest(LoggingComparisonTestCase): diff --git a/holoviews/tests/core/test_dynamic.py b/holoviews/tests/core/test_dynamic.py index 5f0bc7d6b5..b9d020865e 100644 --- a/holoviews/tests/core/test_dynamic.py +++ b/holoviews/tests/core/test_dynamic.py @@ -1,19 +1,29 @@ -import uuid import time +import uuid from collections import deque -import pytest -import param import numpy as np -from holoviews import Dimension, NdLayout, GridSpace, Layout, NdOverlay -from holoviews.core.spaces import DynamicMap, HoloMap, Callable +import param +import pytest + +from holoviews import Dimension, GridSpace, Layout, NdLayout, NdOverlay from holoviews.core.options import Store -from holoviews.element import Image, Scatter, Curve, Text, Points +from holoviews.core.spaces import Callable, DynamicMap, HoloMap +from holoviews.element import Curve, Image, Points, Scatter, Text +from holoviews.element.comparison import ComparisonTestCase from holoviews.operation import histogram from holoviews.plotting.util import initialize_dynamic -from holoviews.streams import Stream, LinkedStream, PointerXY, PointerX, PointerY, RangeX, Buffer, pointer_types +from holoviews.streams import ( + Buffer, + LinkedStream, + PointerX, + PointerXY, + PointerY, + RangeX, + Stream, + pointer_types, +) from holoviews.util import Dynamic -from holoviews.element.comparison import ComparisonTestCase from ..utils import LoggingComparisonTestCase from .test_dimensioned import CustomBackendTestCase, ExampleElement diff --git a/holoviews/tests/core/test_importexport.py b/holoviews/tests/core/test_importexport.py index 1ddd90d18b..197f43a90c 100644 --- a/holoviews/tests/core/test_importexport.py +++ b/holoviews/tests/core/test_importexport.py @@ -3,9 +3,11 @@ """ import os + import numpy as np + from holoviews import Image, Layout -from holoviews.core.io import Serializer, Pickler, Unpickler, Deserializer +from holoviews.core.io import Deserializer, Pickler, Serializer, Unpickler from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/core/test_layers.py b/holoviews/tests/core/test_layers.py index 12d2c0919c..35a21e2613 100644 --- a/holoviews/tests/core/test_layers.py +++ b/holoviews/tests/core/test_layers.py @@ -2,7 +2,8 @@ import numpy as np -from holoviews import NdOverlay, Element +from holoviews import Element, NdOverlay + class CompositeTest(unittest.TestCase): "For testing of basic composite element types" diff --git a/holoviews/tests/core/test_layouts.py b/holoviews/tests/core/test_layouts.py index a08491d0fd..8c53eb5ce8 100644 --- a/holoviews/tests/core/test_layouts.py +++ b/holoviews/tests/core/test_layouts.py @@ -1,8 +1,16 @@ """ Tests of Layout and related classes """ -from holoviews import AdjointLayout, NdLayout, GridSpace, Layout, Element, HoloMap, Overlay -from holoviews.element import HLine, Curve +from holoviews import ( + AdjointLayout, + Element, + GridSpace, + HoloMap, + Layout, + NdLayout, + Overlay, +) +from holoviews.element import Curve, HLine from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/core/test_ndmapping.py b/holoviews/tests/core/test_ndmapping.py index bf1832e3c1..767ed8bb37 100644 --- a/holoviews/tests/core/test_ndmapping.py +++ b/holoviews/tests/core/test_ndmapping.py @@ -1,14 +1,17 @@ import numpy as np +from holoviews import Dataset, HoloMap from holoviews.core import Dimension from holoviews.core.ndmapping import ( - MultiDimensionalMapping, NdMapping, UniformNdMapping + MultiDimensionalMapping, + NdMapping, + UniformNdMapping, ) from holoviews.core.overlay import Overlay from holoviews.element import Curve from holoviews.element.comparison import ComparisonTestCase -from holoviews import HoloMap, Dataset + class DimensionTest(ComparisonTestCase): diff --git a/holoviews/tests/core/test_operation.py b/holoviews/tests/core/test_operation.py index c067272118..eb1dc2bc09 100644 --- a/holoviews/tests/core/test_operation.py +++ b/holoviews/tests/core/test_operation.py @@ -3,7 +3,7 @@ from holoviews.core.operation import Operation from holoviews.element import Curve from holoviews.element.comparison import ComparisonTestCase -from holoviews.streams import Stream, Params +from holoviews.streams import Params, Stream class ExampleOperation(Operation): diff --git a/holoviews/tests/core/test_options.py b/holoviews/tests/core/test_options.py index c070262c8e..10e30ed920 100644 --- a/holoviews/tests/core/test_options.py +++ b/holoviews/tests/core/test_options.py @@ -4,12 +4,26 @@ import numpy as np import pytest -from holoviews import Store, Histogram, Image, Curve, Points, DynamicMap, opts, util +from holoviews import ( + Curve, + DynamicMap, + Histogram, + Image, + Points, + Store, + opts, + plotting, + util, +) from holoviews.core.options import ( - OptionError, Cycle, Options, OptionTree, StoreOptions, options_policy + Cycle, + OptionError, + Options, + OptionTree, + StoreOptions, + options_policy, ) from holoviews.element.comparison import ComparisonTestCase -from holoviews import plotting Options.skip_invalid = False @@ -893,9 +907,9 @@ class TestLookupOptions(ComparisonTestCase): def test_lookup_options_honors_backend(self): points = Points([[1, 2], [3, 4]]) - import holoviews.plotting.mpl import holoviews.plotting.bokeh - import holoviews.plotting.plotly # noqa + import holoviews.plotting.mpl + import holoviews.plotting.plotly # noqa backends = Store.loaded_backends() diff --git a/holoviews/tests/core/test_prettyprint.py b/holoviews/tests/core/test_prettyprint.py index 1388c571ef..5fdf8661a9 100644 --- a/holoviews/tests/core/test_prettyprint.py +++ b/holoviews/tests/core/test_prettyprint.py @@ -3,9 +3,9 @@ """ -from holoviews.element.comparison import ComparisonTestCase -from holoviews import Store, Element, Curve, Overlay, Layout +from holoviews import Curve, Element, Layout, Overlay, Store from holoviews.core.pprint import PrettyPrinter +from holoviews.element.comparison import ComparisonTestCase from .test_dimensioned import CustomBackendTestCase, ExampleElement diff --git a/holoviews/tests/core/test_storeoptions.py b/holoviews/tests/core/test_storeoptions.py index fd686b264e..29a4c67aef 100644 --- a/holoviews/tests/core/test_storeoptions.py +++ b/holoviews/tests/core/test_storeoptions.py @@ -4,11 +4,10 @@ """ import numpy as np -from holoviews.plotting import mpl # noqa Register backend - -from holoviews import Overlay, Curve, Image, HoloMap +from holoviews import Curve, HoloMap, Image, Overlay from holoviews.core.options import Store, StoreOptions from holoviews.element.comparison import ComparisonTestCase +from holoviews.plotting import mpl # noqa Register backend class TestStoreOptionsMerge(ComparisonTestCase): diff --git a/holoviews/tests/core/test_traversal.py b/holoviews/tests/core/test_traversal.py index d253bca859..a9287d3fcf 100644 --- a/holoviews/tests/core/test_traversal.py +++ b/holoviews/tests/core/test_traversal.py @@ -1,4 +1,4 @@ -from holoviews import HoloMap, DynamicMap, Curve +from holoviews import Curve, DynamicMap, HoloMap from holoviews.core.traversal import unique_dimkeys from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/core/test_utils.py b/holoviews/tests/core/test_utils.py index 962a072d9f..1aa628f275 100644 --- a/holoviews/tests/core/test_utils.py +++ b/holoviews/tests/core/test_utils.py @@ -4,21 +4,34 @@ import datetime import math import unittest - from itertools import product import numpy as np import pandas as pd +from holoviews import Dimension, Element from holoviews.core.util import ( - sanitize_identifier_fn, find_range, max_range, wrap_tuple_streams, - deephash, merge_dimensions, get_path, make_path_unique, compute_density, - date_range, dt_to_int, compute_edges, isfinite, cross_index, closest_match, - dimension_range, tree_attribute, search_indices + closest_match, + compute_density, + compute_edges, + cross_index, + date_range, + deephash, + dimension_range, + dt_to_int, + find_range, + get_path, + isfinite, + make_path_unique, + max_range, + merge_dimensions, + sanitize_identifier_fn, + search_indices, + tree_attribute, + wrap_tuple_streams, ) -from holoviews import Dimension, Element -from holoviews.streams import PointerXY from holoviews.element.comparison import ComparisonTestCase +from holoviews.streams import PointerXY sanitize_identifier = sanitize_identifier_fn.instance() diff --git a/holoviews/tests/element/test_annotations.py b/holoviews/tests/element/test_annotations.py index 3188c49b45..9731459eed 100644 --- a/holoviews/tests/element/test_annotations.py +++ b/holoviews/tests/element/test_annotations.py @@ -1,11 +1,11 @@ import numpy as np import param import pytest +from packaging.version import Version -from holoviews import HLine, VLine, Text, Arrow, Annotation, Spline -from holoviews.element.comparison import ComparisonTestCase +from holoviews import Annotation, Arrow, HLine, Spline, Text, VLine from holoviews.element import Points -from packaging.version import Version +from holoviews.element.comparison import ComparisonTestCase class AnnotationTests(ComparisonTestCase): diff --git a/holoviews/tests/element/test_comparisonchart.py b/holoviews/tests/element/test_comparisonchart.py index 261e8ad4f2..34fc3a7991 100644 --- a/holoviews/tests/element/test_comparisonchart.py +++ b/holoviews/tests/element/test_comparisonchart.py @@ -3,7 +3,8 @@ """ import numpy as np -from holoviews import Dimension, Curve, Bars, Histogram, Scatter, Points, VectorField + +from holoviews import Bars, Curve, Dimension, Histogram, Points, Scatter, VectorField from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/element/test_comparisonpath.py b/holoviews/tests/element/test_comparisonpath.py index dd3e6f7f3f..8d1c6e6cef 100644 --- a/holoviews/tests/element/test_comparisonpath.py +++ b/holoviews/tests/element/test_comparisonpath.py @@ -2,7 +2,7 @@ Test cases for the Comparisons class over the Path elements """ -from holoviews import Path, Box, Bounds, Contours, Ellipse +from holoviews import Bounds, Box, Contours, Ellipse, Path from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/element/test_comparisonraster.py b/holoviews/tests/element/test_comparisonraster.py index 0b317cd856..f78092b396 100644 --- a/holoviews/tests/element/test_comparisonraster.py +++ b/holoviews/tests/element/test_comparisonraster.py @@ -3,11 +3,10 @@ """ import numpy as np - +from holoviews import Image from holoviews.core import BoundingBox, Dimension from holoviews.core.element import HoloMap from holoviews.element.comparison import ComparisonTestCase -from holoviews import Image class RasterTestCase(ComparisonTestCase): diff --git a/holoviews/tests/element/test_comparisonsimple.py b/holoviews/tests/element/test_comparisonsimple.py index 513d930f63..9881376411 100644 --- a/holoviews/tests/element/test_comparisonsimple.py +++ b/holoviews/tests/element/test_comparisonsimple.py @@ -5,6 +5,7 @@ """ import numpy as np + from holoviews.core import BoundingBox from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/element/test_elementconstructors.py b/holoviews/tests/element/test_elementconstructors.py index f409a6fa1c..157d99d1cd 100644 --- a/holoviews/tests/element/test_elementconstructors.py +++ b/holoviews/tests/element/test_elementconstructors.py @@ -1,15 +1,38 @@ -import param import numpy as np import pandas as pd +import param from holoviews import ( - Dimension, Dataset, Element, Annotation, Curve, Path, Histogram, - HeatMap, Contours, Scatter, Points, Polygons, VectorField, Spikes, - Area, Bars, ErrorBars, BoxWhisker, Raster, Image, QuadMesh, RGB, - Graph, TriMesh, Div, Tiles + RGB, + Annotation, + Area, + Bars, + BoxWhisker, + Contours, + Curve, + Dataset, + Dimension, + Div, + Element, + ErrorBars, + Graph, + HeatMap, + Histogram, + Image, + Path, + Points, + Polygons, + QuadMesh, + Raster, + Scatter, + Spikes, + Tiles, + TriMesh, + VectorField, ) -from holoviews.element.path import BaseShape from holoviews.element.comparison import ComparisonTestCase +from holoviews.element.path import BaseShape + class ElementConstructorTest(ComparisonTestCase): """ diff --git a/holoviews/tests/element/test_elementranges.py b/holoviews/tests/element/test_elementranges.py index b2892d2618..097da28cf3 100644 --- a/holoviews/tests/element/test_elementranges.py +++ b/holoviews/tests/element/test_elementranges.py @@ -2,7 +2,7 @@ Test cases for computing ranges on elements which are not simply the (min, max) of the dimension values array. """ -from holoviews import Dimension, Histogram, ErrorBars +from holoviews import Dimension, ErrorBars, Histogram from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/element/test_elementselect.py b/holoviews/tests/element/test_elementselect.py index dbe0a13a28..448255c178 100644 --- a/holoviews/tests/element/test_elementselect.py +++ b/holoviews/tests/element/test_elementselect.py @@ -1,12 +1,14 @@ -from itertools import product import datetime as dt +from itertools import product + import numpy as np import pandas as pd from holoviews.core import HoloMap -from holoviews.element import Image, Contours, Curve +from holoviews.element import Contours, Curve, Image from holoviews.element.comparison import ComparisonTestCase + class DimensionedSelectionTest(ComparisonTestCase): def setUp(self): diff --git a/holoviews/tests/element/test_ellipsis.py b/holoviews/tests/element/test_ellipsis.py index 0346591455..b84955b836 100644 --- a/holoviews/tests/element/test_ellipsis.py +++ b/holoviews/tests/element/test_ellipsis.py @@ -2,11 +2,11 @@ Unit tests of Ellipsis (...) in __getitem__ """ import numpy as np + import holoviews as hv from holoviews.element.comparison import ComparisonTestCase - class TestEllipsisCharts(ComparisonTestCase): def test_curve_ellipsis_slice_x(self): diff --git a/holoviews/tests/element/test_graphelement.py b/holoviews/tests/element/test_graphelement.py index 0ed0f99b90..8c36431ec0 100644 --- a/holoviews/tests/element/test_graphelement.py +++ b/holoviews/tests/element/test_graphelement.py @@ -8,11 +8,10 @@ from holoviews.core.data import Dataset from holoviews.element.chart import Points -from holoviews.element.graphs import ( - Graph, Nodes, TriMesh, Chord) -from holoviews.element.sankey import Sankey from holoviews.element.comparison import ComparisonTestCase -from holoviews.element.util import connect_edges, connect_edges_pd, circular_layout +from holoviews.element.graphs import Chord, Graph, Nodes, TriMesh +from holoviews.element.sankey import Sankey +from holoviews.element.util import circular_layout, connect_edges, connect_edges_pd class GraphTests(ComparisonTestCase): diff --git a/holoviews/tests/element/test_image.py b/holoviews/tests/element/test_image.py index a84bf0d214..500862fe42 100644 --- a/holoviews/tests/element/test_image.py +++ b/holoviews/tests/element/test_image.py @@ -3,8 +3,10 @@ """ import numpy as np + import holoviews as hv -from holoviews.element import Image, Curve +from holoviews.element import Curve, Image + from ..utils import LoggingComparisonTestCase diff --git a/holoviews/tests/element/test_paths.py b/holoviews/tests/element/test_paths.py index c9e5e843c9..8674ab6e25 100644 --- a/holoviews/tests/element/test_paths.py +++ b/holoviews/tests/element/test_paths.py @@ -2,7 +2,8 @@ Unit tests of Path types. """ import numpy as np -from holoviews import Dataset, Ellipse, Box, Polygons, Path + +from holoviews import Box, Dataset, Ellipse, Path, Polygons from holoviews.core.data.interface import DataError from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/element/test_raster.py b/holoviews/tests/element/test_raster.py index 8edf0f6f4a..945bab4ec5 100644 --- a/holoviews/tests/element/test_raster.py +++ b/holoviews/tests/element/test_raster.py @@ -3,9 +3,11 @@ """ import numpy as np -from holoviews.element import Raster, Image, Curve, QuadMesh, RGB, HSV + +from holoviews.element import HSV, RGB, Curve, Image, QuadMesh, Raster from holoviews.element.comparison import ComparisonTestCase + class TestRaster(ComparisonTestCase): def setUp(self): diff --git a/holoviews/tests/element/test_selection.py b/holoviews/tests/element/test_selection.py index 54b7460524..05235b995d 100644 --- a/holoviews/tests/element/test_selection.py +++ b/holoviews/tests/element/test_selection.py @@ -11,9 +11,22 @@ from holoviews.core import NdOverlay from holoviews.core.options import Store from holoviews.element import ( - Area, BoxWhisker, Curve, Distribution, HSpan, Image, Points, - Rectangles, RGB, Scatter, Segments, Violin, VSpan, Path, - QuadMesh, Polygons + RGB, + Area, + BoxWhisker, + Curve, + Distribution, + HSpan, + Image, + Path, + Points, + Polygons, + QuadMesh, + Rectangles, + Scatter, + Segments, + Violin, + VSpan, ) from holoviews.element.comparison import ComparisonTestCase from holoviews.element.selection import spatial_select_columnar diff --git a/holoviews/tests/element/test_statselements.py b/holoviews/tests/element/test_statselements.py index d0648d9da3..38e7b5b744 100644 --- a/holoviews/tests/element/test_statselements.py +++ b/holoviews/tests/element/test_statselements.py @@ -1,13 +1,21 @@ from unittest import SkipTest import numpy as np -import holoviews as hv import pandas as pd +import holoviews as hv from holoviews.core.dimension import Dimension from holoviews.core.options import Compositor, Store -from holoviews.element import (Distribution, Bivariate, Points, Image, - Curve, Area, Contours, Polygons) +from holoviews.element import ( + Area, + Bivariate, + Contours, + Curve, + Distribution, + Image, + Points, + Polygons, +) from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/element/test_tiles.py b/holoviews/tests/element/test_tiles.py index 55d42ff764..e92cd729d6 100644 --- a/holoviews/tests/element/test_tiles.py +++ b/holoviews/tests/element/test_tiles.py @@ -1,7 +1,7 @@ import numpy as np import pandas as pd -from holoviews import Tiles +from holoviews import Tiles from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/ipython/test_displayhooks.py b/holoviews/tests/ipython/test_displayhooks.py index ba7316e8bb..086bbb9b79 100644 --- a/holoviews/tests/ipython/test_displayhooks.py +++ b/holoviews/tests/ipython/test_displayhooks.py @@ -1,5 +1,5 @@ -from holoviews import Store, Curve -from holoviews.ipython import notebook_extension, IPTestCase +from holoviews import Curve, Store +from holoviews.ipython import IPTestCase, notebook_extension class TestDisplayHooks(IPTestCase): diff --git a/holoviews/tests/ipython/test_magics.py b/holoviews/tests/ipython/test_magics.py index 808680e97d..ec7055616a 100644 --- a/holoviews/tests/ipython/test_magics.py +++ b/holoviews/tests/ipython/test_magics.py @@ -2,15 +2,18 @@ import holoviews as hv from holoviews.core.options import Store + try: from holoviews import ipython # noqa (Import test) from holoviews.ipython import IPTestCase except ImportError: raise SkipTest("Required dependencies not satisfied for testing magics") -from holoviews.operation import Compositor from pyviz_comms import CommManager +from holoviews.operation import Compositor + + class ExtensionTestCase(IPTestCase): def setUp(self): diff --git a/holoviews/tests/ipython/test_optscompleter.py b/holoviews/tests/ipython/test_optscompleter.py index e9a0409323..585fd26ef5 100644 --- a/holoviews/tests/ipython/test_optscompleter.py +++ b/holoviews/tests/ipython/test_optscompleter.py @@ -3,6 +3,7 @@ """ from unittest import SkipTest + try: from holoviews.ipython import IPTestCase from holoviews.ipython.magics import OptsCompleter diff --git a/holoviews/tests/ipython/test_parsers.py b/holoviews/tests/ipython/test_parsers.py index 23ab3ba6f6..efe145ac7e 100644 --- a/holoviews/tests/ipython/test_parsers.py +++ b/holoviews/tests/ipython/test_parsers.py @@ -1,9 +1,10 @@ """ Tests of the parsers implemented in ipython.parsers """ -from holoviews.element.comparison import ComparisonTestCase from unittest import SkipTest +from holoviews.element.comparison import ComparisonTestCase + try: import pyparsing # noqa (import test) from holoviews.util.parser import OptsSpec @@ -11,8 +12,7 @@ raise SkipTest("Required dependencies not satisfied for testing parsers") -from holoviews.core.options import Options, Cycle - +from holoviews.core.options import Cycle, Options class OptsSpecPlotOptionsTests(ComparisonTestCase): diff --git a/holoviews/tests/operation/test_datashader.py b/holoviews/tests/operation/test_datashader.py index 68a3aaa87c..f6acc419c9 100644 --- a/holoviews/tests/operation/test_datashader.py +++ b/holoviews/tests/operation/test_datashader.py @@ -1,31 +1,60 @@ import datetime as dt - from unittest import SkipTest, skipIf import numpy as np import pandas as pd import pytest +from numpy import nan +from packaging.version import Version from holoviews import ( - Dimension, Curve, Points, Image, Dataset, RGB, Path, Graph, TriMesh, - QuadMesh, NdOverlay, Contours, Spikes, Spread, Area, Rectangles, - Segments, Polygons, Nodes, DynamicMap, Overlay, ImageStack + RGB, + Area, + Contours, + Curve, + Dataset, + Dimension, + DynamicMap, + Graph, + Image, + ImageStack, + NdOverlay, + Nodes, + Overlay, + Path, + Points, + Polygons, + QuadMesh, + Rectangles, + Segments, + Spikes, + Spread, + TriMesh, ) -from holoviews.util import render -from holoviews.streams import Tap from holoviews.element.comparison import ComparisonTestCase -from numpy import nan from holoviews.operation import apply_when -from packaging.version import Version +from holoviews.streams import Tap +from holoviews.util import render try: - import datashader as ds import dask.dataframe as dd + import datashader as ds import xarray as xr + from holoviews.operation.datashader import ( - aggregate, regrid, ds_version, stack, directly_connect_edges, - shade, spread, rasterize, datashade, AggregationOperation, - inspect, inspect_points, inspect_polygons + AggregationOperation, + aggregate, + datashade, + directly_connect_edges, + ds_version, + inspect, + inspect_points, + inspect_polygons, + rasterize, + regrid, + shade, + spread, + stack, ) except ImportError: raise SkipTest('Datashader not available') diff --git a/holoviews/tests/operation/test_operation.py b/holoviews/tests/operation/test_operation.py index 2fad160331..ffabf420c4 100644 --- a/holoviews/tests/operation/test_operation.py +++ b/holoviews/tests/operation/test_operation.py @@ -1,9 +1,9 @@ import datetime as dt from unittest import skipIf -import pytest import numpy as np import pandas as pd +import pytest try: import dask.array as da @@ -15,14 +15,34 @@ except ImportError: ibis = None -from holoviews import (HoloMap, NdOverlay, NdLayout, GridSpace, Image, - Contours, Polygons, Points, Histogram, Curve, Area, - QuadMesh, Dataset, renderer) +from holoviews import ( + Area, + Contours, + Curve, + Dataset, + GridSpace, + Histogram, + HoloMap, + Image, + NdLayout, + NdOverlay, + Points, + Polygons, + QuadMesh, + renderer, +) from holoviews.core.data.grid import GridInterface from holoviews.element.comparison import ComparisonTestCase -from holoviews.operation.element import (operation, transform, threshold, - gradient, contours, histogram, - interpolate_curve, decimate) +from holoviews.operation.element import ( + contours, + decimate, + gradient, + histogram, + interpolate_curve, + operation, + threshold, + transform, +) da_skip = skipIf(da is None, "dask.array is not available") ibis_skip = skipIf(ibis is None, "ibis is not available") diff --git a/holoviews/tests/operation/test_statsoperations.py b/holoviews/tests/operation/test_statsoperations.py index 948cd6fe78..ad4e76f5ae 100644 --- a/holoviews/tests/operation/test_statsoperations.py +++ b/holoviews/tests/operation/test_statsoperations.py @@ -7,9 +7,9 @@ import numpy as np -from holoviews import Distribution, Bivariate, Area, Image, Contours, Polygons +from holoviews import Area, Bivariate, Contours, Distribution, Image, Polygons from holoviews.element.comparison import ComparisonTestCase -from holoviews.operation.stats import (univariate_kde, bivariate_kde) +from holoviews.operation.stats import bivariate_kde, univariate_kde class KDEOperationTests(ComparisonTestCase): diff --git a/holoviews/tests/operation/test_timeseriesoperations.py b/holoviews/tests/operation/test_timeseriesoperations.py index a5a704a0dd..6ed5b57e55 100644 --- a/holoviews/tests/operation/test_timeseriesoperations.py +++ b/holoviews/tests/operation/test_timeseriesoperations.py @@ -12,7 +12,7 @@ from holoviews import Curve, Scatter from holoviews.element.comparison import ComparisonTestCase -from holoviews.operation.timeseries import (rolling, resample, rolling_outlier_std) +from holoviews.operation.timeseries import resample, rolling, rolling_outlier_std class TimeseriesOperationTests(ComparisonTestCase): diff --git a/holoviews/tests/plotting/__init__.py b/holoviews/tests/plotting/__init__.py index 6ddc791827..01a9ae7414 100644 --- a/holoviews/tests/plotting/__init__.py +++ b/holoviews/tests/plotting/__init__.py @@ -1,6 +1,6 @@ from itertools import combinations -from holoviews.core.options import Store, Options +from holoviews.core.options import Options, Store def option_intersections(backend): diff --git a/holoviews/tests/plotting/bokeh/test_annotationplot.py b/holoviews/tests/plotting/bokeh/test_annotationplot.py index d435eaf152..3caee97a1c 100644 --- a/holoviews/tests/plotting/bokeh/test_annotationplot.py +++ b/holoviews/tests/plotting/bokeh/test_annotationplot.py @@ -4,15 +4,30 @@ import holoviews as hv from holoviews.element import ( - HLine, VLine, Text, Labels, Arrow, HSpan, VSpan, Slope, - HLines, VLines, HSpans, VSpans, + Arrow, + HLine, + HLines, + HSpan, + HSpans, + Labels, + Slope, + Text, + VLine, + VLines, + VSpan, + VSpans, ) from holoviews.plotting.bokeh.util import bokeh32, bokeh33 from .test_plot import TestBokehPlot, bokeh_renderer if bokeh32: - from bokeh.models import VSpan as BkVSpan, HSpan as BkHSpan, VStrip as BkVStrip, HStrip as BkHStrip + from bokeh.models import ( + HSpan as BkHSpan, + HStrip as BkHStrip, + VSpan as BkVSpan, + VStrip as BkVStrip, + ) if bokeh33: from bokeh.models.coordinates import Node diff --git a/holoviews/tests/plotting/bokeh/test_areaplot.py b/holoviews/tests/plotting/bokeh/test_areaplot.py index 06b818ec14..47e793e1fe 100644 --- a/holoviews/tests/plotting/bokeh/test_areaplot.py +++ b/holoviews/tests/plotting/bokeh/test_areaplot.py @@ -1,6 +1,7 @@ import datetime as dt -import pandas as pd + import numpy as np +import pandas as pd from holoviews.element import Area, Overlay diff --git a/holoviews/tests/plotting/bokeh/test_barplot.py b/holoviews/tests/plotting/bokeh/test_barplot.py index ccb4ec9aa7..032618bc48 100644 --- a/holoviews/tests/plotting/bokeh/test_barplot.py +++ b/holoviews/tests/plotting/bokeh/test_barplot.py @@ -1,11 +1,10 @@ import numpy as np +from bokeh.models import CategoricalColorMapper, LinearAxis, LinearColorMapper from holoviews.core.overlay import NdOverlay, Overlay from holoviews.element import Bars from holoviews.plotting.bokeh.util import property_to_dict -from bokeh.models import CategoricalColorMapper, LinearColorMapper, LinearAxis - from ..utils import ParamLogStream from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_boxwhiskerplot.py b/holoviews/tests/plotting/bokeh/test_boxwhiskerplot.py index 96274e2907..13c178aeb7 100644 --- a/holoviews/tests/plotting/bokeh/test_boxwhiskerplot.py +++ b/holoviews/tests/plotting/bokeh/test_boxwhiskerplot.py @@ -1,14 +1,13 @@ import datetime as dt import numpy as np +from bokeh.models import CategoricalColorMapper, ColumnDataSource, LinearColorMapper from holoviews.element import BoxWhisker from holoviews.plotting.bokeh.util import property_to_dict from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import ColumnDataSource, CategoricalColorMapper, LinearColorMapper - class TestBoxWhiskerPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_callbacks.py b/holoviews/tests/plotting/bokeh/test_callbacks.py index 68e868a1b7..921ac64e25 100644 --- a/holoviews/tests/plotting/bokeh/test_callbacks.py +++ b/holoviews/tests/plotting/bokeh/test_callbacks.py @@ -1,5 +1,4 @@ import datetime as dt - from collections import deque, namedtuple from unittest import SkipTest @@ -7,24 +6,39 @@ import pandas as pd import pytest import pyviz_comms as comms +from bokeh.events import Tap +from bokeh.io.doc import set_curdoc +from bokeh.models import ColumnDataSource, Plot, PolyEditTool, Range1d, Selection from holoviews.core import DynamicMap from holoviews.core.options import Store -from holoviews.element import Points, Polygons, Box, Curve, Table, Rectangles +from holoviews.element import Box, Curve, Points, Polygons, Rectangles, Table from holoviews.element.comparison import ComparisonTestCase -from holoviews.streams import ( - PointDraw, PolyDraw, PolyEdit, BoxEdit, PointerXY, PointerX, - PlotReset, Selection1D, RangeXY, PlotSize, CDSStream, SingleTap -) - -from bokeh.events import Tap -from bokeh.io.doc import set_curdoc -from bokeh.models import Range1d, Plot, ColumnDataSource, Selection, PolyEditTool from holoviews.plotting.bokeh.callbacks import ( - Callback, CDSCallback, PointDrawCallback, PolyDrawCallback, PolyEditCallback, - BoxEditCallback, PointerXCallback, TapCallback + BoxEditCallback, + Callback, + CDSCallback, + PointDrawCallback, + PointerXCallback, + PolyDrawCallback, + PolyEditCallback, + TapCallback, ) from holoviews.plotting.bokeh.renderer import BokehRenderer +from holoviews.streams import ( + BoxEdit, + CDSStream, + PlotReset, + PlotSize, + PointDraw, + PointerX, + PointerXY, + PolyDraw, + PolyEdit, + RangeXY, + Selection1D, + SingleTap, +) bokeh_server_renderer = BokehRenderer.instance(mode='server') bokeh_renderer = BokehRenderer.instance() diff --git a/holoviews/tests/plotting/bokeh/test_curveplot.py b/holoviews/tests/plotting/bokeh/test_curveplot.py index b84ffde639..5a585e55fd 100644 --- a/holoviews/tests/plotting/bokeh/test_curveplot.py +++ b/holoviews/tests/plotting/bokeh/test_curveplot.py @@ -3,19 +3,18 @@ import numpy as np import pandas as pd import pytest +from bokeh.models import FactorRange, FixedTicker -from holoviews.core import NdOverlay, HoloMap, DynamicMap -from holoviews.core.options import Cycle, Palette, AbbreviatedException +from holoviews.core import DynamicMap, HoloMap, NdOverlay +from holoviews.core.options import AbbreviatedException, Cycle, Palette from holoviews.element import Curve +from holoviews.plotting.bokeh.callbacks import Callback, PointerXCallback from holoviews.plotting.util import rgb2hex from holoviews.streams import PointerX from holoviews.util.transform import dim from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import FactorRange, FixedTicker -from holoviews.plotting.bokeh.callbacks import Callback, PointerXCallback - class TestCurvePlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_elementplot.py b/holoviews/tests/plotting/bokeh/test_elementplot.py index 4577a99c72..67541daaa9 100644 --- a/holoviews/tests/plotting/bokeh/test_elementplot.py +++ b/holoviews/tests/plotting/bokeh/test_elementplot.py @@ -1,29 +1,31 @@ import datetime as dt - from unittest import SkipTest import numpy as np +import panel as pn import pytest +from bokeh.document import Document +from bokeh.models import ( + EqHistColorMapper, + FixedTicker, + LinearColorMapper, + LogColorMapper, + LogTicker, + NumeralTickFormatter, + PrintfTickFormatter, + tools, +) +from bokeh.models.formatters import CustomJSTickFormatter -from holoviews.core import Dimension, DynamicMap, NdOverlay, HoloMap +from holoviews.core import Dimension, DynamicMap, HoloMap, NdOverlay from holoviews.core.util import dt_to_int -from holoviews.element import Curve, Image, Scatter, Labels, HeatMap -from holoviews.streams import Stream, PointDraw +from holoviews.element import Curve, HeatMap, Image, Labels, Scatter from holoviews.plotting.util import process_cmap +from holoviews.streams import PointDraw, Stream from holoviews.util import render -from .test_plot import TestBokehPlot, bokeh_renderer from ...utils import LoggingComparisonTestCase - -import panel as pn - -from bokeh.document import Document -from bokeh.models import tools -from bokeh.models import (PrintfTickFormatter, FixedTicker, - NumeralTickFormatter, LogTicker, - LinearColorMapper, LogColorMapper, EqHistColorMapper) - -from bokeh.models.formatters import CustomJSTickFormatter +from .test_plot import TestBokehPlot, bokeh_renderer class TestElementPlot(LoggingComparisonTestCase, TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_errorbarplot.py b/holoviews/tests/plotting/bokeh/test_errorbarplot.py index b108b5d751..e2a248b657 100644 --- a/holoviews/tests/plotting/bokeh/test_errorbarplot.py +++ b/holoviews/tests/plotting/bokeh/test_errorbarplot.py @@ -1,5 +1,4 @@ import numpy as np - from bokeh.models import CategoricalColorMapper, LinearColorMapper from holoviews.element import ErrorBars diff --git a/holoviews/tests/plotting/bokeh/test_geomplot.py b/holoviews/tests/plotting/bokeh/test_geomplot.py index 0022dff6d0..8b099b3b95 100644 --- a/holoviews/tests/plotting/bokeh/test_geomplot.py +++ b/holoviews/tests/plotting/bokeh/test_geomplot.py @@ -1,12 +1,11 @@ import pandas as pd +from bokeh.models import FactorRange from holoviews.core import NdOverlay from holoviews.element import Segments from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import FactorRange - class TestSegmentPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_graphplot.py b/holoviews/tests/plotting/bokeh/test_graphplot.py index f0a47df345..7ee4e01167 100644 --- a/holoviews/tests/plotting/bokeh/test_graphplot.py +++ b/holoviews/tests/plotting/bokeh/test_graphplot.py @@ -1,12 +1,11 @@ import numpy as np +from bokeh.models import EdgesAndLinkedNodes, NodesAndLinkedEdges, NodesOnly, Patches +from bokeh.models.mappers import CategoricalColorMapper, LinearColorMapper from holoviews.core.data import Dataset -from holoviews.element import Graph, Nodes, TriMesh, Chord, VLine, circular_layout -from holoviews.util.transform import dim +from holoviews.element import Chord, Graph, Nodes, TriMesh, VLine, circular_layout from holoviews.plotting.bokeh.util import property_to_dict - -from bokeh.models import (NodesAndLinkedEdges, EdgesAndLinkedNodes, NodesOnly, Patches) -from bokeh.models.mappers import CategoricalColorMapper, LinearColorMapper +from holoviews.util.transform import dim from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_gridplot.py b/holoviews/tests/plotting/bokeh/test_gridplot.py index 7cc4ec966a..572f89d838 100644 --- a/holoviews/tests/plotting/bokeh/test_gridplot.py +++ b/holoviews/tests/plotting/bokeh/test_gridplot.py @@ -1,19 +1,21 @@ import numpy as np - -from holoviews.core import (HoloMap, GridSpace, NdOverlay, Dataset, - DynamicMap, GridMatrix) +from bokeh.layouts import Column +from bokeh.models import Div, Toolbar + +from holoviews.core import ( + Dataset, + DynamicMap, + GridMatrix, + GridSpace, + HoloMap, + NdOverlay, +) from holoviews.element import Curve, Image, Points from holoviews.operation import gridmatrix from holoviews.streams import Stream from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.layouts import Column -from bokeh.models import Div - -from bokeh.models import Toolbar - - class TestGridPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_heatmapplot.py b/holoviews/tests/plotting/bokeh/test_heatmapplot.py index 593831e864..f44e69e619 100644 --- a/holoviews/tests/plotting/bokeh/test_heatmapplot.py +++ b/holoviews/tests/plotting/bokeh/test_heatmapplot.py @@ -1,9 +1,8 @@ import numpy as np - -from holoviews.element import HeatMap, Points, Image - from bokeh.models import FactorRange, HoverTool, Range1d +from holoviews.element import HeatMap, Image, Points + from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_histogramplot.py b/holoviews/tests/plotting/bokeh/test_histogramplot.py index 9273a7a0f2..995eb6ea32 100644 --- a/holoviews/tests/plotting/bokeh/test_histogramplot.py +++ b/holoviews/tests/plotting/bokeh/test_histogramplot.py @@ -1,14 +1,13 @@ import datetime as dt import numpy as np +from bokeh.models import CategoricalColorMapper, DatetimeAxis, LinearColorMapper from holoviews.core.overlay import NdOverlay -from holoviews.element import Image, Points, Dataset, Histogram +from holoviews.element import Dataset, Histogram, Image, Points from holoviews.operation import histogram from holoviews.plotting.bokeh.util import property_to_dict -from bokeh.models import DatetimeAxis, CategoricalColorMapper, LinearColorMapper - from ...utils import LoggingComparisonTestCase from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_labels.py b/holoviews/tests/plotting/bokeh/test_labels.py index ffdc2f15f1..13f421bb13 100644 --- a/holoviews/tests/plotting/bokeh/test_labels.py +++ b/holoviews/tests/plotting/bokeh/test_labels.py @@ -1,12 +1,11 @@ import numpy as np +from bokeh.models import CategoricalColorMapper, LinearColorMapper from holoviews.core.dimension import Dimension -from holoviews.element import Labels +from holoviews.core.options import Cycle from holoviews.core.spaces import HoloMap +from holoviews.element import Labels from holoviews.plotting.bokeh.util import property_to_dict -from holoviews.core.options import Cycle - -from bokeh.models import LinearColorMapper, CategoricalColorMapper from ..utils import ParamLogStream from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_layoutplot.py b/holoviews/tests/plotting/bokeh/test_layoutplot.py index bb318c8362..80f90571a0 100644 --- a/holoviews/tests/plotting/bokeh/test_layoutplot.py +++ b/holoviews/tests/plotting/bokeh/test_layoutplot.py @@ -2,24 +2,29 @@ import re import numpy as np +from bokeh.models import Div, GlyphRenderer, GridPlot, Spacer, Tabs, Title, Toolbar +from bokeh.models.layouts import TabPanel +from bokeh.plotting import figure -from holoviews.core import (HoloMap, GridSpace, Layout, Empty, Dataset, - NdOverlay, NdLayout, DynamicMap, Dimension) -from holoviews.element import Curve, Image, Points, Histogram, Scatter +from holoviews.core import ( + Dataset, + Dimension, + DynamicMap, + Empty, + GridSpace, + HoloMap, + Layout, + NdLayout, + NdOverlay, +) +from holoviews.element import Curve, Histogram, Image, Points, Scatter from holoviews.streams import Stream -from holoviews.util import render, opts +from holoviews.util import opts, render from holoviews.util.transform import dim -from bokeh.models import Div, GlyphRenderer, Tabs, Spacer, Title - from ...utils import LoggingComparisonTestCase from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models.layouts import TabPanel -from bokeh.plotting import figure -from bokeh.models import GridPlot -from bokeh.models import Toolbar - class TestLayoutPlot(LoggingComparisonTestCase, TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_links.py b/holoviews/tests/plotting/bokeh/test_links.py index 78fdb9f3cb..cb6efa25ef 100644 --- a/holoviews/tests/plotting/bokeh/test_links.py +++ b/holoviews/tests/plotting/bokeh/test_links.py @@ -1,11 +1,10 @@ import numpy as np import pytest +from bokeh.models import ColumnDataSource from holoviews.core.spaces import DynamicMap -from holoviews.element import Curve, Image, Polygons, Table, Scatter, Path, Points -from holoviews.plotting.links import (Link, RangeToolLink, DataLink) - -from bokeh.models import ColumnDataSource +from holoviews.element import Curve, Image, Path, Points, Polygons, Scatter, Table +from holoviews.plotting.links import DataLink, Link, RangeToolLink from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_multiaxis.py b/holoviews/tests/plotting/bokeh/test_multiaxis.py index 4262e11d17..540351b318 100644 --- a/holoviews/tests/plotting/bokeh/test_multiaxis.py +++ b/holoviews/tests/plotting/bokeh/test_multiaxis.py @@ -1,4 +1,5 @@ -from bokeh.models import LinearScale, LogScale, LinearAxis, LogAxis +from bokeh.models import LinearAxis, LinearScale, LogAxis, LogScale + from holoviews.element import Curve from ...utils import LoggingComparisonTestCase diff --git a/holoviews/tests/plotting/bokeh/test_overlayplot.py b/holoviews/tests/plotting/bokeh/test_overlayplot.py index 432f035c97..cee6b061ca 100644 --- a/holoviews/tests/plotting/bokeh/test_overlayplot.py +++ b/holoviews/tests/plotting/bokeh/test_overlayplot.py @@ -1,18 +1,27 @@ import numpy as np import panel as pn +from bokeh.models import FactorRange, FixedTicker, HoverTool, Range1d, Span -from holoviews.core import NdOverlay, HoloMap, DynamicMap, Overlay +from holoviews.core import DynamicMap, HoloMap, NdOverlay, Overlay from holoviews.core.options import Cycle -from holoviews.element import Bars, Box, Curve, ErrorBars, HLine, Points, Scatter, Text, VLine +from holoviews.element import ( + Bars, + Box, + Curve, + ErrorBars, + HLine, + Points, + Scatter, + Text, + VLine, +) +from holoviews.plotting.bokeh.util import property_to_dict from holoviews.streams import Stream, Tap from holoviews.util import Dynamic -from holoviews.plotting.bokeh.util import property_to_dict from ...utils import LoggingComparisonTestCase from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import FixedTicker, HoverTool, FactorRange, Span, Range1d - class TestOverlayPlot(LoggingComparisonTestCase, TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_pathplot.py b/holoviews/tests/plotting/bokeh/test_pathplot.py index a7ffb96dfc..a3adc691a9 100644 --- a/holoviews/tests/plotting/bokeh/test_pathplot.py +++ b/holoviews/tests/plotting/bokeh/test_pathplot.py @@ -2,18 +2,17 @@ import numpy as np import pandas as pd +from bokeh.models import CategoricalColorMapper, LinearColorMapper -from holoviews.core import NdOverlay, HoloMap +from holoviews.core import HoloMap, NdOverlay from holoviews.core.options import Cycle -from holoviews.element import Path, Polygons, Contours +from holoviews.element import Contours, Path, Polygons +from holoviews.plotting.bokeh.util import property_to_dict from holoviews.streams import PolyDraw from holoviews.util.transform import dim -from holoviews.plotting.bokeh.util import property_to_dict from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import LinearColorMapper, CategoricalColorMapper - class TestPathPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_plot.py b/holoviews/tests/plotting/bokeh/test_plot.py index 0b4a1d5b98..fc20bcf033 100644 --- a/holoviews/tests/plotting/bokeh/test_plot.py +++ b/holoviews/tests/plotting/bokeh/test_plot.py @@ -1,16 +1,18 @@ import numpy as np import pyviz_comms as comms - +from bokeh.models import ( + ColumnDataSource, + CustomJS, + HoverTool, + LinearColorMapper, + LogColorMapper, +) from param import concrete_descendents +from holoviews import Curve from holoviews.core.element import Element from holoviews.core.options import Store from holoviews.element.comparison import ComparisonTestCase -from holoviews import Curve - -from bokeh.models import ( - ColumnDataSource, CustomJS, LinearColorMapper, LogColorMapper, HoverTool -) from holoviews.plotting.bokeh.callbacks import Callback from holoviews.plotting.bokeh.element import ElementPlot diff --git a/holoviews/tests/plotting/bokeh/test_pointplot.py b/holoviews/tests/plotting/bokeh/test_pointplot.py index c86e9e4e3d..b4fa85c172 100644 --- a/holoviews/tests/plotting/bokeh/test_pointplot.py +++ b/holoviews/tests/plotting/bokeh/test_pointplot.py @@ -2,18 +2,16 @@ import numpy as np import pandas as pd +from bokeh.models import CategoricalColorMapper, FactorRange, LinearColorMapper, Scatter from holoviews.core import NdOverlay from holoviews.core.options import Cycle from holoviews.element import Points -from holoviews.streams import Stream from holoviews.plotting.bokeh.util import property_to_dict +from holoviews.streams import Stream -from .test_plot import TestBokehPlot, bokeh_renderer from ..utils import ParamLogStream - -from bokeh.models import FactorRange, LinearColorMapper, CategoricalColorMapper -from bokeh.models import Scatter +from .test_plot import TestBokehPlot, bokeh_renderer class TestPointPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_quadmeshplot.py b/holoviews/tests/plotting/bokeh/test_quadmeshplot.py index 626e3bcb42..81b9a467d5 100644 --- a/holoviews/tests/plotting/bokeh/test_quadmeshplot.py +++ b/holoviews/tests/plotting/bokeh/test_quadmeshplot.py @@ -1,11 +1,10 @@ import numpy as np +from bokeh.models import ColorBar -from holoviews.element import QuadMesh, Image +from holoviews.element import Image, QuadMesh from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import ColorBar - class TestQuadMeshPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/bokeh/test_radialheatmap.py b/holoviews/tests/plotting/bokeh/test_radialheatmap.py index 79ab2877f1..97a3cf4522 100644 --- a/holoviews/tests/plotting/bokeh/test_radialheatmap.py +++ b/holoviews/tests/plotting/bokeh/test_radialheatmap.py @@ -1,11 +1,10 @@ from itertools import product import numpy as np +from bokeh.models import ColorBar from holoviews.core.spaces import HoloMap from holoviews.element.raster import HeatMap - -from bokeh.models import ColorBar from holoviews.plotting.bokeh import RadialHeatMapPlot from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_rasterplot.py b/holoviews/tests/plotting/bokeh/test_rasterplot.py index 9e4282c191..a662999031 100644 --- a/holoviews/tests/plotting/bokeh/test_rasterplot.py +++ b/holoviews/tests/plotting/bokeh/test_rasterplot.py @@ -2,7 +2,7 @@ import numpy as np -from holoviews.element import Raster, Image, RGB, ImageStack +from holoviews.element import RGB, Image, ImageStack, Raster from holoviews.plotting.bokeh.raster import ImageStackPlot from .test_plot import TestBokehPlot, bokeh_renderer diff --git a/holoviews/tests/plotting/bokeh/test_renderer.py b/holoviews/tests/plotting/bokeh/test_renderer.py index 202b655e64..bf601f5c81 100644 --- a/holoviews/tests/plotting/bokeh/test_renderer.py +++ b/holoviews/tests/plotting/bokeh/test_renderer.py @@ -2,22 +2,19 @@ from unittest import SkipTest import numpy as np +import panel as pn import param - -from holoviews import DynamicMap, HoloMap, Image, GridSpace, Table, Curve -from holoviews.streams import Stream -from holoviews.plotting import Renderer -from holoviews.element.comparison import ComparisonTestCase - +from bokeh.io import curdoc +from bokeh.themes.theme import Theme +from panel.widgets import DiscreteSlider, FloatSlider, Player from pyviz_comms import CommManager -import panel as pn - -from bokeh.io import curdoc +from holoviews import Curve, DynamicMap, GridSpace, HoloMap, Image, Table +from holoviews.element.comparison import ComparisonTestCase +from holoviews.plotting import Renderer from holoviews.plotting.bokeh import BokehRenderer -from bokeh.themes.theme import Theme +from holoviews.streams import Stream -from panel.widgets import DiscreteSlider, Player, FloatSlider class BokehRendererTest(ComparisonTestCase): diff --git a/holoviews/tests/plotting/bokeh/test_sankey.py b/holoviews/tests/plotting/bokeh/test_sankey.py index a9807e10ec..4a1ea73daa 100644 --- a/holoviews/tests/plotting/bokeh/test_sankey.py +++ b/holoviews/tests/plotting/bokeh/test_sankey.py @@ -5,9 +5,9 @@ from holoviews.core.data import Dataset, Dimension from holoviews.element import Sankey - from .test_plot import TestBokehPlot, bokeh_renderer + class TestSankeyPlot(TestBokehPlot): def test_sankey_simple(self): diff --git a/holoviews/tests/plotting/bokeh/test_server.py b/holoviews/tests/plotting/bokeh/test_server.py index c8b14dce5b..a93f3eeb17 100644 --- a/holoviews/tests/plotting/bokeh/test_server.py +++ b/holoviews/tests/plotting/bokeh/test_server.py @@ -2,26 +2,22 @@ import param import pytest - -from holoviews.core.spaces import DynamicMap -from holoviews.core.options import Store -from holoviews.element import Curve, Polygons, Path, HLine -from holoviews.element.comparison import ComparisonTestCase -from holoviews.plotting import Renderer -from holoviews.streams import Stream, RangeXY, PlotReset - from bokeh.client import pull_session from bokeh.document import Document from bokeh.io.doc import curdoc, set_curdoc from bokeh.models import ColumnDataSource +from panel import serve +from panel.io.state import state +from panel.widgets import DiscreteSlider, FloatSlider -from holoviews.plotting.bokeh.callbacks import ( - Callback, RangeXYCallback, ResetCallback -) +from holoviews.core.options import Store +from holoviews.core.spaces import DynamicMap +from holoviews.element import Curve, HLine, Path, Polygons +from holoviews.element.comparison import ComparisonTestCase +from holoviews.plotting import Renderer +from holoviews.plotting.bokeh.callbacks import Callback, RangeXYCallback, ResetCallback from holoviews.plotting.bokeh.renderer import BokehRenderer -from panel.widgets import DiscreteSlider, FloatSlider -from panel.io.state import state -from panel import serve +from holoviews.streams import PlotReset, RangeXY, Stream bokeh_renderer = BokehRenderer.instance(mode='server') diff --git a/holoviews/tests/plotting/bokeh/test_spikesplot.py b/holoviews/tests/plotting/bokeh/test_spikesplot.py index 95288a800d..1d5dd835cb 100644 --- a/holoviews/tests/plotting/bokeh/test_spikesplot.py +++ b/holoviews/tests/plotting/bokeh/test_spikesplot.py @@ -1,10 +1,10 @@ import datetime as dt import numpy as np +from bokeh.models import CategoricalColorMapper, LinearColorMapper + from holoviews.core import NdOverlay from holoviews.element import Spikes - -from bokeh.models import CategoricalColorMapper, LinearColorMapper from holoviews.plotting.bokeh.util import property_to_dict from ..utils import ParamLogStream diff --git a/holoviews/tests/plotting/bokeh/test_tabular.py b/holoviews/tests/plotting/bokeh/test_tabular.py index 1857736058..d7a7a26e32 100644 --- a/holoviews/tests/plotting/bokeh/test_tabular.py +++ b/holoviews/tests/plotting/bokeh/test_tabular.py @@ -1,9 +1,15 @@ from datetime import datetime as dt from bokeh.models.widgets import ( - NumberEditor, NumberFormatter, DateFormatter, - DateEditor, StringFormatter, StringEditor, IntEditor + DateEditor, + DateFormatter, + IntEditor, + NumberEditor, + NumberFormatter, + StringEditor, + StringFormatter, ) + from holoviews.core.options import Store from holoviews.core.spaces import DynamicMap from holoviews.element import Table diff --git a/holoviews/tests/plotting/bokeh/test_tiles.py b/holoviews/tests/plotting/bokeh/test_tiles.py index 85412b9aea..a8b6a71171 100644 --- a/holoviews/tests/plotting/bokeh/test_tiles.py +++ b/holoviews/tests/plotting/bokeh/test_tiles.py @@ -4,6 +4,7 @@ from .test_plot import TestBokehPlot, bokeh_renderer + class TestTilePlot(TestBokehPlot): def test_xyzservices_tileprovider(self): diff --git a/holoviews/tests/plotting/bokeh/test_utils.py b/holoviews/tests/plotting/bokeh/test_utils.py index b585b6f32d..927ffa7101 100644 --- a/holoviews/tests/plotting/bokeh/test_utils.py +++ b/holoviews/tests/plotting/bokeh/test_utils.py @@ -3,8 +3,12 @@ import holoviews as hv from holoviews.core import Store from holoviews.element.comparison import ComparisonTestCase -from holoviews.plotting.bokeh.util import filter_batched_data, glyph_order, select_legends from holoviews.plotting.bokeh.styles import expand_batched_style +from holoviews.plotting.bokeh.util import ( + filter_batched_data, + glyph_order, + select_legends, +) bokeh_renderer = Store.renderers['bokeh'] diff --git a/holoviews/tests/plotting/bokeh/test_vectorfieldplot.py b/holoviews/tests/plotting/bokeh/test_vectorfieldplot.py index 4d100e7609..d4a71987c8 100644 --- a/holoviews/tests/plotting/bokeh/test_vectorfieldplot.py +++ b/holoviews/tests/plotting/bokeh/test_vectorfieldplot.py @@ -3,11 +3,11 @@ from holoviews.element import VectorField from holoviews.plotting.bokeh.util import property_to_dict -from .test_plot import TestBokehPlot, bokeh_renderer from ..utils import ParamLogStream +from .test_plot import TestBokehPlot, bokeh_renderer try: - from bokeh.models import LinearColorMapper, CategoricalColorMapper + from bokeh.models import CategoricalColorMapper, LinearColorMapper except ImportError: pass diff --git a/holoviews/tests/plotting/bokeh/test_violinplot.py b/holoviews/tests/plotting/bokeh/test_violinplot.py index 036be34f78..bea1ba8742 100644 --- a/holoviews/tests/plotting/bokeh/test_violinplot.py +++ b/holoviews/tests/plotting/bokeh/test_violinplot.py @@ -1,16 +1,15 @@ from unittest import SkipTest import numpy as np +from bokeh.models import CategoricalColorMapper, LinearColorMapper from holoviews.element import Violin from holoviews.operation.stats import univariate_kde -from holoviews.util.transform import dim from holoviews.plotting.bokeh.util import property_to_dict +from holoviews.util.transform import dim from .test_plot import TestBokehPlot, bokeh_renderer -from bokeh.models import LinearColorMapper, CategoricalColorMapper - class TestBokehViolinPlot(TestBokehPlot): diff --git a/holoviews/tests/plotting/matplotlib/test_annotationplot.py b/holoviews/tests/plotting/matplotlib/test_annotationplot.py index 535dc72a44..f060d7911c 100644 --- a/holoviews/tests/plotting/matplotlib/test_annotationplot.py +++ b/holoviews/tests/plotting/matplotlib/test_annotationplot.py @@ -1,5 +1,6 @@ import numpy as np -from holoviews.element import HLines, VLines, HSpans, VSpans + +from holoviews.element import HLines, HSpans, VLines, VSpans from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_areaplot.py b/holoviews/tests/plotting/matplotlib/test_areaplot.py index 86f7d5acbe..748b6a132e 100644 --- a/holoviews/tests/plotting/matplotlib/test_areaplot.py +++ b/holoviews/tests/plotting/matplotlib/test_areaplot.py @@ -1,6 +1,7 @@ -from holoviews.element import Area, Overlay -import pandas as pd import numpy as np +import pandas as pd + +from holoviews.element import Area, Overlay from ...utils import LoggingComparisonTestCase from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_callbacks.py b/holoviews/tests/plotting/matplotlib/test_callbacks.py index 7214704aba..8dbdce363f 100644 --- a/holoviews/tests/plotting/matplotlib/test_callbacks.py +++ b/holoviews/tests/plotting/matplotlib/test_callbacks.py @@ -3,9 +3,8 @@ import numpy as np from holoviews.core import DynamicMap -from holoviews.element import Points, Curve -from holoviews.streams import PointerXY, PointerX - +from holoviews.element import Curve, Points +from holoviews.streams import PointerX, PointerXY from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_curveplot.py b/holoviews/tests/plotting/matplotlib/test_curveplot.py index 919f7db786..a6500702ce 100644 --- a/holoviews/tests/plotting/matplotlib/test_curveplot.py +++ b/holoviews/tests/plotting/matplotlib/test_curveplot.py @@ -4,10 +4,10 @@ import pandas as pd import pytest +from holoviews.core.options import AbbreviatedException from holoviews.core.overlay import NdOverlay from holoviews.element import Curve from holoviews.util.transform import dim -from holoviews.core.options import AbbreviatedException from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_elementplot.py b/holoviews/tests/plotting/matplotlib/test_elementplot.py index 548f95af17..0df1e7bd9a 100644 --- a/holoviews/tests/plotting/matplotlib/test_elementplot.py +++ b/holoviews/tests/plotting/matplotlib/test_elementplot.py @@ -1,16 +1,14 @@ import numpy as np from matplotlib import style +from matplotlib.projections import PolarAxes +from matplotlib.ticker import FormatStrFormatter, FuncFormatter, PercentFormatter from holoviews.core.spaces import DynamicMap -from holoviews.element import Image, Curve, Scatter, Scatter3D, HeatMap +from holoviews.element import Curve, HeatMap, Image, Scatter, Scatter3D from holoviews.streams import Stream -from .test_plot import TestMPLPlot, mpl_renderer - -from matplotlib.ticker import FormatStrFormatter, FuncFormatter, PercentFormatter -from matplotlib.projections import PolarAxes - from ...utils import LoggingComparisonTestCase +from .test_plot import TestMPLPlot, mpl_renderer class TestElementPlot(LoggingComparisonTestCase, TestMPLPlot): diff --git a/holoviews/tests/plotting/matplotlib/test_errorbarplot.py b/holoviews/tests/plotting/matplotlib/test_errorbarplot.py index 003f57accc..0fa9d183ad 100644 --- a/holoviews/tests/plotting/matplotlib/test_errorbarplot.py +++ b/holoviews/tests/plotting/matplotlib/test_errorbarplot.py @@ -1,9 +1,9 @@ import numpy as np import pytest +from holoviews.core.options import AbbreviatedException from holoviews.core.spaces import HoloMap from holoviews.element import ErrorBars -from holoviews.core.options import AbbreviatedException from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_graphplot.py b/holoviews/tests/plotting/matplotlib/test_graphplot.py index 327754fb11..de2e6563f4 100644 --- a/holoviews/tests/plotting/matplotlib/test_graphplot.py +++ b/holoviews/tests/plotting/matplotlib/test_graphplot.py @@ -1,14 +1,13 @@ import numpy as np import pytest +from matplotlib.collections import LineCollection, PolyCollection +from packaging.version import Version from holoviews.core.data import Dataset -from holoviews.core.options import Cycle +from holoviews.core.options import AbbreviatedException, Cycle from holoviews.core.spaces import HoloMap -from holoviews.element import Graph, Nodes, TriMesh, Chord, circular_layout +from holoviews.element import Chord, Graph, Nodes, TriMesh, circular_layout from holoviews.util.transform import dim -from holoviews.core.options import AbbreviatedException -from matplotlib.collections import LineCollection, PolyCollection -from packaging.version import Version from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_hextilesplot.py b/holoviews/tests/plotting/matplotlib/test_hextilesplot.py index 32ba7f8b08..b1ad518846 100644 --- a/holoviews/tests/plotting/matplotlib/test_hextilesplot.py +++ b/holoviews/tests/plotting/matplotlib/test_hextilesplot.py @@ -2,7 +2,6 @@ from holoviews.element import HexTiles - from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_histogramplot.py b/holoviews/tests/plotting/matplotlib/test_histogramplot.py index 9165a96596..2d18b13745 100644 --- a/holoviews/tests/plotting/matplotlib/test_histogramplot.py +++ b/holoviews/tests/plotting/matplotlib/test_histogramplot.py @@ -3,11 +3,11 @@ import numpy as np import pytest +from holoviews.core.options import AbbreviatedException from holoviews.core.overlay import NdOverlay from holoviews.element import Dataset, Histogram from holoviews.operation import histogram from holoviews.plotting.util import hex2rgb -from holoviews.core.options import AbbreviatedException from ...utils import LoggingComparisonTestCase from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_labels.py b/holoviews/tests/plotting/matplotlib/test_labels.py index 4ae9c4a78f..99bf1d8072 100644 --- a/holoviews/tests/plotting/matplotlib/test_labels.py +++ b/holoviews/tests/plotting/matplotlib/test_labels.py @@ -1,9 +1,9 @@ import numpy as np from holoviews.core.dimension import Dimension +from holoviews.core.options import Cycle from holoviews.core.spaces import HoloMap from holoviews.element import Labels -from holoviews.core.options import Cycle from holoviews.plotting.util import rgb2hex from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_layoutplot.py b/holoviews/tests/plotting/matplotlib/test_layoutplot.py index 5d1362b4c1..97ed2ab410 100644 --- a/holoviews/tests/plotting/matplotlib/test_layoutplot.py +++ b/holoviews/tests/plotting/matplotlib/test_layoutplot.py @@ -1,7 +1,7 @@ import numpy as np -from holoviews.core import HoloMap, NdOverlay, DynamicMap -from holoviews.element import Image, Curve +from holoviews.core import DynamicMap, HoloMap, NdOverlay +from holoviews.element import Curve, Image from holoviews.streams import Stream from ...utils import LoggingComparisonTestCase diff --git a/holoviews/tests/plotting/matplotlib/test_overlayplot.py b/holoviews/tests/plotting/matplotlib/test_overlayplot.py index 7e0611cf91..c6638b66a6 100644 --- a/holoviews/tests/plotting/matplotlib/test_overlayplot.py +++ b/holoviews/tests/plotting/matplotlib/test_overlayplot.py @@ -1,6 +1,6 @@ import numpy as np -from holoviews.core import Overlay, NdOverlay, DynamicMap, HoloMap +from holoviews.core import DynamicMap, HoloMap, NdOverlay, Overlay from holoviews.element import Curve, Scatter from ...utils import LoggingComparisonTestCase diff --git a/holoviews/tests/plotting/matplotlib/test_pathplot.py b/holoviews/tests/plotting/matplotlib/test_pathplot.py index 1c09fcc35c..0cd750c1f3 100644 --- a/holoviews/tests/plotting/matplotlib/test_pathplot.py +++ b/holoviews/tests/plotting/matplotlib/test_pathplot.py @@ -2,9 +2,9 @@ import pytest from holoviews.core import NdOverlay -from holoviews.core.spaces import HoloMap -from holoviews.element import Polygons, Contours, Path from holoviews.core.options import AbbreviatedException +from holoviews.core.spaces import HoloMap +from holoviews.element import Contours, Path, Polygons from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_plot.py b/holoviews/tests/plotting/matplotlib/test_plot.py index 4b946f338c..666e08f6f3 100644 --- a/holoviews/tests/plotting/matplotlib/test_plot.py +++ b/holoviews/tests/plotting/matplotlib/test_plot.py @@ -1,10 +1,10 @@ import matplotlib.pyplot as plt import pyviz_comms as comms +from param import concrete_descendents from holoviews.core.options import Store from holoviews.element.comparison import ComparisonTestCase from holoviews.plotting.mpl.element import ElementPlot -from param import concrete_descendents from .. import option_intersections diff --git a/holoviews/tests/plotting/matplotlib/test_pointplot.py b/holoviews/tests/plotting/matplotlib/test_pointplot.py index b1fd15d3bb..8579ac8816 100644 --- a/holoviews/tests/plotting/matplotlib/test_pointplot.py +++ b/holoviews/tests/plotting/matplotlib/test_pointplot.py @@ -1,15 +1,15 @@ +import matplotlib.pyplot as plt import numpy as np import pytest +from holoviews.core.options import AbbreviatedException from holoviews.core.overlay import NdOverlay from holoviews.core.spaces import HoloMap from holoviews.element import Points -from holoviews.core.options import AbbreviatedException -from .test_plot import TestMPLPlot, mpl_renderer from ..utils import ParamLogStream +from .test_plot import TestMPLPlot, mpl_renderer -import matplotlib.pyplot as plt class TestPointPlot(TestMPLPlot): diff --git a/holoviews/tests/plotting/matplotlib/test_quadmeshplot.py b/holoviews/tests/plotting/matplotlib/test_quadmeshplot.py index cd0ef5da84..7a59868fc6 100644 --- a/holoviews/tests/plotting/matplotlib/test_quadmeshplot.py +++ b/holoviews/tests/plotting/matplotlib/test_quadmeshplot.py @@ -1,6 +1,6 @@ import numpy as np -from holoviews.element import QuadMesh, Image, Dataset +from holoviews.element import Dataset, Image, QuadMesh from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_rasterplot.py b/holoviews/tests/plotting/matplotlib/test_rasterplot.py index 5b68d77b41..dbbcabffaa 100644 --- a/holoviews/tests/plotting/matplotlib/test_rasterplot.py +++ b/holoviews/tests/plotting/matplotlib/test_rasterplot.py @@ -1,14 +1,13 @@ from unittest import SkipTest import numpy as np +from matplotlib.colors import ListedColormap -from holoviews.element import Raster, Image, ImageStack +from holoviews.element import Image, ImageStack, Raster from holoviews.plotting.mpl.raster import RGBPlot from .test_plot import TestMPLPlot, mpl_renderer -from matplotlib.colors import ListedColormap - class TestRasterPlot(TestMPLPlot): diff --git a/holoviews/tests/plotting/matplotlib/test_renderer.py b/holoviews/tests/plotting/matplotlib/test_renderer.py index 6017050914..07d7523ebf 100644 --- a/holoviews/tests/plotting/matplotlib/test_renderer.py +++ b/holoviews/tests/plotting/matplotlib/test_renderer.py @@ -2,22 +2,20 @@ Test cases for rendering exporters """ import subprocess - from unittest import SkipTest import numpy as np -import param import panel as pn +import param from matplotlib import style +from panel.widgets import DiscreteSlider, FloatSlider, Player +from pyviz_comms import CommManager -from holoviews import (DynamicMap, HoloMap, Image, ItemTable, - GridSpace, Table, Curve) +from holoviews import Curve, DynamicMap, GridSpace, HoloMap, Image, ItemTable, Table from holoviews.element.comparison import ComparisonTestCase -from holoviews.streams import Stream -from holoviews.plotting.mpl import MPLRenderer, CurvePlot +from holoviews.plotting.mpl import CurvePlot, MPLRenderer from holoviews.plotting.renderer import Renderer -from panel.widgets import DiscreteSlider, Player, FloatSlider -from pyviz_comms import CommManager +from holoviews.streams import Stream class MPLRendererTest(ComparisonTestCase): diff --git a/holoviews/tests/plotting/matplotlib/test_spikeplot.py b/holoviews/tests/plotting/matplotlib/test_spikeplot.py index 67b4a5436b..e8cb405035 100644 --- a/holoviews/tests/plotting/matplotlib/test_spikeplot.py +++ b/holoviews/tests/plotting/matplotlib/test_spikeplot.py @@ -1,10 +1,10 @@ import numpy as np import pytest +from holoviews.core.options import AbbreviatedException from holoviews.core.overlay import NdOverlay from holoviews.core.spaces import HoloMap from holoviews.element import Spikes -from holoviews.core.options import AbbreviatedException from ..utils import ParamLogStream from .test_plot import TestMPLPlot, mpl_renderer diff --git a/holoviews/tests/plotting/matplotlib/test_vectorfieldplot.py b/holoviews/tests/plotting/matplotlib/test_vectorfieldplot.py index 4137d63ea4..127cc3bf00 100644 --- a/holoviews/tests/plotting/matplotlib/test_vectorfieldplot.py +++ b/holoviews/tests/plotting/matplotlib/test_vectorfieldplot.py @@ -1,12 +1,12 @@ import numpy as np import pytest +from holoviews.core.options import AbbreviatedException from holoviews.core.spaces import HoloMap from holoviews.element import VectorField -from holoviews.core.options import AbbreviatedException -from .test_plot import TestMPLPlot, mpl_renderer from ..utils import ParamLogStream +from .test_plot import TestMPLPlot, mpl_renderer class TestVectorFieldPlot(TestMPLPlot): diff --git a/holoviews/tests/plotting/plotly/test_callbacks.py b/holoviews/tests/plotting/plotly/test_callbacks.py index 7b47b7b1b8..f760dca658 100644 --- a/holoviews/tests/plotting/plotly/test_callbacks.py +++ b/holoviews/tests/plotting/plotly/test_callbacks.py @@ -1,18 +1,27 @@ import uuid - from unittest import TestCase from unittest.mock import Mock import plotly.graph_objs as go from holoviews import Tiles -from holoviews.streams import ( - BoundsXY, BoundsX, BoundsY, RangeXY, RangeX, RangeY, Selection1D -) from holoviews.plotting.plotly.callbacks import ( - RangeXYCallback, RangeXCallback, RangeYCallback, - BoundsXYCallback, BoundsXCallback, BoundsYCallback, - Selection1DCallback + BoundsXCallback, + BoundsXYCallback, + BoundsYCallback, + RangeXCallback, + RangeXYCallback, + RangeYCallback, + Selection1DCallback, +) +from holoviews.streams import ( + BoundsX, + BoundsXY, + BoundsY, + RangeX, + RangeXY, + RangeY, + Selection1D, ) diff --git a/holoviews/tests/plotting/plotly/test_dash.py b/holoviews/tests/plotting/plotly/test_dash.py index 106417069d..23a46c9b26 100644 --- a/holoviews/tests/plotting/plotly/test_dash.py +++ b/holoviews/tests/plotting/plotly/test_dash.py @@ -8,17 +8,23 @@ from dash._callback_context import CallbackContext -from .test_plot import TestPlotlyPlot +from holoviews import Bounds, DynamicMap, Scatter from holoviews.plotting.plotly.dash import ( - to_dash, DashComponents, encode_store_data, decode_store_data + DashComponents, + decode_store_data, + encode_store_data, + to_dash, ) -from holoviews import Scatter, DynamicMap, Bounds from holoviews.streams import BoundsXY, RangeXY, Selection1D + +from .test_plot import TestPlotlyPlot + try: from dash_core_components import Store except ImportError: from dash.dcc import Store import plotly.io as pio + pio.templates.default = None diff --git a/holoviews/tests/plotting/plotly/test_dynamic.py b/holoviews/tests/plotting/plotly/test_dynamic.py index 7f51afe675..636349d4e1 100644 --- a/holoviews/tests/plotting/plotly/test_dynamic.py +++ b/holoviews/tests/plotting/plotly/test_dynamic.py @@ -1,16 +1,18 @@ from unittest.mock import Mock -import holoviews as hv -import panel as pn import numpy as np +import panel as pn +from bokeh.document import Document +from pyviz_comms import Comm +import holoviews as hv from holoviews.streams import ( - Stream, Selection1D, RangeXY, BoundsXY, + BoundsXY, + RangeXY, + Selection1D, + Stream, ) -from bokeh.document import Document -from pyviz_comms import Comm - from .test_plot import TestPlotlyPlot diff --git a/holoviews/tests/plotting/plotly/test_elementplot.py b/holoviews/tests/plotting/plotly/test_elementplot.py index 5f1460c6b1..a4cf58a089 100644 --- a/holoviews/tests/plotting/plotly/test_elementplot.py +++ b/holoviews/tests/plotting/plotly/test_elementplot.py @@ -4,7 +4,7 @@ import pandas as pd from holoviews.core.spaces import DynamicMap -from holoviews.element import Curve, Scatter3D, Path3D +from holoviews.element import Curve, Path3D, Scatter3D from holoviews.streams import PointerX from .test_plot import TestPlotlyPlot, plotly_renderer diff --git a/holoviews/tests/plotting/plotly/test_figuresize.py b/holoviews/tests/plotting/plotly/test_figuresize.py index 61627dd739..9c38377e1c 100644 --- a/holoviews/tests/plotting/plotly/test_figuresize.py +++ b/holoviews/tests/plotting/plotly/test_figuresize.py @@ -1,4 +1,5 @@ from holoviews.element import Points + from .test_plot import TestPlotlyPlot diff --git a/holoviews/tests/plotting/plotly/test_gridplot.py b/holoviews/tests/plotting/plotly/test_gridplot.py index 6552d5f052..6052e8c2fe 100644 --- a/holoviews/tests/plotting/plotly/test_gridplot.py +++ b/holoviews/tests/plotting/plotly/test_gridplot.py @@ -1,7 +1,7 @@ import numpy as np from holoviews.core.spaces import GridSpace -from holoviews.element import Scatter, Curve +from holoviews.element import Curve, Scatter from .test_plot import TestPlotlyPlot diff --git a/holoviews/tests/plotting/plotly/test_imagestack.py b/holoviews/tests/plotting/plotly/test_imagestack.py index 774b3c6c15..59fc83e408 100644 --- a/holoviews/tests/plotting/plotly/test_imagestack.py +++ b/holoviews/tests/plotting/plotly/test_imagestack.py @@ -1,10 +1,12 @@ from unittest import SkipTest + try: import datashader # noqa: F401 except ImportError: raise SkipTest("Test requires datashader") import numpy as np + from holoviews.element import ImageStack from holoviews.plotting.plotly import RGBPlot diff --git a/holoviews/tests/plotting/plotly/test_labelplot.py b/holoviews/tests/plotting/plotly/test_labelplot.py index 6c510001ed..ed3adff9a8 100644 --- a/holoviews/tests/plotting/plotly/test_labelplot.py +++ b/holoviews/tests/plotting/plotly/test_labelplot.py @@ -1,8 +1,8 @@ import numpy as np -from holoviews.element import Labels, Tiles from holoviews.core.options import Cycle from holoviews.core.spaces import HoloMap +from holoviews.element import Labels, Tiles from .test_plot import TestPlotlyPlot diff --git a/holoviews/tests/plotting/plotly/test_plot.py b/holoviews/tests/plotting/plotly/test_plot.py index 5b92bccf76..3a033f8848 100644 --- a/holoviews/tests/plotting/plotly/test_plot.py +++ b/holoviews/tests/plotting/plotly/test_plot.py @@ -1,7 +1,6 @@ -from param import concrete_descendents - import plotly.graph_objs as go import pyviz_comms as comms +from param import concrete_descendents from holoviews.core import Store from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/tests/plotting/plotly/test_renderer.py b/holoviews/tests/plotting/plotly/test_renderer.py index 4e674ca418..3dfce0870f 100644 --- a/holoviews/tests/plotting/plotly/test_renderer.py +++ b/holoviews/tests/plotting/plotly/test_renderer.py @@ -4,14 +4,14 @@ import panel as pn import param +from panel.widgets import DiscreteSlider, FloatSlider, Player +from pyviz_comms import CommManager -from holoviews import (DynamicMap, HoloMap, Store, Curve) +from holoviews import Curve, DynamicMap, HoloMap, Store from holoviews.element.comparison import ComparisonTestCase from holoviews.plotting.plotly import PlotlyRenderer from holoviews.plotting.renderer import Renderer from holoviews.streams import Stream -from panel.widgets import DiscreteSlider, Player, FloatSlider -from pyviz_comms import CommManager class PlotlyRendererTest(ComparisonTestCase): diff --git a/holoviews/tests/plotting/plotly/test_rgb.py b/holoviews/tests/plotting/plotly/test_rgb.py index 6480f64fdc..e6737e9bca 100644 --- a/holoviews/tests/plotting/plotly/test_rgb.py +++ b/holoviews/tests/plotting/plotly/test_rgb.py @@ -1,9 +1,9 @@ import numpy as np import PIL.Image -from holoviews.element import RGB, Tiles - import plotly.graph_objs as go +from holoviews.element import RGB, Tiles + from .test_plot import TestPlotlyPlot, plotly_renderer try: diff --git a/holoviews/tests/plotting/plotly/test_shapeplots.py b/holoviews/tests/plotting/plotly/test_shapeplots.py index 624bf206c4..f7d1b67ca7 100644 --- a/holoviews/tests/plotting/plotly/test_shapeplots.py +++ b/holoviews/tests/plotting/plotly/test_shapeplots.py @@ -1,7 +1,16 @@ +import numpy as np + from holoviews.element import ( - VLine, HLine, Bounds, Box, Rectangles, Segments, Tiles, Path + Bounds, + Box, + HLine, + Path, + Rectangles, + Segments, + Tiles, + VLine, ) -import numpy as np + from .test_plot import TestPlotlyPlot default_shape_color = '#2a3f5f' diff --git a/holoviews/tests/plotting/plotly/test_tiles.py b/holoviews/tests/plotting/plotly/test_tiles.py index 6704959a23..f6cd41cbd0 100644 --- a/holoviews/tests/plotting/plotly/test_tiles.py +++ b/holoviews/tests/plotting/plotly/test_tiles.py @@ -1,9 +1,11 @@ -from holoviews.element import RGB, Tiles, Points, Bounds -from holoviews.element.tiles import StamenTerrain, _ATTRIBUTIONS -from .test_plot import TestPlotlyPlot, plotly_renderer import numpy as np import pytest +from holoviews.element import RGB, Bounds, Points, Tiles +from holoviews.element.tiles import _ATTRIBUTIONS, StamenTerrain + +from .test_plot import TestPlotlyPlot, plotly_renderer + class TestMapboxTilesPlot(TestPlotlyPlot): def setUp(self): diff --git a/holoviews/tests/plotting/test_comms.py b/holoviews/tests/plotting/test_comms.py index 07fc4527c1..f0bd8e2cb4 100644 --- a/holoviews/tests/plotting/test_comms.py +++ b/holoviews/tests/plotting/test_comms.py @@ -1,6 +1,7 @@ -from holoviews.element.comparison import ComparisonTestCase from pyviz_comms import Comm, JupyterComm +from holoviews.element.comparison import ComparisonTestCase + class TestComm(ComparisonTestCase): diff --git a/holoviews/tests/plotting/test_plotutils.py b/holoviews/tests/plotting/test_plotutils.py index ee307090b4..af8d2d9f96 100644 --- a/holoviews/tests/plotting/test_plotutils.py +++ b/holoviews/tests/plotting/test_plotutils.py @@ -2,21 +2,37 @@ import numpy as np -from holoviews import NdOverlay, Overlay, Dimension +from holoviews import Dimension, NdOverlay, Overlay +from holoviews.core.options import Cycle, Store from holoviews.core.spaces import DynamicMap, HoloMap -from holoviews.core.options import Store, Cycle +from holoviews.element import ( + Area, + Curve, + HLine, + Image, + Path, + Points, + Scatter, + VectorField, +) from holoviews.element.comparison import ComparisonTestCase -from holoviews.element import (Image, Scatter, Curve, Points, - Area, VectorField, HLine, Path) from holoviews.operation import operation +from holoviews.plotting.bokeh import util from holoviews.plotting.util import ( - compute_overlayable_zorders, get_min_distance, process_cmap, - initialize_dynamic, split_dmap_overlay, _get_min_distance_numpy, - bokeh_palette_to_palette, mplcmap_to_palette, color_intervals, - get_range, get_axis_padding) + _get_min_distance_numpy, + bokeh_palette_to_palette, + color_intervals, + compute_overlayable_zorders, + get_axis_padding, + get_min_distance, + get_range, + initialize_dynamic, + mplcmap_to_palette, + process_cmap, + split_dmap_overlay, +) from holoviews.streams import PointerX -from holoviews.plotting.bokeh import util bokeh_renderer = Store.renderers['bokeh'] diff --git a/holoviews/tests/plotting/utils.py b/holoviews/tests/plotting/utils.py index cadc7e4239..d6e1cfd950 100644 --- a/holoviews/tests/plotting/utils.py +++ b/holoviews/tests/plotting/utils.py @@ -1,5 +1,5 @@ -from io import StringIO import logging +from io import StringIO import param diff --git a/holoviews/tests/test_annotators.py b/holoviews/tests/test_annotators.py index 5453629656..3e9a015d36 100644 --- a/holoviews/tests/test_annotators.py +++ b/holoviews/tests/test_annotators.py @@ -1,8 +1,7 @@ from holoviews import Overlay -from holoviews.annotators import annotate, PointAnnotator, PathAnnotator -from holoviews.element import Points, Path, Table +from holoviews.annotators import PathAnnotator, PointAnnotator, annotate +from holoviews.element import Path, Points, Table from holoviews.element.tiles import EsriStreet, Tiles - from holoviews.tests.plotting.bokeh.test_plot import TestBokehPlot diff --git a/holoviews/tests/test_selection.py b/holoviews/tests/test_selection.py index 65712d84ee..1cdc3fc7ba 100644 --- a/holoviews/tests/test_selection.py +++ b/holoviews/tests/test_selection.py @@ -1,14 +1,14 @@ from unittest import skip, skipIf -import holoviews as hv import pandas as pd +import holoviews as hv from holoviews.core.options import Cycle, Store from holoviews.element import ErrorBars, Points, Rectangles, Table, VSpan +from holoviews.element.comparison import ComparisonTestCase from holoviews.plotting.util import linear_gradient from holoviews.selection import link_selections from holoviews.streams import SelectionXY -from holoviews.element.comparison import ComparisonTestCase try: from holoviews.operation.datashader import datashade, dynspread diff --git a/holoviews/tests/test_streams.py b/holoviews/tests/test_streams.py index 32f81a7e33..5870d03f1b 100644 --- a/holoviews/tests/test_streams.py +++ b/holoviews/tests/test_streams.py @@ -10,9 +10,9 @@ from holoviews.core.spaces import DynamicMap from holoviews.core.util import Version -from holoviews.element import Points, Scatter, Curve, Histogram, Polygons +from holoviews.element import Curve, Histogram, Points, Polygons, Scatter from holoviews.element.comparison import ComparisonTestCase -from holoviews.streams import * # noqa (Test all available streams) +from holoviews.streams import * # noqa (Test all available streams) from holoviews.util import Dynamic, extension from holoviews.util.transform import dim diff --git a/holoviews/tests/ui/bokeh/test_callback.py b/holoviews/tests/ui/bokeh/test_callback.py index 6d3f21dffe..d29c2ebb55 100644 --- a/holoviews/tests/ui/bokeh/test_callback.py +++ b/holoviews/tests/ui/bokeh/test_callback.py @@ -10,13 +10,14 @@ pytestmark = pytest.mark.ui -from holoviews import Curve, Scatter -from holoviews.streams import BoundsXY, Lasso, RangeXY -from holoviews.plotting.bokeh import BokehRenderer -from panel.pane.holoviews import HoloViews from panel.io.server import serve +from panel.pane.holoviews import HoloViews from panel.tests.util import wait_until +from holoviews import Curve, Scatter +from holoviews.plotting.bokeh import BokehRenderer +from holoviews.streams import BoundsXY, Lasso, RangeXY + def test_box_select(page, port): hv_scatter = Scatter([1, 2, 3]).opts( diff --git a/holoviews/tests/util/test_help.py b/holoviews/tests/util/test_help.py index 583bd1756f..6a596a8e34 100644 --- a/holoviews/tests/util/test_help.py +++ b/holoviews/tests/util/test_help.py @@ -1,5 +1,6 @@ import holoviews as hv + def test_help_pattern(capsys): import holoviews.plotting.bokeh # noqa hv.help(hv.Curve, pattern='border') diff --git a/holoviews/tests/util/test_init.py b/holoviews/tests/util/test_init.py index e73212562d..b47dcb58a1 100644 --- a/holoviews/tests/util/test_init.py +++ b/holoviews/tests/util/test_init.py @@ -1,6 +1,6 @@ -from textwrap import dedent -from subprocess import check_output from shutil import which +from subprocess import check_output +from textwrap import dedent def test_no_blocklist_imports(): diff --git a/holoviews/tests/util/test_transform.py b/holoviews/tests/util/test_transform.py index 1e65f3ac8e..0af2e01430 100644 --- a/holoviews/tests/util/test_transform.py +++ b/holoviews/tests/util/test_transform.py @@ -3,18 +3,17 @@ """ import pickle import warnings - -import holoviews as hv - from unittest import skipIf import numpy as np import pandas as pd import param +import holoviews as hv + try: - import dask.dataframe as dd import dask.array as da + import dask.dataframe as dd except ImportError: da, dd = None, None diff --git a/holoviews/tests/util/test_utils.py b/holoviews/tests/util/test_utils.py index 2a502fe6f2..9438f1856c 100644 --- a/holoviews/tests/util/test_utils.py +++ b/holoviews/tests/util/test_utils.py @@ -3,16 +3,13 @@ """ from unittest import SkipTest -from holoviews import notebook_extension -from holoviews.element.comparison import ComparisonTestCase -from holoviews import Store -from holoviews.util import output, opts, OutputSettings, Options - -from holoviews.core.options import OptionTree from pyviz_comms import CommManager -from holoviews.plotting import mpl -from holoviews.plotting import bokeh +from holoviews import Store, notebook_extension +from holoviews.core.options import OptionTree +from holoviews.element.comparison import ComparisonTestCase +from holoviews.plotting import bokeh, mpl +from holoviews.util import Options, OutputSettings, opts, output BACKENDS = ['matplotlib', 'bokeh'] diff --git a/holoviews/tests/utils.py b/holoviews/tests/utils.py index a8241b94fd..c763122272 100644 --- a/holoviews/tests/utils.py +++ b/holoviews/tests/utils.py @@ -1,7 +1,8 @@ +import logging import os import sys + import param -import logging from holoviews.element.comparison import ComparisonTestCase diff --git a/holoviews/util/__init__.py b/holoviews/util/__init__.py index e7fde901d6..11d8455ef0 100644 --- a/holoviews/util/__init__.py +++ b/holoviews/util/__init__.py @@ -1,29 +1,32 @@ -import os -import sys import inspect +import os import shutil - +import sys from collections import defaultdict from inspect import Parameter, Signature -from types import FunctionType from pathlib import Path +from types import FunctionType import param from pyviz_comms import extension as _pyviz_extension from ..core import ( - Dataset, DynamicMap, HoloMap, Dimensioned, ViewableElement, - StoreOptions, Store + Dataset, + Dimensioned, + DynamicMap, + HoloMap, + Store, + StoreOptions, + ViewableElement, + util, ) +from ..core.operation import Operation, OperationCallable from ..core.options import Keywords, Options, options_policy -from ..core.operation import Operation from ..core.overlay import Overlay from ..core.util import merge_options_to_dict -from ..core.operation import OperationCallable -from ..core import util from ..operation.element import function -from ..streams import Stream, Params, streams_list_from_dict -from .settings import OutputSettings, list_formats, list_backends +from ..streams import Params, Stream, streams_list_from_dict +from .settings import OutputSettings, list_backends, list_formats Store.output_settings = OutputSettings @@ -735,6 +738,7 @@ def register_backend_callback(cls, backend, callback): def _ignore_bokeh_warnings(self): import warnings + from bokeh.util.warnings import BokehUserWarning warnings.filterwarnings("ignore", category=BokehUserWarning, message="reference already known") diff --git a/holoviews/util/_versions.py b/holoviews/util/_versions.py index fcccbce25c..3ee6d299e7 100644 --- a/holoviews/util/_versions.py +++ b/holoviews/util/_versions.py @@ -1,5 +1,5 @@ -import sys import platform +import sys __all__ = ("show_versions",) diff --git a/holoviews/util/command.py b/holoviews/util/command.py index 6751142bcc..9332466935 100755 --- a/holoviews/util/command.py +++ b/holoviews/util/command.py @@ -5,23 +5,29 @@ holoviews Conversion_Example.ipynb """ -import sys -import os import argparse +import os +import sys from argparse import RawTextHelpFormatter try: - import nbformat import nbconvert + import nbformat except ImportError: print('nbformat, nbconvert and ipython need to be installed to use the holoviews command') sys.exit() try: - from ..ipython.preprocessors import OptsMagicProcessor, OutputMagicProcessor - from ..ipython.preprocessors import StripMagicsProcessor + from ..ipython.preprocessors import ( + OptsMagicProcessor, + OutputMagicProcessor, + StripMagicsProcessor, + ) except ImportError: - from holoviews.ipython.preprocessors import OptsMagicProcessor, OutputMagicProcessor - from holoviews.ipython.preprocessors import StripMagicsProcessor + from holoviews.ipython.preprocessors import ( + OptsMagicProcessor, + OutputMagicProcessor, + StripMagicsProcessor, + ) from . import examples diff --git a/holoviews/util/parser.py b/holoviews/util/parser.py index 437289e8d6..dbdb1f519d 100644 --- a/holoviews/util/parser.py +++ b/holoviews/util/parser.py @@ -14,7 +14,7 @@ import param import pyparsing as pp -from ..core.options import Options, Cycle, Palette +from ..core.options import Cycle, Options, Palette from ..core.util import merge_option_dicts from ..operation import Compositor from .transform import dim diff --git a/holoviews/util/settings.py b/holoviews/util/settings.py index d1d807317b..05065fb24e 100644 --- a/holoviews/util/settings.py +++ b/holoviews/util/settings.py @@ -1,4 +1,5 @@ from collections import defaultdict + from ..core import Store @@ -238,7 +239,7 @@ def _generate_docstring(cls, signature=False): @classmethod def _generate_signature(cls): - from inspect import Signature, Parameter + from inspect import Parameter, Signature keywords = ['backend', 'fig', 'holomap', 'widgets', 'fps', 'max_frames', 'size', 'dpi', 'filename', 'info', 'css', 'widget_location'] return Signature([Parameter(kw, Parameter.KEYWORD_ONLY) for kw in keywords]) diff --git a/holoviews/util/transform.py b/holoviews/util/transform.py index 9204c2c65d..24a71b03cc 100644 --- a/holoviews/util/transform.py +++ b/holoviews/util/transform.py @@ -1,6 +1,5 @@ import operator import sys - from types import BuiltinFunctionType, BuiltinMethodType, FunctionType, MethodType import numpy as np diff --git a/holoviews/util/warnings.py b/holoviews/util/warnings.py index eb7cfb523e..6136ee7814 100644 --- a/holoviews/util/warnings.py +++ b/holoviews/util/warnings.py @@ -3,7 +3,6 @@ import warnings import param - from packaging.version import Version __all__ = ( diff --git a/pyproject.toml b/pyproject.toml index d1840d8561..3eee3a28e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,6 +54,7 @@ select = [ "E", "F", "FLY", + "I", "ICN", "NPY", "PIE", @@ -95,6 +96,11 @@ unfixable = [ "NPY002", # Replace legacy `np.random.rand` call with Generator ] +[tool.ruff.isort] +known-first-party = ["holoviews"] +force-wrap-aliases = true +combine-as-imports = true + [tool.codespell] ignore-words-list = "lod,nd,ndoes,reenabled,spreaded,whn" skip = "doc/generate_modules.py"