-
Notifications
You must be signed in to change notification settings - Fork 6
python
Christophe Pradal edited this page Dec 18, 2018
·
3 revisions
NB: All the methodology will be tested first on stat_tool
- Look at the organisation of stat_tool
- Get the doc string
- Get the tests
- Enhance the design
- Adapt aml.py to this organisation
Wraps the C++ method in Python. If the method fail, raise the errors. Other else return the result.
from functools import wraps
mod = __stat_tool.stat_tool
def wrapper(f):
@wraps(f)
def method(filename):
error = __stat_tool.stat_tool.StatError(__stat_tool.stat_tool.nb_error)
data = f(error, filename)
if not data:
raise Exception(str(error))
return data
return ascii_read
mod.klass.method = wrapper(mod.klass.method)
Use a decorator function like:
from functools import wraps
mod = __stat_tool.stat_tool
def wrapper(f):
@wraps(f)
def f_comparison(self, other):
sstream = mod.std.Ostringstream(mod.std.ios_openmode.S__OUT)
f(self, sstream, other)
return sstream.str()
return f_comparison
mod.FrequencyDistribution.f_comparison = wrapper(mod.FrequencyDistribution.f__comparison)