From cd13e8121fbac28620e0bfe18553c8277ae70ce6 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 19 Jun 2021 15:06:58 -0600 Subject: [PATCH 1/3] fix report --- ansys/mapdl/reader/misc.py | 93 +++++++++++++++++++++++++------------- doc/source/api/index.rst | 1 + doc/source/api/misc.rst | 8 ++++ doc/source/index.rst | 1 - 4 files changed, 70 insertions(+), 33 deletions(-) create mode 100644 doc/source/api/misc.rst diff --git a/ansys/mapdl/reader/misc.py b/ansys/mapdl/reader/misc.py index 9cd3c8f4..b0fbd9a0 100644 --- a/ansys/mapdl/reader/misc.py +++ b/ansys/mapdl/reader/misc.py @@ -8,9 +8,7 @@ import scooby import pyvista import numpy as np -import vtk - -VTK9 = vtk.vtkVersion().GetVTKMajorVersion() >= 9 +from pyvista._vtk import VTK9 def vtk_cell_info(grid, force_int64=True, shift_offset=True): @@ -65,39 +63,71 @@ def vtk_cell_info(grid, force_int64=True, shift_offset=True): class Report(scooby.Report): - """A class for custom scooby.Report.""" - - def __init__(self, additional=None, ncol=3, text_width=80, sort=False, - gpu=True): - """Generate a :class:`scooby.Report` instance. - - Parameters - ---------- - additional : list(ModuleType), list(str) - List of packages or package names to add to output information. - - ncol : int, optional - Number of package-columns in html table; only has effect if - ``mode='HTML'`` or ``mode='html'``. Defaults to 3. + """Generate an enviornment and software report. - text_width : int, optional - The text width for non-HTML display modes - - sort : bool, optional - Alphabetically sort the packages + Parameters + ---------- + additional : list(ModuleType), list(str) + List of packages or package names to add to output information. + + ncol : int, optional + Number of package-columns in html table; only has effect if + ``mode='HTML'`` or ``mode='html'``. Defaults to 3. + + text_width : int, optional + The text width for non-HTML display modes. + + sort : bool, optional + Alphabetically sort the packages. + + gpu : bool, optional + Gather information about the GPU. Defaults to ``True`` but if + experiencing renderinng issues, pass ``False`` to safely generate + a report. + + Examples + -------- + >>> from ansys.mapdl import reader as pymapdl_reader + >>> print(pymapdl_reader.Report()) + ----------------------------------------------------------------- + PyMAPDL-Reader Software and Environment Report + ----------------------------------------------------------------- + Date: Sat Jun 19 14:52:00 2021 MDT + | + OS : Linux + CPU(s) : 16 + Machine : x86_64 + Architecture : 64bit + RAM : 62.8 GiB + Environment : Python + NVIDIA Corporation : GPU Vendor + NVIDIA Quadro P2000/PCIe/SSE2 : GPU Renderer + 4.5.0 NVIDIA 465.27 : GPU Version + | + Python 3.8.5 (default, May 27 2021, 13:30:53) [GCC 9.3.0] + | + pyvista : 0.31.1 + vtk : 9.0.1 + numpy : 1.20.3 + appdirs : 1.4.4 + ansys.mapdl.reader : 0.51.dev0 + tqdm : 4.61.1 + matplotlib : 3.4.2 + ansys.mapdl.core : 0.59.dev0 + scipy : 1.6.3 + ----------------------------------------------------------------- - gpu : bool - Gather information about the GPU. Defaults to ``True`` but if - experiencing renderinng issues, pass ``False`` to safely generate - a report. + """ - """ + def __init__(self, additional=None, ncol=3, text_width=80, sort=False, + gpu=True): + """Generate a :class:`scooby.Report` instance.""" # Mandatory packages. - core = ['pyansys', 'pyvista', 'vtk', 'numpy', 'scipy', - 'appdirs', 'ansys.mapdl.core'] + core = ['pyvista', 'vtk', 'numpy', 'appdirs', + 'ansys.mapdl.reader', 'tqdm', 'matplotlib'] # Optional packages. - optional = ['matplotlib', 'ansys.mapdl.corba'] + optional = ['matplotlib', 'ansys.mapdl.core', 'scipy'] # Information about the GPU - bare except in case there is a rendering # bug that the user is trying to report. @@ -115,7 +145,7 @@ def __init__(self, additional=None, ncol=3, text_width=80, sort=False, extra_meta=extra_meta) def __repr__(self): - add_text = '-'*79 + '\nPyMAPDL-Reader Software and Environment Report' + add_text = '-'*80 + '\nPyMAPDL-Reader Software and Environment Report' return add_text + super().__repr__() @@ -141,7 +171,6 @@ def _configure_pyvista(): pv.rcParams["cmap"] = "jet" pv.rcParams["font"]["family"] = "courier" pv.rcParams["title"] = "pyansys" - return def break_apart_surface(surf, force_linear=True): diff --git a/doc/source/api/index.rst b/doc/source/api/index.rst index 9dec8034..0bd819d8 100644 --- a/doc/source/api/index.rst +++ b/doc/source/api/index.rst @@ -15,3 +15,4 @@ PyMAPDL-Reader classes, functions, and attributes. full mesh_quality rst + misc diff --git a/doc/source/api/misc.rst b/doc/source/api/misc.rst new file mode 100644 index 00000000..567f9c57 --- /dev/null +++ b/doc/source/api/misc.rst @@ -0,0 +1,8 @@ +.. _ref_misc_api: + +********************* +Miscellaneous Classes +********************* +.. autoclass:: ansys.mapdl.reader.Report + :members: + :noindex: diff --git a/doc/source/index.rst b/doc/source/index.rst index 79fd14a5..a1dc6cf0 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -10,7 +10,6 @@ straightforward API coupled with C libraries based on header files provided by ANSYS. The ``ansys-mapdl-reader`` module supports the following formats: - - ``*.rst`` - Structural analysis result file - ``*.rth`` - Thermal analysis result file - ``*.emat`` - Element matrice data file From 58238b8fff672c062d9d5b1e68cc0d393f1537b4 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 19 Jun 2021 16:14:50 -0600 Subject: [PATCH 2/3] fix spelling --- ansys/mapdl/reader/misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansys/mapdl/reader/misc.py b/ansys/mapdl/reader/misc.py index b0fbd9a0..298696f4 100644 --- a/ansys/mapdl/reader/misc.py +++ b/ansys/mapdl/reader/misc.py @@ -63,7 +63,7 @@ def vtk_cell_info(grid, force_int64=True, shift_offset=True): class Report(scooby.Report): - """Generate an enviornment and software report. + """Generate an environment and software report. Parameters ---------- From 578c6b8b2235ad6c3e9f56f9683ddbbf3f2da240 Mon Sep 17 00:00:00 2001 From: Alex Kaszynski Date: Sat, 19 Jun 2021 16:16:08 -0600 Subject: [PATCH 3/3] fix docstring and __repr__ --- ansys/mapdl/reader/misc.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ansys/mapdl/reader/misc.py b/ansys/mapdl/reader/misc.py index 298696f4..1f56ef5e 100644 --- a/ansys/mapdl/reader/misc.py +++ b/ansys/mapdl/reader/misc.py @@ -82,8 +82,8 @@ class Report(scooby.Report): gpu : bool, optional Gather information about the GPU. Defaults to ``True`` but if - experiencing renderinng issues, pass ``False`` to safely generate - a report. + experiencing rendering issues, pass ``False`` to safely + generate a report. Examples -------- @@ -119,7 +119,7 @@ class Report(scooby.Report): """ - def __init__(self, additional=None, ncol=3, text_width=80, sort=False, + def __init__(self, additional=None, ncol=3, text_width=79, sort=False, gpu=True): """Generate a :class:`scooby.Report` instance.""" # Mandatory packages. @@ -143,9 +143,10 @@ def __init__(self, additional=None, ncol=3, text_width=80, sort=False, optional=optional, ncol=ncol, text_width=text_width, sort=sort, extra_meta=extra_meta) + self._text_width = text_width def __repr__(self): - add_text = '-'*80 + '\nPyMAPDL-Reader Software and Environment Report' + add_text = '-'*self.text_width + '\nPyMAPDL-Reader Software and Environment Report' return add_text + super().__repr__()