Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Plewinski
pystencils
Commits
da5cfa52
Commit
da5cfa52
authored
Sep 23, 2019
by
Stephan Seitz
Browse files
Add dtype assumptions to cast_func
parent
8479aa27
Changes
1
Hide whitespace changes
Inline
Side-by-side
pystencils/data_types.py
View file @
da5cfa52
...
...
@@ -82,6 +82,37 @@ class cast_func(sp.Function):
def
dtype
(
self
):
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
class
boolean_cast_func
(
cast_func
,
Boolean
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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