Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still a UnboundLocalError regarding local variable 'array_bk_sarcs' #3

Closed
mattijn opened this issue Mar 3, 2019 · 0 comments · Fixed by #6
Closed

Still a UnboundLocalError regarding local variable 'array_bk_sarcs' #3

mattijn opened this issue Mar 3, 2019 · 0 comments · Fixed by #6

Comments

@mattijn
Copy link
Owner

mattijn commented Mar 3, 2019

Consider the follow code:

import topojson
from shapely import geometry
from IPython.display import SVG, display
data = {
    "foo": {"type": "LineString", "coordinates": [[0, 0], [2, 2], [4, 0]]},
    "bar": {"type": "LineString", "coordinates": [[0, 2], [1, 1], [2, 2],[3,1],[4,2]]},
}
ex = topojson.extract(data)
lines = geometry.MultiLineString(ex['linestrings'])
svg_lines = lines._repr_svg_()
svg_lines = svg_lines.replace('stroke="#66cc99"', 'stroke="orange"', 1)
svg_lines = svg_lines.replace('stroke-width="0.0864"', 'stroke-width="0.25"', 1)
svg_lines = svg_lines.replace('opacity="0.8"', 'opacity="0.4"', 1)

display(SVG(svg_lines))

screenshot 2019-03-03 at 09 34 13

jo = topojson.join(ex)
geom = geometry.GeometryCollection([
    geometry.MultiLineString(jo['linestrings']),
    geometry.MultiPoint(jo['junctions'])
])
svg_geom = geom._repr_svg_()
svg_geom = svg_geom.replace('fill="#66cc99"', 'fill="orange"')
display(SVG(svg_geom))

screenshot 2019-03-03 at 09 34 32

cu = topojson.cut(jo)
for i in range(len(cu['linestrings'])):
    line = cu['linestrings'][i]
    svg = line._repr_svg_()
    display(SVG(svg))

screenshot 2019-03-03 at 09 34 49

de = topojson.dedup(cu)
    ---------------------------------------------------------------------------

    UnboundLocalError                         Traceback (most recent call last)

    <ipython-input-8-651cef27808e> in <module>()
    ----> 1 de = topojson.dedup(cu)
    

    ~/topojson/topojson/dedup.py in dedup(data)
        253     data = copy.deepcopy(data)
        254     deduper = Dedup()
    --> 255     return deduper.main(data)
    

    ~/topojson/topojson/dedup.py in main(self, data)
        217         # apply a shapely linemerge to merge all contiguous line-elements
        218         # first create a mask for shared arcs to select only non-duplicates
    --> 219         mask = np.isin(array_bk, array_bk_sarcs)
        220         array_bk_ndp = copy.deepcopy(array_bk.astype(float))
        221 


    UnboundLocalError: local variable 'array_bk_sarcs' referenced before assignment
cu['bookkeeping_duplicates']
    array([], dtype=float64)

It seems its related to #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant