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
51d36ff4
Commit
51d36ff4
authored
5 years ago
by
Stephan Seitz
Browse files
Options
Downloads
Patches
Plain Diff
Correctly implement {is_positive,is_real,is_integer} for TypedSymbol
parent
a9d6eb0a
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!14
Remove floor, ceiling for integer symbols
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/data_types.py
+20
-2
20 additions, 2 deletions
pystencils/data_types.py
with
20 additions
and
2 deletions
pystencils/data_types.py
+
20
−
2
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
):
...
...
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