Skip to content

Commit fbb5cdd

Browse files
author
Nathaniel Saul
authored
Merge pull request #82 from scikit-tda/fix/windows-packing
Improve Windows compatibility.
2 parents 5cdc1e1 + 997672c commit fbb5cdd

File tree

2 files changed

+33
-25
lines changed

2 files changed

+33
-25
lines changed

appveyor.yml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
11
build: false
22

3-
environment:
3+
environment:
44
matrix:
55
- PYTHON_VERSION: 3.5
66
MINICONDA: C:\Miniconda3
7-
7+
88
- PYTHON_VERSION: 3.5
99
MINICONDA: C:\Miniconda3-x64
10-
10+
1111
- PYTHON_VERSION: 3.6
1212
MINICONDA: C:\Miniconda3
13-
13+
1414
- PYTHON_VERSION: 3.6
1515
MINICONDA: C:\Miniconda3-x64
16-
16+
1717
- PYTHON_VERSION: 3.7
1818
MINICONDA: C:\Miniconda3
19-
19+
2020
- PYTHON_VERSION: 3.7
2121
MINICONDA: C:\Miniconda3-x64
2222

23-
init:
23+
init:
2424
- "ECHO %PYTHON_VERSION% %MINICONDA%"
2525

26-
install:
27-
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
26+
install:
27+
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
2828
- python --version
2929
- python -c "import sys,platform,struct;print(sys.platform, platform.machine(), struct.calcsize('P') * 8, )"
30-
- conda config --set always_yes yes --set changeps1 no
31-
- conda update -q conda
32-
- conda info -a
33-
- "conda create -q -n test-environment
34-
python=%PYTHON_VERSION% numpy pandas scipy matplotlib pytest"
35-
- activate test-environment
36-
- conda install libpython m2w64-toolchain cython
30+
- conda config --set always_yes yes --set changeps1 no
31+
- conda update -q conda
32+
- conda info -a
33+
- "conda create -q -n test-environment
34+
python=%PYTHON_VERSION% numpy pandas scipy matplotlib pytest"
35+
- activate test-environment
36+
- conda install libpython cython
3737
- echo [build] > %CONDA_PREFIX%\Lib\distutils\distutils.cfg
38-
- echo compiler = mingw32 >> %CONDA_PREFIX%\Lib\distutils\distutils.cfg
3938
- python setup.py install
4039

41-
test_script:
40+
test_script:
4241
- pytest .
4342

4443
after_test:

ripser/ripser.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,22 @@ derivative works thereof, in binary and source code form.
4343
#include <cmath>
4444
#include <cstring>
4545
#include <fstream>
46+
#include <iterator>
4647
#include <iostream>
4748
#include <numeric>
4849
#include <queue>
4950
#include <sstream>
5051
#include <unordered_map>
5152

5253

54+
/* Disable packing for Windows */
55+
#if defined _WIN32
56+
#define PACK
57+
#else
58+
#define PACK __attribute__((__packed__))
59+
#endif
60+
61+
5362
template <class Key, class T> class hash_map : public std::unordered_map<Key, T> {};
5463
typedef float value_t;
5564
typedef int64_t index_t;
@@ -98,7 +107,7 @@ std::vector<coefficient_t> multiplicative_inverse_vector(const coefficient_t m)
98107
}
99108

100109
#ifdef USE_COEFFICIENTS
101-
struct __attribute__((packed)) entry_t {
110+
struct PACK entry_t {
102111
index_t index : 8 * (sizeof(index_t) - sizeof(coefficient_t));
103112
coefficient_t coefficient;
104113
entry_t(index_t _index, coefficient_t _coefficient)
@@ -208,7 +217,7 @@ class sparse_distance_matrix {
208217

209218
//Initialize from thresholded dense distance matrix
210219
template <typename DistanceMatrix>
211-
sparse_distance_matrix(const DistanceMatrix& mat, value_t threshold) :
220+
sparse_distance_matrix(const DistanceMatrix& mat, value_t threshold) :
212221
neighbors(mat.size()), vertex_births(mat.size(), 0) {
213222
for (size_t i = 0; i < size(); ++i) {
214223
for (size_t j = 0; j < size(); ++j) {
@@ -219,7 +228,7 @@ class sparse_distance_matrix {
219228
}
220229
}
221230
//Initialize from COO format
222-
sparse_distance_matrix(int* I, int* J, float* V, int NEdges, int N, float threshold) :
231+
sparse_distance_matrix(int* I, int* J, float* V, int NEdges, int N, float threshold) :
223232
neighbors(N), vertex_births(N, 0) {
224233
int i, j;
225234
value_t val;
@@ -819,7 +828,7 @@ template <> class ripser<compressed_lower_distance_matrix>::simplex_coboundary_e
819828

820829
public:
821830
simplex_coboundary_enumerator(const diameter_entry_t _simplex, index_t _dim,
822-
const ripser& parent)
831+
const ripser<compressed_lower_distance_matrix>& parent)
823832
: idx_below(get_index(_simplex)), idx_above(0), v(parent.n - 1), k(_dim + 1),
824833
vertices(_dim + 1), simplex(_simplex), modulus(parent.modulus), dist(parent.dist),
825834
binomial_coeff(parent.binomial_coeff) {
@@ -849,7 +858,7 @@ template <> class ripser<compressed_lower_distance_matrix>::simplex_coboundary_e
849858

850859
template <> class ripser<sparse_distance_matrix>::simplex_coboundary_enumerator {
851860
private:
852-
const ripser& parent;
861+
const ripser<sparse_distance_matrix>& parent;
853862

854863
index_t idx_below, idx_above, v, k, max_vertex_below;
855864
const diameter_entry_t simplex;
@@ -864,7 +873,7 @@ template <> class ripser<sparse_distance_matrix>::simplex_coboundary_enumerator
864873

865874
public:
866875
simplex_coboundary_enumerator(const diameter_entry_t _simplex, index_t _dim,
867-
const ripser& _parent)
876+
const ripser<sparse_distance_matrix>& _parent)
868877
: parent(_parent), idx_below(get_index(_simplex)), idx_above(0), v(parent.n - 1),
869878
k(_dim + 1), max_vertex_below(parent.n - 1), simplex(_simplex), modulus(parent.modulus),
870879
dist(parent.dist), binomial_coeff(parent.binomial_coeff), vertices(parent.vertices),
@@ -944,7 +953,7 @@ template <> std::vector<diameter_index_t> ripser<sparse_distance_matrix>::get_ed
944953
template <> value_t ripser<compressed_lower_distance_matrix>::get_vertex_birth(index_t i) {
945954
//TODO: Dummy for now; nonzero vertex births are only done through
946955
//sparse matrices at the moment
947-
return 0.0;
956+
return 0.0;
948957
}
949958

950959
template <> value_t ripser<sparse_distance_matrix>::get_vertex_birth(index_t i) {

0 commit comments

Comments
 (0)