Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Plewinski
pystencils
Commits
7acdc31c
Commit
7acdc31c
authored
Apr 10, 2018
by
Martin Bauer
Browse files
More tests
parent
65698934
Changes
2
Hide whitespace changes
Inline
Side-by-side
cpu/cpujit.py
View file @
7acdc31c
...
...
@@ -72,10 +72,11 @@ import numpy as np
from
appdirs
import
user_config_dir
,
user_cache_dir
from
ctypes
import
cdll
from
pystencils.backends.cbackend
import
generate_c
,
get_headers
from
collections
import
OrderedDict
,
Mapping
from
collections
import
OrderedDict
from
pystencils.transformations
import
symbol_name_to_variable_name
from
pystencils.data_types
import
to_ctypes
,
get_base_type
,
StructType
from
pystencils.field
import
FieldType
from
pystencils.utils
import
recursive_dict_update
def
make_python_function
(
kernel_function_node
,
argument_dict
=
{}):
...
...
@@ -133,16 +134,6 @@ def set_compiler_config(config):
_config
=
config
.
copy
()
def
_recursive_dict_update
(
d
,
u
):
for
k
,
v
in
u
.
items
():
if
isinstance
(
v
,
Mapping
):
r
=
_recursive_dict_update
(
d
.
get
(
k
,
{}),
v
)
d
[
k
]
=
r
else
:
d
[
k
]
=
u
[
k
]
return
d
def
get_configuration_file_path
():
config_path_in_home
=
os
.
path
.
join
(
user_config_dir
(
'pystencils'
),
'config.json'
)
...
...
@@ -200,7 +191,7 @@ def read_config():
if
config_exists
:
with
open
(
config_path
,
'r'
)
as
jsonConfigFile
:
loaded_config
=
json
.
load
(
jsonConfigFile
)
config
=
_
recursive_dict_update
(
config
,
loaded_config
)
config
=
recursive_dict_update
(
config
,
loaded_config
)
else
:
create_folder
(
config_path
,
True
)
json
.
dump
(
config
,
open
(
config_path
,
'w'
),
indent
=
4
)
...
...
utils.py
View file @
7acdc31c
from
typing
import
Mapping
class
DotDict
(
dict
):
"""Normal dict with additional dot access for all keys"""
...
...
@@ -13,3 +15,22 @@ def all_equal(iterator):
except
StopIteration
:
return
True
return
all
(
first
==
rest
for
rest
in
iterator
)
def
recursive_dict_update
(
d
,
u
):
"""Updates the first dict argument, using second dictionary recursively.
Examples:
>>> d = {'sub_dict': {'a': 1, 'b': 2}, 'outer': 42}
>>> u = {'sub_dict': {'a': 5, 'c': 10}, 'outer': 41, 'outer2': 43}
>>> recursive_dict_update(d, u)
{'sub_dict': {'a': 5, 'b': 2, 'c': 10}, 'outer': 41, 'outer2': 43}
"""
d
=
d
.
copy
()
for
k
,
v
in
u
.
items
():
if
isinstance
(
v
,
Mapping
):
r
=
recursive_dict_update
(
d
.
get
(
k
,
{}),
v
)
d
[
k
]
=
r
else
:
d
[
k
]
=
u
[
k
]
return
d
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment