generated from neutrons/python_project_template
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Sc tests #21
Merged
Merged
Sc tests #21
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33793fe
tests for SC model
KyleQianliMa 3523bd0
initalization and modQ change
KyleQianliMa 19906b7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 83fc97d
pre-commit fix
KyleQianliMa 801cd60
precommit fix
KyleQianliMa 0951f38
Merge branch 'next' into SC-tests
AndreiSavici c760b9c
initialization and minor changes
KyleQianliMa 81205ed
minor comments
KyleQianliMa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# import numpy as np # noqa: F401 | ||
|
||
from hyspecppt.hppt.hppt_model import HyspecPPTModel # noqa: F401 | ||
|
||
|
||
def test_single_crystal_parameter_set_parameters(): | ||
"""Test SingleCrystalParameters set_parameters function""" | ||
# saving for next story |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
import numpy as np | ||
|
||
from hyspecppt.hppt.hppt_model import CrosshairParameters, SingleCrystalParameters | ||
|
||
|
||
def test_single_crystal_parameter_set_parameters(): | ||
"""Test SingleCrystalParameters set_parameters function""" | ||
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.a == 1.0 | ||
assert scp.b == 1.0 | ||
assert scp.c == 1.0 | ||
assert scp.alpha == 90.0 | ||
assert scp.beta == 90.0 | ||
assert scp.gamma == 90.0 | ||
assert scp.h == 0 | ||
assert scp.k == 0 | ||
assert scp.l == 0 | ||
|
||
|
||
def test_single_crystal_parameter_get_parameters(): | ||
"""Test SingleCrystalParameters get_parameters function""" | ||
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.get_parameters()["a"] == 1.0 | ||
assert scp.get_parameters()["b"] == 1.0 | ||
assert scp.get_parameters()["c"] == 1.0 | ||
assert scp.get_parameters()["alpha"] == 90.0 | ||
assert scp.get_parameters()["beta"] == 90.0 | ||
assert scp.get_parameters()["gamma"] == 90.0 | ||
assert scp.get_parameters()["h"] == 0 | ||
assert scp.get_parameters()["k"] == 0 | ||
assert scp.get_parameters()["l"] == 0 | ||
|
||
|
||
def test_single_crystal_parameter_calculate_modQ(): | ||
"""Test SingleCrystalParameters calculate_modQ function""" | ||
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 | ||
|
||
sc_data["h"] = 1 | ||
sc_data["k"] = 2 | ||
sc_data["l"] = 3 | ||
scp.set_parameters(sc_data) | ||
assert np.isclose(scp.calculate_modQ(), 23.5095267) | ||
|
||
sc_data["alpha"] = 60 | ||
sc_data["beta"] = 60 | ||
sc_data["gamma"] = 90 | ||
scp.set_parameters(sc_data) | ||
assert np.isclose(scp.calculate_modQ(), 19.3660777) | ||
|
||
sc_data["a"] = 10 | ||
sc_data["b"] = 10 | ||
sc_data["c"] = 15.12312 | ||
scp.set_parameters(sc_data) | ||
assert np.isclose(scp.calculate_modQ(), 1.469240) | ||
|
||
|
||
def test_cross_hair_parameters_set_crosshair(): | ||
"""Test Crosshair set_crosshair function""" | ||
cp = CrosshairParameters() | ||
current_experiment_type = "single_crystal" | ||
DeltaE = 10.0 | ||
modQ = 1.23 | ||
cp.set_crosshair(current_experiment_type) | ||
assert cp.current_experiment_type == "single_crystal" | ||
|
||
cp.set_crosshair(current_experiment_type, DeltaE=DeltaE) | ||
assert cp.DeltaE == 10.0 | ||
|
||
cp.set_crosshair(current_experiment_type, modQ=modQ) | ||
assert cp.DeltaE == 10.0 | ||
assert cp.modQ == 1.23 | ||
|
||
|
||
def test_get_cross_hair_parameters_set_crosshair(): | ||
"""Test Crosshair get_crosshair function""" | ||
cp = CrosshairParameters() | ||
current_experiment_type = "single_crystal" | ||
DeltaE = 10.0 | ||
modQ = 1.23 | ||
|
||
cp.set_crosshair(current_experiment_type, DeltaE=DeltaE, modQ=modQ) | ||
cp.sc_parameters.set_parameters( | ||
{"a": 1.0, "b": 1.0, "c": 1.0, "alpha": 90.0, "beta": 90, "gamma": 90, "h": 0, "k": 0, "l": 0} | ||
) | ||
assert cp.get_crosshair()["DeltaE"] == 10.0 | ||
assert cp.get_crosshair()["modQ"] == 0.0 | ||
|
||
cp.set_crosshair("powder", DeltaE=DeltaE, modQ=modQ) | ||
assert cp.get_crosshair()["DeltaE"] == 10.0 | ||
assert cp.get_crosshair()["modQ"] == 1.23 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the initialization of the other parameters: CrosshairParameters and SingleCrystalParameters from the experiment_settings happening in another PR?