-
Notifications
You must be signed in to change notification settings - Fork 2
Separate Rcpp from main logic #57
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
base: master
Are you sure you want to change the base?
Conversation
843af94
to
c12531c
Compare
c12531c
to
3c26adf
Compare
- Removed `set_parameters` method from both RcppRPF and ClassificationRPF classes. - Updated `get_parameters` to return a structured RPFParams object instead of printing to stdout. - Removed obsolete test related to parameter setting from test suite.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
R CMD check
produces this note:
* checking compiled code ... NOTE
File ‘randomPlantedForest/libs/randomPlantedForest.so’:
Found ‘__ZNSt3__14coutE’, possibly from ‘std::cout’ (C++)
Objects: ‘lib/cpf.o’, ‘lib/rpf.o’
Found ‘_rand’, possibly from ‘rand’ (C)
Object: ‘lib/cpf.o’
Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor use Fortran I/O
nor system RNGs nor [v]sprintf.
See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual.
I'm not sure about the _rand
bit but for the stdout/stderr
bit I guess it doesn't like the use of std::cout
, which is why previously Rcout
was used.
I'm not sure how to handle that safely while being interface-agnostic, i.e. working for both R and Python interfaces, but I suspect this is going to require an abstraction similar to the RNG part, I guess? Something like a print
wrapper that either writes to Rcout
or std::cout
or something?
I think that std::cout is used in |
I'm doing parameter checks explicitly in the R package as well, long before the Rcpp interface sees any data, so as far as simple argument checks are concerned I assume that it might be simpler to do these checks in the high-level interface (R/Python) rather than on the C++ side (regardless of whether Rcpp is involved or not). If the C++ backend is not intended to be used as a standalone program (which is possible for Anyway, I think |
In ranger, we simply have a |
This pull request includes several changes to improve the codebase by refactoring and updating the data structures to not depend on Rcpp. The purpose of the refactoring is to serve as a base for future implementations in Python. The forest classes RandomPlantedForest and ClassificationRPF are now implemented exclusively using standard C++ types. A new interface file is added to connect Rcpp with the existing classes.
Additional changes
src/include/random_utils.hpp
: Added a new header file defining theRandomGenerator
class, which provides a unified interface for random number generation using either the C++ standard library or R's RNG.src/include/rpf.hpp
: Added a newRPFParams
struct and updated theRandomPlantedForest
class to use standard C++ containers. Furthermore,set_parameters
was removed as it did not seem to serve any meaningful use case.The method
set_data
does fit the model, this is a very huge side-effect. Instead fit is no called afterset_data