Skip to content

Commit 6430ca0

Browse files
committed
API: Catch nan value Glyphs
Catch LinAlgError from numpy during the creation of a Glyph instead of allowing a error which stops the program. Instead an invisible ellipse is returned.
1 parent 38d3bb7 commit 6430ca0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

xdesign/plot.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,12 @@ def __init__(self, xy, tensor, color='coverage', trace_normal=1, **kwargs):
160160
trace_normal : float
161161
A scalar used to normalize the trace for coloring the glyph.
162162
"""
163-
values, orientation = np.linalg.eig(tensor)
163+
try:
164+
values, orientation = np.linalg.eig(tensor)
165+
except np.linalg.LinAlgError:
166+
logger.debug("GLYPH: nan tensor at {}".format(xy))
167+
super(Glyph, self).__init__(xy, 0, 0)
168+
return
164169
scale = np.sqrt(values.dot(values))
165170
if scale == 0:
166171
logger.info("GLYPH: zero tensor at {}".format(xy))
@@ -214,6 +219,7 @@ def plot_coverage_anisotropy(coverage_map, glyph_density=1.0, **kwargs):
214219
axis.add_artist(glyph)
215220

216221

222+
217223
def plot_phantom(phantom, axis=None, labels=None, c_props=[], c_map=None, i=-1,
218224
z=0.0, t=0.0001):
219225
"""Plot a :class:`.Phantom` to the given axis.

0 commit comments

Comments
 (0)