Skip to content

Commit bda0043

Browse files
committed
TST: Add additional test to verify linking
1 parent 23e3e6f commit bda0043

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

.github/workflows/install_test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ jobs:
166166
167167
cmake \
168168
-DCARMA_INSTALL_LIB=ON \
169+
-DCMAKE_INSTALL_PREFIX:PATH=. \
169170
-DCARMA_TEST_MODE=${{matrix.carma_test_mode}} \
170171
-DCMAKE_C_COMPILER=${{ matrix.config.cc }} \
171172
-DCMAKE_CXX_COMPILER=${{ matrix.config.cxx }} \
@@ -179,7 +180,7 @@ jobs:
179180
cd integration_test/build
180181
cmake \
181182
--build . \
182-
--target ${{ matrix.config.target }} \
183+
--target install \
183184
--config ${{ matrix.config.build_type }}
184185
185186
- name: Test

integration_test/src/integration_test.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ void bind_test_is_f_contiguous(py::module& m) {
1212
"Test is F contiguous");
1313
}
1414

15+
py::array_t<double> test_mat_roundtrip(py::array_t<double>& arr) {
16+
// call function to be tested
17+
arma::Mat<double> M = carma::arr_to_mat<double>(std::move(arr));
18+
return carma::mat_to_arr(M);
19+
}
20+
21+
void bind_test_mat_roundtrip(py::module& m) {
22+
m.def("mat_roundtrip", &test_mat_roundtrip, "Test mat_roundtrip");
23+
}
24+
1525
PYBIND11_MODULE(integration_test_carma, m) {
1626
bind_test_is_f_contiguous(m);
27+
bind_test_mat_roundtrip(m);
1728
}

integration_test/tests/integration_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,13 @@ def test_is_f_contiguous():
1313
m = 'C order array should not be F contiguous'
1414
sample = np.ones((10, 2), dtype=np.float64, order='C')
1515
assert carma.is_f_contiguous(sample) is False, m
16+
17+
18+
def test_mat_roundtrip():
19+
"""Test mat_roundtrip."""
20+
og_sample = np.asarray(
21+
np.random.normal(size=(50, 2)), dtype=np.float64, order='F'
22+
)
23+
sample = og_sample.copy()
24+
out = carma.mat_roundtrip(sample)
25+
assert np.allclose(og_sample, out)

0 commit comments

Comments
 (0)