@@ -293,29 +293,13 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
293293
294294 # sanitize input
295295 if is_categorical_dtype (values ):
296-
297- # we are either a Series or a CategoricalIndex
298- if isinstance (values , (ABCSeries , ABCCategoricalIndex )):
299- values = values ._values
300-
301- if ordered is None :
302- ordered = values .ordered
303- if categories is None :
304- categories = values .categories
305296 values = values .get_values ()
306297
307298 elif isinstance (values , (ABCIndexClass , ABCSeries )):
308299 # we'll do inference later
309300 pass
310301
311302 else :
312-
313- # on numpy < 1.6 datetimelike get inferred to all i8 by
314- # _sanitize_array which is fine, but since factorize does this
315- # correctly no need here this is an issue because _sanitize_array
316- # also coerces np.nan to a string under certain versions of numpy
317- # as well
318- values = maybe_infer_to_datetimelike (values , convert_dates = True )
319303 if not isinstance (values , np .ndarray ):
320304 values = _convert_to_list_like (values )
321305 from pandas .core .series import _sanitize_array
@@ -334,7 +318,7 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
334318 codes , categories = factorize (values , sort = True )
335319 except TypeError :
336320 codes , categories = factorize (values , sort = False )
337- if ordered :
321+ if dtype . ordered :
338322 # raise, as we don't have a sortable data structure and so
339323 # the user should give us one by specifying categories
340324 raise TypeError ("'values' is not ordered, please "
@@ -348,7 +332,7 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
348332
349333 if dtype .categories is None :
350334 # we're inferring from values
351- dtype = CategoricalDtype (categories , ordered )
335+ dtype = CategoricalDtype (categories , dtype . ordered )
352336
353337 else :
354338 codes = _get_codes_for_values (values , dtype .categories )
0 commit comments