Skip to content

Commit

Permalink
Add test_plot_environment dependencies (#30)
Browse files Browse the repository at this point in the history
This commit aims to resolve all dependency issues in the
matplotlib.animation.FuncAnimation when running the
test_plot_environment script.

A toolchain called libav-tools is installed in travis-ci,
and an if-else script checks if display is found. If not,
then it uses the default 'Agg' backend.

Moreover, the mock==2.0.0 package is also used during
tests as shown in setup.py.

Author: ljvmiranda921
E-mail: ljvmiranda@gmail.com
  • Loading branch information
ljvmiranda921 committed Sep 24, 2017
1 parent 7891f9a commit f410600
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ deploy:
repo: ljvmiranda921/pyswarms
tags: true
install:
- "pip install -U tox-travis"
- sudo apt-get update
- sudo apt-get install libav-tools
- pip install -U tox-travis
language: python
python:
- 3.6
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'scipy>=0.17.0',
'numpy>=1.13.0',
'matplotlib>=1.3.1',
'mock==2.0.0',
]

setup_requirements = [
Expand All @@ -29,6 +30,7 @@
'scipy>=0.17.0',
'numpy>=1.13.0',
'matplotlib>=1.3.1',
'mock==2.0.0',
]

setup(
Expand Down
Empty file.
6 changes: 6 additions & 0 deletions tests/utils/environments/test_plot_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,18 @@
from __future__ import print_function

# Import modules
import os
import unittest
import numpy as np
from mock import Mock
import matplotlib as mpl
from matplotlib.axes._subplots import SubplotBase
from matplotlib.animation import FuncAnimation

# Fix for display
if os.environ.get('DISPLAY','') == '':
mpl.use('Agg')

# Import from package
from pyswarms.utils.environments import PlotEnvironment
from pyswarms.single import GlobalBestPSO
Expand Down

0 comments on commit f410600

Please sign in to comment.