Commit 6143e107 authored by dboe's avatar dboe
Browse files

plot debugging

parent 14cf739e
......@@ -19,6 +19,7 @@ from six import string_types
from contextlib import contextmanager
from collections import Counter
from copy import deepcopy
import logging
# 3rd party
import numpy as np
......@@ -2016,10 +2017,7 @@ class TensorFields(Tensors):
if self.dim == field.dim:
field.transform(self.coord_sys)
else:
import logging
log = logging.getLogger()
log.debug(
logging.debug(
"Careful: Plotting tensors with field of"
"different dimension. No coord_sys check performed."
)
......
......@@ -98,7 +98,7 @@ def multi_sort(array, *others, **kwargs):
method = kwargs.pop('method', None)
cast_type = kwargs.pop('cast_type', list)
if not array:
if len(array) == 0:
return tuple(cast_type(x) for x in [array] + list(others))
if method is None:
......
......@@ -197,10 +197,10 @@ class Mesh3D(tfields.TensorMaps):
raise ValueError("Conflicting options maps and faces")
faces = kwargs.pop('faces', None)
maps = kwargs.pop('maps', None)
if faces is not None and not faces:
# faces = []
faces = np.empty((0, 3))
if faces is not None:
if len(faces) == 0:
# faces = []
faces = np.empty((0, 3))
maps = [faces]
if maps is not None:
kwargs['maps'] = maps
......@@ -476,7 +476,9 @@ class Mesh3D(tfields.TensorMaps):
if self.maps:
return self.maps[3]
else:
raise AttributeError("No faces found. Bug - please report")
logging.warning("No faces found. Mesh has {x} vertices."
.format(x=len(self)))
return tfields.Maps.to_map([], dim=3)
@faces.setter
def faces(self, faces):
......@@ -1154,9 +1156,11 @@ class Mesh3D(tfields.TensorMaps):
def plot(self, **kwargs): # pragma: no cover
"""
Forwarding to plotTools.plot_mesh
Forwarding to rna.plotting.plot_mesh
"""
scalars_demanded = any([v in kwargs for v in ['vmin', 'vmax', 'cmap']])
scalars_demanded = 'color' not in kwargs \
and 'facecolors' not in kwargs \
and any([v in kwargs for v in ['vmin', 'vmax', 'cmap']])
map_index = kwargs.pop('map_index',
None if not scalars_demanded else 0)
if map_index is not None:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment