@@ -198,9 +198,7 @@ def test_bar(self):
198
198
df = pd .DataFrame ({'A' : [0 , 1 , 2 ]})
199
199
result = df .style .bar ()._compute ().ctx
200
200
expected = {
201
- (0 , 0 ): ['width: 10em' , ' height: 80%' ,
202
- 'background: linear-gradient('
203
- '90deg,#d65f5f 0.0%, transparent 0%)' ],
201
+ (0 , 0 ): ['width: 10em' , ' height: 80%' ],
204
202
(1 , 0 ): ['width: 10em' , ' height: 80%' ,
205
203
'background: linear-gradient('
206
204
'90deg,#d65f5f 50.0%, transparent 0%)' ],
@@ -212,9 +210,7 @@ def test_bar(self):
212
210
213
211
result = df .style .bar (color = 'red' , width = 50 )._compute ().ctx
214
212
expected = {
215
- (0 , 0 ): ['width: 10em' , ' height: 80%' ,
216
- 'background: linear-gradient('
217
- '90deg,red 0.0%, transparent 0%)' ],
213
+ (0 , 0 ): ['width: 10em' , ' height: 80%' ],
218
214
(1 , 0 ): ['width: 10em' , ' height: 80%' ,
219
215
'background: linear-gradient('
220
216
'90deg,red 25.0%, transparent 0%)' ],
@@ -231,6 +227,44 @@ def test_bar(self):
231
227
result = df .style .bar (color = 'red' , width = 50 )._compute ().ctx
232
228
self .assertEqual (result , expected )
233
229
230
+ def test_bar_0points (self ):
231
+ df = pd .DataFrame ([[1 , 2 , 3 ], [4 , 5 , 6 ], [7 , 8 , 9 ]])
232
+ result = df .style .bar ()._compute ().ctx
233
+ expected = {(0 , 0 ): ['width: 10em' , ' height: 80%' ],
234
+ (0 , 1 ): ['width: 10em' , ' height: 80%' ],
235
+ (0 , 2 ): ['width: 10em' , ' height: 80%' ],
236
+ (1 , 0 ): ['width: 10em' , ' height: 80%' ,
237
+ 'background: linear-gradient(90deg,#d65f5f 50.0%, transparent 0%)' ],
238
+ (1 , 1 ): ['width: 10em' , ' height: 80%' ,
239
+ 'background: linear-gradient(90deg,#d65f5f 50.0%, transparent 0%)' ],
240
+ (1 , 2 ): ['width: 10em' , ' height: 80%' ,
241
+ 'background: linear-gradient(90deg,#d65f5f 50.0%, transparent 0%)' ],
242
+ (2 , 0 ): ['width: 10em' , ' height: 80%' ,
243
+ 'background: linear-gradient(90deg,#d65f5f 100.0%, transparent 0%)' ],
244
+ (2 , 1 ): ['width: 10em' , ' height: 80%' ,
245
+ 'background: linear-gradient(90deg,#d65f5f 100.0%, transparent 0%)' ],
246
+ (2 , 2 ): ['width: 10em' , ' height: 80%' ,
247
+ 'background: linear-gradient(90deg,#d65f5f 100.0%, transparent 0%)' ]}
248
+ self .assertEqual (result , expected )
249
+
250
+ result = df .style .bar (axis = 1 )._compute ().ctx
251
+ expected = {(0 , 0 ): ['width: 10em' , ' height: 80%' ],
252
+ (0 , 1 ): ['width: 10em' , ' height: 80%' ,
253
+ 'background: linear-gradient(90deg,#d65f5f 50.0%, transparent 0%)' ],
254
+ (0 , 2 ): ['width: 10em' , ' height: 80%' ,
255
+ 'background: linear-gradient(90deg,#d65f5f 100.0%, transparent 0%)' ],
256
+ (1 , 0 ): ['width: 10em' , ' height: 80%' ],
257
+ (1 , 1 ): ['width: 10em' , ' height: 80%' ,
258
+ 'background: linear-gradient(90deg,#d65f5f 50.0%, transparent 0%)' ],
259
+ (1 , 2 ): ['width: 10em' , ' height: 80%' ,
260
+ 'background: linear-gradient(90deg,#d65f5f 100.0%, transparent 0%)' ],
261
+ (2 , 0 ): ['width: 10em' , ' height: 80%' ],
262
+ (2 , 1 ): ['width: 10em' , ' height: 80%' ,
263
+ 'background: linear-gradient(90deg,#d65f5f 50.0%, transparent 0%)' ],
264
+ (2 , 2 ): ['width: 10em' , ' height: 80%' ,
265
+ 'background: linear-gradient(90deg,#d65f5f 100.0%, transparent 0%)' ]}
266
+ self .assertEqual (result , expected )
267
+
234
268
def test_highlight_null (self , null_color = 'red' ):
235
269
df = pd .DataFrame ({'A' : [0 , np .nan ]})
236
270
result = df .style .highlight_null ()._compute ().ctx
0 commit comments