88
99
1010class TestCategoricalIndexReprStringCategories :
11- def test_string_categorical_index_repr (self , using_infer_string ):
11+ def test_string_categorical_index_repr (self ):
1212 # short
1313 idx = CategoricalIndex (["a" , "bb" , "ccc" ])
1414 expected = """CategoricalIndex(['a', 'bb', 'ccc'], categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')""" # noqa: E501
15- if using_infer_string :
16- expected = expected .replace (
17- "categories=['a', 'bb', 'ccc']" ,
18- "categories=[a, bb, ccc]" ,
19- )
2015 assert repr (idx ) == expected
2116
22- def test_categorical_index_repr_multiline (self , using_infer_string ):
17+ def test_categorical_index_repr_multiline (self ):
2318 # multiple lines
2419 idx = CategoricalIndex (["a" , "bb" , "ccc" ] * 10 )
2520 expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
2621 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',
2722 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
2823 categories=['a', 'bb', 'ccc'], ordered=False, dtype='category')""" # noqa: E501
29- if using_infer_string :
30- expected = expected .replace (
31- "categories=['a', 'bb', 'ccc']" ,
32- "categories=[a, bb, ccc]" ,
33- )
3424 assert repr (idx ) == expected
3525
36- def test_categorical_index_repr_truncated (self , using_infer_string ):
26+ def test_categorical_index_repr_truncated (self ):
3727 # truncated
3828 idx = CategoricalIndex (["a" , "bb" , "ccc" ] * 100 )
3929 expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
4030 ...
4131 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
4232 categories=['a', 'bb', 'ccc'], ordered=False, dtype='category', length=300)""" # noqa: E501
43- if using_infer_string :
44- expected = expected .replace (
45- "categories=['a', 'bb', 'ccc']" ,
46- "categories=[a, bb, ccc]" ,
47- )
4833 assert repr (idx ) == expected
4934
50- def test_categorical_index_repr_many_categories (self , using_infer_string ):
35+ def test_categorical_index_repr_many_categories (self ):
5136 # larger categories
5237 idx = CategoricalIndex (list ("abcdefghijklmmo" ))
5338 expected = """CategoricalIndex(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
5439 'm', 'm', 'o'],
5540 categories=['a', 'b', 'c', 'd', ..., 'k', 'l', 'm', 'o'], ordered=False, dtype='category')""" # noqa: E501
56- if using_infer_string :
57- expected = expected .replace (
58- "categories=['a', 'b', 'c', 'd', ..., 'k', 'l', 'm', 'o']" ,
59- "categories=[a, b, c, d, ..., k, l, m, o]" ,
60- )
6141 assert repr (idx ) == expected
6242
63- def test_categorical_index_repr_unicode (self , using_infer_string ):
43+ def test_categorical_index_repr_unicode (self ):
6444 # short
6545 idx = CategoricalIndex (["あ" , "いい" , "ううう" ])
6646 expected = """CategoricalIndex(['あ', 'いい', 'ううう'], categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
67- if using_infer_string :
68- expected = expected .replace (
69- "categories=['あ', 'いい', 'ううう']" ,
70- "categories=[あ, いい, ううう]" ,
71- )
7247 assert repr (idx ) == expected
7348
74- def test_categorical_index_repr_unicode_multiline (self , using_infer_string ):
49+ def test_categorical_index_repr_unicode_multiline (self ):
7550 # multiple lines
7651 idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 10 )
7752 expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
7853 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
7954 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
8055 categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
81- if using_infer_string :
82- expected = expected .replace (
83- "categories=['あ', 'いい', 'ううう']" ,
84- "categories=[あ, いい, ううう]" ,
85- )
8656 assert repr (idx ) == expected
8757
88- def test_categorical_index_repr_unicode_truncated (self , using_infer_string ):
58+ def test_categorical_index_repr_unicode_truncated (self ):
8959 # truncated
9060 idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 100 )
9161 expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
9262 ...
9363 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
9464 categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category', length=300)""" # noqa: E501
95- if using_infer_string :
96- expected = expected .replace (
97- "categories=['あ', 'いい', 'ううう']" ,
98- "categories=[あ, いい, ううう]" ,
99- )
10065 assert repr (idx ) == expected
10166
102- def test_categorical_index_repr_unicode_many_categories (self , using_infer_string ):
67+ def test_categorical_index_repr_unicode_many_categories (self ):
10368 # larger categories
10469 idx = CategoricalIndex (list ("あいうえおかきくけこさしすせそ" ))
10570 expected = """CategoricalIndex(['あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し',
10671 'す', 'せ', 'そ'],
10772 categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ'], ordered=False, dtype='category')""" # noqa: E501
108- if using_infer_string :
109- expected = expected .replace (
110- "categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ']" ,
111- "categories=[あ, い, う, え, ..., し, す, せ, そ]" ,
112- )
11373 assert repr (idx ) == expected
11474
115- def test_categorical_index_repr_east_asian_width (self , using_infer_string ):
75+ def test_categorical_index_repr_east_asian_width (self ):
11676 with cf .option_context ("display.unicode.east_asian_width" , True ):
11777 # short
11878 idx = CategoricalIndex (["あ" , "いい" , "ううう" ])
11979 expected = """CategoricalIndex(['あ', 'いい', 'ううう'], categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
120- if using_infer_string :
121- expected = expected .replace (
122- "categories=['あ', 'いい', 'ううう']" ,
123- "categories=[あ, いい, ううう]" ,
124- )
12580 assert repr (idx ) == expected
12681
127- def test_categorical_index_repr_east_asian_width_multiline (
128- self , using_infer_string
129- ):
82+ def test_categorical_index_repr_east_asian_width_multiline (self ):
13083 with cf .option_context ("display.unicode.east_asian_width" , True ):
13184 # multiple lines
13285 idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 10 )
@@ -136,16 +89,9 @@ def test_categorical_index_repr_east_asian_width_multiline(
13689 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
13790 categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
13891
139- if using_infer_string :
140- expected = expected .replace (
141- "categories=['あ', 'いい', 'ううう']" ,
142- "categories=[あ, いい, ううう]" ,
143- )
14492 assert repr (idx ) == expected
14593
146- def test_categorical_index_repr_east_asian_width_truncated (
147- self , using_infer_string
148- ):
94+ def test_categorical_index_repr_east_asian_width_truncated (self ):
14995 with cf .option_context ("display.unicode.east_asian_width" , True ):
15096 # truncated
15197 idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 100 )
@@ -156,25 +102,13 @@ def test_categorical_index_repr_east_asian_width_truncated(
156102 'あ', 'いい', 'ううう'],
157103 categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category', length=300)""" # noqa: E501
158104
159- if using_infer_string :
160- expected = expected .replace (
161- "categories=['あ', 'いい', 'ううう']" ,
162- "categories=[あ, いい, ううう]" ,
163- )
164105 assert repr (idx ) == expected
165106
166- def test_categorical_index_repr_east_asian_width_many_categories (
167- self , using_infer_string
168- ):
107+ def test_categorical_index_repr_east_asian_width_many_categories (self ):
169108 with cf .option_context ("display.unicode.east_asian_width" , True ):
170109 idx = CategoricalIndex (list ("あいうえおかきくけこさしすせそ" ))
171110 expected = """CategoricalIndex(['あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ',
172111 'さ', 'し', 'す', 'せ', 'そ'],
173112 categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ'], ordered=False, dtype='category')""" # noqa: E501
174113
175- if using_infer_string :
176- expected = expected .replace (
177- "categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ']" ,
178- "categories=[あ, い, う, え, ..., し, す, せ, そ]" ,
179- )
180114 assert repr (idx ) == expected
0 commit comments