0

I have the following inputs:

index_array
array([  2.,   3.,   4.,   5.,   6.,   7.,   8.,   9.,  10.,  11.])
success_rate_array
array([ 0.14436074,  0.15488785,  0.17158958,  0.19350282,  0.20358402,
        0.21188935,  0.23390895,  0.26160338,  0.1971831 ,  0.31818182])
x_e
array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
y_e
array([ 0. ,  0.1,  0.2,  0.3,  0.4,  0.5,  0.6,  0.7,  0.8,  0.9])

My call to create a 2d histogram:

H, x_e, y_e = np.histogram2d(sucess_rate_array, index_array, bins=(x_e, y_e))

is failing:

ValueError: The dimension of bins must be equal to the dimension of the  sample x.

As you can see above (and as I verify programmatically) in fact all 4 inputs have identical dimensions of (10, ) although I would have though it's only necessary that x_e and y_e have the same shape as one another and that success_rate_array and index_array have the same shape. Also I don't have an Inf or NaN values. What am I doing wrong?

Benjamin
  • 11,560
  • 13
  • 70
  • 119
helloB
  • 3,472
  • 10
  • 40
  • 87
  • It works fine with the example you provided (in `histogram2d` `success_rate_array` should have 2 c's). (Python 3.5, numpy 1.11.1) – ayhan Aug 31 '16 at 16:32
  • And perhaps you wanted the two arrays swapped: `H, x_e, y_e = np.histogram2d(index_array, success_rate_array, bins=(x_e, y_e))`. Anyway, as ayhan says, it would work. Perhaps you have some "sucess_rate_array" (notice the one "C") from previous? – honza_p Sep 02 '16 at 15:16

0 Answers0