Skip to content

Commit

Permalink
Merge pull request #74 from spglib/bump-up-crates
Browse files Browse the repository at this point in the history
Bump up nalgebra and other crates
  • Loading branch information
lan496 authored Feb 12, 2025
2 parents a529810 + 1864dc7 commit 720ee91
Show file tree
Hide file tree
Showing 15 changed files with 317 additions and 301 deletions.
438 changes: 223 additions & 215 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ license = "MIT OR Apache-2.0"
repository = "https://github.com/spglib/moyo"

[workspace.dependencies]
nalgebra = { version = "0.32", features = ["serde-serialize"] }
nalgebra = { version = "0.33", features = ["serde-serialize"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
approx = "0.5"
Expand Down
8 changes: 8 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,18 @@ clean:
# Rust
################################################################################

[group('rust')]
test:
cargo test

[group('rust')]
doc:
cargo doc --open

[group('rust')]
upgrade:
cargo upgrade -i

[group('rust')]
[working-directory: 'moyo']
profile:
Expand Down
14 changes: 7 additions & 7 deletions moyo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ serde.workspace = true
serde_json.workspace = true
approx.workspace = true
log.workspace = true
itertools = "0.13"
thiserror = "1.0"
itertools = "0.14"
thiserror = "2.0"
union-find = "0.4"
strum = "0.25"
strum_macros = "0.25"
strum = "0.27"
strum_macros = "0.27"
kiddo = "5.0.3"
once_cell = "1.20.2"
once_cell = "1.20.3"

[dev-dependencies]
rand = "0.8"
rstest = "0.18"
rand = "0.9"
rstest = "0.24"
criterion = { version = "0.5", features = ["html_reports"] }
env_logger = "0.11"
test-log = "0.2"
Expand Down
4 changes: 2 additions & 2 deletions moyo/src/math/cycle_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use nalgebra::{DefaultAllocator, Dim, OMatrix};
#[derive(Debug)]
pub struct CycleChecker<N: Dim>
where
DefaultAllocator: Allocator<i32, N, N>,
DefaultAllocator: Allocator<N, N>,
{
visited: HashSet<OMatrix<i32, N, N>>,
}

impl<N: Dim> CycleChecker<N>
where
DefaultAllocator: Allocator<i32, N, N>,
DefaultAllocator: Allocator<N, N>,
{
pub fn new() -> Self {
Self {
Expand Down
36 changes: 18 additions & 18 deletions moyo/src/math/delaunay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ mod tests {

for _ in 0..256 {
let basis = Matrix3::<f64>::new(
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
);
let (reduced_basis, trans_mat) = delaunay_reduce(&basis);
assert_relative_eq!(
Expand All @@ -146,15 +146,15 @@ mod tests {

for _ in 0..256 {
let basis = Matrix3::<f64>::new(
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
);
let (reduced_basis, trans_mat) = delaunay_reduce(&basis);
assert_relative_eq!(
Expand Down
6 changes: 3 additions & 3 deletions moyo/src/math/elementary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use nalgebra::{DefaultAllocator, Dim, OMatrix};
/// Return elementary matrix swapping the `col1`th and `col2`th columns
pub fn swapping_column_matrix<D: Dim>(dim: D, col1: usize, col2: usize) -> OMatrix<i32, D, D>
where
DefaultAllocator: Allocator<i32, D, D>,
DefaultAllocator: Allocator<D, D>,
{
let mut trans_mat = OMatrix::zeros_generic(dim, dim);
for i in 0..dim.value() {
Expand All @@ -22,7 +22,7 @@ where
/// Return elementary matrix adding the `k`-multiplied `col1`th column into the `col2`th column
pub fn adding_column_matrix<D: Dim>(dim: D, col1: usize, col2: usize, k: i32) -> OMatrix<i32, D, D>
where
DefaultAllocator: Allocator<i32, D, D>,
DefaultAllocator: Allocator<D, D>,
{
let mut trans_mat = OMatrix::identity_generic(dim, dim);
for i in 0..dim.value() {
Expand All @@ -36,7 +36,7 @@ where
/// Return elementary matrix changing sign of the `col`th column
pub fn changing_column_sign_matrix<D: Dim>(dim: D, col: usize) -> OMatrix<i32, D, D>
where
DefaultAllocator: Allocator<i32, D, D>,
DefaultAllocator: Allocator<D, D>,
{
let mut trans_mat = OMatrix::identity_generic(dim, dim);
trans_mat[(col, col)] = -1;
Expand Down
10 changes: 5 additions & 5 deletions moyo/src/math/hnf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ use super::elementary::{
#[allow(clippy::upper_case_acronyms)]
pub struct HNF<M: Dim, N: Dim>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<N, N>,
{
pub h: OMatrix<i32, M, N>,
pub r: OMatrix<i32, N, N>,
}

impl<M: Dim, N: Dim> HNF<M, N>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<N, N>,
{
/// Return column-wise Hermite norm form
pub fn new(basis: &OMatrix<i32, M, N>) -> Self {
Expand Down Expand Up @@ -133,13 +133,13 @@ mod tests {
let mut rng: StdRng = SeedableRng::from_seed([0; 32]);

for _ in 0..256 {
let m = SMatrix::<i32, 3, 3>::from_fn(|_, _| rng.gen_range(-4..4));
let m = SMatrix::<i32, 3, 3>::from_fn(|_, _| rng.random_range(-4..4));
let _ = HNF::new(&m);

let m = SMatrix::<i32, 5, 7>::from_fn(|_, _| rng.gen_range(-4..4));
let m = SMatrix::<i32, 5, 7>::from_fn(|_, _| rng.random_range(-4..4));
let _ = HNF::new(&m);

let m = SMatrix::<i32, 7, 5>::from_fn(|_, _| rng.gen_range(-4..4));
let m = SMatrix::<i32, 7, 5>::from_fn(|_, _| rng.random_range(-4..4));
let _ = HNF::new(&m);
}
}
Expand Down
7 changes: 3 additions & 4 deletions moyo/src/math/integer_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::snf::SNF;
#[derive(Debug)]
pub struct IntegerLinearSystem<N: Dim>
where
DefaultAllocator: Allocator<i32, N>,
DefaultAllocator: Allocator<N>,
{
/// rank of the integer linear system
#[allow(dead_code)]
Expand All @@ -20,14 +20,13 @@ where

impl<N: Dim> IntegerLinearSystem<N>
where
DefaultAllocator: Allocator<i32, N>,
DefaultAllocator: Allocator<N>,
{
/// Solve a * x = b
/// If no solution, return None
pub fn new<M: DimMin<N>>(a: &OMatrix<i32, M, N>, b: &OVector<i32, M>) -> Option<Self>
where
DefaultAllocator:
Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N> + Allocator<i32, M>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N> + Allocator<M>,
{
let (_, n) = a.shape_generic();
let snf = SNF::new(a);
Expand Down
38 changes: 19 additions & 19 deletions moyo/src/math/minkowski.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn minkowski_reduce_greedy<N: Dim + DimName>(
trans_mat: &mut OMatrix<i32, N, N>,
rank: usize,
) where
DefaultAllocator: Allocator<f64, N, N> + Allocator<i32, N, N> + Allocator<f64, N>,
DefaultAllocator: Allocator<N, N> + Allocator<N, N> + Allocator<N>,
{
// Line 1: exit condition
if rank == 1 {
Expand Down Expand Up @@ -213,15 +213,15 @@ mod tests {

for _ in 0..256 {
let basis = Matrix3::<f64>::new(
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
);
let (reduced_basis, trans_mat) = minkowski_reduce(&basis);
assert!(is_minkowski_reduced(&reduced_basis));
Expand All @@ -230,15 +230,15 @@ mod tests {

for _ in 0..256 {
let basis = Matrix3::<f64>::new(
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
);
let (reduced_basis, trans_mat) = minkowski_reduce(&basis);
assert!(is_minkowski_reduced(&reduced_basis));
Expand Down
36 changes: 18 additions & 18 deletions moyo/src/math/niggli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,15 +471,15 @@ mod tests {

for _ in 0..256 {
let basis = Matrix3::<f64>::new(
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.gen::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
rng.random::<i8>() as f64,
);
let (reduced_basis, trans_mat) = niggli_reduce(&basis);

Expand All @@ -489,15 +489,15 @@ mod tests {

for _ in 0..256 {
let basis = Matrix3::<f64>::new(
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.gen(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
rng.random(),
);
let (reduced_basis, trans_mat) = niggli_reduce(&basis);
assert!(is_niggli_reduced(&reduced_basis));
Expand Down
12 changes: 6 additions & 6 deletions moyo/src/math/snf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use nalgebra::{DefaultAllocator, Dim, DimMin, OMatrix};
#[allow(clippy::upper_case_acronyms)]
pub struct SNF<M: DimMin<N>, N: Dim>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N>,
{
pub d: OMatrix<i32, M, N>,
pub l: OMatrix<i32, M, M>,
Expand All @@ -15,11 +15,11 @@ where

impl<M: DimMin<N>, N: Dim> SNF<M, N>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N>,
{
pub fn new(basis: &OMatrix<i32, M, N>) -> SNF<M, N>
where
DefaultAllocator: Allocator<i32, M, N> + Allocator<i32, M, M> + Allocator<i32, N, N>,
DefaultAllocator: Allocator<M, N> + Allocator<M, M> + Allocator<N, N>,
{
let (m, n) = basis.shape_generic();
let mut d = basis.clone();
Expand Down Expand Up @@ -133,13 +133,13 @@ mod tests {
let mut rng: StdRng = SeedableRng::from_seed([0; 32]);

for _ in 0..256 {
let m = SMatrix::<i32, 3, 3>::from_fn(|_, _| rng.gen_range(-4..4));
let m = SMatrix::<i32, 3, 3>::from_fn(|_, _| rng.random_range(-4..4));
let _ = SNF::new(&m);

let m = SMatrix::<i32, 5, 7>::from_fn(|_, _| rng.gen_range(-4..4));
let m = SMatrix::<i32, 5, 7>::from_fn(|_, _| rng.random_range(-4..4));
let _ = SNF::new(&m);

let m = SMatrix::<i32, 7, 5>::from_fn(|_, _| rng.gen_range(-4..4));
let m = SMatrix::<i32, 7, 5>::from_fn(|_, _| rng.random_range(-4..4));
let _ = SNF::new(&m);
}
}
Expand Down
4 changes: 2 additions & 2 deletions moyopy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ serde.workspace = true
serde_json.workspace = true
approx.workspace = true
log.workspace = true
pyo3-log = "0.10"
pyo3-log = "0.12"

[dependencies.pyo3]
version = "0.21"
version = "0.23"
features = ["abi3-py39"]
2 changes: 1 addition & 1 deletion moyopy/python/moyopy/_data.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ class MagneticSpaceGroupType:
def construct_type(self) -> int:
"""Construct type of magnetic space group from 1 to 4."""

def operations_from_number(number: int, setting: Setting) -> Operations: ...
def operations_from_number(number: int, *, setting: Setting | None = None) -> Operations: ...
1 change: 1 addition & 0 deletions moyopy/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use moyo::base::{MoyoError, Operation};
use moyo::data::{hall_symbol_entry, HallSymbol, Setting};

#[pyfunction]
#[pyo3(signature = (number, *, setting=None))]
pub fn operations_from_number(
number: i32,
setting: Option<PySetting>,
Expand Down

0 comments on commit 720ee91

Please sign in to comment.