8
8
9
9
10
10
class TestCategoricalIndexReprStringCategories :
11
- def test_string_categorical_index_repr (self , using_infer_string ):
11
+ def test_string_categorical_index_repr (self ):
12
12
# short
13
13
idx = CategoricalIndex (["a" , "bb" , "ccc" ])
14
14
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
- )
20
15
assert repr (idx ) == expected
21
16
22
- def test_categorical_index_repr_multiline (self , using_infer_string ):
17
+ def test_categorical_index_repr_multiline (self ):
23
18
# multiple lines
24
19
idx = CategoricalIndex (["a" , "bb" , "ccc" ] * 10 )
25
20
expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
26
21
'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb',
27
22
'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
28
23
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
- )
34
24
assert repr (idx ) == expected
35
25
36
- def test_categorical_index_repr_truncated (self , using_infer_string ):
26
+ def test_categorical_index_repr_truncated (self ):
37
27
# truncated
38
28
idx = CategoricalIndex (["a" , "bb" , "ccc" ] * 100 )
39
29
expected = """CategoricalIndex(['a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a',
40
30
...
41
31
'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc', 'a', 'bb', 'ccc'],
42
32
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
- )
48
33
assert repr (idx ) == expected
49
34
50
- def test_categorical_index_repr_many_categories (self , using_infer_string ):
35
+ def test_categorical_index_repr_many_categories (self ):
51
36
# larger categories
52
37
idx = CategoricalIndex (list ("abcdefghijklmmo" ))
53
38
expected = """CategoricalIndex(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
54
39
'm', 'm', 'o'],
55
40
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
- )
61
41
assert repr (idx ) == expected
62
42
63
- def test_categorical_index_repr_unicode (self , using_infer_string ):
43
+ def test_categorical_index_repr_unicode (self ):
64
44
# short
65
45
idx = CategoricalIndex (["あ" , "いい" , "ううう" ])
66
46
expected = """CategoricalIndex(['あ', 'いい', 'ううう'], categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
67
- if using_infer_string :
68
- expected = expected .replace (
69
- "categories=['あ', 'いい', 'ううう']" ,
70
- "categories=[あ, いい, ううう]" ,
71
- )
72
47
assert repr (idx ) == expected
73
48
74
- def test_categorical_index_repr_unicode_multiline (self , using_infer_string ):
49
+ def test_categorical_index_repr_unicode_multiline (self ):
75
50
# multiple lines
76
51
idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 10 )
77
52
expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
78
53
'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい',
79
54
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
80
55
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
81
- if using_infer_string :
82
- expected = expected .replace (
83
- "categories=['あ', 'いい', 'ううう']" ,
84
- "categories=[あ, いい, ううう]" ,
85
- )
86
56
assert repr (idx ) == expected
87
57
88
- def test_categorical_index_repr_unicode_truncated (self , using_infer_string ):
58
+ def test_categorical_index_repr_unicode_truncated (self ):
89
59
# truncated
90
60
idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 100 )
91
61
expected = """CategoricalIndex(['あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ',
92
62
...
93
63
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
94
64
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category', length=300)""" # noqa: E501
95
- if using_infer_string :
96
- expected = expected .replace (
97
- "categories=['あ', 'いい', 'ううう']" ,
98
- "categories=[あ, いい, ううう]" ,
99
- )
100
65
assert repr (idx ) == expected
101
66
102
- def test_categorical_index_repr_unicode_many_categories (self , using_infer_string ):
67
+ def test_categorical_index_repr_unicode_many_categories (self ):
103
68
# larger categories
104
69
idx = CategoricalIndex (list ("あいうえおかきくけこさしすせそ" ))
105
70
expected = """CategoricalIndex(['あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ', 'さ', 'し',
106
71
'す', 'せ', 'そ'],
107
72
categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ'], ordered=False, dtype='category')""" # noqa: E501
108
- if using_infer_string :
109
- expected = expected .replace (
110
- "categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ']" ,
111
- "categories=[あ, い, う, え, ..., し, す, せ, そ]" ,
112
- )
113
73
assert repr (idx ) == expected
114
74
115
- def test_categorical_index_repr_east_asian_width (self , using_infer_string ):
75
+ def test_categorical_index_repr_east_asian_width (self ):
116
76
with cf .option_context ("display.unicode.east_asian_width" , True ):
117
77
# short
118
78
idx = CategoricalIndex (["あ" , "いい" , "ううう" ])
119
79
expected = """CategoricalIndex(['あ', 'いい', 'ううう'], categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
120
- if using_infer_string :
121
- expected = expected .replace (
122
- "categories=['あ', 'いい', 'ううう']" ,
123
- "categories=[あ, いい, ううう]" ,
124
- )
125
80
assert repr (idx ) == expected
126
81
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 ):
130
83
with cf .option_context ("display.unicode.east_asian_width" , True ):
131
84
# multiple lines
132
85
idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 10 )
@@ -136,16 +89,9 @@ def test_categorical_index_repr_east_asian_width_multiline(
136
89
'ううう', 'あ', 'いい', 'ううう', 'あ', 'いい', 'ううう'],
137
90
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category')""" # noqa: E501
138
91
139
- if using_infer_string :
140
- expected = expected .replace (
141
- "categories=['あ', 'いい', 'ううう']" ,
142
- "categories=[あ, いい, ううう]" ,
143
- )
144
92
assert repr (idx ) == expected
145
93
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 ):
149
95
with cf .option_context ("display.unicode.east_asian_width" , True ):
150
96
# truncated
151
97
idx = CategoricalIndex (["あ" , "いい" , "ううう" ] * 100 )
@@ -156,25 +102,13 @@ def test_categorical_index_repr_east_asian_width_truncated(
156
102
'あ', 'いい', 'ううう'],
157
103
categories=['あ', 'いい', 'ううう'], ordered=False, dtype='category', length=300)""" # noqa: E501
158
104
159
- if using_infer_string :
160
- expected = expected .replace (
161
- "categories=['あ', 'いい', 'ううう']" ,
162
- "categories=[あ, いい, ううう]" ,
163
- )
164
105
assert repr (idx ) == expected
165
106
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 ):
169
108
with cf .option_context ("display.unicode.east_asian_width" , True ):
170
109
idx = CategoricalIndex (list ("あいうえおかきくけこさしすせそ" ))
171
110
expected = """CategoricalIndex(['あ', 'い', 'う', 'え', 'お', 'か', 'き', 'く', 'け', 'こ',
172
111
'さ', 'し', 'す', 'せ', 'そ'],
173
112
categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ'], ordered=False, dtype='category')""" # noqa: E501
174
113
175
- if using_infer_string :
176
- expected = expected .replace (
177
- "categories=['あ', 'い', 'う', 'え', ..., 'し', 'す', 'せ', 'そ']" ,
178
- "categories=[あ, い, う, え, ..., し, す, せ, そ]" ,
179
- )
180
114
assert repr (idx ) == expected
0 commit comments