Skip to content

Commit

Permalink
Fixed all linting issues.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikmannerfelt committed Feb 25, 2025
1 parent 3e3cc9a commit ddd63a5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
8 changes: 3 additions & 5 deletions src/gpr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ impl GPR {
}
let mut new_traces = Vec::<usize>::new();
let parts: Vec<&str> = token.split('-').collect();
if let (Some(start_str), Some(end_str)) = (parts.get(0), parts.get(1)) {
if let (Some(start_str), Some(end_str)) = (parts.first(), parts.get(1)) {
if let (Ok(start), Ok(end)) =
(start_str.parse::<usize>(), end_str.parse::<usize>())
{
Expand Down Expand Up @@ -1242,10 +1242,8 @@ impl GPR {

// Make a vec of all traces to keep (faster to subset than to explicitly remove in ndarray)
// This is done before the index trick below, because the trick below is only needed for vecs.
let traces_to_keep: Vec<usize> = (0..width)
.into_iter()
.filter(|i| !unique_traces.contains(i))
.collect();
let traces_to_keep: Vec<usize> =
(0..width).filter(|i| !unique_traces.contains(i)).collect();

// Sort them, and then subtract the amount of removals that are done before this index.
// For example, if trace 0,1 and 2 should be removed, by the time the loop reaches 2, it's now the zeroth index.
Expand Down
27 changes: 8 additions & 19 deletions src/io.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/// Functions to handle input and output (I/O) of GPR data files.
use ndarray::{Array1, Array2};
use num::Float;
use rayon::prelude::*;
use std::collections::HashMap;
use std::error::Error;
Expand Down Expand Up @@ -214,26 +213,17 @@ pub fn export_netcdf(gpr: &gpr::GPR, nc_filepath: &Path) -> Result<(), Box<dyn s
// Add global attributes to the file
file.add_attribute(
"start-datetime",
chrono::DateTime::<chrono::Utc>::from_utc(
chrono::NaiveDateTime::from_timestamp_opt(
gpr.location.cor_points[0].time_seconds as i64,
0,
)
.unwrap(),
chrono::Utc,
)
.to_rfc3339(),
chrono::DateTime::from_timestamp(gpr.location.cor_points[0].time_seconds as i64, 0)
.unwrap()
.to_rfc3339(),
)?;
file.add_attribute(
"stop-datetime",
chrono::DateTime::<chrono::Utc>::from_utc(
chrono::NaiveDateTime::from_timestamp_opt(
gpr.location.cor_points[gpr.location.cor_points.len() - 1].time_seconds as i64,
0,
)
.unwrap(),
chrono::Utc,
chrono::DateTime::from_timestamp(
gpr.location.cor_points[gpr.location.cor_points.len() - 1].time_seconds as i64,
0,
)
.unwrap()
.to_rfc3339(),
)?;
file.add_attribute("processing-datetime", chrono::Local::now().to_rfc3339())?;
Expand Down Expand Up @@ -456,8 +446,7 @@ pub fn render_jpg(gpr: &gpr::GPR, filepath: &Path) -> Result<(), Box<dyn Error>>
/// # Arguments
/// - `gpr_locations`: The GPRLocation object to export
/// - `potential_track_path`: The output path of the track file or a directory (if provided)
/// - `output_filepath`: The output filepath to derive a track filepath from in case
/// `potential_track_path` was not provided
/// - `output_filepath`: The output filepath to derive a track filepath from in case `potential_track_path` was not provided.
/// - `verbose`: Print progress?
///
/// # Returns
Expand Down
9 changes: 3 additions & 6 deletions src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,9 @@ where
/// # Returns
/// A string representation of the datetime
pub fn seconds_to_rfc3339(seconds: f64) -> String {
chrono::DateTime::<chrono::Utc>::from_utc(
chrono::NaiveDateTime::from_timestamp_opt(seconds as i64, (seconds.fract() * 1e9) as u32)
.unwrap(),
chrono::Utc,
)
.to_rfc3339()
chrono::DateTime::from_timestamp(seconds as i64, (seconds.fract() * 1e9) as u32)
.unwrap()
.to_rfc3339()
}

/// Parse the options (arguments) of a user-supplied step
Expand Down

0 comments on commit ddd63a5

Please sign in to comment.