Skip to content

Commit

Permalink
sys.simulate_imp() patch (#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjohnsen authored Aug 8, 2022
1 parent 6aad4e5 commit ae14583
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vcpkg/scripts/buildsystems/
############ PROJECT SPECIFICATIONS
################################################################################
# set project name and version (MAJOR.minor.patch)
project(ldsCtrlEst VERSION 0.8.0 LANGUAGES CXX C)
project(ldsCtrlEst VERSION 0.8.1 LANGUAGES CXX C)
include(CTest)
# some name variants I will be using:
set(CMAKE_PROJECT_NAME_CAP LDSCTRLEST)#all caps
Expand Down
2 changes: 1 addition & 1 deletion python/ldsctrlest/bindutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ py::class_<Sys> define_System(py::module &m) {
}, "simulates for multiple trials/timesteps. u is list of n_u X n_t arrays")
// see matlab/[GLDS|PLDS]/simulate_imp.m
.def("simulate_imp", [](Sys& sys, size_t n_t) {
vector<Matrix> cx_imp(sys.n_u(), Matrix(sys.n_x(), n_t, fill::zeros));
vector<Matrix> cx_imp(sys.n_u(), Matrix(sys.n_y(), n_t, fill::zeros));
Vector u_imp(n_t, fill::zeros);
u_imp[0] = 1;
for (size_t which_u = 0; which_u < sys.n_u(); which_u++) {
Expand Down
18 changes: 18 additions & 0 deletions python/tests/test_sys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"""Some tests that can be easily re-used for both Gaussian and Poisson
systems. In hindsight, should have structured tests this way instead
of test_glds.py and test_plds.py"""

import numpy as np
import pytest
from ldsctrlest import gaussian, poisson

@pytest.mark.parametrize("n_u", [1, 2, 4])
@pytest.mark.parametrize("n_x", [1, 2, 4])
@pytest.mark.parametrize("n_y", [1, 2, 4])
@pytest.mark.parametrize("n_t", [1, 100])
@pytest.mark.parametrize("module", [gaussian, poisson])
def test_simulate_imp(module, n_u, n_x, n_y, n_t):
sys = module.System(n_u, n_x, n_y, .001)
cx_imp = sys.simulate_imp(n_t)
assert len(cx_imp) == n_u
assert cx_imp[0].shape == (n_y, n_t)
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lds-ctrl-est",
"version-string": "0.8.0",
"version-string": "0.8.1",
"dependencies": [
"armadillo",
"hdf5"
Expand Down

0 comments on commit ae14583

Please sign in to comment.