|
[yoda-svn] r568 - in trunk: include/YODA pyext/yoda/include srcblackhole at projects.hepforge.org blackhole at projects.hepforge.orgTue Mar 5 11:56:02 GMT 2013
Author: buckley Date: Tue Mar 5 11:56:02 2013 New Revision: 568 Log: Some docstring improvements in YODA IO Modified: trunk/include/YODA/AnalysisObject.h trunk/pyext/yoda/include/IO.pyx trunk/src/WriterFLAT.cc trunk/src/WriterYODA.cc Modified: trunk/include/YODA/AnalysisObject.h ============================================================================== --- trunk/include/YODA/AnalysisObject.h Tue Mar 5 09:55:18 2013 (r567) +++ trunk/include/YODA/AnalysisObject.h Tue Mar 5 11:56:02 2013 (r568) @@ -121,6 +121,9 @@ template <typename T> void setAnnotation(const std::string& name, const T& value) { _annotations[name] = boost::lexical_cast<std::string>(value); + /// @todo Specialise for float, double, etc. with this safer recipe from the Boost docs: + // std::stringstream ss; + // ss << setprecison(std::numeric_limits<double>::max_digits10) << scientific << output_value; } Modified: trunk/pyext/yoda/include/IO.pyx ============================================================================== --- trunk/pyext/yoda/include/IO.pyx Tue Mar 5 09:55:18 2013 (r567) +++ trunk/pyext/yoda/include/IO.pyx Tue Mar 5 11:56:02 2013 (r568) @@ -3,7 +3,7 @@ # The basic idea here is to provide Python IO semantics by using Python to do # the IO. Otherwise we get C++ IO semantics in Python. It also means we can use -# dummy files, e.g. anything with read/write attirbutes. Generally a much better +# dummy files, e.g. anything with read/write attributes. Generally a much better # idea than just "give this a filename", and well worth the inefficiencies and # potential memory limits. @@ -22,11 +22,18 @@ cdef void make_iss(c.istringstream &iss, char *s): iss.str(string(s)) + ## ## Readers ## def readYODA(file_or_filename): + """ + readYODA(file_or_filename) + + Read data objects from the provided YODA-format file. + Returns a list of analysis objects + """ cdef c.istringstream iss cdef vector[c.AnalysisObject*] aobjects @@ -37,13 +44,19 @@ s = f.read() make_iss(iss, s) - c.ReaderYODA_create().read(iss, aobjects) # Not as expensive as it looks! return aobjects_to_list(&aobjects) + def readAIDA(file_or_filename): + """ + readAIDA(file_or_filename) + + Read data objects from the provided AIDA-format file. + Returns a list of analysis objects + """ cdef c.istringstream iss cdef vector[c.AnalysisObject*] aobjects @@ -54,17 +67,22 @@ s = f.read() make_iss(iss, s) - c.ReaderAIDA_create().read(iss, aobjects) # Not as expensive as it looks! return aobjects_to_list(&aobjects) + ## ## Writers ## def writeYODA(ana_objs, file_or_filename): + """ + writeYODA(ana_objs, file_or_filename) + + Write data objects to the provided file in YODA format. + """ cdef c.ostringstream oss cdef vector[c.AnalysisObject*] vec cdef AnalysisObject a @@ -84,6 +102,11 @@ def writeFLAT(ana_objs, file_or_filename): + """ + writeFLAT(ana_objs, file_or_filename) + + Write data objects to the provided file in FLAT format. + """ cdef c.ostringstream oss cdef vector[c.AnalysisObject*] vec cdef AnalysisObject a @@ -103,6 +126,11 @@ def writeAIDA(ana_objs, file_or_filename): + """ + writeAIDA(ana_objs, file_or_filename) + + Write data objects to the provided file in AIDA format. + """ cdef c.ostringstream oss cdef vector[c.AnalysisObject*] vec cdef AnalysisObject a Modified: trunk/src/WriterFLAT.cc ============================================================================== --- trunk/src/WriterFLAT.cc Tue Mar 5 09:55:18 2013 (r567) +++ trunk/src/WriterFLAT.cc Tue Mar 5 11:56:02 2013 (r568) @@ -30,10 +30,11 @@ void WriterFLAT::_writeAnnotations(std::ostream& os, const AnalysisObject& ao) { - os << scientific << showpoint << setprecision(_precision); + os << scientific << setprecision(_precision); typedef pair<string,string> sspair; foreach (const sspair& kv, ao.annotations()) { if (kv.first.empty() || kv.second.empty()) continue; // <- good idea? + /// @todo Should write out floating point annotations as scientific notation... os << kv.first << "=" << kv.second << "\n"; } } Modified: trunk/src/WriterYODA.cc ============================================================================== --- trunk/src/WriterYODA.cc Tue Mar 5 09:55:18 2013 (r567) +++ trunk/src/WriterYODA.cc Tue Mar 5 11:56:02 2013 (r568) @@ -30,10 +30,11 @@ void WriterYODA::_writeAnnotations(std::ostream& os, const AnalysisObject& ao) { - os << scientific << showpoint << setprecision(_precision); + os << scientific << setprecision(_precision); typedef pair<string,string> sspair; foreach (const sspair& kv, ao.annotations()) { if (kv.first.empty() || kv.second.empty()) continue; // <- good idea? + /// @todo Should write out floating point annotations as scientific notation... os << kv.first << "=" << kv.second << "\n"; } }
More information about the yoda-svn mailing list |