Skip to content

Commit

Permalink
Fix number of negatives and zeros statistics
Browse files Browse the repository at this point in the history
Now returns correct statistic if it's already evaluated
  • Loading branch information
xJoskiy committed Jul 4, 2023
1 parent 1831ba5 commit 43952ea
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/algorithms/statistics/data_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ size_t DataStats::CountIf(Pred pred, size_t index) const {
}

Statistic DataStats::CountIfInBinaryRelationWithZero(size_t index, mo::CompareResult res) const {
if (all_stats_[index].num_zeros.HasValue()) return all_stats_[index].num_zeros;
const mo::TypedColumnData& col = GetData()[index];
if (!col.IsNumeric()) return {};

Expand All @@ -318,10 +317,12 @@ Statistic DataStats::CountIfInBinaryRelationWithZero(size_t index, mo::CompareRe
}

Statistic DataStats::GetNumberOfZeros(size_t index) const {
if (all_stats_[index].num_zeros.HasValue()) return all_stats_[index].num_zeros;
return CountIfInBinaryRelationWithZero(index, mo::CompareResult::kEqual);
}

Statistic DataStats::GetNumberOfNegatives(size_t index) const {
if (all_stats_[index].num_negatives.HasValue()) return all_stats_[index].num_negatives;
return CountIfInBinaryRelationWithZero(index, mo::CompareResult::kLess);
}

Expand Down

0 comments on commit 43952ea

Please sign in to comment.