Comments (6)
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.
from rdp.
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.
from rdp.
from rdp.
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)
- Makes no difference in reducing the number of points HOT 1
- simplify_coords function causes unexpected exit
- Wrong calculation of pldist HOT 3
- Link to blog post in docs gets redirected to blog front page HOT 2
- epsilon is int type HOT 1
- A c++ (speed up) version of Ramer-Douglas-Peucker with python binding of identical interface HOT 1
- Can you put a new release? HOT 1
- Recursion bug HOT 5
- unoptimized for loop HOT 5
- keeping track of the index element output from rdp HOT 3
- limiting number of points HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rdp.