Skip to content

Commit

Permalink
Initial version of rng and seed fixtures
Browse files Browse the repository at this point in the history
This is similar to what we had in Nengo core, except:

- We use a `salt` string instead of a `seed-offset` integer.
  Strings are easier to work with than integers.
- We now have a full test suite. It uses pytest's cache fixture,
  so when running the fixture tests manually, pytest has to be run
  twice. Normally tests would be run with test_pytest.py, which
  runs the test suite twice.

Co-authored-by: Trevor Bekolay <tbekolay@gmail.com>
  • Loading branch information
hunse and tbekolay committed Aug 8, 2019
1 parent 2e7bfb4 commit e4dd353
Show file tree
Hide file tree
Showing 26 changed files with 1,061 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Automatically generated by nengo-bones, do not edit this file directly

codecov:
ci:
- "!ci.appveyor.com"
notify:
require_ci_to_pass: no

coverage:
status:
project:
default:
enabled: yes
target: auto
patch:
default:
enabled: yes
target: 100%
changes: no
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
*.py[co]
.DS_Store
_build
build
dist
*.egg-info
*~
*.bak
*.swp
log.txt
.ipynb_checkpoints/
.cache
.tox
.vagrant
wintest.sh
Vagrantfile
*.class
*.eggs/
.coverage
htmlcov
*.dist-info/
.vscode
.idea
.pytest_cache/

.ci/*.sh
12 changes: 12 additions & 0 deletions .gitlint
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[general]
ignore=body-is-missing

[title-max-length]
line-length=50

[B1]
# body line length
line-length=72

[title-match-regex]
regex=^[A-Z]
78 changes: 78 additions & 0 deletions .nengobones.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
project_name: pytest-rng
pkg_name: pytest_rng
repo_name: nengo/pytest-rng
description: Fixtures for seeding tests and making randomness reproducible

copyright_start: 2019

license_rst:
type: mit

contributing_rst: {}

contributors_rst: {}

manifest_in: {}

setup_py:
license: MIT license
python_requires: ">=3.5"
install_req:
- numpy
- pytest
docs_req:
- nengo_sphinx_theme>=1.0
- sphinx
entry_points:
pytest11:
- "rng = pytest_rng.plugin"
classifiers:
- "Development Status :: 5 - Production/Stable"
- "Framework :: Pytest"
- "License :: OSI Approved :: MIT License"
- "Programming Language :: Python :: 3 :: Only"
- "Programming Language :: Python :: 3.5"
- "Programming Language :: Python :: 3.6"
- "Programming Language :: Python :: 3.7"

setup_cfg:
pytest:
addopts: []
filterwarnings:
- ignore:testdir.copy_example is an experimental api
rng_salt: v1.0.0
pytester_example_dir: pytest_rng/tests
python_files: test_pytest.py
pylint:
disable:
- missing-docstring

docs_conf_py:
nengo_logo: general-small-light.svg

travis_yml:
python: 3.6
jobs:
- script: static
- script: test-coverage
- script: test
python: 3.5
cache: false # disable the cache for one build to make sure that works
- script: test
python: 3.7
dist: xenial # currently only xenial has python 3.7
- script: docs

ci_scripts:
- template: static
- template: test
- template: test
output_name: test-coverage
coverage: true
- template: docs

codecov_yml: {}

pre_commit_config_yaml: {}

pyproject_toml: {}
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Automatically generated by nengo-bones, do not edit this file directly

repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
7 changes: 7 additions & 0 deletions .templates/setup.cfg.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends "templates/setup.cfg.template" %}
{% block pytest %}
{{ super() }}
pytester_example_dir = {{ pytest.pytester_example_dir }}
python_files = {{ pytest.python_files }}
{% endblock %}
97 changes: 97 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Automatically generated by nengo-bones, do not edit this file directly

language: python
python: 3.6
notifications:
email:
on_success: change
on_failure: change
cache: pip

dist: trusty

env:
global:
- SCRIPT="test"
- TEST_ARGS=""
- COV_CORE_SOURCE=pytest_rng # early start pytest-cov engine
- COV_CORE_CONFIG=.coveragerc
- COV_CORE_DATAFILE=.coverage.eager
- BRANCH_NAME="${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}"

jobs:
include:
-
env:
SCRIPT="static"
-
env:
SCRIPT="test-coverage"
-
env:
SCRIPT="test"
python: 3.5
cache: False
-
env:
SCRIPT="test"
python: 3.7
dist: xenial
-
env:
SCRIPT="docs"
addons:
apt:
packages:
- pandoc

before_install:
# export travis_terminate for use in scripts
- export -f travis_terminate
_travis_terminate_linux
_travis_terminate_osx
_travis_terminate_unix
_travis_terminate_windows
# upgrade pip
- pip install pip --upgrade
# install/run nengo-bones
- pip install nengo-bones
- bones-generate --output-dir .ci ci-scripts
- if [[ "$TRAVIS_PYTHON_VERSION" < "3.6" ]]; then
echo "Skipping bones-check because Python $TRAVIS_PYTHON_VERSION < 3.6";
else
bones-check;
fi
# display environment info
- pip freeze

install:
- .ci/$SCRIPT.sh install
- pip freeze

after_install:
- .ci/$SCRIPT.sh after_install

before_script:
- .ci/$SCRIPT.sh before_script

script:
- .ci/$SCRIPT.sh script

before_cache:
- .ci/$SCRIPT.sh before_cache

after_success:
- .ci/$SCRIPT.sh after_success

after_failure:
- .ci/$SCRIPT.sh after_failure

before_deploy:
- .ci/$SCRIPT.sh before_deploy

after_deploy:
- .ci/$SCRIPT.sh after_deploy

after_script:
- .ci/$SCRIPT.sh after_script
26 changes: 26 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
***************
Release History
***************

.. Changelog entries should follow this format:
version (release date)
======================
**section**
- One-line description of change (link to Github issue/PR)
.. Changes should be organized in one of several sections:
- Added
- Changed
- Deprecated
- Removed
- Fixed
1.0.0 (unreleased)
==================

Initial release of ``pytest-rng``!
Thanks to all of the contributors for making this possible!
46 changes: 46 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. Automatically generated by nengo-bones, do not edit this file directly
**************************
Contributing to pytest-rng
**************************

Issues and pull requests are always welcome!
We appreciate help from the community to make pytest-rng better.

Filing issues
=============

If you find a bug in pytest-rng,
or think that a certain feature is missing,
please consider
`filing an issue <https://github.com/nengo/pytest-rng/issues>`_!
Please search the currently open issues first
to see if your bug or feature request already exists.
If so, feel free to add a comment to the issue
so that we know that multiple people are affected.

Making pull requests
====================

If you want to fix a bug or add a feature to pytest-rng,
we welcome pull requests.
Ensure that you fill out all sections of the pull request template,
deleting the comments as you go.
We check most aspects of code style automatically.
Please refer to our
`code style guide <https://www.nengo.ai/nengo-bones/style.html>`_
for things that we check manually.

Contributor agreement
=====================

We require that all contributions be covered under
our contributor assignment agreement. Please see
`the agreement <https://www.nengo.ai/caa/>`_
for instructions on how to sign.

More details
============

For more details on how to contribute to Nengo,
please see the `developer guide <https://www.nengo.ai/contributing/>`_.
9 changes: 9 additions & 0 deletions CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. Automatically generated by nengo-bones, do not edit this file directly
***********************
pytest-rng contributors
***********************

See https://github.com/nengo/pytest-rng/graphs/contributors
for a list of the people who have committed to pytest-rng.
Thank you for your contributions!
29 changes: 29 additions & 0 deletions LICENSE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.. Automatically generated by nengo-bones, do not edit this file directly
******************
pytest-rng license
******************

MIT License

Copyright (c) 2019-2019 Applied Brain Research

Permission is hereby granted, free of charge,
to any person obtaining a copy of this software
and associated documentation files (the "Software"),
to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit e4dd353

Please sign in to comment.