question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Removal of features without warning (Path.closed)

See original GitHub issue

Dear @regebro, I was very happy to find your library and I am using it in several projects: NNGT and DeNSE (as it was an optional dependency it does not appear in the manifest though, so GitHub does not know about it for its dependency graph).

This is just to let you know that, as a dependency published on PyPI, I would expect features such as the closed property of path to be deprecated before being removed, so as to not break code immediately for everyone who might be using the library.

Am I correct in thinking that this could have been kept using

    @property
    def closed(self):
        return isinstance(self, Close)

as an object property?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:25 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
tatarizecommented, Jan 2, 2020

Here’s some functions to make the code easier if you want:

from svg.path import Move, Close, Path

def get_subpaths(path):
    segments = None
    for p in path:
        if isinstance(p, Move):
            if segments is not None:
                raise RuntimeError("Only closed shapes accepted.")
            segments = []
        segments.append(p)
        if isinstance(p, Close):
            yield Path(*segments)
            segments = None


def get_points(path, interpolate_curve=50):
    points = []
    for item in path:
        if isinstance(item, (Arc, CubicBezier, QuadraticBezier)):
            istart = 1. / interpolate_curve
            for frac in np.linspace(istart, 1, interpolate_curve):
                points.append(
                    (item.point(frac).real, item.point(frac).imag))
        else:
            points.append((item.start.real, item.start.imag))
    return points

Which could use the start code block:

        path_data = parse_path(instructions["path"])
        subpaths = [subpath for subpath in get_subpaths(path_data)]
        shell = get_points(subpaths[0], interpolate_curve)  # the first path is the outer shell?
        holes = [get_points(subpath) for subpath in subpaths[1:]]
        shell = np.array(shell)
        container = Polygon(shell, holes=holes)
1reaction
tatarizecommented, Dec 30, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 6F - MUTCD 2009 Edition - FHWA
Sign or Plaque Sign Designation Section Conventional Road Freeway or Exp... Stop R1‑1 6F.06 30 x 30* — Stop (on Stop/Slow Paddle) R1‑1 6E.03 18...
Read more >
The art of removing features and products - Mixpanel
Even after features or products are deemed to have little to no value, teams keep them around for ages instead of responsibly removing...
Read more >
How to suppress Pandas Future warning ? - Stack Overflow
Found this on github... import warnings warnings.simplefilter(action='ignore', category=FutureWarning) import pandas.
Read more >
Suppress Warnings - MATLAB & Simulink - MathWorks
MATLAB displays no warning. Turn the warning on, and try to remove a nonexistent path: warning('on',id) rmpath('folderthatisnotonpath').
Read more >
The try-with-resources Statement - Exceptions
See Java Language Changes for a summary of updated language features in Java ... The try -with-resources statement ensures that each resource is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found