Code Monkey home page Code Monkey logo

Comments (5)

benmaier avatar benmaier commented on June 16, 2024

note: It happens very rarely and I'm currently trying to find out under which conditions

from samplableset.

gstonge avatar gstonge commented on June 16, 2024

This might be related to #15. What are the minimum and maximum weight you are using? It is possible that there are some round-off errors that accumulate in the tree structure. When possible, use the clear method if the set is empty. If the error still happens, we might need to implement some automated check-up on the tree structure to make sure that round-off errors do not cause these runtime errors.

from samplableset.

benmaier avatar benmaier commented on June 16, 2024

Yes, I think that's what's happening. I'm usually checking whether or not "total_weight" is zero and sample from the set if this is not the case. However, I'm inserting and deleting like crazy, so I think it happens that small errors accumulate and when the set is empty, the total weight is still 1e-11 or sth like that. In this case, I get the error above.

from samplableset.

gstonge avatar gstonge commented on June 16, 2024

In the latest version, there is an empty method that checks the number of elements instead, or size could be used also. These are not susceptible to rounding errors. When you find that the set is empty, use the clear after to remove all remaining rounding errors in the tree. That might help.

from samplableset.

benmaier avatar benmaier commented on June 16, 2024

awesome, thanks!

from samplableset.

Related Issues (12)

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.