Skip to content

Commit

Permalink
Refine the condition for empty return in DataProcessingService (#184)
Browse files Browse the repository at this point in the history
Adjusted the condition under which an empty HashMap is returned in the DataProcessingService. Now, an empty HashMap will only be returned when both the maximum and minimum values in the data are 0, and the number of bins is also 0. This change takes into account situations where the data contains values but the min and max are both 0.
  • Loading branch information
Gcolon021 authored Feb 29, 2024
1 parent 315a789 commit 68f7ac7
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ private static Map<String, Integer> bucketData(Map<String, Integer> originalMap)
int numBins = calcNumBins(data);
double min = data.keySet().stream().min(Double::compareTo).orElse(0.0);
double max = data.keySet().stream().max(Double::compareTo).orElse(0.0);

if ((min == 0.0 && max == 0.0) || numBins == 0) return new HashMap<>();
// The min and max can both be 0, but we could still have a numBins of 1 if there are values in the data.
if (min == 0.0 && max == 0.0 && numBins == 0) return new HashMap<>();

int binSize = (int) Math.ceil((max - min) / numBins);

Expand Down

0 comments on commit 68f7ac7

Please sign in to comment.