Skip to content

Commit

Permalink
Merge pull request #25 from NeuralEnsemble/development
Browse files Browse the repository at this point in the history
Latest dev -> master - removed py2 support
  • Loading branch information
pgleeson committed May 12, 2023
2 parents 5342155 + 140040e commit 1a96789
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ doc/_build

*.egg-info/
dist/
arm64
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014, Neurotune authors and contributors
Copyright (c) 2023, Neurotune authors and contributors
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
Binary file modified examples/example_2/surrogate_vs_candidates.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion neurotune/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.5"
__version__ = "0.2.6"
59 changes: 33 additions & 26 deletions neurotune/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
"""

from __future__ import annotations
import math
import numpy as np

try:
from typing import List, Dict, Bool, Union
import typing
except ImportError:
pass

Expand All @@ -17,16 +19,15 @@


def plot_generation_evolution(
sim_var_names,
target_values={},
individuals_file_name="../data/ga_individuals.csv",
show_plot_already=True,
save_to_file=False,
save_to_file_scatter=False,
save_to_file_hist=False,
title_prefix="",
):
# type: (List, Dict, str, Bool, Union[Bool, str], Union[Bool, str], Union[Bool, str], str) -> None
sim_var_names: list,
target_values: dict = {},
individuals_file_name: str = "../data/ga_individuals.csv",
show_plot_already: bool = True,
save_to_file: typing.Union[bool, str] = False,
save_to_file_scatter: bool = False,
save_to_file_hist: bool = False,
title_prefix: str = "",
) -> None:
"""Plot generation evolution related graphs.
:param sim_var_names: names of variables
Expand Down Expand Up @@ -145,15 +146,19 @@ def plot_generation_evolution(
0.40,
0.01,
"Generation (%i individuals, offset slightly; larger circle => fitter)"
% (population_total)
% (population_total),
)
for i in range(val_num):

var_name = sim_var_names[i]

pyplot.subplot(nrows, ncols, i + 1, xlabel="Generation",
ylabel="{} ({})".format(var_name.split('/')[-2],
var_name.split('/')[-1]))
pyplot.subplot(
nrows,
ncols,
i + 1,
xlabel="Generation",
ylabel="{} ({})".format(var_name.split("/")[-2], var_name.split("/")[-1]),
)
pyplot.title(var_name)
if target_values is not None and sim_var_names[i] in target_values:
value = target_values[sim_var_names[i]]
Expand All @@ -164,7 +169,7 @@ def plot_generation_evolution(
pyplot.scatter(generations_offset, vals[i], s=sizes[i], c=colours[i], alpha=0.4)

if save_to_file_scatter:
pyplot.savefig(save_to_file_scatter, dpi=300, bbox_inches='tight')
pyplot.savefig(save_to_file_scatter, dpi=300, bbox_inches="tight")

fig2 = pyplot.figure()
pyplot.get_current_fig_manager().set_window_title(
Expand All @@ -183,26 +188,28 @@ def plot_generation_evolution(
0.40,
0.01,
"Generation (%i individuals, offset slightly; larger circle => fitter)"
% (population_total)
% (population_total),
)

if save_to_file:
pyplot.savefig(save_to_file, dpi=300, bbox_inches='tight')
pyplot.savefig(save_to_file, dpi=300, bbox_inches="tight")

fig3 = pyplot.figure()
pyplot.get_current_fig_manager().set_window_title(
title_prefix + " Histograms over %i generations of %s" %
(generations_total, sim_var_names)
title_prefix
+ " Histograms over %i generations of %s" % (generations_total, sim_var_names)
)

pyplot.subplots_adjust(hspace=0.4)
for i in range(val_num):

var_name = (sim_var_names[i])
ax = pyplot.subplot(nrows, ncols, i + 1,
xlabel="{} ({})".format(var_name.split('/')[-2],
var_name.split('/')[-1])
)
var_name = sim_var_names[i]
ax = pyplot.subplot(
nrows,
ncols,
i + 1,
xlabel="{} ({})".format(var_name.split("/")[-2], var_name.split("/")[-1]),
)
pyplot.title(var_name)

for generation in generations:
Expand All @@ -217,7 +224,7 @@ def plot_generation_evolution(
ax.plot(xs, hist, color=(shade, shade, shade))

if save_to_file_hist:
pyplot.savefig(save_to_file_hist, dpi=300, bbox_inches='tight')
pyplot.savefig(save_to_file_hist, dpi=300, bbox_inches="tight")

if show_plot_already:
pyplot.show()
Expand Down
7 changes: 6 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,17 @@
if line.startswith("__version__"):
version = line.split("=")[1].strip()[1:-1]

long_description = open("README.md").read()

setup(
name="neurotune",
version=version,
packages=["neurotune"],
author="Michael Vella, Padraig Gleeson",
author_email="mv333@cam.ac.uk, p.gleeson@gmail.com",
description="A Python library for optimising neuronal models",
long_description=long_description,
long_description_content_type="text/markdown",
license="BSD",
install_requires=["scipy", "inspyred", "pyelectro"],
url="https://github.com/NeuralEnsemble/neurotune",
Expand All @@ -22,11 +26,12 @@
"License :: OSI Approved :: BSD License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"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",
"Topic :: Scientific/Engineering",
],
)
4 changes: 3 additions & 1 deletion test.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
set -e

rm -rf examples/*/x86_64/
pip install .

rm -rf examples/*/x86_64/ examples/*/arm64

#### Requires NEURON
cd examples/example_1
Expand Down

0 comments on commit 1a96789

Please sign in to comment.