Skip to content

Commit 3ba68a7

Browse files
authored
TST: don't catch, but supress warnings in panel4d/panelnd (pandas-dev#15705)
1 parent b69c877 commit 3ba68a7

File tree

7 files changed

+210
-235
lines changed

7 files changed

+210
-235
lines changed

pandas/core/categorical.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,8 @@ def _validate_categories(cls, categories, fastpath=False):
550550
# we don't allow NaNs in the categories themselves
551551

552552
if categories.hasnans:
553-
# NaNs in cats deprecated in 0.17,
554-
# remove in 0.18 or 0.19 GH 10748
553+
# NaNs in cats deprecated in 0.17
554+
# GH 10748
555555
msg = ('\nSetting NaNs in `categories` is deprecated and '
556556
'will be removed in a future version of pandas.')
557557
warn(msg, FutureWarning, stacklevel=3)

pandas/io/pytables.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -2094,7 +2094,17 @@ def convert(self, values, nan_rep, encoding):
20942094

20952095
# we have a categorical
20962096
categories = self.metadata
2097-
self.data = Categorical.from_codes(self.data.ravel(),
2097+
codes = self.data.ravel()
2098+
2099+
# if we have stored a NaN in the categories
2100+
# then strip it; in theory we could have BOTH
2101+
# -1s in the codes and nulls :<
2102+
mask = isnull(categories)
2103+
if mask.any():
2104+
categories = categories[~mask]
2105+
codes[codes != -1] -= mask.astype(int).cumsum().values
2106+
2107+
self.data = Categorical.from_codes(codes,
20982108
categories=categories,
20992109
ordered=self.ordered)
21002110

@@ -3404,10 +3414,12 @@ def create_axes(self, axes, obj, validate=True, nan_rep=None,
34043414
if existing_table is not None:
34053415
indexer = len(self.non_index_axes)
34063416
exist_axis = existing_table.non_index_axes[indexer][1]
3407-
if append_axis != exist_axis:
3417+
if not array_equivalent(np.array(append_axis),
3418+
np.array(exist_axis)):
34083419

34093420
# ahah! -> reindex
3410-
if sorted(append_axis) == sorted(exist_axis):
3421+
if array_equivalent(np.array(sorted(append_axis)),
3422+
np.array(sorted(exist_axis))):
34113423
append_axis = exist_axis
34123424

34133425
# the non_index_axes info

0 commit comments

Comments
 (0)