Skip to content

Commit

Permalink
Merge branch 'master' into allow_different_partitions
Browse files Browse the repository at this point in the history
  • Loading branch information
rowleya committed Oct 10, 2024
2 parents f28fbef + de46d12 commit eb560f8
Show file tree
Hide file tree
Showing 36 changed files with 207 additions and 220 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/c_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:
steps:
- name: Install Ubuntu packages
run: sudo apt-get install doxygen gcc-arm-none-eabi --fix-missing
- name: Configure Python 3.8
- name: Configure Python 3.12
# Note: Python is needed for spinn_utilities.make_tools when building
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.8
python-version: 3.12

- name: Checkout
uses: actions/checkout@v4
Expand Down
86 changes: 15 additions & 71 deletions .github/workflows/python_actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,76 +17,20 @@ name: Python Actions
on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9, "3.10", "3.11"]
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Checkout
uses: actions/checkout@v4
- name: Checkout SupportScripts
uses: actions/checkout@v4
with:
repository: SpiNNakerManchester/SupportScripts
path: support
- name: Install pip, etc
uses: ./support/actions/python-tools

- name: Install Spinnaker Dependencies
uses: ./support/actions/install-spinn-deps
with:
repositories: >
call:
uses: SpiNNakerManchester/SupportScripts/.github/workflows/python_checks.yml@main
with:
dependencies: >
SpiNNUtils SpiNNMachine SpiNNMan PACMAN spalloc
SpiNNFrontEndCommon sPyNNaker TestBase
install: true

- name: Install matplotlib
uses: ./support/actions/install-matplotlib

- name: Setup
uses: ./support/actions/run-install

- name: Setup PyNN
uses: ./support/actions/pynn-setup

# Add this when tests are built
- name: Create a spynnaker.cfg
uses: ./support/actions/configure-spynnaker
with:
board-address: spinn-4.cs.man.ac.uk

- name: Test with pytest
uses: ./support/actions/pytest
with:
tests: unittests
coverage: ${{ matrix.python-version == 3.8 }}
cover-packages: ${{ env.CODE_PATHS }}
coveralls-token: ${{ secrets.COVERALLS_REPO_TOKEN }}

- name: Lint with flake8
run: flake8 examples spinn_gym
- name: Lint with pylint
uses: ./support/actions/pylint
with:
package: examples spinn_gym
exitcheck: 39

#- name: Validate XML
# if: matrix.python-version == 3.8
# uses: ./support/actions/validate-xml
# with:
# base-path: examples spinn_gym

- name: Run rat copyright enforcement
if: matrix.python-version == 3.8
uses: ./support/actions/check-copyrights

- name: Validate CITATION.cff
if: matrix.python-version == 3.8
uses: dieghernan/cff-validator@main

install_module: true
pip_installs: pytest
test_directories: unittests
coverage-package: spinn_gym
flake8-packages: examples spinn_gym integration_tests
pylint-packages: examples spinn_gym integration_tests
pylint-disable: R, invalid-name, missing-class-docstring, missing-function-docstring, wrong-spelling-in-comment, wrong-spelling-in-docstring
mypy-packages: examples spinn_gym integration_tests
run_sphinx: false
cfg_file: spynnaker
rat_config_file: rat_gpl3.xml
1 change: 1 addition & 0 deletions .ratexcludes
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
**/SpiNNFrontEndCommon/**
**/sPyNNaker/**
**/sPyNNaker8/**
**/TestBase/**
**/.pylintrc
2 changes: 1 addition & 1 deletion LICENSE_POLICY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See: [here](https://spinnakermanchester.github.io/latest/LicenseAgreement.html#m

For up to date information on Contributors see the graphs/contributors pages on each project.

For example [https://github.com/SpiNNakerManchester/PyNN8Examples/graphs/contributors](https://github.com/SpiNNakerManchester/PyNN8Examples/graphs/contributors)
For example [https://github.com/SpiNNakerManchester/SpiNNGym/graphs/contributors](https://github.com/SpiNNakerManchester/SpiNNGym/graphs/contributors)

[Combined list](https://spinnakermanchester.github.io/latest/LicenseAgreement.html#contributors)

22 changes: 12 additions & 10 deletions examples/breakout/automated.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
# Copyright (c) 2023 The University of Manchester
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# https://www.apache.org/licenses/LICENSE-2.0
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

from threading import Thread
import pyNN.spiNNaker as p

from spinn_gym.games.breakout.visualise_host import (
host_visualiser, start_visualiser)
from spinn_gym.games.breakout.automated_breakout import (
AutomatedBreakout, X_RES, X_SCALE, Y_RES, Y_SCALE)
from threading import Thread

# ---------------------------------------------------------------------
# Initialise Simulation and Parameters
Expand Down
6 changes: 3 additions & 3 deletions examples/breakout/breakout_simple_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

# non-SpiNNaker imports
import matplotlib.pyplot as plt
import pyNN.spiNNaker as p
from pyNN.utility.plotting import Figure, Panel

# SpiNNaker imports
from spinn_gym.games.breakout.breakout_sim import get_scores
from spinn_gym.games.breakout.random_breakout import RandomBreakout
import pyNN.spiNNaker as p

breakout = RandomBreakout()

Expand Down Expand Up @@ -58,14 +58,14 @@
xlim=(0, runtime)
),
title="Simple Breakout Example",
annotations="Simulated with {}".format(p.name())
annotations=f"Simulated with {p.name()}"
)

plt.show()

scores = get_scores(breakout_pop=breakout.breakout_pop)

print("Scores: {}".format(scores))
print(f"Scores: {scores}")

# End simulation
p.end()
Expand Down
4 changes: 0 additions & 4 deletions examples/breakout/spynnaker.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
[Mapping]

# Reduce the default time (1000s) to wait for compression for breakout

router_table_compression_with_bit_field_iteration_time = 1

# Breakout doesn't implement delays, so avoid DelaySupportAdder
delay_support_adder = None
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def connect_to_arms(pre_pop, from_list, arms, r_type, plastic, stdp_model):
# print "out:", conn[1]
# if conn[1] == 2:
# print '\nit is possible\n'
for j in range(len(arms)):
for j, arm in enumerate(arms):
if len(arm_conn_list[j]) != 0:
if plastic:
p.Projection(pre_pop, arms[j],
p.Projection(pre_pop, arm,
p.FromListConnector(arm_conn_list[j]),
receptor_type=r_type, synapse_type=stdp_model)
else:
p.Projection(pre_pop, arms[j],
p.Projection(pre_pop, arm,
p.FromListConnector(arm_conn_list[j]),
receptor_type=r_type)

Expand Down Expand Up @@ -86,8 +86,8 @@ def connect_to_arms(pre_pop, from_list, arms, r_type, plastic, stdp_model):
# p.Projection(pendulum, null_pops[i],
# p.FromListConnector([[i, 0, weight, 1]]))

arm_collection = []
input_spikes = []
# arm_collection = []
# input_spikes = []
rates = [0, 0]
# rates = [0, 20]
# rates = [0, 10]
Expand Down Expand Up @@ -152,8 +152,7 @@ def connect_to_arms(pre_pop, from_list, arms, r_type, plastic, stdp_model):
i = 0
print("cart | angle")
while i < len(scores[0]):
print("{}\t{}\t{}".format(
scores[0][i], scores[0][i+1], scores[0][i+2]))
print(f"{scores[0][i]}\t{scores[0][i+1]}\t{scores[0][i+2]}")
i += 3

# spikes = []
Expand Down Expand Up @@ -186,7 +185,7 @@ def connect_to_arms(pre_pop, from_list, arms, r_type, plastic, stdp_model):
spikes_o2 = output_pop2.get_data('spikes').segments[0].spiketrains
v_o2 = output_pop2.get_data('v').segments[0].filter(name='v')[0]
g_o2 = output_pop2.get_data('gsyn_exc').segments[0].filter(name='gsyn_exc')[0]
plt.figure("spikes out {}".format(label))
plt.figure(f"spikes out {label}")
Figure(
Panel(spikes_n, xlabel="Time (ms)", ylabel="nID", xticks=True),
Panel(v_n, ylabel="Membrane potential (mV)", yticks=True),
Expand Down
6 changes: 3 additions & 3 deletions examples/inverted_pendulum/inverted_pendulum_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
# p.Projection(pendulum, null_pops[i],
# p.FromListConnector([[i, 0, weight, 1]]))

arm_collection = []
# arm_collection = []
# input_spikes = []
rate = 5
print('rate = ', rate)
Expand Down Expand Up @@ -129,7 +129,7 @@
i = 0
print("cart \t\t|\t\t angle")
while i < len(scores[0]):
print("{:8}\t{:8}".format(scores[0][i], scores[0][i+1]))
print(f"{scores[0][i]:8}\t{scores[0][i+1]:8}")
i += 2

spikes_n = null_pop.get_data('spikes').segments[0].spiketrains
Expand All @@ -140,7 +140,7 @@
spikes_o2 = output_pop2.get_data('spikes').segments[0].spiketrains
v_o2 = output_pop2.get_data('v').segments[0].filter(name='v')[0]
g_o2 = output_pop2.get_data('gsyn_exc').segments[0].filter(name='gsyn_exc')[0]
plt.figure("spikes out {}".format(label))
plt.figure(f"spikes out {label}")
Figure(
Panel(spikes_n, xlabel="Time (ms)", ylabel="nID", xticks=True),
Panel(v_n, ylabel="Membrane potential (mV)", yticks=True),
Expand Down
8 changes: 4 additions & 4 deletions examples/logic/logic_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pyNN.spiNNaker as p
import spinn_gym as gym

from pyNN.utility.plotting import Figure, Panel
import matplotlib.pyplot as plt
import numpy as np
import pyNN.spiNNaker as p
from pyNN.utility.plotting import Figure, Panel

import spinn_gym as gym


p.setup(timestep=1.0)
Expand Down
5 changes: 3 additions & 2 deletions examples/multi_arm_bandit/bandit_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pyNN.spiNNaker as p
import spinn_gym as gym

from pyNN.utility.plotting import Figure, Panel
import matplotlib.pyplot as plt
import numpy as np
import pyNN.spiNNaker as p

import spinn_gym as gym


p.setup(timestep=1.0)
Expand Down
11 changes: 5 additions & 6 deletions examples/store_recall/store_recall_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

import pyNN.spiNNaker as p
import spinn_gym as gym

from pyNN.utility.plotting import Figure, Panel
import matplotlib.pyplot as plt
import numpy as np
import pyNN.spiNNaker as p
from pyNN.utility.plotting import Figure, Panel

import spinn_gym as gym


rate_on = 10
Expand Down Expand Up @@ -72,8 +72,7 @@
i = 0
print("score 0 \t\t|\t score 1 \t|\t\t trials")
while i < len(scores):
print("{:8}\t\t{:8}\t\t{:8}".format(
scores[i][0], scores[i+1][0], scores[i+2][0]))
print(f"{scores[i][0]:8}\t\t{scores[i + 1][0]:8}\t\t{scores[i + 2][0]:8}")
i += 3

accuracy = float(scores[len(scores)-2][0]+scores[len(scores)-3][0]) / float(
Expand Down
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta:"
build-backend = "setuptools.build_meta:"

[[tool.mypy.overrides]]
module = ["pyNN.*", "quantities", "neo", "scipy", "scipy.*", "lazyarray", "IPython", "matplotlib.*"]
ignore_missing_imports = true
8 changes: 4 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,21 @@ classifiers =
Operating System :: Microsoft :: Windows
Operating System :: MacOS
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
Programming Language :: Python :: 3.12
maintainer="SpiNNakerTeam"
maintainer_email="[email protected]"

[options]
python_requires = >=3.7, <4
python_requires = >=3.8, <4
packages = find:
zip_safe = True
include_package_data = True
install_requires =
sPyNNaker == 1!7.1.1
sPyNNaker == 1!7.3.1
opencv-python

[options.packages.find]
Expand All @@ -60,6 +60,6 @@ include =

[options.extras_require]
test =
SpiNNakerTestBase == 1!7.1.1
SpiNNakerTestBase == 1!7.3.1
# pytest will be brought in by pytest-cov
pytest-cov
Loading

0 comments on commit eb560f8

Please sign in to comment.