summaryrefslogtreecommitdiff
path: root/pint
diff options
context:
space:
mode:
authorGuido Imperiale <crusaderky@gmail.com>2019-12-03 16:24:55 +0000
committerGuido Imperiale <crusaderky@gmail.com>2019-12-03 16:24:55 +0000
commit906b7fab656210d3d00b27aebb0af3134e8f4831 (patch)
tree9766d64dc3bdc3bd3630f24bf421435b0c3c594f /pint
parent2ea887fa095013ab80f3f36bf85e143afef4eacc (diff)
downloadpint-906b7fab656210d3d00b27aebb0af3134e8f4831.tar.gz
Fix last bug
Diffstat (limited to 'pint')
-rw-r--r--pint/context.py6
-rw-r--r--pint/registry.py6
2 files changed, 6 insertions, 6 deletions
diff --git a/pint/context.py b/pint/context.py
index bce99da..ea06d9e 100644
--- a/pint/context.py
+++ b/pint/context.py
@@ -201,7 +201,7 @@ class ContextChain(ChainMap):
def __init__(self):
super(ContextChain, self).__init__()
self._graph = None
- self._contexts = ()
+ self._contexts = []
def insert_contexts(self, *contexts):
"""Insert one or more contexts in reversed order the chained map.
@@ -210,7 +210,7 @@ class ContextChain(ChainMap):
To facilitate the identification of the context with the matching rule,
the *relation_to_context* dictionary of the context is used.
"""
- self._contexts = contexts + self._contexts
+ self._contexts.insert(0, contexts)
self.maps = [ctx.relation_to_context for ctx in reversed(contexts)] + self.maps
self._graph = None
@@ -246,4 +246,4 @@ class ContextChain(ChainMap):
return self[(src, dst)].transform(src, dst, registry, value)
def __hash__(self):
- return hash(self._contexts)
+ return hash(tuple(self._contexts))
diff --git a/pint/registry.py b/pint/registry.py
index 7d9fdbb..b9ff71c 100644
--- a/pint/registry.py
+++ b/pint/registry.py
@@ -80,7 +80,7 @@ class _Meta(type):
return obj
-class RegistryCache(object):
+class RegistryCache:
"""Cache to speed up unit registries
"""
@@ -1083,7 +1083,7 @@ class ContextRegistry(BaseRegistry):
#: Map context chain to cache
self._caches = {}
- super(ContextRegistry, self).__init__(**kwargs)
+ super().__init__(**kwargs)
def _register_parsers(self):
super(ContextRegistry, self)._register_parsers()
@@ -1132,7 +1132,7 @@ class ContextRegistry(BaseRegistry):
try:
self._cache = self._caches[self._active_ctx]
except KeyError:
- super(ContextRegistry, self)._build_cache()
+ super()._build_cache()
self._caches[self._active_ctx] = self._cache
def enable_contexts(self, *names_or_contexts, **kwargs):