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
Automatic python bindings #880
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… and an other load. If we're not using the command-line interface we don't need to load matrices.
Otherwise, matrices and models aren't automatically loaded.
This will allow different bindings access to the typename of the parameter itself.
This is a big set of changes. Highlights: * ParamData is far simpler. * CLI now holds a function pointer map for custom binding type functionality. * GetUnmappedParam is now GetPrintableParam. Still a few steps away from working compilation for all of the library.
In some cases there are regressions because hacks are no longer possible, like with k-means and mean_shift.
…y when it is created. This was a subtle and time-consuming issue to track down!
Ok, I think this is ready to merge; I've been sitting on it for quite a while but any outstanding issues have been fixed. I'll let this sit for another 3 days in case anyone has any comments. |
Sounds good, can't wait to work with the bindings. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've spent a long time working on this and there is still a lot to do before merge, but they should at least be in a usable state and can be played with now.
There are some major changes in this PR:
Instead of
mlpack::util::Option
being used withCLI::Add()
, nowOption
is a template typedef specified in<mlpack/core/mlpack_main.hpp>
and controlled by theMLPACK_BINDING_TYPE
macro.CLI
has been revamped (and should probably be renamed) and now does not actually do the parsing of the command line. It simply is a singleton that holds options and their current values, and it also handles the timers too.Each option that
CLI
holds has a type, but since we can't deduce the type from aboost::any
, now we use thisCLI::functionMap
structure along with the C++ typeid to call the appropriate functions for a given option. Before callingCLI::Add()
, an option is responsible for adding all of the function mappings that will be used by that program/binding type.src/mlpack/bindings/cli/
is a reimplementation of the command-line program, but with the refactoredCLI
code. Here,CLIOption
defines the functions that we need for command-line programs.src/mlpack/bindings/python/
contains automatically-generated Python bindings controlled by theadd_python_binding()
CMake macro.If you have cython installed, you can check this branch out and build it, and then you can actually use the python bindings:
There are still many things to do before merging this in though, although maybe some of them can be separated into separate tickets to be resolved after merge:
make install
.