Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pycodegen
pystencils
Commits
7acdc31c
Commit
7acdc31c
authored
7 years ago
by
Martin Bauer
Browse files
Options
Downloads
Patches
Plain Diff
More tests
parent
65698934
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cpu/cpujit.py
+3
-12
3 additions, 12 deletions
cpu/cpujit.py
utils.py
+21
-0
21 additions, 0 deletions
utils.py
with
24 additions
and
12 deletions
cpu/cpujit.py
+
3
−
12
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
)
...
...
This diff is collapsed.
Click to expand it.
utils.py
+
21
−
0
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment