From 0135c74949bf0f03504a04da7bfa0404e65a5d02 Mon Sep 17 00:00:00 2001 From: dboe <dboe@ipp.mpg.de> Date: Wed, 30 Jun 2021 00:20:59 +0200 Subject: [PATCH] plotting tensor_maps --- setup.cfg | 2 +- tfields/core.py | 18 ++++++++++++++++++ tfields/mesh_3d.py | 16 ---------------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/setup.cfg b/setup.cfg index 4e2ff05..4d9a693 100644 --- a/setup.cfg +++ b/setup.cfg @@ -66,7 +66,7 @@ dev = %(docs)s %(test)s %(io)s - bumpversion # for incrementing the version + bumpversion==1.0.0 # for incrementing the version twine # for publishing sphinx # for documentation pre-commit # https://pre-commit.com/ for hook managment diff --git a/tfields/core.py b/tfields/core.py index cf8f85a..8c4ddc9 100644 --- a/tfields/core.py +++ b/tfields/core.py @@ -2830,6 +2830,24 @@ class TensorMaps(TensorFields): paths = sorted_paths return paths + def plot(self, **kwargs): # pragma: no cover + """ + Forwarding to rna.plotting.plot_mesh + """ + scalars_demanded = ( + "color" not in kwargs + and "facecolors" not in kwargs + and any([v in kwargs for v in ["vmin", "vmax", "cmap"]]) + ) + map_ = self.maps[kwargs.pop("map", 3)] + map_index = kwargs.pop("map_index", None if not scalars_demanded else 0) + if map_index is not None: + if not len(map_) == 0: + kwargs["color"] = map_.fields[map_index] + if map_.dim == 3: + return rna.plotting.plot_mesh(self, map_, **kwargs) + return rna.plotting.plot_tensor_map(self, map_, **kwargs) + if __name__ == "__main__": # pragma: no cover import doctest diff --git a/tfields/mesh_3d.py b/tfields/mesh_3d.py index 5965599..afcebff 100644 --- a/tfields/mesh_3d.py +++ b/tfields/mesh_3d.py @@ -9,7 +9,6 @@ Triangulated mesh class and methods import logging import os import numpy as np -import rna import tfields # obj imports @@ -1168,21 +1167,6 @@ class Mesh3D(tfields.TensorMaps): templates.append(template) return parts, templates - def plot(self, **kwargs): # pragma: no cover - """ - Forwarding to rna.plotting.plot_mesh - """ - 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: - if not len(self.maps[3]) == 0: - kwargs["color"] = self.maps[3].fields[map_index] - return rna.plotting.plot_mesh(self, self.faces, **kwargs) - if __name__ == "__main__": # pragma: no cover import doctest -- GitLab