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
Stephan Seitz
pystencils
Commits
9d019783
Commit
9d019783
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Add assumption functions to cast_func
parent
e07600cf
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/data_types.py
+31
-0
31 additions, 0 deletions
pystencils/data_types.py
pystencils/math_optimizations.py
+1
-2
1 addition, 2 deletions
pystencils/math_optimizations.py
with
32 additions
and
2 deletions
pystencils/data_types.py
+
31
−
0
View file @
9d019783
...
@@ -84,6 +84,37 @@ class cast_func(sp.Function):
...
@@ -84,6 +84,37 @@ class cast_func(sp.Function):
def
dtype
(
self
):
def
dtype
(
self
):
return
self
.
args
[
1
]
return
self
.
args
[
1
]
@property
def
is_integer
(
self
):
if
hasattr
(
self
.
dtype
,
'
numpy_dtype
'
):
return
np
.
issubdtype
(
self
.
dtype
.
numpy_dtype
,
np
.
integer
)
or
super
().
is_integer
else
:
return
super
().
is_integer
@property
def
is_negative
(
self
):
if
hasattr
(
self
.
dtype
,
'
numpy_dtype
'
):
if
np
.
issubdtype
(
self
.
dtype
.
numpy_dtype
,
np
.
unsignedinteger
):
return
False
return
super
().
is_negative
@property
def
is_nonnegative
(
self
):
if
self
.
is_negative
is
False
:
return
True
else
:
return
super
().
is_nonnegative
@property
def
is_real
(
self
):
if
hasattr
(
self
.
dtype
,
'
numpy_dtype
'
):
return
np
.
issubdtype
(
self
.
dtype
.
numpy_dtype
,
np
.
integer
)
or
\
np
.
issubdtype
(
self
.
dtype
.
numpy_dtype
,
np
.
floating
)
or
\
super
().
is_real
else
:
return
super
().
is_real
# noinspection PyPep8Naming
# noinspection PyPep8Naming
class
boolean_cast_func
(
cast_func
,
Boolean
):
class
boolean_cast_func
(
cast_func
,
Boolean
):
...
...
This diff is collapsed.
Click to expand it.
pystencils/math_optimizations.py
+
1
−
2
View file @
9d019783
...
@@ -9,7 +9,6 @@ import itertools
...
@@ -9,7 +9,6 @@ import itertools
from
pystencils
import
Assignment
from
pystencils
import
Assignment
from
pystencils.astnodes
import
SympyAssignment
from
pystencils.astnodes
import
SympyAssignment
from
pystencils.integer_functions
import
IntegerFunctionTwoArgsMixIn
try
:
try
:
from
sympy.codegen.rewriting
import
optims_c99
,
optimize
from
sympy.codegen.rewriting
import
optims_c99
,
optimize
...
@@ -38,7 +37,7 @@ def optimize_assignments(assignments, optimizations):
...
@@ -38,7 +37,7 @@ def optimize_assignments(assignments, optimizations):
if
HAS_REWRITING
:
if
HAS_REWRITING
:
assignments
=
[
Assignment
(
a
.
lhs
,
optimize
(
a
.
rhs
,
optimizations
))
assignments
=
[
Assignment
(
a
.
lhs
,
optimize
(
a
.
rhs
,
optimizations
))
if
hasattr
(
a
,
'
lhs
'
)
and
not
a
.
rhs
.
atoms
(
IntegerFunctionTwoArgsMixIn
)
if
hasattr
(
a
,
'
lhs
'
)
else
a
for
a
in
assignments
]
else
a
for
a
in
assignments
]
assignments_nodes
=
[
a
.
atoms
(
SympyAssignment
)
for
a
in
assignments
]
assignments_nodes
=
[
a
.
atoms
(
SympyAssignment
)
for
a
in
assignments
]
for
a
in
itertools
.
chain
.
from_iterable
(
assignments_nodes
):
for
a
in
itertools
.
chain
.
from_iterable
(
assignments_nodes
):
...
...
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