Commit 706e4ecb authored by Andrea Bizzego's avatar Andrea Bizzego
Browse files

check monotonicity

parent af568c14
......@@ -93,8 +93,10 @@ def binImage(binwidth, parameterMatrix, parameterMatrixCoordinates=None, bincoun
binEdges = numpy.r_[binEdges, numpy.max(parameterMatrix[:])]
#check monotonicity
diff = numpy.diff(binEdges)
idx_non_monotonical = numpy.where(diff<0)[0]
binEdges = numpy.delete(binEdges, idx_non_monotonical)
while not (diff>=0).all():
idx_non_monotonical = numpy.where(diff<0)[0]
binEdges = numpy.delete(binEdges, idx_non_monotonical)
diff = numpy.diff(binEdges)
else:
binEdges = getBinEdges(binwidth, parameterMatrix[:])
parameterMatrix = numpy.digitize(parameterMatrix, binEdges)
......@@ -106,10 +108,13 @@ def binImage(binwidth, parameterMatrix, parameterMatrixCoordinates=None, bincoun
# print('equal')
binEdges = numpy.percentile(parameterMatrix[parameterMatrixCoordinates], numpy.arange(0, 1, 1/bincount))
binEdges = numpy.r_[binEdges, numpy.max(parameterMatrix[:])]
#check monotonicity
# check monotonicity
diff = numpy.diff(binEdges)
idx_non_monotonical = numpy.where(diff<0)[0]
binEdges = numpy.delete(binEdges, idx_non_monotonical)
while not (diff>=0).all():
idx_non_monotonical = numpy.where(diff<0)[0]
binEdges = numpy.delete(binEdges, idx_non_monotonical)
diff = numpy.diff(binEdges)
else:
binEdges = getBinEdges(binwidth, parameterMatrix[parameterMatrixCoordinates])
parameterMatrix[parameterMatrixCoordinates] = numpy.digitize(parameterMatrix[parameterMatrixCoordinates], binEdges)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment