Skip to content

Commit

Permalink
Change matplotlib as an optional dependency (#2029)
Browse files Browse the repository at this point in the history
This PR proposes to change matplotlib as an optional dependency.

```python
>>> from databricks import koalas as ks
>>> ks.range(100).plot.bar()
Traceback (most recent call last):
  ...
ImportError: matplotlib is required for plotting when the default backend 'matplotlib' is selected.
```

Resolves #issues
  • Loading branch information
HyukjinKwon authored Feb 2, 2021
1 parent 060fee3 commit 5e28195
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 10 deletions.
5 changes: 2 additions & 3 deletions databricks/koalas/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
TYPE_CHECKING,
)

import matplotlib
import numpy as np
import pandas as pd
from pandas.api.types import is_list_like, is_dict_like, is_scalar
Expand Down Expand Up @@ -858,12 +857,12 @@ def add(self, other) -> "DataFrame":
# create accessor for Koalas specific methods.
koalas = CachedAccessor("koalas", KoalasFrameMethods)

def hist(self, bins=10, **kwds) -> matplotlib.axes.Axes:
def hist(self, bins=10, **kwds):
return self.plot.hist(bins, **kwds)

hist.__doc__ = KoalasPlotAccessor.hist.__doc__

def kde(self, bw_method=None, ind=None, **kwds) -> matplotlib.axes.Axes:
def kde(self, bw_method=None, ind=None, **kwds):
return self.plot.kde(bw_method, ind, **kwds)

kde.__doc__ = KoalasPlotAccessor.kde.__doc__
Expand Down
1 change: 0 additions & 1 deletion databricks/koalas/plot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@
# limitations under the License.
#
from databricks.koalas.plot.core import * # noqa: F401
from databricks.koalas.plot.matplotlib import * # noqa: F401
3 changes: 1 addition & 2 deletions databricks/koalas/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from itertools import chain
from typing import Any, Generic, Iterable, List, Optional, Tuple, TypeVar, Union, cast

import matplotlib
import numpy as np
import pandas as pd
from pandas.core.accessor import CachedAccessor
Expand Down Expand Up @@ -3004,7 +3003,7 @@ def sample(

sample.__doc__ = DataFrame.sample.__doc__

def hist(self, bins=10, **kwds) -> matplotlib.axes.Axes:
def hist(self, bins=10, **kwds):
return self.plot.hist(bins, **kwds)

hist.__doc__ = KoalasPlotAccessor.hist.__doc__
Expand Down
2 changes: 1 addition & 1 deletion docs/source/getting_started/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ Package Required version
`pandas` >=0.23.2
`pyspark` >=2.4.0
`pyarrow` >=0.10
`matplotlib` >=3.0.0,<3.3.0
`numpy` >=1.14
============= ================

Expand All @@ -137,4 +136,5 @@ Package Required version
============= ================
`mlflow` >=1.0
`plotly` >=4.8
`matplotlib` >=3.0.0,<3.3.0
============= ================
2 changes: 1 addition & 1 deletion postBuild
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

# Install PySpark manually because it does not exist in requirement file.
# This file is used in Binder integration.
pip install 'pyspark>=2.4'
pip install 'pyspark>=2.4' 'matplotlib>=3.0.0,<3.3.0' 'plotly>=4.8'
echo "export PYARROW_IGNORE_TIMEZONE=1" >> ~/.profile
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Dependencies in Koalas. When you update don't forget to update setup.py and install.rst in docs.
pandas>=0.23.2,<1.2.0
pyarrow>=0.10
matplotlib>=3.0.0,<3.3.0
numpy>=1.14,<1.20.0

# Optional dependencies in Koalas.
mlflow>=1.0
plotly>=4.8
matplotlib>=3.0.0,<3.3.0

# Documentation build.
sphinx>=2.0.0,<3.1.0
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@
'spark': ['pyspark>=2.4.0'],
'mlflow': ['mlflow>=1.0'],
'plotly': ['plotly>=4.8'],
'matplotlib': ['matplotlib>=3.0.0,<3.3.0'],
},
python_requires='>=3.5,<3.9',
install_requires=[
'pandas>=0.23.2,<1.2.0',
'pyarrow>=0.10',
'numpy>=1.14,<1.20.0',
'matplotlib>=3.0.0,<3.3.0',
],
author="Databricks",
author_email="[email protected]",
Expand Down

0 comments on commit 5e28195

Please sign in to comment.