Skip to content

Commit

Permalink
Resolve Some final comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yashwants19 committed Jul 9, 2020
1 parent 0a9936f commit bdb6454
Show file tree
Hide file tree
Showing 23 changed files with 62 additions and 263 deletions.
28 changes: 0 additions & 28 deletions CMake/FindAutotools.cmake

This file was deleted.

3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
### mlpack ?.?.?
###### ????-??-??
* Rename InformationGain to HoeffdingInformationGain in
methods/hoeffding_trees/information_gain.hpp (#____).
methods/hoeffding_trees/information_gain.hpp (#____).

* Added N-step DQN to q_networks (#2461).

* Add Silhoutte Score metric and Pairwise Distances (#2406).
Expand Down
3 changes: 2 additions & 1 deletion src/mlpack/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ if (BUILD_R_BINDINGS)

foreach(r_src_file ${R_SRC_FILES})
if ("${r_src_file}" MATCHES "methods/" OR
"${r_src_file}" MATCHES "core/")
"${r_src_file}" MATCHES "core/" OR
"${r_src_file}" MATCHES "bindings/utils" )
execute_process(
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/${r_src_file}
Expand Down
70 changes: 20 additions & 50 deletions src/mlpack/bindings/R/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,30 @@ if (BUILD_R_BINDINGS)
## do. So it's probably a good idea to check.
if (FORCE_BUILD_R_BINDINGS)
find_package(R 3.2)
find_package(Autotools)
find_r_module(roxygen2)
find_r_module(Rcpp)
find_r_module(RcppArmadillo)
find_r_module(RcppEnsmallen)
find_r_module(BH)
if (NOT R_FOUND OR NOT AUTOTOOLS_FOUND OR NOT R_RCPP OR NOT R_RCPPARMADILLO OR NOT R_RCPPENSMALLEN OR NOT R_BH OR NOT R_ROXYGEN2)
if (NOT R_FOUND OR NOT R_RCPP OR NOT R_RCPPARMADILLO OR NOT R_RCPPENSMALLEN OR NOT R_BH OR NOT R_ROXYGEN2)
unset(BUILD_R_BINDINGS CACHE)
message(FATAL_ERROR "Could not Build R Bindings")
endif()
else ()
find_package(R 3.2)
find_package(Autotools)
find_r_module(roxygen2)
find_r_module(Rcpp)
find_r_module(RcppArmadillo)
find_r_module(RcppEnsmallen)
find_r_module(BH)
if (NOT R_FOUND OR NOT AUTOTOOLS_FOUND OR NOT R_RCPP OR NOT R_RCPPARMADILLO OR NOT R_RCPPENSMALLEN OR NOT R_BH OR NOT R_ROXYGEN2)
if (NOT R_FOUND OR NOT R_RCPP OR NOT R_RCPPARMADILLO OR NOT R_RCPPENSMALLEN OR NOT R_BH OR NOT R_ROXYGEN2)
unset(BUILD_R_BINDINGS CACHE)
endif()
endif ()

if (NOT R_FOUND)
not_found_return("R not found; not building R bindings.")
endif ()
if (NOT AUTOTOOLS_FOUND)
not_found_return("autotools not found; not building R bindings.")
endif()
if (NOT R_BH)
not_found_return("BH not found; not building R bindings.")
endif ()
Expand Down Expand Up @@ -123,7 +118,7 @@ if (BUILD_R_BINDINGS)
set(CPP_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/src/r_util.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/src/rcpp_mlpack.h"
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/src/Makevars.in"
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/src/Makevars"
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/src/Makevars.win"
)

Expand Down Expand Up @@ -154,10 +149,6 @@ if (BUILD_R_BINDINGS)
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/tests/testthat.R"
)

set(R_ARMA_CONFIG
"${CMAKE_CURRENT_SOURCE_DIR}/arma_config.hpp"
)

add_custom_target(r_copy ALL)

# First we have to create all the required directories for copy.
Expand Down Expand Up @@ -212,20 +203,7 @@ if (BUILD_R_BINDINGS)
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different
${R_TESTS_SOURCES}
${CMAKE_CURRENT_BINARY_DIR}/mlpack/tests)
add_custom_command(TARGET r_copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f "arma_config.hpp"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mlpack/src/mlpack/core/util"
)
add_custom_command(TARGET r_copy PRE_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different
${R_ARMA_CONFIG}
${CMAKE_CURRENT_BINARY_DIR}/mlpack/src/mlpack/core/util
)

file(COPY
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/configure.ac"
DESTINATION
"${CMAKE_CURRENT_BINARY_DIR}/mlpack/")
file(COPY
"${CMAKE_CURRENT_SOURCE_DIR}/mlpack/cleanup"
DESTINATION
Expand All @@ -235,46 +213,38 @@ if (BUILD_R_BINDINGS)
file(TOUCH
"${CMAKE_CURRENT_BINARY_DIR}/mlpack/model.txt")

# Generate configure file from configure.ac.
execute_process(COMMAND ${AUTOCONF_EXECUTABLE} -i
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mlpack/")

# Remove cache files generated by "autoreconf -i".
execute_process(COMMAND rm -r autom4te.cache
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mlpack/")
# Do the actual build.
add_custom_target(r_build ALL)

# Do the actual build.
add_custom_target(r_build ALL)

# "model.txt" is no longer useful, after generating src/.cpp files.
# Remove this file.
add_custom_command(TARGET r_build POST_BUILD
# "model.txt" is no longer useful, after generating src/.cpp files.
# Remove this file.
add_custom_command(TARGET r_build POST_BUILD
COMMAND ${CMAKE_COMMAND} ARGS -E remove -f "model.txt"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mlpack"
)
)

# Build RcppExports.cpp/.R, NAMESPACE and man/ files.
add_custom_command(TARGET r_build POST_BUILD
# Build RcppExports.cpp/.R, NAMESPACE and man/ files.
add_custom_command(TARGET r_build POST_BUILD
COMMAND Rscript ARGS "-e" "'Rcpp::compileAttributes()'"
COMMAND Rscript ARGS "-e" "'roxygen2::roxygenize(\".\")'"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mlpack"
)
)

# Build mlpack_${PACKAGE_VERSION}.tar.gz package.
add_custom_command(TARGET r_build POST_BUILD
# Build mlpack_${PACKAGE_VERSION}.tar.gz package.
add_custom_command(TARGET r_build POST_BUILD
COMMAND R CMD build mlpack
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
)

# Installation script for the packagae.
install(CODE
# Installation script for the packagae.
install(CODE
"execute_process(
COMMAND R CMD INSTALL mlpack_${PACKAGE_VERSION}.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}"
)
)

add_dependencies(r_build r_copy)
add_dependencies(R r_build)
add_dependencies(r_build r_copy)
add_dependencies(R r_build)
endif ()

# Define a global list of models, use for building serialization.R file.
Expand Down
30 changes: 0 additions & 30 deletions src/mlpack/bindings/R/arma_config.hpp

This file was deleted.

3 changes: 0 additions & 3 deletions src/mlpack/bindings/R/mlpack/cleanup
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
## compilation and editing objects
rm -f src/*.o src/*.so src/*.dylib src/*~ *~

## autoconf/configure leftovers
rm -rf autom4te.cache/ config.log config.status src/Makevars confdefs.h
134 changes: 0 additions & 134 deletions src/mlpack/bindings/R/mlpack/configure.ac

This file was deleted.

6 changes: 6 additions & 0 deletions src/mlpack/bindings/R/mlpack/inst/include/mlpack.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

#include <Rcpp.h>

// To suppress Found ‘__assert_fail’, possibly from ‘assert’ (C).
#define BOOST_DISABLE_ASSERTS

// Rcpp has its own stream object which cooperates more nicely with R's i/o
// And as of armadillo and mlpack, we can use this stream object as well.
#if !defined(ARMA_COUT_STREAM)
Expand All @@ -35,6 +38,9 @@
#define ARMA_RNG_ALT RcppArmadillo/Alt_R_RNG.h
#endif

// To suppress warnings related to core/util/arma_util.hpp.
#define MLPACK_CORE_UTIL_ARMA_CONFIG_HPP

@R_SRC@

#include <mlpack/core.hpp>
Expand Down
3 changes: 3 additions & 0 deletions src/mlpack/bindings/R/mlpack/src/Makevars
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PKG_CXXFLAGS = -I. $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
CXX_STD = CXX11
3 changes: 0 additions & 3 deletions src/mlpack/bindings/R/mlpack/src/Makevars.in

This file was deleted.

3 changes: 3 additions & 0 deletions src/mlpack/bindings/R/mlpack/src/rcpp_mlpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@
#define ARMA_RNG_ALT RcppArmadillo/Alt_R_RNG.h
#endif

// To suppress warnings related to core/util/arma_util.hpp.
#define MLPACK_CORE_UTIL_ARMA_CONFIG_HPP

#endif
Loading

0 comments on commit bdb6454

Please sign in to comment.