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
9439a25f
Commit
9439a25f
authored
3 years ago
by
Jan Hönig
Browse files
Options
Downloads
Patches
Plain Diff
Made CreateKernelConfig pickable
parent
e4766ca5
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!292
Rebase of pystencils Type System
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/config.py
+10
-1
10 additions, 1 deletion
pystencils/config.py
with
10 additions
and
1 deletion
pystencils/config.py
+
10
−
1
View file @
9439a25f
...
@@ -125,6 +125,14 @@ class CreateKernelConfig:
...
@@ -125,6 +125,14 @@ class CreateKernelConfig:
periodicity kernel, that access the field outside the iteration bounds. Use with care!
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
):
def
__post_init__
(
self
):
# ---- Legacy parameters
# ---- Legacy parameters
# TODO Sane defaults: Check for abmigous types like "float", python float, which are dangerous for users
# TODO Sane defaults: Check for abmigous types like "float", python float, which are dangerous for users
...
@@ -145,8 +153,9 @@ class CreateKernelConfig:
...
@@ -145,8 +153,9 @@ class CreateKernelConfig:
# Normalise data types
# Normalise data types
if
not
isinstance
(
self
.
data_type
,
dict
):
if
not
isinstance
(
self
.
data_type
,
dict
):
dt
=
copy
(
self
.
data_type
)
# The copy is necessary because BasicType has sympy shinanigans
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
):
if
not
isinstance
(
self
.
default_number_float
,
BasicType
):
self
.
default_number_float
=
BasicType
(
self
.
default_number_float
)
self
.
default_number_float
=
BasicType
(
self
.
default_number_float
)
if
not
isinstance
(
self
.
default_number_int
,
BasicType
):
if
not
isinstance
(
self
.
default_number_int
,
BasicType
):
self
.
default_number_int
=
BasicType
(
self
.
default_number_int
)
self
.
default_number_int
=
BasicType
(
self
.
default_number_int
)
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