Skip to content

Commit 5f7132d

Browse files
committed
style: fix some clippy warnings
1 parent 11fd7e0 commit 5f7132d

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

src/progress.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl ProgressHandler {
4949
let progress =
5050
progress_to_value(progress_update_count, self.n_cores, time_sampling, progress);
5151
let rendered = template.render_from(&self.engine, &progress).to_string();
52-
let rendered = rendered.unwrap_or_else(|err| format!("{}", err));
52+
let rendered = rendered.unwrap_or_else(|err| format!("{err}"));
5353
let _ = Python::with_gil(|py| self.callback.call1(py, (rendered,)));
5454
progress_update_count += 1;
5555
};

src/pyfunc.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,8 @@ impl LogpError for PyLogpError {
127127
let Ok(attr) = err.value(py).getattr("is_recoverable") else {
128128
return false;
129129
};
130-
return attr
131-
.is_truthy()
132-
.expect("Could not access is_recoverable in error check");
130+
attr.is_truthy()
131+
.expect("Could not access is_recoverable in error check")
133132
}),
134133
Self::ReturnTypeError() => false,
135134
Self::NotContiguousError(_) => false,
@@ -151,7 +150,7 @@ impl PyDensity {
151150
transform_adapter: Option<&PyTransformAdapt>,
152151
) -> Result<Self> {
153152
let logp_func = Python::with_gil(|py| logp_clone_func.call0(py))?;
154-
let transform_adapter = transform_adapter.map(|val| val.clone());
153+
let transform_adapter = transform_adapter.cloned();
155154
Ok(Self {
156155
logp: logp_func,
157156
transform_adapter,
@@ -185,7 +184,7 @@ impl CpuLogpFunc for PyDensity {
185184
);
186185
Ok(logp_val)
187186
}
188-
Err(err) => return Err(PyLogpError::PyError(err)),
187+
Err(err) => Err(PyLogpError::PyError(err)),
189188
}
190189
})
191190
}
@@ -359,7 +358,7 @@ impl TensorShape {
359358
Self { shape, dims, size }
360359
}
361360
pub fn size(&self) -> usize {
362-
return self.size;
361+
self.size
363362
}
364363
}
365364

@@ -617,14 +616,14 @@ impl Model for PyModel {
617616
settings: &'model S,
618617
) -> Result<Self::DrawStorage<'model, S>> {
619618
let draws = settings.hint_num_tune() + settings.hint_num_draws();
620-
Ok(PyTrace::new(
619+
PyTrace::new(
621620
rng,
622621
chain_id,
623622
self.variables.clone(),
624623
&self.make_expand_func,
625624
draws,
626625
)
627-
.context("Could not create PyTrace object")?)
626+
.context("Could not create PyTrace object")
628627
}
629628

630629
fn math(&self) -> Result<Self::Math<'_>> {

src/pymc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ impl LogpError for ErrorCode {
112112
}
113113
}
114114

115-
impl<'a> CpuLogpFunc for &'a LogpFunc {
115+
impl CpuLogpFunc for &LogpFunc {
116116
type LogpError = ErrorCode;
117117
type TransformParams = ();
118118

@@ -175,7 +175,7 @@ impl<'model> DrawStorage for PyMcTrace<'model> {
175175
let num_arrays = data.len() / size;
176176
let data = Float64Array::from(data);
177177
let item_field = Arc::new(Field::new("item", DataType::Float64, false));
178-
let offsets = OffsetBuffer::from_lengths((0..num_arrays).into_iter().map(|_| size));
178+
let offsets = OffsetBuffer::from_lengths((0..num_arrays).map(|_| size));
179179
let array = LargeListArray::new(item_field.clone(), offsets, Arc::new(data), None);
180180
let field = Field::new(name, DataType::LargeList(item_field), false);
181181
(Arc::new(field), Arc::new(array) as Arc<dyn Array>)

src/stan.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ fn params(var_string: &str) -> anyhow::Result<Vec<Parameter>> {
137137
for (name, group) in &parsed_variables?.iter().chunk_by(|(name, _, _)| name) {
138138
// Find maximum shape and check if this is a complex variable
139139
let (shape, is_complex) = determine_variable_shape(group)
140-
.context(format!("Error while parsing stan variable {}", name))?;
140+
.context(format!("Error while parsing stan variable {name}"))?;
141141

142142
// Calculate total size of this variable
143143
let size = shape.iter().product();
@@ -146,7 +146,7 @@ fn params(var_string: &str) -> anyhow::Result<Vec<Parameter>> {
146146
// Create Parameter objects (one for real and one for imag if complex)
147147
if is_complex {
148148
variables.push(Parameter {
149-
name: format!("{}.real", name),
149+
name: format!("{name}.real"),
150150
shape: shape.clone(),
151151
size,
152152
start_idx,
@@ -155,7 +155,7 @@ fn params(var_string: &str) -> anyhow::Result<Vec<Parameter>> {
155155
start_idx = end_idx;
156156
end_idx = start_idx + size;
157157
variables.push(Parameter {
158-
name: format!("{}.imag", name),
158+
name: format!("{name}.imag"),
159159
shape,
160160
size,
161161
start_idx,

0 commit comments

Comments
 (0)