Skip to content

Commit 97815dd

Browse files
committed
many things
1 parent c412f99 commit 97815dd

File tree

6 files changed

+47
-37
lines changed

6 files changed

+47
-37
lines changed

doc/source/install.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ pandas-gbq 0.8.0 Google Big Query access
279279
psycopg2 PostgreSQL engine for sqlalchemy
280280
pyarrow 0.9.0 Parquet and feather reading / writing
281281
pymysql MySQL engine for sqlalchemy
282+
pytables 3.4.2 HDF5 reading / writing
282283
qtpy Clipboard I/O
283284
s3fs 0.0.8 Amazon S3 access
284285
xarray 0.8.2 pandas-like API for N-dimensional data

pandas/compat/_optional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"openpyxl": "2.4.0",
1616
"pandas_gbq": "0.8.0",
1717
"pyarrow": "0.9.0",
18-
"pytables": "3.4.2",
18+
"tables": "3.4.2",
1919
"s3fs": "0.0.8",
2020
"scipy": "0.19.0",
2121
"sqlalchemy": "1.1.4",

pandas/io/pytables.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
from pandas._libs import lib, writers as libwriters
2121
from pandas._libs.tslibs import timezones
22+
from pandas.compat._optional import import_optional_dependency
2223
from pandas.errors import PerformanceWarning
2324

2425
from pandas.core.dtypes.common import (
@@ -448,11 +449,7 @@ def __init__(self, path, mode=None, complevel=None, complib=None,
448449
if 'format' in kwargs:
449450
raise ValueError('format is not a defined argument for HDFStore')
450451

451-
try:
452-
import tables # noqa
453-
except ImportError as ex: # pragma: no cover
454-
raise ImportError('HDFStore requires PyTables, "{ex!s}" problem '
455-
'importing'.format(ex=ex))
452+
tables = import_optional_dependency("tables")
456453

457454
if complib is not None and complib not in tables.filters.all_complibs:
458455
raise ValueError(

pandas/tests/test_optional_dependency.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import pytest
55

66
from pandas.compat._optional import VERSIONS, import_optional_dependency
7+
import pandas.util._test_decorators as td
78

9+
import pandas as pd
810
import pandas.util.testing as tm
911

1012

@@ -50,3 +52,11 @@ def test_no_version_raises():
5052

5153
with pytest.raises(ImportError, match="Can't determine .* fakemodule"):
5254
import_optional_dependency(name)
55+
56+
57+
@td.skip_if_installed("tables")
58+
def test_pytables_raises():
59+
df = pd.DataFrame({"A": [1, 2]})
60+
with pytest.raises(ImportError, match="tables"):
61+
with tm.ensure_clean("foo.h5") as path:
62+
df.to_hdf(path, "df")

pandas/util/_print_versions.py

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import subprocess
77
import sys
88

9-
from pandas.compat._optional import _get_version, import_optional_dependency
9+
from pandas.compat._optional import (
10+
VERSIONS, _get_version, import_optional_dependency)
1011

1112

1213
def get_sys_info():
@@ -59,45 +60,35 @@ def get_sys_info():
5960

6061
def show_versions(as_json=False):
6162
sys_info = get_sys_info()
62-
63-
deps = [
64-
"pandas",
65-
"pytest",
66-
"pip",
67-
"setuptools",
68-
"Cython",
69-
"numpy",
70-
"scipy",
71-
"pyarrow",
72-
"xarray",
73-
"IPython",
63+
deps = list(VERSIONS)
64+
deps.extend([
65+
'pandas',
66+
# required
67+
'numpy',
68+
'pytz',
69+
'dateutil',
70+
# install / build,
71+
'pip',
72+
'setuptools',
73+
'Cython',
74+
# test
75+
'pytest',
76+
'hypothesis',
77+
# docs
7478
"sphinx",
75-
"patsy",
76-
"dateutil",
77-
"pytz",
79+
# Other, need a min version
7880
"blosc",
79-
"bottleneck",
80-
"tables",
81-
"numexpr",
8281
"feather",
83-
"matplotlib",
84-
"openpyxl",
85-
"xlrd",
86-
"xlwt",
8782
"xlsxwriter",
8883
"lxml.etree",
89-
"bs4",
9084
"html5lib",
91-
"sqlalchemy",
9285
"pymysql",
9386
"psycopg2",
9487
"jinja2",
95-
"s3fs",
96-
"fastparquet",
97-
"pandas_gbq",
88+
# Other, not imported.
89+
"IPython",
9890
"pandas_datareader",
99-
"gcsfs",
100-
]
91+
])
10192

10293
deps_blob = list()
10394
for modname in deps:

pandas/util/_test_decorators.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ def test_foo():
2626
import locale
2727
from typing import Optional
2828

29-
from _pytest.mark.structures import MarkDecorator
3029
import pytest
3130

3231
from pandas.compat import is_platform_32bit, is_platform_windows
3332
from pandas.compat.numpy import _np_version_under1p15
3433

34+
from _pytest.mark.structures import MarkDecorator
3535
from pandas.core.computation.expressions import (
3636
_NUMEXPR_INSTALLED, _USE_NUMEXPR)
3737

@@ -140,6 +140,17 @@ def skip_if_no(
140140
)
141141

142142

143+
def skip_if_installed(
144+
package: str,
145+
min_version: Optional[str] = None
146+
) -> MarkDecorator:
147+
"""Skip if a package *is* present."""
148+
msg = "Skipping because {} is installed.".format(package)
149+
return pytest.mark.skipif(
150+
safe_import(package, min_version=min_version), reason=msg
151+
)
152+
153+
143154
skip_if_no_mpl = pytest.mark.skipif(_skip_if_no_mpl(),
144155
reason="Missing matplotlib dependency")
145156
skip_if_np_lt_115 = pytest.mark.skipif(_np_version_under1p15,

0 commit comments

Comments
 (0)