Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plots subpackage #67

Merged
merged 22 commits into from
Jun 19, 2021
Merged

Add plots subpackage #67

merged 22 commits into from
Jun 19, 2021

Conversation

quantum9Innovation
Copy link
Member

Development v2: massive-plots


New Feature

The massive-plots operation will add a plots subpackage to epispot, enabling an even wider array of plots and charts to be generated automatically from epispot Model objects. As of right now, these include

  • interactive web-based plots (w/ plotly)
    • standard line charts
    • stacked area charts
  • native plotting (w/ matplotlib + SciencePlots for styling and optionally LaTeX)
    • standard line charts
    • stacked area charts

Another operation, mini-plots, will add comparative features to this list and allow charting parameter values and comparing different models. The testing suite for this new module can be found at tests/plotting. Below are a few screenshots from tests to demonstrate the new charts:

test_plotting_tfw
Plotly web chart (standard line graph of the SEIR model)

test_plotting_tfs
Plotly web chart (stacked area graph of the SEIR model)

test_plotting_tpn
Matplotlib native chart (standard line graph of the SEIR model: no LaTeX)

test_plotting_tpns
Matplotlib native chart (stacked area graph of the SEIR model: with LaTeX)

Known Issues

There is one noted issue about native stacked area plots, which you can see in #66.
This problem will not affect any other part of epispot's codebase.

Code Breakdown

  • .travis.yml
    • Add new requirement installation routine
  • README-nightly.md
    • Describe new experimental requirements
  • epispot/__init__.py
    • Add new requirements to dependency check
  • Delete epispot/plots.py
  • Create epispot/plots subpackage
  • Create requirements-dev.txt, requirements-nightly.txt for experimental dependencies
  • setup-nightly.py
    • Update dependency information
  • Delete no longer necessary tests/transforms
  • Create tests/plotting for plots subpackage
  • tests/x
    • Update package integrity check

Additional Notes

Deprecation Warning (severe):

This commit deprecates the entire epi.plots module.

Release Notes (major):

Due to this severe deprecation and the obvious restructuring of
internal code, these features will likely be released early in the
alpha stage of epispot v3 via epispot-nightly.

Migration (from v2.1.1):

The new epi.plots.native module will serve as the replacement for the
epi.plots module in v2.1.1.

Warnings (minor):

Occasionally, legend visibility is poor due to the fact that
matplotlib does not enforce any white background on the legend.
A patch will likely fix this. See #66 for more information.

quantum9Innovation and others added 13 commits June 11, 2021 14:48
This is a complete restructuring of the `epi.plots` module from previous
releases. This commit creates a subpackage `epi.plots`
to handle plotting operations from various models. This subpackage
currently has one other module `web` which handles web-based plotting
via `plotly`, a new experimental dependency.

Changelist:
- Add new requirement `plotly` to `README-nightly.py`
- Add subpackage `epi.plots` to `__init__.py`
- Create subpackage `epi.plots` (and remove old module)
- Add `web` module to `epi.plots` subpackage
- Update testing suite
    - Replace `test_transforms.py` with `test_plotting.py` for
    `epi.plots` subpackage

Additional Notes:
Deprecation Warning (severe):
This commit deprecates the entire `epi.plots` module.
Release Notes (major):
Due to this severe deprecation and the obvious restructuring of
internal code, these features will likely be released early in the
alpha stage of epispot v3 via `epispot-nightly`.
This commit greatly simplifies the requirements in the epispot project:
- `requirements.txt`: Basic requirements needed to run the stable
version
- `requirements-nightly.txt`: Basic requirements plus experimental
dependencies for the nightly version of epispot
- `requirements-dev.txt`: All requirements for the nightly version plus
helpful packages used in the development process

We have also kept `bin/requirements.txt` separately, but all these
requirements are specified in the nightly requirements file as well.

Changelist:
- Update Travis CI to use dev requirements
- Add new requirement specifications to the nightly README
- Create new requirements files
- Update `setup-nightly.py` to include experimental dependencies

Additional Notes:
Fixes (major):
This commit fixes the failing Travis CI build from
`df13d29b9b7e0b92654576f1f76a2a0d88418083`.
This commit is intended to fix an error in the Travis CI workflow due
to incorrect dependency specifications in `plotly`. Plotly requires
`pandas` to run but `pandas` is not explicitly defined as a dependency so it
is not installed by `pip` automatically. Because of this, it is listed
as a separate dependency to `epispot`.

Changelist:
- Add `pandas` to `requirements-nightly.txt`
- Add `pandas` to `requirements-dev.txt`

Additional Notes:
Fixes (major):
Fix `02202b802793a00c4cb41d8f060d5fb23fb40622`
This commit updates the `plotly` graph styling used in
`epi.plots.web.model()` to use:
- Times New Roman by default, followed by a serif font
- Larger font size (`24px`)
- Greater margins (`250px` left and right, `150px` top and bottom)

Changelist:
- Update graphing styles in `epi.plots.web`
Stacked area charts are now available for compartmental models in
`epi.plots.web`, implemented via the function `stacked`. This function
takes all the same arguments as the `model` function and uses all the
same themes; only the chart type is different.

Changelist:
- Add stacked area charts to `epi.plots.web`
- Add corresponding tests in `tests/test_plotting.py`
The structure label for `epi.plots.web` did not include the `stacked()`
function. Additionally, it did not properly include the `()` to
indicate that both `model()` and `stacked()` are functions.

Changelist:
- Fix `## Structure` label on `epi.plots.web`
This commit adds a `title` parameter to all plotting functions.
Additionally, the `test_plotting` structure label has been changed to
account for the new tests.

Changelist:
- Add `title` parameter to plots in `epi.plots.web`
- Add testing for `title` in `tests/test_plotting.py`
- Update structure label in `tests/test_plotting.py`
This commit introduces native plotting via `matplotlib` and
`SciencePlots` (for styling purposes). Previously, plots were generated
from the `epi.plots.web` module which created in-browser plots rather
than native ones. These new native plots can be accessed via
`epi.plots.native` and are displayed in a new window.

Changelist:
- Add `epi.plots.native` module
- Add `SciencePlots` to `requirements-nightly.txt`
- Add `SciencePlots` to `requirements-dev.txt`
- Add dependency check for `SciencePlots` in `epi.plots.__init__.py`
and add `native` module
- Add `native` plots to tests

Additional Notes:
Migration (from v2.1.1):
The new `epi.plots.native` module will serve as the replacement for the
`epi.plots` module in v2.1.1.
* Debug Travis CI

* Further debug Travis CI

* Update `requirements-dev.txt`

* Optimize imports

Co-authored-by: q9i <46249765+quantum9Innovation@users.noreply.github.com>
This commit fixes the code coverage lapses identified in
"Code Coverage Gaps on `massive-plots` Branch" (#65) by:
 (1) adding `# pragma: no cover` annotations to `ImportError`
 (2) adding a `test_full_native` test to test other parameters in
  `epi.plots.native.model()`
Additionally, this commit fixes an identified bug as a result of the
increased testing on the `epi.plots.native` module. The `compartments`
and `names` parameters to `epi.plots.native.model()` can now be used
without errors.

Changelist:
- Add `# pragma: no cover` annotations to `epi.plots`
- Fix bug in `epi.plots.native.model()`
- Add a full native test in `tests/plotting`

Additional Notes:
Issues (minor):
- Fixes "Code Coverage Gaps on `massive-plots` Branch #65"
- Fixes additional bug discovered in `epi.plots.native.model()`
This commit introduces similar stacked area charts to
`epi.plots.web.stacked()` in `epi.plots.native`, this adding native
support for stacked area charts.

Changelist:
- Add `epi.plots.native.stacked()`
- Add testing support for ^ in `tests/plotting`

Additional Notes:
Warnings (minor):
Occasionally, legend visibility is poor due to the fact that
`matplotlib` does not enforce any white background on the legend.
A patch will likely fix this.
Parameter values that were stretched across multiple lines have now
been concatenated onto one line.

Changelist:
- Format `tests/plotting`
@quantum9Innovation quantum9Innovation added feat 🚀 New feature or request nightly 🌙 Nightly builds or releases high-priority 🔼 This is important labels Jun 17, 2021
@github-actions github-actions bot added src Changes to the package source code tests Testing suite updates labels Jun 17, 2021
@codecov
Copy link

codecov bot commented Jun 17, 2021

Codecov Report

Merging #67 (dfa4d6a) into master (4c36d98) will increase coverage by 2.29%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #67      +/-   ##
==========================================
+ Coverage   87.86%   90.15%   +2.29%     
==========================================
  Files           7        9       +2     
  Lines         412      508      +96     
==========================================
+ Hits          362      458      +96     
  Misses         50       50              
Impacted Files Coverage Δ
epispot/__init__.py 100.00% <100.00%> (ø)
epispot/plots/__init__.py 100.00% <100.00%> (ø)
epispot/plots/native.py 100.00% <100.00%> (ø)
epispot/plots/web.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d9dbf03...dfa4d6a. Read the comment docs.

Fix DeepSource error: Re-defined variable from outer scope
PYL-W0621

Changelist:
- Remove error from epi.plots
Fix DeepSource error: Missing module/function docstring
PY-D0003

Changelist:
- Add docstrings to tests/plotting::
    - test_plain_native
    - test_full_native
    - test_plain_native_stack
    - test_full_native_stack
@lgtm-com
Copy link

lgtm-com bot commented Jun 17, 2021

This pull request introduces 3 alerts when merging f1896c6 into d9dbf03 - view on LGTM.com

new alerts:

  • 2 for Unused local variable
  • 1 for Unused import

@quantum9Innovation
Copy link
Member Author

This pull request introduces 3 alerts when merging f1896c6 into d9dbf03 - view on LGTM.com

new alerts:

  • 2 for Unused local variable
  • 1 for Unused import

Operation massive-plots will be completed after these issues are fixed.
The last issue for unused import can be fixed in a simple commit.
However, the first two have exposed serious bugs with the handling of the compartments parameter in the epi.plots.web module. Additionally, we will need to investigate whether similar bugs can be found in the epi.plots.native module.

quantum9Innovation and others added 3 commits June 19, 2021 13:10
This commit fixes "Decreased legend visibility on `massive-plots`" (#66)
 via a suggestion by @lisphilar.

 Changelist:
 - Fix `epi.plots.native::stacked`

Co-authored-by: Lisphilar <7270139+lisphilar@users.noreply.github.com>
This commit adds a LaTeX installation to the Travis CI install script.
LaTeX is needed for the `SciencePlots` package, which uses it in
epispot's tests. This also (hopefully) fixes the error from the
previous commit on Travis CI.

Changelist:
- Add LaTeX requirements to `.travis.yml::install`

Additional Notes:
Fixes (major):
Fix `0ca85d13b579e624ca5dfff701a7a7c4c62a0d6c`
This commit fixes the issues described in
"Improper handling of `compartments` parameter in `massive-plots`" (#68),
 which also reappear in 2 'unused variable' alerts on LGTM for PR #67.
 These can be seen at
 https://lgtm.com/projects/g/epispot/epispot/rev/pr-4a4c33bcfb0a25433ea10477d7c49b516a6f75d6.
 Additionally, this commit removes all `compartment` parameters where
 they are not necessary because similar functionality is already
 provided by the graphics engine.

Changelist:
- Remove `compartments` from and restructure `epi.plots.native.model()`
- Remove all `compartments` from functions in `epi.plots.web`
- Edit `tests/plotting::*full*` to run tests without `compartments`
specifications

Additional Notes:
Fixes (major):
Fix "Improper handling of `compartments` parameter in `massive-plots`" (#68)
Fix 2 LGTM 'unused variable` alerts in `epi.plots.web` for PR #67
Fix #68, LGTM PR #67 'unused variable' alerts
@lgtm-com
Copy link

lgtm-com bot commented Jun 19, 2021

This pull request introduces 1 alert when merging 3eef7c5 into d9dbf03 - view on LGTM.com

new alerts:

  • 1 for Unused import

This commit fixes the 'unused import alert' in LGTM for PR #67.
This alert can be seen at:
https://lgtm.com/projects/g/epispot/epispot/rev/pr-4fc894482dc65aa247dbd5ef531e8bbd3fd15a7c

Changelist:
- Remove unused import from `epi.plots.native`

Additional Notes:
Fixes (minor):
Fix LGTM 'unused import' alert in `epi.plots.native` for PR #67
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat 🚀 New feature or request high-priority 🔼 This is important nightly 🌙 Nightly builds or releases src Changes to the package source code tests Testing suite updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants