Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Why do polygons have dtype('O') rather than something numeric? #28

Closed
gdmcbain opened this issue Jun 8, 2017 · 1 comment
Closed

Why do polygons have dtype('O') rather than something numeric? #28

gdmcbain opened this issue Jun 8, 2017 · 1 comment

Comments

@gdmcbain
Copy link

gdmcbain commented Jun 8, 2017

When using gds_read, I found that the polygons are represented as numpy.ndarray of dtype('O'), i.e. object, not, say float or 'float64'.

For feeding the polygons to programs downstream, sometimes this matters, sometimes not. For example matplotlib and FreeCAD recognize the coordinates as numbers but PyGmsh doesn't.

To demonstrate, take any gds, say tutorial.gds from here, and

gds = GdsLibrary()
gds.read_gds(argv[1])

for layer, v in gds.top_level()[0].get_polygons(True).iteritems():
    print(layer, map(lambda p: (p.shape, p.dtype), v))

The workaround is trivial of course, just p.astype(float) (as in Polygon.fillet) or np.asarray(p, dtype=float) if a function is preferred to a method, but I was curious as to why the coordinates weren't numeric in the first place.

heitzmann added a commit that referenced this issue Jun 11, 2017
Numpy doesn't recognize builtins.int as int (affects pyton 2.*)
@heitzmann
Copy link
Owner

Thanks for the issue. This bug was introduced when the source was changed from python 2 to 3 and affected only python 2.*. Should be fixed now.

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

No branches or pull requests

2 participants