Skip to content

Commit

Permalink
Release v2.1.1.1 (#57)
Browse files Browse the repository at this point in the history
* Solver dummy extension (#48)

* Rename fulfilledAction, fulfilled_action -> markActionFulfilled, mark_action_fulfilled. #29

* Changing API call isTimestepComplete to is TimeWindowComplete

* Extends solverdummy to include data transfer

* Changing non-PEP8 complaint variable names

* Removing parallel solverdummy

Co-authored-by: BenjaminRueth <[email protected]>
Co-authored-by: ishaandesai <[email protected]>

* Provide compiler_directive language_level to avoid warning.

* Add CHANGELOG

* Add release guide

* Update CHANGELOG.md

* Bump version to release for preCICE v2.1.1

Co-authored-by: Kyle Davis <[email protected]>
Co-authored-by: BenjaminRueth <[email protected]>
  • Loading branch information
3 people authored Oct 15, 2020
1 parent 7307c87 commit 2d3018a
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 5 deletions.
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Changelog of Python language bindings for preCICE

All notable changes to this project will be documented in this file.

## 2.1.1.1

* Bindings can now handle mesh initialization with no vertices. This behavior is consistent with the C++ preCICE API.
* Adds a CHANGELOG to the project.

## 2.1.0.1

* Update solverdummy to include data transfer.

## 2.0.2.1

* No relevant features or fixes. This version is released for compatibility reasons.

## 2.0.1.1

* No relevant features or fixes. This version is released for compatibility reasons.

## 2.0.0.2

* Improvement of PyPI intergration.

## 2.0.0.1

* Introduces new versioning system. See https://github.com/precice/python-bindings/issues/31.
* First independent release of the python bindings.
* Name the package `pyprecice`.
* Publish package on [PyPI](https://pypi.org/project/pyprecice/).
19 changes: 19 additions & 0 deletions docs/ReleaseGuide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Guide to release new version of python-bindings
The developer who is releasing a new version of the python-bindings is expected to follow this work flow

1. The release of the `python-bindings` repository is made directly from the latest commit of the `develop` branch (no independent release branch).

2. Bump the version to the appropriately in [`setup.py`](https://github.com/precice/python-bindings/blob/develop/setup.py) (i.e. `precice_version = version.Version("2.1.1")` and `bindings_version = version.Version("1")`). *Note:* If a pre-release version is being made then the `rc` key in the `bindings_version` attached (i.e. `bindings_version = version.Version("1rc1")`).

3. [Open a Pull Request from `develop` --> `master`](https://github.com/precice/python-bindings/compare/master...develop) named after the version (i.e. `Release v2.1.1.1`) and briefly describe the new features of the release in the PR description.

4. [Draft a New Release](https://github.com/precice/python-bindings/releases/new) in the `Releases` section of the repository page in a web browser. The release tag needs to be the exact version number (i.e.`v2.1.1.1` or `v2.1.1.1rc1`, compare to [existing tags](https://github.com/precice/python-bindings/tags)). Use `@target:master`. Release title is also the version number (i.e. `v2.1.1.1` or `v2.1.1.1rc1`, compare to [existing releases](https://github.com/precice/python-bindings/tags)).
*Note:* If it is a pre-release then the option *This is a pre-release* needs to be selected at the bottom of the page. Use `@target:develop` for a pre-release, since we will never merge a pre-release into master.

a) If a pre-release is made: Directly hit the "Publish release" button in your Release Draft. Now you can check the artifacts (e.g. release on [PyPI](https://pypi.org/project/pyprecice/#history)) of the release. *Note:* As soon as a new tag is created github actions will take care of deploying the new version on PyPI using [this workflow](https://github.com/precice/python-bindings/actions?query=workflow%3A%22Upload+Python+Package%22).

b) If this is a "real" release: As soon as one approving review is made, merge the release PR (`develop`) into `master`.

6. Merge `master` into `develop` for synchronization of `develop`.

7. If everything is in order up to this point then the new version can be released by hitting the "Publish release" button in your Release Draft.
17 changes: 13 additions & 4 deletions precice.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -446,8 +446,12 @@ cdef class Interface:
"""
if not isinstance(position, np.ndarray):
position = np.asarray(position)
dimensions = position.size
assert(dimensions == self.get_dimensions())
if len(position) > 0:
dimensions = position.size
assert(dimensions == self.get_dimensions())
elif len(position) == 0:
dimensions = self.get_dimensions()

cdef np.ndarray[double, ndim=1] _position = np.ascontiguousarray(position, dtype=np.double)
vertex_id = self.thisptr.setMeshVertex(mesh_id, <const double*>_position.data)
return vertex_id
Expand Down Expand Up @@ -516,8 +520,13 @@ cdef class Interface:
"""
if not isinstance(positions, np.ndarray):
positions = np.asarray(positions)
size, dimensions = positions.shape
assert(dimensions == self.get_dimensions())
if len(positions) > 0:
size, dimensions = positions.shape
assert(dimensions == self.get_dimensions())
elif len(positions) == 0:
size = positions.shape[0]
dimensions = self.get_dimensions()

cdef np.ndarray[double, ndim=1] _positions = np.ascontiguousarray(positions.flatten(), dtype=np.double)
cdef np.ndarray[int, ndim=1] vertex_ids = np.empty(size, dtype=np.int32)
self.thisptr.setMeshVertices (mesh_id, size, <const double*>_positions.data, <int*>vertex_ids.data)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# name of Interfacing API
APPNAME = "pyprecice"
# this version should be in sync with the latest supported preCICE version
precice_version = version.Version("2.1.0") # todo: should be replaced with precice.get_version(), if possible or we should add an assertion that makes sure that the version of preCICE is actually supported
precice_version = version.Version("2.1.1") # todo: should be replaced with precice.get_version(), if possible or we should add an assertion that makes sure that the version of preCICE is actually supported
# this version number may be increased, if changes for the bindings are required
bindings_version = version.Version("1")
APPVERSION = version.Version(str(precice_version) + "." + str(bindings_version))
Expand Down
33 changes: 33 additions & 0 deletions test/test_bindings_module.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ class TestBindings(TestCase):
positions = list(list(positions[i,j] for j in range(positions.shape[1])) for i in range(positions.shape[0]))
self.assertTrue(np.array_equal(np.array(range(n_fake_vertices)), solver_interface.set_mesh_vertices(fake_mesh_id, positions)))

def test_set_mesh_vertices_empty_list (self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
positions = []
n_fake_vertices = 0
self.assertTrue(np.array_equal(np.array(range(n_fake_vertices)), solver_interface.set_mesh_vertices(fake_mesh_id, positions)))

def test_set_mesh_vertices_tuple (self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
Expand All @@ -68,6 +75,13 @@ class TestBindings(TestCase):
positions = tuple(tuple(positions[i,j] for j in range(positions.shape[1])) for i in range(positions.shape[0]))
self.assertTrue(np.array_equal(np.array(range(n_fake_vertices)), solver_interface.set_mesh_vertices(fake_mesh_id, positions)))

def test_set_mesh_vertices_empty_tuple (self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
positions = ()
n_fake_vertices = 0
self.assertTrue(np.array_equal(np.array(range(n_fake_vertices)), solver_interface.set_mesh_vertices(fake_mesh_id, positions)))

def test_set_mesh_vertices_mixed (self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
Expand All @@ -84,20 +98,39 @@ class TestBindings(TestCase):
position = np.random.rand(fake_dimension)
self.assertTrue(0 == solver_interface.set_mesh_vertex(fake_mesh_id, position))

def test_set_mesh_vertex_empty(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
fake_dimension = 0 # compare to test/SolverInterface.cpp, fake_dimensions
position = np.random.rand(fake_dimension)
self.assertTrue(0 == solver_interface.set_mesh_vertex(fake_mesh_id, position))

def test_set_mesh_vertex_list(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
fake_dimension = 3 # compare to test/SolverInterface.cpp, fake_dimensions
position = list(np.random.rand(fake_dimension))
self.assertTrue(0 == solver_interface.set_mesh_vertex(fake_mesh_id, position))

def test_set_mesh_vertex_empty_list(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
position = []
self.assertTrue(0 == solver_interface.set_mesh_vertex(fake_mesh_id, position))

def test_set_mesh_vertex_tuple(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
fake_dimension = 3 # compare to test/SolverInterface.cpp, fake_dimensions
position = tuple(np.random.rand(fake_dimension))
self.assertTrue(0 == solver_interface.set_mesh_vertex(fake_mesh_id, position))

def test_set_mesh_vertex_empty_tuple(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
position = ()
self.assertTrue(0 == solver_interface.set_mesh_vertex(fake_mesh_id, position))

def test_get_mesh_vertex_ids_from_positions(self):
solver_interface = precice.Interface("test", "dummy.xml", 0, 1)
fake_mesh_id = 0 # compare to test/SolverInterface.cpp, fake_mesh_id
Expand Down

0 comments on commit 2d3018a

Please sign in to comment.