-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/iteration64' into develop
- Loading branch information
Showing
10 changed files
with
196 additions
and
47 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
rust_project/arc-competition/payload/.loda-rust/analytics-arc/last_analytics_timestamp.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2023-11-25T18:24:46Z | ||
2023-11-26T21:00:17Z |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "loda-rust-cli" | ||
version = "2023.11.25" | ||
version = "2023.11.26" | ||
authors = ["Simon Strandgaard <[email protected]>"] | ||
description = "Command line interface for LODA Rust" | ||
repository = "https://github.com/loda-lang/loda-rust" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use super::{Image, ImagePadding, convolution3x3, ImageHistogram, Histogram}; | ||
use anyhow::bail; | ||
|
||
pub struct MeasureDensity { | ||
pub density_any_direction: Image, | ||
} | ||
|
||
impl MeasureDensity { | ||
pub fn analyze(image: &Image) -> anyhow::Result<Self> { | ||
if image.is_empty() { | ||
bail!("image is empty. Must be 1x1 or larger"); | ||
} | ||
let padding: Image = image.padding_with_color(1, 255)?; | ||
let density: Image = convolution3x3(&padding, conv3x3_measure_density_any_direction)?; | ||
let instance = Self { | ||
density_any_direction: density, | ||
}; | ||
Ok(instance) | ||
} | ||
} | ||
|
||
fn conv3x3_measure_density_any_direction(image: &Image) -> anyhow::Result<u8> { | ||
let histogram: Histogram = image.histogram_all(); | ||
let center: u8 = image.get(1, 1).unwrap_or(255); | ||
let count: u32 = histogram.get(center).min(9).max(1) - 1; | ||
Ok(count as u8) | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
use crate::arc::ImageTryCreate; | ||
|
||
#[test] | ||
fn test_10000_density_any_direction() { | ||
// Arrange | ||
let pixels: Vec<u8> = vec![ | ||
5, 3, 3, 3, | ||
3, 3, 3, 3, | ||
5, 5, 3, 3, | ||
3, 5, 3, 3, | ||
]; | ||
let input: Image = Image::try_create(4, 4, pixels).expect("image"); | ||
|
||
// Act | ||
let actual: MeasureDensity = MeasureDensity::analyze(&input).expect("image"); | ||
|
||
// Assert | ||
let expected_pixels: Vec<u8> = vec![ | ||
0, 4, 5, 3, | ||
2, 5, 7, 5, | ||
2, 2, 6, 5, | ||
0, 2, 3, 3, | ||
]; | ||
let expected: Image = Image::try_create(4, 4, expected_pixels).expect("image"); | ||
assert_eq!(actual.density_any_direction, expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 120 additions & 38 deletions
158
rust_project/loda-rust-cli/src/arc/solve_logisticregression.rs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters