Giter Club home page Giter Club logo

Comments (4)

ulupo avatar ulupo commented on June 8, 2024

@MandMarc thanks for the input! This could be interesting, perhaps it is only a matter of adding appropriate bindings to the C++ code. Both @MonkeyBreaker and I are very busy these days so we ca''t give you a timeframe if we have to do it ourselves but of course we accept PRs and we could try to help you if you'd like to try to add this feature yourself.

from pyflagser.

MarcMachaczek avatar MarcMachaczek commented on June 8, 2024

Yes, I thought so too since the functionality technically already exists! Actually, I'm pretty interested in working on bindings etc. However, I have never done this before and don't have too much experience in C++ (a little tho), so this would require quite some time on my side which I won't have before christmas holidays unfortunately. Nonetheless, could you by any chance recommend some material/references regarding the whole Python C++ binding topic?

from pyflagser.

MonkeyBreaker avatar MonkeyBreaker commented on June 8, 2024

Hi @MandMarc,

Thank you for interest in this feature. I need to be honest, I did not touch the filtration generation at all, meaning I don't have much experience on this.

But, to explain how the filtration are generated for the moment is as follow:

  1. Go in flagser
  2. There you have a file algorithms.math that describes the filtration in a kind of pseudo-code.
  3. When you added you new filtration in this file, you can the run build_custom_algorithms.sh
  4. This script will run a Python parser to convert algorithms.math pseudo-code into flagser/include/algorithms.h c code.
  5. Then you can manually compile pyflagser from the root of the repository with python -m pip install -e ..
  6. From there your new filtration should be available in theory.

I never tried to create a new filtration, so I don't know much of the pseudo-code syntax. But the rest, I could help in debug if necessary.

As you can understand, the filtration are hard-coded into the code. And if you want to add a new filtration, you are required to compile again the package. What should be necessary, is to add the possibility from Python to pass a filtration function.
In order to achieve this, we should define a common interface for filtration that matches what flagser expects.

I think it is definitely doable, but as @ulupo said, currently we are really busy, I cannot give a specific time frame.

I can provide by end of the week, what I think the changes in the different parts of the code should be and if you are interested, you can start from there, otherwise, please let me some time to be able to implement this.

Best,
Julián

from pyflagser.

MonkeyBreaker avatar MonkeyBreaker commented on June 8, 2024

Hi again,

I give it a second though about the feature.

The filtration is a core part of the algorithm. This function is called extensively.
If we would want to provide a custom filtration, we would need to provide a callback function from Python to the C++ backend.
This is definitely doable for pybind11, but I am afraid about the performances implication. I opened a discussion in pybind11 about this, to see if I am right in thinking that performance will be highly impacted, or if I am wrong.

The reason I think this could have a big runtime impact is because, if I understood right the documentation, when you provide from Python a callback. Then in the C++ core, it will call the Python function and then the Python function will return the value to the C++ core. Hope I am clear in my explanation.

I will wait on their input to see if we should proceed by providing a callback from Python directly.

Otherwise, a different approach, would be to add to the bindings the possibility to add new filtrations. But even this will require to compile again the package.

I cannot see a good solution (good in term of performance and easy to use), but I will continue to think about this.

@MandMarc I will try to keep you updated and not delay to much this, but It could take time to have a smart solution. If on the meantime you can try the solution I posted before, I can provide you assistance.

from pyflagser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.