Skip to content

Commit

Permalink
initialization and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleQianliMa committed Jan 9, 2025
1 parent 0951f38 commit c760b9c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
26 changes: 13 additions & 13 deletions src/hyspecppt/hppt/hppt_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@
import numpy as np
from scipy.constants import e, hbar, m_n

from .experiment_settings import DEFAULT_EXPERIMENT, PLOT_TYPES, MaxQ
from .experiment_settings import DEFAULT_CROSSHAIR, DEFAULT_EXPERIMENT, DEFAULT_LATTICE, DEFAULT_MODE, PLOT_TYPES, MaxQ

logger = logging.getLogger("hyspecppt")


class SingleCrystalParameters:
"""Model for single crystal calculations"""

a: float
b: float
c: float
alpha: float
beta: float
gamma: float
h: float
k: float
l: float
a: float = DEFAULT_LATTICE["a"]
b: float = DEFAULT_LATTICE["b"]
c: float = DEFAULT_LATTICE["c"]
alpha: float = DEFAULT_LATTICE["alpha"]
beta: float = DEFAULT_LATTICE["beta"]
gamma: float = DEFAULT_LATTICE["gamma"]
h: float = DEFAULT_LATTICE["h"]
k: float = DEFAULT_LATTICE["k"]
l: float = DEFAULT_LATTICE["l"]

def __init__(self) -> None:
"""Constructor"""
Expand Down Expand Up @@ -97,9 +97,9 @@ def calculate_modQ(self) -> float:
class CrosshairParameters:
"""Model for the crosshair parameters"""

modQ: float
DeltaE: float
current_experiment_type: str
modQ: float = DEFAULT_CROSSHAIR["modQ"]
DeltaE: float = DEFAULT_CROSSHAIR["DeltaE"]
current_experiment_type: str = DEFAULT_MODE["current_experiment_type"]
sc_parameters: SingleCrystalParameters
experiment_types = ["single_crystal", "powder"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np # noqa: F401

import hyspecppt.hppt.hppt_model as hppt_model # noqa: F401
from hyspecppt.hppt.hppt_model import HyspecPPTModel # noqa: F401


def test_single_crystal_parameter_set_parameters():
Expand Down
12 changes: 6 additions & 6 deletions tests/hppt_model/test_single_crystal_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import numpy as np

import hyspecppt.hppt.hppt_model as hppt_model
from hyspecppt.hppt.hppt_model import CrosshairParameters, SingleCrystalParameters


def test_single_crystal_parameter_set_parameters():
"""Test SingleCrystalParameters set_parameters function"""
scp = hppt_model.SingleCrystalParameters()
scp = SingleCrystalParameters()
sc_data = {"a": 1.0, "b": 1.0, "c": 1.0, "alpha": 90.0, "beta": 90, "gamma": 90, "h": 0, "k": 0, "l": 0}
scp.set_parameters(sc_data)

Expand All @@ -22,7 +22,7 @@ def test_single_crystal_parameter_set_parameters():

def test_single_crystal_parameter_get_parameters():
"""Test SingleCrystalParameters get_parameters function"""
scp = hppt_model.SingleCrystalParameters()
scp = SingleCrystalParameters()
sc_data = {"a": 1.0, "b": 1.0, "c": 1.0, "alpha": 90.0, "beta": 90, "gamma": 90, "h": 0, "k": 0, "l": 0}
scp.set_parameters(sc_data)

Expand All @@ -39,7 +39,7 @@ def test_single_crystal_parameter_get_parameters():

def test_single_crystal_parameter_calculate_modQ():
"""Test SingleCrystalParameters calculate_modQ function"""
scp = hppt_model.SingleCrystalParameters()
scp = SingleCrystalParameters()
sc_data = {"a": 1.0, "b": 1.0, "c": 1.0, "alpha": 90.0, "beta": 90, "gamma": 90, "h": 0, "k": 0, "l": 0}
scp.set_parameters(sc_data)
assert scp.calculate_modQ() == 0.0
Expand All @@ -65,7 +65,7 @@ def test_single_crystal_parameter_calculate_modQ():

def test_cross_hair_parameters_set_crosshair():
"""Test Crosshair set_crosshair function"""
cp = hppt_model.CrosshairParameters()
cp = CrosshairParameters()
current_experiment_type = "single_crystal"
DeltaE = 10.0
modQ = 1.23
Expand All @@ -82,7 +82,7 @@ def test_cross_hair_parameters_set_crosshair():

def test_get_cross_hair_parameters_set_crosshair():
"""Test Crosshair get_crosshair function"""
cp = hppt_model.CrosshairParameters()
cp = CrosshairParameters()
current_experiment_type = "single_crystal"
DeltaE = 10.0
modQ = 1.23
Expand Down

0 comments on commit c760b9c

Please sign in to comment.