Skip to content

Commit b3fb54b

Browse files
authored
Merge pull request #20 from SylvainCorlay/fix-build
Update xtensor and fix travisci build
2 parents 62e824a + 8947482 commit b3fb54b

4 files changed

Lines changed: 30 additions & 61 deletions

File tree

.travis.yml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,14 @@ matrix:
99
apt:
1010
sources:
1111
- ubuntu-toolchain-r-test
12-
packages:
13-
- g++-6
14-
env: COMPILER=gcc GCC=6
12+
- os: osx
13+
osx_image: xcode8
14+
compiler: clang
1515
env:
1616
global:
1717
- MINCONDA_VERSION="latest"
1818
- MINCONDA_LINUX="Linux-x86_64"
1919
- MINCONDA_OSX="MacOSX-x86_64"
20-
# before_install:
21-
2220
install:
2321
# Define the version of miniconda to download
2422
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
@@ -28,20 +26,24 @@ install:
2826
fi
2927
- wget "http://repo.continuum.io/miniconda/Miniconda3-$MINCONDA_VERSION-$MINCONDA_OS.sh" -O miniconda.sh;
3028
- bash miniconda.sh -b -p $HOME/miniconda
29+
- export CONDA_PREFIX=$HOME/miniconda
3130
- export PATH="$HOME/miniconda/bin:$PATH"
3231
- hash -r
3332
- conda config --set always_yes yes --set changeps1 no
3433
- conda update -q conda
3534
- conda info -a
36-
# Start test environement
37-
- conda env create -f ./test/test-environment.yml
38-
- source activate test-xtensorio
39-
- export CC=$CONDA_PREFIX/bin/gcc
40-
- export CXX=$CONDA_PREFIX/bin/g++
41-
# from conda toolchain package
35+
- |
36+
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
37+
export CC=$CONDA_PREFIX/bin/gcc
38+
export CXX=$CONDA_PREFIX/bin/g++
39+
conda install gcc-7 -c QuantStack -c conda-forge
40+
elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
41+
export CXX=clang++ CC=clang;
42+
conda install libcxx clangdev -c QuantStack -c conda-forge
43+
fi
44+
- conda install cmake openimageio libsndfile boost zlib xtensor=0.15.5 -c QuantStack -c conda-forge
4245
- export LDFLAGS="${LDFLAGS} -Wl,-rpath,$CONDA_PREFIX/lib"
4346
- export LINKFLAGS="${LDFLAGS}"
44-
# Testing
4547
- mkdir build
4648
- cd build
4749
- cmake -DBUILD_TESTS=ON -DDOWNLOAD_GTEST=ON -DCMAKE_PREFIX_PATH=$CONDA_PREFIX ..;

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Reading and writing image, sound and npz file formats to and from xtensor data s
2929
conda install xtensor-io -c QuantStack -c conda-forge
3030
```
3131

32-
- `xtensor-io` depends on `xtensor` `^0.13.2`.
32+
- `xtensor-io` depends on `xtensor` `^0.15.5`.
3333

3434
- `OpenImageIO`, `libsndfile` and `zlib` are optional dependencies to `xtensor-io`
3535

test/test-environment.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

test/test_xnpz.cpp

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -33,52 +33,31 @@ namespace xt
3333
EXPECT_TRUE(xt::all(xt::equal(arr_0, xarr_0)));
3434
}
3535

36-
bool compare_binary_files(std::string fn1, std::string fn2, std::size_t n_zipped_files)
37-
{
38-
std::ifstream stream1(fn1, std::ios::in | std::ios::binary);
39-
std::vector<uint8_t> fn1_contents((std::istreambuf_iterator<char>(stream1)),
40-
std::istreambuf_iterator<char>());
41-
42-
std::ifstream stream2(fn2, std::ios::in | std::ios::binary);
43-
std::vector<uint8_t> fn2_contents((std::istreambuf_iterator<char>(stream2)),
44-
std::istreambuf_iterator<char>());
45-
std::size_t unequal = 0;
46-
47-
if (fn1_contents.size() != fn2_contents.size())
48-
{
49-
return false;
50-
}
51-
52-
for (auto iter_fn1 = fn1_contents.begin(), iter_fn2 = fn2_contents.begin();
53-
iter_fn1 != fn1_contents.end();
54-
iter_fn1++, iter_fn2++)
55-
{
56-
if (*iter_fn1 != *iter_fn2)
57-
{
58-
unequal += 1;
59-
}
60-
}
61-
// this is date + time == 4 bytes per file + once in global header
62-
std::size_t unequal_allowed = (n_zipped_files + 2) * 3;
63-
if (unequal > unequal_allowed)
64-
{
65-
return false;
66-
}
67-
}
68-
6936
TEST(xnpz, save_uncompressed)
7037
{
7138
dump_npz("files/dump_uncompressed.npz", "arr_0", linspace<double>(0, 100), false, false);
7239
xt::xarray<int64_t> arr = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
7340
dump_npz("files/dump_uncompressed.npz", "arr_1", arr);
74-
EXPECT_TRUE(compare_binary_files("files/dump_uncompressed.npz", "files/uncompressed.npz", 2));
41+
// Re-read
42+
auto npz_map = xt::load_npz("files/dump_uncompressed.npz");
43+
auto arr_0 = npz_map["arr_0"].cast<double>();
44+
auto arr_1 = npz_map["arr_1"].cast<uint64_t>(false);
45+
xt::xarray<uint64_t> xarr_1 = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
46+
EXPECT_TRUE(xt::all(xt::isclose(arr_0, linspace<double>(0, 100))));
47+
EXPECT_TRUE(xt::all(xt::equal(arr_1, xarr_1)));
7548
}
7649

7750
TEST(xnpz, save_compressed)
7851
{
7952
xt::xarray<int64_t> arr = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
8053
dump_npz("files/dump_compressed.npz", "arr_1", linspace<double>(0, 100), true, false );
8154
dump_npz("files/dump_compressed.npz", "arr_0", arr, true);
82-
EXPECT_TRUE(compare_binary_files("files/dump_compressed.npz", "files/compressed.npz", 2));
55+
// Re-read
56+
auto npz_map = xt::load_npz("files/dump_compressed.npz");
57+
auto arr_0 = npz_map["arr_0"].cast<uint64_t>(false);
58+
auto arr_1 = npz_map["arr_1"].cast<double>();
59+
xt::xarray<uint64_t> xarr_0 = {{0, 1, 2}, {3, 4, 5}, {6, 7, 8}};
60+
EXPECT_TRUE(xt::all(xt::isclose(arr_1, linspace<double>(0, 100))));
61+
EXPECT_TRUE(xt::all(xt::equal(arr_0, xarr_0)));
8362
}
84-
}
63+
}

0 commit comments

Comments
 (0)