Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a python version #10

Merged
merged 104 commits into from
Sep 14, 2024
Merged
Changes from 1 commit
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
ecb536c
add files for python
ygeunkim Aug 23, 2024
76bee86
Merge branch 'develop' into feature/python
ygeunkim Aug 24, 2024
4f812b5
add use_rcpp macro and setup.py that works
ygeunkim Aug 24, 2024
a5e0362
make module finding function in setup
ygeunkim Aug 24, 2024
dba8c82
Merge branch 'develop' into feature/python
ygeunkim Aug 25, 2024
9fe5050
fix setup.py to compile pybind modules
ygeunkim Aug 25, 2024
8a94099
add omp check
ygeunkim Aug 25, 2024
8a548bf
make bvharcommon header work in pybind
ygeunkim Aug 25, 2024
f032e21
add readme generated by quarto
ygeunkim Aug 25, 2024
227940a
add local installation script in readme
ygeunkim Aug 25, 2024
8293d3c
start to add modules
ygeunkim Aug 26, 2024
da410fd
use two different env
ygeunkim Aug 26, 2024
e91c0e8
add temp modules using r header
ygeunkim Aug 26, 2024
7b9818d
add quarto
ygeunkim Aug 26, 2024
483def2
add some random generation functions
ygeunkim Aug 27, 2024
14b2b42
set quartodoc locally
ygeunkim Aug 27, 2024
7cd916f
start to make ols module
ygeunkim Aug 27, 2024
a3d4063
Merge branch 'develop' into feature/python
ygeunkim Aug 29, 2024
d88e5da
Merge branch 'develop' into feature/python
ygeunkim Aug 29, 2024
b3d8865
change the ols module name
ygeunkim Aug 29, 2024
23bc6d4
fix multiple openmp linking issue
ygeunkim Aug 29, 2024
6e804a6
make test code for internal cpp ols classes
ygeunkim Aug 29, 2024
8950fba
make ols python classes
ygeunkim Aug 29, 2024
dd2bedd
will move cpp files into one directory
ygeunkim Aug 30, 2024
ee969fb
use macros for py dict
ygeunkim Aug 31, 2024
b1add63
add other methods in ols that will be defined later
ygeunkim Aug 31, 2024
ee0f5ac
start to make mcmcldlt in python
ygeunkim Aug 31, 2024
6bd4e83
Merge branch 'develop' into feature/python
ygeunkim Aug 31, 2024
6bef3b2
can do var ldlt mcmc with ssvs and horseshoe
ygeunkim Sep 1, 2024
7ed9351
use inheritance for vhar bayes
ygeunkim Sep 1, 2024
1917111
move pybind macro to bvharcommon header
ygeunkim Sep 1, 2024
62ca3fe
add ng and dl
ygeunkim Sep 1, 2024
486895d
make separate common header that defines macros
ygeunkim Sep 1, 2024
9c8cc93
try python ci
ygeunkim Sep 1, 2024
f9063d7
Merge branch 'develop' into feature/python
ygeunkim Sep 2, 2024
1247429
change requirements format and remove ci files
ygeunkim Sep 2, 2024
297f8f3
Merge branch 'develop' into feature/python
ygeunkim Sep 2, 2024
d23cbc1
use inheritance for ols
ygeunkim Sep 2, 2024
c877fa7
add more steps for eigen directory code
ygeunkim Sep 2, 2024
2e2ed7c
use different lag name in error
ygeunkim Sep 2, 2024
fb9cb0c
add minnesota prior
ygeunkim Sep 2, 2024
b556938
add sv class in pybind
ygeunkim Sep 2, 2024
56e02f0
use pybind11extension instead of setuptools
ygeunkim Sep 3, 2024
816c060
add predict method for varbayes and vharbayes
ygeunkim Sep 3, 2024
68df07e
added the same vix dataset as in r package
ygeunkim Sep 3, 2024
822be86
Merge branch 'develop' into feature/python
ygeunkim Sep 4, 2024
c825656
change pkl to csv
ygeunkim Sep 4, 2024
20f6ad1
change sv python class name
ygeunkim Sep 4, 2024
864ac88
add some doc in functions
ygeunkim Sep 4, 2024
2af0591
add sv forecast and start to add rolling window
ygeunkim Sep 5, 2024
1f91d28
add pred roll argument in test
ygeunkim Sep 6, 2024
bf8054d
Merge branch 'develop' into feature/python
ygeunkim Sep 6, 2024
01c1520
fix pybind rolling window
ygeunkim Sep 7, 2024
d953d2e
move forecast classes to separate modules
ygeunkim Sep 7, 2024
553767a
add use rcpp in the same line
ygeunkim Sep 7, 2024
26b4cdc
Merge branch 'develop' into feature/python
ygeunkim Sep 8, 2024
b994033
add conda ci
ygeunkim Sep 8, 2024
2cf8020
fix env yaml file path in ci
ygeunkim Sep 8, 2024
c5e3fbe
simplify environment yaml
ygeunkim Sep 8, 2024
1fb2309
add conda init step in ci
ygeunkim Sep 8, 2024
00ab8ec
separate conda init does not work
ygeunkim Sep 8, 2024
f696098
should specify the env name
ygeunkim Sep 8, 2024
7ca5031
use sys prefix instead of conda prefix
ygeunkim Sep 8, 2024
34f698a
add openmp after check the flag
ygeunkim Sep 8, 2024
dada2dd
install llvm in macos check
ygeunkim Sep 8, 2024
5be39fe
fix macos cpplags in ci
ygeunkim Sep 9, 2024
01fac91
add more messages to check and fix env variables usage in macos ci
ygeunkim Sep 9, 2024
a111ec6
change tempfile option against permission issue in windows
ygeunkim Sep 9, 2024
2daaa4f
not use editable mode in ci
ygeunkim Sep 9, 2024
4e47b66
move tests folder
ygeunkim Sep 9, 2024
9b4a1a7
add more metadata
ygeunkim Sep 9, 2024
154e547
separate install and verify steps in ci
ygeunkim Sep 9, 2024
b8ae83f
use close() to tempfile in setup
ygeunkim Sep 9, 2024
f877a76
add m_pi macro for windows
ygeunkim Sep 9, 2024
62fa0d1
use importlib.resources.path in python 3.9 and remove pybind11/numpy.h
ygeunkim Sep 9, 2024
ab543d0
change dataset method
ygeunkim Sep 10, 2024
157aa24
set python 3.10 as minimum
ygeunkim Sep 10, 2024
6d580fd
try pip check ci
ygeunkim Sep 10, 2024
38520dd
fix eigen_include_dir string in setup
ygeunkim Sep 10, 2024
73873c0
add some temporary message in pip ci
ygeunkim Sep 11, 2024
0b591e4
simplify the pattern to find boost in windows runner
ygeunkim Sep 11, 2024
9cd7fe0
try boost folder also in windows
ygeunkim Sep 11, 2024
b0bc727
use src layout instead of flat layout
ygeunkim Sep 11, 2024
3fbfd9d
gitignore for doc was in home ignore so move it
ygeunkim Sep 11, 2024
12cbbd1
add test coverage for python
ygeunkim Sep 11, 2024
15e98de
add codecov badge in python readme
ygeunkim Sep 11, 2024
fd306da
add some doc in model classes
ygeunkim Sep 11, 2024
1b348aa
add wheel check
ygeunkim Sep 11, 2024
fbc9a3c
separate install wheel step
ygeunkim Sep 11, 2024
d98738c
use different path for whl file
ygeunkim Sep 11, 2024
8eb00fd
fix windows whl finding and add sdist check
ygeunkim Sep 11, 2024
63b6291
add manifest.in
ygeunkim Sep 11, 2024
203437f
try to use setup.py solution instead of manifest for sdist
ygeunkim Sep 11, 2024
f807cc0
add pip git install ci
ygeunkim Sep 12, 2024
5b9c670
change include path line in setup.py
ygeunkim Sep 12, 2024
da125ef
remove sdistinclude and use manifest
ygeunkim Sep 12, 2024
d683fd7
use package-data for include
ygeunkim Sep 12, 2024
f2f796f
try to change package data path
ygeunkim Sep 12, 2024
06b33f0
do not use sdist
ygeunkim Sep 13, 2024
a609f7f
use temp directory in git install
ygeunkim Sep 13, 2024
b2cb0de
add vhar ldlt bayes rolling forecast
ygeunkim Sep 14, 2024
5df25bf
add expanding window in ldlt
ygeunkim Sep 14, 2024
c7905b3
add rolling and expanding windows for sv
ygeunkim Sep 14, 2024
2a8599d
add quartodoc ci
ygeunkim Sep 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make test code for internal cpp ols classes
ygeunkim committed Aug 29, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 6e804a6a7bf562ec04fcd2fe4100dbcf18652011
15 changes: 2 additions & 13 deletions python/bvhar/model/_ols.cpp
Original file line number Diff line number Diff line change
@@ -3,16 +3,6 @@

py::dict bvhar::MultiOls::returnOlsRes() {
this->fit();
// py::dict res;
// res["coefficients"] = this->coef;
// res["fitted.values"] = this->yhat;
// res["residuals"] = this->resid;
// res["covmat"] = this->cov;
// res["df"] = this->dim_design;
// res["m"] = this->dim;
// res["obs"] = this->num_design;
// res["y0"] = this->response;
// return res;
return py::dict(
py::arg("coefficients") = this->coef,
py::arg("fitted.values") = this->yhat,
@@ -27,7 +17,6 @@ py::dict bvhar::MultiOls::returnOlsRes() {

py::dict bvhar::OlsVar::returnOlsRes() {
py::dict ols_res = this->_ols->returnOlsRes();
// py::dict ols_res;
ols_res["p"] = this->lag;
ols_res["totobs"] = this->data.rows();
ols_res["process"] = "VAR";
@@ -71,14 +60,14 @@ PYBIND11_MODULE(_ols, m) {
py::class_<bvhar::OlsVar>(m, "OlsVar")
.def(
py::init<const Eigen::MatrixXd&, int, const bool, int>(),
py::arg("y"), py::arg("lag"), py::arg("include_mean"), py::arg("method")
py::arg("y"), py::arg("lag") = 1, py::arg("include_mean") = true, py::arg("method") = 1
)
.def("return_ols_res", &bvhar::OlsVar::returnOlsRes);

py::class_<bvhar::OlsVhar>(m, "OlsVhar")
.def(
py::init<const Eigen::MatrixXd&, int, int, const bool, int>(),
py::arg("y"), py::arg("week"), py::arg("month"), py::arg("include_mean"), py::arg("method")
py::arg("y"), py::arg("week") = 5, py::arg("month") = 22, py::arg("include_mean") = true, py::arg("method") = 1
)
.def("return_ols_res", &bvhar::OlsVhar::returnOlsRes);
}
39 changes: 39 additions & 0 deletions python/tests/test_ols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# import pytest
from bvhar.model import OlsVar, OlsVhar
import numpy as np

def test_var():
num_data = 30
dim_data = 3
var_lag = 2
data = np.random.randn(num_data, dim_data)
fit_var = OlsVar(data, var_lag, True, 1)
fit_var_llt = OlsVar(data, var_lag, True, 2)
fit_var_qr = OlsVar(data, var_lag, True, 3)
res = fit_var.return_ols_res()
res_llt = fit_var_llt.return_ols_res()
res_qr = fit_var_qr.return_ols_res()
res_keys = ['coefficients', 'fitted.values', 'residuals', 'covmat', 'df', 'm', 'obs', 'y0',
'p', 'totobs', 'process', 'type', 'design', 'y']
assert set(res_keys).issubset(set(res.keys()))
assert set(res_keys).issubset(set(res_llt.keys()))
assert set(res_keys).issubset(set(res_qr.keys()))


def test_vhar():
num_data = 30
dim_data = 3
week = 5
month = 22
data = np.random.randn(num_data, dim_data)
fit_vhar = OlsVhar(data, week, month, True, 1)
fit_vhar_llt = OlsVhar(data, week, month, True, 2)
fit_vhar_qr = OlsVhar(data, week, month, True, 3)
res = fit_vhar.return_ols_res()
res_llt = fit_vhar_llt.return_ols_res()
res_qr = fit_vhar_qr.return_ols_res()
res_keys = ['coefficients', 'fitted.values', 'residuals', 'covmat', 'df', 'm', 'obs', 'y0',
'p', 'week', 'month', 'totobs', 'process', 'type', 'HARtrans', 'design', 'y']
assert set(res_keys).issubset(set(res.keys()))
assert set(res_keys).issubset(set(res_llt.keys()))
assert set(res_keys).issubset(set(res_qr.keys()))