Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/v0.3.0 #62

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
lint corrections
  • Loading branch information
ABouttefeux committed Sep 2, 2023
commit 51f1e0d693e8430aec93eb6d093f56e8a6b29612
12 changes: 6 additions & 6 deletions .github/workflows/benches.yml
Original file line number Diff line number Diff line change
@@ -12,8 +12,8 @@ jobs:
bench:
name: Run checks for Lattice QCD rs
runs-on: ubuntu-latest
env:
CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
# env:
# CRITERION_TOKEN: ${{ secrets.CRITERION_TOKEN }}
steps:
- name: Checkout
uses: actions/checkout@v2
@@ -25,7 +25,7 @@ jobs:
run: |
# run benchmarks and save baseline in a directory called "new"
cargo bench
- name: Upload benchmarks
run: |
# upload the files
bash <(curl -s https://criterion.dev/bash)
# - name: Upload benchmarks
# run: |
# # upload the files
# bash <(curl -s https://criterion.dev/bash)
4 changes: 2 additions & 2 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -29,8 +29,8 @@ jobs:
run: |
export RUSTFLAGS="-Zinstrument-coverage"
export RUSTDOCFLAGS="-Zinstrument-coverage -Zunstable-options --persist-doctests target/debug/doctestbins"
cargo +nightly build --verbose --all --features="no-overflow-test","serde-serialize"
LLVM_PROFILE_FILE="lattice_qcd_rs-%p-%m.profraw" cargo +nightly test --verbose --features="no-overflow-test","serde-serialize" --workspace --exclude lattice_qcd_rs-procedural_macro
cargo +nightly build --verbose --all --no-default-features --features="serde-serialize"
LLVM_PROFILE_FILE="lattice_qcd_rs-%p-%m.profraw" cargo +nightly test --verbose --no-default-features --features="serde-serialize" --workspace --exclude lattice_qcd_rs-procedural_macro

- name: parse code coverage
run: ./grcov . --binary-path ./target/debug/ -s . -t lcov --branch --ignore-not-existing --ignore "/*" -o lcov.info
4 changes: 2 additions & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ jobs:
run: cargo test --all --verbose --features serde-serialize

- name: Build no features
run: cargo build --all --verbose --no-default-features
run: cargo build --all --verbose --no-default-features --features overflow-test

- name: Run tests no features
run: cargo test --all --verbose --no-default-features
run: cargo test --all --verbose --no-default-features --features overflow-test
4 changes: 2 additions & 2 deletions .github/workflows/rust_beta.yml
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ jobs:
run: cargo test --all --verbose --features serde-serialize

- name: Build beta no features
run: cargo build --all --verbose --no-default-features
run: cargo build --all --verbose --no-default-features --features overflow-test

- name: Run tests beta no features
run: cargo test --all --verbose --no-default-features
run: cargo test --all --verbose --no-default-features --features overflow-test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -11,3 +11,4 @@ Cargo.lock
data/
.vscode/settings.json
logo.png
rust-toolchain.toml
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@

# v0.3.0

## breaking changes
- [`SymplecticEulerError`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/integrator/symplectic_euler/enum.SymplecticEulerError.html) is now marked `#[non_exhaustive]`
- change the feature "no-overflow-test" to "overflow-test" and enabling "overflow-test" by default

## non breaking
- update dependencies
- remove the extern crate declaration in lib.rs
- correct documentation

# v0.2.1

13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -10,20 +10,24 @@ description = "Lattice QCD simulation"
keywords = ["QCD", "Lattice", "Monte-Carlo", "chromodynamics"]
publish = true
license = "MIT OR Apache-2.0"
rust-version = "1.61"
rust-version = "1.72"


[lib]
path = "src/lib.rs"
crate-type = ["lib"]


[features]
serde-serialize = ["dep:serde", "nalgebra/serde-serialize"]
no-overflow-test = []
default = ["serde-serialize"]
overflow-test = []
default = ["serde-serialize", "overflow-test"]


[workspace]
members = ["procedural_macro"]


[dependencies]
nalgebra = { version = "0.32", features = ["serde-serialize"] }
approx = "0.5.1"
@@ -35,15 +39,18 @@ rayon = "1.7"
serde = { version = "1.0", features = ["derive"], optional = true }
lattice_qcd_rs-procedural_macro = { path = "procedural_macro", version = "0.3.0" }


[dev-dependencies]
criterion = "0.5.1"
version-sync = "0.9.4"


[[bench]]
name = "bench"
path = "benches/bench.rs"
harness = false


[profile.test]
opt-level = 2 # in order to have resonable test time

2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
@@ -199,7 +199,7 @@ fn criterion_benchmark(c: &mut Criterion) {
LatticeStateDefault::<4>::new_determinist(1_f64, 1_f64, *i, &mut rng).unwrap();
let d = rand_distr::Normal::new(0.0, 0.5_f64).unwrap();
let e_field = EField::new_determinist(state.lattice(), &mut rng, &d);
e_field.project_to_gauss(state.link_matrix(), state.lattice());
let _ = e_field.project_to_gauss(state.link_matrix(), state.lattice());
})
});
}
1 change: 1 addition & 0 deletions clippy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
avoid-breaking-exported-api = false
7 changes: 5 additions & 2 deletions procedural_macro/Cargo.toml
Original file line number Diff line number Diff line change
@@ -3,10 +3,13 @@ name = "lattice_qcd_rs-procedural_macro"
version = "0.3.0"
authors = ["Aliénore Bouttefeux <alienore.bouttefeux@gmail.com>"]
edition = "2021"
description = "Set of procedural macro for the main library lattice_qcd_rs"
readme = "README.md"
repository = "https://github.com/ABouttefeux/lattice-qcd-rs/"
license = "MIT OR Apache-2.0"
categories = ["Science", "Simulation"]
description = "Set of procedural macro for the main library lattice_qcd_rs"
keywords = ["QCD", "Lattice", "Monte-Carlo", "chromodynamics", "macro"]
publish = true
license = "MIT OR Apache-2.0"

[lib]
proc-macro = true
146 changes: 120 additions & 26 deletions procedural_macro/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,130 @@
#![doc = include_str!("../README.md")]
#![doc(html_root_url = "https://docs.rs/lattice_qcd_rs-procedural_macro/0.3.0")]
//
#![allow(clippy::needless_return)]
#![warn(clippy::cast_sign_loss)]
#![warn(clippy::cast_possible_truncation)]
#![warn(clippy::cast_possible_wrap)]
#![warn(clippy::pedantic)]
#![warn(clippy::cargo)]
//
#![warn(clippy::absolute_paths)]
#![warn(clippy::allow_attributes)] // attributes
#![warn(clippy::allow_attributes_without_reason)] //attributes
#![warn(clippy::as_underscore)]
#![warn(clippy::assertions_on_result_states)]
#![warn(clippy::branches_sharing_code)]
#![warn(clippy::clear_with_drain)]
#![warn(clippy::clone_on_ref_ptr)]
#![warn(clippy::cognitive_complexity)]
#![warn(clippy::collection_is_never_read)]
#![warn(clippy::create_dir)]
#![warn(clippy::debug_assert_with_mut_call)]
#![warn(clippy::decimal_literal_representation)]
#![warn(clippy::default_numeric_fallback)]
#![warn(clippy::default_union_representation)]
#![warn(clippy::disallowed_script_idents)] // cspell: ignore idents
#![warn(clippy::empty_drop)]
#![warn(clippy::empty_line_after_doc_comments)]
#![warn(clippy::empty_line_after_outer_attr)]
#![warn(clippy::empty_structs_with_brackets)]
#![warn(clippy::equatable_if_let)]
#![warn(clippy::error_impl_error)]
#![warn(clippy::exhaustive_enums)]
#![warn(clippy::fallible_impl_from)]
#![warn(clippy::filetype_is_file)]
#![warn(clippy::float_cmp_const)]
#![warn(clippy::implicit_hasher)]
#![warn(clippy::fn_to_numeric_cast_any)]
#![warn(clippy::format_push_string)]
#![warn(clippy::if_then_some_else_none)]
#![warn(clippy::impl_trait_in_params)]
#![warn(clippy::implicit_saturating_sub)]
#![warn(clippy::imprecise_flops)]
#![warn(clippy::large_types_passed_by_value)]
#![warn(clippy::macro_use_imports)]
#![warn(clippy::manual_ok_or)]
#![warn(clippy::iter_on_empty_collections)]
#![warn(clippy::iter_on_single_items)]
#![warn(clippy::iter_with_drain)]
#![warn(clippy::large_include_file)]
#![warn(clippy::large_stack_frames)]
#![warn(clippy::let_underscore_must_use)]
#![warn(clippy::let_underscore_untyped)]
#![warn(clippy::lossy_float_literal)]
#![warn(clippy::manual_clamp)]
#![deny(clippy::exit)] // deny
#![warn(clippy::future_not_send)]
//#![warn(clippy::mem_forget)] // memory, mistake allow
#![warn(clippy::map_err_ignore)]
#![warn(clippy::map_unwrap_or)]
#![warn(clippy::match_wildcard_for_single_variants)]
#![warn(clippy::missing_assert_message)]
#![warn(clippy::missing_const_for_fn)]
#![warn(clippy::needless_pass_by_value)]
#![warn(clippy::missing_enforced_import_renames)]
#![warn(clippy::missing_inline_in_public_items)]
#![warn(clippy::mixed_read_write_in_expression)]
// #![warn(clippy::module_name_repetitions)] // allow
// #![warn(clippy::multiple_unsafe_ops_per_block)]
#![warn(clippy::mutex_atomic)]
#![warn(clippy::mutex_integer)]
#![warn(clippy::needless_collect)]
#![warn(clippy::needless_raw_strings)]
#![warn(clippy::nonstandard_macro_braces)]
#![warn(clippy::non_ascii_literal)]
#![warn(clippy::semicolon_if_nothing_returned)]
#![warn(clippy::suboptimal_flops)]
#![warn(clippy::todo)]
#![warn(clippy::trivially_copy_pass_by_ref)]
#![warn(clippy::type_repetition_in_bounds)]
#![warn(clippy::unreadable_literal)]
#![warn(clippy::unseparated_literal_suffix)]
#![warn(clippy::unused_self)]
#![warn(clippy::unnecessary_wraps)]
#![warn(clippy::missing_errors_doc)]
#![warn(missing_docs)]
#![forbid(unsafe_code)]

#![warn(clippy::option_if_let_else)]
#![warn(clippy::or_fun_call)]
#![warn(clippy::path_buf_push_overwrite)]
// #![warn(clippy::pattern_type_mismatch)] // maybe
// #![warn(clippy::ptr_as_ptr)] // allowed ?
#![warn(clippy::pub_without_shorthand)] // style choice
#![warn(clippy::rc_buffer)]
#![warn(clippy::rc_mutex)]
#![warn(clippy::readonly_write_lock)]
#![warn(clippy::redundant_clone)]
#![warn(clippy::redundant_pub_crate)]
#![warn(clippy::redundant_type_annotations)]
#![warn(clippy::rest_pat_in_fully_bound_structs)]
#![warn(clippy::same_name_method)]
#![deny(clippy::self_named_module_files)] // style, file
//#![deny(clippy::mod_module_files)]
#![warn(clippy::semicolon_outside_block)] // style
// cspell: ignore scrutinee
#![warn(clippy::significant_drop_in_scrutinee)] // maybe ?
#![warn(clippy::significant_drop_tightening)] // maybe ?
#![warn(clippy::str_to_string)] // style
#![warn(clippy::string_add)] // restriction, style
#![warn(clippy::string_lit_chars_any)] // perf
#![warn(clippy::string_to_string)] // mistake
#![warn(clippy::suboptimal_flops)] // precision
#![warn(clippy::suspicious_operation_groupings)] // mistake
#![warn(clippy::suspicious_xor_used_as_pow)] // mistake
#![warn(clippy::tests_outside_test_module)] // mistake, perf, readability
#![warn(clippy::todo)] // reminder
#![warn(clippy::trailing_empty_array)] // mistake
#![warn(clippy::trait_duplication_in_bounds)] // mistake, readability
// cspell: ignore repr
#![warn(clippy::transmute_undefined_repr)] // safety
#![warn(clippy::trivial_regex)] // perf, mistake
#![warn(clippy::try_err)] // restriction. style
#![warn(clippy::tuple_array_conversions)] // style
#![warn(clippy::type_repetition_in_bounds)] // style, mistake
#![warn(clippy::undocumented_unsafe_blocks)] // Doc
#![warn(clippy::unimplemented)] // reminder
#![warn(clippy::unnecessary_self_imports)] // style
#![warn(clippy::unnecessary_struct_initialization)] // style , readability
// cspell: ignore unseparated
#![warn(clippy::unseparated_literal_suffix)] // style
// cspell: ignore peekable
#![warn(clippy::unused_peekable)] // mistake
#![warn(clippy::unused_rounding)] // mistake, readability
#![warn(clippy::unwrap_in_result)] // mistake, error propagation
#![warn(clippy::unwrap_used)] // allow ? style
#![warn(clippy::use_debug)] // debug removing
#![warn(clippy::use_self)] // style
#![warn(clippy::useless_let_if_seq)] // style
#![warn(clippy::verbose_file_reads)]
//
//---------------
// doc
#![warn(missing_docs)] // doc
#![warn(clippy::missing_docs_in_private_items)] // doc
#![deny(unsafe_code)]
//---------------
// allow
#![allow(clippy::module_name_repetitions)]

/// Only contains the version test.
#[cfg(test)]
@@ -45,10 +139,10 @@ const MAX_DIM: usize = 127;
/// Implement [`DirectionList`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/trait.DirectionList.html)
/// for [`Direction`](https://abouttefeux.github.io/lattice-qcd-rs/lattice_qcd_rs/lattice/struct.Direction.html) of `1` to `127` the value of `MAX_DIM`.
///
/// Using const generics might render this unnecessary. Waiting for stabilization of feature(generic_const_exprs).
/// Using const generics might render this unnecessary. Waiting for stabilization of `feature(generic_const_exprs)`.
#[proc_macro]
pub fn implement_direction_list(_item: TokenStream) -> TokenStream {
let mut implem = Vec::with_capacity(MAX_DIM);
let mut implem = Vec::with_capacity(MAX_DIM); // cspell: ignore implem implems

// creation of the vec containing the directions.
for i in 1_usize..=MAX_DIM {
@@ -64,9 +158,9 @@ pub fn implement_direction_list(_item: TokenStream) -> TokenStream {
});
}
//let u_ident = syn::Ident::new(&format!("U{}", i), proc_macro2::Span::call_site());
let u_dir_ident = syn::Ident::new(&format!("U{}_DIR", i), proc_macro2::Span::call_site());
let u_dir_ident = syn::Ident::new(&format!("U{i}_DIR"), proc_macro2::Span::call_site());
let u_dir_pos_ident =
syn::Ident::new(&format!("U{}_DIR_POS", i), proc_macro2::Span::call_site());
syn::Ident::new(&format!("U{i}_DIR_POS"), proc_macro2::Span::call_site());
// we store the values in array so we can access them as fast as possible.
let s = quote! {
const #u_dir_ident: [Direction<#i>; #i * 2] = [ #(#array_direction),* ];
2 changes: 1 addition & 1 deletion rustfmt.toml
Original file line number Diff line number Diff line change
@@ -5,4 +5,4 @@ group_imports = "StdExternalCrate"
unstable_features = true
use_field_init_shorthand = true
wrap_comments = false
control_brace_style = "ClosingNextLine"
control_brace_style = "AlwaysSameLine"
Loading