From 773dda4b9466f28f50257dbc8a574a5a1331d37e Mon Sep 17 00:00:00 2001 From: Robin Gutzen Date: Thu, 21 Dec 2023 11:44:47 +0100 Subject: [PATCH] V0.2.1 (#30) * update environment, change to pyproject.toml convention * update test and score list in readme * update environment * update environment --- LICENSE.txt | 4 +- MANIFEST.in | 6 --- README.rst | 51 ++++++++++--------- environment.yml | 2 - networkunit/VERSION | 2 +- networkunit/scores/best_effect_size.py | 6 ++- networkunit/scores/eigenangle.py | 7 ++- networkunit/tests/timescale_test.py | 2 +- pyproject.toml | 68 ++++++++++++++++++++++++++ requirements.txt | 10 ---- setup.py | 50 ++----------------- tox.ini | 22 +++++++++ 12 files changed, 136 insertions(+), 94 deletions(-) delete mode 100644 MANIFEST.in create mode 100644 pyproject.toml delete mode 100644 requirements.txt create mode 100644 tox.ini diff --git a/LICENSE.txt b/LICENSE.txt index 6138510..abe4507 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2018, NetworkUnit authors and contributors +Copyright (c) 2018-2023, NetworkUnit authors and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: @@ -7,4 +7,4 @@ Redistribution and use in source and binary forms, with or without modification, * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the names of the copyright holders nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission. -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 233463f..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,6 +0,0 @@ -# Include requirements -include requirement*.txt -include README.md -include LICENSE.txt -include AUTHORS.txt - diff --git a/README.rst b/README.rst index c2ee04c..196e558 100644 --- a/README.rst +++ b/README.rst @@ -58,53 +58,60 @@ accessible via the launch-binder button at the top. Overview of tests ----------------- -=================================== ======================= =================================================== +=================================== ======================= ====================================================== Class name Parent class Prediction measure -=================================== ======================= =================================================== +=================================== ======================= ====================================================== two_sample_test \- \- +firing_rate_test two_sample_test firing rates +isi_variation_test two_sample_test inter-spike-intervals, their CV, CV2, LV, or LVR +covariance_test two_sample_test covariances correlation_test two_sample_test \- correlation_dist_test correlation_test correlation coefficients correlation_matrix_test correlation_test correlation coefficient matrix +avg_std_correlation_test correlation_test avg or std of correlation coefficients generalized_correlation_matrix_test correlation_matrix_test matrix of derived cross-correlation measures eigenvalue_test correlation_test eigenvalues of the correlation coefficient matrix -covariance_test two_sample_test covariances -firing_rate_test two_sample_test firing rates -isi_variation_test two_sample_test inter-spike-intervals, their CV, or LV +power_spectrum_test two_sample_test power spectral density values +freqband_power_test power_spectrum_test power spectral density values in frequency band +timescale_test two_sample_test spike train timescale graph_centrality_helperclass sciunit.Test graph centrality measures of given adjacency matrix -=================================== ======================= =================================================== +joint_test two_sample_test joining other test classes for multivariate evaluation +=================================== ======================= ====================================================== Inheritance order in case of multiple inheritance for derived test classes: -.. code:: python +.. code:: Python - class new_test(sciunit.TestM2M, graph_centrality_helperclass, ) + class new_test(sciunit.TestM2M, graph_centrality_helperclass, ) Overview of scores ------------------ -================ =============================== =================== -Class name Test name Comparison measure -================ =============================== =================== -students_t Student't test sample mean -ks_distance Kolmogorov-Smirnov test sample distribution -kl_divergence Kullback-Leibler divergence sample entropy -mwu_statistic Mann-Whitney U test rank sum -levene_score Levene's test sample variance -effect_size Effect size standardized mean -best_effect_size Bayesian estimation effect size standardized mean -================ =============================== =================== +==================== =============================== =========================== +Class name Test name Comparison measure +==================== =============================== =========================== +students_t Student't test sample mean +ks_distance Kolmogorov-Smirnov test sample distribution +kl_divergence Kullback-Leibler divergence sample entropy +mwu_statistic Mann-Whitney U test rank sum +levene_score Levene's test sample variance +effect_size Effect size standardized mean +best_effect_size Bayesian estimation effect size standardized mean +wasserstein_distance Wasserstein Distance multivariate score distance +eigenangle Eigenangle Test eigenangle similarity +==================== =============================== =========================== Overview of model classes ------------------------- -=================== =================== =============== ================================== +=================== =================== ===================== ================================== Model name Capability Parent class Purpose -=================== =================== =============== ================================== +=================== =================== ===================== ================================== loaded_spiketrains ProducesSpikeTrains sciunit.RunnableModel loading simulated spiking data stochastic_activity ProducesSpikeTrains sciunit.RunnableModel generating stochastic spiking data nest_simulation ProducesSpikeTrains sciunit.RunnableModel template for NEST models -=================== =================== =============== ================================== +=================== =================== ===================== ================================== Other validation test repositories ---------------------------------- diff --git a/environment.yml b/environment.yml index 9b7e83c..9dce931 100644 --- a/environment.yml +++ b/environment.yml @@ -1,9 +1,7 @@ name: networkunit_env channels: - - damianavila82 - defaults dependencies: - - rise - pip - pip: - jupyter==1.0.0 diff --git a/networkunit/VERSION b/networkunit/VERSION index 3f69f33..0c62199 100644 --- a/networkunit/VERSION +++ b/networkunit/VERSION @@ -1 +1 @@ -0.2.0dev +0.2.1 diff --git a/networkunit/scores/best_effect_size.py b/networkunit/scores/best_effect_size.py index f355dd6..0355df9 100644 --- a/networkunit/scores/best_effect_size.py +++ b/networkunit/scores/best_effect_size.py @@ -1,3 +1,7 @@ +""" +The Baysian Estimation Effect Size is introduced in Kruschke, J. (2012) +doi:10.1037/a0029146 +""" from __future__ import division import numpy as np import sciunit @@ -16,8 +20,6 @@ class best_effect_size(sciunit.Score): """ Baysian Estimation Effect Size according to Kruschke, J. (2012) - 'Bayesian estimation supersedes the t-test', - Journal of Experimental Psychology Requires the test parameters: mcmc_iter : int (default 110000) diff --git a/networkunit/scores/eigenangle.py b/networkunit/scores/eigenangle.py index 93bea4f..4bfa204 100644 --- a/networkunit/scores/eigenangle.py +++ b/networkunit/scores/eigenangle.py @@ -1,6 +1,9 @@ +""" +The Eigenangle Test is introduced in Gutzen, GrĂ¼n, Denker (2023) +doi:10.1016/j.biosystems.2022.104813 +""" import numpy as np from scipy.linalg import eigh -from scipy.special import binom from scipy.integrate import quad import matplotlib.pyplot as plt import seaborn as sns @@ -18,7 +21,7 @@ class eigenangle(sciunit.Score): similar non-random elements by calculating the significance of the angles between the corresponding eigenvectors. Either the bin_size or the number of bins must be provides to perform the - signficnace test. + significance test. """ score = np.nan diff --git a/networkunit/tests/timescale_test.py b/networkunit/tests/timescale_test.py index 686cb88..334e874 100644 --- a/networkunit/tests/timescale_test.py +++ b/networkunit/tests/timescale_test.py @@ -44,7 +44,7 @@ def generate_prediction(self, model): def calc_timescales(self, spiketrain): if len(spiketrain.times) >= self.params['min_spikecount']: - bst = BinnedSpikeTrain(st, bin_size=self.params['bin_size']) + bst = BinnedSpikeTrain(spiketrain, bin_size=self.params['bin_size']) tau = timescale(bst, self.params['tau_max']) tau = tau.rescale('ms').magnitude else: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e191f46 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,68 @@ +[project] +name = "networkunit" +description = "A SciUnit library for validation testing of spiking networks." +version = "0.2.1" +readme = "README.rst" +authors = [ + { name = "NetworkUnit authors and contributors", email = "robin.gutzen@outlook.com" } +] + +requires-python = ">=3.8" +dependencies = [ + "nbconvert == 7.12.0", #remove when updating sciunit version + "sciunit == 0.2.7", + "elephant >= 0.7.0", + "neo >= 0.9", + "networkx >= 2.1", + "tabulate >= 0.8.2", + "seaborn >= 0.8.1", + "numpy >= 1.15.3", + "opencv-python" +] + +[metadata] +description-file = "README.md" +classifiers = [ + "Intended Audience :: Developers", + "License :: OSI Approved :: BSD-3-Clause", + "Programming Language :: Python :: 3", + "Topic :: Software Development :: Libraries :: Python Modules" +] + +[project.urls] +"Homepage" = "https://github.com/INM-6/networkunit" +"Bug Tracker" = "https://github.com/INM-6/networkunit/issues" + +[project.scripts] + +[project.optional-dependencies] +dev = [ + "black", + "bump2version", + "flake8", + "mypy", + "pre-commit", + "pydocstyle", + "pylint", + "pytest", + "pytest-black", + "pytest-cov", + "pytest-flake8", + "pytest-mypy", + "pytest-pydocstyle", + "pytest-pylint", + "pytest-xdist", +] +doc = [ + "sphinx", + "sphinx-autodoc-typehints", + "numpydoc>=1.1.0", + "sphinx-tabs>=1.3.0", + "sphinx-argparse>=0.4.0", + "pygments", + "recommonmark", +] + +[build-system] +build-backend = "flit_core.buildapi" +requires = ["flit_core >=3.2,<4"] diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 66a95cc..0000000 --- a/requirements.txt +++ /dev/null @@ -1,10 +0,0 @@ -elephant >= 0.7.0 -neo >= 0.9 -sciunit >= 0.2.2 -jupyter >= 1.0.0 -tabulate >= 0.8.2 -networkx >= 2.1 -seaborn >= 0.8.1 -numpy >= 1.15.3 -odml >= 1.3.0 -opencv-python diff --git a/setup.py b/setup.py index 94a248f..c7b5ce0 100644 --- a/setup.py +++ b/setup.py @@ -1,48 +1,6 @@ -# -*- coding: utf-8 -*- +# encoding: utf8 +'Packaging configuration.' -from setuptools import setup -import os -import sys +from setuptools import setup # type: ignore -long_description = open("README.rst").read() -with open('requirements.txt', 'r') as fp: - install_requires = fp.read() -extras_require = {} -for extra in ['docs']: - with open('requirements-{0}.txt'.format(extra)) as fp: - extras_require[extra] = fp.read() - -setup( - name="networkunit", - version='0.2.0', - packages=['networkunit', 'figures', 'examples'], - package_data={'networkunit':[ - os.path.join('tests','*.py'), - os.path.join('models','*.py'), - os.path.join('models/backends','*.py'), - os.path.join('capabilities','*.py'), - os.path.join('scores','*.py'), - os.path.join('plots','*.py'), - 'VERSION'], - 'figures':['*.png'], - 'examples':['*.py', '*.ipynb'] - }, - install_requires=install_requires, - extras_require=extras_require, - - author="NetworkUnit authors and contributors", - author_email="r.gutzen@fz-juelich.de", - description="A SciUnit library for validation testing of neural network models.", - long_description=long_description, - license="BSD", - url='https://github.com/INM-6/NetworkUnit', - classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Natural Language :: English', - 'Operating System :: OS Independent', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 3', - 'Topic :: Scientific/Engineering'] -) +setup() # everything configured via pyproject.toml diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..8e057ea --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[pytest] +addopts = -n 0 --doctest-modules --pycodestyle --mypy --pylint --pylint-rcfile=.pylintrc --pydocstyle --cov --ignore=conda --ignore=env --ignore=.git --ignore=__pycache__ + +[pycodestyle] +count = False +#ignore = E226,E302,E41 +exclude = .git/, .snakemake/, .pytest_cache/, sync-test-env/, conda/, env/ +max-line-length = 120 +statistics = True + +# as suggested by pylint docs for joint usage with other tools +# http://pylint.pycqa.org/en/latest/faq.html?highlight=pylintrc#i-am-using-another-popular-linter-alongside-pylint-which-messages-should-i-disable-to-avoid-duplicates + +[pylint] +options = unneeded-not, line-too-long, unnecessary-semicolon, trailing-whitespace, missing-final-newline, bad-indentation, multiple-statements, bare-except + +[pydocstyle] +convention = numpy +add-ignore = D300 + +[mypy] +exclude = .git/, .snakemake/, .pytest_cache/, sync-test-env/, conda/, env/