Giter Club home page Giter Club logo

Comments (7)

MonkeyBreaker avatar MonkeyBreaker commented on May 18, 2024

Good remark.

By default, numpy uses a 64-bit precision for float representation.
We need to currently cast input matrices to 32-bit, because the C++ core currently only supports 32-bit floating point representation.
For the output, If I am not mistaken, this line cast implicitly from 32-bit to 64-bit for float representation in the Python interface.
The cast from 32-bit to 64-bit should be safe in terms of precision.

I don't think it is a bad idea to return to users the default type for numpy.float from the Python interface. But, I do not have a strong reason to not return 32-bit as how it is currently returned from the C++ core.

from giotto-ph.

ulupo avatar ulupo commented on May 18, 2024

I don't think it is a bad idea to return to users the default type for numpy.float from the Python interface. But, I do not have a strong reason to not return 32-bit as how it is currently returned from the C++ core.

The reason I think it is not great to upcast downcasted floats is that users who pass distance matrices (as 64-bit arrays) might decide to "match" distance matrix values with the output bars. If 64-bit, they would be well-justified to expect that every birth and death corresponds exactly to an entry in the distance matrix. If 32-bit, they would at least have an indirect hint as to what might have happened.

Incidentally, this is related to another issue, namely that a possible enhancement would be to add a 64-bit implementation and allow users to pass a precision kwarg (default: single, but with the possibility of passing double).

from giotto-ph.

MonkeyBreaker avatar MonkeyBreaker commented on May 18, 2024

The reason I think it is not great to upcast downcasted floats is that users who pass distance matrices (as 64-bit arrays) might decide to "match" distance matrix values with the output bars. If 64-bit, they would be well-justified to expect that every birth and death corresponds exactly to an entry in the distance matrix. If 32-bit, they would at least have an indirect hint as to what might have happened.

Good argument about trying to match the output with the input ! Definitely, if they try to match and because we outputs 64-bit float, they would expect to find the exact same values they used as input. But, because of the downcast, this values are slightly different.

Incidentally, this is related to another issue, namely that a possible enhancement would be to add a 64-bit implementation and allow users to pass a precision kwarg (default: single, but with the possibility of passing double).

This shall not be in my opinion too much work, it is adding a template argument to the ripser function in the C++. Currently I am on a different project, but if this should be a must to have, then I can see to do it earlier.

from giotto-ph.

ulupo avatar ulupo commented on May 18, 2024

if this should be a must to have, then I can see to do it earlier.

I think there are other features that would be cooler to have first, but they are harder (cocycles, persistence pairs, isolate edge collapser). Maybe we should make a kanban for these? Anyway, if it is really that simple, why not add it I say.

from giotto-ph.

MonkeyBreaker avatar MonkeyBreaker commented on May 18, 2024

As always, it seems simple, maybe some issues will be encountered ...
But even if it seems easy, we should add corresponding test in order to ensure that what we add works when expected.
This alone takes some time.

Maybe we should make a kanban for these?

Definitely, but if possible, if we can centralize this in Github directly, it would be really cool !

from giotto-ph.

ulupo avatar ulupo commented on May 18, 2024

Definitely, but if possible, if we can centralize this in Github directly, it would be really cool !

Done :)

from giotto-ph.

MonkeyBreaker avatar MonkeyBreaker commented on May 18, 2024

Nice, thank you !

from giotto-ph.

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.