| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,61 +17,57 @@ | |||
| 17 | 17 | # exported items, these also makes them show in pydoc. | |
| 18 | 18 | __all__ = ["BondCalculator"] | |
| 19 | 19 | ||
| 20 | - from diffpy.srreal.srreal_ext import BondCalculator | ||
| 20 | + from diffpy.srreal.srreal_ext import BondCalculator as _BondCalculator | ||
| 21 | 21 | from diffpy.srreal.wraputils import ( | |
| 22 | 22 | propertyFromExtDoubleAttr, | |
| 23 | 23 | setattrFromKeywordArguments, | |
| 24 | 24 | ) | |
| 25 | 25 | ||
| 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 | - ) | ||
| 37 | 26 | ||
| 27 | + class BondCalculator(_BondCalculator): | ||
| 28 | + __doc__ = _BondCalculator.__doc__ | ||
| 38 | 29 | ||
| 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: | ||
| 40 | 33 | ||
| 34 | + bdc = BondCalculator(rmin=1.5, rmax=2.5) | ||
| 41 | 35 | ||
| 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 | ||
| 45 | 41 | ||
| 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. | ||
| 47 | 44 | ||
| 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 | ||
| 53 | 52 | ||
| 53 | + Return a sorted numpy array. | ||
| 54 | + """ | ||
| 55 | + setattrFromKeywordArguments(self, **kwargs) | ||
| 56 | + self.eval(structure) | ||
| 57 | + return self.distances | ||
| 54 | 58 | ||
| 55 | - def _call_kwargs(self, structure=None, **kwargs): | ||
| 56 | - """Return sorted bond distances in the specified structure. | ||
| 57 | 59 | ||
| 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 | ||
| 65 | 61 | ||
| 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 | + ) | ||
| 71 | 66 | ||
| 67 | + BondCalculator.rmax = propertyFromExtDoubleAttr( | ||
| 68 | + "rmax", | ||
| 69 | + "Upper bound for the bond distances. [5 A]", | ||
| 70 | + ) | ||
| 72 | 71 | ||
| 73 | - BondCalculator.__boostpython__init = BondCalculator.__init__ | ||
| 74 | - BondCalculator.__init__ = _init_kwargs | ||
| 75 | - BondCalculator.__call__ = _call_kwargs | ||
| 76 | 72 | ||
| 77 | 73 | # End of file | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,12 +17,48 @@ | |||
| 17 | 17 | # exported items | |
| 18 | 18 | __all__ = ["BVSCalculator"] | |
| 19 | 19 | ||
| 20 | - from diffpy.srreal.srreal_ext import BVSCalculator | ||
| 20 | + from diffpy.srreal.srreal_ext import BVSCalculator as _BVSCalculator | ||
| 21 | 21 | from diffpy.srreal.wraputils import ( | |
| 22 | 22 | propertyFromExtDoubleAttr, | |
| 23 | 23 | setattrFromKeywordArguments, | |
| 24 | 24 | ) | |
| 25 | 25 | ||
| 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 | + | ||
| 26 | 62 | # Property wrappers to C++ double attributes | |
| 27 | 63 | ||
| 28 | 64 | BVSCalculator.valenceprecision = propertyFromExtDoubleAttr( | |
@@ -56,44 +92,4 @@ | |||
| 56 | 92 | ) | |
| 57 | 93 | ||
| 58 | 94 | ||
| 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 | - | ||
| 99 | 95 | # End of file | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,12 +18,46 @@ | |||
| 18 | 18 | # exported items, these also makes them show in pydoc. | |
| 19 | 19 | __all__ = ["OverlapCalculator"] | |
| 20 | 20 | ||
| 21 | - from diffpy.srreal.srreal_ext import OverlapCalculator | ||
| 21 | + from diffpy.srreal.srreal_ext import OverlapCalculator as _OverlapCalculator | ||
| 22 | 22 | from diffpy.srreal.wraputils import ( | |
| 23 | 23 | propertyFromExtDoubleAttr, | |
| 24 | 24 | setattrFromKeywordArguments, | |
| 25 | 25 | ) | |
| 26 | 26 | ||
| 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 | + | ||
| 27 | 61 | # property wrappers to C++ double attributes | |
| 28 | 62 | ||
| 29 | 63 | OverlapCalculator.rmin = propertyFromExtDoubleAttr( | |
@@ -45,42 +79,4 @@ | |||
| 45 | 79 | ), | |
| 46 | 80 | ) | |
| 47 | 81 | ||
| 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 | - | ||
| 86 | 82 | # End of file | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -19,8 +19,8 @@ | |||
| 19 | 19 | """ | |
| 20 | 20 | ||
| 21 | 21 | from diffpy.srreal.srreal_ext import ( | |
| 22 | - DebyePDFCalculator, | ||
| 23 | - PDFCalculator, | ||
| 22 | + DebyePDFCalculator as _DebyePDFCalculator, | ||
| 23 | + PDFCalculator as _PDFCalculator, | ||
| 24 | 24 | fftftog, | |
| 25 | 25 | fftgtof, | |
| 26 | 26 | ) | |
@@ -195,6 +195,23 @@ def _call_kwargs(self, structure=None, **kwargs): | |||
| 195 | 195 | ||
| 196 | 196 | # class DebyePDFCalculator --------------------------------------------------- | |
| 197 | 197 | ||
| 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 | + | ||
| 198 | 215 | # shared interface of the PDF calculator classes | |
| 199 | 216 | ||
| 200 | 217 | _defineCommonInterface(DebyePDFCalculator) | |
@@ -230,28 +247,26 @@ def _call_kwargs(self, structure=None, **kwargs): | |||
| 230 | 247 | ), | |
| 231 | 248 | ) | |
| 232 | 249 | ||
| 233 | - # method overrides to support optional keyword arguments | ||
| 234 | - | ||
| 250 | + # End of class DebyePDFCalculator | ||
| 235 | 251 | ||
| 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 -------------------------------------------------------------- | ||
| 240 | 253 | ||
| 241 | - dpc = DebyePDFCalculator(qmax=20, rmin=7, rmax=15) | ||
| 254 | + class PDFCalculator(_PDFCalculator): | ||
| 255 | + __doc__ = _PDFCalculator.__doc__ | ||
| 242 | 256 | ||
| 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: | ||
| 248 | 261 | ||
| 262 | + pc = PDFCalculator(qmax=20, rmin=7, rmax=15) | ||
| 249 | 263 | ||
| 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 | ||
| 253 | 269 | ||
| 254 | - # PDFCalculator -------------------------------------------------------------- | ||
| 255 | 270 | ||
| 256 | 271 | # shared interface of the PDF calculator classes | |
| 257 | 272 | ||
@@ -319,26 +334,6 @@ def _init_kwargs0(self, **kwargs): | |||
| 319 | 334 | ), | |
| 320 | 335 | ) | |
| 321 | 336 | ||
| 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 | - | ||
| 342 | 337 | # End of class PDFCalculator | |
| 343 | 338 | ||
| 344 | 339 | # End of file | |
| Back | FazBrowse Home | New Git URL |
0 commit comments