Skip to content

Commit 5914ba3

Browse files
committed
Always import Python tweaks to extension classes.
This ensures that unpickled instances of extension classes have all Python-level tweaks loaded and behave consistently This closes #6.
1 parent 0323a2d commit 5914ba3

4 files changed

Lines changed: 13 additions & 10 deletions

File tree

diffpy/srreal/overlapcalculator.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,4 @@ def _call_kwargs(self, structure=None, **kwargs):
7575
OverlapCalculator.__init__ = _init_kwargs
7676
OverlapCalculator.__call__ = _call_kwargs
7777

78-
# this registers CovalentRadiiTable as 'covalent' type
79-
import diffpy.srreal.atomradiitable
80-
8178
# End of file

diffpy/srreal/pdfcalculator.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
from diffpy.srreal.peakwidthmodel import (PeakWidthModel,
4444
ConstantPeakWidth, DebyeWallerPeakWidth, JeongPeakWidth)
4545

46-
# activate pickling in PDFCalculator-owned classes
47-
48-
import diffpy.srreal.scatteringfactortable
49-
5046
# ----------------------------------------------------------------------------
5147

5248
def _defineCommonInterface(cls):

srrealmodule/srreal_ext.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,20 @@ BOOST_PYTHON_MODULE(srreal_ext)
7878
wrap_BondCalculator();
7979
wrap_AtomRadiiTable();
8080
wrap_OverlapCalculator();
81-
// load structure converters
81+
// load Python modules that tweak the wrapped classes
8282
using boost::python::import;
83+
import("diffpy.srreal.attributes");
84+
import("diffpy.srreal.atomradiitable");
85+
import("diffpy.srreal.bondcalculator");
86+
import("diffpy.srreal.bvscalculator");
87+
import("diffpy.srreal.overlapcalculator");
88+
import("diffpy.srreal.pdfbaseline");
89+
import("diffpy.srreal.pdfcalculator");
90+
import("diffpy.srreal.pdfenvelope");
91+
import("diffpy.srreal.peakprofile");
92+
import("diffpy.srreal.peakwidthmodel");
93+
import("diffpy.srreal.scatteringfactortable");
94+
// load structure converters
8395
import("diffpy.srreal.structureconverters");
8496
}
8597

srrealmodule/wrap_Attributes.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,6 @@ void wrap_Attributes()
196196
(python::arg("getter")=None, python::arg("setter")=None),
197197
doc_Attributes__registerDoubleAttribute)
198198
;
199-
// inject the __getattr__ and __setattr__ methods
200-
import("diffpy.srreal.attributes");
201199
}
202200

203201
} // namespace srrealmodule

0 commit comments

Comments
 (0)