diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..c66544b --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,27 @@ +name: test + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-w-conda-recipe: + runs-on: ubuntu-latest + steps: + - name: checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: setup conda + uses: conda-incubator/setup-miniconda@v2 + with: + auto-update-conda: true + auto-activate-base: true + activate-environment: "" + - name: linux conda build test + shell: bash -l {0} + run: | + conda install -n base -c conda-forge conda-build -y + conda build -c conda-forge conda-recipe diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 776aa35..0000000 --- a/.travis.yml +++ /dev/null @@ -1,18 +0,0 @@ -language: python -python: - - 3.7 - -before_install: - - wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh - - chmod +x miniconda.sh - - ./miniconda.sh -b - - export PATH=$HOME/miniconda3/bin:$PATH - - conda update --yes -q conda -c conda-forge - - conda config --set always_yes true - - conda config --set anaconda_upload no - -install: - - conda install -q conda-build - -script: - - conda build -c ilastik-forge -c conda-forge -c defaults conda-recipe diff --git a/README.md b/README.md index 0ec20ae..8f62842 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.org/ilastik/ilastikrag.svg?branch=master)](https://travis-ci.org/ilastik/ilastikrag) +[![test](https://github.com/ilastik/ilastikrag/actions/workflows/test.yaml/badge.svg)](https://github.com/ilastik/ilastikrag/actions/workflows/test.yaml) ilastikrag ========== @@ -11,7 +11,7 @@ Installation ------------ ```bash -conda install -c stuarteberg ilastikrag +conda install -c ilastik-forge ilastikrag ``` [Documentation]: http://stuarteberg.github.io/ilastikrag diff --git a/conda-recipe/conda_build_config.yaml b/conda-recipe/conda_build_config.yaml deleted file mode 100644 index 8b8415d..0000000 --- a/conda-recipe/conda_build_config.yaml +++ /dev/null @@ -1,10 +0,0 @@ -h5py: - - 2.9 -networkx: - - 1.11 -numpy: - - 1.12 -pandas: - - 0.24 -vigra: - - 1.11 diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml index 960f61c..9234560 100644 --- a/conda-recipe/meta.yaml +++ b/conda-recipe/meta.yaml @@ -13,21 +13,21 @@ source: build: noarch: python - number: 1001 - string: py_{{PKG_BUILDNUM}}_h{{PKG_HASH}}_g{{GIT_FULL_HASH[:7]}} + number: 0 + string: py_{{PKG_BUILDNUM}}_g{{GIT_FULL_HASH[:7]}} script: python -m pip install --no-deps --ignore-installed . requirements: build: - - python {{ python }} + - python >=3.7 - pip run: - - {{ pin_compatible('python') }} - - {{ pin_compatible('numpy') }} - - {{ pin_compatible('h5py') }} - - {{ pin_compatible('pandas', lower_bound='0.16', upper_bound='0.25') }} - - vigra >={{ vigra }} - - {{ pin_compatible('networkx') }} + - python >=3.7 + - numpy >=1.12,<1.19 + - h5py + - pandas >=0.25 + - vigra >=1.11 + - networkx >=1.11 test: requires: diff --git a/dev/environment-dev.yaml b/dev/environment-dev.yaml index 6b13169..bd1cc35 100644 --- a/dev/environment-dev.yaml +++ b/dev/environment-dev.yaml @@ -1,13 +1,11 @@ -name: ilastikrag-dev2 +name: ilastikrag-dev channels: - - defaults - conda-forge - - ilastik-forge dependencies: - - h5py=2.9* - - networkx=2.2* - - numpy=1.14* - - pandas=0.24* + - h5py + - networkx + - numpy>=1.12,<1.20 + - pandas - pytest - - python=3.7* - - vigra=1.11* + - python>=3.7 + - vigra diff --git a/ilastikrag/accumulators/edgeregion/edgeregion_edge_accumulator.py b/ilastikrag/accumulators/edgeregion/edgeregion_edge_accumulator.py index e723563..e116ce9 100644 --- a/ilastikrag/accumulators/edgeregion/edgeregion_edge_accumulator.py +++ b/ilastikrag/accumulators/edgeregion/edgeregion_edge_accumulator.py @@ -88,19 +88,12 @@ def ingest_edges(self, rag, edge_values): ndim = len(self._dense_axiskeys) covariance_matrices_array = np.zeros( (num_edges, ndim, ndim), dtype=np.float32 ) - group_index = [-1] + group_index = [0] def write_covariance_matrix(group_df): """ Computes the covariance matrix of the given group, and writes it into the pre-existing covariance_matrices_array. """ - # There's one 'gotcha' to watch out for here: - # GroupBy.apply() calls this function *twice* for the first group. - # http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.groupby.GroupBy.apply.html - if group_index[0] < 0: - group_index[0] += 1 - return None - # Compute covariance. # Apparently computing it manually is much faster than group_df.cov() group_vals = group_df.values.astype(np.float32, copy=False) diff --git a/ilastikrag/accumulators/similarity/similarity_flatedge_accumulator.py b/ilastikrag/accumulators/similarity/similarity_flatedge_accumulator.py index 86c98e7..3a9907d 100644 --- a/ilastikrag/accumulators/similarity/similarity_flatedge_accumulator.py +++ b/ilastikrag/accumulators/similarity/similarity_flatedge_accumulator.py @@ -47,24 +47,17 @@ def _compute_correlation_feature(self, rag, value_img): z_edge_ids.sort(1) values_df = pd.DataFrame(z_edge_ids, columns=['sp1', 'sp2']) - values_df['left_values'] = value_img[:-1].reshape(-1) - values_df['right_values'] = value_img[1:].reshape(-1) + values_df['left_values'] = np.array(value_img[:-1].reshape(-1)) + values_df['right_values'] = np.array(value_img[1:].reshape(-1)) correlations = np.zeros( len(self._final_df), dtype=np.float32 ) - group_index = [-1] + group_index = [0] def write_correlation(group_df): """ Computes the correlation between 'left_values' and 'right_values' of the given group, and writes it into the pre-existing correlations_array. """ - # There's one 'gotcha' to watch out for here: - # GroupBy.apply() calls this function *twice* for the first group. - # http://pandas.pydata.org/pandas-docs/stable/generated/pandas.core.groupby.GroupBy.apply.html - if group_index[0] < 0: - group_index[0] += 1 - return None - # Compute covariance = np.cov(group_df['left_values'].values, group_df['right_values'].values) denominator = np.sqrt(covariance[0,0]*covariance[1,1]) diff --git a/ilastikrag/tests/test_edgeregion_accumulator.py b/ilastikrag/tests/test_edgeregion_accumulator.py index b814f9b..6603298 100644 --- a/ilastikrag/tests/test_edgeregion_accumulator.py +++ b/ilastikrag/tests/test_edgeregion_accumulator.py @@ -48,14 +48,14 @@ def test1(self): debug_sp[superpixels == sp1] = 128 for sp2 in problem_df['sp2'].values: debug_sp[superpixels == sp2] = 255 - + vigra.impex.writeImage(debug_sp, '/tmp/debug_sp.png', dtype='NATIVE') - + # The first axes should all be close. # The second axes may differ somewhat in the case of purely linear edges, # so we allow a higher tolerance. - assert np.isclose(radii[:,0], transposed_radii[:,0]).all() - assert np.isclose(radii[:,1], transposed_radii[:,1], atol=0.001).all() + np.testing.assert_allclose(radii[:, 0], transposed_radii[:, 0], rtol=1e-4, atol=1e-2) + np.testing.assert_allclose(radii[:, 1], transposed_radii[:, 1], rtol=1e-4, atol=1e-2) def test2(self): superpixels = np.zeros((10, 10), dtype=np.uint32) diff --git a/ilastikrag/tests/test_standard_accumulators.py b/ilastikrag/tests/test_standard_accumulators.py index f5c5385..8bcad55 100644 --- a/ilastikrag/tests/test_standard_accumulators.py +++ b/ilastikrag/tests/test_standard_accumulators.py @@ -46,14 +46,14 @@ def test_sp_features_no_histogram(self): # sp sum features ought to be normalized, too... for _index, sp1, sp2, sp_sum_sum, sp_sum_difference in features_df.itertuples(): - np.testing.assert_almost_equal( + np.testing.assert_allclose( sp_sum_sum, np.power(sp1*sp_counts[sp1] + sp2*sp_counts[sp2], 1./superpixels.ndim).astype(np.float32), - decimal=6) - np.testing.assert_almost_equal( + rtol=10e-4) + np.testing.assert_allclose( sp_sum_difference, np.power(np.abs(sp1*sp_counts[sp1] - sp2*sp_counts[sp2]), 1./superpixels.ndim).astype(np.float32), - decimal=6) + rtol=10e-4) # MEAN features_df = rag.compute_features(values, ['standard_sp_mean'])