From 934464f992805ca8d444c9349f5e63c45d09dee9 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 07:22:46 +0100 Subject: [PATCH 01/23] use SupportScripts python_checks --- .github/workflows/python_actions.yml | 75 ++++++---------------------- 1 file changed, 15 insertions(+), 60 deletions(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index dfccde6..6ed4802 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -17,66 +17,21 @@ name: Python Actions on: [push] -jobs: - build: - runs-on: ubuntu-latest - strategy: - matrix: - python-version: [3.8, 3.9, "3.10", "3.11", "3.12"] - - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Checkout SupportScripts - uses: actions/checkout@v4 - with: - repository: SpiNNakerManchester/SupportScripts - path: support - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 - with: - python-version: ${{ matrix.python-version }} - - name: Install pip, etc - uses: ./support/actions/python-tools - - name: Install Spinnaker Dependencies - uses: ./support/actions/install-spinn-deps - with: - repositories: > +jobs: + call: + uses: SpiNNakerManchester/SupportScripts/.github/workflows/python_checks.yml@main + with: + dependencies: > SpiNNUtils SpiNNMachine SpiNNMan PACMAN spalloc SpiNNFrontEndCommon sPyNNaker - install: true - - - name: Setup PyNN - uses: ./support/actions/pynn-setup - - name: Install matplotlib - uses: ./support/actions/install-matplotlib - - - name: Lint with flake8 - run: flake8 examples balanced_random learning sudoku synfire - - - name: Lint with pylint - uses: ./support/actions/pylint - with: - package: examples balanced_random learning sudoku synfire - exitcheck: 39 - - validate: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Checkout SupportScripts - uses: actions/checkout@v4 - with: - repository: SpiNNakerManchester/SupportScripts - path: support - - name: Run rat copyright enforcement - if: matrix.python-version == 3.12 - uses: ./support/actions/check-copyrights - with: - config_file: rat_asl20.xml - - - name: Validate CITATION.cff - if: matrix.python-version == 3.12 - uses: dieghernan/cff-validator@main + ubuntu_packages: graphviz + test_directories: unittests + coverage-package: mcmc + flake8-packages: examples balanced_random learning sudoku synfire + pylint-packages: examples balanced_random learning sudoku synfire + pylint_exitcheck: 39 + # Examples are not types to keep them easier to read + mypy-packages: + check_prereleases: false + run_sphinx: false From 7a740219a6f71e6fc169b94c7021cd028031dcce Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 07:50:59 +0100 Subject: [PATCH 02/23] don't install --- .github/workflows/python_actions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 6ed4802..5bf00fc 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -25,13 +25,13 @@ jobs: dependencies: > SpiNNUtils SpiNNMachine SpiNNMan PACMAN spalloc SpiNNFrontEndCommon sPyNNaker + install_module: false ubuntu_packages: graphviz test_directories: unittests - coverage-package: mcmc + coverage-package: flake8-packages: examples balanced_random learning sudoku synfire pylint-packages: examples balanced_random learning sudoku synfire pylint_exitcheck: 39 # Examples are not types to keep them easier to read mypy-packages: - check_prereleases: false run_sphinx: false From 7d6d5d60e2dfe3f5755bc59354a8ff2017858d1a Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 08:14:52 +0100 Subject: [PATCH 03/23] does setup work --- .github/workflows/python_actions.yml | 1 - requirements-test.txt | 17 --------- setup.cfg | 56 ++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+), 18 deletions(-) delete mode 100644 requirements-test.txt create mode 100644 setup.cfg diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 5bf00fc..69f0f43 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -25,7 +25,6 @@ jobs: dependencies: > SpiNNUtils SpiNNMachine SpiNNMan PACMAN spalloc SpiNNFrontEndCommon sPyNNaker - install_module: false ubuntu_packages: graphviz test_directories: unittests coverage-package: diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 856e7df..0000000 --- a/requirements-test.txt +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2017 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 -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# 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. - -# pytest will be brought in by pytest-cov -pytest-cov -testfixtures diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..e8f6ad7 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,56 @@ +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + +[metadata] +name = PyNNExamples +description = Example PyNN Scripts on the SpiNNaker platform +long_description = file: README.md +long_description_content_type = text/markdown +url = https://github.com/SpiNNakerManchester/PyNNExamples +license = Apache-2.0 +classifiers = + Development Status :: 5 - Production/Stable + Intended Audience :: Developers + Intended Audience :: Science/Research + License :: OSI Approved :: Apache Software License + Natural Language :: English + Operating System :: POSIX :: Linux + Operating System :: Microsoft :: Windows + Operating System :: MacOS + Programming Language :: Python :: 3 + 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 = spinnakerusers@googlegroups.com +keywords = + spinnaker + pynn + +[options] +python_requires = >=3.8, <4 +packages = find: +zip_safe = True +include_package_data = True +install_requires = + sPyNNaker + +[options.extras_require] +test = + # pytest will be brought in by pytest-cov + pytest-cov + testfixtures + From b32731b034667e7a9f83e9d0f2eeab267f03c6e5 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 08:15:07 +0100 Subject: [PATCH 04/23] remove 0.9 reference --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 97f75b2..c35eddb 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ [![Build Status](https://travis-ci.org/SpiNNakerManchester/PyNN8Examples.svg?branch=master)](https://travis-ci.org/SpiNNakerManchester/PyNN8Examples) -Examples for PyNN 0.9 -===================== +Examples for PyNN +================= -This repository holds miscellaneous examples of using sPyNNaker for PyNN 0.9 +This repository holds miscellaneous examples of using sPyNNaker for PyNN See Also -------- From 5975e67df19a42c868586670a429033e35cfbf2d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 09:47:19 +0100 Subject: [PATCH 05/23] pip install pytest --- .github/workflows/python_actions.yml | 2 + setup.cfg | 56 ---------------------------- 2 files changed, 2 insertions(+), 56 deletions(-) delete mode 100644 setup.cfg diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 69f0f43..73359b5 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -25,6 +25,8 @@ jobs: dependencies: > SpiNNUtils SpiNNMachine SpiNNMan PACMAN spalloc SpiNNFrontEndCommon sPyNNaker + install_module: false + pip_installs: pytest ubuntu_packages: graphviz test_directories: unittests coverage-package: diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index e8f6ad7..0000000 --- a/setup.cfg +++ /dev/null @@ -1,56 +0,0 @@ -# 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 -# -# https://www.apache.org/licenses/LICENSE-2.0 -# -# 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. - -[metadata] -name = PyNNExamples -description = Example PyNN Scripts on the SpiNNaker platform -long_description = file: README.md -long_description_content_type = text/markdown -url = https://github.com/SpiNNakerManchester/PyNNExamples -license = Apache-2.0 -classifiers = - Development Status :: 5 - Production/Stable - Intended Audience :: Developers - Intended Audience :: Science/Research - License :: OSI Approved :: Apache Software License - Natural Language :: English - Operating System :: POSIX :: Linux - Operating System :: Microsoft :: Windows - Operating System :: MacOS - Programming Language :: Python :: 3 - 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 = spinnakerusers@googlegroups.com -keywords = - spinnaker - pynn - -[options] -python_requires = >=3.8, <4 -packages = find: -zip_safe = True -include_package_data = True -install_requires = - sPyNNaker - -[options.extras_require] -test = - # pytest will be brought in by pytest-cov - pytest-cov - testfixtures - From bb71fcedb661830a528be3d6e19f6552e13c6a1e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 10:22:41 +0100 Subject: [PATCH 06/23] copyrights --- balanced_random/split/balanced_random_split.py | 14 ++++++++++++++ learning/split/stdp_split.py | 14 ++++++++++++++ learning/split/struct_pl_split.py | 14 ++++++++++++++ learning/split/struct_pl_stdp_split.py | 14 ++++++++++++++ learning/struct_pl.py | 14 ++++++++++++++ learning/struct_pl_stdp.py | 14 ++++++++++++++ pendulum/pendulum_follow_c_vis.py | 14 ++++++++++++++ pendulum/pendulum_follow_python_vis.py | 15 +++++++++++++++ pendulum/spike_filter.py | 14 ++++++++++++++ spiNNaker_start/spinnaker_start.py | 15 +++++++++++++++ sudoku/utils.py | 14 ++++++++++++++ 11 files changed, 156 insertions(+) diff --git a/balanced_random/split/balanced_random_split.py b/balanced_random/split/balanced_random_split.py index 94a7902..0107c2b 100755 --- a/balanced_random/split/balanced_random_split.py +++ b/balanced_random/split/balanced_random_split.py @@ -1,3 +1,17 @@ +# Copyright (c) 2021 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import pylab import numpy from pyNN.random import RandomDistribution diff --git a/learning/split/stdp_split.py b/learning/split/stdp_split.py index fc9e531..b8d95c4 100755 --- a/learning/split/stdp_split.py +++ b/learning/split/stdp_split.py @@ -1,3 +1,17 @@ +# Copyright (c) 2021 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import pyNN.spiNNaker as sim diff --git a/learning/split/struct_pl_split.py b/learning/split/struct_pl_split.py index 0ea0301..6e30171 100755 --- a/learning/split/struct_pl_split.py +++ b/learning/split/struct_pl_split.py @@ -1,3 +1,17 @@ +# Copyright (c) 2021 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import matplotlib.pyplot as plt import numpy import pyNN.utility.plotting as plot diff --git a/learning/split/struct_pl_stdp_split.py b/learning/split/struct_pl_stdp_split.py index 2c05567..5495cf4 100755 --- a/learning/split/struct_pl_stdp_split.py +++ b/learning/split/struct_pl_stdp_split.py @@ -1,3 +1,17 @@ +# Copyright (c) 2021 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import matplotlib.pyplot as plt import numpy import pyNN.spiNNaker as sim diff --git a/learning/struct_pl.py b/learning/struct_pl.py index d2f09af..efc4c06 100755 --- a/learning/struct_pl.py +++ b/learning/struct_pl.py @@ -1,3 +1,17 @@ +# Copyright (c) 2021 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import numpy diff --git a/learning/struct_pl_stdp.py b/learning/struct_pl_stdp.py index df6194e..202acc1 100755 --- a/learning/struct_pl_stdp.py +++ b/learning/struct_pl_stdp.py @@ -1,3 +1,17 @@ +# Copyright (c) 2021 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import numpy diff --git a/pendulum/pendulum_follow_c_vis.py b/pendulum/pendulum_follow_c_vis.py index 6fb8ca6..7257764 100644 --- a/pendulum/pendulum_follow_c_vis.py +++ b/pendulum/pendulum_follow_c_vis.py @@ -1,3 +1,17 @@ +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import math import os import re diff --git a/pendulum/pendulum_follow_python_vis.py b/pendulum/pendulum_follow_python_vis.py index 8c08271..6174e12 100644 --- a/pendulum/pendulum_follow_python_vis.py +++ b/pendulum/pendulum_follow_python_vis.py @@ -1,3 +1,18 @@ +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + + import math from time import time, sleep from functools import partial diff --git a/pendulum/spike_filter.py b/pendulum/spike_filter.py index ea2c757..0f0e616 100644 --- a/pendulum/spike_filter.py +++ b/pendulum/spike_filter.py @@ -1,3 +1,17 @@ +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import numpy import math from time import time, sleep diff --git a/spiNNaker_start/spinnaker_start.py b/spiNNaker_start/spinnaker_start.py index 7a8c994..7bc3008 100644 --- a/spiNNaker_start/spinnaker_start.py +++ b/spiNNaker_start/spinnaker_start.py @@ -1,3 +1,18 @@ +# Copyright (c) 2018 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + + from __future__ import print_function from six import iteritems from threading import Thread, RLock, Condition diff --git a/sudoku/utils.py b/sudoku/utils.py index bb1bf97..7cefe85 100644 --- a/sudoku/utils.py +++ b/sudoku/utils.py @@ -1,3 +1,17 @@ +# Copyright (c) 2018 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + puzzles = list() puzzles.append( # Diabolical problem: From d603527f98ea8a4541eceb8fcd4ef1e9f15a0951 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 10:58:15 +0100 Subject: [PATCH 07/23] standard pylint exit checks --- .github/workflows/python_actions.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index 73359b5..fc479ca 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -32,7 +32,6 @@ jobs: coverage-package: flake8-packages: examples balanced_random learning sudoku synfire pylint-packages: examples balanced_random learning sudoku synfire - pylint_exitcheck: 39 # Examples are not types to keep them easier to read mypy-packages: run_sphinx: false From 7a91b32fa127f832bac82870940535e83a9fe616 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 10:59:01 +0100 Subject: [PATCH 08/23] copyright --- sudoku/set_numbers.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sudoku/set_numbers.py b/sudoku/set_numbers.py index fcbf526..7b22e41 100644 --- a/sudoku/set_numbers.py +++ b/sudoku/set_numbers.py @@ -1,3 +1,17 @@ +# Copyright (c) 2018 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# 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. + import tkinter as tk import tkinter.font as tkFont import sys From 0acc0674a63fadc52ca7fd3eddeb82a9d9d23ff4 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 12:19:21 +0100 Subject: [PATCH 09/23] pylint-disable: R, wrong-spelling-in-comment --- .github/workflows/python_actions.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index fc479ca..d71ab55 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -32,6 +32,7 @@ jobs: coverage-package: flake8-packages: examples balanced_random learning sudoku synfire pylint-packages: examples balanced_random learning sudoku synfire - # Examples are not types to keep them easier to read + pylint-disable: R, wrong-spelling-in-comment + # Examples are not typed to keep them easier to read mypy-packages: run_sphinx: false From 0b7dfee43d162d809ecacfe516e012a3960793fb Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 13:01:57 +0100 Subject: [PATCH 10/23] wrong-spelling-in-docstring --- .github/workflows/python_actions.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/python_actions.yml b/.github/workflows/python_actions.yml index d71ab55..c5cc10d 100644 --- a/.github/workflows/python_actions.yml +++ b/.github/workflows/python_actions.yml @@ -32,7 +32,9 @@ jobs: coverage-package: flake8-packages: examples balanced_random learning sudoku synfire pylint-packages: examples balanced_random learning sudoku synfire - pylint-disable: R, wrong-spelling-in-comment + # invalid-name because scripts have values pylint considers constants + # wrong-spelling-in-docstring due to param names ect + pylint-disable: R, wrong-spelling-in-docstring, invalid-name # Examples are not typed to keep them easier to read mypy-packages: run_sphinx: false From b3f52e75d3f6b217649c88a1beaf6b52703263ae Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 13:24:20 +0100 Subject: [PATCH 11/23] pylit fixes --- .../stdp_example_izk_cond.py | 2 +- examples/if_curr_alpha.py | 2 +- examples/spike_time_compare.py | 2 +- examples/stdp_example.py | 16 ++++++++-------- examples/stdp_example_cond.py | 6 +++--- examples/stdp_example_get_plastic_params.py | 2 +- examples/stdp_example_izk.py | 2 +- examples/synfire_izk_curr_exp.py | 2 +- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/examples/extra_models_examples/stdp_example_izk_cond.py b/examples/extra_models_examples/stdp_example_izk_cond.py index c2f4672..9c6faf8 100644 --- a/examples/extra_models_examples/stdp_example_izk_cond.py +++ b/examples/extra_models_examples/stdp_example_izk_cond.py @@ -24,7 +24,7 @@ Reproduces a classical plasticity experiment of plasticity induction by pre/post synaptic pairing specifically : - * At the begining of the simulation, "n_stim_test" external stimulations of + * At the beginning of the simulation, "n_stim_test" external stimulations of the "pre_pop" (presynaptic) population do not trigger activity in the "post_pop" (postsynaptic) population. diff --git a/examples/if_curr_alpha.py b/examples/if_curr_alpha.py index 7ef3e20..bc8259f 100644 --- a/examples/if_curr_alpha.py +++ b/examples/if_curr_alpha.py @@ -60,7 +60,7 @@ data_labels=[populations[0].label], yticks=True, xlim=(0, runtime)), title=title, - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() p.end() diff --git a/examples/spike_time_compare.py b/examples/spike_time_compare.py index 56c583a..685da63 100644 --- a/examples/spike_time_compare.py +++ b/examples/spike_time_compare.py @@ -69,6 +69,6 @@ # plot spikes (or in this case spike) plot.Panel(spikes, yticks=True, markersize=5, xlim=(0, simtime)), title="Simple Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/stdp_example.py b/examples/stdp_example.py index 89318ab..3527b44 100644 --- a/examples/stdp_example.py +++ b/examples/stdp_example.py @@ -18,7 +18,7 @@ Reproduces a classical plasticity experiment of plasticity induction by pre/post synaptic pairing specifically : - * At the begining of the simulation, "n_stim_test" external stimulations of + * At the beginning of the simulation, "n_stim_test" external stimulations of the "pre_pop" (presynaptic) population do not trigger activity in the "post_pop" (postsynaptic) population. @@ -26,7 +26,7 @@ "n_stim_pairing" times by an external source so that the "post_pop" population spikes 10ms after the "pre_pop" population. - * Ater that period, only the "pre_pop" population is externally stimulated + * After that period, only the "pre_pop" population is externally stimulated "n_stim_test" times, but now it should trigger activity in the "post_pop" population (due to STDP learning) @@ -148,13 +148,13 @@ synapse_type=sim.StaticSynapse(weight=jee * 0.05)) # Additional Inputs projections -for i in range(len(i_add_pre)): +for _i_add_pre in i_add_pre: sim.Projection( - i_add_pre[i], pre_pop, ee_connector, receptor_type='excitatory', + _i_add_pre, pre_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) -for i in range(len(i_add_post)): +for _i_add_post in i_add_post: sim.Projection( - i_add_post[i], post_pop, ee_connector, receptor_type='excitatory', + _i_add_post, post_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) # Plastic Connections between pre_pop and post_pop @@ -178,7 +178,7 @@ # Run simulation sim.run(sim_time) -print("Weights:{}".format(plastic_projection.get('weight', 'list'))) +print(f"Weights:{plastic_projection.get('weight', 'list')}") pre_spikes = pre_pop.get_data('spikes') post_spikes = post_pop.get_data('spikes') @@ -190,7 +190,7 @@ Panel(post_spikes.segments[0].spiketrains, yticks=True, markersize=0.5, xlim=(0, sim_time)), title="stdp example curr", - annotations="Simulated with {}".format(sim.name())) + annotations=f"Simulated with {sim.name()}") plt.show() # End simulation on SpiNNaker diff --git a/examples/stdp_example_cond.py b/examples/stdp_example_cond.py index 0002c9a..3cc6113 100644 --- a/examples/stdp_example_cond.py +++ b/examples/stdp_example_cond.py @@ -18,7 +18,7 @@ Reproduces a classical plasticity experiment of plasticity induction by pre/post synaptic pairing specifically : - * At the begining of the simulation, "n_stim_test" external stimulations of + * At the beginning of the simulation, "n_stim_test" external stimulations of the "pre_pop" (presynaptic) population do not trigger activity in the "post_pop" (postsynaptic) population. @@ -178,7 +178,7 @@ # Run simulation sim.run(simtime) -print("Weights:{}".format(plastic_projection.get('weight', 'list'))) +print(f"Weights:{plastic_projection.get('weight', 'list')}") pre_spikes = pre_pop.get_data('spikes') post_spikes = post_pop.get_data('spikes') @@ -190,7 +190,7 @@ Panel(post_spikes.segments[0].spiketrains, yticks=True, markersize=0.5, xlim=(0, simtime)), title="stdp example cond", - annotations="Simulated with {}".format(sim.name())) + annotations=f"Simulated with {sim.name()}") plt.show() # End simulation on SpiNNaker diff --git a/examples/stdp_example_get_plastic_params.py b/examples/stdp_example_get_plastic_params.py index ee28c44..0a03f3b 100644 --- a/examples/stdp_example_get_plastic_params.py +++ b/examples/stdp_example_get_plastic_params.py @@ -18,7 +18,7 @@ Reproduces a classical plasticity experiment of plasticity induction by pre/post synaptic pairing specifically : - * At the begining of the simulation, "n_stim_test" external stimulations of + * At the beginning of the simulation, "n_stim_test" external stimulations of the "pre_pop" (presynaptic) population do not trigger activity in the "post_pop" (postsynaptic) population. diff --git a/examples/stdp_example_izk.py b/examples/stdp_example_izk.py index 8617cf7..3e2aa9a 100644 --- a/examples/stdp_example_izk.py +++ b/examples/stdp_example_izk.py @@ -24,7 +24,7 @@ Reproduces a classical plasticity experiment of plasticity induction by pre/post synaptic pairing specifically : - * At the begining of the simulation, "n_stim_test" external stimulations of + * At the beginning of the simulation, "n_stim_test" external stimulations of the "pre_pop" (presynaptic) population do not trigger activity in the "post_pop" (postsynaptic) population. diff --git a/examples/synfire_izk_curr_exp.py b/examples/synfire_izk_curr_exp.py index f1976ad..93ac0be 100644 --- a/examples/synfire_izk_curr_exp.py +++ b/examples/synfire_izk_curr_exp.py @@ -82,7 +82,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[populations[0].label], yticks=True, xlim=(0, runtime)), title="Simple synfire chain example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() From b8b70e475487e0e9e66784688db7a60d00839b14 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 13:27:52 +0100 Subject: [PATCH 12/23] # pylint: disable=wrong-spelling-in-comment --- synfire/synfire.py | 1 + 1 file changed, 1 insertion(+) diff --git a/synfire/synfire.py b/synfire/synfire.py index 56a9643..b7cfffe 100644 --- a/synfire/synfire.py +++ b/synfire/synfire.py @@ -77,6 +77,7 @@ print(spikes) raise ex + # pylint: disable=wrong-spelling-in-comment # Way to plot the spikes without neo converter but without the colours # try: # import matplotlib.pyplot as plt From 83e209ba66f6361a7c6a21bbe996b10717d6700e Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 14:55:18 +0100 Subject: [PATCH 13/23] f strings --- balanced_random/balanced_random.py | 2 +- .../split/balanced_random_split.py | 2 +- examples/current_injection_example.py | 2 +- .../balanced_random_live_rate.py | 2 +- .../live_examples/spike_io.py | 15 +++++++-------- .../spike_io_interactive_demo_with_c_vis.py | 7 +++---- .../live_examples/synfire_if_curr_exp_live.py | 2 +- .../extra_models_examples/IF_cond_exp_stoc.py | 2 +- .../extra_models_examples/IF_curr_delta.py | 2 +- .../extra_models_examples/IF_curr_exp_sEMD.py | 2 +- .../extra_models_examples/LGN_Izhikevich.py | 2 +- .../stdp_associative_memory.py | 4 ++-- .../stdp_example_izk_cond.py | 4 ++-- .../synfire_if_curr_dual_exp.py | 2 +- .../vogel_2011/vogels_2011.py | 10 +++++----- examples/if_curr_delta.py | 2 +- .../partitioner_examples/splitter_usage.py | 2 +- examples/pynnBrunnel.py | 2 +- examples/simple_STDP.py | 2 +- examples/split_examples/pynnBrunnelSplit.py | 2 +- examples/split_examples/va_benchmark_split.py | 10 +++++----- examples/stdp_example_get_plastic_params.py | 8 ++++---- examples/stdp_example_izk.py | 4 ++-- examples/synfire_if_cond_exp.py | 2 +- examples/synfire_if_curr_exp.py | 2 +- examples/synfire_if_curr_exp_large_array.py | 2 +- examples/synfire_if_curr_exp_random.py | 4 ++-- examples/va_benchmark.py | 10 +++++----- learning/random_dist.py | 2 +- learning/simple.py | 2 +- learning/split/stdp_split.py | 2 +- learning/split/struct_pl_split.py | 2 +- learning/split/struct_pl_stdp_split.py | 2 +- learning/stdp.py | 2 +- learning/struct_pl.py | 2 +- learning/struct_pl_stdp.py | 2 +- spiNNaker_start/spinnaker_start.py | 19 +++++++++---------- sudoku/set_numbers.py | 2 +- sudoku/sudoku_main.py | 2 +- synfire/synfire.py | 2 +- synfire/synfire_collab.py | 2 +- 41 files changed, 76 insertions(+), 79 deletions(-) diff --git a/balanced_random/balanced_random.py b/balanced_random/balanced_random.py index a2c4777..48bd4db 100644 --- a/balanced_random/balanced_random.py +++ b/balanced_random/balanced_random.py @@ -106,6 +106,6 @@ Panel(data.segments[0].spiketrains, yticks=True, markersize=2.0, xlim=(0, end_time)), title="Balanced Random Network", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) pylab.show() diff --git a/balanced_random/split/balanced_random_split.py b/balanced_random/split/balanced_random_split.py index 0107c2b..2b20fbb 100755 --- a/balanced_random/split/balanced_random_split.py +++ b/balanced_random/split/balanced_random_split.py @@ -127,6 +127,6 @@ Panel(data.segments[0].spiketrains, yticks=True, markersize=2.0, xlim=(0, end_time)), title="Balanced Random Network", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) pylab.show() diff --git a/examples/current_injection_example.py b/examples/current_injection_example.py index 532086e..c2a470f 100644 --- a/examples/current_injection_example.py +++ b/examples/current_injection_example.py @@ -66,7 +66,7 @@ xlabel="Time (ms)", ylabel="Membrane potential (mV)", ylim=(-96, -59)), title="Current injection example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/external_devices_examples/live_examples/balanced_random_live_rate.py b/examples/external_devices_examples/live_examples/balanced_random_live_rate.py index 2b15ae4..c0c4007 100644 --- a/examples/external_devices_examples/live_examples/balanced_random_live_rate.py +++ b/examples/external_devices_examples/live_examples/balanced_random_live_rate.py @@ -112,6 +112,6 @@ def start_callback(label, connection): Panel(data.segments[0].spiketrains, yticks=True, markersize=2.0, xlim=(0, end_time)), title="Balanced Random Network", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) pylab.show() diff --git a/examples/external_devices_examples/live_examples/spike_io.py b/examples/external_devices_examples/live_examples/spike_io.py index a12ae42..c89651e 100644 --- a/examples/external_devices_examples/live_examples/spike_io.py +++ b/examples/external_devices_examples/live_examples/spike_io.py @@ -29,9 +29,9 @@ # Create an initialisation method def init_pop(_label, _n_neurons, _run_time_ms, _machine_timestep_ms): - print("{} has {} neurons".format(_label, _n_neurons)) - print("Simulation will run for {}ms at {}ms timesteps".format( - _run_time_ms, _machine_timestep_ms)) + print(f"{_label} has {_n_neurons} neurons") + print(f"Simulation will run for {_run_time_ms}ms " + f"at {_machine_timestep_ms}ms timesteps") # Create a sender of packets for the forward population @@ -39,7 +39,7 @@ def send_input_forward(label, sender): for neuron_id in range(0, 100, 20): time.sleep(random.random() + 0.5) print_condition.acquire() - print("Sending forward spike {}".format(neuron_id)) + print(f"Sending forward spike {neuron_id}") print_condition.release() sender.send_spike(label, neuron_id, send_full_keys=True) @@ -50,7 +50,7 @@ def send_input_backward(label, sender): real_id = 100 - neuron_id - 1 time.sleep(random.random() + 0.5) print_condition.acquire() - print("Sending backward spike {}".format(real_id)) + print(f"Sending backward spike {real_id}") print_condition.release() sender.send_spike(label, real_id) @@ -59,8 +59,7 @@ def send_input_backward(label, sender): def receive_spikes(label, _time, neuron_ids): for neuron_id in neuron_ids: print_condition.acquire() - print("Received spike at time {} from {} - {}".format( - _time, label, neuron_id)) + print(f"Received spike at time {_time} from {label} - {neuron_id}") print_condition.release() @@ -203,7 +202,7 @@ def receive_spikes(label, _time, neuron_ids): Panel(spikes_backward.segments[0].spiketrains, yticks=True, markersize=0.2, xlim=(0, run_time)), title="Simple synfire chain example with injected spikes", - annotations="Simulated with {}".format(Frontend.name()) + annotations=f"Simulated with {Frontend.name}" ) plt.show() diff --git a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py index bb817bf..fb612f9 100644 --- a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py +++ b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py @@ -218,7 +218,7 @@ def __init__(self): Panel(spikes_backward.segments[0].spiketrains, yticks=True, markersize=0.2, xlim=(0, run_time)), title="Simple synfire chain example with injected spikes", - annotations="Simulated with {}".format(Frontend.name()) + annotations=f"Simulated with {Frontend.name()}" ) plt.show() @@ -226,8 +226,7 @@ def __init__(self): # Create a receiver of live spikes def receive_spikes(label, time, neuron_ids): for neuron_id in neuron_ids: - print("Received spike at time {} from {} - {}".format( - time, label, neuron_id)) + print(f"Received spike at time {time} from {label} - {neuron_id}") class GUI(object): @@ -280,7 +279,7 @@ def start(self, pop_label, connection): def inject_spike(self): neuron_id = self._neuron_id.get() label = self._pop_label.get() - print("injecting with neuron_id {} to pop {}".format(neuron_id, label)) + print(f"injecting with neuron_id {neuron_id} to pop {label}") self._live_spikes_connection.send_spike(label, neuron_id) diff --git a/examples/external_devices_examples/live_examples/synfire_if_curr_exp_live.py b/examples/external_devices_examples/live_examples/synfire_if_curr_exp_live.py index 1633df8..185c192 100644 --- a/examples/external_devices_examples/live_examples/synfire_if_curr_exp_live.py +++ b/examples/external_devices_examples/live_examples/synfire_if_curr_exp_live.py @@ -75,7 +75,7 @@ Panel(spikes.segments[0].spiketrains, yticks=True, markersize=0.2, xlim=(0, 5000)), title="Simple synfire chain example with injected spikes", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/examples/extra_models_examples/IF_cond_exp_stoc.py b/examples/extra_models_examples/IF_cond_exp_stoc.py index a14ce56..b4798a8 100644 --- a/examples/extra_models_examples/IF_cond_exp_stoc.py +++ b/examples/extra_models_examples/IF_cond_exp_stoc.py @@ -112,7 +112,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[exp_cell.label], yticks=True, xlim=(0, runtime)), title="IF_cond_exp_stoc example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/extra_models_examples/IF_curr_delta.py b/examples/extra_models_examples/IF_curr_delta.py index 5d14d9d..8d2c9c4 100644 --- a/examples/extra_models_examples/IF_curr_delta.py +++ b/examples/extra_models_examples/IF_curr_delta.py @@ -98,7 +98,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[exp_cell.label], yticks=True, xlim=(0, runtime)), title="IF_curr_delta example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/extra_models_examples/IF_curr_exp_sEMD.py b/examples/extra_models_examples/IF_curr_exp_sEMD.py index 35778a5..a76d825 100644 --- a/examples/extra_models_examples/IF_curr_exp_sEMD.py +++ b/examples/extra_models_examples/IF_curr_exp_sEMD.py @@ -98,7 +98,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[sEMD.label], yticks=True, xlim=(0, simulation_runtime)), title="SEMD example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() # plt.savefig('results.png') diff --git a/examples/extra_models_examples/LGN_Izhikevich.py b/examples/extra_models_examples/LGN_Izhikevich.py index fb1515d..78897cc 100644 --- a/examples/extra_models_examples/LGN_Izhikevich.py +++ b/examples/extra_models_examples/LGN_Izhikevich.py @@ -394,7 +394,7 @@ def print_synchrony(): xticks=True, ylabel="TRN membrane voltage", yticks=True, markersize=0.5, xlim=(100, 400), legend=False), title="Effect of I_DC on periodic input, with Izhikevich_cond neurons", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) # plt.savefig("Effect of I_DC on periodic input.png") plt.show() diff --git a/examples/extra_models_examples/stdp_associative_memory.py b/examples/extra_models_examples/stdp_associative_memory.py index e653885..2ae549c 100644 --- a/examples/extra_models_examples/stdp_associative_memory.py +++ b/examples/extra_models_examples/stdp_associative_memory.py @@ -164,7 +164,7 @@ p.run(runTime) final_weights = projections[0].get('weight', 'list', with_address=False) -print("Final weights: {}".format(final_weights)) +print(f"Final weights: {final_weights}") # myDelays = projections[0].getDelays() # total=0.0 @@ -205,7 +205,7 @@ data_labels=[populations[excit].label], yticks=True, xlim=(0, runTime), xticks=True), title="Simple associative memory: spikes and membrane potential", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/examples/extra_models_examples/stdp_example_izk_cond.py b/examples/extra_models_examples/stdp_example_izk_cond.py index 9c6faf8..0d81ec4 100644 --- a/examples/extra_models_examples/stdp_example_izk_cond.py +++ b/examples/extra_models_examples/stdp_example_izk_cond.py @@ -182,7 +182,7 @@ # Run simulation sim.run(simtime) -print("Weights:{}".format(plastic_projection.get('weight', 'list'))) +print(f"Weights:{plastic_projection.get('weight', 'list')}") # Get data pre_spikes = pre_pop.get_data('spikes') @@ -215,7 +215,7 @@ yticks=True, xticks=True, markersize=2.0, xlim=(0, simtime), color="blue", ylabel="Post-Population"), title="excitatory synaptic conductance (mS) and spike raster plots", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/extra_models_examples/synfire_if_curr_dual_exp.py b/examples/extra_models_examples/synfire_if_curr_dual_exp.py index c5112e6..1af151c 100644 --- a/examples/extra_models_examples/synfire_if_curr_dual_exp.py +++ b/examples/extra_models_examples/synfire_if_curr_dual_exp.py @@ -84,7 +84,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[populations[0].label], yticks=True, xlim=(0, runtime)), title="Synfire chain example with dual exponential synapse", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() print(figure_filename) diff --git a/examples/extra_models_examples/vogel_2011/vogels_2011.py b/examples/extra_models_examples/vogel_2011/vogels_2011.py index f2887ff..27ed58f 100644 --- a/examples/extra_models_examples/vogel_2011/vogels_2011.py +++ b/examples/extra_models_examples/vogel_2011/vogels_2011.py @@ -173,10 +173,10 @@ def _build_network(self, uses_stdp, slow_down): @staticmethod def save_name(spike_name): index = 0 - file_name = spike_name + "{}".format(index) + file_name = spike_name + str(index) while os.path.exists(file_name): index += 1 - file_name = spike_name + "{}".format(index) + file_name = spike_name + str(index) return file_name def run(self, slow_down_static, slow_down_plastic, extract_weights): @@ -209,7 +209,7 @@ def run(self, slow_down_static, slow_down_plastic, extract_weights): index = 0 if self.SAVE_ALL_CONNECTIVITY_IF_INSANE: for proj in projs: - proj.save("all", "projection{}_data".format(index)) + proj.save("all", f"projection{index}_data") index += 1 # Get static spikes @@ -241,7 +241,7 @@ def run(self, slow_down_static, slow_down_plastic, extract_weights): index = 0 if self.SAVE_ALL_CONNECTIVITY_IF_INSANE: plastic_ie_projection.save( - "all", "projection{}_before_data_plastic".format(index)) + "all", f"projection{index}_before_data_plastic") # Run simulation sim.run(self.SECOND_RUN_RUNTIME) @@ -250,7 +250,7 @@ def run(self, slow_down_static, slow_down_plastic, extract_weights): projs = [plastic_ie_projection] index = 0 for proj in projs: - proj.save("all", "projection{}_data_plastic".format(index)) + proj.save("all", f"projection{index}_data_plastic") index += 1 # Get plastic spikes and save to disk diff --git a/examples/if_curr_delta.py b/examples/if_curr_delta.py index 47956d9..68c88be 100644 --- a/examples/if_curr_delta.py +++ b/examples/if_curr_delta.py @@ -98,7 +98,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[exp_cell.label], yticks=True, xlim=(0, runtime)), title="IF_curr_delta example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/partitioner_examples/splitter_usage.py b/examples/partitioner_examples/splitter_usage.py index ba454c4..f33854c 100644 --- a/examples/partitioner_examples/splitter_usage.py +++ b/examples/partitioner_examples/splitter_usage.py @@ -91,6 +91,6 @@ ylabel="gsyn inhibitory (mV)", data_labels=[neuron.label], yticks=True, xlim=(0, runtime)), title="Simple synfire chain example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/examples/pynnBrunnel.py b/examples/pynnBrunnel.py index 9454b6f..fc4abcd 100644 --- a/examples/pynnBrunnel.py +++ b/examples/pynnBrunnel.py @@ -228,7 +228,7 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): Panel(esp.segments[0].spiketrains, yticks=True, markersize=1, xlim=(0, sim_time)), title="Brunnel example", - annotations="Simulated with {}".format(pynn.name()) + annotations=f"Simulated with {pynn.name()}" ) plt.show() diff --git a/examples/simple_STDP.py b/examples/simple_STDP.py index c2bd0ca..449284a 100644 --- a/examples/simple_STDP.py +++ b/examples/simple_STDP.py @@ -144,7 +144,7 @@ def spike_time_gen(i): ylim=(0.9 * final_weights.min(), 1.1 * final_weights.max()), xlabel="t_post - t_pre (ms)", ylabel="Final weight (nA)"), title="Simple STDP example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) # figure_filename = "simple_STDP.png" diff --git a/examples/split_examples/pynnBrunnelSplit.py b/examples/split_examples/pynnBrunnelSplit.py index cea0208..228ce06 100755 --- a/examples/split_examples/pynnBrunnelSplit.py +++ b/examples/split_examples/pynnBrunnelSplit.py @@ -239,7 +239,7 @@ def poisson_generator(rate, rng, t_start=0.0, t_stop=1000.0, array=True, Panel(esp.segments[0].spiketrains, yticks=True, markersize=1, xlim=(0, sim_time)), title="Brunnel example", - annotations="Simulated with {}".format(pynn.name()) + annotations=f"Simulated with {pynn.name()}" ) plt.show() diff --git a/examples/split_examples/va_benchmark_split.py b/examples/split_examples/va_benchmark_split.py index 9e39e5b..ef825ee 100755 --- a/examples/split_examples/va_benchmark_split.py +++ b/examples/split_examples/va_benchmark_split.py @@ -97,7 +97,7 @@ n_exc = int(round((n * r_ei / (1 + r_ei)))) # number of excitatory cells n_inh = n - n_exc # number of inhibitory cells -print("{} {}".format(n_exc, n_inh)) +print(n_exc, n_inh) w_exc = None w_inh = None @@ -106,7 +106,7 @@ celltype = p.IF_cond_exp w_exc = Gexc * 1e-3 # We convert conductances to uS w_inh = Ginh * 1e-3 - print("{} {}".format(w_exc, w_inh)) + print(w_exc, w_inh) elif benchmark == "CUBA": celltype = p.IF_curr_exp w_exc = 1e-3 * Gexc * (Erev_exc - v_mean) # (nA) weight of exc synapses @@ -216,8 +216,8 @@ # === Run simulation === print("%d Running simulation..." % node_id) -print("timings: number of neurons: {}".format(n)) -print("timings: number of synapses: {}".format(n * n * pconn)) +print(f"timings: number of neurons: {n}") +print(f"timings: number of synapses: {n * n * pconn}") p.run(tstop) @@ -232,7 +232,7 @@ Panel(exc_spikes.segments[0].spiketrains, xlabel="Time/ms", xticks=True, yticks=True, markersize=0.2, xlim=(0, tstop)), title="Vogels-Abbott benchmark: spikes", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/examples/stdp_example_get_plastic_params.py b/examples/stdp_example_get_plastic_params.py index 0a03f3b..85af7db 100644 --- a/examples/stdp_example_get_plastic_params.py +++ b/examples/stdp_example_get_plastic_params.py @@ -172,10 +172,10 @@ # Run simulation sim.run(simtime) -print("Weights:{}".format(plastic_projection.get('weight', 'list'))) -print("plastic1:{}".format(plastic_projection.get('tau_plus', 'list'))) -print("plastic2andweights:{}".format(plastic_projection.get( - ['weight', 'tau_plus'], 'list'))) +print(f"Weights:{plastic_projection.get('weight', 'list')}") +print(f"plastic1:{plastic_projection.get('tau_plus', 'list')}") +print(f"plastic2andweights:{plastic_projection.get( + ['weight', 'tau_plus'], 'list')}") # End simulation on SpiNNaker sim.end() diff --git a/examples/stdp_example_izk.py b/examples/stdp_example_izk.py index 3e2aa9a..2caf151 100644 --- a/examples/stdp_example_izk.py +++ b/examples/stdp_example_izk.py @@ -179,7 +179,7 @@ # Run simulation sim.run(simtime) -print("Weights:{}".format(plastic_projection.get('weight', 'list'))) +print(f"Weights:{plastic_projection.get('weight', 'list')}") # Get data pre_spikes = pre_pop.get_data('spikes') @@ -211,7 +211,7 @@ yticks=True, xticks=True, markersize=2.0, xlim=(0, simtime), color="blue", ylabel="Post-Population"), title="Excitatory synaptic conductance (mS) and spike raster plots", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/examples/synfire_if_cond_exp.py b/examples/synfire_if_cond_exp.py index 2e639d6..a039d67 100644 --- a/examples/synfire_if_cond_exp.py +++ b/examples/synfire_if_cond_exp.py @@ -85,7 +85,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[main_pop.label], yticks=True, xlim=(0, runtime)), title="Simple synfire chain example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() print(figure_filename) diff --git a/examples/synfire_if_curr_exp.py b/examples/synfire_if_curr_exp.py index 973838f..56791bc 100644 --- a/examples/synfire_if_curr_exp.py +++ b/examples/synfire_if_curr_exp.py @@ -86,7 +86,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[populations[0].label], yticks=True, xlim=(0, runtime)), title="Simple synfire chain example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}".format() ) plt.show() diff --git a/examples/synfire_if_curr_exp_large_array.py b/examples/synfire_if_curr_exp_large_array.py index ea1144e..b558736 100644 --- a/examples/synfire_if_curr_exp_large_array.py +++ b/examples/synfire_if_curr_exp_large_array.py @@ -92,7 +92,7 @@ ylabel="spikes from second pop", yticks=True, markersize=0.2, xlim=(0, run_time)), title="large data Simple synfire chain example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/examples/synfire_if_curr_exp_random.py b/examples/synfire_if_curr_exp_random.py index 9165bee..b5c818d 100644 --- a/examples/synfire_if_curr_exp_random.py +++ b/examples/synfire_if_curr_exp_random.py @@ -59,7 +59,7 @@ main_pop.record(['v', 'gsyn_exc', 'gsyn_inh', 'spikes']) -print("Running for {} ms".format(run_time)) +print(f"Running for {run_time} ms") p.run(run_time) # get data (could be done as one, but can be done bit by bit as well) data = main_pop.get_data(['v', 'gsyn_exc', 'spikes', 'gsyn_inh']) @@ -79,7 +79,7 @@ ylabel="gsyn inhibitory (mV)", data_labels=[main_pop.label], yticks=True, xlim=(0, run_time)), title="Simple synfire chain example", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/examples/va_benchmark.py b/examples/va_benchmark.py index f6969c6..1883815 100644 --- a/examples/va_benchmark.py +++ b/examples/va_benchmark.py @@ -95,7 +95,7 @@ n_exc = int(round((n * r_ei / (1 + r_ei)))) # number of excitatory cells n_inh = n - n_exc # number of inhibitory cells -print("{} {}".format(n_exc, n_inh)) +print(n_exc, n_inh) w_exc = None w_inh = None @@ -104,7 +104,7 @@ celltype = p.IF_cond_exp w_exc = Gexc * 1e-3 # We convert conductances to uS w_inh = Ginh * 1e-3 - print("{} {}".format(w_exc, w_inh)) + print(w_exc, w_inh) elif benchmark == "CUBA": celltype = p.IF_curr_exp w_exc = 1e-3 * Gexc * (Erev_exc - v_mean) # (nA) weight of exc synapses @@ -212,8 +212,8 @@ # === Run simulation === print("%d Running simulation..." % node_id) -print("timings: number of neurons: {}".format(n)) -print("timings: number of synapses: {}".format(n * n * pconn)) +print(f"timings: number of neurons: {n}") +print(f"timings: number of synapses: {n * n * pconn}") p.run(tstop) @@ -228,7 +228,7 @@ Panel(exc_spikes.segments[0].spiketrains, xlabel="Time/ms", xticks=True, yticks=True, markersize=0.2, xlim=(0, tstop)), title="Vogels-Abbott benchmark: spikes", - annotations="Simulated with {}".format(p.name()) + annotations=f"Simulated with {p.name()}" ) plt.show() diff --git a/learning/random_dist.py b/learning/random_dist.py index 5a70254..cd7ae38 100644 --- a/learning/random_dist.py +++ b/learning/random_dist.py @@ -67,6 +67,6 @@ # plot spikes plot.Panel(spikes, yticks=True, markersize=5, xlim=(0, simtime)), title="Balanced Random Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/simple.py b/learning/simple.py index 8e29136..32259fd 100644 --- a/learning/simple.py +++ b/learning/simple.py @@ -43,6 +43,6 @@ # plot spikes (or in this case spike) plot.Panel(spikes, yticks=True, markersize=5, xlim=(0, simtime)), title="Simple Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/split/stdp_split.py b/learning/split/stdp_split.py index b8d95c4..0d424d2 100755 --- a/learning/split/stdp_split.py +++ b/learning/split/stdp_split.py @@ -90,6 +90,6 @@ plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime), line_properties=line_properties), title="STDP Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/split/struct_pl_split.py b/learning/split/struct_pl_split.py index 6e30171..0d625df 100755 --- a/learning/split/struct_pl_split.py +++ b/learning/split/struct_pl_split.py @@ -111,6 +111,6 @@ plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime), line_properties=line_properties), title="STDP Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/split/struct_pl_stdp_split.py b/learning/split/struct_pl_stdp_split.py index 5495cf4..2f63920 100755 --- a/learning/split/struct_pl_stdp_split.py +++ b/learning/split/struct_pl_stdp_split.py @@ -121,6 +121,6 @@ plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime), line_properties=line_properties), title="STDP Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/stdp.py b/learning/stdp.py index 9bde57e..8b7de16 100644 --- a/learning/stdp.py +++ b/learning/stdp.py @@ -77,6 +77,6 @@ plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime), line_properties=line_properties), title="STDP Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/struct_pl.py b/learning/struct_pl.py index efc4c06..5ef01c5 100755 --- a/learning/struct_pl.py +++ b/learning/struct_pl.py @@ -104,6 +104,6 @@ plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime), line_properties=line_properties), title="STDP Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/learning/struct_pl_stdp.py b/learning/struct_pl_stdp.py index 202acc1..934f04a 100755 --- a/learning/struct_pl_stdp.py +++ b/learning/struct_pl_stdp.py @@ -109,6 +109,6 @@ plot.Panel(pre_spikes, post_spikes, yticks=True, xlim=(0, simtime), line_properties=line_properties), title="STDP Network Example", - annotations="Simulated with {}".format(sim.name()) + annotations=f"Simulated with {sim.name()}" ) plt.show() diff --git a/spiNNaker_start/spinnaker_start.py b/spiNNaker_start/spinnaker_start.py index 7bc3008..7b45c96 100644 --- a/spiNNaker_start/spinnaker_start.py +++ b/spiNNaker_start/spinnaker_start.py @@ -166,7 +166,7 @@ def __init__(self, x, y, connection_selector, core_counter, save, load): self._start_time = time.time() if load: read_file = open_file( - "record/netinit_{}_{}.dat".format(x, y), "rb") + f"record/netinit_{x}_{y}.dat", "rb") self._p2p_active_data = read_data_from_file(read_file) self._netinit_phase_data = read_data_from_file(read_file) close_file(read_file) @@ -189,8 +189,8 @@ def _process_p2p_active_response(self, response): def _process_p2p_active_count(self, count): if count != self._last_count: - warn("{:03d} {:03d} {:05d} has {} active P2P entries".format( - self._x, self._y, self._index, count)) + warn(f"{self._x:03d} {self._y:03d} {self._index:05d} " + f"has {count} active P2P entries") self._last_count = count self._core_counter.set_ethernet_n_routes(self._x, self._y, count) self._index += 1 @@ -210,8 +210,8 @@ def _process_netinit_phase_value(self, value): if self._last_phase != value: self._core_counter.set_ethernet_netinit_phase( self._x, self._y, value) - warn("{:03d} {:03d} {:05d} moved to phase {:03d}".format( - self._x, self._y, self._index, value)) + warn(f"{self._x:03d} {self._y:03d} {self._index:05d} " + f"moved to phase {value:03d}") self._index += 1 self._last_phase = value if self._save: @@ -271,7 +271,7 @@ def _run(self): time.sleep(0.1) if self._save: write_file = open_file( - "record/netinit_{}_{}.dat".format(self._x, self._y), "wb") + f"record/netinit_{self._x}_{self._y}.dat", "wb") write_data_to_file(write_file, self._p2p_active_data) write_data_to_file(write_file, self._netinit_phase_data) close_file(write_file) @@ -351,7 +351,7 @@ def __init__( self._start_time = time.time() if load: read_file = open_file( - "record/board_{}_{}.dat".format(eth_x, eth_y), "rb") + f"record/board_{eth_x}_{eth_y}.dat", "rb") self._data = read_data_from_file(read_file) close_file(read_file) @@ -404,8 +404,7 @@ def _read_board(self): warn(e) if self._save: write_file = open_file( - "record/board_{}_{}.dat".format( - self._eth_x, self._eth_y), "wb") + f"record/board_{self._eth_x}_{self._eth_y}.dat", "wb") write_data_to_file(write_file, self._data) close_file(write_file) @@ -463,7 +462,7 @@ def _update(self, _frame): bbox = self._ax.get_window_extent().transformed( self._fig.dpi_scale_trans.inverted()) self._text.set_fontsize(bbox.width * 12.5) - self._text.set_text("{:08,d}".format(self._total_cores)) + self._text.set_text(f"{self._total_cores:08,d}") return [self._image, self._text] def _get_max_value(self, x, y): diff --git a/sudoku/set_numbers.py b/sudoku/set_numbers.py index 7b22e41..cad48da 100644 --- a/sudoku/set_numbers.py +++ b/sudoku/set_numbers.py @@ -64,7 +64,7 @@ def __init__(self, n_total, n_cell, n_N, default_rate, max_rate, puzzle): frame = tk.Frame(self._root) for i in range(len(puzzles)): button = tk.Button( - frame, text="Puzzle {}".format(i + 1), width=10, + frame, text=f"Puzzle {i + 1}", width=10, command=functools.partial(self.set_puzzle, i)) button.grid(row=i, column=0, pady=5) button = tk.Button(frame, text="Dream", width=10, diff --git a/sudoku/sudoku_main.py b/sudoku/sudoku_main.py index 608caee..0f04fec 100644 --- a/sudoku/sudoku_main.py +++ b/sudoku/sudoku_main.py @@ -45,7 +45,7 @@ def read_output(visualiser, out): if line: print(line) result = visualiser.poll() - print("Visualiser exited: {}".format(result)) + print(f"Visualiser exited: {result}") def activate_visualiser(old_vis): diff --git a/synfire/synfire.py b/synfire/synfire.py index b7cfffe..8070ff5 100644 --- a/synfire/synfire.py +++ b/synfire/synfire.py @@ -33,7 +33,7 @@ label='stimulus') chain_pops = [ - sim.Population(n_neurons, sim.IF_curr_exp, {}, label='chain_{}'.format(i)) + sim.Population(n_neurons, sim.IF_curr_exp, {}, label=f'chain_{i}') for i in range(n_populations) ] for pop in chain_pops: diff --git a/synfire/synfire_collab.py b/synfire/synfire_collab.py index 1f53aa4..a36c6eb 100644 --- a/synfire/synfire_collab.py +++ b/synfire/synfire_collab.py @@ -33,7 +33,7 @@ label='stimulus') chain_pops = [ - sim.Population(n_neurons, sim.IF_curr_exp, {}, label='chain_{}'.format(i)) + sim.Population(n_neurons, sim.IF_curr_exp, {}, label='chain_{i}') for i in range(n_populations) ] for pop in chain_pops: From 7b1c9d77d7353702cf048ec61f457f617de34765 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 15:10:47 +0100 Subject: [PATCH 14/23] correct linebreak in f string --- examples/stdp_example_get_plastic_params.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/stdp_example_get_plastic_params.py b/examples/stdp_example_get_plastic_params.py index 85af7db..6b26727 100644 --- a/examples/stdp_example_get_plastic_params.py +++ b/examples/stdp_example_get_plastic_params.py @@ -174,8 +174,8 @@ print(f"Weights:{plastic_projection.get('weight', 'list')}") print(f"plastic1:{plastic_projection.get('tau_plus', 'list')}") -print(f"plastic2andweights:{plastic_projection.get( - ['weight', 'tau_plus'], 'list')}") +print(f"plastic2andweights:" + f"{plastic_projection.get(['weight', 'tau_plus'], 'list')}") # End simulation on SpiNNaker sim.end() From fb033ebd929388d4f43f535e3c101d4bbdbb72b7 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Thu, 6 Jun 2024 16:13:22 +0100 Subject: [PATCH 15/23] pylint fixes --- sudoku/set_numbers.py | 33 ++++++++++++++++++++++++++++++++- sudoku/sudoku_main.py | 4 ++++ sudoku/utils.py | 11 +++++++++++ synfire/synfire_collab.py | 1 - 4 files changed, 47 insertions(+), 2 deletions(-) diff --git a/sudoku/set_numbers.py b/sudoku/set_numbers.py index cad48da..4330820 100644 --- a/sudoku/set_numbers.py +++ b/sudoku/set_numbers.py @@ -23,6 +23,14 @@ class GUI(object): def __init__(self, n_total, n_cell, n_N, default_rate, max_rate, puzzle): + """ + :param int n_total: + :param int n_cell: + :param int n_N: + :param float default_rate: + :param float max_rate: + :param int puzzle: + """ self._n_total = n_total self._n_cell = n_cell self._n_N = n_N @@ -108,11 +116,18 @@ def __init__(self, n_total, n_cell, n_N, default_rate, max_rate, puzzle): def start(self): self._root.mainloop() - def on_start(self, label, connection): # pylint: disable=unused-argument + def on_start(self, label, connection): + """ + set the button and cycle button to normal + """ + # pylint: disable=unused-argument self._button["state"] = "normal" self._cycle_button["state"] = "normal" def cycle_puzzles(self): + """ + Cycle through the puzzles at 30 seconds intervals + """ self._after_id = self._root.after(30000, self.cycle_puzzles) print("Cycling after 30 seconds") self._puzzle = (self._puzzle + 1) % len(puzzles) @@ -120,12 +135,22 @@ def cycle_puzzles(self): self.set_puzzle(self._puzzle, automatic=True) def set_dream(self): + """ + Sets the numbers to zero and based on that the coonections and rates + """ for x in range(9): for y in range(9): self._numbers_txt[x][y].set(0) self.set_values() def set_puzzle(self, puzzle, automatic=False): + """ + Sets the puzzel number and based on that the numbers, coonections \ + and rates + + :param int puzzle: + :param bool automatic: + """ self._puzzle = puzzle for x in range(9): for y in range(9): @@ -133,6 +158,12 @@ def set_puzzle(self, puzzle, automatic=False): self.set_values(automatic) def set_values(self, automatic=False): + """ + Stes the connections and rates + + :param bool automatic: + :return: + """ if not automatic: if self._after_id is not None: print("Cancelling") diff --git a/sudoku/sudoku_main.py b/sudoku/sudoku_main.py index 0f04fec..f214bd7 100644 --- a/sudoku/sudoku_main.py +++ b/sudoku/sudoku_main.py @@ -237,6 +237,9 @@ def interCell(ic_x, ic_y, ic_r, ic_c, conns): def wait_for_end(): + """ + Collections of method that need to run at the endo of a run + """ set_window.wait() set_window.terminate() vis_process.terminate() @@ -248,6 +251,7 @@ def wait_for_end(): p.external_devices.run_forever() +# pylint: disable=wrong-spelling-in-comment # spikes = cells.getSpikes() # f, axarr = pylab.subplots(9, 9) # for y in range(9): diff --git a/sudoku/utils.py b/sudoku/utils.py index 7cefe85..f26212e 100644 --- a/sudoku/utils.py +++ b/sudoku/utils.py @@ -104,6 +104,17 @@ def get_rates(values, n_total, n_cell, n_N, default_rate, max_rate): + """ + Calculates the list of rates for a given number of cells. + + :param list(list(int)) values: + :param int n_total: + :param int n_cell: + :param int n_N: + :param float default_rate: + :param float max_rate: + :rtype: list(float) + """ rates = [default_rate] * n_total for x in range(9): for y in range(9): diff --git a/synfire/synfire_collab.py b/synfire/synfire_collab.py index a36c6eb..b34623d 100644 --- a/synfire/synfire_collab.py +++ b/synfire/synfire_collab.py @@ -73,7 +73,6 @@ ) offset += n_neurons plt.show() - # pylab.savefig("results.png") except Exception as ex: print(spikes) raise ex From 817c29e3ccbab582915aba2ba4025f78d51b126d Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Fri, 7 Jun 2024 08:13:31 +0100 Subject: [PATCH 16/23] pylint fixes --- .../live_examples/spike_io.py | 30 ++++++++++++++++++- .../spike_io_interactive_demo_with_c_vis.py | 2 +- .../IF_curr_exp_ca2_adaptive.py | 7 +++-- .../extra_models_examples/IF_curr_exp_sEMD.py | 1 - .../extra_models_examples/LGN_Izhikevich.py | 26 +++++++++++++++- .../stdp_associative_memory.py | 1 + .../stdp_example_izk_cond.py | 11 +++---- .../extra_models_examples/stdp_triplet.py | 1 + .../vogel_2011/vogels_2011.py | 13 ++++++-- .../vogel_2011/vogels_2011_live.py | 2 +- learning/simple.py | 2 +- learning/stdp.py | 2 +- learning/struct_pl.py | 2 +- sudoku/set_numbers.py | 7 +++++ sudoku/sudoku_main.py | 4 --- 15 files changed, 89 insertions(+), 22 deletions(-) diff --git a/examples/external_devices_examples/live_examples/spike_io.py b/examples/external_devices_examples/live_examples/spike_io.py index c89651e..8a2251c 100644 --- a/examples/external_devices_examples/live_examples/spike_io.py +++ b/examples/external_devices_examples/live_examples/spike_io.py @@ -29,6 +29,14 @@ # Create an initialisation method def init_pop(_label, _n_neurons, _run_time_ms, _machine_timestep_ms): + """ + Print method to show callback has been called + + :param str _label: + :param int _n_neurons: + :param float _run_time_ms: + :param float _machine_timestep_ms: + """ print(f"{_label} has {_n_neurons} neurons") print(f"Simulation will run for {_run_time_ms}ms " f"at {_machine_timestep_ms}ms timesteps") @@ -36,6 +44,12 @@ def init_pop(_label, _n_neurons, _run_time_ms, _machine_timestep_ms): # Create a sender of packets for the forward population def send_input_forward(label, sender): + """ + Sends 5 spikes at 20 millisecond intervals + + :param str label: + :param SpynnakerLiveSpikesConnection sender: + """ for neuron_id in range(0, 100, 20): time.sleep(random.random() + 0.5) print_condition.acquire() @@ -46,6 +60,12 @@ def send_input_forward(label, sender): # Create a sender of packets for the backward population def send_input_backward(label, sender): + """ + Sends 5 spikes at 20 millisecond intervals + + :param str label: + :param SpynnakerLiveSpikesConnection sender: + """ for neuron_id in range(0, 100, 20): real_id = 100 - neuron_id - 1 time.sleep(random.random() + 0.5) @@ -57,6 +77,14 @@ def send_input_backward(label, sender): # Create a receiver of live spikes def receive_spikes(label, _time, neuron_ids): + """ + Prints that spikes have been received + + :param int label: + :param str _time: + :param list(int) neuron_ids: + :return: + """ for neuron_id in neuron_ids: print_condition.acquire() print(f"Received spike at time {_time} from {label} - {neuron_id}") @@ -176,7 +204,7 @@ def receive_spikes(label, _time, neuron_ids): Frontend.FromListConnector(loop_backward)) # record spikes from the synfire chains so that we can read off valid results -# in a safe way afterwards, and verify the behavior +# in a safe way afterwards, and verify the behaviour pop_forward.record('spikes') pop_backward.record('spikes') diff --git a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py index fb612f9..b7213d1 100644 --- a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py +++ b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py @@ -185,7 +185,7 @@ def __init__(self): Frontend.FromListConnector(loop_backward)) # record spikes from the synfire chains so that we can read off valid - # results in a safe way afterwards, and verify the behavior + # results in a safe way afterwards, and verify the behaviour pop_forward.record('spikes') pop_backward.record('spikes') diff --git a/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py b/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py index 3cfb078..1e7386f 100644 --- a/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py +++ b/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py @@ -26,7 +26,7 @@ import pyNN.spiNNaker as sim # Timestep (ms) -# **NOTE** the 2.5Khz input frequency is not going to work particularily well +# **NOTE** the 2.5Khz input frequency is not going to work particularly well # at 1ms dt = 0.1 @@ -67,7 +67,8 @@ # Split into list of spike times for each neuron neuron_spikes = [spike_times[spike_times[:, 0] == n, 1] for n in range(N)] -# Calculate isis and pair these with bin index of last spike time in pair +# Calculate interspike intervals +# and pair these with bin index of last spike time in pair # **NOTE** using first spike time in pair leads to a dip at the # end as the end of long pairs goes off the end of the simulation binned_isis = numpy.hstack([ @@ -76,7 +77,7 @@ numpy.digitize(t[1:], numpy.arange(T)) - 1)) for t in neuron_spikes]) -# Split ISIs into seperate array for each time bin +# Split interspike intervals into separate array for each time bin time_binned_isis = [binned_isis[0, binned_isis[1] == t] for t in range(T)] # Create a dictionary of non-empty time bins to mean ISI diff --git a/examples/extra_models_examples/IF_curr_exp_sEMD.py b/examples/extra_models_examples/IF_curr_exp_sEMD.py index a76d825..ef9eb1d 100644 --- a/examples/extra_models_examples/IF_curr_exp_sEMD.py +++ b/examples/extra_models_examples/IF_curr_exp_sEMD.py @@ -101,7 +101,6 @@ annotations=f"Simulated with {p.name()}" ) plt.show() -# plt.savefig('results.png') # end p.end() diff --git a/examples/extra_models_examples/LGN_Izhikevich.py b/examples/extra_models_examples/LGN_Izhikevich.py index 78897cc..fdb64bc 100644 --- a/examples/extra_models_examples/LGN_Izhikevich.py +++ b/examples/extra_models_examples/LGN_Izhikevich.py @@ -49,10 +49,17 @@ from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt -# pylint: disable=pointless-string-statement +# pylint: disable=pointless-string-statement,disable=wrong-spelling-in-comment def get_mean_rate(numCells, population): + """ + Calculate the average number of spikes ber neuron + + :param int numCells: + :param population: neo block + :return: + """ firing_rate = [] # format = < neuron_id, rate (spikes/ms) > for index in range(0, numCells): @@ -63,6 +70,11 @@ def get_mean_rate(numCells, population): def calc_irregularity(segment): + """ + Calculate the irregularity of spikes + + :param segment: neo Segment + """ irregularity = 0 isi_array = [] for i in range(len(segment.spiketrains)): @@ -81,12 +93,21 @@ def calc_irregularity(segment): def print_irregularity(): + """ + Calculate and prints the irregularity of spikes + """ print("TCR irregularity: ", calc_irregularity(TCR_spikes.segments[0])) print("IN irregularity: ", calc_irregularity(IN_spikes.segments[0])) print("TRN irregularity: ", calc_irregularity(TRN_spikes.segments[0])) def calc_synchrony(segment): + """ + Calculate the synchrony of spikes + + :param segment: neo Segment + :return: + """ spike_counts = np.zeros(int(TotalDuration/2.0), dtype=int) for i in range(len(segment.spiketrains)): for j in range(len(segment.spiketrains[i])): @@ -99,6 +120,9 @@ def calc_synchrony(segment): def print_synchrony(): + """ + Calculate and print the synchrony of spikes + """ print("TCR synchrony: ", calc_synchrony(TCR_spikes.segments[0])) print("IN synchrony: ", calc_synchrony(IN_spikes.segments[0])) print("TRN synchrony: ", calc_synchrony(TRN_spikes.segments[0])) diff --git a/examples/extra_models_examples/stdp_associative_memory.py b/examples/extra_models_examples/stdp_associative_memory.py index 2ae549c..703878e 100644 --- a/examples/extra_models_examples/stdp_associative_memory.py +++ b/examples/extra_models_examples/stdp_associative_memory.py @@ -166,6 +166,7 @@ final_weights = projections[0].get('weight', 'list', with_address=False) print(f"Final weights: {final_weights}") +# pylint: disable=wrong-spelling-in-comment # myDelays = projections[0].getDelays() # total=0.0 # count = len(myDelays) diff --git a/examples/extra_models_examples/stdp_example_izk_cond.py b/examples/extra_models_examples/stdp_example_izk_cond.py index 0d81ec4..c913297 100644 --- a/examples/extra_models_examples/stdp_example_izk_cond.py +++ b/examples/extra_models_examples/stdp_example_izk_cond.py @@ -121,7 +121,8 @@ pop_size, sim.SpikeSourcePoisson( rate=in_rate, start=start_pairing + ISI * i + 10, duration=dur_stim))) - # Pre spikes 10ms after Post so that Hebb can cause LTP + # pylint: disable=wrong-spelling-in-comment + # Pre spikes 10ms after Post so that Hebb can cause long-term potentiation # Test post pairing : only pre_pop is stimulated (and should trigger activity # in Post) @@ -156,13 +157,13 @@ synapse_type=sim.StaticSynapse(weight=JEE * 0.01)) # Additional Inputs projections -for i in range(len(IAddPre)): +for iAddPre in IAddPre: sim.Projection( - IAddPre[i], pre_pop, ee_connector, receptor_type='excitatory', + iAddPre, pre_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE * 0.01)) -for i in range(len(IAddPost)): +for iAddPost in IAddPost: sim.Projection( - IAddPost[i], post_pop, ee_connector, receptor_type='excitatory', + iAddPost, post_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE * 0.01)) # Plastic Connections between pre_pop and post_pop diff --git a/examples/extra_models_examples/stdp_triplet.py b/examples/extra_models_examples/stdp_triplet.py index 86ac2ae..a5ecea8 100644 --- a/examples/extra_models_examples/stdp_triplet.py +++ b/examples/extra_models_examples/stdp_triplet.py @@ -16,6 +16,7 @@ import pyNN.spiNNaker as sim +# pylint: disable=wrong-spelling-in-comment # ------------------------------------------------------------------- # This example uses the sPyNNaker implementation of the triplet rule # Developed by Pfister and Gerstner(2006) to reproduce the pairing diff --git a/examples/extra_models_examples/vogel_2011/vogels_2011.py b/examples/extra_models_examples/vogel_2011/vogels_2011.py index 27ed58f..33c8ca6 100644 --- a/examples/extra_models_examples/vogel_2011/vogels_2011.py +++ b/examples/extra_models_examples/vogel_2011/vogels_2011.py @@ -11,10 +11,10 @@ # 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. +import os from pyNN.random import NumpyRNG import pyNN.spiNNaker as sim import numpy -import os import matplotlib.pyplot as pylab from spynnaker.pyNN.utilities import neo_convertor @@ -172,6 +172,15 @@ def _build_network(self, uses_stdp, slow_down): @staticmethod def save_name(spike_name): + """ + Gets the name of a none existing file based on this name. + + If needed ands a number at the end. + + :param str spike_name: + :return: A unique file name + :rtype: str + """ index = 0 file_name = spike_name + str(index) while os.path.exists(file_name): @@ -293,7 +302,7 @@ def plot( # print mean weight, if we bothered to extract them. if plastic_weights is not None: mean_weight = numpy.average(plastic_weights) - print("Mean learnt ie weight:%f" % mean_weight) + print(f"Mean learnt ie weight:{mean_weight:f}") # Create plot _fig, axes = pylab.subplots(3) diff --git a/examples/extra_models_examples/vogel_2011/vogels_2011_live.py b/examples/extra_models_examples/vogel_2011/vogels_2011_live.py index a996888..38df246 100644 --- a/examples/extra_models_examples/vogel_2011/vogels_2011_live.py +++ b/examples/extra_models_examples/vogel_2011/vogels_2011_live.py @@ -14,7 +14,7 @@ import pyNN.spiNNaker as sim - +# pylint: disable=wrong-spelling-in-comment # ------------------------------------------------------------------- # This example uses the sPyNNaker implementation of the inhibitory # Plasticity rule developed by Vogels, Sprekeler, Zenke et al (2011) diff --git a/learning/simple.py b/learning/simple.py index 32259fd..e93bca8 100644 --- a/learning/simple.py +++ b/learning/simple.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import pyNN.spiNNaker as sim +import pyNN.utility.plotting as plot sim.setup(timestep=1.0, n_boards_required=1) machine = sim.get_machine() diff --git a/learning/stdp.py b/learning/stdp.py index 8b7de16..40aa5ba 100644 --- a/learning/stdp.py +++ b/learning/stdp.py @@ -12,9 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import pyNN.spiNNaker as sim +import pyNN.utility.plotting as plot n_neurons = 100 simtime = 5000 diff --git a/learning/struct_pl.py b/learning/struct_pl.py index 5ef01c5..baa4846 100755 --- a/learning/struct_pl.py +++ b/learning/struct_pl.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import numpy import pyNN.spiNNaker as sim +import pyNN.utility.plotting as plot n_neurons = 100 simtime = 5000 diff --git a/sudoku/set_numbers.py b/sudoku/set_numbers.py index 4330820..dcb45ad 100644 --- a/sudoku/set_numbers.py +++ b/sudoku/set_numbers.py @@ -21,6 +21,9 @@ class GUI(object): + """ + A Gui for setting the numbers in the puzzle. + """ def __init__(self, n_total, n_cell, n_N, default_rate, max_rate, puzzle): """ @@ -114,6 +117,10 @@ def __init__(self, n_total, n_cell, n_N, default_rate, max_rate, puzzle): button_frame.grid(row=13, column=0, columnspan=11, pady=5) def start(self): + """ + Starts the main loop running + + """ self._root.mainloop() def on_start(self, label, connection): diff --git a/sudoku/sudoku_main.py b/sudoku/sudoku_main.py index f214bd7..63e7eba 100644 --- a/sudoku/sudoku_main.py +++ b/sudoku/sudoku_main.py @@ -204,10 +204,6 @@ def interCell(ic_x, ic_y, ic_r, ic_c, conns): """ base_source = ((ic_y * 9) + ic_x) * n_cell base_dest = ((ic_c * 9) + ic_r) * n_cell - # p.Projection(cells_pop[base_source:base_source+n_cell], - # cells_pop[base_dest:base_dest+n_cell], - # p.AllToAllConnector(), - # p.StaticSynapse(weight=weight_cell, delay=delay)) connections_intC = [ (i + base_source, j + base_dest, weight_cell, delay) for i in range(n_cell) From 3e0fffd8332d59ace6b1af4d2ee4c00f844fa1c6 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jun 2024 08:51:32 +0100 Subject: [PATCH 17/23] docs and error fix --- sudoku/sudoku_main.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/sudoku/sudoku_main.py b/sudoku/sudoku_main.py index 63e7eba..66d0f71 100644 --- a/sudoku/sudoku_main.py +++ b/sudoku/sudoku_main.py @@ -39,6 +39,12 @@ # Run the visualiser def read_output(visualiser, out): + """ + Pools the visualiser and prints the output until the + + :param subprocess.Popen visualiser: + :param BufferedReader out: + """ result = visualiser.poll() while result is None: line = out.readline() @@ -49,6 +55,11 @@ def read_output(visualiser, out): def activate_visualiser(old_vis): + """ + Creates and starts the GUi + + :param bool old_vis: If the old Visualiser should be used + """ vis_exe = None if old_vis: if sys.platform.startswith("win32"): @@ -76,7 +87,7 @@ def activate_visualiser(old_vis): vismatch = re.match("^Listening on (.*)$", visline) if not vismatch: vis_proc.kill() - raise ValueError(f"Receiver returned unknown output: {firstline}") + raise ValueError(f"Receiver returned unknown output: {visline}") port = int(vismatch.group(1)) Thread(target=read_output, args=[vis_proc, vis_proc.stderr]).start() From bf69f2ac4f788e220e378f80f60948ddc99bbf9c Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jun 2024 14:40:55 +0100 Subject: [PATCH 18/23] pylint fixes --- .../balanced_random_live_rate.py | 12 ++++-- .../live_examples/spike_io.py | 2 +- .../spike_io_interactive_demo_with_c_vis.py | 23 +++++++++-- .../pushbot_light_follower.py | 4 +- .../IF_curr_exp_ca2_adaptive.py | 2 +- .../extra_models_examples/LGN_Izhikevich.py | 22 +++++----- .../stdp_associative_memory.py | 2 +- .../extra_models_examples/stdp_triplet.py | 10 ++++- examples/if_curr_alpha.py | 2 +- examples/pynnBrunnel.py | 14 +++---- examples/simple_STDP.py | 5 ++- examples/stdp_curve.py | 2 +- examples/stdp_curve_cond.py | 2 +- examples/stdp_example_izk.py | 9 +++-- .../structural_plasticity_with_stdp_2d.py | 8 ++-- examples/va_benchmark.py | 40 ++++++++++--------- learning/struct_pl_stdp.py | 2 +- 17 files changed, 98 insertions(+), 63 deletions(-) diff --git a/examples/external_devices_examples/live_examples/balanced_random_live_rate.py b/examples/external_devices_examples/live_examples/balanced_random_live_rate.py index c0c4007..7ab9aaa 100644 --- a/examples/external_devices_examples/live_examples/balanced_random_live_rate.py +++ b/examples/external_devices_examples/live_examples/balanced_random_live_rate.py @@ -12,12 +12,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +import time +import numpy +import pylab import pyNN.spiNNaker as p from pyNN.random import RandomDistribution -import pylab -import numpy from pyNN.utility.plotting import Figure, Panel -import time p.setup(timestep=0.1) p.set_number_of_neurons_per_core(p.SpikeSourcePoisson, 50) @@ -92,6 +92,12 @@ def start_callback(label, connection): + """ + Changes the connection rate very 10 seconds + + :param str label: + :param SpynnakerPoissonControlConnection connection: + """ for rate in [50, 10, 20]: time.sleep(10.0) connection.set_rates(label, [(i, rate) for i in range(100)]) diff --git a/examples/external_devices_examples/live_examples/spike_io.py b/examples/external_devices_examples/live_examples/spike_io.py index 8a2251c..b01a4ac 100644 --- a/examples/external_devices_examples/live_examples/spike_io.py +++ b/examples/external_devices_examples/live_examples/spike_io.py @@ -137,7 +137,7 @@ def receive_spikes(label, _time, neuron_ids): run_time = 8000 weight_to_spike = 2.0 -# neural parameters of the ifcur model used to respond to injected spikes. +# neural parameters of the model used to respond to injected spikes. # (cell params for a synfire chain) cell_params_lif = {'cm': 0.25, 'i_offset': 0.0, diff --git a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py index b7213d1..ba8500a 100644 --- a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py +++ b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py @@ -12,11 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +import multiprocessing import tkinter as tk import pyNN.spiNNaker as Frontend from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt -import multiprocessing class PyNNScript(object): @@ -37,7 +37,7 @@ def __init__(self): # simulation, as well as the expected weight each spike will contain self.n_neurons = 100 - # set up gui + # set up GUI p = None sender_port = None if use_spike_injector: @@ -65,7 +65,7 @@ def __init__(self): live_spikes_connection_receive.add_receive_callback( "pop_backward", receive_spikes) - # different runtimes for demostration purposes + # different runtimes for demonstration purposes run_time = None if not use_c_visualiser and not use_spike_injector: run_time = 1000 @@ -225,6 +225,14 @@ def __init__(self): # Create a receiver of live spikes def receive_spikes(label, time, neuron_ids): + """ + Print that spikes have been received + + :param str label: + :param int time: + :param list(int) neuron_ids: + :return: + """ for neuron_id in neuron_ids: print(f"Received spike at time {time} from {label} - {neuron_id}") @@ -273,10 +281,19 @@ def __init__(self, n_neurons, ready, port): self._root.mainloop() def start(self, pop_label, connection): + """ + Set the start button to state to normal + + :param pop_label: IGNORED + :param connection: IGNORED + """ # pylint: disable=unused-argument self._button["state"] = "normal" def inject_spike(self): + """ + Inject a spike into system + """ neuron_id = self._neuron_id.get() label = self._pop_label.get() print(f"injecting with neuron_id {neuron_id} to pop {label}") diff --git a/examples/external_devices_examples/pushbot_light_follower.py b/examples/external_devices_examples/pushbot_light_follower.py index 5f12d7b..e168480 100644 --- a/examples/external_devices_examples/pushbot_light_follower.py +++ b/examples/external_devices_examples/pushbot_light_follower.py @@ -75,7 +75,7 @@ # Create populations ########################################### -# Retina population ( num of neurons:n_pixel*n_pixel*2 ) +# Retina population ( number of neurons:n_pixel*n_pixel*2 ) pushbot_retina = p.Population( retina_resolution.value.n_neurons, retina_device, label=retina_label) p.external_devices.activate_live_output_for( @@ -162,7 +162,7 @@ id_to_middle_up = numpy.extract(id_to_middle_up, arr) print("middle =", id_to_middle_up) -# Conn list: (source neuron, target neuron, weight, delay) +# Connection list: (source neuron, target neuron, weight, delay) # Creates connection list to connect left neuron conn_list_left = [(i, 0, w_conn, d_conn) for i in id_to_left] diff --git a/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py b/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py index 1e7386f..0b61677 100644 --- a/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py +++ b/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py @@ -80,7 +80,7 @@ # Split interspike intervals into separate array for each time bin time_binned_isis = [binned_isis[0, binned_isis[1] == t] for t in range(T)] -# Create a dictionary of non-empty time bins to mean ISI +# Create a dictionary of non-empty time bins to mean interspike inverval mean_isis = {t: numpy.average(i) for (t, i) in enumerate(time_binned_isis) if len(i) > 0} diff --git a/examples/extra_models_examples/LGN_Izhikevich.py b/examples/extra_models_examples/LGN_Izhikevich.py index fdb64bc..d362ed4 100644 --- a/examples/extra_models_examples/LGN_Izhikevich.py +++ b/examples/extra_models_examples/LGN_Izhikevich.py @@ -40,9 +40,9 @@ https://journal.frontiersin.org/article/10.3389/fnins.2017.00454/abstract """ +import math import pyNN.spiNNaker as p import numpy as np -import math from pyNN.random import RandomDistribution, NumpyRNG # for plotting @@ -77,15 +77,15 @@ def calc_irregularity(segment): """ irregularity = 0 isi_array = [] - for i in range(len(segment.spiketrains)): - if len(segment.spiketrains[i]) > 2: + for spiketrain in segment.spiketrains: + if len(spiketrain) > 2: isi_array.append([]) - for j in range(len(segment.spiketrains[i])-1): + for j in range(len(spiketrain)-1): isi_array[-1].append( - segment.spiketrains[i][j+1]-segment.spiketrains[i][j]) - for i in range(len(isi_array)): - mean = np.mean(isi_array[i]) - sd = np.std(isi_array[i]) + spiketrain[j+1]-spiketrain[j]) + for isi in isi_array: + mean = np.mean(isi) + sd = np.std(isi) cv = sd / mean irregularity += cv irregularity = irregularity / len(segment.spiketrains) @@ -109,9 +109,9 @@ def calc_synchrony(segment): :return: """ spike_counts = np.zeros(int(TotalDuration/2.0), dtype=int) - for i in range(len(segment.spiketrains)): - for j in range(len(segment.spiketrains[i])): - index = math.floor(segment.spiketrains[i][j] / 2.0) + for spiketrain in segment.spiketrains: + for spike in spiketrain: + index = math.floor(spike / 2.0) spike_counts[index] += 1 mean = np.mean(spike_counts) var = np.std(spike_counts) * np.std(spike_counts) diff --git a/examples/extra_models_examples/stdp_associative_memory.py b/examples/extra_models_examples/stdp_associative_memory.py index 703878e..c004c3a 100644 --- a/examples/extra_models_examples/stdp_associative_memory.py +++ b/examples/extra_models_examples/stdp_associative_memory.py @@ -19,6 +19,7 @@ from pyNN.random import NumpyRNG, RandomDistribution import pyNN.spiNNaker as p from pyNN.utility.plotting import Figure, Panel +# pylint: disable=wrong-spelling-in-comment p.setup(timestep=1.0, min_delay=1.0) p.set_number_of_neurons_per_core(p.IF_curr_exp, 100) @@ -166,7 +167,6 @@ final_weights = projections[0].get('weight', 'list', with_address=False) print(f"Final weights: {final_weights}") -# pylint: disable=wrong-spelling-in-comment # myDelays = projections[0].getDelays() # total=0.0 # count = len(myDelays) diff --git a/examples/extra_models_examples/stdp_triplet.py b/examples/extra_models_examples/stdp_triplet.py index a5ecea8..3d3eaac 100644 --- a/examples/extra_models_examples/stdp_triplet.py +++ b/examples/extra_models_examples/stdp_triplet.py @@ -37,6 +37,14 @@ def generate_fixed_frequency_test_data( frequency, first_spike_time, num_spikes): + """ + Generates a list of spike times based on the frequency + + :param int frequency: + :param int first_spike_time: + :param int num_spikes: + :rtype: list(int) + """ # Calculate interspike delays in ms interspike_delay = int(1000.0 / float(frequency)) @@ -110,7 +118,7 @@ def generate_fixed_frequency_test_data( pre_pop, post_pop, sim.OneToOneConnector(), synapse_type=stdp_model)) -print("Simulating for %us" % (sim_time / 1000)) +print(f"Simulating for {(sim_time / 1000)}s") # Run simulation sim.run(sim_time) diff --git a/examples/if_curr_alpha.py b/examples/if_curr_alpha.py index bc8259f..a01d246 100644 --- a/examples/if_curr_alpha.py +++ b/examples/if_curr_alpha.py @@ -12,8 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. import pyNN.spiNNaker as p -import matplotlib.pyplot as plt import pyNN.utility.plotting as plot +import matplotlib.pyplot as plt p.setup(0.1) runtime = 50 diff --git a/examples/pynnBrunnel.py b/examples/pynnBrunnel.py index fc4abcd..504f76a 100644 --- a/examples/pynnBrunnel.py +++ b/examples/pynnBrunnel.py @@ -66,7 +66,7 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): extra_spikes = [] if i == len(spikes): - # ISI buf overrun + # Interspike interval buffer overrun t_last = spikes[-1] + _rng.exponential(1.0 / _rate, 1)[0] * 1000.0 @@ -77,8 +77,8 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): spikes = np.concatenate((spikes, extra_spikes)) if _debug: - print("ISI buf overrun handled. len(spikes)=%d," - " len(extra_spikes)=%d" % (len(spikes), len(extra_spikes))) + print(f"ISI buf overrun handled. {len(spikes)=}, " + f"{len(extra_spikes)=}") else: spikes = np.resize(spikes, (i,)) @@ -125,7 +125,7 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): # nu_ex*C_E the factor 1000.0 changes the units from # spikes per ms to spikes per second. p_rate = 1000.0 * nu_ex * C_E -print("Rate is: %f HZ" % (p_rate / 1000)) +print(f"Rate is: {p_rate / 1000} HZ") # Neural Parameters pynn.setup(timestep=0.1, min_delay=0.1) @@ -137,7 +137,7 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): pynn.set_number_of_neurons_per_core(pynn.SpikeSourcePoisson, 64) exc_cell_params = { - 'cm': 1.0, # pf + 'cm': 1.0, 'tau_m': tau_m, 'tau_refrac': tau_ref, 'v_rest': v_rest, @@ -149,7 +149,7 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): } inh_cell_params = { - 'cm': 1.0, # pf + 'cm': 1.0, 'tau_m': tau_m, 'tau_refrac': tau_ref, 'v_rest': v_rest, @@ -179,7 +179,7 @@ def poisson_generator(_rate, _rng, _t_start=0.0, _t_stop=1000.0, _debug=False): I_conn = pynn.FixedProbabilityConnector(epsilon) # Use random delays for the external noise and -# set the inital membrance voltage below the resting potential +# set the initial membrane voltage below the resting potential # to avoid the overshoot of activity in the beginning of the simulation delay_distr = RandomDistribution('uniform', low=0.1, high=12.8) Ext_conn = pynn.OneToOneConnector() diff --git a/examples/simple_STDP.py b/examples/simple_STDP.py index 449284a..2e55dc9 100644 --- a/examples/simple_STDP.py +++ b/examples/simple_STDP.py @@ -118,15 +118,16 @@ def spike_time_gen(i): presynaptic_spikes = p1.get_data('spikes').segments[0] postsynaptic_spikes = p2.get_data('spikes').segments[0] postsynaptic_v = p2.get_data('v').segments[0] -print("Post-synaptic spike times: %s" % postsynaptic_spikes.spiketrains[0]) +print(f"Post-synaptic spike times: {postsynaptic_spikes.spiketrains[0]}") weights = connections.get(["weight"], "list") final_weights = numpy.array([w[-1] for w in weights]) deltas = delta_t * numpy.arange(n // 2, -n // 2, -1) -print("Final weights: %s" % final_weights) +print(f"Final weights: {final_weights}") plasticity_data = DataTable(deltas, final_weights) Figure( + # pylint: disable=wrong-spelling-in-comment # raster plot of the presynaptic neuron spike times Panel(presynaptic_spikes.spiketrains, yticks=True, markersize=0.2, xlim=(0, t_stop)), diff --git a/examples/stdp_curve.py b/examples/stdp_curve.py index 9f41036..95b520d 100644 --- a/examples/stdp_curve.py +++ b/examples/stdp_curve.py @@ -111,7 +111,7 @@ pre_pop, post_pop, sim.OneToOneConnector(), synapse_type=stdp_model)) -print("Simulating for %us" % (sim_time / 1000)) +print("Simulating for {sim_time / 1000}s") # Run simulation sim.run(sim_time) diff --git a/examples/stdp_curve_cond.py b/examples/stdp_curve_cond.py index fbafed0..bc78429 100644 --- a/examples/stdp_curve_cond.py +++ b/examples/stdp_curve_cond.py @@ -112,7 +112,7 @@ pre_pop, post_pop, sim.OneToOneConnector(), synapse_type=stdp_model)) -print("Simulating for %us" % (sim_time / 1000)) +print(f"Simulating for {sim_time / 1000}s") # Run simulation sim.run(sim_time) diff --git a/examples/stdp_example_izk.py b/examples/stdp_example_izk.py index 2caf151..3b52d2f 100644 --- a/examples/stdp_example_izk.py +++ b/examples/stdp_example_izk.py @@ -118,6 +118,7 @@ pop_size, sim.SpikeSourcePoisson( rate=in_rate, start=start_pairing + ISI * i + 10, duration=dur_stim))) + # pylint: disable=wrong-spelling-in-comment # Pre spikes 10ms after Post so that Hebb can cause LTP # Test post pairing : only pre_pop is stimulated (and should trigger activity @@ -153,13 +154,13 @@ synapse_type=sim.StaticSynapse(weight=JEE)) # Additional Inputs projections -for i in range(len(IAddPre)): +for iAddPre in IAddPre: sim.Projection( - IAddPre[i], pre_pop, ee_connector, receptor_type='excitatory', + iAddPre, pre_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE)) -for i in range(len(IAddPost)): +for iAddPost in IAddPost: sim.Projection( - IAddPost[i], post_pop, ee_connector, receptor_type='excitatory', + iAddPost, post_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE)) # Plastic Connections between pre_pop and post_pop diff --git a/examples/structural_plasticity_with_stdp_2d.py b/examples/structural_plasticity_with_stdp_2d.py index 4ebd1fb..69d4acb 100644 --- a/examples/structural_plasticity_with_stdp_2d.py +++ b/examples/structural_plasticity_with_stdp_2d.py @@ -159,14 +159,14 @@ synapse_type=sim.StaticSynapse(weight=jee * 0.05)) # Additional Inputs projections -for i in range(len(i_add_pre)): +for _i_add_pre in i_add_pre: sim.Projection( - i_add_pre[i], pre_pop, sim.OneToOneConnector(), + _i_add_pre, pre_pop, sim.OneToOneConnector(), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) -for i in range(len(i_add_post)): +for _i_add_post in range(len(i_add_post)): sim.Projection( - i_add_post[i], post_pop, sim.OneToOneConnector(), + _i_add_post, post_pop, sim.OneToOneConnector(), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) diff --git a/examples/va_benchmark.py b/examples/va_benchmark.py index 1883815..8b93f3d 100644 --- a/examples/va_benchmark.py +++ b/examples/va_benchmark.py @@ -14,6 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# pylint: disable=wrong-spelling-in-comment + """ An implementation of benchmarks 1 and 2 from @@ -53,7 +55,7 @@ rate = 100. # (Hz) frequency of the random stimulation dt = 1.0 # (ms) simulation timestep -tstop = 1000 # (ms) simulaton duration +tstop = 1000 # (ms) simulation duration delay = 2 # Cell parameters @@ -115,7 +117,7 @@ # === Build the network === extra = {'threads': threads, - 'filename': "va_%s.xml" % benchmark, + 'filename': f"va_{benchmark}.xml", 'label': 'VA'} if simulator_name == "neuroml": extra["file"] = "VAbenchmarks.xml" @@ -131,10 +133,10 @@ np = 1 host_name = socket.gethostname() -print("Host #%d is on %s" % (np, host_name)) +print(f"Host #{np} is on {host_name}") -print("%s Initialising the simulator with %d thread(s)..." % ( - node_id, extra['threads'])) +print(f"{node_id} Initialising the simulator " + f"with {extra['threads']} thread(s)...") cell_params = {'tau_m': tau_m, 'tau_syn_E': tau_exc, @@ -155,7 +157,7 @@ timer.start() -print("%s Creating cell populations..." % node_id) +print(f"{ode_id} Creating cell populations...") exc_cells = p.Population( n_exc, celltype(**cell_params), label="Excitatory_Cells", seed=1) inh_cells = p.Population( @@ -170,12 +172,12 @@ ext_conn = p.FixedProbabilityConnector(rconn) ext_stim.record("spikes") -print("%s Initialising membrane potential to random values..." % node_id) +print(f"{node_id} Initialising membrane potential to random values...") uniformDistr = RandomDistribution('uniform', [v_reset, v_thresh]) exc_cells.initialize(v=uniformDistr) inh_cells.initialize(v=uniformDistr) -print("%s Connecting populations..." % node_id) +print(f"{node_id}Connecting populations...") exc_conn = p.FixedProbabilityConnector(pconn) inh_conn = p.FixedProbabilityConnector(pconn) @@ -204,13 +206,13 @@ synapse_type=p.StaticSynapse(weight=0.1)) # === Setup recording === -print("%s Setting up recording..." % node_id) +print(f"{node_id} Setting up recording...") exc_cells.record("spikes") buildCPUTime = timer.diff() # === Run simulation === -print("%d Running simulation..." % node_id) +print(f"{node_id} Running simulation...") print(f"timings: number of neurons: {n}") print(f"timings: number of synapses: {n * n * pconn}") @@ -236,15 +238,15 @@ if node_id == 0: print("\n--- Vogels-Abbott Network Simulation ---") - print("Nodes : %d" % np) - print("Simulation type : %s" % benchmark) - print("Number of Neurons : %d" % n) - print("Number of Synapses : %s" % connections) - print("Excitatory conductance : %g nS" % Gexc) - print("Inhibitory conductance : %g nS" % Ginh) - print("Build time : %g s" % buildCPUTime) - print("Simulation time : %g s" % simCPUTime) - print("Writing time : %g s" % writeCPUTime) + print(f"Nodes : {np}") + print(f"Simulation type : {benchmark}") + print(f"Number of Neurons : {n}") + print(f"Number of Synapses : {connections}") + print(f"Excitatory conductance : {Gexc} nS") + print(f"Inhibitory conductance : {Ginh} nS") + print(f"Build time : {buildCPUTime} s") + print(f"Simulation time : {simCPUTime} s") + print(f"Writing time : {writeCPUTime} s" ) # === Finished with simulator === diff --git a/learning/struct_pl_stdp.py b/learning/struct_pl_stdp.py index 934f04a..6513eb0 100755 --- a/learning/struct_pl_stdp.py +++ b/learning/struct_pl_stdp.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pyNN.utility.plotting as plot import matplotlib.pyplot as plt import numpy import pyNN.spiNNaker as sim +import pyNN.utility.plotting as plot n_neurons = 100 simtime = 5000 From 8e9f056550f1834a60d2e9b4eb5c6c11e429b291 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jun 2024 15:30:30 +0100 Subject: [PATCH 19/23] flake8 fixes --- examples/va_benchmark.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/va_benchmark.py b/examples/va_benchmark.py index 8b93f3d..d17e152 100644 --- a/examples/va_benchmark.py +++ b/examples/va_benchmark.py @@ -157,7 +157,7 @@ timer.start() -print(f"{ode_id} Creating cell populations...") +print(f"{node_id} Creating cell populations...") exc_cells = p.Population( n_exc, celltype(**cell_params), label="Excitatory_Cells", seed=1) inh_cells = p.Population( @@ -246,7 +246,7 @@ print(f"Inhibitory conductance : {Ginh} nS") print(f"Build time : {buildCPUTime} s") print(f"Simulation time : {simCPUTime} s") - print(f"Writing time : {writeCPUTime} s" ) + print(f"Writing time : {writeCPUTime} s") # === Finished with simulator === From 740fbbdf6b5dcb3dba9ce542006c4f2b68d30d07 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jun 2024 15:53:00 +0100 Subject: [PATCH 20/23] pylint fixes --- .../live_examples/spike_io.py | 2 +- .../spike_io_interactive_demo_with_c_vis.py | 2 +- .../external_devices_examples/retina_example.py | 5 +++++ .../IF_curr_exp_ca2_adaptive.py | 2 +- .../stdp_associative_memory.py | 4 ++-- examples/stdp_neuromodulated_example.py | 2 +- ...ity_with_stdp_neuromodulated_separate_pops.py | 16 +++++++++++++--- 7 files changed, 24 insertions(+), 9 deletions(-) diff --git a/examples/external_devices_examples/live_examples/spike_io.py b/examples/external_devices_examples/live_examples/spike_io.py index b01a4ac..6395e9f 100644 --- a/examples/external_devices_examples/live_examples/spike_io.py +++ b/examples/external_devices_examples/live_examples/spike_io.py @@ -13,9 +13,9 @@ # limitations under the License. import random -import pyNN.spiNNaker as Frontend import time from threading import Condition +import pyNN.spiNNaker as Frontend from pyNN.utility.plotting import Figure, Panel import matplotlib.pyplot as plt diff --git a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py index ba8500a..470c8f1 100644 --- a/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py +++ b/examples/external_devices_examples/live_examples/spike_io_interactive_demo_with_c_vis.py @@ -65,7 +65,7 @@ def __init__(self): live_spikes_connection_receive.add_receive_callback( "pop_backward", receive_spikes) - # different runtimes for demonstration purposes + # different run times for demonstration purposes run_time = None if not use_c_visualiser and not use_spike_injector: run_time = 1000 diff --git a/examples/external_devices_examples/retina_example.py b/examples/external_devices_examples/retina_example.py index 0ad0fb5..8f633ac 100644 --- a/examples/external_devices_examples/retina_example.py +++ b/examples/external_devices_examples/retina_example.py @@ -24,6 +24,11 @@ def get_updated_params(params): + """ + Adds extra values to the params + + :param dict params: + """ params.update(connected_chip_details) return params diff --git a/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py b/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py index 0b61677..ebf299a 100644 --- a/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py +++ b/examples/extra_models_examples/IF_curr_exp_ca2_adaptive.py @@ -80,7 +80,7 @@ # Split interspike intervals into separate array for each time bin time_binned_isis = [binned_isis[0, binned_isis[1] == t] for t in range(T)] -# Create a dictionary of non-empty time bins to mean interspike inverval +# Create a dictionary of non-empty time bins to mean interspike interval mean_isis = {t: numpy.average(i) for (t, i) in enumerate(time_binned_isis) if len(i) > 0} diff --git a/examples/extra_models_examples/stdp_associative_memory.py b/examples/extra_models_examples/stdp_associative_memory.py index c004c3a..69bafc1 100644 --- a/examples/extra_models_examples/stdp_associative_memory.py +++ b/examples/extra_models_examples/stdp_associative_memory.py @@ -100,8 +100,8 @@ arrayEntries = [] for i in range(nSourceNeurons): newEntry = [] - for j in range(len(spikes0)): - newEntry.append(spikes0[j] + i*40.0/100.0) + for spike in spikes0: + newEntry.append(spike + i*40.0/100.0) arrayEntries.append(newEntry) spikeArray = {'spike_times': arrayEntries} diff --git a/examples/stdp_neuromodulated_example.py b/examples/stdp_neuromodulated_example.py index 7358d69..70283e0 100644 --- a/examples/stdp_neuromodulated_example.py +++ b/examples/stdp_neuromodulated_example.py @@ -136,7 +136,7 @@ def plot_spikes(_spikes, _title, _n_neurons): pylab.plot(punishments, [0.5 for x in punishments], 'r^') pylab.show() -print("Weights(Initial %s)" % plastic_weights) +print("Weights(Initial {plastic_weights})") for x in weights: print(x) diff --git a/examples/structural_plasticity_with_stdp_neuromodulated_separate_pops.py b/examples/structural_plasticity_with_stdp_neuromodulated_separate_pops.py index 4cbbf4e..a98fbf1 100644 --- a/examples/structural_plasticity_with_stdp_neuromodulated_separate_pops.py +++ b/examples/structural_plasticity_with_stdp_neuromodulated_separate_pops.py @@ -85,7 +85,7 @@ # Structurally plastic connection between pre_pop and post_pop partner_selection_last_neuron = sim.RandomSelection() formation_distance = sim.DistanceDependentFormation( - grid=[np.sqrt(n_neurons), np.sqrt(n_neurons)], # spatial org of neurons + grid=[np.sqrt(n_neurons), np.sqrt(n_neurons)], # spatial neurons sigma_form_forward=1.0 # spread of feed-forward connections ) elimination_weight = sim.RandomByWeightElimination( @@ -129,7 +129,8 @@ cell_params, label='post')) mid_projections.append(sim.Projection( stimulation[i], mid_pops[i], - sim.FixedProbabilityConnector(0.0), # small number of initial conns + # small number of initial connections + sim.FixedProbabilityConnector(0.0), synapse_type=structure_model_with_stdp, label="stim-mid projection")) plastic_projections.append( @@ -157,6 +158,15 @@ def plot_spikes(_mid_spikes, _spikes, _title, _n_pops, _n_neurons): + """ + Creates a plot of the spikes if any received. + + :param list([int, quantity]) _mid_spikes: + :param list([int, quantity]) _spikes: + :param str _title: + :param iny _n_pops: + :param int _n_neurons: + """ if _spikes is not None: pylab.figure(figsize=(15, 5)) pylab.xlim((0, duration)) @@ -191,7 +201,7 @@ def plot_spikes(_mid_spikes, _spikes, _title, _n_pops, _n_neurons): pylab.plot(punishments, [0.5 for x in punishments], 'r^') pylab.show() -print("Weights(Initial %s)" % plastic_weights) +print("Weights(Initial {plastic_weights})") for x in weights: print(x) From 33ece7f7b3faf17b1abd117f26c4e9758c1d8754 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jun 2024 16:11:23 +0100 Subject: [PATCH 21/23] pylint fixes --- examples/stdp_example_cond.py | 8 ++++---- examples/stdp_example_get_plastic_params.py | 8 ++++---- examples/stdp_neuromodulated_example.py | 7 +++++++ examples/structural_plasticity_without_stdp_2d.py | 8 ++++---- examples/synfire_if_curr_exp_random.py | 4 ++-- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/examples/stdp_example_cond.py b/examples/stdp_example_cond.py index 3cc6113..224efb9 100644 --- a/examples/stdp_example_cond.py +++ b/examples/stdp_example_cond.py @@ -148,13 +148,13 @@ synapse_type=sim.StaticSynapse(weight=JEE * 0.001)) # Additional Inputs projections -for i in range(len(IAddPre)): +for iAddPre in IAddPre: sim.Projection( - IAddPre[i], pre_pop, ee_connector, receptor_type='excitatory', + iAddPre, pre_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE * 0.001)) -for i in range(len(IAddPost)): +for iAddPost in IAddPost: sim.Projection( - IAddPost[i], post_pop, ee_connector, receptor_type='excitatory', + iAddPost, post_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE * 0.001)) # Plastic Connections between pre_pop and post_pop diff --git a/examples/stdp_example_get_plastic_params.py b/examples/stdp_example_get_plastic_params.py index 6b26727..60b9d59 100644 --- a/examples/stdp_example_get_plastic_params.py +++ b/examples/stdp_example_get_plastic_params.py @@ -146,13 +146,13 @@ synapse_type=sim.StaticSynapse(weight=JEE * 0.05)) # Additional Inputs projections -for i in range(len(IAddPre)): +for iAddPre in IAddPre: sim.Projection( - IAddPre[i], pre_pop, ee_connector, receptor_type='excitatory', + iAddPre, pre_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE * 0.05)) -for i in range(len(IAddPost)): +for iAddPost in IAddPost: sim.Projection( - IAddPost[i], post_pop, ee_connector, receptor_type='excitatory', + iAddPost, post_pop, ee_connector, receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=JEE * 0.05)) # Plastic Connections between pre_pop and post_pop diff --git a/examples/stdp_neuromodulated_example.py b/examples/stdp_neuromodulated_example.py index 70283e0..640c70b 100644 --- a/examples/stdp_neuromodulated_example.py +++ b/examples/stdp_neuromodulated_example.py @@ -109,6 +109,13 @@ def plot_spikes(_spikes, _title, _n_neurons): + """ + Plots the spikes if there are any. + + :param list([int, quantity]) _spikes: + :param str _title: + :param int _n_neurons: + """ if _spikes is not None: pylab.figure(figsize=(15, 5)) pylab.xlim((0, duration)) diff --git a/examples/structural_plasticity_without_stdp_2d.py b/examples/structural_plasticity_without_stdp_2d.py index ae18c8f..fb7b0a4 100644 --- a/examples/structural_plasticity_without_stdp_2d.py +++ b/examples/structural_plasticity_without_stdp_2d.py @@ -159,14 +159,14 @@ synapse_type=sim.StaticSynapse(weight=jee * 0.05)) # Additional Inputs projections -for i in range(len(i_add_pre)): +for _i_add_pre in i_add_pre: sim.Projection( - i_add_pre[i], pre_pop, sim.OneToOneConnector(), + _i_add_pre, pre_pop, sim.OneToOneConnector(), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) -for i in range(len(i_add_post)): +for _i_add_post in i_add_post: sim.Projection( - i_add_post[i], post_pop, sim.OneToOneConnector(), + _i_add_post, post_pop, sim.OneToOneConnector(), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) diff --git a/examples/synfire_if_curr_exp_random.py b/examples/synfire_if_curr_exp_random.py index b5c818d..60b7837 100644 --- a/examples/synfire_if_curr_exp_random.py +++ b/examples/synfire_if_curr_exp_random.py @@ -15,11 +15,11 @@ """ Synfirechain-like example """ +import matplotlib.pyplot as plt +from pyNN.random import RandomDistribution import pyNN.spiNNaker as p from pyNN.utility.plotting import Figure, Panel -import matplotlib.pyplot as plt -from pyNN.random import RandomDistribution p.setup(timestep=1.0, min_delay=1.0) nNeurons = 200 # number of neurons in each population From d97355a130998a00991017c0c0462c88b927c8c6 Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 10 Jun 2024 16:17:35 +0100 Subject: [PATCH 22/23] pylint fixes --- .../structural_plasticity_with_stdp_neuromodulated.py | 2 +- examples/structural_plasticity_with_stdp_2d.py | 2 +- examples/structural_plasticity_without_stdp_2d.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py b/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py index fd5e044..93493b0 100644 --- a/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py +++ b/examples/split_examples/structural_plasticity_with_stdp_neuromodulated.py @@ -87,7 +87,7 @@ # Structurally plastic connection between pre_pop and post_pop partner_selection_last_neuron = sim.RandomSelection() formation_distance = sim.DistanceDependentFormation( - grid=[np.sqrt(n_neurons), np.sqrt(n_neurons)], # spatial org of neurons + grid=[np.sqrt(n_neurons), np.sqrt(n_neurons)], # spatial neurons sigma_form_forward=0.5 # spread of feed-forward connections ) elimination_weight = sim.RandomByWeightElimination( diff --git a/examples/structural_plasticity_with_stdp_2d.py b/examples/structural_plasticity_with_stdp_2d.py index 69d4acb..26ce42f 100644 --- a/examples/structural_plasticity_with_stdp_2d.py +++ b/examples/structural_plasticity_with_stdp_2d.py @@ -174,7 +174,7 @@ # Structurally plastic connection between pre_pop and post_pop partner_selection_last_neuron = sim.RandomSelection() formation_distance = sim.DistanceDependentFormation( - grid=[np.sqrt(pop_size), np.sqrt(pop_size)], # spatial org of neurons + grid=[np.sqrt(pop_size), np.sqrt(pop_size)], # spatial neurons sigma_form_forward=.5 # spread of feed-forward connections ) elimination_weight = sim.RandomByWeightElimination( diff --git a/examples/structural_plasticity_without_stdp_2d.py b/examples/structural_plasticity_without_stdp_2d.py index fb7b0a4..5f5d52f 100644 --- a/examples/structural_plasticity_without_stdp_2d.py +++ b/examples/structural_plasticity_without_stdp_2d.py @@ -173,7 +173,7 @@ # Structurally plastic connection between pre_pop and post_pop partner_selection_last_neuron = sim.RandomSelection() formation_distance = sim.DistanceDependentFormation( - grid=[np.sqrt(pop_size), np.sqrt(pop_size)], # spatial org of neurons + grid=[np.sqrt(pop_size), np.sqrt(pop_size)], # spatial neurons sigma_form_forward=.5 # spread of feed-forward connections ) elimination_weight = sim.RandomByWeightElimination( From f28b0a6218a923025f46f1f0735bbbefb37a84dc Mon Sep 17 00:00:00 2001 From: "Christian Y. Brenninkmeijer" Date: Mon, 8 Jul 2024 09:43:44 +0100 Subject: [PATCH 23/23] fix for loop --- examples/structural_plasticity_with_stdp_2d.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/structural_plasticity_with_stdp_2d.py b/examples/structural_plasticity_with_stdp_2d.py index 26ce42f..a84a836 100644 --- a/examples/structural_plasticity_with_stdp_2d.py +++ b/examples/structural_plasticity_with_stdp_2d.py @@ -164,7 +164,7 @@ _i_add_pre, pre_pop, sim.OneToOneConnector(), receptor_type='excitatory', synapse_type=sim.StaticSynapse(weight=jee * 0.05)) -for _i_add_post in range(len(i_add_post)): +for _i_add_post in i_add_post: sim.Projection( _i_add_post, post_pop, sim.OneToOneConnector(), receptor_type='excitatory',