Package: bookkeep
ContentsWhat is bookkeep?InstallationDocumentationGetting startedLatest source codeBug reportsLicense informationCitationWhat is bookkeep?bookkeep is a python package for keeping track of units of measure and measurment bounds. The package mainly features the SmartBook, a dictionary subclass that incorporatespint Quantity objectsfor managing units of measure.InstallationGet the latest version of bookkeep fromhttps://pypi.python.org/pypi/bookkeep/If you have an installation of Python with pip, simple install it with:$ pip install bookkeepTo get the git version, run:$ git clone git://github.com/yoelcortes/bookkeepDocumentationbookkeep’s documentation is available on the web:http://bookkeep.readthedocs.io/Getting startedSmartBook objects are dictionaries that provide an easy way to keep track of units of measure and enforce bounds.Create aSmartBookobject withunits,bounds, asourcedescription, and arguments to initialize the dictionary:>>>sb=SmartBook(units={'T':'K','Duty':'kJ/hr'},...bounds={'T':(0,1000)},...source='Operating conditions',...T=350)>>>sb{'T':350(K)}Theunitsattribute becomes aUnitManagerobject with a reference to all dictionaries (clients) it controls. These include the SmartBook and its bounds.>>>sb.unitsUnitManager:{'T':'degC','Duty':'kJ/hr'}>>>sb.units.clients[{'T':350(K)},{'T':(0,1000)}]Change units:>>>sb.units['T']='degC'>>>sb{'T':76.85(degC)}>>>sb.bounds{'T':array([-273.15,726.85])}Add items:>>>sb['P']=101325>>>sb{'T':76.85(degC),'P':101325}Add units:>>>sb.units['P']='Pa'>>>sb{'T':76.85(degC),'P':101325(Pa)}A BookkeepWarning is issued when a value is set out of bounds:>>>sb['T']=-300__main__:1:BookkeepWarning:@Operatingconditions:T(-300degC)isoutofbounds(-273.15to726.85degC).Nested SmartBook objects are easy to read, and can be made using the same units and bounds.Create new SmartBook objects:>>>sb1=SmartBook(sb.units,sb.bounds,...T=25,P=500)>>>sb2=SmartBook(sb.units,sb.bounds,...T=50,Duty=50)>>>sb1{'T':25(degC),'P':500(Pa)}>>>sb2{'T':50(degC),'Duty':50(kJ/hr)})Create nested SmartBook:>>>nsb=SmartBook(sb1=sb1,sb2=sb2){'sb1':{'T':25(degC),'P':500(Pa)},'sb2':{'T':50(degC),'Duty':50(kg/hr)}}PintQuantityobjects are also compatible, so long as the corresponding Quantity class is set as the Quantity attribute.Set a Quantity object:>>>Q_=SmartBook.Quantity>>>sb1.bounds['T']=Q_((0,1000),'K')>>>sb1['T']=Q_(100,'K')>>>sb1{'T':-173.15degC,'P':500(Pa)}Setting a Quantity object out of bounds will issue a warning:>>>sb1['T']=Q_(-1,'K')__main__:1:BookkeepWarning:T(-274.15degC)isoutofbounds(-273.15to726.85degC).Trying to set a Quantity object with wrong dimensions will raise an error:>>>Q_=SmartBook.Quantity>>>sb1['T']=Q_(100,'meter')DimensionalityError:Cannotconvertfrom'meter'([length])to'degC'([temperature])Latest source codeThe latest development version of bookeep’s sources can be obtained at:https://github.com/yoelcortes/bookkeepBug reportsTo report bugs, please use the bookkeep’s Bug Tracker at:https://github.com/yoelcortes/bookkeepLicense informationSeeLICENSE.txtfor information on the terms & conditions for usage
of this software, and a DISCLAIMER OF ALL WARRANTIES.Although not required by the bookkeep license, if it is convenient for you,
please cite bookkeep if used in your work. Please also consider contributing
any changes you make back, and benefit the community.CitationTo cite bookkeep in publications use:Yoel Cortes-Pena (2018). bookkeep: An easy way to track quantities
https://github.com/yoelcortes/bookkeep