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
Jonas Plewinski
pystencils
Commits
51d36ff4
Commit
51d36ff4
authored
Aug 02, 2019
by
Stephan Seitz
Browse files
Correctly implement {is_positive,is_real,is_integer} for TypedSymbol
parent
a9d6eb0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
pystencils/data_types.py
View file @
51d36ff4
...
...
@@ -127,12 +127,30 @@ class TypedSymbol(sp.Symbol):
def
__getnewargs__
(
self
):
return
self
.
name
,
self
.
dtype
# For reference: Numpy type hierarchy https://docs.scipy.org/doc/numpy-1.13.0/reference/arrays.scalars.html
@
property
def
is_integer
(
self
):
if
hasattr
(
self
.
dtype
,
'numpy_dtype'
):
return
np
.
issubdtype
(
self
.
dtype
.
numpy_dtype
,
np
.
integer
)
return
np
.
issubdtype
(
self
.
dtype
.
numpy_dtype
,
np
.
integer
)
or
super
().
is_integer
else
:
return
False
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_positive
@
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
def
create_type
(
specification
):
...
...
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