Skip to content

Commit adf591c

Browse files
committed
cargo fmt
1 parent b3d6b49 commit adf591c

6 files changed

Lines changed: 95 additions & 20 deletions

File tree

src/plot/layer/geom/boxplot.rs

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,13 @@ fn stat_boxplot(
164164
})
165165
}
166166

167-
fn boxplot_sql_compute_summary(from: &str, groups: &[String], value: &str, coef: &f64, dialect: &dyn SqlDialect) -> String {
167+
fn boxplot_sql_compute_summary(
168+
from: &str,
169+
groups: &[String],
170+
value: &str,
171+
coef: &f64,
172+
dialect: &dyn SqlDialect,
173+
) -> String {
168174
let groups_str = groups.join(", ");
169175
let lower_expr = dialect.sql_greatest(&[&format!("q1 - {coef} * (q3 - q1)"), "min"]);
170176
let upper_expr = dialect.sql_least(&[&format!("q3 + {coef} * (q3 - q1)"), "max"]);
@@ -367,7 +373,13 @@ mod tests {
367373
#[test]
368374
fn test_boxplot_sql_compute_summary_single_group() {
369375
let groups = vec!["category".to_string()];
370-
let result = boxplot_sql_compute_summary("SELECT * FROM sales", &groups, "price", &1.5, &AnsiDialect);
376+
let result = boxplot_sql_compute_summary(
377+
"SELECT * FROM sales",
378+
&groups,
379+
"price",
380+
&1.5,
381+
&AnsiDialect,
382+
);
371383

372384
let q1 = AnsiDialect.sql_percentile("price", 0.25, "SELECT * FROM sales", &groups);
373385
let median = AnsiDialect.sql_percentile("price", 0.50, "SELECT * FROM sales", &groups);
@@ -397,7 +409,13 @@ mod tests {
397409
#[test]
398410
fn test_boxplot_sql_compute_summary_multiple_groups() {
399411
let groups = vec!["region".to_string(), "product".to_string()];
400-
let result = boxplot_sql_compute_summary("SELECT * FROM data", &groups, "revenue", &1.5, &AnsiDialect);
412+
let result = boxplot_sql_compute_summary(
413+
"SELECT * FROM data",
414+
&groups,
415+
"revenue",
416+
&1.5,
417+
&AnsiDialect,
418+
);
401419

402420
let q1 = AnsiDialect.sql_percentile("revenue", 0.25, "SELECT * FROM data", &groups);
403421
let median = AnsiDialect.sql_percentile("revenue", 0.50, "SELECT * FROM data", &groups);
@@ -510,7 +528,13 @@ mod tests {
510528
);
511529
parameters.insert("outliers".to_string(), ParameterValue::Boolean(true));
512530

513-
let result = stat_boxplot("SELECT * FROM data", &aesthetics, &groups, &parameters, &AnsiDialect);
531+
let result = stat_boxplot(
532+
"SELECT * FROM data",
533+
&aesthetics,
534+
&groups,
535+
&parameters,
536+
&AnsiDialect,
537+
);
514538

515539
assert!(result.is_err());
516540
assert!(result.unwrap_err().to_string().contains("coef"));
@@ -525,7 +549,13 @@ mod tests {
525549
parameters.insert("outliers".to_string(), ParameterValue::Boolean(true));
526550
// Missing coef
527551

528-
let result = stat_boxplot("SELECT * FROM data", &aesthetics, &groups, &parameters, &AnsiDialect);
552+
let result = stat_boxplot(
553+
"SELECT * FROM data",
554+
&aesthetics,
555+
&groups,
556+
&parameters,
557+
&AnsiDialect,
558+
);
529559

530560
assert!(result.is_err());
531561
assert!(result.unwrap_err().to_string().contains("coef"));
@@ -543,7 +573,13 @@ mod tests {
543573
ParameterValue::String("yes".to_string()),
544574
);
545575

546-
let result = stat_boxplot("SELECT * FROM data", &aesthetics, &groups, &parameters, &AnsiDialect);
576+
let result = stat_boxplot(
577+
"SELECT * FROM data",
578+
&aesthetics,
579+
&groups,
580+
&parameters,
581+
&AnsiDialect,
582+
);
547583

548584
assert!(result.is_err());
549585
assert!(result.unwrap_err().to_string().contains("outliers"));
@@ -558,7 +594,13 @@ mod tests {
558594
parameters.insert("coef".to_string(), ParameterValue::Number(1.5));
559595
// Missing outliers
560596

561-
let result = stat_boxplot("SELECT * FROM data", &aesthetics, &groups, &parameters, &AnsiDialect);
597+
let result = stat_boxplot(
598+
"SELECT * FROM data",
599+
&aesthetics,
600+
&groups,
601+
&parameters,
602+
&AnsiDialect,
603+
);
562604

563605
assert!(result.is_err());
564606
assert!(result.unwrap_err().to_string().contains("outliers"));

src/plot/layer/geom/density.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,13 @@ fn density_sql_bandwidth(
285285
)
286286
}
287287

288-
fn silverman_rule(adjust: f64, value_column: &str, from: &str, groups: &[String], dialect: &dyn SqlDialect) -> String {
288+
fn silverman_rule(
289+
adjust: f64,
290+
value_column: &str,
291+
from: &str,
292+
groups: &[String],
293+
dialect: &dyn SqlDialect,
294+
) -> String {
289295
// The query computes Silverman's rule of thumb (R's `stats::bw.nrd0()`).
290296
// We absorb the adjustment in the 0.9 multiplier of the rule
291297
let adjust = 0.9 * adjust;
@@ -379,7 +385,14 @@ fn build_data_cte(value: &str, weight: Option<&str>, from: &str, group_by: &[Str
379385
)
380386
}
381387

382-
fn build_grid_cte(groups: &[String], from: &str, min: f64, max: f64, n_points: usize, dialect: &dyn SqlDialect) -> String {
388+
fn build_grid_cte(
389+
groups: &[String],
390+
from: &str,
391+
min: f64,
392+
max: f64,
393+
n_points: usize,
394+
dialect: &dyn SqlDialect,
395+
) -> String {
383396
let has_groups = !groups.is_empty();
384397
let n_points = n_points - 1; // GENERATE_SERIES gives on point for free
385398
let diff = (max - min).abs();
@@ -509,8 +522,8 @@ fn compute_density(
509522
#[cfg(test)]
510523
mod tests {
511524
use super::*;
512-
use crate::reader::AnsiDialect;
513525
use crate::reader::duckdb::DuckDBReader;
526+
use crate::reader::AnsiDialect;
514527
use crate::reader::Reader;
515528

516529
#[test]

src/plot/layer/geom/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ pub trait GeomTrait: std::fmt::Debug + std::fmt::Display + Send + Sync {
191191
/// Apply statistical transformation to the layer query.
192192
///
193193
/// The default implementation returns identity (no transformation).
194+
#[allow(clippy::too_many_arguments)]
194195
fn apply_stat_transform(
195196
&self,
196197
_query: &str,
@@ -402,6 +403,7 @@ impl Geom {
402403
}
403404

404405
/// Apply stat transform
406+
#[allow(clippy::too_many_arguments)]
405407
pub fn apply_stat_transform(
406408
&self,
407409
query: &str,

src/plot/layer/geom/violin.rs

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,14 @@ impl GeomTrait for Violin {
9191
execute_query: &dyn Fn(&str) -> crate::Result<polars::prelude::DataFrame>,
9292
dialect: &dyn crate::reader::SqlDialect,
9393
) -> Result<StatResult> {
94-
stat_violin(query, aesthetics, group_by, parameters, execute_query, dialect)
94+
stat_violin(
95+
query,
96+
aesthetics,
97+
group_by,
98+
parameters,
99+
execute_query,
100+
dialect,
101+
)
95102
}
96103

97104
/// Post-process the violin DataFrame to scale offset to [0, 0.5 * width].
@@ -201,9 +208,9 @@ fn stat_violin(
201208
#[cfg(test)]
202209
mod tests {
203210
use super::*;
204-
use crate::reader::AnsiDialect;
205211
use crate::plot::AestheticValue;
206212
use crate::reader::duckdb::DuckDBReader;
213+
use crate::reader::AnsiDialect;
207214
use crate::reader::Reader;
208215

209216
// ==================== Helper Functions ====================
@@ -257,8 +264,15 @@ mod tests {
257264

258265
let execute = |sql: &str| reader.execute_sql(sql);
259266

260-
let result = stat_violin(query, &aesthetics, &groups, &parameters, &execute, &AnsiDialect)
261-
.expect("stat_violin should succeed");
267+
let result = stat_violin(
268+
query,
269+
&aesthetics,
270+
&groups,
271+
&parameters,
272+
&execute,
273+
&AnsiDialect,
274+
)
275+
.expect("stat_violin should succeed");
262276

263277
// Verify the result is a transformed stat result
264278
match result {
@@ -322,8 +336,15 @@ mod tests {
322336

323337
let execute = |sql: &str| reader.execute_sql(sql);
324338

325-
let result = stat_violin(query, &aesthetics, &groups, &parameters, &execute, &AnsiDialect)
326-
.expect("stat_violin should succeed");
339+
let result = stat_violin(
340+
query,
341+
&aesthetics,
342+
&groups,
343+
&parameters,
344+
&execute,
345+
&AnsiDialect,
346+
)
347+
.expect("stat_violin should succeed");
327348

328349
// Verify the result is a transformed stat result
329350
match result {

src/plot/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,3 @@ pub use main::*;
3131
pub use projection::*;
3232
pub use scale::*;
3333
pub use types::*;
34-

src/reader/duckdb.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,7 @@ mod tests {
10631063
.unwrap();
10641064

10651065
let spec = reader
1066-
.execute(
1067-
"SELECT * FROM box_data VISUALISE DRAW boxplot MAPPING grp AS x, value AS y",
1068-
)
1066+
.execute("SELECT * FROM box_data VISUALISE DRAW boxplot MAPPING grp AS x, value AS y")
10691067
.unwrap();
10701068

10711069
assert!(spec.layer_data(0).is_some());

0 commit comments

Comments
 (0)