I use the Python "units" package (http://pypi.python.org/pypi/units/) and I ran into some problems when trying to sort them. I tried to weld it to the simplest case, to try to figure out what was going on. Here is my simple test:
from units import unit, named_unit from units.predefined import define_units from units.compatibility import compatible from units.registry import REGISTRY a = unit('m') a_p = pickle.dumps(a) a_up = pickle.loads(a_p) logging.info(repr(unit('m'))) logging.info(repr(a)) logging.info(repr(a_up)) logging.info(a.is_si()) logging.info(a_up.is_si()) logging.info( compatible(a,a_up) ) logging.info(a(10) + a_up(10))
The result that I see at startup is:
LeafUnit('m', True) LeafUnit('m', True) LeafUnit('m', True) True True False IncompatibleUnitsError
I would understand if their herbs broke, if not for the fact that repr () returns the same results for them. What am I missing?
It uses the v0.04 unit package, and the Google App Engine 1.4 SDK 1
, , , , , , equivlent.
, , , , , units.compatibility.compatible , , LeafUnit __eq__, ( python ).
units.compatibility.compatible
__eq__
, , ( ..), . , , , , (, , )
- unit.abstract.AbstractUnit __eq__:
AbstractUnit.__eq__ = lambda self, other: repr(self)==repr(other)
, , , , . () "".
, pickle , , __reduce__() copy_reg.dispatch_table
pickle
__reduce__()
copy_reg.dispatch_table
import copy_reg from units import LeafUnit def leafunit_reduce(self): return LeafUnit, (self.specifier, self.is_si()) copy_reg.pickle(LeafUnit, leafunit_reduce)
Source: https://habr.com/ru/post/1783171/More articles:How can I check the plus sign with regular expressions? - phpHow to get the current node selected in a TreeView control? - c #Google App Engine as an authentication server for mobile applications - pythonsetStatusBarOrientation: how to change device orientation - iphoneC # DataSet, DataAdapter - How to change row state for INSERT call? - c #Use `require ()` with `node --eval` - node.jsUploading a file to the sharepoint library raises an unhandled exception (hresult: 0x80020009, error code: -2147352567) with an empty error message - fileJQuery tooltip next to mouse - jqueryКак установить модули python на основе каждого проекта, а не на всю систему? - pythonWhat does this CSS property mean: text-indent: -1e + 7px; - cssAll Articles