Skip to content

Commit

Permalink
Update dependencies (#6253)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Jun 5, 2024
1 parent d74dc71 commit 9cc87fe
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 109 deletions.
8 changes: 3 additions & 5 deletions doc/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ provided by the [Anaconda](https://docs.anaconda.com/anaconda/install/)
or [Miniconda](https://docs.conda.io/en/latest/miniconda.html)
scientific Python distributions:

conda install -c pyviz holoviews
conda install holoviews

This recommended installation includes the default
[Matplotlib](http://matplotlib.org) plotting library backend, the more
interactive [Bokeh](http://bokeh.pydata.org) plotting library backend,
and the [Jupyter Notebook](http://jupyter.org).
This installation includes the default [Matplotlib](http://matplotlib.org)
plotting library backend, the more interactive [Bokeh](http://bokeh.pydata.org) plotting library backend.

A similar set of packages can be installed using `pip`, if that command
is available on your system:
Expand Down
10 changes: 3 additions & 7 deletions holoviews/core/data/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ def range(cls, dataset, dimension):
else:
column = dataset.data[dimension.name]
if column.dtype.kind == 'O':
if (not isinstance(dataset.data, pd.DataFrame) or
util.pandas_version < Version('0.17.0')):
if not isinstance(dataset.data, pd.DataFrame):
column = column.sort(inplace=False)
else:
column = column.sort_values()
Expand All @@ -221,9 +220,7 @@ def range(cls, dataset, dimension):

@classmethod
def concat_fn(cls, dataframes, **kwargs):
if util.pandas_version >= Version('0.23.0'):
kwargs['sort'] = False
return pd.concat(dataframes, **kwargs)
return pd.concat(dataframes, sort=False, **kwargs)


@classmethod
Expand Down Expand Up @@ -346,8 +343,7 @@ def sort(cls, dataset, by=None, reverse=False):
by = []
cols = [dataset.get_dimension(d, strict=True).name for d in by]

if (not isinstance(dataset.data, pd.DataFrame) or
util.pandas_version < Version('0.17.0')):
if not isinstance(dataset.data, pd.DataFrame):
return dataset.data.sort(columns=cols, ascending=not reverse)
return dataset.data.sort_values(by=cols, ascending=not reverse)

Expand Down
89 changes: 29 additions & 60 deletions holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import pandas as pd
import param
from packaging.version import Version
from pandas.core.arrays.masked import BaseMaskedArray
from pandas.core.dtypes.dtypes import DatetimeTZDtype
from pandas.core.dtypes.generic import ABCExtensionArray, ABCIndex, ABCSeries

# Python 2 builtins
basestring = str
Expand All @@ -31,59 +34,22 @@
cmp = lambda a, b: (a>b)-(a<b)

get_keywords = operator.attrgetter('varkw')
generator_types = (zip, range, types.GeneratorType)
numpy_version = Version(np.__version__)
param_version = Version(param.__version__)

datetime_types = (np.datetime64, dt.datetime, dt.date, dt.time)
timedelta_types = (np.timedelta64, dt.timedelta,)
arraylike_types = (np.ndarray,)
masked_types = ()

anonymous_dimension_label = '_'

# Argspec was removed in Python 3.11
ArgSpec = namedtuple('ArgSpec', 'args varargs keywords defaults')

_NP_SIZE_LARGE = 1_000_000
_NP_SAMPLE_SIZE = 1_000_000
_PANDAS_ROWS_LARGE = 1_000_000
_PANDAS_SAMPLE_SIZE = 1_000_000

# Versions
numpy_version = Version(Version(np.__version__).base_version)
param_version = Version(param.__version__)
pandas_version = Version(pd.__version__)

NUMPY_GE_200 = numpy_version >= Version("2")

pandas_version = Version(pd.__version__)
try:
if pandas_version >= Version('1.3.0'):
from pandas.core.dtypes.dtypes import DatetimeTZDtype as DatetimeTZDtypeType
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 ABCIndexClass, ABCSeries
elif pandas_version > Version('0.20.0'):
from pandas.core.dtypes.dtypes import DatetimeTZDtypeType
from pandas.core.dtypes.generic import ABCIndexClass, ABCSeries
else:
from pandas.types.dtypes import DatetimeTZDtypeType
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
timedelta_types = timedelta_types + pandas_timedelta_types
arraylike_types = arraylike_types + (ABCSeries, ABCIndexClass)
if pandas_version > Version('0.23.0'):
from pandas.core.dtypes.generic import ABCExtensionArray
arraylike_types = arraylike_types + (ABCExtensionArray,)
if pandas_version > Version('1.0'):
from pandas.core.arrays.masked import BaseMaskedArray
masked_types = (BaseMaskedArray,)
except Exception as e:
param.main.param.warning('pandas could not register all extension types '
f'imports failed with the following error: {e}')
# Types
generator_types = (zip, range, types.GeneratorType)
pandas_datetime_types = (pd.Timestamp, DatetimeTZDtype, pd.Period)
pandas_timedelta_types = (pd.Timedelta,)
datetime_types = (np.datetime64, dt.datetime, dt.date, dt.time, *pandas_datetime_types)
timedelta_types = (np.timedelta64, dt.timedelta, *pandas_timedelta_types)
arraylike_types = (np.ndarray, ABCSeries, ABCIndex, ABCExtensionArray)
masked_types = (BaseMaskedArray,)

try:
import cftime
Expand All @@ -93,6 +59,15 @@
cftime_types = ()
_STANDARD_CALENDARS = {'standard', 'gregorian', 'proleptic_gregorian'}

anonymous_dimension_label = '_'

# Argspec was removed in Python 3.11
ArgSpec = namedtuple('ArgSpec', 'args varargs keywords defaults')

_NP_SIZE_LARGE = 1_000_000
_NP_SAMPLE_SIZE = 1_000_000
_PANDAS_ROWS_LARGE = 1_000_000
_PANDAS_SAMPLE_SIZE = 1_000_000

# To avoid pandas warning about using DataFrameGroupBy.function
# introduced in Pandas 2.1.
Expand Down Expand Up @@ -890,10 +865,7 @@ def isnat(val):
"""
if (isinstance(val, (np.datetime64, np.timedelta64)) or
(isinstance(val, np.ndarray) and val.dtype.kind == 'M')):
if numpy_version >= Version('1.13'):
return np.isnat(val)
else:
return val.view('i8') == nat_as_integer
return np.isnat(val)
elif val is pd.NaT:
return True
elif isinstance(val, pandas_datetime_types+pandas_timedelta_types):
Expand Down Expand Up @@ -928,19 +900,16 @@ def isfinite(val):
elif val.dtype.kind in 'US':
return ~pd.isna(val)
finite = np.isfinite(val)
if pandas_version >= Version('1.0.0'):
finite &= ~pd.isna(val)
finite &= ~pd.isna(val)
return finite
elif isinstance(val, datetime_types+timedelta_types):
return not isnat(val)
elif isinstance(val, (str, bytes)):
return True
finite = np.isfinite(val)
if pandas_version >= Version('1.0.0'):
if finite is pd.NA:
return False
return finite & ~pd.isna(np.asarray(val))
return finite
if finite is pd.NA:
return False
return finite & ~pd.isna(np.asarray(val))


def isdatetime(value):
Expand Down
6 changes: 2 additions & 4 deletions holoviews/operation/timeseries.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import numpy as np
import pandas as pd
import param
from packaging.version import Version

from ..core import Element, Operation
from ..core.data import PandasInterface
from ..core.util import _PANDAS_FUNC_LOOKUP, pandas_version
from ..core.util import _PANDAS_FUNC_LOOKUP
from ..element import Scatter


Expand Down Expand Up @@ -51,8 +50,7 @@ def _process_layer(self, element, key=None):
df = df.set_index(xdim).rolling(win_type=self.p.window_type,
**self._roll_kwargs())
if self.p.window_type is None:
kwargs = {'raw': True} if pandas_version >= Version('0.23.0') else {}
rolled = df.apply(self.p.function, **kwargs)
rolled = df.apply(self.p.function, raw=True)
elif self.p.function is np.mean:
rolled = df.mean()
elif self.p.function is np.sum:
Expand Down
21 changes: 10 additions & 11 deletions holoviews/plotting/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,20 @@
from bokeh.resources import CDN, INLINE
from packaging.version import Version
from panel import config
from panel.io.notebook import ipywidget, load_notebook, render_mimebundle, render_model
from panel.io.notebook import (
JupyterCommManagerBinary,
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.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 param.parameterized import bothmethod
from pyviz_comms import CommManager

from ..core import AdjointLayout, DynamicMap, HoloMap, Layout
from ..core.data import disable_pipeline
Expand Down Expand Up @@ -665,8 +664,8 @@ def load_nb(cls, inline=False, reloading=False, enable_mathjax=False):
if not ip or not hasattr(ip, 'kernel'):
return
cls.notebook_context = True
cls.comm_manager = JupyterCommManager
state._comm_manager = JupyterCommManager
cls.comm_manager = JupyterCommManagerBinary
state._comm_manager = JupyterCommManagerBinary

@classmethod
def _delete_plot(cls, plot_id):
Expand Down
13 changes: 1 addition & 12 deletions holoviews/util/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,7 @@ def categorize(values, categories, default=None):
return result


if hasattr(np, 'isin'):
isin = _maybe_map(np.isin)
else:
# for 1.4 <= numpy < 1.13; in1d() available since 1.4
def _isin(element, test_elements, assume_unique=False, invert=False):
# from 1.13's numpy.lib.arraysetops
element = np.asarray(element)
return np.in1d(element, test_elements, assume_unique=assume_unique,
invert=invert).reshape(element.shape)
isin = _maybe_map(_isin)
del _isin

isin = _maybe_map(np.isin)
digitize = _maybe_map(np.digitize)
astype = _maybe_map(np.asarray)
round_ = _maybe_map(np.round)
Expand Down
5 changes: 2 additions & 3 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ build = ["py311", "build"]
lint = ["py311", "lint"]

[dependencies]
bokeh = ">=3.1"
colorcet = "*"
numpy = ">=1.0"
packaging = "*"
Expand All @@ -35,10 +36,7 @@ param = ">=2.0,<3.0"
pip = "*"
pyviz_comms = ">=2.1"
# Recommended
bokeh = ">=3.1"
ipython = ">=5.4.0"
matplotlib-base = ">=3"
notebook = "*"
plotly = ">=4.0"

[feature.py39.dependencies]
Expand All @@ -58,6 +56,7 @@ cftime = "*"
dask-core = "*"
datashader = ">=0.11.1"
ffmpeg = "*"
ipython = ">=5.4.0"
netcdf4 = "*"
networkx = "*"
notebook = "*"
Expand Down
13 changes: 7 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ classifiers = [
"Topic :: Software Development :: Libraries",
]
dependencies = [
"param >=2.0,<3.0",
"numpy >=1.0",
"pyviz_comms >=2.1",
"panel >=1.0",
"bokeh >=3.1",
"colorcet",
"numpy >=1.21",
"packaging",
"pandas >=0.20.0",
"pandas >=1.3",
"panel >=1.0",
"param >=2.0,<3.0",
"pyviz_comms >=2.1",
]

[project.urls]
Expand All @@ -45,7 +46,7 @@ Source = "https://github.com/holoviz/holoviews"
HoloViz = "https://holoviz.org/"

[project.optional-dependencies]
recommended = ["ipython >=5.4.0", "notebook", "matplotlib >=3", "bokeh >=3.1", "plotly >=4.0"]
recommended = ["matplotlib >=3", "plotly >=4.0"]
tests = ["pytest", "pytest-rerunfailures"]

[project.scripts]
Expand Down
4 changes: 3 additions & 1 deletion scripts/conda/recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ requirements:
- {{ dep }}
{% endfor %}
{% for dep in project['optional-dependencies']['recommended'] %}
- {{ dep }}
{% if dep.startswith('matplotlib') %}
- {{ dep.replace('matplotlib', 'matplotlib-base') }}
{% endif %}
{% endfor %}

test:
Expand Down

0 comments on commit 9cc87fe

Please sign in to comment.