Skip to content

Commit

Permalink
Merge pull request #113 from NNPDF/tests
Browse files Browse the repository at this point in the history
Enable tests in build
  • Loading branch information
Zaharid committed Mar 23, 2018
2 parents 8f07cfd + ac6cb56 commit 14c63c7
Show file tree
Hide file tree
Showing 24 changed files with 1,364 additions and 1,332 deletions.
4 changes: 3 additions & 1 deletion .ciscripts/build-deploy-osx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
set -u
set -v

#Find conda
#Set up netrc file for uploading/downloading
echo "$NETRC_FILE" | base64 --decode > ~/.netrc

conda build -q conda-recipe
if [ $? != 0 ]; then
echo failed to build
Expand Down
4 changes: 4 additions & 0 deletions .ciscripts/build-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

#Find conda
source ~/.bashrc
#Set up netrc file for uploading/downloading
echo "$NETRC_FILE" | base64 --decode > ~/.netrc

#Build package
conda build -q conda-recipe
if [ $? != 0 ]; then
echo failed to build
Expand Down
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required (VERSION 3.0.2)

#This helps executables on Mac (where the linker didn't graduate from
#the kindergarden) to find the libraries
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)

# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
Expand Down
2 changes: 2 additions & 0 deletions conda-recipe/build.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
export LDFLAGS=$(echo $LDFLAGS | sed 's/-Wl,-dead_strip_dylibs//g')

mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DVP_DEV=OFF
Expand Down
15 changes: 15 additions & 0 deletions conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ requirements:
- requests
- prompt_toolkit

test:
requires:
- hypothesis
- pytest
- coverage
#Build dependencies for catch tests
- {{ compiler("cxx") }}
- {{ compiler("c") }}
- swig ==3.0.10
- cmake
- pkg-config

source_files:
- "*"

build:
number: 0
detect_binary_files_with_prefix: True
Expand Down
20 changes: 20 additions & 0 deletions conda-recipe/run_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -u
set -v
set -e

#Python tests for the installed validphys package
pytest --pyargs validphys


export LDFLAGS=$(echo $LDFLAGS | sed 's/-Wl,-dead_strip_dylibs//g')

mkdir bldtest
cd bldtest
cmake .. -DENABLE_TESTS=ON
make catch_test -j
./libnnpdf/tests/catch_test


#Print linkage data
conda inspect linkages -p $PREFIX $PKG_NAME
67 changes: 31 additions & 36 deletions libnnpdf/tests/experiment_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
using namespace NNPDF;
using namespace std;

TEST_CASE( "Experiment constructor", "[Experiment]" ) {
TEST_CASE("Experiment constructor", "[Experiment]") {

const auto cd = CommonData::ReadFile( get_data_path() + "commondata/DATA_NMC.dat",
get_data_path() + "commondata/systypes/SYSTYPE_NMC_DEFAULT.dat");
const auto cd = CommonData::ReadFile(
get_data_path() + "commondata/DATA_NMC.dat",
get_data_path() + "commondata/systypes/SYSTYPE_NMC_DEFAULT.dat");

const auto fk = FKSet(FKSet::parseOperator("NULL"),
{new FKTable{get_data_path() + "theory_53/fastkernel/FK_NMC.dat"}});
const auto fk = FKSet(
FKSet::parseOperator("NULL"),
{new FKTable{get_data_path() + "theory_162/fastkernel/FK_NMC.dat"}});

const auto pdf = LHAPDFSet("NNPDF31_nnlo_as_0118", PDFSet::erType::ER_MCT0);

Expand All @@ -22,51 +24,44 @@ TEST_CASE( "Experiment constructor", "[Experiment]" ) {
auto exp = Experiment{{dset}, "NMC"};
auto exp2 = Experiment{exp};

REQUIRE( exp.GetNData() == exp2.GetNData() );
for (int i = 0; i < exp.GetNData(); i++)
{
REQUIRE( exp.GetData()[i] == exp2.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++)
REQUIRE( exp.GetCovMat()(i,j) == exp2.GetCovMat()(i,j) );
}
REQUIRE(exp.GetNData() == exp2.GetNData());
for (int i = 0; i < exp.GetNData(); i++) {
REQUIRE(exp.GetData()[i] == exp2.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++)
REQUIRE(exp.GetCovMat()(i, j) == exp2.GetCovMat()(i, j));
}

// CHECKING T0
exp.SetT0(pdf);
exp2.SetT0(pdf);

for (int i = 0; i < exp.GetNData(); i++)
{
REQUIRE( exp.GetData()[i] == exp2.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++)
{
REQUIRE( exp.GetCovMat()(i,j) == exp2.GetCovMat()(i,j) );
REQUIRE( exp.GetSqrtCov()(i,j) == exp2.GetSqrtCov()(i,j) );
}
for (int i = 0; i < exp.GetNData(); i++) {
REQUIRE(exp.GetData()[i] == exp2.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++) {
REQUIRE(exp.GetCovMat()(i, j) == exp2.GetCovMat()(i, j));
REQUIRE(exp.GetSqrtCov()(i, j) == exp2.GetSqrtCov()(i, j));
}
}

// CHECKING COPY AFTER T0
auto exp3 = Experiment{exp};

for (int i = 0; i < exp.GetNData(); i++)
{
REQUIRE( exp.GetData()[i] == exp3.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++)
{
REQUIRE( exp.GetCovMat()(i,j) == exp3.GetCovMat()(i,j) );
REQUIRE( exp.GetSqrtCov()(i,j) == exp3.GetSqrtCov()(i,j) );
}
for (int i = 0; i < exp.GetNData(); i++) {
REQUIRE(exp.GetData()[i] == exp3.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++) {
REQUIRE(exp.GetCovMat()(i, j) == exp3.GetCovMat()(i, j));
REQUIRE(exp.GetSqrtCov()(i, j) == exp3.GetSqrtCov()(i, j));
}
}

// CHECKING FURTHER SET T0
exp3.SetT0(pdf);

for (int i = 0; i < exp.GetNData(); i++)
{
REQUIRE( exp.GetData()[i] == exp3.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++)
{
REQUIRE( exp.GetCovMat()(i,j) == exp3.GetCovMat()(i,j) );
REQUIRE( exp.GetSqrtCov()(i,j) == exp3.GetSqrtCov()(i,j) );
}
for (int i = 0; i < exp.GetNData(); i++) {
REQUIRE(exp.GetData()[i] == exp3.GetData()[i]);
for (int j = 0; j < exp.GetNData(); j++) {
REQUIRE(exp.GetCovMat()(i, j) == exp3.GetCovMat()(i, j));
REQUIRE(exp.GetSqrtCov()(i, j) == exp3.GetSqrtCov()(i, j));
}
}
}
293 changes: 0 additions & 293 deletions libnnpdf/tests/vp/regressions/test_dataset_t0_predictions.csv

This file was deleted.

Loading

0 comments on commit 14c63c7

Please sign in to comment.