Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jan Hönig
pystencils
Commits
6f74f2ab
Commit
6f74f2ab
authored
Oct 26, 2021
by
Markus Holzer
Committed by
Helen Schottenhamml
Oct 26, 2021
Browse files
Clean up and Bug Fixes
parent
a3cec2ce
Changes
27
Expand all
Hide whitespace changes
Inline
Side-by-side
pystencils_tests/test_fd_derivation.ipynb
View file @
6f74f2ab
This diff is collapsed.
Click to expand it.
pystencils_tests/test_fvm.py
View file @
6f74f2ab
...
...
@@ -117,6 +117,7 @@ def test_advection_diffusion_2d(velocity):
advection_diffusion
.
runners
[
2
](
velocity
)
@
pytest
.
mark
.
longrun
@
pytest
.
mark
.
parametrize
(
"velocity"
,
list
(
product
([
0
,
-
0.047
,
0.041
],
[
0
,
-
0.031
,
0.023
],
[
0
,
-
0.017
,
0.011
])))
def
test_advection_diffusion_3d
(
velocity
):
if
3
not
in
advection_diffusion
.
runners
:
...
...
pystencils_tests/test_kerncraft_coupling.py
View file @
6f74f2ab
...
...
@@ -44,7 +44,6 @@ def test_compilation():
print
(
mine
)
@
pytest
.
mark
.
kerncraft
def
analysis
(
kernel
,
machine
,
model
=
'ecmdata'
):
if
model
==
'ecmdata'
:
model
=
ECMData
(
kernel
,
machine
,
KerncraftParameters
())
...
...
pystencils_tests/test_sympy_optimizations.py
deleted
100644 → 0
View file @
a3cec2ce
import
pytest
import
sympy
as
sp
import
pystencils
as
ps
from
pystencils.math_optimizations
import
HAS_REWRITING
,
optimize_assignments
,
optims_pystencils_cpu
,
optimize_ast
@
pytest
.
mark
.
skipif
(
not
HAS_REWRITING
,
reason
=
"need sympy.codegen.rewriting"
)
def
test_sympy_optimizations
():
for
target
in
(
ps
.
Target
.
CPU
,
ps
.
Target
.
GPU
):
for
op_ast
in
(
True
,
False
):
x
,
y
,
z
=
ps
.
fields
(
'x, y, z: float32[2d]'
)
# Triggers Sympy's expm1 optimization
# Sympy's expm1 optimization is tedious to use and the behaviour is highly depended on the sympy version. In
# some cases the exp expression has to be encapsulated in brackets or multiplied with 1 or 1.0
# for sympy to work properly ...
assignments
=
ps
.
AssignmentCollection
({
x
[
0
,
0
]:
1.0
*
(
sp
.
exp
(
y
[
0
,
0
])
-
1
)
})
if
not
op_ast
:
assignments
=
optimize_assignments
(
assignments
,
optims_pystencils_cpu
)
print
(
assignments
)
ast
=
ps
.
create_kernel
(
assignments
,
config
=
ps
.
CreateKernelConfig
(
target
=
target
))
if
op_ast
:
optimize_ast
(
ast
,
optims_pystencils_cpu
)
code
=
ps
.
get_code_str
(
ast
)
assert
'expm1('
in
code
@
pytest
.
mark
.
skipif
(
not
HAS_REWRITING
,
reason
=
"need sympy.codegen.rewriting"
)
def
test_evaluate_constant_terms
():
for
target
in
(
ps
.
Target
.
CPU
,
ps
.
Target
.
GPU
):
x
,
y
,
z
=
ps
.
fields
(
'x, y, z: float32[2d]'
)
# Triggers Sympy's cos optimization
assignments
=
ps
.
AssignmentCollection
({
x
[
0
,
0
]:
-
sp
.
cos
(
1
)
+
y
[
0
,
0
]
})
assignments
=
optimize_assignments
(
assignments
,
optims_pystencils_cpu
)
ast
=
ps
.
create_kernel
(
assignments
,
config
=
ps
.
CreateKernelConfig
(
target
=
target
))
code
=
ps
.
get_code_str
(
ast
)
assert
'cos('
not
in
code
print
(
code
)
@
pytest
.
mark
.
skipif
(
not
HAS_REWRITING
,
reason
=
"need sympy.codegen.rewriting"
)
def
test_do_not_evaluate_constant_terms
():
optimizations
=
ps
.
math_optimizations
.
optims_pystencils_cpu
optimizations
.
remove
(
ps
.
math_optimizations
.
evaluate_constant_terms
)
for
target
in
(
ps
.
Target
.
CPU
,
ps
.
Target
.
GPU
):
x
,
y
,
z
=
ps
.
fields
(
'x, y, z: float32[2d]'
)
assignments
=
ps
.
AssignmentCollection
({
x
[
0
,
0
]:
-
sp
.
cos
(
1
)
+
y
[
0
,
0
]
})
ast
=
ps
.
create_kernel
(
assignments
,
config
=
ps
.
CreateKernelConfig
(
target
=
target
))
code
=
ps
.
get_code_str
(
ast
)
assert
'cos('
in
code
print
(
code
)
pystencils_tests/test_types.py
View file @
6f74f2ab
...
...
@@ -5,7 +5,7 @@ import ctypes
import
pystencils
as
ps
from
pystencils
import
data_types
from
pystencils.data_types
import
TypedSymbol
,
get_type_of_expression
,
VectorType
,
collate_types
,
create_type
,
\
from
pystencils.data_types
import
TypedSymbol
,
get_type_of_expression
,
VectorType
,
collate_types
,
create_type
,
\
typed_symbols
,
type_all_numbers
,
matrix_symbols
,
cast_func
,
pointer_arithmetic_func
,
ctypes_from_llvm
,
PointerType
...
...
@@ -114,11 +114,11 @@ def test_Basic_data_type():
assert
s
.
dtype
.
is_uint
()
assert
s
.
dtype
.
is_complex
()
==
0
assert
typed_symbols
(
(
"s"
)
,
str
).
dtype
.
is_other
()
assert
typed_symbols
(
(
"s"
)
,
bool
).
dtype
.
is_other
()
assert
typed_symbols
(
(
"s"
)
,
np
.
void
).
dtype
.
is_other
()
assert
typed_symbols
(
"s"
,
str
).
dtype
.
is_other
()
assert
typed_symbols
(
"s"
,
bool
).
dtype
.
is_other
()
assert
typed_symbols
(
"s"
,
np
.
void
).
dtype
.
is_other
()
assert
typed_symbols
(
(
"s"
)
,
np
.
float64
).
dtype
.
base_name
==
'double'
assert
typed_symbols
(
"s"
,
np
.
float64
).
dtype
.
base_name
==
'double'
# removed for old sympy version
# assert typed_symbols(("s"), np.float64).dtype.sympy_dtype == typed_symbols(("s"), float).dtype.sympy_dtype
...
...
pytest.ini
View file @
6f74f2ab
...
...
@@ -5,6 +5,14 @@ addopts = --doctest-modules --durations=20 --cov-config pytest.ini
markers
=
kerncraft:
tests
depending
on
kerncraft
notebook:
mark
for
notebooks
# these warnings all come from third party libraries.
filterwarnings
=
ignore:an
integer
is
required:DeprecationWarning
ignore:\s*load
will
be
removed,
use:PendingDeprecationWarning
ignore:the
imp
module
is
deprecated
in
favour
of
importlib:DeprecationWarning
ignore:.*is
a
deprecated
alias
for
the
builtin
`bool`:DeprecationWarning
ignore:'contextfilter'
is
renamed
to
'pass_context':DeprecationWarning
ignore:Using
or
importing
the
ABCs
from
'collections'
instead
of
from
'collections.abc':DeprecationWarning
[run]
branch
=
True
...
...
setup.py
View file @
6f74f2ab
import
distutils
import
io
import
os
import
sys
from
contextlib
import
redirect_stdout
from
importlib
import
import_module
...
...
@@ -11,6 +10,7 @@ import versioneer
try
:
import
cython
# noqa
USE_CYTHON
=
True
except
ImportError
:
USE_CYTHON
=
False
...
...
@@ -32,13 +32,13 @@ class SimpleTestRunner(distutils.cmd.Command):
@
staticmethod
def
_run_tests_in_module
(
test
):
"""Short test runner function - to work also if py.test is not installed."""
test
=
'pystencils_tests.
'
+
test
test
=
f
'pystencils_tests.
{
test
}
'
mod
,
function_name
=
test
.
rsplit
(
'.'
,
1
)
if
isinstance
(
mod
,
str
):
mod
=
import_module
(
mod
)
func
=
getattr
(
mod
,
function_name
)
print
(
f
" ->
{
function_name
}
in
{
mod
.
__name__
}
"
)
print
(
f
" ->
{
function_name
}
in
{
mod
.
__name__
}
"
)
with
redirect_stdout
(
io
.
StringIO
()):
func
()
...
...
@@ -76,7 +76,7 @@ def cython_extensions(*extensions):
def
get_cmdclass
():
cmdclass
=
{
"quicktest"
:
SimpleTestRunner
}
cmdclass
=
{
"quicktest"
:
SimpleTestRunner
}
cmdclass
.
update
(
versioneer
.
get_cmdclass
())
return
cmdclass
...
...
@@ -91,7 +91,7 @@ setuptools.setup(name='pystencils',
author_email
=
'cs10-codegen@fau.de'
,
url
=
'https://i10git.cs.fau.de/pycodegen/pystencils/'
,
packages
=
[
'pystencils'
]
+
[
'pystencils.'
+
s
for
s
in
setuptools
.
find_packages
(
'pystencils'
)],
install_requires
=
[
'sympy>=1.
2
'
,
'numpy>=1.8.0'
,
'appdirs'
,
'joblib'
],
install_requires
=
[
'sympy>=1.
5.1,<=1.9
'
,
'numpy>=1.8.0'
,
'appdirs'
,
'joblib'
],
package_data
=
{
'pystencils'
:
[
'include/*.h'
,
'kerncraft_coupling/templates/*'
,
'backends/cuda_known_functions.txt'
,
...
...
@@ -122,7 +122,9 @@ setuptools.setup(name='pystencils',
'autodiff'
:
[
'pystencils-autodiff'
],
'doc'
:
[
'sphinx'
,
'sphinx_rtd_theme'
,
'nbsphinx'
,
'sphinxcontrib-bibtex'
,
'sphinx_autodoc_typehints'
,
'pandoc'
],
'use_cython'
:
[
'Cython'
]
'use_cython'
:
[
'Cython'
],
'kerncraft'
:
[
'osaca'
,
'kerncraft'
],
'llvm_jit'
:
[
'llvmlite'
]
},
tests_require
=
[
'pytest'
,
'pytest-cov'
,
...
...
Prev
1
2
Next
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