-
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
Add some unit tests #23
Conversation
tests/chopper_test.py
Outdated
phase=0.0 * deg, | ||
distance=1.0 * meter, | ||
) | ||
assert chopper.omega == (2.0 * rad * sc.constants.pi) * f |
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.
Define two_pi
on top?
tests/chopper_test.py
Outdated
open=sc.array(dims=['cutout'], values=[10.0], unit='deg'), | ||
close=sc.array(dims=['cutout'], values=[20.0], unit='deg'), | ||
phase=0.0 * deg, | ||
distance=1.0 * meter, |
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.
Having a factor(?) of 1 is bad for tests, since it it hard to tell whether it was missed or accidentally included in an equation.
def test_neutron_conservation(): | ||
N = 100_000 | ||
pulse = tof.Pulse(neutrons=N, kind='ess') | ||
|
||
chopper1 = make_chopper( | ||
topen=[5.0 * ms], | ||
tclose=[16.0 * ms], | ||
f=10.0 * Hz, | ||
phase=0.0 * deg, | ||
distance=10 * meter, | ||
name="chopper1", | ||
) | ||
chopper2 = make_chopper( | ||
topen=[9.0 * ms, 15.0 * ms], | ||
tclose=[15.0 * ms, 20.0 * ms], | ||
f=15.0 * Hz, | ||
phase=0.0 * deg, | ||
distance=15 * meter, |
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.
Could parametrize this, or consider using hypothesis in the future?
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.
ok for hypothesis in the future
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.
See #25
Fix #12