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
Markus Holzer
pystencils
Commits
65c7e576
Commit
65c7e576
authored
3 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Implemented Logarithm
parent
ea943334
No related branches found
No related tags found
No related merge requests found
Pipeline
#39713
passed
3 years ago
Stage: pretest
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pystencils/kernel_contrains_check.py
+2
-1
2 additions, 1 deletion
pystencils/kernel_contrains_check.py
pystencils/typing/leaf_typing.py
+1
-1
1 addition, 1 deletion
pystencils/typing/leaf_typing.py
pystencils_tests/test_logarithm.py
+26
-0
26 additions, 0 deletions
pystencils_tests/test_logarithm.py
with
29 additions
and
2 deletions
pystencils/kernel_contrains_check.py
+
2
−
1
View file @
65c7e576
...
...
@@ -10,10 +10,11 @@ from pystencils.field import Field
from
pystencils.node_collection
import
NodeCollection
from
pystencils.transformations
import
NestedScopes
# TODO use this in Constraint Checker
accepted_functions
=
[
sp
.
Pow
,
sp
.
sqrt
,
sp
.
log
,
# TODO trigonometric functions (and whatever tests will fail)
]
...
...
This diff is collapsed.
Click to expand it.
pystencils/typing/leaf_typing.py
+
1
−
1
View file @
65c7e576
...
...
@@ -212,7 +212,7 @@ class TypeAdder:
new_args
.
append
(
a
)
return
expr
.
func
(
*
new_args
)
if
new_args
else
expr
,
collated_type
elif
isinstance
(
expr
,
(
sp
.
Pow
,
sp
.
exp
,
InverseTrigonometricFunction
,
TrigonometricFunction
,
HyperbolicFunction
)):
HyperbolicFunction
,
sp
.
log
)):
args_types
=
[
self
.
figure_out_type
(
arg
)
for
arg
in
expr
.
args
]
collated_type
=
collate_types
([
t
for
_
,
t
in
args_types
])
new_args
=
[
a
if
t
.
dtype_eq
(
collated_type
)
else
CastFunc
(
a
,
collated_type
)
for
a
,
t
in
args_types
]
...
...
This diff is collapsed.
Click to expand it.
pystencils_tests/test_logarithm.py
0 → 100644
+
26
−
0
View file @
65c7e576
import
pytest
import
numpy
as
np
import
sympy
as
sp
import
pystencils
as
ps
@pytest.mark.parametrize
(
'
dtype
'
,
[
"
float64
"
,
"
float32
"
])
def
test_log
(
dtype
):
a
=
sp
.
Symbol
(
"
a
"
)
x
=
ps
.
fields
(
f
'
x:
{
dtype
}
[1d]
'
)
assignments
=
ps
.
AssignmentCollection
({
x
.
center
():
sp
.
log
(
a
)})
ast
=
ps
.
create_kernel
(
assignments
)
code
=
ps
.
get_code_str
(
ast
)
kernel
=
ast
.
compile
()
# ps.show_code(ast)
if
dtype
==
"
float64
"
:
assert
"
float
"
not
in
code
array
=
np
.
zeros
((
10
,),
dtype
=
dtype
)
kernel
(
x
=
array
,
a
=
100
)
assert
np
.
allclose
(
array
,
4.60517019
)
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