Skip to content

Commit

Permalink
Merge branch 'release/0.4.7'
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Mar 7, 2020
2 parents 132723e + 056a2b7 commit b500e05
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 14 deletions.
2 changes: 1 addition & 1 deletion tests/test_kw_passing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
import inspect

from warg.kw_passing import passes_kws_to, super_init_pass_on_kws
from warg.decorators.kw_passing import passes_kws_to, super_init_pass_on_kws

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Expand Down
3 changes: 1 addition & 2 deletions tests/test_post_init.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from warg import drop_unused_kws
from warg.post_init import PostInit
from warg.singleton import SingletonMeta, SingletonBase
from warg.metas.post_init import PostInit

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Expand Down
2 changes: 1 addition & 1 deletion tests/test_singleton.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from warg.singleton import SingletonMeta, SingletonBase
from warg.metas.singleton import SingletonMeta, SingletonBase

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Expand Down
7 changes: 2 additions & 5 deletions warg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

__project__ = "Warg"
__author__ = "Christian Heider Nielsen"
__version__ = "0.4.6"
__version__ = "0.4.7"
__doc__ = r"""
Created on 27/04/2019
Expand Down Expand Up @@ -89,12 +89,9 @@ def get_version(append_time=DEVELOP):

from .named_ordered_dictionary import *
from .pooled_queue_processor import *
from .singleton import *
from .arguments import *
from .gdkc import *
from .kw_passing import *
from .mixins import *
from .decorators import *
from .auto_dict import *
from .post_init import *
from .hashing import *
from .metas import *
4 changes: 3 additions & 1 deletion warg/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
Created on 16/02/2020
"""

from .decorators import *
from .timing import *
from .caching import *
from .look_up_table import *
from .hashing import *
from .kw_passing import *
24 changes: 21 additions & 3 deletions warg/hashing.py → warg/decorators/hashing.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,38 @@ def make_hash(o):
make_hash([fn.__dict__, fn.__code__])
"""

if type(o) == DictProxyType:
if isinstance(o, DictProxyType):
o2 = {}
for k, v in o.items():
if not k.startswith("__"):
o2[k] = v
o = o2

if isinstance(o, (set, tuple, list)):
return tuple([make_hash(e) for e in o])
elif not isinstance(o, dict):
return hash(tuple([make_hash(e) for e in o]))
if not isinstance(o, dict):
return hash(o)

new_o = copy.deepcopy(o)
for k, v in new_o.items():
new_o[k] = make_hash(v)

return hash(tuple(frozenset(sorted(new_o.items()))))


if __name__ == "__main__":
print(hash(1))
print(make_hash(1))
print(make_hash(1))
print(make_hash({1}))
print(make_hash([1]))
print(make_hash({1}))
print(make_hash({1, 2}))
print(make_hash([1, 2]))
print(make_hash((1, 2)))
print(make_hash({4}))
print(make_hash("1"))
print(make_hash({"2": 2}))
print(make_hash({"2": 3}))
print(make_hash({"3": 2}))
print(make_hash({"3": 3}))
File renamed without changes.
2 changes: 1 addition & 1 deletion warg/decorators/look_up_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from time import sleep, time
from typing import Iterable, Set, Mapping, Tuple

from warg.hashing import make_hash
from warg.decorators.hashing import make_hash

global_table = {}

Expand Down
File renamed without changes.
11 changes: 11 additions & 0 deletions warg/metas/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Created on 07/03/2020
"""

from .post_init import *
from .singleton import *
File renamed without changes.
File renamed without changes.

0 comments on commit b500e05

Please sign in to comment.