Skip to content

Commit

Permalink
Modifications for docker test
Browse files Browse the repository at this point in the history
  • Loading branch information
blankjul committed Nov 18, 2018
1 parent 39538c9 commit 6f0b2c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pymoo/operators/sampling/bin_random_sampling.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

from pymoo.model.sampling import Sampling
from pymoo.rand import random

Expand All @@ -12,6 +14,6 @@ def sample(self, problem, pop, n_samples, **kwargs):
m = problem.n_var

val = random.random((n_samples, m))
val = (val < 0.5)
val = (val < 0.5).astype(np.bool)

return pop.new("X", val)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def get_extension_modules():
license='Apache License 2.0',
keywords="optimization",
packages=setuptools.find_packages(exclude=['tests', 'docs', 'experiments']),
install_requires=['pymop==0.2.3', 'numpy>=1.15', 'scipy>=1.1', 'matplotlib>=3'],
install_requires=['pymop==0.2.3', 'numpy>=1.15', 'scipy>=1.1', 'matplotlib==3.0.2'],
include_package_data=True,
platforms='any'
)
Expand Down
13 changes: 10 additions & 3 deletions tests/test_usage.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
import os
import unittest


class UsageTest(unittest.TestCase):

def test(self):

USAGE_DIR = os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pymoo", "usage")
#USAGE_DIR = os.path.dirname(os.path.realpath(__file__))
# USAGE_DIR = os.path.dirname(os.path.realpath(__file__))

for fname in os.listdir(USAGE_DIR):

if fname != "nsga2.py":
continue

if fname == "test_usage.py":
continue

Expand All @@ -18,8 +22,11 @@ def test(self):
with open(os.path.join(USAGE_DIR, fname)) as f:
s = f.read()

no_plots = "from matplotlib import pyplot as plt\n" \
"plt.ioff()\n"
no_plots = "import matplotlib\n" \
"from matplotlib import pyplot as plt\n" \
"plt.ioff()\n" \
"matplotlib.use('Agg')\n"

s = no_plots + s

try:
Expand Down

0 comments on commit 6f0b2c2

Please sign in to comment.