From f7429b12541e7e4cffa4220a30412961de9a7d5c Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Wed, 11 Jan 2023 17:55:12 +1100 Subject: [PATCH 1/6] Move matplotlib to extras_require --- plot_requirements.txt | 1 + requirements.txt | 2 -- setup.py | 2 ++ 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 plot_requirements.txt diff --git a/plot_requirements.txt b/plot_requirements.txt new file mode 100644 index 00000000..a343acb5 --- /dev/null +++ b/plot_requirements.txt @@ -0,0 +1 @@ +matplotlib==3.5.3 diff --git a/requirements.txt b/requirements.txt index 47f9dc7e..1101330e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,2 @@ -matplotlib==3.5.3 numpy>=1.15 scipy>=1.1.0 - diff --git a/setup.py b/setup.py index 3487de20..3762b01e 100644 --- a/setup.py +++ b/setup.py @@ -23,6 +23,7 @@ def read_file(file): long_description = read_file("README.md") requirements = read_requirements("requirements.txt") +plot_requirements = read_requirements("plot_requirements.txt") __version__ = "0" exec(read_file("anastruct/_version.py")) # pylint: disable=exec-used @@ -51,5 +52,6 @@ def read_file(file): ], package_data={"anastruct.sectionbase": ["data/*.xml"]}, install_requires=requirements, + extras_require={"plotting": plot_requirements}, ext_modules=em, ) From aced2cb83e493a15729b1350fe76c1250cace50c Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Wed, 11 Jan 2023 18:21:28 +1100 Subject: [PATCH 2/6] Install plot requirements in testing --- .github/workflows/release.yaml | 1 + .github/workflows/test.yaml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c531fdd4..7037a10d 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -24,6 +24,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install -r plot_requirements.txt pip install -r test_requirements.txt - name: Run linting check with pylint run: | diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 227e1bd9..0fec4659 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -20,6 +20,7 @@ jobs: run: | python -m pip install --upgrade pip pip install -r requirements.txt + pip install -r plot_requirements.txt pip install -r test_requirements.txt - name: Run linting check with pylint run: | From 4af12f764025aa3050ecf42052f4973a03b2a050 Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Wed, 11 Jan 2023 18:22:04 +1100 Subject: [PATCH 3/6] Also stick testing as an extras_require --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 3762b01e..64da7cbd 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ def read_file(file): long_description = read_file("README.md") requirements = read_requirements("requirements.txt") plot_requirements = read_requirements("plot_requirements.txt") +test_requirements = read_requirements("test_requirements.txt") __version__ = "0" exec(read_file("anastruct/_version.py")) # pylint: disable=exec-used @@ -52,6 +53,6 @@ def read_file(file): ], package_data={"anastruct.sectionbase": ["data/*.xml"]}, install_requires=requirements, - extras_require={"plotting": plot_requirements}, + extras_require={"plot": plot_requirements, "test": test_requirements}, ext_modules=em, ) From 26c283ab3b70b369a48989600b900c2decdbc3a2 Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Wed, 11 Jan 2023 18:26:26 +1100 Subject: [PATCH 4/6] Handle case where matplotlib is not included in install --- anastruct/fem/plotter/__init__.py | 5 ++++- anastruct/fem/plotter/null.py | 10 ++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 anastruct/fem/plotter/null.py diff --git a/anastruct/fem/plotter/__init__.py b/anastruct/fem/plotter/__init__.py index d8220915..102e8fa1 100644 --- a/anastruct/fem/plotter/__init__.py +++ b/anastruct/fem/plotter/__init__.py @@ -1,2 +1,5 @@ -from .mpl import Plotter +try: + from .mpl import Plotter +except ImportError: + from .null import Plotter from .values import PlottingValues diff --git a/anastruct/fem/plotter/null.py b/anastruct/fem/plotter/null.py new file mode 100644 index 00000000..3ef58e1d --- /dev/null +++ b/anastruct/fem/plotter/null.py @@ -0,0 +1,10 @@ +from anastruct.fem.plotter.values import PlottingValues + + +class Plotter(PlottingValues): + def __init__(self, system, mesh): + super(Plotter, self).__init__(system, mesh) + self.system = system + self.one_fig = None + self.max_q = 0 + self.max_system_point_load = 0 From 0342d135178bff5b16c78be1c54932789cf5eadf Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Wed, 11 Jan 2023 18:30:02 +1100 Subject: [PATCH 5/6] Ignore type checking on null Plotter --- anastruct/fem/plotter/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/anastruct/fem/plotter/__init__.py b/anastruct/fem/plotter/__init__.py index 102e8fa1..9109a0eb 100644 --- a/anastruct/fem/plotter/__init__.py +++ b/anastruct/fem/plotter/__init__.py @@ -1,5 +1,5 @@ try: from .mpl import Plotter except ImportError: - from .null import Plotter + from .null import Plotter # type: ignore from .values import PlottingValues From 897e85149c5db32686dba042e8127082ad9d34ce Mon Sep 17 00:00:00 2001 From: Brooks Smith Date: Wed, 11 Jan 2023 18:46:28 +1100 Subject: [PATCH 6/6] Update documentation to include submodule installation instructions --- doc/source/installation.rst | 8 ++++++-- doc/source/plotting.rst | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/source/installation.rst b/doc/source/installation.rst index 0aa9a1f6..3b9350bf 100644 --- a/doc/source/installation.rst +++ b/doc/source/installation.rst @@ -5,10 +5,14 @@ You can install anaStruct with pip! :: + $ pip install anastruct[plot] + +Or if you would like a headless version of anaStruct (with no plotting abilities), you can do that too. + +:: $ pip install anastruct -It takes a while before new features are added in the official PyPI index. So if you want the latest features, -install from github. +Finally, while updates are made regularly on PyPI, if you'd like the bleeding edge newest features and fixes, or if you'd like to contribute to the development of anaStruct, then install from github. :: diff --git a/doc/source/plotting.rst b/doc/source/plotting.rst index a539e28d..833b86c1 100644 --- a/doc/source/plotting.rst +++ b/doc/source/plotting.rst @@ -4,8 +4,9 @@ Plotting The SystemElements object implements several plotting methods for retrieving standard plotting results. Every plotting method has got the same parameters. The plotter is based on a Matplotlib backend and it is possible to get the figure and do modifications of your own. The x and y coordinates of the model should all be positive value for the plotter -to work properly. +to work properly. +Note that plotting capabilities do require that anaStruct be installed with the "plot" sub-module (e.g. `pip install anastruct[plot]` ) Structure #########