Mentions légales du service

Skip to content
Snippets Groups Projects
Commit cac5d765 authored by LEGRAND Jonathan's avatar LEGRAND Jonathan
Browse files

Merge branch 'hotfix/1.3.1'

parents c070e35e b7acef67
Branches
No related tags found
No related merge requests found
......@@ -19,7 +19,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(${PROJECT_NAME}_VERSION_MAJOR 1)
set(${PROJECT_NAME}_VERSION_MINOR 3)
set(${PROJECT_NAME}_VERSION_PATCH 0)
set(${PROJECT_NAME}_VERSION_PATCH 1)
set(${PROJECT_NAME}_VERSION
${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH})
......
......@@ -22,7 +22,7 @@ copyright = '2021, Grégoire MALANDAIN'
author = 'Grégoire MALANDAIN'
# The full version, including alpha/beta/rc tags
release = '1.3.0'
release = '1.3.1'
# -- General configuration ---------------------------------------------------
......
......@@ -15,4 +15,4 @@ dependencies:
- numpy-base
- pooch
- pytest
- vt >=1.6.0
- vt >=1.6.1
......@@ -2,7 +2,7 @@
[metadata]
name = vtpython
version = 1.3.0
version = 1.3.1
author = Gregoire Malandain
author_email = gregoire.malandain@inria.fr
description = Python wrappers for the vt library
......
......@@ -6,11 +6,13 @@ from os.path import dirname
from os.path import join
from pathlib import Path
import numpy as np
import vt
from vt.dataset import shared_data_path
class TestPointmatching(unittest.TestCase):
class TestPointmatchingFromFiles(unittest.TestCase):
@classmethod
def setUpClass(cls):
......@@ -50,3 +52,28 @@ class TestPointmatching(unittest.TestCase):
def test_pointmatching_vectorfield(self):
self._pointmatching(params='-trsf-type vectorfield -no-verbose')
class TestPointmatchingFromArrays(unittest.TestCase):
@classmethod
def setUpClass(cls):
flo_pts = [[0, 0, 0], [0, 0, 1], [0, 1, 0], [1, 0, 0]]
ref_pts = [[0, 0, 0], [0, 0, 2], [0, 2, 0], [2, 0, 0]]
cls._ref_points = vt.vtPointList(ref_pts)
cls._flo_points = vt.vtPointList(flo_pts)
cls._template_path = shared_data_path("flower_confocal_ds2x", 0)
cls._template = vt.vtImage(str(cls._template_path))
def _pointmatching(self, params=""):
out_trsf = vt.pointmatching(self._flo_points, self._ref_points,
self._template, params=params)
self.assertIsNotNone(out_trsf)
def test_pointmatching_rigid(self):
self._pointmatching(params='-trsf-type rigid -no-verbose')
def test_pointmatching_affine(self):
self._pointmatching(params='-trsf-type affine -no-verbose')
def test_pointmatching_vectorfield(self):
self._pointmatching(params='-trsf-type vectorfield -no-verbose')
......@@ -6,6 +6,7 @@ import unittest
from pathlib import Path
import numpy as np
from vt.tools import random_array
import vt
......@@ -17,20 +18,18 @@ class TestVtPointList(unittest.TestCase):
cls._points_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data",
"cell_barycenters_landmarks-t0.txt"))
cls.file_points = vt.vtPointList(cls._points_path)
cls.rand_double_points = np.ndarray(dtype='double', shape=[12, 3])
for i in range(cls.rand_double_points.shape[0]):
for j in range(cls.rand_double_points.shape[1]):
cls.rand_double_points[i, j] = random.random()
cls.rand_float_points = np.ndarray(dtype='float', shape=[15, 3])
for i in range(cls.rand_float_points.shape[0]):
for j in range(cls.rand_float_points.shape[1]):
cls.rand_float_points[i, j] = random.random()
# Create two random arrays
cls.rand_double_points = random_array(dtype='double', shape=[12, 3])
cls.rand_float_points = random_array(dtype='float', shape=[15, 3])
def _vt_np_vt(self, pts):
a = pts.copy_to_array()
l = vt.vtPointList(a)
# Test unit default value:
self.assertEqual(l.unit(), "real")
# Test spacing default value:
np.testing.assert_array_equal(l.spacing(), [1., 1., 1.])
# Save file from `vtPointList` and compare to original:
with tempfile.NamedTemporaryFile(delete=False) as pts_file, tempfile.NamedTemporaryFile(
delete=False) as array_file:
pts.write(pts_file.name)
......@@ -41,6 +40,11 @@ class TestVtPointList(unittest.TestCase):
def _np_vt_np(self, a):
pts = vt.vtPointList(a)
# Test unit default value:
self.assertEqual(pts.unit(), "real")
# Test spacing default value:
np.testing.assert_array_equal(pts.spacing(), [1., 1., 1.])
# Copy array of point and compare to original
b = pts.copy_to_array()
self.assertTrue((a == b).all())
......
......@@ -154,6 +154,9 @@ void vtPointListWrapper(py::module m) {
// Bind the method to get the spacing from the `vtPointListBridge` object
.def("spacing", &vtPointList::spacing)
// Bind the method to get the unit from the `vtPointListBridge` object
.def("unit", &vtPointList::unit)
// Bind the `__repr__` method to provide a string representation of the object
.def("__repr__", &vtPointList::toString)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment