File tree 2 files changed +40
-1
lines changed
2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -5014,7 +5014,7 @@ def reduce_C_function(C: array) -> float
5014
5014
if mincnt is None :
5015
5015
mincnt = 0
5016
5016
accum = np .array (
5017
- [reduce_C_function (acc ) if len (acc ) > mincnt else np .nan
5017
+ [reduce_C_function (acc ) if len (acc ) >= mincnt else np .nan
5018
5018
for Cs_at_i in [Cs_at_i1 , Cs_at_i2 ]
5019
5019
for acc in Cs_at_i [1 :]], # [1:] drops out-of-range points.
5020
5020
float )
Original file line number Diff line number Diff line change @@ -999,6 +999,45 @@ def test_hexbin_log_clim():
999
999
assert h .get_clim () == (2 , 100 )
1000
1000
1001
1001
1002
+ @check_figures_equal (extensions = ['png' ])
1003
+ def test_hexbin_mincnt_behavior_upon_C_parameter (fig_test , fig_ref ):
1004
+ # see: gh:12926
1005
+ datapoints = [
1006
+ # list of (x, y)
1007
+ (0 , 0 ),
1008
+ (0 , 0 ),
1009
+ (6 , 0 ),
1010
+ (0 , 6 ),
1011
+ ]
1012
+ X , Y = zip (* datapoints )
1013
+ C = [1 ] * len (X )
1014
+ extent = [- 10. , 10 , - 10. , 10 ]
1015
+ gridsize = (7 , 7 )
1016
+
1017
+ ax_test = fig_test .subplots ()
1018
+ ax_ref = fig_ref .subplots ()
1019
+
1020
+ # without C parameter
1021
+ ax_ref .hexbin (
1022
+ X , Y ,
1023
+ extent = extent ,
1024
+ gridsize = gridsize ,
1025
+ mincnt = 1 ,
1026
+ )
1027
+ ax_ref .set_facecolor ("green" ) # for contrast of background
1028
+
1029
+ # with C parameter
1030
+ ax_test .hexbin (
1031
+ X , Y ,
1032
+ C = [1 ] * len (X ),
1033
+ reduce_C_function = lambda v : sum (v ),
1034
+ mincnt = 1 ,
1035
+ extent = extent ,
1036
+ gridsize = gridsize ,
1037
+ )
1038
+ ax_test .set_facecolor ("green" )
1039
+
1040
+
1002
1041
def test_inverted_limits ():
1003
1042
# Test gh:1553
1004
1043
# Calling invert_xaxis prior to plotting should not disable autoscaling
You can’t perform that action at this time.
0 commit comments