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
Frederik Hennig
pystencils
Commits
9439a25f
Commit
9439a25f
authored
May 04, 2022
by
Jan Hönig
Browse files
Made CreateKernelConfig pickable
parent
e4766ca5
Changes
1
Hide whitespace changes
Inline
Side-by-side
pystencils/config.py
View file @
9439a25f
...
...
@@ -125,6 +125,14 @@ class CreateKernelConfig:
periodicity kernel, that access the field outside the iteration bounds. Use with care!
"""
class
DataTypeFactory
:
"""Because of pickle, we need to have a nested class, instead of a lambda in __post_init__"""
def
__init__
(
self
,
dt
):
self
.
dt
=
dt
def
__call__
(
self
):
return
BasicType
(
self
.
dt
)
def
__post_init__
(
self
):
# ---- Legacy parameters
# TODO Sane defaults: Check for abmigous types like "float", python float, which are dangerous for users
...
...
@@ -145,8 +153,9 @@ class CreateKernelConfig:
# Normalise data types
if
not
isinstance
(
self
.
data_type
,
dict
):
dt
=
copy
(
self
.
data_type
)
# The copy is necessary because BasicType has sympy shinanigans
self
.
data_type
=
defaultdict
(
lambda
:
BasicType
(
dt
))
self
.
data_type
=
defaultdict
(
self
.
DataTypeFactory
(
dt
))
if
not
isinstance
(
self
.
default_number_float
,
BasicType
):
self
.
default_number_float
=
BasicType
(
self
.
default_number_float
)
if
not
isinstance
(
self
.
default_number_int
,
BasicType
):
self
.
default_number_int
=
BasicType
(
self
.
default_number_int
)
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