From db82a0505a3eee6437ed123209bee078e7ef6715 Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 29 May 2020 15:47:43 -0700 Subject: [PATCH 01/38] refractor: remove redundancy in ci workflow --- .github/workflows/continuous-integration-workflow.yml | 11 ++++------- tox.ini | 9 ++++++++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 5b2b25b..eb7efb5 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -17,13 +17,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - - name: Install dependencies + - name: "Install dependencies" run: | python -m pip install --upgrade pip - pip install flake8 pytest - pip install -r requirements.txt - - name: Install Tox - run: pip install tox - - name: Run Tox + pip install tox tox-gh-actions + - name: "Run tox targets for ${{ matrix.python-version }}" # Run tox using the version of Python in `PATH` - run: tox -e py \ No newline at end of file + run: python -m tox \ No newline at end of file diff --git a/tox.ini b/tox.ini index 0b82edb..345cb29 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,12 @@ [tox] -envlist=py{35,36,37} +envlist=py{35,36,37,38} + +[gh-actions] +python = + 3.5: py35, + 3.6: py36, + 3.7: py37, + 3.8: py38, [testenv] deps = -rrequirements.txt From d13be0cf483d1360620a6aa5f53f2d79d8360283 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 30 May 2020 14:00:19 -0700 Subject: [PATCH 02/38] feat: dev and doc requirments --- requirements-dev.txt | 3 +++ setup.py | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 requirements-dev.txt diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..d2d078b --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,3 @@ +flake8 +sphinx +black \ No newline at end of file diff --git a/setup.py b/setup.py index 43ded13..779dcda 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,9 @@ "dill", "backports.functools_lru_cache; python_version<'3.3'", ], + extras_require={ + 'dev': ['tox','sphinx','black'], + 'docs': ['sphinx']}, include_package_data=True, license="BSD", entry_points={ From 19a1fa0a3bc37e19e1a442b380c64152250a6c9b Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 30 May 2020 14:02:11 -0700 Subject: [PATCH 03/38] doc: project badges --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index e933b0a..fb2d833 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +![](https://github.com/flyranch/figurefirst/workflows/Python%20package/badge.svg) +![](https://img.shields.io/pypi/v/figurefirst) +![](https://img.shields.io/github/license/flyranch/figurefirst) +![](https://img.shields.io/badge/code%20style-black-000000.svg) # FigureFirst FigureFirst is a python 3.5+ library to decorate and parse SVG files so they can serve as layout documents for matplotlib figures. In principle FigureFirst works on python 2.7, but it is not officially supported. * See our github page for readme and examples: http://flyranch.github.io/figurefirst/ From 8b249590edb71be4c9d8f4fb268bb821b17f6d37 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 30 May 2020 14:02:54 -0700 Subject: [PATCH 04/38] fix: licence --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 779dcda..1656e5a 100644 --- a/setup.py +++ b/setup.py @@ -37,7 +37,7 @@ 'dev': ['tox','sphinx','black'], 'docs': ['sphinx']}, include_package_data=True, - license="BSD", + license="MIT", entry_points={ "console_scripts": [ "figurefirst_ext=figurefirst_scripts.install_inkscape_ext:main" From 334a5103da73330a66c1626af5796b0af5787dae Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 30 May 2020 14:08:58 -0700 Subject: [PATCH 05/38] chore: update test workflow name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb2d833..3921633 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![](https://github.com/flyranch/figurefirst/workflows/Python%20package/badge.svg) +![](https://github.com/flyranch/figurefirst/workflows/Tests/badge.svg) ![](https://img.shields.io/pypi/v/figurefirst) ![](https://img.shields.io/github/license/flyranch/figurefirst) ![](https://img.shields.io/badge/code%20style-black-000000.svg) From ce0394b63074110232d40269a5d074e8b0418e76 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 30 May 2020 14:09:43 -0700 Subject: [PATCH 06/38] chore: workflow name --- .github/workflows/continuous-integration-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index eb7efb5..950701e 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -1,4 +1,4 @@ -name: Python package +name: Tests on: [push] From cba818422ef55cbc4b4225f77e3793fd4eb8aeb4 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 30 May 2020 14:13:47 -0700 Subject: [PATCH 07/38] chore: test badge on master --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3921633..ef4a92a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![](https://github.com/flyranch/figurefirst/workflows/Tests/badge.svg) +![](https://github.com/flyranch/figurefirst/workflows/Tests/badge.svg?branch=master) ![](https://img.shields.io/pypi/v/figurefirst) ![](https://img.shields.io/github/license/flyranch/figurefirst) ![](https://img.shields.io/badge/code%20style-black-000000.svg) From 0684f005a66cceed7b407af2f742c3d12d437154 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 02:06:12 -0700 Subject: [PATCH 08/38] chore: add black check to tox --- tox.ini | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 345cb29..0c4ee96 100644 --- a/tox.ini +++ b/tox.ini @@ -1,15 +1,21 @@ [tox] -envlist=py{35,36,37,38} +envlist=py{35,36,37,38,py38-black} [gh-actions] python = 3.5: py35, 3.6: py36, 3.7: py37, - 3.8: py38, + 3.8: py38, py38-black [testenv] deps = -rrequirements.txt commands = pip install . pytest -v + +[testenv:py38-black] +deps = + black +commands = + black --check --diff figurefirst From 84da09bfd34f80560a6aa050dbb98c251bf9bee0 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 02:20:06 -0700 Subject: [PATCH 09/38] fix: gh-actions syntax --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 0c4ee96..73194f5 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ python = 3.5: py35, 3.6: py36, 3.7: py37, - 3.8: py38, py38-black + 3.8: py38, black [testenv] deps = -rrequirements.txt From f9bbbcd2305f1dc994886188ace5b60194980b09 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 02:24:03 -0700 Subject: [PATCH 10/38] fix: gh-actions syntax --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 73194f5..0e3751f 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ commands = pip install . pytest -v -[testenv:py38-black] +[testenv:black] deps = black commands = From f13917fbc404f3554600d71e4598e85c9a79258e Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 02:32:54 -0700 Subject: [PATCH 11/38] fix: gh-actions syntax --- tox.ini | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 0e3751f..efb777f 100644 --- a/tox.ini +++ b/tox.ini @@ -1,12 +1,12 @@ [tox] -envlist=py{35,36,37,38,py38-black} +envlist=py{35,36,37,38,38-black} [gh-actions] python = 3.5: py35, 3.6: py36, 3.7: py37, - 3.8: py38, black + 3.8: py38, py38-black [testenv] deps = -rrequirements.txt @@ -14,7 +14,7 @@ commands = pip install . pytest -v -[testenv:black] +[testenv:py38-black] deps = black commands = From fa43cfd8e0ebbbc7323f52b608efc9f000a252be Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 15:14:23 -0700 Subject: [PATCH 12/38] chore: add security check workflow --- .github/workflows/security-check-workflow.yml | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .github/workflows/security-check-workflow.yml diff --git a/.github/workflows/security-check-workflow.yml b/.github/workflows/security-check-workflow.yml new file mode 100644 index 0000000..19633cb --- /dev/null +++ b/.github/workflows/security-check-workflow.yml @@ -0,0 +1,21 @@ +name: Security-check + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ python-version }} + uses: actions/setup-python@v2 + with: + python-version: 3.8 + - name: "Install dependencies" + run: | + python -m pip install --upgrade pip + pip install bandit + - name: "Run security check using bandit" + run: bandit -r figurefirst \ No newline at end of file From fb082b3de6975aa6d7d39368b79396843de765b7 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 15:16:09 -0700 Subject: [PATCH 13/38] chore: fix missing reference in security check --- .github/workflows/security-check-workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/security-check-workflow.yml b/.github/workflows/security-check-workflow.yml index 19633cb..3cc26de 100644 --- a/.github/workflows/security-check-workflow.yml +++ b/.github/workflows/security-check-workflow.yml @@ -9,7 +9,7 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python ${{ python-version }} + - name: Set up Python 3.8 uses: actions/setup-python@v2 with: python-version: 3.8 From 46ff340d44e28bd0d0afd78e474cad4cd4fb19fd Mon Sep 17 00:00:00 2001 From: psilentp Date: Sun, 31 May 2020 16:46:11 -0700 Subject: [PATCH 14/38] chore: using marketplace for soft failing checks --- .github/workflows/security-check-workflow.yml | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/security-check-workflow.yml b/.github/workflows/security-check-workflow.yml index 3cc26de..9232dde 100644 --- a/.github/workflows/security-check-workflow.yml +++ b/.github/workflows/security-check-workflow.yml @@ -9,13 +9,22 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up Python 3.8 - uses: actions/setup-python@v2 + - name: Security check - Bandit + uses: Joel-hanson/bandit-report-artifacts@V1 with: - python-version: 3.8 - - name: "Install dependencies" - run: | - python -m pip install --upgrade pip - pip install bandit - - name: "Run security check using bandit" - run: bandit -r figurefirst \ No newline at end of file + python_version: 3.8 + project_path: figurefirst + ignore_failure: true + + - name: Security check report artifacts + uses: actions/upload-artifact@v1 + # if: failure() + with: + name: Security report + path: output/security_report.txt + + - name: "Flake8 warnings" + uses: TrueBrain/actions-flake8@master + with: + path: figurefirst + only_warn: 1 \ No newline at end of file From bb2d3d9d4223c8b5c53093965e05fbf1ec9d1c9f Mon Sep 17 00:00:00 2001 From: psilentp Date: Mon, 1 Jun 2020 10:15:23 -0700 Subject: [PATCH 15/38] chore: remove artifact upload since there is no github ui to access --- ...check-workflow.yml => noncritical-checks-workflow.yml} | 8 -------- 1 file changed, 8 deletions(-) rename .github/workflows/{security-check-workflow.yml => noncritical-checks-workflow.yml} (69%) diff --git a/.github/workflows/security-check-workflow.yml b/.github/workflows/noncritical-checks-workflow.yml similarity index 69% rename from .github/workflows/security-check-workflow.yml rename to .github/workflows/noncritical-checks-workflow.yml index 9232dde..702f367 100644 --- a/.github/workflows/security-check-workflow.yml +++ b/.github/workflows/noncritical-checks-workflow.yml @@ -15,14 +15,6 @@ jobs: python_version: 3.8 project_path: figurefirst ignore_failure: true - - - name: Security check report artifacts - uses: actions/upload-artifact@v1 - # if: failure() - with: - name: Security report - path: output/security_report.txt - - name: "Flake8 warnings" uses: TrueBrain/actions-flake8@master with: From 7d494e6eea52810f9e9846d5134628c1fa88a8dc Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 5 Jun 2020 00:27:45 -0700 Subject: [PATCH 16/38] chore: remove line comment --- .github/workflows/continuous-integration-workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 950701e..c73d0e0 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -22,5 +22,4 @@ jobs: python -m pip install --upgrade pip pip install tox tox-gh-actions - name: "Run tox targets for ${{ matrix.python-version }}" - # Run tox using the version of Python in `PATH` run: python -m tox \ No newline at end of file From c982ece4d83b2ac8f412785856c57f834c856547 Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 5 Jun 2020 00:31:55 -0700 Subject: [PATCH 17/38] chore: publish workflow --- .github/workflows/publish-workflow.yml | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/publish-workflow.yml diff --git a/.github/workflows/publish-workflow.yml b/.github/workflows/publish-workflow.yml new file mode 100644 index 0000000..3f8e3de --- /dev/null +++ b/.github/workflows/publish-workflow.yml @@ -0,0 +1,32 @@ +name: Publish to PyPI and TestPyPI + +on: push +jobs: + build-n-publish: + name: Build and publish to PyPI and TestPyPI + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install twine + run: | + python -m pip install --upgrade pip + pip install twine + - name: Build a binary wheel and a source tarball + run: | + python setup.py sdist + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + if: startsWith(github.event.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file From 0e1e702ac2fc3ddc69b0ad611d076caa887e9b4a Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 5 Jun 2020 13:01:53 -0700 Subject: [PATCH 18/38] fix:added ordered dict shim to svg_to_axes --- figurefirst/svg_to_axes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/figurefirst/svg_to_axes.py b/figurefirst/svg_to_axes.py index 01fd2ed..2468204 100644 --- a/figurefirst/svg_to_axes.py +++ b/figurefirst/svg_to_axes.py @@ -7,6 +7,9 @@ import time import sys import copy +import sys +if sys.version_info < (3, 6): + from collections import OrderedDict as dict if sys.version_info > (3, 0): PY3 = True From 50e9fce34c52af6f5bf20e3dba7ccc03947416d4 Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 5 Jun 2020 22:20:01 -0700 Subject: [PATCH 19/38] chore:remove test-pypy step --- .github/workflows/publish-workflow.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/publish-workflow.yml b/.github/workflows/publish-workflow.yml index 3f8e3de..ba0b86d 100644 --- a/.github/workflows/publish-workflow.yml +++ b/.github/workflows/publish-workflow.yml @@ -18,12 +18,6 @@ jobs: - name: Build a binary wheel and a source tarball run: | python setup.py sdist - - name: Publish distribution 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - name: Publish distribution 📦 to PyPI if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master From 4acd4b8d709454c3db9e99cd39d65140c5acaa1a Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 5 Jun 2020 22:33:03 -0700 Subject: [PATCH 20/38] version bump: patch --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 1656e5a..5d23a41 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,7 @@ setup( name="figurefirst", - version="0.0.6", + version="0.0.7", author="Floris van Breugel, Theodore Lindsay, Peter Weir", author_email="floris@caltech.edu", packages=find_packages(exclude=("inkscape_extensions", "test")), From ed31fc60087dc088ae0672c5017c11a61aff0b31 Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 5 Jun 2020 22:52:30 -0700 Subject: [PATCH 21/38] Revert "fix:added ordered dict shim to svg_to_axes" This reverts commit 0e1e702ac2fc3ddc69b0ad611d076caa887e9b4a. --- figurefirst/svg_to_axes.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/figurefirst/svg_to_axes.py b/figurefirst/svg_to_axes.py index 2468204..01fd2ed 100644 --- a/figurefirst/svg_to_axes.py +++ b/figurefirst/svg_to_axes.py @@ -7,9 +7,6 @@ import time import sys import copy -import sys -if sys.version_info < (3, 6): - from collections import OrderedDict as dict if sys.version_info > (3, 0): PY3 = True From e6011b17dcc5723d0839541af2afcd0b1b4402e9 Mon Sep 17 00:00:00 2001 From: psilentp Date: Wed, 10 Jun 2020 16:53:00 -0700 Subject: [PATCH 22/38] Revert "chore:remove test-pypy step" This reverts commit 50e9fce34c52af6f5bf20e3dba7ccc03947416d4. --- .github/workflows/publish-workflow.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/publish-workflow.yml b/.github/workflows/publish-workflow.yml index ba0b86d..3f8e3de 100644 --- a/.github/workflows/publish-workflow.yml +++ b/.github/workflows/publish-workflow.yml @@ -18,6 +18,12 @@ jobs: - name: Build a binary wheel and a source tarball run: | python setup.py sdist + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ - name: Publish distribution 📦 to PyPI if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master From 7fc72171b27edd8fd89fd4af162091562d14fe83 Mon Sep 17 00:00:00 2001 From: psilentp Date: Wed, 10 Jun 2020 17:16:33 -0700 Subject: [PATCH 23/38] chore: moved deploy to ci workflow --- .../continuous-integration-workflow.yml | 37 +++++++++++++++++-- .github/workflows/publish-workflow.yml | 32 ---------------- 2 files changed, 33 insertions(+), 36 deletions(-) delete mode 100644 .github/workflows/publish-workflow.yml diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index c73d0e0..548641a 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -1,10 +1,10 @@ -name: Tests +name: CI on: [push] jobs: - build: - + tests: + name: run tests runs-on: ${{ matrix.os }} strategy: matrix: @@ -22,4 +22,33 @@ jobs: python -m pip install --upgrade pip pip install tox tox-gh-actions - name: "Run tox targets for ${{ matrix.python-version }}" - run: python -m tox \ No newline at end of file + run: python -m tox + build-n-publish: + name: Build and publish to PyPI and TestPyPI + runs-on: ubuntu-latest + needs: tests + steps: + - uses: actions/checkout@master + - name: Set up Python 3.7 + uses: actions/setup-python@v1 + with: + python-version: 3.7 + - name: Install twine + run: | + python -m pip install --upgrade pip + pip install twine + - name: Build a binary wheel and a source tarball + run: | + python setup.py sdist + - name: Publish distribution 📦 to Test PyPI + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + - name: Publish distribution 📦 to PyPI + if: startsWith(github.event.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish-workflow.yml b/.github/workflows/publish-workflow.yml deleted file mode 100644 index 3f8e3de..0000000 --- a/.github/workflows/publish-workflow.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Publish to PyPI and TestPyPI - -on: push -jobs: - build-n-publish: - name: Build and publish to PyPI and TestPyPI - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@master - - name: Set up Python 3.7 - uses: actions/setup-python@v1 - with: - python-version: 3.7 - - name: Install twine - run: | - python -m pip install --upgrade pip - pip install twine - - name: Build a binary wheel and a source tarball - run: | - python setup.py sdist - - name: Publish distribution 📦 to Test PyPI - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - - name: Publish distribution 📦 to PyPI - if: startsWith(github.event.ref, 'refs/tags') - uses: pypa/gh-action-pypi-publish@master - with: - user: __token__ - password: ${{ secrets.PYPI_TOKEN }} \ No newline at end of file From 79a9623d4f61163ec658bf4f9c6c44c0605742a1 Mon Sep 17 00:00:00 2001 From: psilentp Date: Wed, 10 Jun 2020 20:27:54 -0700 Subject: [PATCH 24/38] chore: switched to setuptools_scm for versionning --- figurefirst/__init__.py | 9 +++++++++ setup.py | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/figurefirst/__init__.py b/figurefirst/__init__.py index c243f6e..2f18fa4 100644 --- a/figurefirst/__init__.py +++ b/figurefirst/__init__.py @@ -6,8 +6,17 @@ from . import mpl_fig_to_figurefirst_svg from . import svg_util from . import deprecated_regenerate +try: + from importlib.metadata import version, PackageNotFoundError +except ImportError: + from importlib_metadata import version, PackageNotFoundError import sys if sys.version_info[0] > 2: # regenerate uses importlib.utils, which requires python 3? from . import regenerate + +try: + __version__ = version(__name__) +except PackageNotFoundError: + print('package not installed') \ No newline at end of file diff --git a/setup.py b/setup.py index 5d23a41..4956dfbd 100644 --- a/setup.py +++ b/setup.py @@ -23,7 +23,8 @@ setup( name="figurefirst", - version="0.0.7", + use_scm_version=True, + setup_requires=['setuptools_scm'], author="Floris van Breugel, Theodore Lindsay, Peter Weir", author_email="floris@caltech.edu", packages=find_packages(exclude=("inkscape_extensions", "test")), From e1e3ab3bca5059b36e06c7268615384df37dbf2f Mon Sep 17 00:00:00 2001 From: psilentp Date: Wed, 10 Jun 2020 20:32:32 -0700 Subject: [PATCH 25/38] style: black --- figurefirst/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/figurefirst/__init__.py b/figurefirst/__init__.py index 2f18fa4..82dd635 100644 --- a/figurefirst/__init__.py +++ b/figurefirst/__init__.py @@ -6,6 +6,7 @@ from . import mpl_fig_to_figurefirst_svg from . import svg_util from . import deprecated_regenerate + try: from importlib.metadata import version, PackageNotFoundError except ImportError: @@ -19,4 +20,4 @@ try: __version__ = version(__name__) except PackageNotFoundError: - print('package not installed') \ No newline at end of file + print("package not installed") From 771b71790155799b78be70f8c9bfd0a1c27ef647 Mon Sep 17 00:00:00 2001 From: psilentp Date: Wed, 10 Jun 2020 20:50:54 -0700 Subject: [PATCH 26/38] chore: updated local version for test-pypi --- setup.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 4956dfbd..2fe5a77 100644 --- a/setup.py +++ b/setup.py @@ -20,10 +20,12 @@ for fname in os.listdir(ext_dir_1) if fname.endswith(".inx") or fname.endswith(".py") ] +def local_scheme(version): + return "" setup( name="figurefirst", - use_scm_version=True, + use_scm_version={"local_scheme": local_scheme}, setup_requires=['setuptools_scm'], author="Floris van Breugel, Theodore Lindsay, Peter Weir", author_email="floris@caltech.edu", From d2e35f27972388bc3d0c8d84118bc44b58641da3 Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 19 Jun 2020 23:16:01 -0700 Subject: [PATCH 27/38] style: fixed unused import warning --- figurefirst/__init__.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/figurefirst/__init__.py b/figurefirst/__init__.py index 82dd635..4b56b62 100644 --- a/figurefirst/__init__.py +++ b/figurefirst/__init__.py @@ -1,12 +1,10 @@ -from . import svg_to_axes - -# reload(svg_to_axes) -from . import mpl_functions -from .svg_to_axes import FigureLayout -from . import mpl_fig_to_figurefirst_svg -from . import svg_util -from . import deprecated_regenerate - +__all__ = [ + "svg_to_axes", + "mpl_functions", + "mpl_fig_to_figurefirst_svg", + "svg_util", + "deprecated_regenerate", +] try: from importlib.metadata import version, PackageNotFoundError except ImportError: From 42d4f5986b334620d7476b89ffb05ab9c8c6a4fb Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 19 Jun 2020 23:16:48 -0700 Subject: [PATCH 28/38] style: ran black on non-package python files --- docs/conf.py | 80 +++--- examples/example_axis_methods.py | 40 +-- examples/example_figure_templating.py | 13 +- examples/example_group_axes.py | 10 +- examples/example_hello_world.py | 231 +++++++++++++++++- examples/example_jessyink.py | 41 +++- .../example_minimal_multi_fig_multi_ax.py | 194 ++++++++------- ...imal_multi_fig_multi_ax_template_layout.py | 92 +++---- examples/example_multi_fig.py | 18 +- examples/example_negative_labels.py | 12 +- examples/example_nested_groups.py | 22 +- examples/example_pathspec.py | 131 +++++----- examples/example_spine_spec.py | 5 +- examples/example_svgitem.py | 26 +- .../make_figure_example.py | 80 +++--- .../multi_figures_autogen_targetlayers.py | 55 +++-- examples/run_examples.py | 27 +- inkscape_extensions/0.x/tag_axis.py | 48 ++-- inkscape_extensions/0.x/tag_figure.py | 62 +++-- inkscape_extensions/0.x/tag_group.py | 48 ++-- inkscape_extensions/0.x/tag_linespec.py | 48 ++-- inkscape_extensions/0.x/tag_mplmethods.py | 58 +++-- inkscape_extensions/0.x/tag_patchspec.py | 48 ++-- inkscape_extensions/0.x/tag_spinespec.py | 48 ++-- inkscape_extensions/0.x/tag_svgitem.py | 46 ++-- inkscape_extensions/1.x/tag_axis.py | 48 ++-- inkscape_extensions/1.x/tag_figure.py | 63 +++-- inkscape_extensions/1.x/tag_group.py | 49 ++-- inkscape_extensions/1.x/tag_linespec.py | 49 ++-- inkscape_extensions/1.x/tag_mplmethods.py | 59 +++-- inkscape_extensions/1.x/tag_patchspec.py | 49 ++-- inkscape_extensions/1.x/tag_spinespec.py | 49 ++-- inkscape_extensions/1.x/tag_svgitem.py | 47 ++-- 33 files changed, 1212 insertions(+), 684 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index e81dd60..893deea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -18,8 +18,9 @@ # import os import sys -sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('../figurefirst')) + +sys.path.insert(0, os.path.abspath(".")) +sys.path.insert(0, os.path.abspath("../figurefirst")) # -- General configuration ------------------------------------------------ @@ -30,38 +31,40 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = ['sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.viewcode', - 'sphinx.ext.githubpages'] +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.doctest", + "sphinx.ext.todo", + "sphinx.ext.coverage", + "sphinx.ext.viewcode", + "sphinx.ext.githubpages", +] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'FigureFirst' -copyright = u'2017, Theodore Lindsay, Peter Weir, Floris van Breugel' -author = u'Theodore Lindsay, Peter Weir, Floris van Breugel' +project = u"FigureFirst" +copyright = u"2017, Theodore Lindsay, Peter Weir, Floris van Breugel" +author = u"Theodore Lindsay, Peter Weir, Floris van Breugel" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'0.1' +version = u"0.1" # The full version, including alpha/beta/rc tags. -release = u'0.1' +release = u"0.1" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -73,13 +76,13 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. -#todo_include_todos = True +# todo_include_todos = True # -- Options for HTML output ---------------------------------------------- @@ -87,8 +90,8 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -#html_theme = 'alabaster' -html_theme = 'sphinx_rtd_theme' +# html_theme = 'alabaster' +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -99,13 +102,13 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # -- Options for HTMLHelp output ------------------------------------------ # Output file base name for HTML help builder. -htmlhelp_basename = 'FigureFirstdoc' +htmlhelp_basename = "FigureFirstdoc" # -- Options for LaTeX output --------------------------------------------- @@ -114,15 +117,12 @@ # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -132,8 +132,13 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'FigureFirst.tex', u'FigureFirst Documentation', - u'Theodore Lindsay, Peter Weir, Floris van Breugel', 'manual'), + ( + master_doc, + "FigureFirst.tex", + u"FigureFirst Documentation", + u"Theodore Lindsay, Peter Weir, Floris van Breugel", + "manual", + ), ] @@ -141,10 +146,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'figurefirst', u'FigureFirst Documentation', - [author], 1) -] +man_pages = [(master_doc, "figurefirst", u"FigureFirst Documentation", [author], 1)] # -- Options for Texinfo output ------------------------------------------- @@ -153,7 +155,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'FigureFirst', u'FigureFirst Documentation', - author, 'FigureFirst', 'One line description of project.', - 'Miscellaneous'),] - + ( + master_doc, + "FigureFirst", + u"FigureFirst Documentation", + author, + "FigureFirst", + "One line description of project.", + "Miscellaneous", + ), +] diff --git a/examples/example_axis_methods.py b/examples/example_axis_methods.py index b2ff3b1..ca719df 100755 --- a/examples/example_axis_methods.py +++ b/examples/example_axis_methods.py @@ -1,32 +1,36 @@ #!/usr/bin/env python from pylab import * -from figurefirst import FigureLayout,mpl_functions +from figurefirst import FigureLayout, mpl_functions # You can decorate the svg tag with mpl.axis methods. For example to call ax.axhspan(100,200,zorder=10,color ='r',alpha = 0.3) on the axis named frequency.22H05.start use the following tag: -# +# # ``` # ``` -# +# # The layout.apply_mpl_methods function will then apply the methods passing the value of the svg atribute as arguments to the mpl.axis method. -#Passing axis methods +# Passing axis methods import numpy as np -layout = FigureLayout('example_axis_methods_layout.svg') + +layout = FigureLayout("example_axis_methods_layout.svg") layout.make_mplfigures() -layout.fig.set_facecolor('None') +layout.fig.set_facecolor("None") for mplax in layout.axes.values(): - ax = mplax['axis'] - ax.plot(np.arange(30),np.random.rand(30),color = 'k') - mpl_functions.adjust_spines(ax,'none', - spine_locations={}, - smart_bounds=True, - xticks=None, - yticks=None, - linewidth=1) - ax.patch.set_facecolor('None') + ax = mplax["axis"] + ax.plot(np.arange(30), np.random.rand(30), color="k") + mpl_functions.adjust_spines( + ax, + "none", + spine_locations={}, + smart_bounds=True, + xticks=None, + yticks=None, + linewidth=1, + ) + ax.patch.set_facecolor("None") layout.apply_mpl_methods() -layout.insert_figures('mpl_panel_a') -layout.write_svg('example_axis_methods_output.svg') -close('all') \ No newline at end of file +layout.insert_figures("mpl_panel_a") +layout.write_svg("example_axis_methods_output.svg") +close("all") diff --git a/examples/example_figure_templating.py b/examples/example_figure_templating.py index 5b8bfb4..56328d0 100755 --- a/examples/example_figure_templating.py +++ b/examples/example_figure_templating.py @@ -1,16 +1,15 @@ #!/usr/bin/env python import figurefirst -''' +""" To create a templated figure, draw a rectangle, and add a figurefirst:figure tag as if you were creating another figure. Then in addition to the figurefirst:name attribute, add a figurefirst:template attribute, whose value should correspond to the name of the figurefirst figure you want to use as the template. The template figure will be scaled to fill the box. -''' +""" -layout = figurefirst.FigureLayout('example_figure_templating_layout.svg' ) +layout = figurefirst.FigureLayout("example_figure_templating_layout.svg") layout.make_mplfigures() -layout.append_figure_to_layer(layout.figures['group2'], 'mpl_layer_2') -layout.append_figure_to_layer(layout.figures['group3'], 'mpl_layer_3') -layout.write_svg('example_figure_templating_output.svg') - +layout.append_figure_to_layer(layout.figures["group2"], "mpl_layer_2") +layout.append_figure_to_layer(layout.figures["group3"], "mpl_layer_3") +layout.write_svg("example_figure_templating_output.svg") diff --git a/examples/example_group_axes.py b/examples/example_group_axes.py index 39ff163..976002f 100755 --- a/examples/example_group_axes.py +++ b/examples/example_group_axes.py @@ -1,10 +1,10 @@ #!/usr/bin/env python from pylab import * -from figurefirst import FigureLayout,mpl_functions +from figurefirst import FigureLayout, mpl_functions -#Group axes example -layout = FigureLayout('example_group_axes_layout.svg') +# Group axes example +layout = FigureLayout("example_group_axes_layout.svg") layout.make_mplfigures() layout.insert_figures() -layout.write_svg('example_group_axes_output.svg') -close('all') \ No newline at end of file +layout.write_svg("example_group_axes_output.svg") +close("all") diff --git a/examples/example_hello_world.py b/examples/example_hello_world.py index b17eab4..3e1b23d 100755 --- a/examples/example_hello_world.py +++ b/examples/example_hello_world.py @@ -1,18 +1,237 @@ #!/usr/bin/env python import numpy as np import matplotlib.pyplot as plt + plt.ion() from figurefirst import FigureLayout -layout = FigureLayout('example_hello_world_layout.svg') +layout = FigureLayout("example_hello_world_layout.svg") layout.make_mplfigures() -d = np.array([[144, 57], [138, 57], [138, 59], [141, 61], [141, 82], [138, 84], [138, 85], [142, 85], [147, 85], [147, 84], [144, 82], [144, 57], [144, 57], [155, 57], [149, 57], [149, 59], [152, 61], [152, 82], [149, 84], [149, 85], [153, 85], [158, 85], [158, 84], [155, 82], [155, 57], [155, 57], [273, 57], [267, 57], [267, 59], [270, 61], [270, 82], [267, 84], [267, 85], [271, 85], [276, 85], [276, 84], [273, 82], [273, 57], [273, 57], [295, 57], [289, 57], [289, 59], [292, 61], [292, 70], [287, 67], [278, 76], [287, 85], [292, 83], [292, 85], [298, 85], [298, 84], [295, 81], [295, 57], [295, 57], [90, 57], [90, 59], [91, 59], [94, 61], [94, 82], [91, 84], [90, 84], [90, 85], [96, 85], [102, 85], [102, 84], [101, 84], [98, 82], [98, 71], [110, 71], [110, 82], [107, 84], [106, 84], [106, 85], [112, 85], [118, 85], [118, 84], [117, 84], [113, 82], [113, 61], [117, 59], [118, 59], [118, 57], [112, 58], [106, 57], [106, 59], [107, 59], [110, 61], [110, 70], [98, 70], [98, 61], [101, 59], [102, 59], [102, 57], [96, 58], [90, 57], [90, 57], [193, 57], [193, 59], [197, 60], [205, 85], [205, 86], [206, 85], [213, 65], [219, 85], [220, 86], [221, 85], [229, 61], [233, 59], [233, 57], [229, 58], [224, 57], [224, 59], [228, 61], [227, 62], [221, 80], [215, 60], [215, 60], [218, 59], [218, 57], [213, 58], [208, 57], [208, 59], [211, 60], [212, 63], [207, 80], [200, 60], [200, 60], [203, 59], [203, 57], [198, 58], [193, 57], [193, 57], [128, 67], [120, 76], [129, 85], [135, 80], [135, 80], [134, 80], [129, 84], [125, 82], [123, 76], [134, 76], [135, 75], [128, 67], [128, 67], [169, 67], [160, 76], [169, 85], [178, 76], [169, 67], [169, 67], [240, 67], [231, 76], [240, 85], [249, 76], [240, 67], [240, 67], [257, 67], [251, 68], [251, 69], [254, 71], [254, 82], [251, 84], [251, 85], [256, 85], [261, 85], [261, 84], [260, 84], [257, 82], [257, 75], [262, 68], [262, 68], [261, 70], [263, 71], [265, 70], [262, 67], [257, 71], [257, 67], [257, 67], [128, 68], [133, 75], [123, 75], [128, 68], [128, 68], [169, 68], [173, 70], [174, 76], [173, 81], [169, 84], [164, 82], [163, 76], [164, 70], [169, 68], [169, 68], [240, 68], [244, 70], [246, 76], [245, 81], [240, 84], [235, 82], [234, 76], [235, 70], [240, 68], [240, 68], [287, 68], [292, 70], [292, 72], [292, 80], [292, 82], [287, 84], [283, 82], [281, 76], [283, 71], [287, 68], [287, 68]]) +d = np.array( + [ + [144, 57], + [138, 57], + [138, 59], + [141, 61], + [141, 82], + [138, 84], + [138, 85], + [142, 85], + [147, 85], + [147, 84], + [144, 82], + [144, 57], + [144, 57], + [155, 57], + [149, 57], + [149, 59], + [152, 61], + [152, 82], + [149, 84], + [149, 85], + [153, 85], + [158, 85], + [158, 84], + [155, 82], + [155, 57], + [155, 57], + [273, 57], + [267, 57], + [267, 59], + [270, 61], + [270, 82], + [267, 84], + [267, 85], + [271, 85], + [276, 85], + [276, 84], + [273, 82], + [273, 57], + [273, 57], + [295, 57], + [289, 57], + [289, 59], + [292, 61], + [292, 70], + [287, 67], + [278, 76], + [287, 85], + [292, 83], + [292, 85], + [298, 85], + [298, 84], + [295, 81], + [295, 57], + [295, 57], + [90, 57], + [90, 59], + [91, 59], + [94, 61], + [94, 82], + [91, 84], + [90, 84], + [90, 85], + [96, 85], + [102, 85], + [102, 84], + [101, 84], + [98, 82], + [98, 71], + [110, 71], + [110, 82], + [107, 84], + [106, 84], + [106, 85], + [112, 85], + [118, 85], + [118, 84], + [117, 84], + [113, 82], + [113, 61], + [117, 59], + [118, 59], + [118, 57], + [112, 58], + [106, 57], + [106, 59], + [107, 59], + [110, 61], + [110, 70], + [98, 70], + [98, 61], + [101, 59], + [102, 59], + [102, 57], + [96, 58], + [90, 57], + [90, 57], + [193, 57], + [193, 59], + [197, 60], + [205, 85], + [205, 86], + [206, 85], + [213, 65], + [219, 85], + [220, 86], + [221, 85], + [229, 61], + [233, 59], + [233, 57], + [229, 58], + [224, 57], + [224, 59], + [228, 61], + [227, 62], + [221, 80], + [215, 60], + [215, 60], + [218, 59], + [218, 57], + [213, 58], + [208, 57], + [208, 59], + [211, 60], + [212, 63], + [207, 80], + [200, 60], + [200, 60], + [203, 59], + [203, 57], + [198, 58], + [193, 57], + [193, 57], + [128, 67], + [120, 76], + [129, 85], + [135, 80], + [135, 80], + [134, 80], + [129, 84], + [125, 82], + [123, 76], + [134, 76], + [135, 75], + [128, 67], + [128, 67], + [169, 67], + [160, 76], + [169, 85], + [178, 76], + [169, 67], + [169, 67], + [240, 67], + [231, 76], + [240, 85], + [249, 76], + [240, 67], + [240, 67], + [257, 67], + [251, 68], + [251, 69], + [254, 71], + [254, 82], + [251, 84], + [251, 85], + [256, 85], + [261, 85], + [261, 84], + [260, 84], + [257, 82], + [257, 75], + [262, 68], + [262, 68], + [261, 70], + [263, 71], + [265, 70], + [262, 67], + [257, 71], + [257, 67], + [257, 67], + [128, 68], + [133, 75], + [123, 75], + [128, 68], + [128, 68], + [169, 68], + [173, 70], + [174, 76], + [173, 81], + [169, 84], + [164, 82], + [163, 76], + [164, 70], + [169, 68], + [169, 68], + [240, 68], + [244, 70], + [246, 76], + [245, 81], + [240, 84], + [235, 82], + [234, 76], + [235, 70], + [240, 68], + [240, 68], + [287, 68], + [292, 70], + [292, 72], + [292, 80], + [292, 82], + [287, 84], + [283, 82], + [281, 76], + [283, 71], + [287, 68], + [287, 68], + ] +) -ax = layout.axes['ax_name']['axis'] +ax = layout.axes["ax_name"]["axis"] -ax.plot(d[:,0], -d[:,1], lw=4) +ax.plot(d[:, 0], -d[:, 1], lw=4) -layout.insert_figures('target_layer_name') +layout.insert_figures("target_layer_name") -layout.write_svg('example_hello_world_output.svg') +layout.write_svg("example_hello_world_output.svg") diff --git a/examples/example_jessyink.py b/examples/example_jessyink.py index 563e275..eb2aaf6 100755 --- a/examples/example_jessyink.py +++ b/examples/example_jessyink.py @@ -2,24 +2,39 @@ import numpy as np from figurefirst import FigureLayout -layout = FigureLayout('example_jessyink_layout.svg') +layout = FigureLayout("example_jessyink_layout.svg") layout.make_mplfigures() x_data = np.arange(30) -ax = layout.axes['ax_name']['axis'] -ax.plot(x_data, x_data**3, color='k', gid='figurefirst:line1') -ax.fill_between(x_data, .5*x_data**3, 2*x_data**3, color='k', edgecolor='none', alpha=.3, gid='figurefirst:fill1') -ax.plot(x_data, x_data[::-1]**3, color='r', gid='figurefirst:line2') -ax.axvspan(2, 10, color='b', alpha=.2, gid='figurefirst:span1') +ax = layout.axes["ax_name"]["axis"] +ax.plot(x_data, x_data ** 3, color="k", gid="figurefirst:line1") +ax.fill_between( + x_data, + 0.5 * x_data ** 3, + 2 * x_data ** 3, + color="k", + edgecolor="none", + alpha=0.3, + gid="figurefirst:fill1", +) +ax.plot(x_data, x_data[::-1] ** 3, color="r", gid="figurefirst:line2") +ax.axvspan(2, 10, color="b", alpha=0.2, gid="figurefirst:span1") layout.apply_mpl_methods() -layout.insert_figures('figurefirst_target_layer') +layout.insert_figures("figurefirst_target_layer") -layout.pass_xml('figurefirst:span1','jessyink:effectIn', 'name:appear;order:1;length:800') -layout.pass_xml('figurefirst:line1','jessyink:effectIn', 'name:appear;order:2;length:800') -layout.pass_xml('figurefirst:fill1','jessyink:effectIn', 'name:appear;order:2;length:800') -layout.pass_xml('figurefirst:line2','jessyink:effectIn', 'name:appear;order:3;length:800') - -layout.write_svg('example_jessyink_output.svg') +layout.pass_xml( + "figurefirst:span1", "jessyink:effectIn", "name:appear;order:1;length:800" +) +layout.pass_xml( + "figurefirst:line1", "jessyink:effectIn", "name:appear;order:2;length:800" +) +layout.pass_xml( + "figurefirst:fill1", "jessyink:effectIn", "name:appear;order:2;length:800" +) +layout.pass_xml( + "figurefirst:line2", "jessyink:effectIn", "name:appear;order:3;length:800" +) +layout.write_svg("example_jessyink_output.svg") diff --git a/examples/example_minimal_multi_fig_multi_ax.py b/examples/example_minimal_multi_fig_multi_ax.py index 0b975a8..060a66d 100755 --- a/examples/example_minimal_multi_fig_multi_ax.py +++ b/examples/example_minimal_multi_fig_multi_ax.py @@ -3,7 +3,7 @@ import matplotlib.pyplot as plt import figurefirst -''' +""" This example contains 3 methods for creating the same output from the same layout file. Choose the method most appropriate to your use-case as a starting template. @@ -12,171 +12,189 @@ Method 3: More sophisticated code, using loops to address the nested group structure To run all examples, see bottom of file starting with " if __name__ == '__main__' " -''' +""" + def get_example_x_and_y_data(): - x = np.linspace(0,10,100) - possible_y_outputs = [np.sin(x)*np.random.random(), - np.exp(x), - x**2, - np.sqrt(x)] - y = possible_y_outputs[ np.random.choice(range(len(possible_y_outputs))) ] + x = np.linspace(0, 10, 100) + possible_y_outputs = [np.sin(x) * np.random.random(), np.exp(x), x ** 2, np.sqrt(x)] + y = possible_y_outputs[np.random.choice(range(len(possible_y_outputs)))] return x, y + def method_1(): # Create layout object from layout svg file - layout = figurefirst.svg_to_axes.FigureLayout('example_minimal_multi_fig_multi_ax_layout.svg', make_mplfigures=True) - + layout = figurefirst.svg_to_axes.FigureLayout( + "example_minimal_multi_fig_multi_ax_layout.svg", make_mplfigures=True + ) + # Figure 1, axis a x, y = get_example_x_and_y_data() - ax = layout.axes[('figure1', 'axis_a')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['left']) + ax = layout.axes[("figure1", "axis_a")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["left"]) # Figure 1, axis b x, y = get_example_x_and_y_data() - ax = layout.axes[('figure1', 'axis_b')] - ax.plot(x,y,color='green') - figurefirst.mpl_functions.adjust_spines(ax, ['left', 'bottom']) - + ax = layout.axes[("figure1", "axis_b")] + ax.plot(x, y, color="green") + figurefirst.mpl_functions.adjust_spines(ax, ["left", "bottom"]) + # Figure 2, axis a # axis tag names in different figures can be identical, and still create unique axis objects x, y = get_example_x_and_y_data() - ax = layout.axes[('figure2', 'axis_a')] - ax.plot(x,y,color='black') + ax = layout.axes[("figure2", "axis_a")] + ax.plot(x, y, color="black") figurefirst.mpl_functions.adjust_spines(ax, []) - + # Figure 2, axis d # axis tag names in different figures can can also be different x, y = get_example_x_and_y_data() - ax = layout.axes[('figure2', 'axis_d')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['right', 'bottom']) - + ax = layout.axes[("figure2", "axis_d")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["right", "bottom"]) + # Set axis fontsize - figurefirst.mpl_functions.set_fontsize(layout.figures['figure1'], 8) - figurefirst.mpl_functions.set_fontsize(layout.figures['figure2'], 8) + figurefirst.mpl_functions.set_fontsize(layout.figures["figure1"], 8) + figurefirst.mpl_functions.set_fontsize(layout.figures["figure2"], 8) # Render figure 1 and 2 - layout.append_figure_to_layer(layout.figures['figure1'], 'figure1', cleartarget=True) - layout.append_figure_to_layer(layout.figures['figure2'], 'figure2', cleartarget=True) + layout.append_figure_to_layer( + layout.figures["figure1"], "figure1", cleartarget=True + ) + layout.append_figure_to_layer( + layout.figures["figure2"], "figure2", cleartarget=True + ) # Write (save) the resulting svg - layout.write_svg('output_of_examples/example_minimal_multi_fig_multi_ax_method1_layout.svg') - + layout.write_svg( + "output_of_examples/example_minimal_multi_fig_multi_ax_method1_layout.svg" + ) + + def __create_figure_1__(): - ''' + """ Create figures independently, as you would if you wanted to use two seperate scripts - ''' - layout = figurefirst.svg_to_axes.FigureLayout('example_minimal_multi_fig_multi_ax_layout.svg', make_mplfigures=True) - + """ + layout = figurefirst.svg_to_axes.FigureLayout( + "example_minimal_multi_fig_multi_ax_layout.svg", make_mplfigures=True + ) + # Figure 1, axis a x, y = get_example_x_and_y_data() - ax = layout.axes[('figure1', 'axis_a')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['left']) + ax = layout.axes[("figure1", "axis_a")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["left"]) # Figure 1, axis b x, y = get_example_x_and_y_data() - ax = layout.axes[('figure1', 'axis_b')] - ax.plot(x,y,color='green') - figurefirst.mpl_functions.adjust_spines(ax, ['left', 'bottom']) + ax = layout.axes[("figure1", "axis_b")] + ax.plot(x, y, color="green") + figurefirst.mpl_functions.adjust_spines(ax, ["left", "bottom"]) # Set axis fontsize - figurefirst.mpl_functions.set_fontsize(layout.figures['figure1'], 8) + figurefirst.mpl_functions.set_fontsize(layout.figures["figure1"], 8) # Render figure 1 and 2 - layout.append_figure_to_layer(layout.figures['figure1'], 'figure1', cleartarget=True) + layout.append_figure_to_layer( + layout.figures["figure1"], "figure1", cleartarget=True + ) # Write (save) the resulting svg - layout.write_svg('output_of_examples/example_minimal_multi_fig_multi_ax_method2_layout.svg') + layout.write_svg( + "output_of_examples/example_minimal_multi_fig_multi_ax_method2_layout.svg" + ) + def __create_figure_2__(): # must run "create_figure_1" first! Note that layout grabs the svg created with "create_figure_1" - layout = figurefirst.svg_to_axes.FigureLayout('output_of_examples/example_minimal_multi_fig_multi_ax_method2_layout.svg', make_mplfigures=True) - + layout = figurefirst.svg_to_axes.FigureLayout( + "output_of_examples/example_minimal_multi_fig_multi_ax_method2_layout.svg", + make_mplfigures=True, + ) + # Figure 2, axis a # axis tag names in different figures can be identical, and still create unique axis objects x, y = get_example_x_and_y_data() - ax = layout.axes[('figure2', 'axis_a')] - ax.plot(x,y,color='black') + ax = layout.axes[("figure2", "axis_a")] + ax.plot(x, y, color="black") figurefirst.mpl_functions.adjust_spines(ax, []) - + # Figure 2, axis d # axis tag names in different figures can can also be different x, y = get_example_x_and_y_data() - ax = layout.axes[('figure2', 'axis_d')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['right', 'bottom']) - + ax = layout.axes[("figure2", "axis_d")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["right", "bottom"]) + # Set axis fontsize - figurefirst.mpl_functions.set_fontsize(layout.figures['figure2'], 8) + figurefirst.mpl_functions.set_fontsize(layout.figures["figure2"], 8) # Render figure 1 and 2 - layout.append_figure_to_layer(layout.figures['figure2'], 'figure2', cleartarget=True) + layout.append_figure_to_layer( + layout.figures["figure2"], "figure2", cleartarget=True + ) # Write (save) the resulting svg - layout.write_svg('output_of_examples/example_minimal_multi_fig_multi_ax_method2_layout.svg') + layout.write_svg( + "output_of_examples/example_minimal_multi_fig_multi_ax_method2_layout.svg" + ) + def method_2(): - ''' + """ This is what you would do if you wanted to use two seperate scripts to create an output figure from 1 layout file. - ''' + """ __create_figure_1__() __create_figure_2__() + def method_3(): - ''' + """ Use loops to minimize code duplication. - ''' - possible_axis_tags = ['axis_a', 'axis_b', 'axis_d'] - possible_figure_tags = ['figure1', 'figure2'] - layout = figurefirst.svg_to_axes.FigureLayout('example_minimal_multi_fig_multi_ax_layout.svg', make_mplfigures=True) + """ + possible_axis_tags = ["axis_a", "axis_b", "axis_d"] + possible_figure_tags = ["figure1", "figure2"] + layout = figurefirst.svg_to_axes.FigureLayout( + "example_minimal_multi_fig_multi_ax_layout.svg", make_mplfigures=True + ) # reusable function for plotting data on figure / axis combo def plot_random_data_on_layout(layout, figure, axis): x, y = get_example_x_and_y_data() ax = layout.axes[(figure, axis)] - ax.plot(x,y) + ax.plot(x, y) # make axes pretty - if figure=='figure1' and axis=='axis_a': - figurefirst.mpl_functions.adjust_spines(ax, ['left']) - if figure=='figure1' and axis=='axis_b': - figurefirst.mpl_functions.adjust_spines(ax, ['left', 'bottom']) - if figure=='figure2' and axis=='axis_a': + if figure == "figure1" and axis == "axis_a": + figurefirst.mpl_functions.adjust_spines(ax, ["left"]) + if figure == "figure1" and axis == "axis_b": + figurefirst.mpl_functions.adjust_spines(ax, ["left", "bottom"]) + if figure == "figure2" and axis == "axis_a": figurefirst.mpl_functions.adjust_spines(ax, []) - if figure=='figure2' and axis=='axis_d': - figurefirst.mpl_functions.adjust_spines(ax, ['right', 'bottom']) - + if figure == "figure2" and axis == "axis_d": + figurefirst.mpl_functions.adjust_spines(ax, ["right", "bottom"]) + # loop through all figure and axis tags, check if the axis object exists, if it does, plot the data. for figure in possible_figure_tags: for axis in possible_axis_tags: if (figure, axis) in layout.axes.keys(): plot_random_data_on_layout(layout, figure, axis) figurefirst.mpl_functions.set_fontsize(layout.figures[figure], 8) - layout.append_figure_to_layer(layout.figures[figure], figure, cleartarget=True) + layout.append_figure_to_layer(layout.figures[figure], figure, cleartarget=True) # save output - layout.write_svg('output_of_examples/example_minimal_multi_fig_multi_ax_method3_layout.svg') + layout.write_svg( + "output_of_examples/example_minimal_multi_fig_multi_ax_method3_layout.svg" + ) + + +if __name__ == "__main__": -if __name__ == '__main__': - # Basic, linear code method_1() - + # Make the 2 figures independently - this is what you would do if using two seperate scripts to make your final figure output method_2() - + # More sophisticated code, using loops to address the nested group structure method_3() - - - - - - - - - - - diff --git a/examples/example_minimal_multi_fig_multi_ax_template_layout.py b/examples/example_minimal_multi_fig_multi_ax_template_layout.py index 878b93f..96d605c 100755 --- a/examples/example_minimal_multi_fig_multi_ax_template_layout.py +++ b/examples/example_minimal_multi_fig_multi_ax_template_layout.py @@ -3,7 +3,7 @@ import matplotlib.pyplot as plt import figurefirst -''' +""" This example contains 3 methods for creating the same output from the same layout file. Choose the method most appropriate to your use-case as a starting template. @@ -12,75 +12,75 @@ Method 3: More sophisticated code, using loops to address the nested group structure To run all examples, see bottom of file starting with " if __name__ == '__main__' " -''' +""" + def get_example_x_and_y_data(): - x = np.linspace(0,10,100) - possible_y_outputs = [np.sin(x)*np.random.random(), - np.exp(x), - x**2, - np.sqrt(x)] - y = possible_y_outputs[ np.random.choice(range(len(possible_y_outputs))) ] + x = np.linspace(0, 10, 100) + possible_y_outputs = [np.sin(x) * np.random.random(), np.exp(x), x ** 2, np.sqrt(x)] + y = possible_y_outputs[np.random.choice(range(len(possible_y_outputs)))] return x, y + def method_1(): # Create layout object from layout svg file - layout = figurefirst.svg_to_axes.FigureLayout('example_minimal_multi_fig_multi_ax_template_layout.svg', make_mplfigures=True) - + layout = figurefirst.svg_to_axes.FigureLayout( + "example_minimal_multi_fig_multi_ax_template_layout.svg", make_mplfigures=True + ) + # Figure 1, axis a x, y = get_example_x_and_y_data() - ax = layout.axes[('figure1', 'axis_a')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['left']) + ax = layout.axes[("figure1", "axis_a")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["left"]) # copy data over to figure 1 copy, axis a - ax = layout.axes[('figure1_copy', 'axis_a')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['left']) + ax = layout.axes[("figure1_copy", "axis_a")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["left"]) # Figure 1, axis b x, y = get_example_x_and_y_data() - ax = layout.axes[('figure1', 'axis_b')] - ax.plot(x,y,color='green') - figurefirst.mpl_functions.adjust_spines(ax, ['left', 'bottom']) - + ax = layout.axes[("figure1", "axis_b")] + ax.plot(x, y, color="green") + figurefirst.mpl_functions.adjust_spines(ax, ["left", "bottom"]) + # Figure 2, axis a # axis tag names in different figures can be identical, and still create unique axis objects x, y = get_example_x_and_y_data() - ax = layout.axes[('figure2', 'axis_a')] - ax.plot(x,y,color='black') + ax = layout.axes[("figure2", "axis_a")] + ax.plot(x, y, color="black") figurefirst.mpl_functions.adjust_spines(ax, []) - + # Figure 2, axis d # axis tag names in different figures can can also be different x, y = get_example_x_and_y_data() - ax = layout.axes[('figure2', 'axis_d')] - ax.plot(x,y,color='blue') - figurefirst.mpl_functions.adjust_spines(ax, ['right', 'bottom']) - + ax = layout.axes[("figure2", "axis_d")] + ax.plot(x, y, color="blue") + figurefirst.mpl_functions.adjust_spines(ax, ["right", "bottom"]) + # Set axis fontsize - figurefirst.mpl_functions.set_fontsize(layout.figures['figure1'], 8) - figurefirst.mpl_functions.set_fontsize(layout.figures['figure2'], 8) + figurefirst.mpl_functions.set_fontsize(layout.figures["figure1"], 8) + figurefirst.mpl_functions.set_fontsize(layout.figures["figure2"], 8) # Render figure 1 and 2 - layout.append_figure_to_layer(layout.figures['figure1'], 'figure1', cleartarget=True) - layout.append_figure_to_layer(layout.figures['figure2'], 'figure2', cleartarget=True) - layout.append_figure_to_layer(layout.figures['figure1_copy'], 'figure1_copy', cleartarget=True) + layout.append_figure_to_layer( + layout.figures["figure1"], "figure1", cleartarget=True + ) + layout.append_figure_to_layer( + layout.figures["figure2"], "figure2", cleartarget=True + ) + layout.append_figure_to_layer( + layout.figures["figure1_copy"], "figure1_copy", cleartarget=True + ) # Write (save) the resulting svg - layout.write_svg('output_of_examples/example_minimal_multi_fig_multi_ax_template_layout.svg') - -if __name__ == '__main__': - + layout.write_svg( + "output_of_examples/example_minimal_multi_fig_multi_ax_template_layout.svg" + ) + + +if __name__ == "__main__": + # Basic, linear code method_1() - - - - - - - - - - diff --git a/examples/example_multi_fig.py b/examples/example_multi_fig.py index 6ce8609..f7b09a3 100755 --- a/examples/example_multi_fig.py +++ b/examples/example_multi_fig.py @@ -1,13 +1,13 @@ #!/usr/bin/env python from pylab import * -from figurefirst import FigureLayout,mpl_functions +from figurefirst import FigureLayout, mpl_functions -print('running multi figure example') -#Groups and figures example -layout = FigureLayout('example_multi_fig_layout.svg') +print("running multi figure example") +# Groups and figures example +layout = FigureLayout("example_multi_fig_layout.svg") mplfig = layout.make_mplfigures() -layout.append_figure_to_layer(layout.figures['threeport'],'mpl_layer_2') -layout.append_figure_to_layer(layout.figures['oval'],'mpl_layer_3') -layout.append_figure_to_layer(layout.figures['holy'],'mpl_layer_4') -layout.write_svg('example_multi_fig_output.svg') -close('all') +layout.append_figure_to_layer(layout.figures["threeport"], "mpl_layer_2") +layout.append_figure_to_layer(layout.figures["oval"], "mpl_layer_3") +layout.append_figure_to_layer(layout.figures["holy"], "mpl_layer_4") +layout.write_svg("example_multi_fig_output.svg") +close("all") diff --git a/examples/example_negative_labels.py b/examples/example_negative_labels.py index 46c6cb3..5790e3f 100644 --- a/examples/example_negative_labels.py +++ b/examples/example_negative_labels.py @@ -1,10 +1,10 @@ import figurefirst as fifi -layout = fifi.svg_to_axes.FigureLayout('example_negative_labels.svg') +layout = fifi.svg_to_axes.FigureLayout("example_negative_labels.svg") layout.make_mplfigures() -layout.fig.set_facecolor('None') -ex = layout.axes['ex'] +layout.fig.set_facecolor("None") +ex = layout.axes["ex"] ex.plot([1, 2], [3, 4]) -fifi.mpl_functions.adjust_spines(ex, spines='left', yticks=[-1, -2]) -layout.insert_figures('panels', cleartarget=True) -layout.write_svg('negative_labels_output.svg') \ No newline at end of file +fifi.mpl_functions.adjust_spines(ex, spines="left", yticks=[-1, -2]) +layout.insert_figures("panels", cleartarget=True) +layout.write_svg("negative_labels_output.svg") diff --git a/examples/example_nested_groups.py b/examples/example_nested_groups.py index 0ad1df2..a697bbc 100755 --- a/examples/example_nested_groups.py +++ b/examples/example_nested_groups.py @@ -3,20 +3,20 @@ import matplotlib.pyplot as plt import matplotlib -layout = fifi.FigureLayout('example_nested_groups_layout.svg') +layout = fifi.FigureLayout("example_nested_groups_layout.svg") layout.make_mplfigures() -#print layout.axes -#layout.axes_groups['fig2']['group3']['ax2'].plot([2,3,4]) -for key,ax in layout.axes.items(): - #print key - #print type(ax) - ax.plot([1,3,2,4]) +# print layout.axes +# layout.axes_groups['fig2']['group3']['ax2'].plot([2,3,4]) +for key, ax in layout.axes.items(): + # print key + # print type(ax) + ax.plot([1, 3, 2, 4]) -cdict = {'r1':0.3,'r2':0.1,'r3':0.9} -for key,value in cdict.items(): +cdict = {"r1": 0.3, "r2": 0.1, "r3": 0.9} +for key, value in cdict.items(): hexi = matplotlib.colors.rgb2hex(plt.cm.viridis(value)) - layout.svgitems['svggroup'][key].style['fill'] = str(hexi) + layout.svgitems["svggroup"][key].style["fill"] = str(hexi) layout.apply_svg_attrs() layout.insert_figures() -layout.write_svg('example_nested_groups_output.svg') +layout.write_svg("example_nested_groups_output.svg") diff --git a/examples/example_pathspec.py b/examples/example_pathspec.py index 9737741..90dee4b 100755 --- a/examples/example_pathspec.py +++ b/examples/example_pathspec.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -import pylab as plb # this notebook is for plotting +import pylab as plb # this notebook is for plotting import numpy as np import figurefirst as fifi @@ -19,78 +19,99 @@ data = dict() N = 500 -T = 1. -Delta = T/N -for group_name,group_mean,group_sigma in zip(['A','B'], - [groupA_mean,groupB_mean], - [groupA_sigma,groupB_sigma]): +T = 1.0 +Delta = T / N +for group_name, group_mean, group_sigma in zip( + ["A", "B"], [groupA_mean, groupB_mean], [groupA_sigma, groupB_sigma] +): data[group_name] = dict() - for cond_name,cond_effect in zip(['cond_1','cond_2','cond_3','cond_4'], - [c1_effect,c2_effect,c3_effect,c4_effect]): + for cond_name, cond_effect in zip( + ["cond_1", "cond_2", "cond_3", "cond_4"], + [c1_effect, c2_effect, c3_effect, c4_effect], + ): data[group_name][cond_name] = list() for trial in range(10): - W = np.zeros(N+1) - t = np.linspace(0, T, N+1); - W[:N+1] = cond_effect + group_mean + np.cumsum(np.sqrt(Delta) * - np.random.standard_normal(N+1) * - group_sigma) - t = np.linspace(0, T, N+1); + W = np.zeros(N + 1) + t = np.linspace(0, T, N + 1) + W[: N + 1] = ( + cond_effect + + group_mean + + np.cumsum( + np.sqrt(Delta) * np.random.standard_normal(N + 1) * group_sigma + ) + ) + t = np.linspace(0, T, N + 1) data[group_name][cond_name].append(W) ##################################################### # Plot the data into a layout #################################################### - -#to remove spines + +# to remove spines def kill_spines(ax): - return fifi.mpl_functions.adjust_spines(ax,'none', - spine_locations={}, - smart_bounds=True, - xticks=None, - yticks=None, - linewidth=1) + return fifi.mpl_functions.adjust_spines( + ax, + "none", + spine_locations={}, + smart_bounds=True, + xticks=None, + yticks=None, + linewidth=1, + ) + ## create a layout -layout = fifi.FigureLayout('example_pathspec_layout.svg') +layout = fifi.FigureLayout("example_pathspec_layout.svg") ## make the mpl figure objects mplfig = layout.make_mplfigures() ## load the line and path specs to get plotting colors and effects layout.load_pathspecs() ## iterate through what you want to plot and find the needed data, ## not the other way around.. -for group_name,group in layout.axes_groups['none'].items(): - if not(group_name == 'summary'): - #print group_name - for cond_name,cond_ax in group.items(): - #print group_name - group_letter = group_name.split('group')[1] - kwargs = layout.pathspecs['trial_%s'%group_letter].mplkwargs() - cond_ax['axis'].plot(np.array(data[group_letter][cond_name]).T,**kwargs) - - kill_spines(cond_ax['axis']) - kwargs = layout.pathspecs['mean_%s'%group_letter].mplkwargs() - cond_ax['axis'].plot(np.mean(np.array(data[group_letter][cond_name]).T,axis = 1) - ,**kwargs) - cond_ax['axis'].set_ybound(-2,5) +for group_name, group in layout.axes_groups["none"].items(): + if not (group_name == "summary"): + # print group_name + for cond_name, cond_ax in group.items(): + # print group_name + group_letter = group_name.split("group")[1] + kwargs = layout.pathspecs["trial_%s" % group_letter].mplkwargs() + cond_ax["axis"].plot(np.array(data[group_letter][cond_name]).T, **kwargs) + + kill_spines(cond_ax["axis"]) + kwargs = layout.pathspecs["mean_%s" % group_letter].mplkwargs() + cond_ax["axis"].plot( + np.mean(np.array(data[group_letter][cond_name]).T, axis=1), **kwargs + ) + cond_ax["axis"].set_ybound(-2, 5) else: - group_letter = 'A' - kwargs = layout.pathspecs['hist%s'%group_letter].mplkwargs() - for cond_name,cond_ax in group.items(): - cond_ax['axis'].hist(np.array(data[group_letter][cond_name]).ravel(), - bins = 50,histtype = 'stepfilled',clip_on = False,**kwargs) - cond_ax['axis'].set_xbound(-2,5) - kill_spines(cond_ax['axis']) - group_letter = 'B' - kwargs = layout.pathspecs['hist%s'%group_letter].mplkwargs() - for cond_name,cond_ax in group.items(): - cond_ax['axis'].hist(np.array(data[group_letter][cond_name]).ravel(), - bins =50,histtype = 'stepfilled',clip_on = False,**kwargs) - cond_ax['axis'].set_xbound(-2,5) - kill_spines(cond_ax['axis']) + group_letter = "A" + kwargs = layout.pathspecs["hist%s" % group_letter].mplkwargs() + for cond_name, cond_ax in group.items(): + cond_ax["axis"].hist( + np.array(data[group_letter][cond_name]).ravel(), + bins=50, + histtype="stepfilled", + clip_on=False, + **kwargs + ) + cond_ax["axis"].set_xbound(-2, 5) + kill_spines(cond_ax["axis"]) + group_letter = "B" + kwargs = layout.pathspecs["hist%s" % group_letter].mplkwargs() + for cond_name, cond_ax in group.items(): + cond_ax["axis"].hist( + np.array(data[group_letter][cond_name]).ravel(), + bins=50, + histtype="stepfilled", + clip_on=False, + **kwargs + ) + cond_ax["axis"].set_xbound(-2, 5) + kill_spines(cond_ax["axis"]) ## insert the figures into the layout and save layout.insert_figures() -layout.set_layer_visibility('Layer 1',False) -layout.write_svg('example_pathspec_output.svg') -plb.close('all') -#display(SVG('pathspec_test_output.svg')) \ No newline at end of file +layout.set_layer_visibility("Layer 1", False) +layout.write_svg("example_pathspec_output.svg") +plb.close("all") +# display(SVG('pathspec_test_output.svg')) diff --git a/examples/example_spine_spec.py b/examples/example_spine_spec.py index 1445787..2a0b898 100755 --- a/examples/example_spine_spec.py +++ b/examples/example_spine_spec.py @@ -1,5 +1,6 @@ #!/usr/bin/env python import figurefirst as fifi -layout = fifi.FigureLayout('example_spine_spec_layout.svg',make_mplfigures = True) + +layout = fifi.FigureLayout("example_spine_spec_layout.svg", make_mplfigures=True) fifi.mpl_functions.set_spines(layout) -layout.save('example_spine_spec_output.svg') \ No newline at end of file +layout.save("example_spine_spec_output.svg") diff --git a/examples/example_svgitem.py b/examples/example_svgitem.py index 41c95e9..5036d21 100755 --- a/examples/example_svgitem.py +++ b/examples/example_svgitem.py @@ -2,25 +2,25 @@ import numpy as np import matplotlib.pyplot as plt import matplotlib -import figurefirst as fifi +import figurefirst as fifi -layout = fifi.FigureLayout('example_svgitem_layout.svg') +layout = fifi.FigureLayout("example_svgitem_layout.svg") layout.make_mplfigures() -cdict1 = {'r1':0.3,'r2':0.1,'r3':0.9} -cdict2 = {'path1':0.3,'path2':0.1,'path3':0.9} -for key,patch in layout.svgitems['svggroup'].items(): +cdict1 = {"r1": 0.3, "r2": 0.1, "r3": 0.9} +cdict2 = {"path1": 0.3, "path2": 0.1, "path3": 0.9} +for key, patch in layout.svgitems["svggroup"].items(): clev = cdict1[key] hexi = matplotlib.colors.rgb2hex(plt.cm.viridis(clev)) - patch.style['fill'] = str(hexi) + patch.style["fill"] = str(hexi) -for key,patch in layout.svgitems['pathgroup'].items(): +for key, patch in layout.svgitems["pathgroup"].items(): clev = cdict2[key] hexi = matplotlib.colors.rgb2hex(plt.cm.viridis(clev)) - patch.style['fill'] = str(hexi) - -layout.svgitems['l1'].style['fill'] = str(hexi) -layout.svgitems['l1'].text = str(clev) -layout.svgitems['l1'].style['font-size'] = 12 + patch.style["fill"] = str(hexi) + +layout.svgitems["l1"].style["fill"] = str(hexi) +layout.svgitems["l1"].text = str(clev) +layout.svgitems["l1"].style["font-size"] = 12 layout.apply_svg_attrs() -layout.save('example_svgitem_output.svg') +layout.save("example_svgitem_output.svg") diff --git a/examples/figure_groups_and_templates/make_figure_example.py b/examples/figure_groups_and_templates/make_figure_example.py index c0c7cf4..5c7de0e 100644 --- a/examples/figure_groups_and_templates/make_figure_example.py +++ b/examples/figure_groups_and_templates/make_figure_example.py @@ -2,63 +2,71 @@ import matplotlib.pyplot as plt import numpy as np + def make_plot(template_filename, output_filename): - + ## Define colors, spine locations, and notes for data ###################### - colors = {'group1': 'green', - 'group2': 'blue', - 'group3': 'orange'} - - spines = {'ax1': ['left', 'top'], - 'ax2': ['left', 'bottom'], - 'ax3': ['right', 'bottom']} - - functions = { 'ax1': np.sin, - 'ax2': np.cos, - 'ax3': np.tan} - - notes = {'group1': 'random data about green fish', - 'group2': 'random data about blue squirrels', - 'group3': 'random data about orange bats'} - + colors = {"group1": "green", "group2": "blue", "group3": "orange"} + + spines = { + "ax1": ["left", "top"], + "ax2": ["left", "bottom"], + "ax3": ["right", "bottom"], + } + + functions = {"ax1": np.sin, "ax2": np.cos, "ax3": np.tan} + + notes = { + "group1": "random data about green fish", + "group2": "random data about blue squirrels", + "group3": "random data about orange bats", + } + ## Open layout and generate matplotlib axes ################################ layout = figurefirst.svg_to_axes.FigureLayout(template_filename) layout.make_mplfigures() ## Iterate through groups and axes and plot data ########################### - for group in ['group1', 'group2', 'group3']: - for ax in ['ax1', 'ax2', 'ax3']: + for group in ["group1", "group2", "group3"]: + for ax in ["ax1", "ax2", "ax3"]: # grab the axis in this group mpl_axis = layout.axes[(group, ax)] # generate some data - x_data = np.arange(0,10,0.1) + x_data = np.arange(0, 10, 0.1) y_data = functions[ax](x_data) # plot the data mpl_axis.plot(x_data, y_data, color=colors[group]) # optional: make the spines look nice - mpl_axis.set_ylim(-1.2,1.2) - mpl_axis.set_xlim(-1,11) - figurefirst.mpl_functions.adjust_spines( mpl_axis, spines[ax], - spine_location_offset=5, - xticks=[0,5,10], - yticks=[-1, 0, 1]) - figurefirst.mpl_functions.set_fontsize(mpl_axis.figure,8) + mpl_axis.set_ylim(-1.2, 1.2) + mpl_axis.set_xlim(-1, 11) + figurefirst.mpl_functions.adjust_spines( + mpl_axis, + spines[ax], + spine_location_offset=5, + xticks=[0, 5, 10], + yticks=[-1, 0, 1], + ) + figurefirst.mpl_functions.set_fontsize(mpl_axis.figure, 8) # add the figure (group) to the layout as a new layer - layout.append_figure_to_layer(layout.figures[group], group, - cleartarget=True, # clear out the layer - save_traceback=True, # save the function call traceback - notes=notes[group]) # save notes about the data into the svg + layout.append_figure_to_layer( + layout.figures[group], + group, + cleartarget=True, # clear out the layer + save_traceback=True, # save the function call traceback + notes=notes[group], + ) # save notes about the data into the svg ## Hide the design layer and save the new svg file ########################## - layout.set_layer_visibility(inkscape_label = 'layout_design',vis = False) + layout.set_layer_visibility(inkscape_label="layout_design", vis=False) layout.write_svg(output_filename) -if __name__ == '__main__': - template_filename = 'figure_groups_and_templates.svg' - output_filename = 'figure_groups_and_templates_output.svg' - make_plot(template_filename, output_filename) +if __name__ == "__main__": + + template_filename = "figure_groups_and_templates.svg" + output_filename = "figure_groups_and_templates_output.svg" + make_plot(template_filename, output_filename) diff --git a/examples/multi_figures_layers/multi_figures_autogen_targetlayers.py b/examples/multi_figures_layers/multi_figures_autogen_targetlayers.py index 7a00d3c..070db5f 100755 --- a/examples/multi_figures_layers/multi_figures_autogen_targetlayers.py +++ b/examples/multi_figures_layers/multi_figures_autogen_targetlayers.py @@ -1,59 +1,68 @@ import figurefirst import numpy as np -''' +""" To create a templated figure, draw a rectangle, and add a figurefirst:figure tag as if you were creating another figure. Then in addition to the figurefirst:name attribute, add a figurefirst:template attribute, whose value should correspond to the name of the figurefirst figure you want to use as the template. The template figure will be scaled to fill the box. -''' +""" # manually create layers + def populate_axes_with_data(ax, color): - ax.plot(np.random.random(100), np.random.random(100), 'o', color=color) + ax.plot(np.random.random(100), np.random.random(100), "o", color=color) + -layout = figurefirst.FigureLayout('multi_figures_autogen_targetlayers.svg', autogenlayers=False ) +layout = figurefirst.FigureLayout( + "multi_figures_autogen_targetlayers.svg", autogenlayers=False +) layout.make_mplfigures() -name_to_color = {'figure1': 'blue', - 'figure2': 'red', - } +name_to_color = { + "figure1": "blue", + "figure2": "red", +} for figure_name, group in layout.axes_groups.items(): for axis_name, axis in group.items(): populate_axes_with_data(axis, name_to_color[figure_name]) -layout.create_new_targetlayer('figure1') -layout.create_new_targetlayer('figure2') +layout.create_new_targetlayer("figure1") +layout.create_new_targetlayer("figure2") -layout.append_figure_to_layer(layout.figures['figure1'], 'figure1') -layout.append_figure_to_layer(layout.figures['figure2'], 'figure2') +layout.append_figure_to_layer(layout.figures["figure1"], "figure1") +layout.append_figure_to_layer(layout.figures["figure2"], "figure2") -layout.set_layer_visibility('Design_layer', False) +layout.set_layer_visibility("Design_layer", False) -layout.write_svg('multi_figures_autogen_targetlayers_manual.svg') +layout.write_svg("multi_figures_autogen_targetlayers_manual.svg") # auto gen layers based on need + def populate_axes_with_data(ax, color): - ax.plot(np.random.random(100), np.random.random(100), 'o', color=color) + ax.plot(np.random.random(100), np.random.random(100), "o", color=color) -layout = figurefirst.FigureLayout('multi_figures_autogen_targetlayers.svg', autogenlayers=True ) + +layout = figurefirst.FigureLayout( + "multi_figures_autogen_targetlayers.svg", autogenlayers=True +) layout.make_mplfigures() -name_to_color = {'figure1': 'blue', - 'figure2': 'red', - } +name_to_color = { + "figure1": "blue", + "figure2": "red", +} for figure_name, group in layout.axes_groups.items(): for axis_name, axis in group.items(): populate_axes_with_data(axis, name_to_color[figure_name]) -layout.append_figure_to_layer(layout.figures['figure1'], 'figure1') -layout.append_figure_to_layer(layout.figures['figure2'], 'figure2') - -layout.set_layer_visibility('Design_layer', False) +layout.append_figure_to_layer(layout.figures["figure1"], "figure1") +layout.append_figure_to_layer(layout.figures["figure2"], "figure2") -layout.write_svg('multi_figures_autogen_targetlayers_auto.svg') +layout.set_layer_visibility("Design_layer", False) +layout.write_svg("multi_figures_autogen_targetlayers_auto.svg") diff --git a/examples/run_examples.py b/examples/run_examples.py index f50c564..401065a 100755 --- a/examples/run_examples.py +++ b/examples/run_examples.py @@ -1,18 +1,21 @@ #!/usr/bin/env python import os from glob import glob -#from subprocess import call -examples = glob(os.path.join(os.path.dirname(os.path.realpath(__file__)), "example_*.py")) -print('########################') -print('# Testing Python2 #') -print('########################') + +# from subprocess import call +examples = glob( + os.path.join(os.path.dirname(os.path.realpath(__file__)), "example_*.py") +) +print("########################") +print("# Testing Python2 #") +print("########################") for example in examples: - print("Running:%s"%example) - os.system('python2 %s'%(example)) + print("Running:%s" % example) + os.system("python2 %s" % (example)) -print('########################') -print('# Testing Python3 #') -print('########################') +print("########################") +print("# Testing Python3 #") +print("########################") for example in examples: - print("Running:%s"%example) - os.system('python %s'%(example)) \ No newline at end of file + print("Running:%s" % example) + os.system("python %s" % (example)) diff --git a/inkscape_extensions/0.x/tag_axis.py b/inkscape_extensions/0.x/tag_axis.py index 4d43aa7..893fde2 100644 --- a/inkscape_extensions/0.x/tag_axis.py +++ b/inkscape_extensions/0.x/tag_axis.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstAxisTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,18 +26,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.OptionParser.add_option('-n', '--name', action = 'store', - type = 'string', dest = 'name', default = 'none', - help = 'Name axis') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.OptionParser.add_option( + "-n", + "--name", + action="store", + type="string", + dest="name", + default="none", + help="Name axis", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -48,16 +60,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("axis", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstAxisTagEffect() -effect.affect() \ No newline at end of file +effect.affect() diff --git a/inkscape_extensions/0.x/tag_figure.py b/inkscape_extensions/0.x/tag_figure.py index 03ca612..8480156 100644 --- a/inkscape_extensions/0.x/tag_figure.py +++ b/inkscape_extensions/0.x/tag_figure.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstFigureTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,21 +26,35 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.OptionParser.add_option('-n', '--name', action = 'store', - type = 'string', dest = 'name', default = 'none', - help = 'Name figure') - self.OptionParser.add_option('-t', '--template', action = 'store', - type = 'string', dest = 'template', default = 'none', - help = 'Name template (optional)') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.OptionParser.add_option( + "-n", + "--name", + action="store", + type="string", + dest="name", + default="none", + help="Name figure", + ) + self.OptionParser.add_option( + "-t", + "--template", + action="store", + type="string", + dest="template", + default="none", + help="Name template (optional)", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -52,19 +70,19 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("figure", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - if template != 'none': + if template != "none": newElm.attrib[inkex.addNS("template", "figurefirst")] = template - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstFigureTagEffect() -effect.affect() \ No newline at end of file +effect.affect() diff --git a/inkscape_extensions/0.x/tag_group.py b/inkscape_extensions/0.x/tag_group.py index 1f52593..7649c69 100644 --- a/inkscape_extensions/0.x/tag_group.py +++ b/inkscape_extensions/0.x/tag_group.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstGroupTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,18 +26,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.OptionParser.add_option('-n', '--name', action = 'store', - type = 'string', dest = 'name', default = 'none', - help = 'Name group') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.OptionParser.add_option( + "-n", + "--name", + action="store", + type="string", + dest="name", + default="none", + help="Name group", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -48,16 +60,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("group", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstGroupTagEffect() -effect.affect() \ No newline at end of file +effect.affect() diff --git a/inkscape_extensions/0.x/tag_linespec.py b/inkscape_extensions/0.x/tag_linespec.py index 59f2ef4..769c7ca 100644 --- a/inkscape_extensions/0.x/tag_linespec.py +++ b/inkscape_extensions/0.x/tag_linespec.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstLineTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,18 +26,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.OptionParser.add_option('-n', '--name', action = 'store', - type = 'string', dest = 'name', default = 'none', - help = 'Name linespec') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.OptionParser.add_option( + "-n", + "--name", + action="store", + type="string", + dest="name", + default="none", + help="Name linespec", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -48,16 +60,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("linespec", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstLineTagEffect() -effect.affect() \ No newline at end of file +effect.affect() diff --git a/inkscape_extensions/0.x/tag_mplmethods.py b/inkscape_extensions/0.x/tag_mplmethods.py index 4eb9c8c..0fb13bd 100644 --- a/inkscape_extensions/0.x/tag_mplmethods.py +++ b/inkscape_extensions/0.x/tag_mplmethods.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstMPLMethodsTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with mplmethods tag. """ + def __init__(self): """ Constructor. @@ -22,21 +26,35 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #Define string option "--mplmethod" with "-m" shortcut and default value "none". - self.OptionParser.add_option('-m', '--mplmethod', action = 'store', - type = 'string', dest = 'mplmethod', default = 'none', - help = 'Method name') - #Define string option "--mplmethodarg" with "-z" shortcut and default value "none". - self.OptionParser.add_option('-a', '--mplmethodarg', action = 'store', - type = 'string', dest = 'mplmethodarg', default = 'none', - help = 'Method arguments') + # Define string option "--mplmethod" with "-m" shortcut and default value "none". + self.OptionParser.add_option( + "-m", + "--mplmethod", + action="store", + type="string", + dest="mplmethod", + default="none", + help="Method name", + ) + # Define string option "--mplmethodarg" with "-z" shortcut and default value "none". + self.OptionParser.add_option( + "-a", + "--mplmethodarg", + action="store", + type="string", + dest="mplmethodarg", + default="none", + help="Method arguments", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -53,13 +71,13 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("mplmethods", "figurefirst")) newElm.attrib[inkex.addNS(mplmethod, "figurefirst")] = mplmethodarg - #print inkex.NSS + # print inkex.NSS el.append(newElm) diff --git a/inkscape_extensions/0.x/tag_patchspec.py b/inkscape_extensions/0.x/tag_patchspec.py index 79a4db6..b57dbb3 100644 --- a/inkscape_extensions/0.x/tag_patchspec.py +++ b/inkscape_extensions/0.x/tag_patchspec.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstPatchTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,18 +26,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.OptionParser.add_option('-n', '--name', action = 'store', - type = 'string', dest = 'name', default = 'none', - help = 'Name patch') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.OptionParser.add_option( + "-n", + "--name", + action="store", + type="string", + dest="name", + default="none", + help="Name patch", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -48,16 +60,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("patchspec", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstPatchTagEffect() -effect.affect() \ No newline at end of file +effect.affect() diff --git a/inkscape_extensions/0.x/tag_spinespec.py b/inkscape_extensions/0.x/tag_spinespec.py index f8a0621..808ef78 100644 --- a/inkscape_extensions/0.x/tag_spinespec.py +++ b/inkscape_extensions/0.x/tag_spinespec.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstAxisTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,18 +26,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--spinespec" with "-sp" shortcut and default value "left,bottom". - self.OptionParser.add_option('-s', '--spinespec', action = 'store', - type = 'string', dest = 'spinespec', default = 'left,bottom', - help = "Add a spine specification as a comma separated list of spine locations. \n Valid values are: top,bottom,right or left") + # import matplotlib + # Define string option "--spinespec" with "-sp" shortcut and default value "left,bottom". + self.OptionParser.add_option( + "-s", + "--spinespec", + action="store", + type="string", + dest="spinespec", + default="left,bottom", + help="Add a spine specification as a comma separated list of spine locations. \n Valid values are: top,bottom,right or left", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -47,16 +59,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("spinespec", "figurefirst")) newElm.attrib[inkex.addNS("spinelist", "figurefirst")] = spinelist - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstAxisTagEffect() -effect.affect() \ No newline at end of file +effect.affect() diff --git a/inkscape_extensions/0.x/tag_svgitem.py b/inkscape_extensions/0.x/tag_svgitem.py index 4ac7206..264a15d 100644 --- a/inkscape_extensions/0.x/tag_svgitem.py +++ b/inkscape_extensions/0.x/tag_svgitem.py @@ -1,20 +1,24 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstSVGItemTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -22,18 +26,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.OptionParser.add_option('-n', '--name', action = 'store', - type = 'string', dest = 'name', default = 'none', - help = 'Name svgitem') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.OptionParser.add_option( + "-n", + "--name", + action="store", + type="string", + dest="name", + default="none", + help="Name svgitem", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - inkex.etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + inkex.etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -48,13 +60,13 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.selected.values())>1: - raise Exception('too many items') + if len(self.selected.values()) > 1: + raise Exception("too many items") else: el = self.selected.values()[0] newElm = inkex.etree.Element(inkex.addNS("svgitem", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) diff --git a/inkscape_extensions/1.x/tag_axis.py b/inkscape_extensions/1.x/tag_axis.py index 3b1d155..792fbd9 100644 --- a/inkscape_extensions/1.x/tag_axis.py +++ b/inkscape_extensions/1.x/tag_axis.py @@ -1,21 +1,25 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * from lxml import etree + class FigureFirstAxisTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,18 +27,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.arg_parser.add_argument('-n', '--name', action = 'store', - type = str, dest = 'name', default = 'none', - help = 'Name axis') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.arg_parser.add_argument( + "-n", + "--name", + action="store", + type=str, + dest="name", + default="none", + help="Name axis", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -50,16 +62,16 @@ def effect(self): # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("axis", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstAxisTagEffect() -effect.run() \ No newline at end of file +effect.run() diff --git a/inkscape_extensions/1.x/tag_figure.py b/inkscape_extensions/1.x/tag_figure.py index 619a14f..4c91108 100644 --- a/inkscape_extensions/1.x/tag_figure.py +++ b/inkscape_extensions/1.x/tag_figure.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstFigureTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,21 +28,35 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.arg_parser.add_argument('-n', '--name', action = 'store', - type =str, dest = 'name', default = 'none', - help = 'Name figure') - self.arg_parser.add_argument('-t', '--template', action = 'store', - type = str, dest = 'template', default = 'none', - help = 'Name template (optional)') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.arg_parser.add_argument( + "-n", + "--name", + action="store", + type=str, + dest="name", + default="none", + help="Name figure", + ) + self.arg_parser.add_argument( + "-t", + "--template", + action="store", + type=str, + dest="template", + default="none", + help="Name template (optional)", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -53,19 +72,19 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(list(self.svg.selected.values()))>1: - raise Exception('too many items') + if len(list(self.svg.selected.values())) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("figure", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - if template != 'none': + if template != "none": newElm.attrib[inkex.addNS("template", "figurefirst")] = template - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstFigureTagEffect() -effect.run() \ No newline at end of file +effect.run() diff --git a/inkscape_extensions/1.x/tag_group.py b/inkscape_extensions/1.x/tag_group.py index 433613d..a39c3fa 100644 --- a/inkscape_extensions/1.x/tag_group.py +++ b/inkscape_extensions/1.x/tag_group.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstGroupTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,18 +28,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.arg_parser.add_argument('-n', '--name', action = 'store', - type = str, dest = 'name', default = 'none', - help = 'Name group') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.arg_parser.add_argument( + "-n", + "--name", + action="store", + type=str, + dest="name", + default="none", + help="Name group", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -49,16 +62,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("group", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstGroupTagEffect() -effect.run() \ No newline at end of file +effect.run() diff --git a/inkscape_extensions/1.x/tag_linespec.py b/inkscape_extensions/1.x/tag_linespec.py index 01d4d75..868eb5a 100644 --- a/inkscape_extensions/1.x/tag_linespec.py +++ b/inkscape_extensions/1.x/tag_linespec.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstLineTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,18 +28,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.arg_parser.add_argument('-n', '--name', action = 'store', - type = str, dest = 'name', default = 'none', - help = 'Name linespec') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.arg_parser.add_argument( + "-n", + "--name", + action="store", + type=str, + dest="name", + default="none", + help="Name linespec", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -49,16 +62,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("linespec", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstLineTagEffect() -effect.run() \ No newline at end of file +effect.run() diff --git a/inkscape_extensions/1.x/tag_mplmethods.py b/inkscape_extensions/1.x/tag_mplmethods.py index b12cb40..51f509b 100644 --- a/inkscape_extensions/1.x/tag_mplmethods.py +++ b/inkscape_extensions/1.x/tag_mplmethods.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstMPLMethodsTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with mplmethods tag. """ + def __init__(self): """ Constructor. @@ -23,21 +28,35 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #Define string option "--mplmethod" with "-m" shortcut and default value "none". - self.arg_parser.add_argument('-m', '--mplmethod', action = 'store', - type = str, dest = 'mplmethod', default = 'none', - help = 'Method name') - #Define string option "--mplmethodarg" with "-z" shortcut and default value "none". - self.arg_parser.add_argument('-a', '--mplmethodarg', action = 'store', - type = str, dest = 'mplmethodarg', default = 'none', - help = 'Method arguments') + # Define string option "--mplmethod" with "-m" shortcut and default value "none". + self.arg_parser.add_argument( + "-m", + "--mplmethod", + action="store", + type=str, + dest="mplmethod", + default="none", + help="Method name", + ) + # Define string option "--mplmethodarg" with "-z" shortcut and default value "none". + self.arg_parser.add_argument( + "-a", + "--mplmethodarg", + action="store", + type=str, + dest="mplmethodarg", + default="none", + help="Method arguments", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -54,13 +73,13 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("mplmethods", "figurefirst")) newElm.attrib[inkex.addNS(mplmethod, "figurefirst")] = mplmethodarg - #print inkex.NSS + # print inkex.NSS el.append(newElm) diff --git a/inkscape_extensions/1.x/tag_patchspec.py b/inkscape_extensions/1.x/tag_patchspec.py index 89132ec..32dece7 100644 --- a/inkscape_extensions/1.x/tag_patchspec.py +++ b/inkscape_extensions/1.x/tag_patchspec.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstPatchTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,18 +28,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.arg_parser.add_argument('-n', '--name', action = 'store', - type = str, dest = 'name', default = 'none', - help = 'Name patch') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.arg_parser.add_argument( + "-n", + "--name", + action="store", + type=str, + dest="name", + default="none", + help="Name patch", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -49,16 +62,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("patchspec", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstPatchTagEffect() -effect.run() \ No newline at end of file +effect.run() diff --git a/inkscape_extensions/1.x/tag_spinespec.py b/inkscape_extensions/1.x/tag_spinespec.py index 8ac2e64..599b5c9 100644 --- a/inkscape_extensions/1.x/tag_spinespec.py +++ b/inkscape_extensions/1.x/tag_spinespec.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstAxisTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,18 +28,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--spinespec" with "-sp" shortcut and default value "left,bottom". - self.arg_parser.add_argument('-s', '--spinespec', action = 'store', - type =str, dest = 'spinespec', default = 'left,bottom', - help = "Add a spine specification as a comma separated list of spine locations. \n Valid values are: top,bottom,right or left") + # import matplotlib + # Define string option "--spinespec" with "-sp" shortcut and default value "left,bottom". + self.arg_parser.add_argument( + "-s", + "--spinespec", + action="store", + type=str, + dest="spinespec", + default="left,bottom", + help="Add a spine specification as a comma separated list of spine locations. \n Valid values are: top,bottom,right or left", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -48,16 +61,16 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("spinespec", "figurefirst")) newElm.attrib[inkex.addNS("spinelist", "figurefirst")] = spinelist - #print inkex.NSS + # print inkex.NSS el.append(newElm) # Create effect instance and apply it. effect = FigureFirstAxisTagEffect() -effect.run() \ No newline at end of file +effect.run() diff --git a/inkscape_extensions/1.x/tag_svgitem.py b/inkscape_extensions/1.x/tag_svgitem.py index c787041..3825f67 100644 --- a/inkscape_extensions/1.x/tag_svgitem.py +++ b/inkscape_extensions/1.x/tag_svgitem.py @@ -1,21 +1,26 @@ #!/usr/bin/env python import sys -sys.path.append('/usr/share/inkscape/extensions') # or another path, as necessary -sys.path.append('/Applications/Inkscape.app/Contents/Resources/extensions') -sys.path.append('C:\Program Files\Inkscape\share\extensions') + +sys.path.append("/usr/share/inkscape/extensions") # or another path, as necessary +sys.path.append("/Applications/Inkscape.app/Contents/Resources/extensions") +sys.path.append("C:\Program Files\Inkscape\share\extensions") from lxml import etree -#import xml.etree.ElementTree as ET -#ET.register_namespace('figurefirst', 'http://www.figurefirst.com') + +# import xml.etree.ElementTree as ET +# ET.register_namespace('figurefirst', 'http://www.figurefirst.com') # We will use the inkex module with the predefined Effect base class. import inkex + # The simplestyle module provides functions for style parsing. from simplestyle import * + class FigureFirstSVGItemTagEffect(inkex.Effect): """ Modified from example Inkscape effect extension. Tags object with axis tag. """ + def __init__(self): """ Constructor. @@ -23,18 +28,26 @@ def __init__(self): """ # Call the base class constructor. inkex.Effect.__init__(self) - #import matplotlib - #Define string option "--name" with "-n" shortcut and default value "World". - self.arg_parser.add_argument('-n', '--name', action = 'store', - type = str, dest = 'name', default = 'none', - help = 'Name svgitem') + # import matplotlib + # Define string option "--name" with "-n" shortcut and default value "World". + self.arg_parser.add_argument( + "-n", + "--name", + action="store", + type=str, + dest="name", + default="none", + help="Name svgitem", + ) inkex.NSS[u"figurefirst"] = u"http://flyranch.github.io/figurefirst/" try: - etree.register_namespace("figurefirst","http://flyranch.github.io/figurefirst/") + etree.register_namespace( + "figurefirst", "http://flyranch.github.io/figurefirst/" + ) except AttributeError: - #inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) - #This happens on windows version of inkscape - it might be good to check - #and see if the namespace has been correctly added to the document + # inkex.etree._NamespaceRegistry.update(inkex.addNS("name", "figurefirst")) + # This happens on windows version of inkscape - it might be good to check + # and see if the namespace has been correctly added to the document pass def effect(self): @@ -49,13 +62,13 @@ def effect(self): svg = self.document.getroot() # or alternatively # Create text element - if len(self.svg.selected.values())>1: - raise Exception('too many items') + if len(self.svg.selected.values()) > 1: + raise Exception("too many items") else: el = list(self.svg.selected.values())[0] newElm = etree.Element(inkex.addNS("svgitem", "figurefirst")) newElm.attrib[inkex.addNS("name", "figurefirst")] = name - #print inkex.NSS + # print inkex.NSS el.append(newElm) From d69a8d956d452d6affe679e71ea6f030d10e2e1b Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 19 Jun 2020 23:17:27 -0700 Subject: [PATCH 29/38] chore: added flake8 config --- .flake8 | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..7d46f26 --- /dev/null +++ b/.flake8 @@ -0,0 +1,6 @@ +[flake8] +exclude = .git,*site-packages* +ignore = E203, E266, E501, W503, F403, F401 +max-line-length = 89 +max-complexity = 18 +select = B,C,E,F,W,T4,B9 \ No newline at end of file From 6549767e918996ddf24ad59beb855a82bea97308 Mon Sep 17 00:00:00 2001 From: psilentp Date: Fri, 19 Jun 2020 23:51:35 -0700 Subject: [PATCH 30/38] chore: added pyprojec.toml --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 pyproject.toml diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2d229e7 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,4 @@ +[tool.setuptools_scm] + +[build-system] +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] \ No newline at end of file From ac532ba6f2b82f1f31a388a44be75e03b3e6db45 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 00:09:38 -0700 Subject: [PATCH 31/38] fix: FigureLayout import in __init__ --- figurefirst/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/figurefirst/__init__.py b/figurefirst/__init__.py index 4b56b62..44e10c2 100644 --- a/figurefirst/__init__.py +++ b/figurefirst/__init__.py @@ -4,7 +4,11 @@ "mpl_fig_to_figurefirst_svg", "svg_util", "deprecated_regenerate", + "FigureLayout" ] + +from figurefirst.svg_to_axes import FigureLayout + try: from importlib.metadata import version, PackageNotFoundError except ImportError: From 7e9385123b4a0f7d74ab9da91953da0139f5fb96 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 00:19:14 -0700 Subject: [PATCH 32/38] style:black --- figurefirst/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/figurefirst/__init__.py b/figurefirst/__init__.py index 44e10c2..3a7283d 100644 --- a/figurefirst/__init__.py +++ b/figurefirst/__init__.py @@ -4,7 +4,7 @@ "mpl_fig_to_figurefirst_svg", "svg_util", "deprecated_regenerate", - "FigureLayout" + "FigureLayout", ] from figurefirst.svg_to_axes import FigureLayout From 1132c851e66309b90f8b1cfbd367b6353cd00b7f Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 00:20:35 -0700 Subject: [PATCH 33/38] doc:readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ef4a92a..24ac865 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,6 @@ Restart Inkscape - To keep the test output files for inspection, add the `--keep_files` option - To test against all supported python versions, run `tox` - We use [black](https://pypi.org/project/black/) for code formatting. -- Enable your github account with travis for continuous integration - Raise a pull request From 478c726d969745f23125ec06520538832f64288f Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 00:29:03 -0700 Subject: [PATCH 34/38] fix:removed wheel --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 2d229e7..c63e706 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [tool.setuptools_scm] [build-system] -requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] \ No newline at end of file +requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4"] \ No newline at end of file From 5058da34e9f9ca70634338429d68cb21c9d28f35 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 01:47:36 -0700 Subject: [PATCH 35/38] Revert "fix:removed wheel" This reverts commit 478c726d969745f23125ec06520538832f64288f. --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c63e706..2d229e7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [tool.setuptools_scm] [build-system] -requires = ["setuptools>=42", "setuptools_scm[toml]>=3.4"] \ No newline at end of file +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] \ No newline at end of file From 6858565da6c85072fa2002c192d83dbeb21f7e16 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 21:29:13 -0700 Subject: [PATCH 36/38] chore: format dev versions for test pypi --- pyproject.toml | 5 ++--- setup.py | 4 +++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 2d229e7..908bdac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,3 @@ -[tool.setuptools_scm] - [build-system] -requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] \ No newline at end of file +requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/setup.py b/setup.py index 2fe5a77..26cd193 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,9 @@ if fname.endswith(".inx") or fname.endswith(".py") ] def local_scheme(version): - return "" + return "_{rev}_{distance}".format( + rev=version.node[1:], + distance=version.distance) setup( name="figurefirst", From fa6c2fc54f9083377124e2f2bd1b5914aff3cd89 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 22:01:38 -0700 Subject: [PATCH 37/38] chore: return to empty dev version string --- setup.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/setup.py b/setup.py index 26cd193..2fe5a77 100644 --- a/setup.py +++ b/setup.py @@ -21,9 +21,7 @@ if fname.endswith(".inx") or fname.endswith(".py") ] def local_scheme(version): - return "_{rev}_{distance}".format( - rev=version.node[1:], - distance=version.distance) + return "" setup( name="figurefirst", From 2cc87a5d6313f1ef68d2c5a46422bdbdfb969f94 Mon Sep 17 00:00:00 2001 From: psilentp Date: Sat, 20 Jun 2020 22:37:07 -0700 Subject: [PATCH 38/38] chore: continue on error true for test-pypi --- .github/workflows/continuous-integration-workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration-workflow.yml b/.github/workflows/continuous-integration-workflow.yml index 548641a..1247b9c 100644 --- a/.github/workflows/continuous-integration-workflow.yml +++ b/.github/workflows/continuous-integration-workflow.yml @@ -46,6 +46,7 @@ jobs: user: __token__ password: ${{ secrets.TEST_PYPI_TOKEN }} repository_url: https://test.pypi.org/legacy/ + continue-on-error: true - name: Publish distribution 📦 to PyPI if: startsWith(github.event.ref, 'refs/tags') uses: pypa/gh-action-pypi-publish@master