Git Product home page Git Product logo

Comments (6)

fhirschmann avatar fhirschmann commented on July 17, 2024

Hi hardmaru,

I have seen that error before, but I was unable to pinpoint the root cause. Do you know what the input data in that case looked like? Is it possible that it was an empty array?

You can also try if it works with an older version: https://pypi.python.org/packages/6c/4e/7ab95aad0a39c5d938014344cc321be6012b4156226d04ab3803b759a35c/rdp-0.6.tar.gz#md5=0e5de170f1322ef2d9e390a4502b5d0e

If that works it may be a regression bug.

I really like your work by the way! :)

from rdp.

hardmaru avatar hardmaru commented on July 17, 2024

from rdp.

hardmaru avatar hardmaru commented on July 17, 2024

Hi fhirschmann,

It seems that is the case. An example of a line where rdp was breaking is:

line = [[53, 90],[52, 89],[51, 89],[50, 89],[50, 90],[50, 91],[52, 91],[56, 91],[56, 90],[55, 90],[54, 90],[53, 90]]

If I use the pl_dist in the older version, and rename it pldist_old

def pldist_old(x0, x1, x2):
    """
    Calculates the distance from the point ``x0`` to the line given
    by the points ``x1`` and ``x2``.

    :param x0: a point
    :type x0: a 2x1 numpy array
    :param x1: a point of the line
    :type x1: 2x1 numpy array
    :param x2: another point of the line
    :type x2: 2x1 numpy array
    """
    if x1[0] == x2[0]:
        return np.abs(x0[0] - x1[0])

    return np.divide(np.linalg.norm(np.linalg.det([x2 - x1, x1 - x0])),
                     np.linalg.norm(x2 - x1))

After I call rdp(line, epsilon=0.99, dist=pldist_old), we can now get reduced line:

[[53, 90], [50, 89], [50, 91], [56, 91], [53, 90]]

But if we call rdp(line, epsilon=0.99, dist=pldist), the error pops up:

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I'm not sure the best way to get this back into your code, but it's very helpful to have resolved this!

Cheers.

from rdp.

fhirschmann avatar fhirschmann commented on July 17, 2024

from rdp.

hardmaru avatar hardmaru commented on July 17, 2024

from rdp.

robertrlindner avatar robertrlindner commented on July 17, 2024

Hi all,
I'm using rdp version (0.7) and experiencing the same error.
I believe it's coming from line 33:

return np.linalg.norm(point, start)

Based on what pldist is trying to compute, and the inputs for linalg.norm, I think this should simply be:

return np.linalg.norm(point - start).

Let me know what you think,
Thanks,
Bob

from rdp.

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.