Skip to content

Commit

Permalink
Allow to increase verbosity of test. Correct powder pattern tests to …
Browse files Browse the repository at this point in the history
…avoid uninitialised observed data which gives warnings in valgrind
  • Loading branch information
vincefn committed Nov 5, 2022
1 parent bcf1eba commit 93b202a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion conda-recipe/run_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python

import pyobjcryst.tests
assert pyobjcryst.tests.test().wasSuccessful()
assert pyobjcryst.tests.test(verbosity=2).wasSuccessful()
4 changes: 2 additions & 2 deletions src/pyobjcryst/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ def testsuite(pattern=''):
return suite


def test():
def test(verbosity=1):
'''Execute all unit tests for the pyobjcryst package.
Returns
-------
result : `unittest.TestResult`
'''
suite = testsuite()
runner = unittest.TextTestRunner()
runner = unittest.TextTestRunner(verbosity=verbosity)
result = runner.run(suite)
return result
4 changes: 4 additions & 0 deletions src/pyobjcryst/tests/testpowderpattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ def test_quick_fit(self):
p.SetWavelength(0.7)
x = np.linspace(0, 40, 8001)
p.SetPowderPatternX(np.deg2rad(x))
p.SetPowderPatternObs(np.ones_like(x))
pd = p.AddPowderPatternDiffraction(c)
pd.SetReflectionProfilePar(ReflectionProfileType.PROFILE_PSEUDO_VOIGT, 1e-6)
# p.plot(hkl=True)
Expand All @@ -169,6 +170,7 @@ def test_peaklist_index(self):
p.SetWavelength(0.7)
x = np.linspace(0, 40, 16001)
p.SetPowderPatternX(np.deg2rad(x))
p.SetPowderPatternObs(np.ones_like(x))
pd = p.AddPowderPatternDiffraction(c)
pd.SetReflectionProfilePar(ReflectionProfileType.PROFILE_PSEUDO_VOIGT, 1e-7)
# p.plot(hkl=True)
Expand All @@ -194,6 +196,7 @@ def test_spacegroup_explorer(self):
p.SetWavelength(0.7)
x = np.linspace(0, 40, 8001)
p.SetPowderPatternX(np.deg2rad(x))
p.SetPowderPatternObs(np.ones_like(x))
pd = p.AddPowderPatternDiffraction(c)
pd.SetReflectionProfilePar(ReflectionProfileType.PROFILE_PSEUDO_VOIGT, 1e-6, 0, 0, 0, 0)
# p.plot(hkl=True)
Expand Down Expand Up @@ -224,6 +227,7 @@ def test_update_nbrefl(self):
p.SetWavelength(1.5)
x = np.linspace(0, 40, 4000)
p.SetPowderPatternX(np.deg2rad(x))
p.SetPowderPatternObs(np.ones_like(x))
pd = p.AddPowderPatternDiffraction(c)
p.GetPowderPatternCalc()
self.assertEqual(pd.GetNbRefl(), 89)
Expand Down

0 comments on commit 93b202a

Please sign in to comment.