示例#1
0
    def test_amplitude(self):
        """ Test that the output of ``biexponential`` is at most ``amp1 + amp2``. """
        t = np.arange(-10, 50, step=0.3)
        I = biexponential(
            t,
            tzero=self.tzero,
            amp1=self.amp1,
            amp2=self.amp2,
            tconst1=self.tconst1,
            tconst2=self.tconst2,
        )

        self.assertTrue(np.all(np.less_equal(I, self.amp1 + self.amp2)))
示例#2
0
    def test_positivity(self):
        """ Test that the output of ``biexponential`` is always positive. """
        t = np.arange(-10, 50, step=0.3)
        I = biexponential(
            t,
            tzero=self.tzero,
            amp1=self.amp1,
            amp2=self.amp2,
            tconst1=self.tconst1,
            tconst2=self.tconst2,
        )

        self.assertTrue(np.all(I > 0))
示例#3
0
def test_biexponential_against_exponential():
    """ Test that ``biexponential`` reduces to ``exponential`` for appropriate parameters """
    tzero = 10 * (random() - 0.5)  # between -5 and 5
    amp1 = 5 * random() + 5  # between 5 and 10
    tconst1 = random() + 0.3  # between 0.3 and 1.3
    amp2 = 5 * random() + 5  # between 5 and 10
    tconst2 = random() + 0.3  # between 0.3 and 1.3

    t = np.arange(-10, 50, step=0.3)
    offset = 2
    exp = exponential(t, tzero, amp1, tconst1, offset=offset)
    biexp = biexponential(t, tzero, amp1, 0, tconst1, 1, offset=offset)

    assert np.allclose(exp, biexp)
示例#4
0
    def test_offset(self):
        """ Test that the output of ``biexponential`` is at least ``offset``. """
        offset = 15
        t = np.arange(-10, 50, step=0.3)
        I = biexponential(
            t,
            tzero=self.tzero,
            amp1=self.amp1,
            amp2=self.amp2,
            tconst1=self.tconst1,
            tconst2=self.tconst2,
            offset=offset,
        )

        self.assertTrue(np.all(np.greater_equal(I, offset)))
示例#5
0
    def test_tzero_limits(self):
        """ Test that the output of ``biexponential`` has the correct time-zero """
        t = np.arange(-10, 50, step=0.3)
        I = biexponential(
            t,
            tzero=self.tzero,
            amp1=self.amp1,
            amp2=self.amp2,
            tconst1=self.tconst1,
            tconst2=self.tconst2,
        )

        # Check that all values before time-zero are the amplitude
        self.assertTrue(
            np.all(np.equal(I[t < self.tzero], self.amp1 + self.amp2)))
        self.assertTrue(
            np.all(np.less(I[t > self.tzero], self.amp1 + self.amp2)))
示例#6
0
    def test_against_exponential(self):
        """ Test that ``biexponential`` reduces to ``exponential`` for appropriate parameters """
        t = np.arange(-10, 50, step=0.3)
        offset = 2
        exp = exponential(t,
                          self.tzero,
                          self.amp1,
                          self.tconst1,
                          offset=offset)
        biexp = biexponential(t,
                              self.tzero,
                              self.amp1,
                              0,
                              self.tconst1,
                              1,
                              offset=offset)

        self.assertTrue(np.allclose(exp, biexp))
示例#7
0
def test_biexponential_positivity():
    """ Test that the output of ``biexponential`` is always positive. """
    tzero = 10 * (random() - 0.5)  # between -5 and 5
    amp1 = 5 * random() + 5  # between 5 and 10
    tconst1 = random() + 0.3  # between 0.3 and 1.3
    amp2 = 5 * random() + 5  # between 5 and 10
    tconst2 = random() + 0.3  # between 0.3 and 1.3

    t = np.arange(-10, 50, step=0.3)
    I = biexponential(
        t,
        tzero=tzero,
        amp1=amp1,
        amp2=amp2,
        tconst1=tconst1,
        tconst2=tconst2,
    )

    assert np.all(I > 0)
示例#8
0
def test_biexponential_amplitude():
    """ Test that the output of ``biexponential`` is at most ``amp1 + amp2``. """
    tzero = 10 * (random() - 0.5)  # between -5 and 5
    amp1 = 5 * random() + 5  # between 5 and 10
    tconst1 = random() + 0.3  # between 0.3 and 1.3
    amp2 = 5 * random() + 5  # between 5 and 10
    tconst2 = random() + 0.3  # between 0.3 and 1.3

    t = np.arange(-10, 50, step=0.3)
    I = biexponential(
        t,
        tzero=tzero,
        amp1=amp1,
        amp2=amp2,
        tconst1=tconst1,
        tconst2=tconst2,
    )

    assert np.all(np.less_equal(I, amp1 + amp2))
示例#9
0
def test_biexponential_tzero_limits():
    """ Test that the output of ``biexponential`` has the correct time-zero """
    tzero = 10 * (random() - 0.5)  # between -5 and 5
    amp1 = 5 * random() + 5  # between 5 and 10
    tconst1 = random() + 0.3  # between 0.3 and 1.3
    amp2 = 5 * random() + 5  # between 5 and 10
    tconst2 = random() + 0.3  # between 0.3 and 1.3

    t = np.arange(-10, 50, step=0.3)
    I = biexponential(
        t,
        tzero=tzero,
        amp1=amp1,
        amp2=amp2,
        tconst1=tconst1,
        tconst2=tconst2,
    )

    # Check that all values before time-zero are the amplitude
    assert np.all(np.equal(I[t < tzero], amp1 + amp2))
    assert np.all(np.less(I[t > tzero], amp1 + amp2))
示例#10
0
def test_biexponential_offset():
    """ Test that the output of ``biexponential`` is at least ``offset``. """
    tzero = 10 * (random() - 0.5)  # between -5 and 5
    amp1 = 5 * random() + 5  # between 5 and 10
    tconst1 = random() + 0.3  # between 0.3 and 1.3
    amp2 = 5 * random() + 5  # between 5 and 10
    tconst2 = random() + 0.3  # between 0.3 and 1.3

    offset = 15
    t = np.arange(-10, 50, step=0.3)
    I = biexponential(
        t,
        tzero=tzero,
        amp1=amp1,
        amp2=amp2,
        tconst1=tconst1,
        tconst2=tconst2,
        offset=offset,
    )

    assert np.all(np.greater_equal(I, offset))