Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting of imports #5937

Merged
merged 2 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion holoviews/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
17 changes: 10 additions & 7 deletions holoviews/annotators.py
Original file line number Diff line number Diff line change
@@ -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=[]):
Expand Down
4 changes: 2 additions & 2 deletions holoviews/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
18 changes: 10 additions & 8 deletions holoviews/core/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
import copy
import sys

from functools import wraps
from types import FunctionType

Expand All @@ -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]

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion holoviews/core/boundingregion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
44 changes: 23 additions & 21 deletions holoviews/core/data/__init__.py
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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])}
Expand Down
4 changes: 2 additions & 2 deletions holoviews/core/data/array.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
1 change: 0 additions & 1 deletion holoviews/core/data/cudf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import sys
import warnings

from itertools import product

import numpy as np
Expand Down
5 changes: 2 additions & 3 deletions holoviews/core/data/dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 4 additions & 5 deletions holoviews/core/data/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 3 additions & 2 deletions holoviews/core/data/ibis.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
8 changes: 4 additions & 4 deletions holoviews/core/data/image.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
4 changes: 2 additions & 2 deletions holoviews/core/data/interface.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import sys
import warnings

import param
import numpy as np
import param

from .. import util
from ..element import Element
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions holoviews/core/data/multipath.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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}
Expand Down Expand Up @@ -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:
Expand Down
9 changes: 4 additions & 5 deletions holoviews/core/data/pandas.py
Original file line number Diff line number Diff line change
@@ -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


Expand Down
Loading