Skip to content

Commit

Permalink
API: compute grid points here, instead of calling `tulip.graphics.dom…
Browse files Browse the repository at this point in the history
…2vec`

Thus, make plotting independent of `tulip`.
  • Loading branch information
johnyf committed Jan 22, 2017
1 parent c313c64 commit 9d96bc0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions polytope/polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
#
# import matplotlib as mpl
# from matplotlib import pyplot as plt
# from tulip.graphics import dom2vec


class Polytope(object):
Expand Down Expand Up @@ -2116,12 +2115,6 @@ def grid_region(polyreg, res=None):
@param res: resolution of grid
"""
try:
from tulip.graphics import dom2vec
except:
logger.error('pyvectorized not found')
return

bbox = polyreg.bounding_box
bbox = np.hstack(bbox)
dom = bbox.flatten()
Expand All @@ -2132,7 +2125,14 @@ def grid_region(polyreg, res=None):
for i in xrange(0, dom.size, 2):
L = dom[i+1] - dom[i]
res += [density * L]
x = dom2vec(dom, res)
linspaces = list()
for i, n in enumerate(res):
a = dom[2 * i]
b = dom[2 * i + 1]
r = np.linspace(a, b, n)
linspaces.append(r)
points = np.meshgrid(*linspaces)
x = np.vstack(map(np.ravel, points))
x = x[:, polyreg.are_inside(x)]

return (x, res)
Expand Down

0 comments on commit 9d96bc0

Please sign in to comment.