Skip to content

Commit

Permalink
Fix array major
Browse files Browse the repository at this point in the history
  • Loading branch information
lan496 committed Mar 10, 2024
1 parent ed6b718 commit f45cb8f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 9 deletions.
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ set positional-arguments
default:
just --list

build-python:
maturin develop --release --manifest-path moyo_py/Cargo.toml

install-python:
maturin develop --release --manifest-path moyo_py/Cargo.toml
pip install -e "moyo_py[dev]"
Expand Down
2 changes: 1 addition & 1 deletion moyo/tests/test_moyo_dataset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ fn test_with_wurtzite() {
let numbers = vec![0, 0, 1, 1];
let cell = Cell::new(lattice, positions, numbers);

let symprec = 1e-2;
let symprec = 1e-4;
let angle_tolerance = AngleTolerance::Default;
let setting = Setting::Standard;

Expand Down
2 changes: 1 addition & 1 deletion moyo_py/python/moyo/_moyo.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MoyoDataset:
def __init__(
self,
structure: Structure,
symprec: float = 1e-5,
symprec: float = 1e-4,
angle_tolerance: float | None = None,
setting: Setting | None = None,
): ...
Expand Down
12 changes: 9 additions & 3 deletions moyo_py/python/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,17 @@ def wurtzite() -> moyo.Structure:
[-a / 2.0, a * sqrt(3.0) / 2.0, 0.0],
[0.0, 0.0, c],
]
z1_2b = 0.00014
z2_2b = 0.37486
positions = [
[1 / 3, 2 / 3, 0.00014],
[1 / 3, 2 / 3, 0.37486],
# 2b
[1 / 3, 2 / 3, z1_2b],
[2 / 3, 1 / 3, z1_2b + 0.5],
# 2b
[1 / 3, 2 / 3, z2_2b],
[2 / 3, 1 / 3, z2_2b + 0.5],
]
numbers = [0, 1]
numbers = [0, 0, 1, 1]

structure = moyo.Structure(basis, positions, numbers)
return structure
3 changes: 2 additions & 1 deletion moyo_py/python/tests/test_moyo_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@


def test_moyo_dataset(wurtzite: moyo.Structure):
_dataset = moyo.MoyoDataset(wurtzite)
dataset = moyo.MoyoDataset(wurtzite)
assert dataset.number == 186
9 changes: 7 additions & 2 deletions moyo_py/src/base.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use nalgebra::{OMatrix, Vector3};
use nalgebra::{OMatrix, RowVector3, Vector3};
use pyo3::exceptions::PyValueError;
use pyo3::prelude::*;

Expand All @@ -24,7 +24,12 @@ impl PyStructure {
));
}

let lattice = Lattice::new(OMatrix::from(basis));
// let lattice = Lattice::new(OMatrix::from(basis));
let lattice = Lattice::new(OMatrix::from_rows(&[
RowVector3::from(basis[0]),
RowVector3::from(basis[1]),
RowVector3::from(basis[2]),
]));
let positions = positions
.iter()
.map(|x| Vector3::new(x[0], x[1], x[2]))
Expand Down
2 changes: 1 addition & 1 deletion moyo_py/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct PyMoyoDataset(MoyoDataset);
#[pymethods]
impl PyMoyoDataset {
#[new]
#[pyo3(signature = (structure, *, symprec=1e-5, angle_tolerance=None, setting=None))]
#[pyo3(signature = (structure, *, symprec=1e-4, angle_tolerance=None, setting=None))]
pub fn new(
structure: &PyStructure,
symprec: f64,
Expand Down

0 comments on commit f45cb8f

Please sign in to comment.