Skip to content

Commit

Permalink
Merge pull request #2806 from nicolossus/port_issue_1305
Browse files Browse the repository at this point in the history
Port `issue-1305.sli` to Pytest
  • Loading branch information
heplesser authored Aug 8, 2023
2 parents 4229988 + a69e04f commit 1cf951e
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 63 deletions.
54 changes: 54 additions & 0 deletions testsuite/pytests/sli2py_regressions/test_issue_1305.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
#
# test_issue_1305.py
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

"""
Regression test for Issue #1305 (GitHub).
This set of tests ensures that NEST can set small resolutions and deals with
rounding errors correctly.
"""

import pytest

import nest


@pytest.fixture(autouse=True)
def reset():
nest.ResetKernel()


def test_resolution_rounding_valid():
"""Test setting valid resolution."""

target_resolution = 0.102
nest.set(resolution=target_resolution, tics_per_ms=1000.0)

assert nest.resolution == pytest.approx(target_resolution)


def test_resolution_rounding_invalid():
"""Test setting invalid resolution."""

target_resolution = 0.1002

with pytest.raises(nest.kernel.NESTError):
nest.set(resolution=target_resolution, tics_per_ms=1000.0)
63 changes: 0 additions & 63 deletions testsuite/regressiontests/issue-1305.sli

This file was deleted.

0 comments on commit 1cf951e

Please sign in to comment.