Skip to content

Commit 02c659d

Browse files
committed
deprivatize
1 parent 9b7af91 commit 02c659d

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

pandas/core/arrays/categorical.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
294294

295295
if fastpath:
296296
self._codes = coerce_indexer_dtype(values, categories)
297-
self._dtype = self._dtype._update_dtype(dtype)
297+
self._dtype = self._dtype.update_dtype(dtype)
298298
return
299299

300300
# null_mask indicates missing values we want to exclude from inference.
@@ -358,7 +358,7 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
358358
full_codes[~null_mask] = codes
359359
codes = full_codes
360360

361-
self._dtype = self._dtype._update_dtype(dtype)
361+
self._dtype = self._dtype.update_dtype(dtype)
362362
self._codes = coerce_indexer_dtype(codes, dtype.categories)
363363

364364
@property
@@ -438,7 +438,7 @@ def astype(self, dtype, copy=True):
438438
"""
439439
if is_categorical_dtype(dtype):
440440
# GH 10696/18593
441-
dtype = self.dtype._update_dtype(dtype)
441+
dtype = self.dtype.update_dtype(dtype)
442442
self = self.copy() if copy else self
443443
if dtype == self.dtype:
444444
return self
@@ -560,7 +560,7 @@ def from_codes(cls, codes, categories, ordered=False):
560560
raise ValueError(
561561
"codes need to be convertible to an arrays of integers")
562562

563-
categories = CategoricalDtype._validate_categories(categories)
563+
categories = CategoricalDtype.validate_categories(categories)
564564

565565
if len(codes) and (codes.max() >= len(categories) or codes.min() < -1):
566566
raise ValueError("codes need to be between -1 and "
@@ -1165,7 +1165,7 @@ def __setstate__(self, state):
11651165

11661166
# Provide compatibility with pre-0.15.0 Categoricals.
11671167
if '_categories' not in state and '_levels' in state:
1168-
state['_categories'] = self.dtype._validate_categories(state.pop(
1168+
state['_categories'] = self.dtype.validate_categories(state.pop(
11691169
'_levels'))
11701170
if '_codes' not in state and 'labels' in state:
11711171
state['_codes'] = coerce_indexer_dtype(

pandas/core/dtypes/dtypes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ def _from_categorical_dtype(cls, dtype, categories=None, ordered=None):
181181
def _finalize(self, categories, ordered, fastpath=False):
182182

183183
if ordered is not None:
184-
self._validate_ordered(ordered)
184+
self.validate_ordered(ordered)
185185

186186
if categories is not None:
187-
categories = self._validate_categories(categories,
188-
fastpath=fastpath)
187+
categories = self.validate_categories(categories,
188+
fastpath=fastpath)
189189

190190
self._categories = categories
191191
self._ordered = ordered
@@ -286,7 +286,7 @@ def construct_from_string(cls, string):
286286
raise TypeError("cannot construct a CategoricalDtype")
287287

288288
@staticmethod
289-
def _validate_ordered(ordered):
289+
def validate_ordered(ordered):
290290
"""
291291
Validates that we have a valid ordered parameter. If
292292
it is not a boolean, a TypeError will be raised.
@@ -306,7 +306,7 @@ def _validate_ordered(ordered):
306306
raise TypeError("'ordered' must either be 'True' or 'False'")
307307

308308
@staticmethod
309-
def _validate_categories(categories, fastpath=False):
309+
def validate_categories(categories, fastpath=False):
310310
"""
311311
Validates that we have good categories
312312
@@ -338,7 +338,7 @@ def _validate_categories(categories, fastpath=False):
338338

339339
return categories
340340

341-
def _update_dtype(self, dtype):
341+
def update_dtype(self, dtype):
342342
"""
343343
Returns a CategoricalDtype with categories and ordered taken from dtype
344344
if specified, otherwise falling back to self if unspecified

pandas/core/indexes/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def astype(self, dtype, copy=True):
344344
return IntervalIndex(np.array(self))
345345
elif is_categorical_dtype(dtype):
346346
# GH 18630
347-
dtype = self.dtype._update_dtype(dtype)
347+
dtype = self.dtype.update_dtype(dtype)
348348
if dtype == self.dtype:
349349
return self.copy() if copy else self
350350

pandas/tests/dtypes/test_dtypes.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -739,15 +739,15 @@ def test_update_dtype(self, ordered, new_categories, new_ordered):
739739
if expected_ordered is None:
740740
expected_ordered = dtype.ordered
741741

742-
result = dtype._update_dtype(new_dtype)
742+
result = dtype.update_dtype(new_dtype)
743743
tm.assert_index_equal(result.categories, expected_categories)
744744
assert result.ordered is expected_ordered
745745

746746
def test_update_dtype_string(self, ordered):
747747
dtype = CategoricalDtype(list('abc'), ordered)
748748
expected_categories = dtype.categories
749749
expected_ordered = dtype.ordered
750-
result = dtype._update_dtype('category')
750+
result = dtype.update_dtype('category')
751751
tm.assert_index_equal(result.categories, expected_categories)
752752
assert result.ordered is expected_ordered
753753

@@ -757,7 +757,7 @@ def test_update_dtype_errors(self, bad_dtype):
757757
dtype = CategoricalDtype(list('abc'), False)
758758
msg = 'a CategoricalDtype must be passed to perform an update, '
759759
with tm.assert_raises_regex(ValueError, msg):
760-
dtype._update_dtype(bad_dtype)
760+
dtype.update_dtype(bad_dtype)
761761

762762

763763
class DummyArray(ExtensionArray):

0 commit comments

Comments
 (0)