Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summary stat #803

Merged
merged 26 commits into from
Jun 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7886cbc
First implementation of the summary stat.
ASmirnov-HORIS Jun 16, 2023
d95a062
Update API for the stat_summary() function.
ASmirnov-HORIS Jun 20, 2023
b28bf7f
Small refactor in SummaryStat.
ASmirnov-HORIS Jun 21, 2023
6ce963b
Remove extra enum class from the SummaryStatUtil.
ASmirnov-HORIS Jun 21, 2023
b7a8f33
Remove SummaryStatUtil.
ASmirnov-HORIS Jun 21, 2023
05345ee
Use references instead of lambdas for the SummaryCalculator.
ASmirnov-HORIS Jun 21, 2023
756b626
Replace SummaryCalculator by the SummaryStatUtil.
ASmirnov-HORIS Jun 21, 2023
3b2bca7
Refactor functions in SummaryStatUtil.
ASmirnov-HORIS Jun 22, 2023
1f03da4
Refactor summary stat options in StatProto.
ASmirnov-HORIS Jun 22, 2023
baccb49
Fix statData emptiness case in the SummaryStat.
ASmirnov-HORIS Jun 22, 2023
c9e154c
Further code refactoring.
ASmirnov-HORIS Jun 22, 2023
0082f74
Small fixes.
ASmirnov-HORIS Jun 22, 2023
cbabbe3
Add new stat variables and use them in the SummaryStat.
ASmirnov-HORIS Jun 23, 2023
7fea03b
Add prefix to min/max stats in stat_summary().
ASmirnov-HORIS Jun 23, 2023
0ecc6ec
Change API of the summary_stat() - add 'quantiles' parameter.
ASmirnov-HORIS Jun 26, 2023
722b43a
Tiny refactor in SummaryStat and AggregateFunctions.
ASmirnov-HORIS Jun 27, 2023
e30b93b
Use AggregateFunctions in the FiveNumberSummary.
ASmirnov-HORIS Jun 27, 2023
f076938
Add tests for AggregateFunctions.
ASmirnov-HORIS Jun 27, 2023
2313872
Replace parameter fun_map by usual aesthetics list for the stat_summa…
ASmirnov-HORIS Jun 29, 2023
4bba413
Small fixes in code for summary stat.
ASmirnov-HORIS Jun 29, 2023
9cfeea5
Merge branch 'master' into summary-stats
ASmirnov-HORIS Jun 29, 2023
4586451
Add getMapping() method to the Flipped stat context.
ASmirnov-HORIS Jun 29, 2023
9dcdd79
Add docstrings to the stat_summary() function.
ASmirnov-HORIS Jun 29, 2023
37526eb
Add demo notebook for stat_summary().
ASmirnov-HORIS Jun 29, 2023
0a1d636
Mention stat_summary() in the future_changes.
ASmirnov-HORIS Jun 29, 2023
a392ba1
Refactor StatContext.
ASmirnov-HORIS Jun 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Use references instead of lambdas for the SummaryCalculator.
  • Loading branch information
ASmirnov-HORIS committed Jun 21, 2023
commit 05345eed93dc0ad596ce5ca93fefb3e46a38e499
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ class SummaryStat(
}

val statValues: Map<Aes<*>, MutableList<Double>> = DEF_MAPPING.keys.associateWith { mutableListOf() }
val defaultAggFun: (SummaryCalculator) -> Double = { calc -> calc.nan }
for ((x, bin) in binnedData) {
val calc = SummaryCalculator(bin)
for (aes in statValues.keys) {
if (aes == Aes.X) {
statValues[aes]!!.add(x)
} else {
statValues[aes]!!.add(aggFunctionsMap.getOrElse(aes) { defaultAggFun }(calc))
statValues[aes]!!.add(aggFunctionsMap.getOrElse(aes) { SummaryCalculator::nan }(calc))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,15 +415,15 @@ object StatProto {
} else {
opts.getStringDef(option, default).let {
when (it.lowercase()) {
"nan" -> { calc -> calc.nan }
"count" -> { calc -> calc.count }
"sum" -> { calc -> calc.sum }
"mean" -> { calc -> calc.mean }
"median" -> { calc -> calc.median }
"min" -> { calc -> calc.min }
"max" -> { calc -> calc.max }
"q1" -> { calc -> calc.q1 }
"q3" -> { calc -> calc.q3 }
"nan" -> SummaryCalculator::nan
"count" -> SummaryCalculator::count
"sum" -> SummaryCalculator::sum
"mean" -> SummaryCalculator::mean
"median" -> SummaryCalculator::median
"min" -> SummaryCalculator::min
"max" -> SummaryCalculator::max
"q1" -> SummaryCalculator::q1
"q3" -> SummaryCalculator::q3
else -> throw IllegalArgumentException(
"Unsupported function name: '$it'\n" +
"Use one of: nan, count, sum, mean, median, min, max, q1, q3."
Expand Down