@@ -293,7 +293,7 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
293
293
# coerce to the object dtype
294
294
data = data .astype (object )
295
295
return Index (data , dtype = object , copy = copy , name = name ,
296
- ** kwargs )
296
+ tolerance = tolerance , ** kwargs )
297
297
298
298
# index-like
299
299
elif isinstance (data , (np .ndarray , Index , ABCSeries )):
@@ -306,7 +306,8 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
306
306
dtype = dtype , tolerance = tolerance ,
307
307
** kwargs )
308
308
if dtype is not None and is_dtype_equal (_o_dtype , dtype ):
309
- return Index (result .to_pydatetime (), dtype = _o_dtype )
309
+ return Index (result .to_pydatetime (), dtype = _o_dtype ,
310
+ tolerance = tolerance )
310
311
else :
311
312
return result
312
313
@@ -316,7 +317,8 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
316
317
result = TimedeltaIndex (data , copy = copy , name = name ,
317
318
tolerance = tolerance , ** kwargs )
318
319
if dtype is not None and _o_dtype == dtype :
319
- return Index (result .to_pytimedelta (), dtype = _o_dtype )
320
+ return Index (result .to_pytimedelta (), dtype = _o_dtype ,
321
+ tolerance = tolerance )
320
322
else :
321
323
return result
322
324
@@ -468,7 +470,8 @@ def __new__(cls, data=None, dtype=None, copy=False, name=None,
468
470
# 10697
469
471
from .multi import MultiIndex
470
472
return MultiIndex .from_tuples (
471
- data , names = name or kwargs .get ('names' ))
473
+ data , names = name or kwargs .get ('names' ),
474
+ tolerance = tolerance )
472
475
# other iterable of some kind
473
476
subarr = com .asarray_tuplesafe (data , dtype = object )
474
477
return Index (subarr , dtype = dtype , copy = copy , name = name ,
@@ -1925,6 +1928,7 @@ def __setstate__(self, state):
1925
1928
1926
1929
if isinstance (state , dict ):
1927
1930
self ._data = state .pop ('data' )
1931
+ self .tolerance = state .pop ('tolerance' , None )
1928
1932
for k , v in compat .iteritems (state ):
1929
1933
setattr (self , k , v )
1930
1934
@@ -1940,6 +1944,7 @@ def __setstate__(self, state):
1940
1944
data = np .empty (state )
1941
1945
np .ndarray .__setstate__ (data , state )
1942
1946
1947
+ self .tolerance = None
1943
1948
self ._data = data
1944
1949
self ._reset_identity ()
1945
1950
else :
@@ -2430,6 +2435,10 @@ def identical(self, other):
2430
2435
"""Similar to equals, but check that other comparable attributes are
2431
2436
also equal
2432
2437
"""
2438
+ # FIXME: Should two indexes with different tolerances but are
2439
+ # otherwise identical be considered identical?
2440
+ # FIXME: Should this equality check take into account tolerances,
2441
+ # or should it be forced to be strict (tolerance=0)?
2433
2442
return (self .equals (other ) and
2434
2443
all ((getattr (self , c , None ) == getattr (other , c , None )
2435
2444
for c in self ._comparables )) and
@@ -4563,7 +4572,7 @@ def unique(self, level=None):
4563
4572
if level is not None :
4564
4573
self ._validate_index_level (level )
4565
4574
result = super (Index , self ).unique ()
4566
- return self ._shallow_copy (result )
4575
+ return self ._shallow_copy (result , tolerance = self . tolerance )
4567
4576
4568
4577
def drop_duplicates (self , keep = 'first' ):
4569
4578
"""
0 commit comments