diff --git a/.appveyor.yml b/.appveyor.yml
index a9df1bc..640c9e3 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -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
\ No newline at end of file
+ - 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
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 839a4e9..efa5593 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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"
diff --git a/README.md b/README.md
index 9680bc7..2e5542f 100644
--- a/README.md
+++ b/README.md
@@ -10,10 +10,10 @@
-
+The python bindings are in alpha. Expect a lot of API changes and possible bugs. Use at your own peril!
+
+
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).
@@ -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
```
@@ -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/).
diff --git a/cmake/PolyfemPythonDownloadExternal.cmake b/cmake/PolyfemPythonDownloadExternal.cmake
index eb80766..740181f 100644
--- a/cmake/PolyfemPythonDownloadExternal.cmake
+++ b/cmake/PolyfemPythonDownloadExternal.cmake
@@ -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()
diff --git a/setup.py b/setup.py
index 4f8fe89..35e4b8b 100644
--- a/setup.py
+++ b/setup.py
@@ -101,5 +101,5 @@ def build_extension(self, ext):
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License"
],
- test_suite="tests"
+ test_suite="test"
)
diff --git a/src/binding.cpp b/src/binding.cpp
index 364324a..e531b3b 100644
--- a/src/binding.cpp
+++ b/src/binding.cpp
@@ -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"))
diff --git a/tests/__init__.py b/test/__init__.py
similarity index 100%
rename from tests/__init__.py
rename to test/__init__.py
diff --git a/tests/bending.py b/test/test_bending.py
similarity index 97%
rename from tests/bending.py
rename to test/test_bending.py
index 2f374ef..238fa97 100644
--- a/tests/bending.py
+++ b/test/test_bending.py
@@ -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()
diff --git a/tests/gravity.py b/test/test_gravity.py
similarity index 97%
rename from tests/gravity.py
rename to test/test_gravity.py
index e86a606..e5eef7b 100644
--- a/tests/gravity.py
+++ b/test/test_gravity.py
@@ -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)
diff --git a/tests/inflation.py b/test/test_inflation.py
similarity index 96%
rename from tests/inflation.py
rename to test/test_inflation.py
index 9850a52..9ac42ec 100644
--- a/tests/inflation.py
+++ b/test/test_inflation.py
@@ -33,7 +33,7 @@ def test_run(self):
- solver.settings(str(settings))
+ solver.settings(settings)
solver.load_mesh_from_path(mesh_path)
solver.solve()
@@ -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
diff --git a/tests/plane_hole.py b/test/test_plane_hole.py
similarity index 97%
rename from tests/plane_hole.py
rename to test/test_plane_hole.py
index 714bee3..1c49acb 100644
--- a/tests/plane_hole.py
+++ b/test/test_plane_hole.py
@@ -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()
diff --git a/tests/torsion.py b/test/test_torsion.py
similarity index 97%
rename from tests/torsion.py
rename to test/test_torsion.py
index a0c6dcb..dd23960 100644
--- a/tests/torsion.py
+++ b/test/test_torsion.py
@@ -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")
@@ -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()
diff --git a/tests/utils.py b/tests/utils.py
deleted file mode 100644
index 011f013..0000000
--- a/tests/utils.py
+++ /dev/null
@@ -1,35 +0,0 @@
-import plotly.offline as plotly
-import plotly.graph_objs as go
-
-import numpy as np
-
-
-def plot(vertices, connectivity, function):
- x = vertices[:,0]
- y = vertices[:,1]
-
- if vertices.shape[1] == 3:
- z = vertices[:,2]
- else:
- z = np.zeros(x.shape, dtype=x.dtype)
-
- if connectivity.shape[1] == 3:
- f = connectivity
- else:
- f = np.ndarray([len(connectivity)*4, 3], dtype=np.int64)
- for i in range(len(connectivity)):
- f[i*4+0] = np.array([connectivity[i][1], connectivity[i][0], connectivity[i][2]])
- f[i*4+1] = np.array([connectivity[i][0], connectivity[i][1], connectivity[i][3]])
- f[i*4+2] = np.array([connectivity[i][1], connectivity[i][2], connectivity[i][3]])
- f[i*4+3] = np.array([connectivity[i][2], connectivity[i][0], connectivity[i][3]])
-
- mesh = go.Mesh3d(x=x, y=y, z=z,
- i=f[:,0], j=f[:,1], k=f[:,2],
- intensity=function, flatshading=function is not None,
- colorscale='Viridis',
- contour=dict(show=True, color='#fff'),
- hoverinfo="all")
- layout = go.Layout(scene=go.layout.Scene(aspectmode='data'))
- fig = go.Figure(data=[mesh], layout=layout)
-
- plotly.plot(fig)