numpy.logspace

Here are the examples of the python api numpy.logspace taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

129 Examples 7

Example 1

Project: python-control
Source File: frd_test.py
View license
    def testSISOtf(self):
        # get a SISO transfer function
        h = TransferFunction([1], [1, 2, 2])
        omega = np.logspace(-1, 2, 10)
        frd = FRD(h, omega)
        assert isinstance(frd, FRD)

        np.testing.assert_array_almost_equal(
            frd.freqresp([1.0]), h.freqresp([1.0]))

Example 2

Project: python-acoustics
Source File: test_octave.py
View license
    def test_interval(self):
        emin = 1.0
        emax = 4.0
        f = np.logspace(emin, emax, 50)
        
        o = Octave(interval=f)
        
        
        assert(o.fmin == 10.0**emin)
        assert(o.fmax == 10.0**emax)
        assert(len(o.n) == len(o.center))
        
        o.unique = True
        assert( len(o.n) == len(f) )

Example 3

Project: python-control
Source File: frd_test.py
View license
    def testFeedback(self):
        h1 = TransferFunction([1], [1, 2, 2])
        omega = np.logspace(-1, 2, 10)
        f1 = FRD(h1, omega)
        np.testing.assert_array_almost_equal(
            f1.feedback(1).freqresp([0.1, 1.0, 10])[0],
            h1.feedback(1).freqresp([0.1, 1.0, 10])[0])

        # Make sure default argument also works
        np.testing.assert_array_almost_equal(
            f1.feedback().freqresp([0.1, 1.0, 10])[0],
            h1.feedback().freqresp([0.1, 1.0, 10])[0])

Example 4

Project: python-control
Source File: frd_test.py
View license
    def testAuto(self):
        omega = np.logspace(-1, 2, 10)
        f1 = _convertToFRD(1, omega)
        f2 = _convertToFRD(np.matrix([[1, 0], [0.1, -1]]), omega)
        f2 = _convertToFRD([[1, 0], [0.1, -1]], omega)
        f1, f2  # reference to avoid pyflakes error

Example 5

Project: python-control
Source File: frd_test.py
View license
    def testNyquist(self):
        h1 = TransferFunction([1], [1, 2, 2])
        omega = np.logspace(-1, 2, 40)
        f1 = FRD(h1, omega, smooth=True)
        freqplot.nyquist(f1, np.logspace(-1, 2, 100))
        # plt.savefig('/dev/null', format='svg')
        plt.figure(2)
        freqplot.nyquist(f1, f1.omega)

Example 6

Project: python-control
Source File: frd_test.py
View license
    def testMIMO(self):
        sys = StateSpace([[-0.5, 0.0], [0.0, -1.0]],
                         [[1.0, 0.0], [0.0, 1.0]],
                         [[1.0, 0.0], [0.0, 1.0]],
                         [[0.0, 0.0], [0.0, 0.0]])
        omega = np.logspace(-1, 2, 10)
        f1 = FRD(sys, omega)
        np.testing.assert_array_almost_equal(
            sys.freqresp([0.1, 1.0, 10])[0],
            f1.freqresp([0.1, 1.0, 10])[0])
        np.testing.assert_array_almost_equal(
            sys.freqresp([0.1, 1.0, 10])[1],
            f1.freqresp([0.1, 1.0, 10])[1])

Example 7

Project: python-control
Source File: frd_test.py
View license
    def testMIMOfb(self):
        sys = StateSpace([[-0.5, 0.0], [0.0, -1.0]],
                         [[1.0, 0.0], [0.0, 1.0]],
                         [[1.0, 0.0], [0.0, 1.0]],
                         [[0.0, 0.0], [0.0, 0.0]])
        omega = np.logspace(-1, 2, 10)
        f1 = FRD(sys, omega).feedback([[0.1, 0.3], [0.0, 1.0]])
        f2 = FRD(sys.feedback([[0.1, 0.3], [0.0, 1.0]]), omega)
        np.testing.assert_array_almost_equal(
            f1.freqresp([0.1, 1.0, 10])[0],
            f2.freqresp([0.1, 1.0, 10])[0])
        np.testing.assert_array_almost_equal(
            f1.freqresp([0.1, 1.0, 10])[1],
            f2.freqresp([0.1, 1.0, 10])[1])

Example 8

Project: python-control
Source File: frd_test.py
View license
    def testMIMOMult(self):
        sys = StateSpace([[-0.5, 0.0], [0.0, -1.0]],
                         [[1.0, 0.0], [0.0, 1.0]],
                         [[1.0, 0.0], [0.0, 1.0]],
                         [[0.0, 0.0], [0.0, 0.0]])
        omega = np.logspace(-1, 2, 10)
        f1 = FRD(sys, omega)
        f2 = FRD(sys, omega)
        np.testing.assert_array_almost_equal(
            (f1*f2).freqresp([0.1, 1.0, 10])[0],
            (sys*sys).freqresp([0.1, 1.0, 10])[0])
        np.testing.assert_array_almost_equal(
            (f1*f2).freqresp([0.1, 1.0, 10])[1],
            (sys*sys).freqresp([0.1, 1.0, 10])[1])

Example 9

Project: python-control
Source File: margin_test.py
View license
    def test_stability_margins(self):
        omega = np.logspace(-2, 2, 2000)
        for sys,rgm,rwgm,rpm,rwpm in self.tsys:
            print(sys)
            out = np.array(stability_margins(sys))
            gm, pm, sm, wg, wp, ws = out
            outf = np.array(stability_margins(FRD(sys, omega)))
            print(out,'\n', outf)
            print(out != np.array(None))
            np.testing.assert_array_almost_equal(
                out[out != np.array(None)],
                outf[outf != np.array(None)], 2)
            
        # final one with fixed values
        np.testing.assert_array_almost_equal(
            [gm, pm, sm, wg, wp, ws],
            self.stability_margins4, 3)

Example 10

Project: python-control
Source File: margin_test.py
View license
    def test_mag_phase_omega(self):
        # test for bug reported in gh-58
        sys = TransferFunction(15, [1, 6, 11, 6])
        out = stability_margins(sys)
        omega = np.logspace(-2,2,1000)
        mag, phase, omega = sys.freqresp(omega)
        #print( mag, phase, omega)
        out2 = stability_margins((mag, phase*180/np.pi, omega))
        ind = [0,1,3,4]   # indices of gm, pm, wg, wp -- ignore sm
        marg1 = np.array(out)[ind]
        marg2 = np.array(out2)[ind]
        np.testing.assert_array_almost_equal(marg1, marg2, 4)

Example 11

Project: python-control
Source File: margin_test.py
View license
    def test_nocross(self):
        # what happens when no gain/phase crossover?
        s = TransferFunction([1, 0], [1])
        h1 = 1/(1+s)
        h2 = 3*(10+s)/(2+s)
        h3 = 0.01*(10-s)/(2+s)/(1+s)
        gm, pm, wm, wg, wp, ws = stability_margins(h1)
        self.assertEqual(gm, None)
        self.assertEqual(wg, None)
        gm, pm, wm, wg, wp, ws = stability_margins(h2)
        self.assertEqual(pm, None)
        gm, pm, wm, wg, wp, ws = stability_margins(h3)
        self.assertEqual(pm, None)
        omega = np.logspace(-2,2, 100)
        out1b = stability_margins(FRD(h1, omega))
        out2b = stability_margins(FRD(h2, omega))
        out3b = stability_margins(FRD(h3, omega))

Example 12

Project: python-control
Source File: matlab_test.py
View license
    def testFRD(self):
        h = tf([1], [1, 2, 2])
        omega = np.logspace(-1, 2, 10)
        frd1 = frd(h, omega)
        assert isinstance(frd1, FRD)
        frd2 = frd(frd1.fresp[0,0,:], omega)
        assert isinstance(frd2, FRD)

Example 13

Project: scikit-learn
Source File: test_online_lda.py
View license
def test_dirichlet_expectation():
    """Test Cython version of Dirichlet expectation calculation."""
    x = np.logspace(-100, 10, 10000)
    expectation = np.empty_like(x)
    _dirichlet_expectation_1d(x, 0, expectation)
    assert_allclose(expectation, np.exp(psi(x) - psi(np.sum(x))),
                    atol=1e-19)

    x = x.reshape(100, 100)
    assert_allclose(_dirichlet_expectation_2d(x),
                    psi(x) - psi(np.sum(x, axis=1)[:, np.newaxis]),
                    rtol=1e-11, atol=3e-9)

Example 14

Project: scipy
Source File: test_ltisys.py
View license
    def test_05(self):
        # Test that bode() finds a reasonable frequency range.
        # 1st order low-pass filter: H(s) = 1 / (s + 1)
        system = lti([1], [1, 1])
        n = 10
        # Expected range is from 0.01 to 10.
        expected_w = np.logspace(-2, 1, n)
        w, mag, phase = bode(system, n=n)
        assert_almost_equal(w, expected_w)

Example 15

Project: scipy
Source File: test_ltisys.py
View license
    def test_freq_range(self):
        # Test that freqresp() finds a reasonable frequency range.
        # 1st order low-pass filter: H(s) = 1 / (s + 1)
        # Expected range is from 0.01 to 10.
        system = lti([1], [1, 1])
        n = 10
        expected_w = np.logspace(-2, 1, n)
        w, H = freqresp(system, n=n)
        assert_almost_equal(w, expected_w)

Example 16

Project: scipy
Source File: test_digamma.py
View license
def test_consistency():
    # Make sure the implementation of digamma for real arguments
    # agrees with the implementation of digamma for complex arguments.

    # It's all poles after -1e16
    x = np.r_[-np.logspace(15, -30, 200), np.logspace(-30, 300, 200)]
    dataset = np.vstack((x + 0j, digamma(x))).T
    FuncData(digamma, dataset, 0, 1, rtol=5e-14, nan_ok=True).check()

Example 17

Project: scipy
Source File: test_loggamma.py
View license
def test_realpart():
    # Test that the real parts of loggamma and gammaln agree on the
    # real axis.
    x = np.r_[-np.logspace(10, -10), np.logspace(-10, 10)] + 0.5
    dataset = np.vstack((x, gammaln(x))).T

    def f(z):
        return loggamma(z).real
    
    FuncData(f, dataset, 0, 1, rtol=1e-14, atol=1e-14).check()

Example 18

Project: scipy
Source File: test_loggamma.py
View license
def test_branch_cut():
    # Make sure negative zero is treated correctly
    x = -np.logspace(300, -30, 100)
    z = np.asarray([complex(x0, 0.0) for x0 in x])
    zbar = np.asarray([complex(x0, -0.0) for x0 in x])
    assert_allclose(z, zbar.conjugate(), rtol=1e-15, atol=0)

Example 19

Project: scipy
Source File: test_sici.py
View license
def test_sici_consistency():
    # Make sure the implementation of sici for real arguments agrees
    # with the implementation of sici for complex arguments.

    # On the negative real axis Cephes drops the imaginary part in ci
    def sici(x):
        si, ci = sc.sici(x + 0j)
        return si.real, ci.real
    
    x = np.r_[-np.logspace(8, -30, 200), 0, np.logspace(-30, 8, 200)]
    si, ci = sc.sici(x)
    dataset = np.column_stack((x, si, ci))
    FuncData(sici, dataset, 0, (1, 2), rtol=1e-12).check()

Example 20

Project: scipy
Source File: test_spence.py
View license
def test_consistency():
    # Make sure the implementation of spence for real arguments
    # agrees with the implementation of spence for imaginary arguments.

    x = np.logspace(-30, 300, 200)
    dataset = np.vstack((x + 0j, spence(x))).T
    FuncData(spence, dataset, 0, 1, rtol=1e-14).check()

Example 21

Project: simpeg
Source File: testUtils.py
View license
def getInputs():
    """
    Function that returns Mesh, freqs, rx_loc, elev.
    """
    # Make a mesh
    M = simpeg.Mesh.TensorMesh([[(200,6,-1.5),(200.,4),(200,6,1.5)],[(200,6,-1.5),(200.,4),(200,6,1.5)],[(200,8,-1.5),(200.,8),(200,8,1.5)]], x0=['C','C','C'])# Setup the model
    # Set the frequencies
    freqs = np.logspace(1,-3,5)
    elev = 0

    ## Setup the the survey object
    # Receiver locations
    rx_x, rx_y = np.meshgrid(np.arange(-350,350,200),np.arange(-350,350,200))
    rx_loc = np.hstack((simpeg.Utils.mkvc(rx_x,2),simpeg.Utils.mkvc(rx_y,2),elev+np.zeros((np.prod(rx_x.shape),1))))

    return M, freqs, rx_loc, elev

Example 22

Project: hmf
Source File: test_integrate_hmf.py
View license
    def test_high_z(self):
        m = np.logspace(10,18,500)
        dndm = self.tggd(m,9.0,-1.93,0.4)
        ngtm = self.anl_int(m,9.0,-1.93,0.4)

        print ngtm/hmf_integral_gtm(m,dndm)
        assert np.allclose(ngtm,hmf_integral_gtm(m,dndm),rtol=0.03)

Example 23

Project: hmf
Source File: test_integrate_hmf.py
View license
    def test_low_mmax_high_z(self):
        m = np.logspace(10,15,500)
        dndm = self.tggd(m,9.0,-1.93,0.4)
        ngtm = self.anl_int(m,9.0,-1.93,0.4)

        print ngtm/hmf_integral_gtm(m,dndm)
        assert np.allclose(ngtm,hmf_integral_gtm(m,dndm),rtol=0.03)

Example 24

Project: chempy
Source File: equilibria.py
View license
    def time_roots_symengine(self):
        from symengine import Lambdify
        x, new_inits, success = self.eqsys.roots(
            self.c0, np.logspace(-3, 0, 50), 'NH3',
            lambdify=Lambdify, lambdify_unpack=False)
        assert all(success)

Example 25

Project: omesa
Source File: components.py
View license
    def __init__(self, conf=None, classifiers=None, scoring='f1_micro'):
        """Initialize optimizer with classifier dict and scoring, or conf."""
        std_clf = [Pipe('clf', SVC(kernel='linear'),
                        parameters={'C': np.logspace(-2.0, 1.0, 10)})]

        if not classifiers:
            classifiers = std_clf
        if not conf.get('classifiers'):
            conf['classifiers'] = std_clf

        self.scores = {}
        self.met = conf.get('scoring', scoring)
        self.conf = conf if conf else classifiers

Example 26

Project: allantools
Source File: test_ns.py
View license
def test_ns():
    
    # this test asks for results at unreasonable tau-values
    # either zero, not an integer multiple of the data-interval
    # or too large, given the length of the dataset
    N = 500
    rate = 1.0
    phase_white = noise.white(N)
    taus_try = [x for x in numpy.logspace(0,4,4000)] # try insane tau values
    _test( allan.adev, phase_white, rate, taus_try)
    _test( allan.oadev, phase_white, rate, taus_try)
    _test( allan.mdev, phase_white, rate, taus_try)
    _test( allan.tdev, phase_white, rate, taus_try)
    _test( allan.hdev, phase_white, rate, taus_try)
    _test( allan.ohdev, phase_white, rate, taus_try)
    _test( allan.totdev, phase_white, rate, taus_try)
    _test( allan.mtie, phase_white, rate, taus_try)
    _test( allan.tierms, phase_white, rate, taus_try)

Example 27

Project: pyensemble
Source File: model_library.py
View license
def build_kernPipelines(random_state=None):
    print('Building Kernel Approximation Pipelines')

    param_grid = {
        'n_components': xrange(5, 105, 5),
        'gamma': np.logspace(-6, 2, 9, base=2)
    }

    models = []

    for params in ParameterGrid(param_grid):
        nys = Nystroem(**params)
        lr = LogisticRegression()
        models.append(Pipeline([('nys', nys), ('lr', lr)]))

    return models

Example 28

Project: ahkab
Source File: test_utilities.py
View license
def test_log_axis_iterator():
    """Test utilities.log_axis_iterator"""
    # logspace with endpoint
    a = np.logspace(0, 3, 1000, True)
    # iterator to list to array
    b = np.array(list(log_axis_iterator(1e3, 1, 1000)))
    assert abs((a - b).mean()) < .2

Example 29

Project: gwpy
Source File: test_array.py
View license
    def test_xspan(self):
        # test normal
        series = self.create(x0=1, dx=1)
        self.assertEqual(series.xspan, (1, 1 + 1 * series.shape[0]))
        self.assertIsInstance(series.xspan, Segment)
        # test from irregular xindex
        x = numpy.logspace(0, 2, num=self.data.shape[0])
        series = self.create(xindex=x)
        self.assertEqual(series.xspan, (x[0], x[-1] + x[-1] - x[-2]))

Example 30

Project: gwpy
Source File: test_array.py
View license
    def test_is_compatible(self):
        """Test the `Series.is_compatible` method
        """
        ts1 = self.create()
        ts2 = self.create(name='TEST CASE 2')
        self.assertTrue(ts1.is_compatible(ts2))
        ts3 = self.create(dx=2)
        self.assertRaises(ValueError, ts1.is_compatible, ts3)
        ts4 = self.create(unit='m')
        self.assertRaises(ValueError, ts1.is_compatible, ts4)
        x = numpy.logspace(0, 2, num=self.data.shape[0])
        ts5 = self.create(xindex=x)
        self.assertRaises(ValueError, ts1.is_compatible, ts5)

Example 31

Project: hyperion
Source File: test_dust.py
View license
    def setup_method(self, method):

        self.dust = SphericalDust()

        self.dust.optical_properties.nu = np.logspace(0., 20., 100)
        self.dust.optical_properties.albedo = np.repeat(0.5, 100)
        self.dust.optical_properties.chi = np.ones(100)
        self.dust.optical_properties.mu = [-1., 1.]
        self.dust.optical_properties.initialize_scattering_matrix()
        self.dust.optical_properties.P1[:, :] = 1.
        self.dust.optical_properties.P2[:, :] = 0.
        self.dust.optical_properties.P3[:, :] = 1.
        self.dust.optical_properties.P4[:, :] = 0.

Example 32

Project: hyperion
Source File: test_dust.py
View license
    def test_helpers(self):

        nu = np.logspace(5., 15., 1000)

        # Here we don't set the mean opacities to make sure they are computed
        # automatically

        assert_allclose(self.dust.kappa_nu_temperature(34.),
                        self.dust.kappa_nu_spectrum(nu, B_nu(nu, 34)))

        assert_allclose(self.dust.chi_nu_temperature(34.),
                        self.dust.chi_nu_spectrum(nu, B_nu(nu, 34)))

Example 33

Project: hyperion
Source File: test_optical_properties.py
View license
def test_extrapolate_inner_range():
    o = OpticalProperties()
    o.nu = np.logspace(8., 10., 100)
    o.albedo = np.repeat(0.5, 100)
    o.chi = np.ones(100)
    o.mu = [-1., 1.]
    o.initialize_scattering_matrix()
    o.extrapolate_nu(1e9, 2e9)
    assert o.nu[0] == 1.e8 and o.nu[-1] == 1.e10

Example 34

Project: hyperion
Source File: test_optical_properties.py
View license
def test_extrapolate_upper():
    o = OpticalProperties()
    o.nu = np.logspace(8., 10., 100)
    o.albedo = np.repeat(0.5, 100)
    o.chi = np.ones(100)
    o.mu = [-1., 1.]
    o.initialize_scattering_matrix()
    o.extrapolate_nu(1e9, 1e11)
    assert o.nu[0] == 1.e8 and o.nu[-1] == 1.e11

Example 35

Project: hyperion
Source File: test_optical_properties.py
View license
def test_extrapolate_lower():
    o = OpticalProperties()
    o.nu = np.logspace(8., 10., 100)
    o.albedo = np.repeat(0.5, 100)
    o.chi = np.ones(100)
    o.mu = [-1., 1.]
    o.initialize_scattering_matrix()
    o.extrapolate_nu(1e7, 1e9)
    assert o.nu[0] == 1.e7 and o.nu[-1] == 1.e10

Example 36

Project: hyperion
Source File: test_optical_properties.py
View license
def test_extrapolate_both():
    o = OpticalProperties()
    o.nu = np.logspace(8., 10., 100)
    o.albedo = np.repeat(0.5, 100)
    o.chi = np.ones(100)
    o.mu = [-1., 1.]
    o.initialize_scattering_matrix()
    o.extrapolate_nu(1e7, 1e11)
    assert o.nu[0] == 1.e7 and o.nu[-1] == 1.e11

Example 37

Project: hyperion
Source File: test_optical_properties.py
View license
def test_extrapolate_wav():
    o = OpticalProperties()
    o.nu = np.logspace(8., 10., 100)
    o.albedo = np.repeat(0.5, 100)
    o.chi = np.ones(100)
    o.mu = [-1., 1.]
    o.initialize_scattering_matrix()
    o.extrapolate_wav(1., 1.e20)
    assert_array_almost_equal_nulp(o.nu[0], c / 1.e16, 2)
    assert_array_almost_equal_nulp(o.nu[-1], c / 1.e-4, 2)

Example 38

Project: hyperion
Source File: test_optical_properties.py
View license
def test_plot():

    # Just check that plot runs without crashing

    fig = plt.figure()

    o = OpticalProperties()
    o.nu = np.logspace(8., 10., 100)
    o.albedo = np.repeat(0.5, 100)
    o.chi = np.ones(100)
    o.mu = [-1., 1.]
    o.initialize_scattering_matrix()
    o.plot(fig, [321, 322, 323, 324, 325, 326])

    plt.close(fig)

Example 39

Project: hyperion
Source File: test_functions.py
View license
def test_b_nu():

    nu = np.logspace(-20, 20., 10000)

    for T in [10, 100, 1000, 10000]:

        # Compute planck function
        b = B_nu(nu, T)

        # Check that the intergral is correct
        total = integrate_loglog(nu, b)
        np.testing.assert_allclose(total, sigma * T ** 4 / np.pi, rtol=1e-4)

        # Check that we reach the rayleigh-jeans limit at low frequencies
        rj = 2. * nu ** 2 * k * T / c**2
        np.testing.assert_allclose(b[nu < 1e-10], rj[nu < 1e-10], rtol=1.e-8)

Example 40

Project: hyperion
Source File: test_functions.py
View license
def test_db_nu_dt():

    nu = np.logspace(-20, 20., 10000)

    for T in [10, 100, 1000, 10000]:

        # Compute exact planck function derivative
        db = dB_nu_dT(nu, T)

        # Compute numerical planck function derivative
        dT = T / 1e6
        b1 = B_nu(nu, T - dT)
        b2 = B_nu(nu, T + dT)
        db_num = 0.5 * (b2 - b1) / dT

        # Check that the two are the same
        np.testing.assert_allclose(db, db_num, rtol=1.e-2)

Example 41

Project: holoviews
Source File: testplotinstantiation.py
View license
    def test_quadmesh_colormapping(self):
        n = 21
        xs = np.logspace(1, 3, n)
        ys = np.linspace(1, 10, n)
        qmesh = QuadMesh((xs, ys, np.random.rand(n-1, n-1)))
        self._test_colormapping(qmesh, 2)

Example 42

Project: imagen
Source File: audio.py
View license
    def _set_frequency_spacing(self, min_freq, max_freq):
        min_frequency = log10(min_freq+1) / log10(self.log_base)
        max_frequency = log10(max_freq) / log10(self.log_base)

        self.frequency_spacing = logspace(min_frequency, max_frequency,
            num=self._sheet_dimensions[0]+1, endpoint=True, base=self.log_base)

Example 43

View license
def determine_error_offsets():
    """
    Experiment to determine how wrong the error estimates are
    (WHY are they wrong?  Still don't understand)
    """
    # analytic
    A = np.array([run_tests(1.5,1.5,50,a,False,nfits=200) for a in np.logspace(1.5,3,30)]);
    G = np.array([run_tests(1.5,1.5,50,a,True,nfits=200) for a in np.logspace(1.5,3,30)]);
    print("Analytic offset: %g" % (( (A[:,3]/A[:,1]).mean() + (A[:,2]/A[:,0]).mean() )/2. ))
    print("Gaussian offset: %g" % (( (G[:,3]/G[:,1]).mean() + (G[:,2]/G[:,0]).mean() )/2. ))

Example 44

View license
def determine_error_offsets():
    """
    Experiment to determine how wrong the error estimates are
    (WHY are they wrong?  Still don't understand)
    """
    # analytic
    A = np.array([run_tests(1.5,1.5,50,a,False,nfits=200) for a in np.logspace(1.5,3,30)]);
    G = np.array([run_tests(1.5,1.5,50,a,True,nfits=200) for a in np.logspace(1.5,3,30)]);
    print("Analytic offset: %g" % (( (A[:,3]/A[:,1]).mean() + (A[:,2]/A[:,0]).mean() )/2. ))
    print("Gaussian offset: %g" % (( (G[:,3]/G[:,1]).mean() + (G[:,2]/G[:,0]).mean() )/2. ))

Example 45

View license
    def test_basic(self):
        y = logspace(0, 6)
        assert_(len(y) == 50)
        y = logspace(0, 6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = logspace(0, 6, endpoint=0)
        assert_(y[-1] < 10 ** 6)
        y = logspace(0, 6, num=7)
        assert_array_equal(y, [1, 10, 100, 1e3, 1e4, 1e5, 1e6])

Example 46

View license
    def test_dtype(self):
        y = logspace(0, 6, dtype='float32')
        assert_equal(y.dtype, dtype('float32'))
        y = logspace(0, 6, dtype='float64')
        assert_equal(y.dtype, dtype('float64'))
        y = logspace(0, 6, dtype='int32')
        assert_equal(y.dtype, dtype('int32'))

Example 47

View license
    def test_basic(self):
        y = logspace(0, 6)
        assert_(len(y) == 50)
        y = logspace(0, 6, num=100)
        assert_(y[-1] == 10 ** 6)
        y = logspace(0, 6, endpoint=0)
        assert_(y[-1] < 10 ** 6)
        y = logspace(0, 6, num=7)
        assert_array_equal(y, [1, 10, 100, 1e3, 1e4, 1e5, 1e6])

Example 48

View license
    def test_dtype(self):
        y = logspace(0, 6, dtype='float32')
        assert_equal(y.dtype, dtype('float32'))
        y = logspace(0, 6, dtype='float64')
        assert_equal(y.dtype, dtype('float64'))
        y = logspace(0, 6, dtype='int32')
        assert_equal(y.dtype, dtype('int32'))

Example 49

View license
    def test_05(self):
        # Test that bode() finds a reasonable frequency range.
        # 1st order low-pass filter: H(s) = 1 / (s + 1)
        system = lti([1], [1, 1])
        n = 10
        # Expected range is from 0.01 to 10.
        expected_w = np.logspace(-2, 1, n)
        w, mag, phase = bode(system, n=n)
        assert_almost_equal(w, expected_w)

Example 50

View license
    def test_freq_range(self):
        # Test that freqresp() finds a reasonable frequency range.
        # 1st order low-pass filter: H(s) = 1 / (s + 1)
        # Expected range is from 0.01 to 10.
        system = lti([1], [1, 1])
        n = 10
        expected_w = np.logspace(-2, 1, n)
        w, H = freqresp(system, n=n)
        assert_almost_equal(w, expected_w)