33"""Tests for diffractiondatasinglecrystal module."""
44
55import unittest
6+
67import numpy as np
78
89from pyobjcryst .crystal import Crystal
9- from pyobjcryst .diffractiondatasinglecrystal import DiffractionDataSingleCrystal
10+ from pyobjcryst .diffractiondatasinglecrystal import (
11+ DiffractionDataSingleCrystal ,
12+ )
1013
1114
1215class test_single_crystal_data (unittest .TestCase ):
1316
1417 def test_create (self ):
15- """Test creating a DiffractionDataSingleCrystal object"""
18+ """Test creating a DiffractionDataSingleCrystal object. """
1619 c = Crystal (3.52 , 3.52 , 3.52 , "225" )
17- d = DiffractionDataSingleCrystal (c )
20+ DiffractionDataSingleCrystal (c )
1821
1922 def test_create_set_hkliobs (self ):
20- """test SetHklIobs, SetIobs and SetSigma"""
23+ """Test SetHklIobs, SetIobs and SetSigma. """
2124 c = Crystal (3.1 , 3.2 , 3.3 , "Pmmm" )
2225 d = DiffractionDataSingleCrystal (c )
2326 n0 = 5
24- nb = n0 ** 3
27+ nb = n0 ** 3
2528 r = np .arange (1 , nb + 1 , dtype = np .float64 )
2629 h = r % n0
27- l = r // n0 ** 2
28- k = (r - l * n0 ** 2 ) // n0
30+ l = r // n0 ** 2 # noqa: E741
31+ k = (r - l * n0 ** 2 ) // n0
2932 iobs = np .random .uniform (0 , 100 , nb )
3033 sigma = np .sqrt (iobs )
3134
3235 d .SetHklIobs (h , k , l , iobs , sigma )
3336
3437 # SetHklIobs sorts reflecions by sin(theta)/lambda, so do the same for comparison
35- s = np .sqrt (h ** 2 / 3.1 ** 2 + k ** 2 / 3.2 ** 2 + l ** 2 / 3.3 ** 2 ) / 2
38+ s = np .sqrt (h ** 2 / 3.1 ** 2 + k ** 2 / 3.2 ** 2 + l ** 2 / 3.3 ** 2 ) / 2
3639 idx = np .argsort (s )
3740
3841 iobs = np .take (iobs , idx )
3942 sigma = np .take (sigma , idx )
4043 h = np .take (h , idx )
4144 k = np .take (k , idx )
42- l = np .take (l , idx )
45+ l = np .take (l , idx ) # noqa: E741
4346 self .assertTrue (np .all (iobs == d .GetIobs ()))
4447 self .assertTrue (np .all (sigma == d .GetSigma ()))
4548 self .assertTrue (np .all (h == d .GetH ()))
@@ -55,5 +58,6 @@ def test_create_set_hkliobs(self):
5558 d .SetSigma (sigma )
5659 self .assertTrue (np .all (sigma == d .GetSigma ()))
5760
61+
5862if __name__ == "__main__" :
5963 unittest .main ()
0 commit comments