Skip to content

Conversation

montanalow
Copy link
Contributor

No description provided.

@montanalow montanalow merged commit 5aaac95 into master Sep 13, 2022
@montanalow montanalow deleted the montana/clippy branch September 13, 2022 17:11
}
match strategy {
Strategy::best_score => match task {
Task::regression => {
sql += &format!("{predicate}\nORDER BY models.metrics->>'r2' DESC NULLS LAST");
let _ = write!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What come on clippy, this seems totally fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

format! does an extra allocation compared to write... 🤷‍♂️

Some(limit) => Some(limit.try_into().unwrap()),
None => None,
};
let limit: Option<usize> = limit.map(|limit| limit.try_into().unwrap());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, turns out you can map things like this...

@@ -66,7 +66,7 @@ fn model_predict_batch(model_id: i64, features: Vec<f32>, num_rows: i32) -> Vec<

match guard.get(&model_id) {
Some(data) => {
let bst = Booster::load_buffer(&data).unwrap();
let bst = Booster::load_buffer(data).unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was a clippy warning? Should of been a compilation error...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compiler handles the extra dereference for you.

@@ -86,7 +90,7 @@ pub fn load_diabetes(limit: Option<usize>) -> (String, i64) {
None => diabetes.num_samples,
};
for i in 0..limit {
let age = diabetes.data[(i * diabetes.num_features) + 0];
let age = diabetes.data[(i * diabetes.num_features)];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah!

@@ -153,6 +157,7 @@ pub fn load_digits(limit: Option<usize>) -> (String, i64) {
let target = digits.target[i];
// shape the image in a 2d array
let mut image = vec![vec![0.; 8]; 8];
#[allow(clippy::needless_range_loop)] // x & y are in fact used
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, don't get me started with these haha! Rubocop was plenty, thank you

@@ -13,15 +13,16 @@ use crate::orm::Algorithm;
use crate::orm::Dataset;
use crate::orm::Task;

#[allow(clippy::type_complexity)]
Copy link
Contributor

@levkk levkk Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy needs to get it together.

.as_str(),
),
)
let task = Task::from_str(&task.unwrap_or_else(|| {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok what's up with these. Why does not like expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expect input is always executed which may have side effects or allocations. or_else is only executed if needed.

@@ -60,7 +60,7 @@ impl Model {
(PgBuiltInOids::JSONBOID.oid(), search_args.into_datum()),
])
).first();
if result.len() > 0 {
if !result.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

He got you there.

@@ -113,7 +113,7 @@ impl Snapshot {
Spi::connect(|client| {
let parts = self
.relation_name
.split(".")
.split('.')
Copy link
Contributor

@levkk levkk Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ummm. Those are completely different data types if you ask me. Although we may have just removed a heap allocation so that's cool.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, so why allocate the string if you can just use a char instead...

@@ -279,7 +279,7 @@ impl Snapshot {
(num_rows as f32 * self.test_size).round() as usize
};
let num_train_rows = num_rows - num_test_rows;
if num_train_rows <= 0 {
if num_train_rows == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clippy never heard of off-by-one errors? == 0 always made me paranoid.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's unsigned. Can't be < 0.

@montanalow montanalow restored the montana/clippy branch September 27, 2022 18:13
@montanalow montanalow deleted the montana/clippy branch September 27, 2022 18:14
SilasMarvin pushed a commit that referenced this pull request Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy