Skip to content

Commit

Permalink
[skip-ci] add save and load model
Browse files Browse the repository at this point in the history
  • Loading branch information
fradav committed Apr 25, 2024
1 parent 3195b6e commit e38289e
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15...3.19)
cmake_minimum_required(VERSION 3.26)
cmake_policy(SET CMP0074 NEW)

set(CMAKE_CXX_STANDARD 17)
Expand Down Expand Up @@ -76,18 +76,19 @@ if(TEST)
endif()

if(PYABCRANGER)
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
set(PYBIND11PKG pybind11-nodep)
find_package(Python3 COMPONENTS Interpreter Development REQUIRED)
set(PYBIND11PKG pybind11)
endif()

pmm(
VCPKG
# https://github.com/microsoft/vcpkg/pull/19665
# REVISION a69b65229b3956b7f45abd81671b7330114bcaad
REVISION 6f7ffeb18f99796233b958aaaf14ec7bd4fb64b2
# REVISION 6f7ffeb18f99796233b958aaaf14ec7bd4fb64b2
REVISION 9d47b24eacbd1cd94f139457ef6cd35e5d92cc84
TRIPLET ${VCPKG_TARGET_TRIPLET}
REQUIRES range-v3 catch2 cxxopts fmt eigen3 ${PYBIND11PKG} ${TBBPKG} ${BOOSTREPKG} ${TESTDEPS}
PORTS "${PROJECT_SOURCE_DIR}/pybind11-nodep"
# PORTS "${PROJECT_SOURCE_DIR}/pybind11-nodep"
)

if(MAKE_STATIC_EXE)
Expand Down Expand Up @@ -126,6 +127,7 @@ add_definitions(-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
-D_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING
-D_SILENCE_CXX17_RESULT_OF_DEPRECATION_WARNING
-D_CRT_SECURE_NO_WARNINGS
-DTBB_ENABLE_IPO=OFF
-DNOMINMAX)
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")

Expand Down
3 changes: 1 addition & 2 deletions abcranger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "EstimParam.hpp"
#include "ModelChoice.hpp"

int main(int argc, char* argv[]) {
int main(const int argc, const char* argv[]) {
size_t nref, chosenscen;
std::string headerfile,reftablefile,statobsfile;

Expand Down Expand Up @@ -44,7 +44,6 @@ int main(int argc, char* argv[]) {
exit(0);
}


headerfile = opts["h"].as<std::string>();
reftablefile = opts["r"].as<std::string>();
statobsfile = opts["b"].as<std::string>();
Expand Down
10 changes: 10 additions & 0 deletions environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: abcranger
channels:
- conda-forge
- defaults
dependencies:
- python=3.11
- numpy
- pandas
- h5py
- tqdm
4 changes: 2 additions & 2 deletions pybind11-nodep/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pybind/pybind11
REF v2.9.2
SHA512 c6c18e5f59873adb3692640ade26472abd257607e7bb9fd48cfd1949878811e83d6ac6eb8c8dd926622d52ca4f13e5e6a58e0abaaaa1fa814ee831ea2b515272
REF v2.11.1
SHA512 ed1512ff0bca3bc0a45edc2eb8c77f8286ab9389f6ff1d5cb309be24bc608abbe0df6a7f5cb18c8f80a3bfa509058547c13551c3cd6a759af708fd0cdcdd9e95
HEAD_REF master
)

Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,9 @@ before-build = "rm -f {project}/build/CMakeCache.txt"

[tool.cibuildwheel.windows]
before-build = "pip install cmake & IF EXIST {project}\\build\\CMakeCache.txt DEL /F {project}\\build\\CMakeCache.txt"

[tool.poetry]
name = "pyabcranger"
version = "0.70"
description = "Python bindings for the ABC-Ranger library"
authors = ["François-David Collin <Francois-David.Collin@umontpellier.fr>"]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pytest]
testpaths = test
2 changes: 1 addition & 1 deletion src/EstimParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ EstimParamResults EstimParam_fun(Reftable<MatrixType> &myread,
size_t nref, ntree, nthreads, noisecols, seed, minnodesize, ntest;
std::string outfile, parameter_of_interest;
double chosenscen, plsmaxvar;
bool plsok, seeded, forest_save, weights_keep;
bool plsok, seeded, forest_save;

ntree = opts["t"].as<size_t>();
nthreads = opts["j"].as<size_t>();
Expand Down
4 changes: 3 additions & 1 deletion src/pyabcranger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ project(pyabcranger)
## Pybind11
find_package(pybind11 CONFIG REQUIRED)

pybind11_add_module(pyabcranger ${ABCRANGER_SOURCE_DIR}/ModelChoice.cpp ${ABCRANGER_SOURCE_DIR}/EstimParam.cpp pyabcranger.cpp ${PROJECT_abcranger_SRCS})

pybind11_add_module(pyabcranger ${ABCRANGER_SOURCE_DIR}/ModelChoice.cpp ${ABCRANGER_SOURCE_DIR}/EstimParam.cpp pyabcranger.cpp ${PROJECT_abcranger_SRCS})
remove_definitions(-DPy_DEBUG)
target_link_libraries(pyabcranger PRIVATE ${TBBLIB} fmt::fmt cxxopts::cxxopts)
set_property(TARGET pyabcranger PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_compile_definitions(pyabcranger PRIVATE PYTHON_OUTPUT=1)
target_compile_options(pyabcranger PRIVATE -UPy_DEBUG)
# if (USES_LIBCXX)
# target_link_options(pyabcranger PRIVATE -nodefaultlibs)
# target_link_libraries(pyabcranger PRIVATE libc++.a libc++abi.a libgcc_eh.a libgcc.a)
Expand Down

0 comments on commit e38289e

Please sign in to comment.