Skip to content

Commit

Permalink
new version, better test, better integration with settings
Browse files Browse the repository at this point in the history
  • Loading branch information
teseoch committed Mar 22, 2019
1 parent b0c8179 commit 45847c6
Show file tree
Hide file tree
Showing 13 changed files with 38 additions and 75 deletions.
34 changes: 14 additions & 20 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,33 @@ environment:
PYTHON_VERSION: "3.6.x" # currently 3.6.8
PYTHON_ARCH: "64"

# - config: Release
# PYTHON: "C:\\Python35-x64"
# PYTHON_VERSION: "3.5.x" # currently 3.5.8
# PYTHON_ARCH: "64"
- config: Release
PYTHON: "C:\\Python35-x64"
PYTHON_VERSION: "3.5.x" # currently 3.5.8
PYTHON_ARCH: "64"

# - config: Release
# PYTHON: "C:\\Python27-x64"
# PYTHON_VERSION: "2.7.x" # currently 2.7.15
# PYTHON_ARCH: "64"
- config: Release
PYTHON: "C:\\Python27-x64"
PYTHON_VERSION: "2.7.x" # currently 2.7.15
PYTHON_ARCH: "64"
install:
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- "python --version"
- "python -c \"import struct; print(struct.calcsize('P') * 8)\""
- "python -m pip install numpy"
- "python -c \"import numpy as np;import sys;print(np.get_include())\""

# - "dir C:\\Python36-x64\\lib\\site-packages\\numpy\\core\\include"
# - "dir C:\\Python36-x64\\lib\\site-packages\\numpy\\core\\include\\numpy"
build:
parallel: true
build_script:
# - "MSBuild /help"
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- cd c:\projects\polyfempy
- "python --version"
# - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
# - set MSBuildOptions=/v:m /p:Configuration=%config% /logger:%MSBuildLogger%
- python setup.py install
- python setup.py build --debug install

test_script:
- cd c:\projects\polyfempy
- python tests/bending.py
- python tests/gravity.py
- python tests/inflation.py
- python tests/plane_hole.py
- python tests/torsion.py
- python test/test_bending.py
- python test/test_gravity.py
- python test/test_inflation.py
- python test/test_plane_hole.py
- python test/test_torsion.py
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ install:
- pip install numpy
- pip install plotly
script:
- python setup.py install
- python tests/bending.py
- python tests/gravity.py
- python tests/inflation.py
- python tests/plane_hole.py
- python tests/torsion.py
- python setup.py build --debug install
- python test/test_bending.py
- python test/test_gravity.py
- python test/test_inflation.py
- python test/test_plane_hole.py
- python test/test_torsion.py
# deploy:
# provider: pypi
# user: "teseoch"
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@



<aside class="warning">
The python bindings are in alpha. Expect a lot of API changes and possible bugs. Use at your own peril!
</aside>

The python bindings are in alpha. Expect a lot of API changes and possible bugs. Use at your own peril!

<br/>
I am making efforts to provide a simple python interface to Polyfem.

For doing so I am maintaining a *conda* package which can be easily installed [https://anaconda.org/conda-forge/polyfempy](https://anaconda.org/conda-forge/polyfempy).
Expand All @@ -22,7 +22,7 @@ Note that the conda deployment is slow and this tutorial will follow the deploym

If you hare in a hurry for the juicy latest feature you can clone the repository [Polyfem-python](https://github.com/polyfem/polyfem-python) and use `pip` to install:
```
python setup.py develop
python setup.py install
```
and
```
Expand All @@ -32,4 +32,6 @@ for testing.

For python documentation [https://polyfem.github.io/python/](https://polyfem.github.io/python/).

For python jupyter notebook [https://polyfem.github.io/python_examples/](https://polyfem.github.io/python_examples/).

For full documentation see [https://polyfem.github.io/](https://polyfem.github.io/).
2 changes: 1 addition & 1 deletion cmake/PolyfemPythonDownloadExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ endfunction()
function(polyfem_python_download_polyfem)
polyfem_python_download_project(polyfem
GIT_REPOSITORY https://github.com/polyfem/polyfem.git
GIT_TAG 545389f97c37c465de56035cc975dcd980f27648
GIT_TAG 758b9b2cd9fc960f9d3fef777b7ae072d4c535b0
)
endfunction()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,5 @@ def build_extension(self, ext):
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License"
],
test_suite="tests"
test_suite="test"
)
5 changes: 3 additions & 2 deletions src/binding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ PYBIND11_MODULE(polyfempy, m) {

.def(py::init<>())

.def("settings", [](polyfem::State &self, const std::string &json) {
.def("settings", [](polyfem::State &self, const py::object &json) {
init_globals(self);
self.init(json::parse(json));
const std::string json_string = py::str(json);
self.init(json::parse(json_string));
},
"load PDE and problem parameters from the settings",
py::arg("json"))
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/bending.py → test/test_bending.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_run(self):

solver = pf.Solver()

solver.settings(str(settings))
solver.settings(settings)
solver.load_mesh_from_path_and_tags(mesh_path, tag_path)

solver.solve()
Expand Down
2 changes: 1 addition & 1 deletion tests/gravity.py → test/test_gravity.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def test_run(self):
settings.set_problem(problem)

solver = pf.Solver()
solver.settings(str(settings))
solver.settings(settings)

# This time we are using pts and faces instead of loading from the disk
solver.set_mesh(pts, faces)
Expand Down
4 changes: 2 additions & 2 deletions tests/inflation.py → test/test_inflation.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_run(self):



solver.settings(str(settings))
solver.settings(settings)
solver.load_mesh_from_path(mesh_path)

solver.solve()
Expand All @@ -48,7 +48,7 @@ def test_run(self):
settings.set_problem(problem)

#reload the parameters and mesh
solver.settings(settings.serialize())
solver.settings(settings)
solver.load_mesh_from_path(mesh_path)

#set the rhs as prev sol
Expand Down
2 changes: 1 addition & 1 deletion tests/plane_hole.py → test/test_plane_hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_run(self):

solver = pf.Solver()

solver.settings(str(settings))
solver.settings(settings)
solver.load_mesh_from_path(mesh_path)

solver.solve()
Expand Down
3 changes: 2 additions & 1 deletion tests/torsion.py → test/test_torsion.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
import platform


class TorsionTest(unittest.TestCase):
def test_run(self):
root_folder = os.path.join("..", "3rdparty.nosync" if platform.system() == 'Darwin' else "3rdparty", "data")
Expand Down Expand Up @@ -39,7 +40,7 @@ def test_run(self):
solver = pf.Solver()


solver.settings(str(settings))
solver.settings(settings)
solver.load_mesh_from_path(mesh_path)

solver.solve()
Expand Down
35 changes: 0 additions & 35 deletions tests/utils.py

This file was deleted.

0 comments on commit 45847c6

Please sign in to comment.