Skip to content

Commit

Permalink
Make lti tests less verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
befelix committed May 7, 2015
1 parent d0afc2d commit 176f38e
Showing 1 changed file with 17 additions and 32 deletions.
49 changes: 17 additions & 32 deletions scipy/signal/tests/test_ltisys.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,13 +642,10 @@ def test_complex_input(self):


class TestLti(object):
"""Test the lti base class"""
def test_lti_instantiation(self):
"""
Test that lti can be instantiated with sequences, scalars.
# Test that lti can be instantiated with sequences, scalars.
# See PR-225.

See PR-225.
"""
# TransferFunction
s = lti([1], [-1])
assert_(isinstance(s, TransferFunction))
Expand All @@ -667,24 +664,22 @@ def test_lti_instantiation(self):


class TestStateSpace(object):
"""Test StateSpace class"""

def test_initialization(self):
"""Check that all initializations work"""
# Check that all initializations work
s = StateSpace(1, 1, 1, 1)
s = StateSpace([1], [2], [3], [4])
s = StateSpace(np.array([[1, 2], [3, 4]]), np.array([[1], [2]]),
np.array([[1, 0]]), np.array([[0]]))

def _compare_systems(self, sys1, sys2):
"""Compare the contents of two systems"""
# Compare the contents of two systems
assert_equal(sys1.A, sys2.A)
assert_equal(sys1.B, sys2.B)
assert_equal(sys1.C, sys2.C)
assert_equal(sys1.D, sys2.D)

def test_conversion(self):
"""Check the conversion functions"""
# Check the conversion functions
s = StateSpace(1, 2, 3, 4)
assert_(isinstance(s.to_ss(), StateSpace))
assert_(isinstance(s.to_tf(), TransferFunction))
Expand All @@ -695,11 +690,9 @@ def test_conversion(self):
assert_(s.to_ss() is not s)

def test_properties(self):
"""
Test setters/getters for cross class properties.
# Test setters/getters for cross class properties.
# This implicitly tests to_tf() and to_zpk()

This implicitly tests to_tf() and to_zpk()
"""
# Getters
s = StateSpace(1, 1, 1, 1)
assert_equal(s.num, [1, 0])
Expand All @@ -723,21 +716,19 @@ def test_properties(self):


class TestTransferFunction(object):
"""Test TransferFunction class"""

def test_initialization(self):
"""Check that all initializations work"""
# Check that all initializations work
s = TransferFunction(1, 1)
s = TransferFunction([1], [2])
s = TransferFunction(np.array([1]), np.array([2]))

def _compare_systems(self, sys1, sys2):
"""Compare the contents of two systems"""
# Compare the contents of two systems
assert_equal(sys1.num, sys2.num)
assert_equal(sys1.den, sys2.den)

def test_conversion(self):
"""Check the conversion functions"""
# Check the conversion functions
s = TransferFunction([1, 0], [1, -1])
assert_(isinstance(s.to_ss(), StateSpace))
assert_(isinstance(s.to_tf(), TransferFunction))
Expand All @@ -748,11 +739,9 @@ def test_conversion(self):
assert_(s.to_tf() is not s)

def test_properties(self):
"""
Test setters/getters for cross class properties.
# Test setters/getters for cross class properties.
# This implicitly tests to_ss() and to_zpk()

This implicitly tests to_ss() and to_zpk()
"""
# Getters
s = TransferFunction([1, 0], [1, -1])
assert_equal(s.poles, [1])
Expand Down Expand Up @@ -780,22 +769,20 @@ def test_properties(self):


class TestZerosPolesGain(object):
"""Test ZerosPolesGain class"""

def test_initialization(self):
"""Check that all initializations work"""
# Check that all initializations work
s = ZerosPolesGain(1, 1, 1)
s = ZerosPolesGain([1], [2], 1)
s = ZerosPolesGain(np.array([1]), np.array([2]), 1)

def _compare_systems(self, sys1, sys2):
"""Compare the contents of two systems"""
#Compare the contents of two systems
assert_equal(sys1.poles, sys2.poles)
assert_equal(sys1.zeros, sys2.zeros)
assert_equal(sys1.gain, sys2.gain)

def test_conversion(self):
"""Check the conversion functions"""
#Check the conversion functions
s = ZerosPolesGain(1, 2, 3)
assert_(isinstance(s.to_ss(), StateSpace))
assert_(isinstance(s.to_tf(), TransferFunction))
Expand All @@ -806,11 +793,9 @@ def test_conversion(self):
assert_(s.to_zpk() is not s)

def test_properties(self):
"""
Test setters/getters for cross class properties.
# Test setters/getters for cross class properties.
# This implicitly tests to_ss() and to_tf()

This implicitly tests to_ss() and to_tf()
"""
# Getters
s = ZerosPolesGain(0, 1, 1)
assert_equal(s.num, [1, 0])
Expand Down

0 comments on commit 176f38e

Please sign in to comment.