Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
db82a05
refractor: remove redundancy in ci workflow
psilentp May 29, 2020
d13be0c
feat: dev and doc requirments
psilentp May 30, 2020
19a1fa0
doc: project badges
psilentp May 30, 2020
8b24959
fix: licence
psilentp May 30, 2020
334a510
chore: update test workflow name
psilentp May 30, 2020
ce0394b
chore: workflow name
psilentp May 30, 2020
cba8184
chore: test badge on master
psilentp May 30, 2020
0684f00
chore: add black check to tox
psilentp May 31, 2020
84da09b
fix: gh-actions syntax
psilentp May 31, 2020
f9bbbcd
fix: gh-actions syntax
psilentp May 31, 2020
f13917f
fix: gh-actions syntax
psilentp May 31, 2020
fa43cfd
chore: add security check workflow
psilentp May 31, 2020
fb082b3
chore: fix missing reference in security check
psilentp May 31, 2020
46ff340
chore: using marketplace for soft failing checks
psilentp May 31, 2020
bb2d3d9
chore: remove artifact upload since there is no github ui to access
psilentp Jun 1, 2020
7d494e6
chore: remove line comment
psilentp Jun 5, 2020
c982ece
chore: publish workflow
psilentp Jun 5, 2020
0e1e702
fix:added ordered dict shim to svg_to_axes
psilentp Jun 5, 2020
50e9fce
chore:remove test-pypy step
psilentp Jun 6, 2020
4acd4b8
version bump: patch
psilentp Jun 6, 2020
ed31fc6
Revert "fix:added ordered dict shim to svg_to_axes"
psilentp Jun 6, 2020
e6011b1
Revert "chore:remove test-pypy step"
psilentp Jun 10, 2020
7fc7217
chore: moved deploy to ci workflow
psilentp Jun 11, 2020
79a9623
chore: switched to setuptools_scm for versionning
psilentp Jun 11, 2020
e1e3ab3
style: black
psilentp Jun 11, 2020
771b717
chore: updated local version for test-pypi
psilentp Jun 11, 2020
d2e35f2
style: fixed unused import warning
psilentp Jun 20, 2020
42d4f59
style: ran black on non-package python files
psilentp Jun 20, 2020
d69a8d9
chore: added flake8 config
psilentp Jun 20, 2020
6549767
chore: added pyprojec.toml
psilentp Jun 20, 2020
ac532ba
fix: FigureLayout import in __init__
psilentp Jun 20, 2020
7e93851
style:black
psilentp Jun 20, 2020
1132c85
doc:readme
psilentp Jun 20, 2020
478c726
fix:removed wheel
psilentp Jun 20, 2020
5058da3
Revert "fix:removed wheel"
psilentp Jun 20, 2020
6858565
chore: format dev versions for test pypi
psilentp Jun 21, 2020
fa6c2fc
chore: return to empty dev version string
psilentp Jun 21, 2020
2cc87a5
chore: continue on error true for test-pypi
psilentp Jun 21, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -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
48 changes: 37 additions & 11 deletions .github/workflows/continuous-integration-workflow.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Python package
name: CI

on: [push]

jobs:
build:

tests:
name: run tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
Expand All @@ -17,13 +17,39 @@ 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
# Run tox using the version of Python in `PATH`
run: tox -e py
pip install tox tox-gh-actions
- name: "Run tox targets for ${{ matrix.python-version }}"
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this runs every time, will it fail a build if the same version is pushed repeatedly?

Copy link
Member Author

@psilentp psilentp Jun 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should push something like figurefirst-0.0.6.dev{distance}. Of course given this workflow where we are hitting test-pipy with every push on any branch, there is a potential collision if two branches get pushed at the same distance.

My original idea was to implement something like this:
https://github.com/scikit-hep/pyhf/tree/master/.github/workflows
Which has a separate build and publish workflow for merged branches. But as we discussed above, this might just add unnecessary complexity to the project given its size.

I've enabled continue on error for this step so that the failures in the rare cases of these collisions shouldn't keep us from pushing a release. I'm not sure it is actually necessary to set continue on error to true, but it does get rid of the annoying email updates, and we can still double check the console output before merging.

uses: pypa/gh-action-pypi-publish@master
with:
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
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/noncritical-checks-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Security-check

on: [push]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Security check - Bandit
uses: Joel-hanson/bandit-report-artifacts@V1
with:
python_version: 3.8
project_path: figurefirst
ignore_failure: true
- name: "Flake8 warnings"
uses: TrueBrain/actions-flake8@master
with:
path: figurefirst
only_warn: 1
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
![](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)
# 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/
Expand Down Expand Up @@ -68,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


Expand Down
80 changes: 44 additions & 36 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ------------------------------------------------

Expand All @@ -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.
Expand All @@ -73,22 +76,22 @@
# 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 ----------------------------------------------

# 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
Expand All @@ -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 ---------------------------------------------
Expand All @@ -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',
Expand All @@ -132,19 +132,21 @@
# (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",
),
]


# -- Options for manual page output ---------------------------------------

# 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 -------------------------------------------
Expand All @@ -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",
),
]
40 changes: 22 additions & 18 deletions examples/example_axis_methods.py
Original file line number Diff line number Diff line change
@@ -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 <figurefirsrt:axis> 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:
#
#
# ```
# <figurefirst:axis
# figurefirst:name="frequency.22H05.start"
# figurefirst:axhspan="100,200,zorder=10,color='r',alpha=.3"/> ```
#
#
# 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')
layout.insert_figures("mpl_panel_a")
layout.write_svg("example_axis_methods_output.svg")
close("all")
13 changes: 6 additions & 7 deletions examples/example_figure_templating.py
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 5 additions & 5 deletions examples/example_group_axes.py
Original file line number Diff line number Diff line change
@@ -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')
layout.write_svg("example_group_axes_output.svg")
close("all")
Loading