Skip to content

Commit

Permalink
Merge pull request #41 from aarongarrett/development
Browse files Browse the repository at this point in the history
Development -> Master for next release
  • Loading branch information
sanjayankur31 authored Oct 24, 2024
2 parents 0caf899 + 32dde12 commit 1d0089c
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 44 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
fail-fast: false

steps:
Expand All @@ -41,10 +41,8 @@ jobs:
- name: Run example tests
run: |
pip install -r ./requirements_dev.txt
pip install .
# uses pp, which is not available for py3
# python3 ./tests/evaluator_tests.py
pip install .[dev]
python3 ./tests/evaluator_tests.py
python3 ./tests/example_tests.py
python3 ./tests/observer_tests.py
# intermittently fails
Expand Down
7 changes: 4 additions & 3 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sphinx:

python:
install:
- method: pip
path: .
- requirements: requirements_dev.txt
- method: pip
path: .
extra_requirements:
- doc
9 changes: 6 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ Requirements
------------

* Requires Python 3+.
* Numpy and Pylab are required for several functions in ``ec.observers``.
* Pylab and Matplotlib are required for several functions in ``ec.analysis``.
* Parallel Python (pp) is required if ``ec.evaluators.parallel_evaluation_pp`` is used.
* Numpy and Matplotlib are required for several functions in ``ec.observers``.
* Matplotlib is required for several functions in ``ec.analysis``.
* Parallel Python (ppft) is required if ``ec.evaluators.parallel_evaluation_pp`` is used.

You can use the `all` extra to install inspyred with all the extra dependencies::

pip install inspyred[all]

License
-------
Expand Down
28 changes: 14 additions & 14 deletions examples/advanced/parallel_evaluation_pp_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import math

# Define an additional "necessary" function for the evaluator
# to see how it must be handled when using pp.
# to see how it must be handled when using ppft.
def my_squaring_function(x):
return x**2

Expand All @@ -15,36 +15,36 @@ def generate_rastrigin(random, args):
def evaluate_rastrigin(candidates, args):
fitness = []
for cs in candidates:
fit = 10 * len(cs) + sum([(my_squaring_function(x - 1) -
10 * math.cos(2 * math.pi * (x - 1)))
fit = 10 * len(cs) + sum([(my_squaring_function(x - 1) -
10 * math.cos(2 * math.pi * (x - 1)))
for x in cs])
fitness.append(fit)
return fitness
def main(prng=None, display=False):

def main(prng=None, display=False):
if prng is None:
prng = Random()
prng.seed(time())
prng.seed(time())

ea = inspyred.ec.DEA(prng)
if display:
ea.observer = inspyred.ec.observers.stats_observer
ea.observer = inspyred.ec.observers.stats_observer
ea.terminator = inspyred.ec.terminators.evaluation_termination
final_pop = ea.evolve(generator=generate_rastrigin,
final_pop = ea.evolve(generator=generate_rastrigin,
evaluator=inspyred.ec.evaluators.parallel_evaluation_pp,
pp_evaluator=evaluate_rastrigin,
pp_evaluator=evaluate_rastrigin,
pp_dependencies=(my_squaring_function,),
pp_modules=("math",),
pop_size=8,
pop_size=8,
bounder=inspyred.ec.Bounder(-5.12, 5.12),
maximize=False,
max_evaluations=256,
num_inputs=3)

if display:
best = max(final_pop)
best = max(final_pop)
print('Best Solution: \n{0}'.format(str(best)))
return ea

if __name__ == '__main__':
main(display=True)
2 changes: 1 addition & 1 deletion inspyred/ec/evaluators.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def parallel_evaluation_pp(candidates, args):
documentation for `Parallel Python <http://www.parallelpython.com>`_.
"""
import pp
import ppft as pp
logger = args['_ec'].logger

try:
Expand Down
8 changes: 0 additions & 8 deletions requirements_dev.txt

This file was deleted.

20 changes: 19 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ classifiers =
License :: OSI Approved :: MIT License
Natural Language :: English
Operating System :: OS Independent
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Topic :: Scientific/Engineering :: Artificial Intelligence

[options]
Expand All @@ -32,6 +33,23 @@ packages = find:
where = .
include = inspyred*

[options.extras_require]
all =
ppft[dill]
matplotlib

doc =
Sphinx

dev =
inspyred[all]
inspyred[doc]
wheel
flake8
tox
coverage
pytest

[options.entry_points]
console_scripts =
inspyred = inspyred.cli:main
Expand Down
15 changes: 6 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py37, py38, py39, py310, py311
envlist = py38, py39, py310, py311, py312, py313
; , flake8

[testenv:flake8]
Expand All @@ -10,22 +10,19 @@ commands=flake8 inspyred
[testenv]
setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/inspyred
deps =
-r{toxinidir}/requirements_dev.txt

extras = dev

commands =
pip install -U pip
py.test --basetemp={envtmpdir}


; If you want to make tox run the tests with the same versions, create a
; requirements.txt with the pinned versions and uncomment the following lines:
; deps =
; -r{toxinidir}/requirements.txt

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
3.11: py311
3.12: py312
3.13: py313

0 comments on commit 1d0089c

Please sign in to comment.