Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Prev Previous commit
Move journal dictionary to top; add testing for journals
  • Loading branch information
bradyrx committed Sep 4, 2019
commit 32c4cc8ede5d98dd479145f5db518cf1bb845c4c
11 changes: 10 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
=================
Changelog History
=================

ProPlot v1.0.0
--------------
==============
First official release. Coming soon! Future changes and releases will be documented.

Internals/Minor Fixes
---------------------
- Add AAAS journal specifications to ``journal`` keyword for ``proplot.subplots()``, fix bug breaking on certain journals, add testing. (:pr:`30`) `Riley X. Brady`_.


.. _`Luke Davis`: https://github.com/lukelbd
.. _`Riley X. Brady`: https://github.com/bradyrx
5 changes: 5 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@
# 'matplotlib.sphinxext.plot_directive', # see: https://matplotlib.org/sampledoc/extensions.html
]

extlinks = {
Comment thread
lukelbd marked this conversation as resolved.
'issue': ('https://github.com/lukelbd/proplot/issues/%s', 'GH#'),
'pr': ('https://github.com/lukelbd/proplot/pull/%s', 'GH#'),
}

# Do not run doctest tests, these are just to show syntax and expected
# output may be graphical
doctest_test_doctest_blocks = ''
Expand Down
40 changes: 22 additions & 18 deletions proplot/subplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,24 @@
't':'top',
}

# Dimensions of figures for common journals
JOURNAL_SPECS = {
'pnas1': '8.7cm', # if 1 number specified, this is a tuple
'pnas2': '11.4cm',
'pnas3': '17.8cm',
'ams1': 3.2, # spec is in inches
'ams2': 4.5,
'ams3': 5.5,
'ams4': 6.5,
'agu1': ('95mm', '115mm'),
'agu2': ('190mm', '115mm'),
'agu3': ('95mm', '230mm'),
'agu4': ('190mm', '230mm'),
'aaas1': '5.5cm', # AAAS (e.g., Science) 1 column
'aaas2': '12cm', # AAAS 2 column
}


#-----------------------------------------------------------------------------#
# Miscellaneous stuff
#-----------------------------------------------------------------------------#
Expand Down Expand Up @@ -1473,30 +1491,16 @@ def _iter_axes(self):
#-----------------------------------------------------------------------------#
def _journals(journal):
"""Journal sizes for figures."""
table = {
'pnas1': '8.7cm', # if 1 number specified, this is a tuple
'pnas2': '11.4cm',
'pnas3': '17.8cm',
'ams1': 3.2, # spec is in inches
'ams2': 4.5,
'ams3': 5.5,
'ams4': 6.5,
'agu1': ('95mm', '115mm'),
'agu2': ('190mm', '115mm'),
'agu3': ('95mm', '230mm'),
'agu4': ('190mm', '230mm'),
'aaas1': '5.5cm', # AAAS (e.g., Science) 1 column
'aaas2': '12cm', # AAAS 2 column
}
value = table.get(journal, None)
# Get dimensions for figure from common journals.
value = JOURNAL_SPECS.get(journal, None)
if value is None:
raise ValueError(f'Unknown journal figure size specifier {journal!r}. ' +
'Current options are: ' + ', '.join(table.keys()))
'Current options are: ' + ', '.join(JOURNAL_SPECS.keys()))
# Return width, and optionally also the height
width, height = None, None
try:
width, height = value
except ValueError:
except (TypeError, ValueError):
width = value
return width, height

Expand Down
11 changes: 11 additions & 0 deletions proplot/tests/test_journals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pytest

import proplot as plot
from proplot.subplots import JOURNAL_SPECS


# Loop through all available journals.
@pytest.mark.parametrize('journal', JOURNAL_SPECS.keys())
def test_journal_subplots(journal):
"""Tests that subplots can be generated with journal specifications."""
f, axs = plot.subplots(journal=journal)
Comment thread
lukelbd marked this conversation as resolved.