diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1705f123f..9c855da58 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -8,14 +8,13 @@ on: jobs: test: - name: ${{ matrix.os }} ${{ matrix.python-version }} + name: ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [macos-latest, windows-latest, ubuntu-latest] - python-version: [3.11] steps: - name: Checkout @@ -25,7 +24,6 @@ jobs: uses: mamba-org/setup-micromamba@v2 with: environment-file: .github/workflows/environment.yaml - python-version: ${{ matrix.python-version }} # this will set the system compiler; # I don't know how to set the conda compilers for windows diff --git a/.github/workflows/build_unix.sh b/.github/workflows/build_unix.sh index d7b006718..28a1d0ef5 100755 --- a/.github/workflows/build_unix.sh +++ b/.github/workflows/build_unix.sh @@ -1,7 +1,9 @@ #!/bin/bash -export PY_BIN="$CONDA_PREFIX/bin/python" -cmake . \ +mkdir -p bld +cd bld + +cmake .. \ -DWITHIN_TRAVIS=ON \ -DWITH_QPBO=OFF \ -DWITH_HDF5=ON \ @@ -13,10 +15,8 @@ cmake . \ -DWITH_GUROBI=OFF \ -DBUILD_CPP_TEST=OFF \ -DCMAKE_PREFIX_PATH="$CONDA_PREFIX" \ - -DPython_NumPy_INCLUDE_DIRS=$(python -c "import numpy; print(numpy.get_include())") \ - -DPYTHON_EXECUTABLE="$PY_BIN" \ - -DCMAKE_CXX_FLAGS="-std=c++17" \ - -DCMAKE_INSTALL_PREFIX="$CONDA_PREFIX" \ + -DPython_EXECUTABLE="${CONDA_PREFIX}/bin/python" \ + -DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \ -DBUILD_NIFTY_PYTHON=ON make -j 4 make install diff --git a/.github/workflows/build_win.bat b/.github/workflows/build_win.bat index 095776c4e..0b98a3612 100644 --- a/.github/workflows/build_win.bat +++ b/.github/workflows/build_win.bat @@ -1,15 +1,16 @@ REM https://stackoverflow.com/questions/6832666/lnk2019-when-including-asio-headers-solution-generated-with-cmake -cmake . -G "NMake Makefiles" ^ +mkdir bld +cd bld +cmake .. -G "NMake Makefiles" ^ -DWITH_QPBO=OFF ^ - -DWITH_HDF5=OFF ^ -DWITH_GLPK=OFF ^ -DWITH_CPLEX=OFF ^ -DWITH_GUROBI=OFF ^ -DBUILD_CPP_TEST=OFF ^ - -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%" ^ - -DCMAKE_INSTALL_PREFIX="%CONDA_PREFIX%" ^ - -DPython_NumPy_INCLUDE_DIRS=$(python -c "import numpy; print(numpy.get_include())") ^ - -DCMAKE_CXX_FLAGS="/std:c++17 /EHsc" ^ + -DCMAKE_PREFIX_PATH:PATH="%CONDA_PREFIX%" ^ + -DCMAKE_INSTALL_PREFIX:PATH="%CONDA_PREFIX%" ^ + -DPython_EXECUTABLE:PATH="%CONDA_PREFIX%\python.exe" ^ + -DCMAKE_CXX_FLAGS="/EHsc" ^ -DBUILD_NIFTY_PYTHON=ON ^ -DWITH_HDF5=OFF ^ -DWITH_Z5=ON ^ diff --git a/.github/workflows/environment.yaml b/.github/workflows/environment.yaml index dcbb2f4bb..6386d5c66 100644 --- a/.github/workflows/environment.yaml +++ b/.github/workflows/environment.yaml @@ -2,7 +2,7 @@ name: nifty-build-env channels: - conda-forge dependencies: - - boost-cpp>=1.63 + - libboost-devel - cmake - compilers - h5py @@ -12,4 +12,4 @@ dependencies: - xtensor - xtensor-python - vigra - - z5py + - z5py >=2.0.20 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..4e6a92c44 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1 @@ +repos: [] diff --git a/CMakeLists.txt b/CMakeLists.txt index c46ae71fe..433302be2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,9 @@ -cmake_minimum_required(VERSION 3.1) +cmake_minimum_required(VERSION 3.10) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) project(NIFTY) set(${PROJECT_NAME}_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) +cmake_policy(SET CMP0057 NEW) @@ -158,7 +159,7 @@ endif() #------------------------------------------------------------------------------------------------------------------- # find boost #------------------------------------------------------------------------------------------------------------------- -find_package(Boost 1.63.0 REQUIRED) +find_package(Boost 1.63.0 CONFIG REQUIRED) # see this issue for discussions about the filesystem lib in CMake # https://gitlab.kitware.com/cmake/cmake/issues/17834 diff --git a/cmake/modules/FindNUMPY.cmake b/cmake/modules/FindNUMPY.cmake deleted file mode 100644 index a719c7425..000000000 --- a/cmake/modules/FindNUMPY.cmake +++ /dev/null @@ -1,93 +0,0 @@ -# - Find the NumPy libraries -# This module finds if NumPy is installed, and sets the following variables -# indicating where it is. -# -# TODO: Update to provide the libraries and paths for linking npymath lib. -# -# NUMPY_FOUND - was NumPy found -# NUMPY_VERSION - the version of NumPy found as a string -# NUMPY_VERSION_MAJOR - the major version number of NumPy -# NUMPY_VERSION_MINOR - the minor version number of NumPy -# NUMPY_VERSION_PATCH - the patch version number of NumPy -# NUMPY_VERSION_DECIMAL - e.g. version 1.6.1 is 10601 -# NUMPY_INCLUDE_DIRS - path to the NumPy include files - -#============================================================================ -# Copyright 2012 Continuum Analytics, Inc. -# -# MIT License -# -# Permission is hereby granted, free of charge, to any person obtaining -# a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, including -# without limitation the rights to use, copy, modify, merge, publish, -# distribute, sublicense, and/or sell copies of the Software, and to permit -# persons to whom the Software is furnished to do so, subject to -# the following conditions: -# -# The above copyright notice and this permission notice shall be included -# in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. -# -#============================================================================ - -# Finding NumPy involves calling the Python interpreter, -# if we have PYTHON_EXECUTABLE found already, we don't need to -# check for it a second time, this might lead to version conflicts! -if(NOT DEFINED PYTHON_EXECUTABLE OR PYTHON_EXECUTABLE MATCHES "^$") - if(NumPy_FIND_REQUIRED) - find_package(PythonInterp REQUIRED) - else() - find_package(PythonInterp) - endif() - - if(NOT PYTHONINTERP_FOUND) - set(NUMPY_FOUND FALSE) - endif() -endif() - -execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" - "import numpy as n; print(n.__version__); print(n.get_include());" - RESULT_VARIABLE _NUMPY_SEARCH_SUCCESS - OUTPUT_VARIABLE _NUMPY_VALUES - ERROR_VARIABLE _NUMPY_ERROR_VALUE - OUTPUT_STRIP_TRAILING_WHITESPACE) - -if(NOT _NUMPY_SEARCH_SUCCESS MATCHES 0) - if(NumPy_FIND_REQUIRED) - message(FATAL_ERROR - "NumPy import failure:\n${_NUMPY_ERROR_VALUE}") - endif() - set(NUMPY_FOUND FALSE) -endif() - -# Convert the process output into a list -string(REGEX REPLACE ";" "\\\\;" _NUMPY_VALUES ${_NUMPY_VALUES}) -string(REGEX REPLACE "\n" ";" _NUMPY_VALUES ${_NUMPY_VALUES}) -list(GET _NUMPY_VALUES 0 NUMPY_VERSION) -list(GET _NUMPY_VALUES 1 NUMPY_INCLUDE_DIRS) - -# Make sure all directory separators are '/' -string(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIRS ${NUMPY_INCLUDE_DIRS}) - -# Get the major and minor version numbers -string(REGEX REPLACE "\\." ";" _NUMPY_VERSION_LIST ${NUMPY_VERSION}) -list(GET _NUMPY_VERSION_LIST 0 NUMPY_VERSION_MAJOR) -list(GET _NUMPY_VERSION_LIST 1 NUMPY_VERSION_MINOR) -list(GET _NUMPY_VERSION_LIST 2 NUMPY_VERSION_PATCH) -string(REGEX MATCH "[0-9]*" NUMPY_VERSION_PATCH ${NUMPY_VERSION_PATCH}) -math(EXPR NUMPY_VERSION_DECIMAL - "(${NUMPY_VERSION_MAJOR} * 10000) + (${NUMPY_VERSION_MINOR} * 100) + ${NUMPY_VERSION_PATCH}") - -find_package_message(NUMPY - "Found NumPy: version \"${NUMPY_VERSION}\" ${NUMPY_INCLUDE_DIRS}" - "${NUMPY_INCLUDE_DIRS}${NUMPY_VERSION}") - -set(NUMPY_FOUND TRUE) diff --git a/cmake/modules/PythonLibTest.cmake b/cmake/modules/PythonLibTest.cmake index 7eaa72e4e..42f503a04 100644 --- a/cmake/modules/PythonLibTest.cmake +++ b/cmake/modules/PythonLibTest.cmake @@ -1,19 +1,19 @@ -#message(PYTHON_VERSION_MAJOR ${PYTHON_VERSION_MAJOR}) -if(PYTHON_VERSION_MAJOR STREQUAL "2") +#message(Python_VERSION_MAJOR ${Python_VERSION_MAJOR}) +if(Python_VERSION_MAJOR STREQUAL "2") #message(STATUS "222222") find_program(NOSETESTS_PATH NAMES - #"nosetests${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests${PYTHON_VERSION_MAJOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}" + #"nosetests${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests-${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests${Python_VERSION_MAJOR}" + #"nosetests-${Python_VERSION_MAJOR}" "nosetests") else() find_program(NOSETESTS_PATH NAMES - #"nosetests${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests${PYTHON_VERSION_MAJOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}" + #"nosetests${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests-${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests${Python_VERSION_MAJOR}" + #"nosetests-${Python_VERSION_MAJOR}" "nosetests3") endif() @@ -101,4 +101,4 @@ function(add_python_test_target TARGET_NAME) add_dependencies(${TARGET_NAME} ${COPY_TARGET}) -endfunction() \ No newline at end of file +endfunction() diff --git a/environment.yaml b/environment.yaml index a60c9a6b6..d41f5bf12 100644 --- a/environment.yaml +++ b/environment.yaml @@ -1,13 +1,18 @@ -name: - nifty-dev +name: nifty-dev channels: - - conda-forge + - conda-forge dependencies: - - boost-cpp>=1.63 - - h5py - - nlohmann_json - - scikit-image - - xtensor>=0.21,<0.22 - - xtensor-python>=0.24,<0.25 + - python 3.12 + - numpy + - xtensor >=0.26,<0.27 + - xtensor-python >=0.28,<0.29 + - libboost-devel + - libvigra + # Vigra Numpy is used at link time too - vigra - - z5py + - z5py >=2.0.20 + # build dependencies needed for z5 + - nlohmann_json + - blosc + - bzip2 + - zlib diff --git a/include/nifty/array/arithmetic_array.hxx b/include/nifty/array/arithmetic_array.hxx index ba6cf0506..8617f622e 100644 --- a/include/nifty/array/arithmetic_array.hxx +++ b/include/nifty/array/arithmetic_array.hxx @@ -3,7 +3,7 @@ #include #include -#include "xtensor/xtensor.hpp" +#include "xtensor.hpp" #include "nifty/tools/runtime_check.hxx" namespace nifty{ diff --git a/include/nifty/distributed/graph_extraction.hxx b/include/nifty/distributed/graph_extraction.hxx index 8323db45e..6aba81bae 100644 --- a/include/nifty/distributed/graph_extraction.hxx +++ b/include/nifty/distributed/graph_extraction.hxx @@ -4,8 +4,8 @@ #include #include -#include "xtensor/xtensor.hpp" -#include "xtensor/xadapt.hpp" +#include "xtensor.hpp" +#include "xtensor/containers/xadapt.hpp" #include "z5/factory.hxx" #include "z5/attributes.hxx" diff --git a/include/nifty/graph/agglo/cluster_policies/gasp_cluster_policy.hxx b/include/nifty/graph/agglo/cluster_policies/gasp_cluster_policy.hxx index a047af47b..857fc58d5 100644 --- a/include/nifty/graph/agglo/cluster_policies/gasp_cluster_policy.hxx +++ b/include/nifty/graph/agglo/cluster_policies/gasp_cluster_policy.hxx @@ -12,7 +12,7 @@ #include "nifty/graph/agglo/cluster_policies/cluster_policies_common.hxx" #include #include // std::max -#include +#include using namespace xt::placeholders; @@ -633,4 +633,3 @@ namespace nifty{ } // namespace agglo } // namespace nifty::graph } // namespace nifty - diff --git a/include/nifty/graph/label_propagation.hxx b/include/nifty/graph/label_propagation.hxx index 8a4655a41..66e83d107 100644 --- a/include/nifty/graph/label_propagation.hxx +++ b/include/nifty/graph/label_propagation.hxx @@ -16,11 +16,11 @@ // #include "nifty/graph/edge_contraction_graph.hxx" // #include "nifty/graph/agglo/cluster_policies/cluster_policies_common.hxx" #include -#include "xtensor/xarray.hpp" +#include "xtensor/containers/xarray.hpp" #include "nifty/parallel/threadpool.hxx" #include // Random seed for shuffle -#include +#include namespace nifty{ diff --git a/include/nifty/graph/opt/lifted_multicut/pixel_wise.hxx b/include/nifty/graph/opt/lifted_multicut/pixel_wise.hxx index 9316845b8..c1e1cce43 100644 --- a/include/nifty/graph/opt/lifted_multicut/pixel_wise.hxx +++ b/include/nifty/graph/opt/lifted_multicut/pixel_wise.hxx @@ -5,11 +5,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "nifty/ufd/ufd.hxx" #include "nifty/graph/undirected_list_graph.hxx" @@ -82,12 +82,12 @@ namespace lifted_multicut{ { const auto label_p = labels(p0, p1, p2); - for(int offset_index=0; offset_index= 0 && q0 < shape[0] && - q1 >= 0 && q1 < shape[1] && + if(q0 >= 0 && q0 < shape[0] && + q1 >= 0 && q1 < shape[1] && q2 >= 0 && q2 < shape[2] ){ const auto label_q = labels(q0, q1, q2); @@ -121,15 +121,15 @@ namespace lifted_multicut{ auto node_p = 0; for(int p0=0; p0= 0 && q0 < shape[0] && - q1 >= 0 && q1 < shape[1] + if(q0 >= 0 && q0 < shape[0] && + q1 >= 0 && q1 < shape[1] ){ const auto node_q = q0*shape[1] + q1; const auto e = weights(p0, p1, offset_index); - gridGraphObj.setCost(node_p, node_q, e); + gridGraphObj.setCost(node_p, node_q, e); } } ++node_p; @@ -155,17 +155,17 @@ namespace lifted_multicut{ for(int p0=0; p0= 0 && q0 < shape[0] && - q1 >= 0 && q1 < shape[1] && + if(q0 >= 0 && q0 < shape[0] && + q1 >= 0 && q1 < shape[1] && q2 >= 0 && q2 < shape[2] ){ const auto node_q = q0*shape[1]*shape[2] + q1*shape[2] + q2; const auto e = weights(p0, p1, p2, offset_index); - gridGraphObj.setCost(node_p, node_q, e); + gridGraphObj.setCost(node_p, node_q, e); } } ++node_p; @@ -188,7 +188,7 @@ namespace lifted_multicut{ const xt::xexpression & e_offsets ){ typedef xt::xtensor ReturnType; - + const auto & gt = e_gt.derived_cast(); const auto & offsets = e_offsets.derived_cast(); @@ -231,7 +231,7 @@ namespace lifted_multicut{ PixelWiseLmcObjective( const xt::xexpression & e_weights, const xt::xexpression & e_offsets - ) + ) : weights_(e_weights), offsets_(e_offsets), shape_(), @@ -243,7 +243,7 @@ namespace lifted_multicut{ std::copy(wshape.begin(), wshape.end(), shape_.begin()); n_offsets_ = wshape[DIM]; - // n_var + // n_var n_variables_ = shape_[0]; for(auto d=1; d GraphType; + typedef nifty::graph::UndirectedGridGraph GraphType; typedef LiftedMulticutObjective ObjectiveType; typedef LiftedMulticutBase BaseType; typedef typename BaseType::VisitorBaseType VisitorBaseType; @@ -330,7 +330,7 @@ namespace lifted_multicut{ ++node; } return resultArray; - } + } @@ -387,11 +387,11 @@ namespace lifted_multicut{ struct Settings { - + }; - + template auto fuse( @@ -411,7 +411,7 @@ namespace lifted_multicut{ this->merge_ufd(e_labels_a, e_labels_b); - // + // auto e_a = objective_.evaluate(labels_a); auto e_b = objective_.evaluate(labels_b); this->_build_(res, [&]( @@ -426,7 +426,7 @@ namespace lifted_multicut{ *res_iter = cc_node_labels[dense_var]; //*res_iter = cc_node_labels[to_dense[ufd_.find(var)]]; ++res_iter; - } + } } else if(e_a < e_b){ @@ -464,8 +464,8 @@ namespace lifted_multicut{ this->merge_ufd2(e_labels); - // - + // + this->_build_(res, [&]( const auto & cc_node_labels, const auto & cc_energy @@ -484,17 +484,17 @@ namespace lifted_multicut{ best_i = i; } } - + if(cc_energy < best_e){//cc_energy < std::min(e_a, e_b)){ - + auto res_iter = res.begin(); for(auto var=0; var to_dense; ufd_.representativeLabeling(to_dense); @@ -623,12 +623,12 @@ namespace lifted_multicut{ for(auto var=0; var visitor; solver->optimize(cc_node_labels, nullptr); auto e_res = cc_obj.evalNodeLabels(cc_node_labels); - delete solver; + delete solver; f(cc_node_labels, e_res); } @@ -738,11 +738,11 @@ namespace lifted_multicut{ struct Settings { - + }; - + template auto fuse( @@ -757,7 +757,7 @@ namespace lifted_multicut{ const auto & labels_b = e_labels_b.derived_cast(); typename xt::xtensor::shape_type reshape{ - std::size_t(shape[0]), + std::size_t(shape[0]), std::size_t(shape[1]), std::size_t(shape[2]) }; @@ -766,7 +766,7 @@ namespace lifted_multicut{ this->merge_ufd(e_labels_a, e_labels_b); - // + // auto e_a = objective_.evaluate(labels_a); auto e_b = objective_.evaluate(labels_b); this->_build_(res, [&]( @@ -781,7 +781,7 @@ namespace lifted_multicut{ *res_iter = cc_node_labels[dense_var]; //*res_iter = cc_node_labels[to_dense[ufd_.find(var)]]; ++res_iter; - } + } } else if(e_a < e_b){ @@ -816,8 +816,8 @@ namespace lifted_multicut{ this->merge_ufd2(e_labels); - // - + // + this->_build_(res, [&]( const auto & cc_node_labels, const auto & cc_energy @@ -836,17 +836,17 @@ namespace lifted_multicut{ best_i = i; } } - + if(cc_energy < best_e){//cc_energy < std::min(e_a, e_b)){ - + auto res_iter = res.begin(); for(auto var=0; var to_dense; ufd_.representativeLabeling(to_dense); @@ -999,11 +999,11 @@ namespace lifted_multicut{ for(auto var=0; var= 0 && q0 < shape[0] && + if( q0 >= 0 && q0 < shape[0] && q1 >= 0 && q1 < shape[1] && q2 >= 0 && q2 < shape[2] ){ @@ -1064,7 +1064,7 @@ namespace lifted_multicut{ const auto q_label = ufd_.find(node_q); if(p_label != q_label){ - cc_obj.setCost(to_dense[p_label], to_dense[q_label], + cc_obj.setCost(to_dense[p_label], to_dense[q_label], weights(p0,p1,p2,offset_index)); } } @@ -1082,7 +1082,7 @@ namespace lifted_multicut{ solver->optimize(cc_node_labels, nullptr); auto e_res = cc_obj.evalNodeLabels(cc_node_labels); - delete solver; + delete solver; f(cc_node_labels, e_res); } @@ -1100,4 +1100,3 @@ namespace lifted_multicut{ } // namespace nifty::graph::opt } // namespace nifty::graph } // namespace nifty - diff --git a/include/nifty/graph/opt/lifted_multicut/pixel_wise_q.hxx b/include/nifty/graph/opt/lifted_multicut/pixel_wise_q.hxx index 6f9424ba7..855692413 100644 --- a/include/nifty/graph/opt/lifted_multicut/pixel_wise_q.hxx +++ b/include/nifty/graph/opt/lifted_multicut/pixel_wise_q.hxx @@ -5,11 +5,11 @@ #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include "nifty/ufd/ufd.hxx" #include "nifty/graph/undirected_list_graph.hxx" @@ -84,7 +84,7 @@ namespace lifted_multicut{ PixelWiseLmcObjective( const xt::xexpression & e_weights, const xt::xexpression & e_offsets - ) + ) : weights_(e_weights), offsets_(e_offsets), shape_(), @@ -96,7 +96,7 @@ namespace lifted_multicut{ std::copy(wshape.begin(), wshape.end(), shape_.begin()); n_offsets_ = wshape[DIM]; - // n_var + // n_var n_variables_ = shape_[0]; for(auto d=1; d auto fuse( @@ -204,7 +204,7 @@ namespace lifted_multicut{ this->merge_ufd(e_labels_a, e_labels_b); - // + // auto e_a = objective_.evaluate(labels_a); auto e_b = objective_.evaluate(labels_b); this->do_it(res, [&]( @@ -219,7 +219,7 @@ namespace lifted_multicut{ *res_iter = cc_node_labels[dense_var]; //*res_iter = cc_node_labels[to_dense[ufd_.find(var)]]; ++res_iter; - } + } } else if(e_a < cc_energy){ @@ -257,21 +257,21 @@ namespace lifted_multicut{ this->merge_ufd2(e_labels); - // - + // + this->do_it(res, [&]( const auto & cc_node_labels, const auto & cc_energy ){ if(1){//cc_energy < std::min(e_a, e_b)){ - + auto res_iter = res.begin(); for(auto var=0; var to_dense; ufd_.representativeLabeling(to_dense); @@ -403,12 +403,12 @@ namespace lifted_multicut{ for(auto var=0; var visitor; solver->optimize(cc_node_labels, nullptr); auto e_res = cc_obj.evalNodeLabels(cc_node_labels); - delete solver; + delete solver; f(cc_node_labels, e_res); } @@ -487,4 +487,3 @@ namespace lifted_multicut{ } // namespace nifty::graph::opt } // namespace nifty::graph } // namespace nifty - diff --git a/include/nifty/graph/rag/feature_accumulation/grid_rag_accumulate_stacked.hxx b/include/nifty/graph/rag/feature_accumulation/grid_rag_accumulate_stacked.hxx index 1a66ec19c..a58548d06 100644 --- a/include/nifty/graph/rag/feature_accumulation/grid_rag_accumulate_stacked.hxx +++ b/include/nifty/graph/rag/feature_accumulation/grid_rag_accumulate_stacked.hxx @@ -3,8 +3,8 @@ #include #include -#include "xtensor/xtensor.hpp" -#include "xtensor/xeval.hpp" +#include "xtensor.hpp" +#include "xtensor/core/xeval.hpp" #include "nifty/tools/array_tools.hxx" @@ -102,9 +102,9 @@ namespace graph{ } - // FIXME FIXME FIXME + // FIXME FIXME FIXME // FIXME !!! we waste a lot for zDirection != 0, because we always load both slices, which is totally - // unncessary. Instead, we should have 2 seperate functons (z = 0 / z = 1,2) that get called with the proper + // unncessary. Instead, we should have 2 seperate functons (z = 0 / z = 1,2) that get called with the proper // labels and data // // accumulate filter for the between slice edges diff --git a/include/nifty/graph/rag/get_lifted_edges_from_rag_and_offsets.hxx b/include/nifty/graph/rag/get_lifted_edges_from_rag_and_offsets.hxx index 31544ea02..98efdd218 100644 --- a/include/nifty/graph/rag/get_lifted_edges_from_rag_and_offsets.hxx +++ b/include/nifty/graph/rag/get_lifted_edges_from_rag_and_offsets.hxx @@ -2,10 +2,10 @@ #include #include -#include "xtensor/xexpression.hpp" +#include "xtensor/core/xexpression.hpp" -#include "xtensor/xview.hpp" -#include "xtensor/xmath.hpp" +#include "xtensor/views/xview.hpp" +#include "xtensor/core/xmath.hpp" #include "nifty/graph/undirected_list_graph.hxx" #include "nifty/array/arithmetic_array.hxx" @@ -63,4 +63,3 @@ namespace nifty{ } } - diff --git a/include/nifty/graph/rag/grid_rag.hxx b/include/nifty/graph/rag/grid_rag.hxx index b6a5beb57..cf093d9a9 100644 --- a/include/nifty/graph/rag/grid_rag.hxx +++ b/include/nifty/graph/rag/grid_rag.hxx @@ -18,7 +18,7 @@ #include "nifty/graph/rag/detail_rag/compute_grid_rag.hxx" -#include "xtensor/xtensor.hpp" +#include "xtensor.hpp" #include "nifty/xtensor/xtensor.hxx" #ifdef WITH_HDF5 diff --git a/include/nifty/graph/undirected_list_graph.hxx b/include/nifty/graph/undirected_list_graph.hxx index 653b6f8e8..a226f1ad1 100644 --- a/include/nifty/graph/undirected_list_graph.hxx +++ b/include/nifty/graph/undirected_list_graph.hxx @@ -6,7 +6,7 @@ #include #include -#include +#include #include "nifty/container/boost_flat_set.hxx" #include "nifty/container/flat_set.hxx" diff --git a/include/nifty/hdf5/hdf5_array.hxx b/include/nifty/hdf5/hdf5_array.hxx index b5575ff49..c36dd3b2e 100644 --- a/include/nifty/hdf5/hdf5_array.hxx +++ b/include/nifty/hdf5/hdf5_array.hxx @@ -4,7 +4,7 @@ #include #include -#include "xtensor/xarray.hpp" +#include "xtensor/containers/xarray.hpp" #include "nifty/hdf5/hdf5.hxx" #include "nifty/tools/block_access.hxx" diff --git a/include/nifty/python/graph/agglo/export_agglomerative_clustering.hxx b/include/nifty/python/graph/agglo/export_agglomerative_clustering.hxx index 762d8fe1e..0ba6ef480 100644 --- a/include/nifty/python/graph/agglo/export_agglomerative_clustering.hxx +++ b/include/nifty/python/graph/agglo/export_agglomerative_clustering.hxx @@ -7,8 +7,8 @@ #include "nifty/python/graph/undirected_list_graph.hxx" #include "nifty/graph/agglo/agglomerative_clustering.hxx" -#include -#include +#include +#include #include // Numpy bindings #include // Numpy bindings @@ -134,9 +134,9 @@ namespace agglo{ typedef DendrogramAgglomerativeClusteringVisitor DendrogramAgglomerativeClusteringVisitorType; // dendrogram visitor - { + { typedef DendrogramAgglomerativeClusteringVisitorType VisitorType; - const auto visitorClsName = std::string("DendrogramAgglomerativeClusteringVisitor") + const auto visitorClsName = std::string("DendrogramAgglomerativeClusteringVisitor") + clusterPolicyClsName; auto visitorCls = py::class_(aggloModule, visitorClsName.c_str()); @@ -298,11 +298,10 @@ namespace agglo{ }, py::return_value_policy::take_ownership, py::keep_alive<0,1>(), - py::arg("clusterPolicy") + py::arg("clusterPolicy") ); } } // end namespace agglo } // end namespace graph } // end namespace nifty - diff --git a/include/nifty/tools/block_access.hxx b/include/nifty/tools/block_access.hxx index a170cf445..2ab356fa5 100644 --- a/include/nifty/tools/block_access.hxx +++ b/include/nifty/tools/block_access.hxx @@ -1,6 +1,6 @@ #pragma once -#include "xtensor/xarray.hpp" +#include "xtensor/containers/xarray.hpp" #include "nifty/xtensor/xtensor.hxx" #include "nifty/array/arithmetic_array.hxx" diff --git a/include/nifty/tools/label_multiset.hxx b/include/nifty/tools/label_multiset.hxx index f7b8a95ba..4eaed009c 100644 --- a/include/nifty/tools/label_multiset.hxx +++ b/include/nifty/tools/label_multiset.hxx @@ -1,6 +1,6 @@ #include #include -#include "xtensor/xtensor.hpp" +#include "xtensor.hpp" #include "nifty/tools/blocking.hxx" namespace nifty { diff --git a/include/nifty/transformation/coordinate_transformation.hxx b/include/nifty/transformation/coordinate_transformation.hxx index 6c1543303..ede023f8b 100644 --- a/include/nifty/transformation/coordinate_transformation.hxx +++ b/include/nifty/transformation/coordinate_transformation.hxx @@ -1,5 +1,5 @@ #pragma once -#include +#include #include "nifty/tools/for_each_coordinate.hxx" #include "nifty/xtensor/xtensor.hxx" diff --git a/include/nifty/ufd/boost_ufd.hxx b/include/nifty/ufd/boost_ufd.hxx index d19131c4a..716ba0b32 100644 --- a/include/nifty/ufd/boost_ufd.hxx +++ b/include/nifty/ufd/boost_ufd.hxx @@ -1,7 +1,7 @@ #pragma once #include -#include +#include namespace nifty { diff --git a/include/nifty/xtensor/xtensor.hxx b/include/nifty/xtensor/xtensor.hxx index a18c5cfc3..c06821b6b 100644 --- a/include/nifty/xtensor/xtensor.hxx +++ b/include/nifty/xtensor/xtensor.hxx @@ -1,7 +1,7 @@ #pragma once -#include "xtensor/xarray.hpp" -#include "xtensor/xstrided_view.hpp" +#include "xtensor/containers/xarray.hpp" +#include "xtensor/views/xstrided_view.hpp" namespace nifty { diff --git a/src/python/CMakeLists.txt b/src/python/CMakeLists.txt index 47fbb453f..65bf53849 100644 --- a/src/python/CMakeLists.txt +++ b/src/python/CMakeLists.txt @@ -1,21 +1,21 @@ +find_package(Python REQUIRED COMPONENTS NumPy Interpreter Development) +include_directories(${Python_NumPy_INCLUDE_DIRS}) + find_package(xtensor-python REQUIRED) include_directories(${xtensor-python_INCLUDE_DIRS}) -find_package(pybind11 REQUIRED) +find_package(pybind11 CONFIG REQUIRED) include_directories(${pybind11_INCLUDE_DIRS}) -if(MSVC) - set(PYBIND11_CPP_STANDARD /std:c++17) -else() - set(PYBIND11_CPP_STANDARD -std=c++17) -endif() -message(STATUS "Using c++ 17 for pybind") - -find_package(Python REQUIRED COMPONENTS NumPy) -include_directories(${Python_NumPy_INCLUDE_DIRS}) - add_subdirectory(test) add_subdirectory(lib) -install(DIRECTORY ${CMAKE_BINARY_DIR}/python/nifty +# message(STATUS "Python_SITELIB ${Python_SITELIB}") +# Seems like with cmake 4 this is no longer so forgiving??? +# This line will convert backslashes to forward slash +# which are "safer" for cmake +file(TO_CMAKE_PATH "${Python_SITELIB}" Python_SITELIB) +# message(STATUS "Python_SITELIB ${Python_SITELIB}") + +install(DIRECTORY "${CMAKE_BINARY_DIR}/python/nifty" DESTINATION ${Python_SITELIB}) diff --git a/src/python/lib/CMakeLists.txt b/src/python/lib/CMakeLists.txt index 7b6b47fbb..edb659043 100644 --- a/src/python/lib/CMakeLists.txt +++ b/src/python/lib/CMakeLists.txt @@ -38,7 +38,7 @@ macro(addPythonModule) set(options "") set(oneValueArgs NESTED_NAME) - set(multiValueArgs SOURCES LIBRRARIES) + set(multiValueArgs SOURCES LIBRARIES) cmake_parse_arguments(ADD_PY_MOD "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) #message(STATUS "BRAAA" ${ADD_PY_MOD_NESTED_NAME}) @@ -60,17 +60,23 @@ macro(addPythonModule) #endif() set_target_properties(_${MODULE_NAME} PROPERTIES PREFIX "") - #message(STATUS ********Module: ${MODULE_NAME}) - #message(STATUS ********Libs: ${ADD_PY_MOD_LIBRRARIES}) + # message(STATUS ********Module: ${MODULE_NAME}) + # message(STATUS ********Libs: ${ADD_PY_MOD_LIBRARIES}) # NOTE it's not necessary to link against the python library here # and if we do, this causes seg-faults on mac, so don't do it! # link additional libraries target_link_libraries(_${MODULE_NAME} - PUBLIC - # ${PYTHON_LIBRARIES} - ${ADD_PY_MOD_LIBRRARIES} + PRIVATE + ${ADD_PY_MOD_LIBRARIES} ) + if(MSVC) + # Doing this linking for all platforms causes segfaults on mac + # and is not necessary on linux + # But it avoids linking to the debug libraries in windows.... + target_link_libraries(_${MODULE_NAME} PRIVATE ${Python_LIBRARIES}) + # target_link_libraries(_${MODULE_NAME} PRIVATE Boost::headers) + endif() # create module dir file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python/${ADD_PY_MOD_NESTED_NAME}) @@ -94,7 +100,7 @@ addPythonModule( nifty SOURCES nifty.cxx - LIBRRARIES + LIBRARIES ${NIFTY_LP_SOLVER_LIBS}) diff --git a/src/python/lib/carving/CMakeLists.txt b/src/python/lib/carving/CMakeLists.txt index b7308b649..37eb30bb6 100644 --- a/src/python/lib/carving/CMakeLists.txt +++ b/src/python/lib/carving/CMakeLists.txt @@ -3,6 +3,6 @@ addPythonModule( nifty/carving SOURCES carving.cxx - LIBRRARIES + LIBRARIES ${FILESYSTEM_LIBRARIES} ) diff --git a/src/python/lib/distributed/CMakeLists.txt b/src/python/lib/distributed/CMakeLists.txt index 0166e60a6..5840c8bb4 100644 --- a/src/python/lib/distributed/CMakeLists.txt +++ b/src/python/lib/distributed/CMakeLists.txt @@ -11,7 +11,7 @@ addPythonModule( lifted_utils.cxx morphology.cxx edge_morphology.cxx - LIBRRARIES + LIBRARIES # ${FASTFILTERS_LIBRARY} ${Z5_COMPRESSION_LIBRARIES} ${FILESYSTEM_LIBRARIES} diff --git a/src/python/lib/graph/CMakeLists.txt b/src/python/lib/graph/CMakeLists.txt index 47394cb4a..916a67c8d 100644 --- a/src/python/lib/graph/CMakeLists.txt +++ b/src/python/lib/graph/CMakeLists.txt @@ -12,7 +12,7 @@ addPythonModule( connected_components.cxx label_propagation.cxx accumulate_long_range_affinities.cxx - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ) diff --git a/src/python/lib/graph/long_range_adjacency/CMakeLists.txt b/src/python/lib/graph/long_range_adjacency/CMakeLists.txt index 8f5d2107a..474a0b4af 100644 --- a/src/python/lib/graph/long_range_adjacency/CMakeLists.txt +++ b/src/python/lib/graph/long_range_adjacency/CMakeLists.txt @@ -7,7 +7,7 @@ addPythonModule( adjacency.cxx long_range_adjacency.cxx long_range_features.cxx - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ${Boost_SYSTEM_LIBRARY} ) diff --git a/src/python/lib/graph/opt/CMakeLists.txt b/src/python/lib/graph/opt/CMakeLists.txt index cef928282..fb735b7db 100644 --- a/src/python/lib/graph/opt/CMakeLists.txt +++ b/src/python/lib/graph/opt/CMakeLists.txt @@ -14,7 +14,7 @@ addPythonModule( nifty/graph/opt SOURCES opt.cxx - #LIBRRARIES + #LIBRARIES # ${MOD_LIBS} ) diff --git a/src/python/lib/graph/opt/lifted_multicut/CMakeLists.txt b/src/python/lib/graph/opt/lifted_multicut/CMakeLists.txt index dd217d7fa..b9b95967a 100644 --- a/src/python/lib/graph/opt/lifted_multicut/CMakeLists.txt +++ b/src/python/lib/graph/opt/lifted_multicut/CMakeLists.txt @@ -27,7 +27,7 @@ addPythonModule( nifty/graph/opt/lifted_multicut SOURCES ${MOD_SOURCES} - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ) diff --git a/src/python/lib/graph/opt/lifted_multicut/pixel_wise_lifted_multicut.cxx b/src/python/lib/graph/opt/lifted_multicut/pixel_wise_lifted_multicut.cxx index eddd0860a..f174f1a4f 100644 --- a/src/python/lib/graph/opt/lifted_multicut/pixel_wise_lifted_multicut.cxx +++ b/src/python/lib/graph/opt/lifted_multicut/pixel_wise_lifted_multicut.cxx @@ -6,8 +6,8 @@ -#include -#include +#include +#include #include "xtensor-python/pyarray.hpp" // Numpy bindings #include "xtensor-python/pytensor.hpp" // Numpy bindings @@ -35,7 +35,7 @@ namespace lifted_multicut{ []( xt::pytensor weights, xt::pytensor offsets - ) { + ) { ObjType * a; { py::gil_scoped_release allowThreads; @@ -85,7 +85,7 @@ namespace lifted_multicut{ std::string fmClsName = std::string("PixelWiseLmcConnetedComponentsFusion") + std::to_string(DIM) + std::string("D"); - + typedef typename CCFusionType::CCLmcFactoryBase CCLmcFactoryBase; typedef std::shared_ptr CCLmcFactoryBaseSharedPtr; @@ -93,14 +93,14 @@ namespace lifted_multicut{ py::class_(liftedMulticutModule, fmClsName.c_str()) - + .def(py::init( []( const ObjType & objective, CCLmcFactoryBaseSharedPtr solver_factory - ) { + ) { CCFusionType * ret; { py::gil_scoped_release allowThreads; @@ -158,7 +158,7 @@ namespace lifted_multicut{ return nifty::graph::opt::lifted_multicut::pixel_wise_lmc_edge_gt_2d(gt, offsets); } ); - + } diff --git a/src/python/lib/graph/opt/mincut/CMakeLists.txt b/src/python/lib/graph/opt/mincut/CMakeLists.txt index 7b496b713..ae1b94d88 100644 --- a/src/python/lib/graph/opt/mincut/CMakeLists.txt +++ b/src/python/lib/graph/opt/mincut/CMakeLists.txt @@ -25,6 +25,6 @@ addPythonModule( nifty/graph/opt/mincut SOURCES ${MOD_SOURCES} - LIBRRARIES + LIBRARIES ${MOD_LIBS} ) \ No newline at end of file diff --git a/src/python/lib/graph/opt/minstcut/CMakeLists.txt b/src/python/lib/graph/opt/minstcut/CMakeLists.txt index 16a18e3cc..29f75f949 100644 --- a/src/python/lib/graph/opt/minstcut/CMakeLists.txt +++ b/src/python/lib/graph/opt/minstcut/CMakeLists.txt @@ -18,6 +18,6 @@ addPythonModule( nifty/graph/opt/minstcut SOURCES ${MOD_SOURCES} - LIBRRARIES + LIBRARIES ${MOD_LIBS} ) diff --git a/src/python/lib/graph/opt/multicut/CMakeLists.txt b/src/python/lib/graph/opt/multicut/CMakeLists.txt index 71dba6242..b3ab9504b 100644 --- a/src/python/lib/graph/opt/multicut/CMakeLists.txt +++ b/src/python/lib/graph/opt/multicut/CMakeLists.txt @@ -28,7 +28,7 @@ addPythonModule( nifty/graph/opt/multicut SOURCES ${MOD_SOURCES} - LIBRRARIES + LIBRARIES ${MOD_LIBS} ) diff --git a/src/python/lib/graph/rag/CMakeLists.txt b/src/python/lib/graph/rag/CMakeLists.txt index fc700c487..5ac3daf3f 100644 --- a/src/python/lib/graph/rag/CMakeLists.txt +++ b/src/python/lib/graph/rag/CMakeLists.txt @@ -15,7 +15,7 @@ addPythonModule( grid_rag_coordinates.cxx accumulate_affinities.cxx get_lifted_edges_from_rag_and_offsets.cxx - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ${FASTFILTERS_LIBRARY} ${Z5_COMPRESSION_LIBRARIES} diff --git a/src/python/lib/hdf5/CMakeLists.txt b/src/python/lib/hdf5/CMakeLists.txt index a9436ed72..1ee872697 100644 --- a/src/python/lib/hdf5/CMakeLists.txt +++ b/src/python/lib/hdf5/CMakeLists.txt @@ -12,6 +12,6 @@ addPythonModule( hdf5_array.cxx #hdf5_watershed.cxx hdf5_benchmark.cxx - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ) diff --git a/src/python/lib/skeletons/CMakeLists.txt b/src/python/lib/skeletons/CMakeLists.txt index 0f432813d..73d5a16f9 100644 --- a/src/python/lib/skeletons/CMakeLists.txt +++ b/src/python/lib/skeletons/CMakeLists.txt @@ -5,7 +5,7 @@ addPythonModule( SOURCES skeletons.cxx evaluation.cxx - LIBRRARIES + LIBRARIES ${Z5_COMPRESSION_LIBRARIES} ${FILESYSTEM_LIBRARIES} Threads::Threads diff --git a/src/python/lib/tools/CMakeLists.txt b/src/python/lib/tools/CMakeLists.txt index d259d476b..2b9dd81e8 100644 --- a/src/python/lib/tools/CMakeLists.txt +++ b/src/python/lib/tools/CMakeLists.txt @@ -15,7 +15,7 @@ addPythonModule( merge_helper.cxx label_multiset.cxx rle.cxx - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ${Z5_COMPRESSION_LIBRARIES} ${FILESYSTEM_LIBRARIES} diff --git a/src/python/lib/transformation/CMakeLists.txt b/src/python/lib/transformation/CMakeLists.txt index 34d284770..c60fd51d5 100644 --- a/src/python/lib/transformation/CMakeLists.txt +++ b/src/python/lib/transformation/CMakeLists.txt @@ -6,7 +6,7 @@ addPythonModule( transformation.cxx affine_transformation.cxx coordinate_transformation.cxx - LIBRRARIES + LIBRARIES ${HDF5_LIBRARIES} ${FASTFILTERS_LIBRARY} ${Z5_COMPRESSION_LIBRARIES} diff --git a/src/python/lib/z5/CMakeLists.txt b/src/python/lib/z5/CMakeLists.txt index 7af7d9b85..28628690b 100644 --- a/src/python/lib/z5/CMakeLists.txt +++ b/src/python/lib/z5/CMakeLists.txt @@ -5,7 +5,7 @@ addPythonModule( SOURCES z5.cxx dataset_wrapper.cxx - LIBRRARIES + LIBRARIES ${Z5_COMPRESSION_LIBRARIES} ${FILESYSTEM_LIBRARIES} Threads::Threads diff --git a/src/python/test/CMakeLists.txt b/src/python/test/CMakeLists.txt index b6e27aa36..dd6fae3a9 100644 --- a/src/python/test/CMakeLists.txt +++ b/src/python/test/CMakeLists.txt @@ -1,19 +1,19 @@ if(BUILD_PYTHON_TEST) - if(PYTHON_VERSION_MAJOR STREQUAL "2") + if(Python_VERSION_MAJOR STREQUAL "2") #message(STATUS "222222") find_program(NOSETESTS_PATH NAMES - #"nosetests${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests${PYTHON_VERSION_MAJOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}" + #"nosetests${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests-${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests${Python_VERSION_MAJOR}" + #"nosetests-${Python_VERSION_MAJOR}" "nosetests") else() find_program(NOSETESTS_PATH NAMES - #"nosetests${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" - #"nosetests${PYTHON_VERSION_MAJOR}" - #"nosetests-${PYTHON_VERSION_MAJOR}" + #"nosetests${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests-${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}" + #"nosetests${Python_VERSION_MAJOR}" + #"nosetests-${Python_VERSION_MAJOR}" "nosetests3") endif() @@ -56,4 +56,4 @@ endif() -endif() \ No newline at end of file +endif() diff --git a/src/test/test_graph/test_rag/simple_rag_test.cxx b/src/test/test_graph/test_rag/simple_rag_test.cxx index c01b571b7..7726e8ab2 100644 --- a/src/test/test_graph/test_rag/simple_rag_test.cxx +++ b/src/test/test_graph/test_rag/simple_rag_test.cxx @@ -1,7 +1,7 @@ #define BOOST_TEST_MODULE NiftyRagTest #include -#include "xtensor/xarray.hpp" +#include "xtensor/containers/xarray.hpp" #include #include