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

Improve Windows compatibility. #82

Merged
merged 14 commits into from
Jul 16, 2019
35 changes: 17 additions & 18 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
build: false

environment:
environment:
matrix:
- PYTHON_VERSION: 3.5
MINICONDA: C:\Miniconda3

- PYTHON_VERSION: 3.5
MINICONDA: C:\Miniconda3-x64

- PYTHON_VERSION: 3.6
MINICONDA: C:\Miniconda3

- PYTHON_VERSION: 3.6
MINICONDA: C:\Miniconda3-x64

- PYTHON_VERSION: 3.7
MINICONDA: C:\Miniconda3

- PYTHON_VERSION: 3.7
MINICONDA: C:\Miniconda3-x64

init:
init:
- "ECHO %PYTHON_VERSION% %MINICONDA%"

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

test_script:
test_script:
- pytest .

after_test:
Expand Down
23 changes: 16 additions & 7 deletions ripser/ripser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ derivative works thereof, in binary and source code form.
#include <unordered_map>


/* Disable packing for Windows */
#if defined _WIN32
#define PACK
#else
#define PACK __attribute__((__packed__))
#endif



template <class Key, class T> class hash_map : public std::unordered_map<Key, T> {};
typedef float value_t;
typedef int64_t index_t;
Expand Down Expand Up @@ -98,7 +107,7 @@ std::vector<coefficient_t> multiplicative_inverse_vector(const coefficient_t m)
}

#ifdef USE_COEFFICIENTS
struct __attribute__((packed)) entry_t {
struct PACK entry_t {
index_t index : 8 * (sizeof(index_t) - sizeof(coefficient_t));
coefficient_t coefficient;
entry_t(index_t _index, coefficient_t _coefficient)
Expand Down Expand Up @@ -208,7 +217,7 @@ class sparse_distance_matrix {

//Initialize from thresholded dense distance matrix
template <typename DistanceMatrix>
sparse_distance_matrix(const DistanceMatrix& mat, value_t threshold) :
sparse_distance_matrix(const DistanceMatrix& mat, value_t threshold) :
neighbors(mat.size()), vertex_births(mat.size(), 0) {
for (size_t i = 0; i < size(); ++i) {
for (size_t j = 0; j < size(); ++j) {
Expand All @@ -219,7 +228,7 @@ class sparse_distance_matrix {
}
}
//Initialize from COO format
sparse_distance_matrix(int* I, int* J, float* V, int NEdges, int N, float threshold) :
sparse_distance_matrix(int* I, int* J, float* V, int NEdges, int N, float threshold) :
neighbors(N), vertex_births(N, 0) {
int i, j;
value_t val;
Expand Down Expand Up @@ -819,7 +828,7 @@ template <> class ripser<compressed_lower_distance_matrix>::simplex_coboundary_e

public:
simplex_coboundary_enumerator(const diameter_entry_t _simplex, index_t _dim,
const ripser& parent)
const ripser<compressed_lower_distance_matrix>& parent)
: idx_below(get_index(_simplex)), idx_above(0), v(parent.n - 1), k(_dim + 1),
vertices(_dim + 1), simplex(_simplex), modulus(parent.modulus), dist(parent.dist),
binomial_coeff(parent.binomial_coeff) {
Expand Down Expand Up @@ -849,7 +858,7 @@ template <> class ripser<compressed_lower_distance_matrix>::simplex_coboundary_e

template <> class ripser<sparse_distance_matrix>::simplex_coboundary_enumerator {
private:
const ripser& parent;
const ripser<sparse_distance_matrix>& parent;

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

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

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