8
8
import numpy as np
9
9
import pytest
10
10
11
- import pandas ._config .config as cf
12
-
13
11
from pandas ._libs .tslib import Timestamp
14
12
from pandas .compat .numpy import np_datetime64_compat
15
13
from pandas .util ._test_decorators import async_mark
@@ -1907,115 +1905,6 @@ def test_dt_conversion_preserves_name(self, dt_conv):
1907
1905
index = Index (["01:02:03" , "01:02:04" ], name = "label" )
1908
1906
assert index .name == dt_conv (index ).name
1909
1907
1910
- @pytest .mark .parametrize (
1911
- "index,expected" ,
1912
- [
1913
- # ASCII
1914
- # short
1915
- (
1916
- Index (["a" , "bb" , "ccc" ]),
1917
- """Index(['a', 'bb', 'ccc'], dtype='object')""" ,
1918
- ),
1919
- # multiple lines
1920
- (
1921
- Index (["a" , "bb" , "ccc" ] * 10 ),
1922
- """\
1923
- Index(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc',
1924
- 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc',
1925
- 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
1926
- dtype='object')""" ,
1927
- ),
1928
- # truncated
1929
- (
1930
- Index (["a" , "bb" , "ccc" ] * 100 ),
1931
- """\
1932
- Index(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
1933
- ...
1934
- 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
1935
- dtype='object', length=300)""" ,
1936
- ),
1937
- # Non-ASCII
1938
- # short
1939
- (
1940
- Index (["あ" , "いい" , "ううう" ]),
1941
- """Index(['あ', 'いい', 'ううう'], dtype='object')""" ,
1942
- ),
1943
- # multiple lines
1944
- (
1945
- Index (["あ" , "いい" , "ううう" ] * 10 ),
1946
- (
1947
- "Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
1948
- "'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',\n "
1949
- " 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
1950
- "'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう',\n "
1951
- " 'あ', 'いい', 'ううう', 'あ', 'いい', "
1952
- "'ううう'],\n "
1953
- " dtype='object')"
1954
- ),
1955
- ),
1956
- # truncated
1957
- (
1958
- Index (["あ" , "いい" , "ううう" ] * 100 ),
1959
- (
1960
- "Index(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', "
1961
- "'あ', 'いい', 'ううう', 'あ',\n "
1962
- " ...\n "
1963
- " 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', "
1964
- "'ううう', 'あ', 'いい', 'ううう'],\n "
1965
- " dtype='object', length=300)"
1966
- ),
1967
- ),
1968
- ],
1969
- )
1970
- def test_string_index_repr (self , index , expected ):
1971
- result = repr (index )
1972
- assert result == expected
1973
-
1974
- @pytest .mark .parametrize (
1975
- "index,expected" ,
1976
- [
1977
- # short
1978
- (
1979
- Index (["あ" , "いい" , "ううう" ]),
1980
- ("Index(['あ', 'いい', 'ううう'], dtype='object')" ),
1981
- ),
1982
- # multiple lines
1983
- (
1984
- Index (["あ" , "いい" , "ううう" ] * 10 ),
1985
- (
1986
- "Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
1987
- "'ううう', 'あ', 'いい', 'ううう',\n "
1988
- " 'あ', 'いい', 'ううう', 'あ', 'いい', "
1989
- "'ううう', 'あ', 'いい', 'ううう',\n "
1990
- " 'あ', 'いい', 'ううう', 'あ', 'いい', "
1991
- "'ううう', 'あ', 'いい', 'ううう',\n "
1992
- " 'あ', 'いい', 'ううう'],\n "
1993
- " dtype='object')"
1994
- ""
1995
- ),
1996
- ),
1997
- # truncated
1998
- (
1999
- Index (["あ" , "いい" , "ううう" ] * 100 ),
2000
- (
2001
- "Index(['あ', 'いい', 'ううう', 'あ', 'いい', "
2002
- "'ううう', 'あ', 'いい', 'ううう',\n "
2003
- " 'あ',\n "
2004
- " ...\n "
2005
- " 'ううう', 'あ', 'いい', 'ううう', 'あ', "
2006
- "'いい', 'ううう', 'あ', 'いい',\n "
2007
- " 'ううう'],\n "
2008
- " dtype='object', length=300)"
2009
- ),
2010
- ),
2011
- ],
2012
- )
2013
- def test_string_index_repr_with_unicode_option (self , index , expected ):
2014
- # Enable Unicode option -----------------------------------------
2015
- with cf .option_context ("display.unicode.east_asian_width" , True ):
2016
- result = repr (index )
2017
- assert result == expected
2018
-
2019
1908
def test_cached_properties_not_settable (self ):
2020
1909
index = Index ([1 , 2 , 3 ])
2021
1910
with pytest .raises (AttributeError , match = "Can't set attribute" ):
@@ -2236,12 +2125,6 @@ def test_is_monotonic_na(self, index):
2236
2125
assert index ._is_strictly_monotonic_increasing is False
2237
2126
assert index ._is_strictly_monotonic_decreasing is False
2238
2127
2239
- def test_repr_summary (self ):
2240
- with cf .option_context ("display.max_seq_items" , 10 ):
2241
- result = repr (Index (np .arange (1000 )))
2242
- assert len (result ) < 200
2243
- assert "..." in result
2244
-
2245
2128
@pytest .mark .parametrize ("klass" , [Series , DataFrame ])
2246
2129
def test_int_name_format (self , klass ):
2247
2130
index = Index (["a" , "b" , "c" ], name = 0 )
@@ -2265,17 +2148,6 @@ def test_intersect_str_dates(self):
2265
2148
expected = Index ([], dtype = object )
2266
2149
tm .assert_index_equal (result , expected )
2267
2150
2268
- def test_index_repr_bool_nan (self ):
2269
- # GH32146
2270
- arr = Index ([True , False , np .nan ], dtype = object )
2271
- exp1 = arr .format ()
2272
- out1 = ["True" , "False" , "NaN" ]
2273
- assert out1 == exp1
2274
-
2275
- exp2 = repr (arr )
2276
- out2 = "Index([True, False, nan], dtype='object')"
2277
- assert out2 == exp2
2278
-
2279
2151
@pytest .mark .filterwarnings ("ignore:elementwise comparison failed:FutureWarning" )
2280
2152
def test_index_with_tuple_bool (self ):
2281
2153
# GH34123
0 commit comments