FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix tests · diffpy/diffpy.srreal@72deaae · GitHub

Repository navigation

Commit 72deaae

Browse files
committed
fix tests
1 parent 334cfcd commit 72deaae

20 files changed

Lines changed: 420 additions & 233 deletions

‎src/diffpy/srreal/bondcalculator.py‎

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -17,61 +17,57 @@
1717
# exported items, these also makes them show in pydoc.
1818
__all__ = ["BondCalculator"]
1919

20-
from diffpy.srreal.srreal_ext import BondCalculator
20+
from diffpy.srreal.srreal_ext import BondCalculator as _BondCalculator
2121
from diffpy.srreal.wraputils import (
2222
propertyFromExtDoubleAttr,
2323
setattrFromKeywordArguments,
2424
)
2525

26-
# property wrappers to C++ double attributes
27-
28-
BondCalculator.rmin = propertyFromExtDoubleAttr(
29-
"rmin",
30-
"Lower bound for the bond distances. [0 A]",
31-
)
32-
33-
BondCalculator.rmax = propertyFromExtDoubleAttr(
34-
"rmax",
35-
"Upper bound for the bond distances. [5 A]",
36-
)
3726

27+
class BondCalculator(_BondCalculator):
28+
__doc__ = _BondCalculator.__doc__
3829

39-
# method overrides that support keyword arguments
30+
def __init__(self, **kwargs):
31+
"""Create a new instance of BondCalculator. Keyword arguments can be
32+
used to configure calculator properties, for example:
4033
34+
bdc = BondCalculator(rmin=1.5, rmax=2.5)
4135
42-
def _init_kwargs(self, **kwargs):
43-
"""Create a new instance of BondCalculator. Keyword arguments can be
44-
used to configure calculator properties, for example:
36+
Raise ValueError for invalid keyword argument.
37+
"""
38+
super().__init__()
39+
setattrFromKeywordArguments(self, **kwargs)
40+
return
4541

46-
bdc = BondCalculator(rmin=1.5, rmax=2.5)
42+
def __call__(self, structure=None, **kwargs):
43+
"""Return sorted bond distances in the specified structure.
4744
48-
Raise ValueError for invalid keyword argument.
49-
"""
50-
BondCalculator.__boostpython__init(self)
51-
setattrFromKeywordArguments(self, **kwargs)
52-
return
45+
Attributes
46+
----------
47+
structure
48+
structure to be evaluated, an instance of diffpy Structure
49+
or pyobjcryst Crystal. Reuse the last structure when None.
50+
kwargs
51+
optional parameter settings for this calculator
5352
53+
Return a sorted numpy array.
54+
"""
55+
setattrFromKeywordArguments(self, **kwargs)
56+
self.eval(structure)
57+
return self.distances
5458

55-
def _call_kwargs(self, structure=None, **kwargs):
56-
"""Return sorted bond distances in the specified structure.
5759

58-
Attributes
59-
----------
60-
structure
61-
structure to be evaluated, an instance of diffpy Structure
62-
or pyobjcryst Crystal. Reuse the last structure when None.
63-
kwargs
64-
optional parameter settings for this calculator
60+
# property wrappers to C++ double attributes
6561

66-
Return a sorted numpy array.
67-
"""
68-
setattrFromKeywordArguments(self, **kwargs)
69-
self.eval(structure)
70-
return self.distances
62+
BondCalculator.rmin = propertyFromExtDoubleAttr(
63+
"rmin",
64+
"Lower bound for the bond distances. [0 A]",
65+
)
7166

67+
BondCalculator.rmax = propertyFromExtDoubleAttr(
68+
"rmax",
69+
"Upper bound for the bond distances. [5 A]",
70+
)
7271

73-
BondCalculator.__boostpython__init = BondCalculator.__init__
74-
BondCalculator.__init__ = _init_kwargs
75-
BondCalculator.__call__ = _call_kwargs
7672

7773
# End of file

‎src/diffpy/srreal/bvscalculator.py‎

Lines changed: 37 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,48 @@
1717
# exported items
1818
__all__ = ["BVSCalculator"]
1919

20-
from diffpy.srreal.srreal_ext import BVSCalculator
20+
from diffpy.srreal.srreal_ext import BVSCalculator as _BVSCalculator
2121
from diffpy.srreal.wraputils import (
2222
propertyFromExtDoubleAttr,
2323
setattrFromKeywordArguments,
2424
)
2525

26+
27+
class BVSCalculator(_BVSCalculator):
28+
__doc__ = _BVSCalculator.__doc__
29+
30+
def __init__(self, **kwargs):
31+
"""Create a new instance of BVSCalculator.
32+
Keyword arguments can be used to configure the calculator properties,
33+
for example:
34+
35+
bvscalc = BVSCalculator(valenceprecision=0.001)
36+
37+
Raise ValueError for invalid keyword argument.
38+
"""
39+
super().__init__()
40+
setattrFromKeywordArguments(self, **kwargs)
41+
return
42+
43+
def __call__(self, structure=None, **kwargs):
44+
"""Return bond valence sums at each atom site in the structure.
45+
46+
Attributes
47+
----------
48+
structure
49+
structure to be evaluated, an instance of diffpy Structure
50+
or pyobjcryst Crystal. Reuse the last structure when None.
51+
kwargs
52+
optional parameter settings for this calculator
53+
54+
Return an array of calculated valence sums.
55+
See valences for the expected values.
56+
"""
57+
setattrFromKeywordArguments(self, **kwargs)
58+
rv = self.eval(structure)
59+
return rv
60+
61+
2662
# Property wrappers to C++ double attributes
2763

2864
BVSCalculator.valenceprecision = propertyFromExtDoubleAttr(
@@ -56,44 +92,4 @@
5692
)
5793

5894

59-
# method overrides that support keyword arguments
60-
61-
62-
def _init_kwargs(self, **kwargs):
63-
"""Create a new instance of BVSCalculator.
64-
Keyword arguments can be used to configure the calculator properties,
65-
for example:
66-
67-
bvscalc = BVSCalculator(valenceprecision=0.001)
68-
69-
Raise ValueError for invalid keyword argument.
70-
"""
71-
BVSCalculator.__boostpython__init(self)
72-
setattrFromKeywordArguments(self, **kwargs)
73-
return
74-
75-
76-
def _call_kwargs(self, structure=None, **kwargs):
77-
"""Return bond valence sums at each atom site in the structure.
78-
79-
Attributes
80-
----------
81-
structure
82-
structure to be evaluated, an instance of diffpy Structure
83-
or pyobjcryst Crystal. Reuse the last structure when None.
84-
kwargs
85-
optional parameter settings for this calculator
86-
87-
Return an array of calculated valence sums.
88-
See valences for the expected values.
89-
"""
90-
setattrFromKeywordArguments(self, **kwargs)
91-
rv = self.eval(structure)
92-
return rv
93-
94-
95-
BVSCalculator.__boostpython__init = BVSCalculator.__init__
96-
BVSCalculator.__init__ = _init_kwargs
97-
BVSCalculator.__call__ = _call_kwargs
98-
9995
# End of file

‎src/diffpy/srreal/overlapcalculator.py‎

Lines changed: 35 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,46 @@
1818
# exported items, these also makes them show in pydoc.
1919
__all__ = ["OverlapCalculator"]
2020

21-
from diffpy.srreal.srreal_ext import OverlapCalculator
21+
from diffpy.srreal.srreal_ext import OverlapCalculator as _OverlapCalculator
2222
from diffpy.srreal.wraputils import (
2323
propertyFromExtDoubleAttr,
2424
setattrFromKeywordArguments,
2525
)
2626

27+
28+
class OverlapCalculator(_OverlapCalculator):
29+
__doc__ = _OverlapCalculator.__doc__
30+
31+
def __init__(self, **kwargs):
32+
"""Create a new instance of OverlapCalculator. Keyword arguments can
33+
be used to configure calculator properties, for example:
34+
35+
olc = OverlapCalculator(rmax=2.5)
36+
37+
Raise ValueError for invalid keyword argument.
38+
"""
39+
super().__init__()
40+
setattrFromKeywordArguments(self, **kwargs)
41+
return
42+
43+
def __call__(self, structure=None, **kwargs):
44+
"""Return siteSquareOverlaps per each site of the structure.
45+
46+
Attributes
47+
----------
48+
structure
49+
structure to be evaluated, an instance of diffpy Structure
50+
or pyobjcryst Crystal. Reuse the last structure when None.
51+
kwargs
52+
optional parameter settings for this calculator
53+
54+
Return a numpy array.
55+
"""
56+
setattrFromKeywordArguments(self, **kwargs)
57+
self.eval(structure)
58+
return self.sitesquareoverlaps
59+
60+
2761
# property wrappers to C++ double attributes
2862

2963
OverlapCalculator.rmin = propertyFromExtDoubleAttr(
@@ -45,42 +79,4 @@
4579
),
4680
)
4781

48-
# method overrides that support keyword arguments
49-
50-
51-
def _init_kwargs(self, **kwargs):
52-
"""Create a new instance of OverlapCalculator. Keyword arguments can
53-
be used to configure calculator properties, for example:
54-
55-
olc = OverlapCalculator(rmax=2.5)
56-
57-
Raise ValueError for invalid keyword argument.
58-
"""
59-
OverlapCalculator.__boostpython__init(self)
60-
setattrFromKeywordArguments(self, **kwargs)
61-
return
62-
63-
64-
def _call_kwargs(self, structure=None, **kwargs):
65-
"""Return siteSquareOverlaps per each site of the structure.
66-
67-
Attributes
68-
----------
69-
structure
70-
structure to be evaluated, an instance of diffpy Structure
71-
or pyobjcryst Crystal. Reuse the last structure when None.
72-
kwargs
73-
optional parameter settings for this calculator
74-
75-
Return a numpy array.
76-
"""
77-
setattrFromKeywordArguments(self, **kwargs)
78-
self.eval(structure)
79-
return self.sitesquareoverlaps
80-
81-
82-
OverlapCalculator.__boostpython__init = OverlapCalculator.__init__
83-
OverlapCalculator.__init__ = _init_kwargs
84-
OverlapCalculator.__call__ = _call_kwargs
85-
8682
# End of file

‎src/diffpy/srreal/pdfcalculator.py‎

Lines changed: 33 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
"""
2020

2121
from diffpy.srreal.srreal_ext import (
22-
DebyePDFCalculator,
23-
PDFCalculator,
22+
DebyePDFCalculator as _DebyePDFCalculator,
23+
PDFCalculator as _PDFCalculator,
2424
fftftog,
2525
fftgtof,
2626
)
@@ -195,6 +195,23 @@ def _call_kwargs(self, structure=None, **kwargs):
195195

196196
# class DebyePDFCalculator ---------------------------------------------------
197197

198+
class DebyePDFCalculator(_DebyePDFCalculator):
199+
__doc__ = _DebyePDFCalculator.__doc__
200+
201+
def __init__(self, **kwargs):
202+
"""Create a new instance of the DebyePDFCalculator.
203+
Keyword arguments can be used to configure the calculator properties,
204+
for example:
205+
206+
dpc = DebyePDFCalculator(qmax=20, rmin=7, rmax=15)
207+
208+
Raise ValueError for invalid keyword argument.
209+
"""
210+
super().__init__()
211+
setattrFromKeywordArguments(self, **kwargs)
212+
return
213+
214+
198215
# shared interface of the PDF calculator classes
199216

200217
_defineCommonInterface(DebyePDFCalculator)
@@ -230,28 +247,26 @@ def _call_kwargs(self, structure=None, **kwargs):
230247
),
231248
)
232249

233-
# method overrides to support optional keyword arguments
234-
250+
# End of class DebyePDFCalculator
235251

236-
def _init_kwargs0(self, **kwargs):
237-
"""Create a new instance of the DebyePDFCalculator.
238-
Keyword arguments can be used to configure the calculator properties,
239-
for example:
252+
# PDFCalculator --------------------------------------------------------------
240253

241-
dpc = DebyePDFCalculator(qmax=20, rmin=7, rmax=15)
254+
class PDFCalculator(_PDFCalculator):
255+
__doc__ = _PDFCalculator.__doc__
242256

243-
Raise ValueError for invalid keyword argument.
244-
"""
245-
DebyePDFCalculator.__boostpython__init(self)
246-
setattrFromKeywordArguments(self, **kwargs)
247-
return
257+
def __init__(self, **kwargs):
258+
"""Create a new instance of PDFCalculator.
259+
Keyword arguments can be used to configure the calculator properties,
260+
for example:
248261
262+
pc = PDFCalculator(qmax=20, rmin=7, rmax=15)
249263
250-
DebyePDFCalculator.__boostpython__init = DebyePDFCalculator.__init__
251-
DebyePDFCalculator.__init__ = _init_kwargs0
252-
# End of class DebyePDFCalculator
264+
Raise ValueError for invalid keyword argument.
265+
"""
266+
super().__init__()
267+
setattrFromKeywordArguments(self, **kwargs)
268+
return
253269

254-
# PDFCalculator --------------------------------------------------------------
255270

256271
# shared interface of the PDF calculator classes
257272

@@ -319,26 +334,6 @@ def _init_kwargs0(self, **kwargs):
319334
),
320335
)
321336

322-
# method overrides to support optional keyword arguments
323-
324-
325-
def _init_kwargs1(self, **kwargs):
326-
"""Create a new instance of PDFCalculator.
327-
Keyword arguments can be used to configure the calculator properties,
328-
for example:
329-
330-
pc = PDFCalculator(qmax=20, rmin=7, rmax=15)
331-
332-
Raise ValueError for invalid keyword argument.
333-
"""
334-
PDFCalculator.__boostpython__init(self)
335-
setattrFromKeywordArguments(self, **kwargs)
336-
return
337-
338-
339-
PDFCalculator.__boostpython__init = PDFCalculator.__init__
340-
PDFCalculator.__init__ = _init_kwargs1
341-
342337
# End of class PDFCalculator
343338

344339
# End of file

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL