Skip to content

Commit

Permalink
fix clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
Tehforsch committed Sep 15, 2023
1 parent 1541204 commit 1e7b4c6
Show file tree
Hide file tree
Showing 17 changed files with 39 additions and 45 deletions.
4 changes: 2 additions & 2 deletions src/arepo_postprocess/remap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ impl<'a, 'w, 's> Remapper<'a, 'w, 's> {
let data = exchange_according_to_domain_decomposition(data, box_, decomposition);
let tree: Tree = (&data
.iter()
.map(|d| pos_to_tree_coord(&(*d.position)))
.map(|d| pos_to_tree_coord(&d.position))
.collect::<Vec<_>>())
.into();
let extents = exchange_extents(&data);
Expand Down Expand Up @@ -281,7 +281,7 @@ fn exchange_according_to_domain_decomposition(
let this_rank = comm.rank();
let world_size = comm.size();
for d in data {
let key = d.position.into_key(&*box_);
let key = d.position.into_key(box_);
let mut rank = decomposition.get_owning_rank(key);
// Sometimes the decomposition will return ranks outside of the range,
// because of lookup points outside the simulation box. Just keep these
Expand Down
4 changes: 2 additions & 2 deletions src/communication/exchange_communicator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl<T: 'static> ExchangeCommunicator<T> {
Self {
communicator,
pending_data,
_marker: PhantomData::default(),
_marker: PhantomData,
}
}
}
Expand All @@ -43,7 +43,7 @@ impl<T> From<Communicator<T>> for ExchangeCommunicator<T> {
Self {
communicator,
pending_data,
_marker: PhantomData::default(),
_marker: PhantomData,
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/communication/mpi_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl<T: 'static> MpiWorld<T> {
let tag = get_tag_for_type::<T>();
Self {
world,
_marker: PhantomData::default(),
_marker: PhantomData,
tag,
}
}
Expand All @@ -102,7 +102,7 @@ impl<T: 'static> MpiWorld<T> {
Self {
world,
tag,
_marker: PhantomData::default(),
_marker: PhantomData,
}
}
}
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<T> From<MpiWorld<T>> for MpiWorld<Identified<T>> {
fn from(other: MpiWorld<T>) -> Self {
Self {
world: other.world,
_marker: PhantomData::default(),
_marker: PhantomData,
tag: other.tag,
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cosmology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::units::Dimensionless;
use crate::units::Time;

#[raxiom_parameters("cosmology")]
#[derive(Copy, Named, Debug)]
#[derive(Named, Debug)]
#[serde(untagged)]
pub enum Cosmology {
Cosmological {
Expand Down
4 changes: 2 additions & 2 deletions src/domain/decomposition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ impl<K: Key> LoadCounter<K> for KeyCounter<K> {
}

fn min_key(&mut self) -> K {
self.keys.iter().min().unwrap().clone()
*self.keys.iter().min().unwrap()
}

fn max_key(&mut self) -> K {
self.keys.iter().max().unwrap().clone()
*self.keys.iter().max().unwrap()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/domain/exchange_data_plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub struct ExchangeDataPlugin<T> {
impl<T> Default for ExchangeDataPlugin<T> {
fn default() -> Self {
Self {
_marker: PhantomData::default(),
_marker: PhantomData,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/domain/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn domain_decomposition_system(
) {
info!("Starting domain decomposition");
let decomp =
get_decomposition_from_points_and_box(particles.iter().map(|x| **x), &*box_, **world_size);
get_decomposition_from_points_and_box(particles.iter().map(|x| **x), &box_, **world_size);
decomp.log_imbalance();
commands.insert_resource(decomp);
}
Expand Down
18 changes: 9 additions & 9 deletions src/io/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ pub struct Reader {

impl Reader {
/// Construct a reader with the contents of the files split evenly between the ranks.
pub fn split_between_ranks<'a, U: AsRef<Path>>(paths: impl Iterator<Item = U>) -> Self {
pub fn split_between_ranks<U: AsRef<Path>>(paths: impl Iterator<Item = U>) -> Self {
let t: Communicator<usize> = Communicator::new();
let rank = t.rank();
let num_ranks = t.size();
Expand All @@ -189,7 +189,7 @@ impl Reader {
}

/// Construct a reader for the contents of all files.
pub fn full<'a, U: AsRef<Path>>(paths: impl Iterator<Item = U>) -> Self {
pub fn full<U: AsRef<Path>>(paths: impl Iterator<Item = U>) -> Self {
let rank = 0;
let num_ranks = 1;
Self {
Expand All @@ -211,7 +211,7 @@ impl Reader {
let num_entries = self
.files
.iter()
.map(|f| self.get_num_entries(dataset_name, &f))
.map(|f| self.get_num_entries(dataset_name, f))
.collect::<Vec<_>>();
get_rank_assignment_for_rank(&num_entries, self.num_ranks, self.rank)
}
Expand All @@ -229,22 +229,22 @@ impl Reader {
})
}

pub fn read_dataset<'a, T: ToDataset + Named>(
&'a self,
pub fn read_dataset<T: ToDataset + Named>(
&'_ self,
descriptor: InputDatasetDescriptor<T>,
) -> impl Iterator<Item = T> + 'a {
) -> impl Iterator<Item = T> + '_ {
let assignment = self.get_assignment(descriptor.dataset_name());
assignment
.regions
.into_iter()
.flat_map(move |region| self.read_region(descriptor.clone(), &region))
}

pub fn read_dataset_chunked<'a, 'b, T>(
&'a self,
pub fn read_dataset_chunked<T>(
&'_ self,
descriptor: InputDatasetDescriptor<T>,
chunk_size: usize,
) -> impl Iterator<Item = T> + 'a
) -> impl Iterator<Item = T> + '_
where
T: ToDataset + Named,
{
Expand Down
2 changes: 1 addition & 1 deletion src/io/output/attribute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ macro_rules! impl_attribute {
}
}

impl crate::io::input::attribute::FromAttribute for $name {
impl $crate::io::input::attribute::FromAttribute for $name {
fn from_value(val: <Self as ToAttribute>::Output) -> Self {
Self(val)
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn main() {
InputDatasetDescriptor::<InternalEnergy> {
descriptor: DatasetDescriptor {
dataset_name: "PartType0/InternalEnergy".into(),
unit_reader: unit_reader,
unit_reader,
},
..Default::default()
},
Expand Down
2 changes: 1 addition & 1 deletion src/parameter_plugin/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct ParameterPlugin<T> {
impl<T> Default for ParameterPlugin<T> {
fn default() -> Self {
Self {
_marker: PhantomData::default(),
_marker: PhantomData,
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/performance_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ impl Result {
.sum()
}

fn into_value(&self) -> Value {
fn as_value(&self) -> Value {
match self {
Result::RunTimes(run_times) => serde_yaml::to_value(&Statistics::new(run_times)),
Result::Number(num) => serde_yaml::to_value(&num),
Result::RunTimes(run_times) => serde_yaml::to_value(Statistics::new(run_times)),
Result::Number(num) => serde_yaml::to_value(num),
}
.unwrap()
}
Expand Down Expand Up @@ -132,18 +132,18 @@ impl Timers {
};
}

pub(crate) fn time<'a, N: Into<String> + Clone>(&'a mut self, name: N) -> TimerGuard<'a, N> {
pub(crate) fn time<N: Into<String> + Clone>(&mut self, name: N) -> TimerGuard<'_, N> {
self.start(name.clone());
TimerGuard { data: self, name }
}

pub fn into_output(&self) -> LinkedHashMap<Category, Value> {
pub fn as_output(&self) -> LinkedHashMap<Category, Value> {
let mut names: Vec<_> = self.results.iter().map(|(name, _)| name.clone()).collect();
names.sort();
names
.into_iter()
.map(move |name| {
let result = self.results[&name].into_value();
let result = self.results[&name].as_value();
(name, result)
})
.collect()
Expand All @@ -170,7 +170,7 @@ pub fn write_performance_data_system(
parameters
.output_dir
.join(&parameters.performance_data_filename),
serde_yaml::to_string(&timers.into_output()).unwrap(),
serde_yaml::to_string(&timers.as_output()).unwrap(),
)
.unwrap_or_else(|e| panic!("Failed to write performance data to file. {}", e));
}
2 changes: 1 addition & 1 deletion src/simulation_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ impl SimulationBuilder {
sim.add_bevy_plugin(bevy_core::CorePlugin {
task_pool_options: self.task_pool_opts(),
})
.add_bevy_plugin(bevy_app::ScheduleRunnerPlugin::default());
.add_bevy_plugin(bevy_app::ScheduleRunnerPlugin);
}

fn task_pool_opts(&self) -> TaskPoolOptions {
Expand Down
4 changes: 2 additions & 2 deletions src/stages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ pub fn create_schedule() -> Schedule {
StartupStages::Final.as_label(),
];
let mut startup_schedule = Schedule::default().with_run_criteria(ShouldRun::once);
make_schedule_from_stage_labels(&mut startup_schedule, &startup_stages);
make_schedule_from_stage_labels(&mut startup_schedule, startup_stages);
schedule.add_stage(StartupSchedule, startup_schedule);
make_schedule_from_stage_labels(&mut schedule, &stages);
make_schedule_from_stage_labels(&mut schedule, stages);
schedule
}

Expand Down
10 changes: 2 additions & 8 deletions src/sweep/grid/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,11 @@ pub enum ParticleType {

impl ParticleType {
pub fn is_boundary(&self) -> bool {
match self {
Self::Boundary => true,
_ => false,
}
matches!(self, Self::Boundary)
}

pub fn is_local(&self) -> bool {
match self {
Self::Local(_) => true,
_ => false,
}
matches!(self, Self::Local(_))
}

pub fn unwrap_id(&self) -> ParticleId {
Expand Down
4 changes: 2 additions & 2 deletions src/sweep/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl<C: Chemistry> Sweep<C> {
halo_levels,
to_solve: PriorityQueue::new(),
to_send: DataByRank::from_size_and_rank(world_size, world_rank),
directions: directions.clone(),
directions,
to_solve_count: CountByDir::empty(),
to_receive_count: DataByRank::empty(),
timestep_safety_factor,
Expand Down Expand Up @@ -472,7 +472,7 @@ impl<C: Chemistry> Sweep<C> {
neighbour: ParticleId,
) {
let site = self.sites.get_mut(neighbour);
site.periodic_source[*dir] += incoming_rate_correction.clone();
site.periodic_source[*dir] += incoming_rate_correction;
}

fn handle_remote_neighbour(
Expand Down
2 changes: 1 addition & 1 deletion src/voronoi/constructor/parallel/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub fn construct_grid_system(
num_relevant_haloes += 1;
let pos = cons.get_position_for_cell(cell_index);
let pos = VecLength::new_unchecked(pos);
commands.spawn((HaloParticle { rank: rank }, Position(pos), id));
commands.spawn((HaloParticle { rank }, Position(pos), id));
}
};
for (cell_index, cell) in cons.sweep_grid(sweep_parameters.periodic) {
Expand Down

0 comments on commit 1e7b4c6

Please sign in to comment.