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.
101 Examples
4
Example 1
Project: python-control Source File: frd_test.py
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]))
3
Example 2
Project: hmf Source File: test_integrate_hmf.py
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)
3
Example 3
Project: hyperion Source File: test_functions.py
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)
3
Example 4
Project: calcuMLator Source File: data.py
def create_full_set(step, maximum):
'''
Returns a grid set with up to the "maximum" value and with "step" spacing
'''
X, y_add, y_sub, y_mul, y_div = [], [], [], [], []
dat1 = np.logspace(-1, step, maximum)
# dat1 = np.linspace(0, 5, 10)
x0 = np.append(-np.flipud(dat1), dat1)
for i in x0:
for j in x0:
if j == 0:
continue
X.append([i, j])
y_add.append(np.add(i, j))
y_sub.append(np.subtract(i, j))
y_mul.append(np.multiply(i, j))
y_div.append(np.divide(i, j))
return shuffle(np.array(X), np.array(y_add), np.array(y_sub),
np.array(y_mul), np.array(y_div))
3
Example 5
Project: hyperion Source File: test_optical_properties.py
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
3
Example 6
Project: scipy Source File: test_sici.py
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()
3
Example 7
Project: image_registration Source File: registration_testing.py
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. ))
3
Example 8
Project: python-control Source File: margin_test.py
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))
3
Example 9
Project: scikit-learn Source File: test_online_lda.py
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)
3
Example 10
def test_validation_curve(self):
digits = datasets.load_digits()
df = pdml.ModelFrame(digits)
param_range = np.logspace(-2, -1, 2)
svc = df.svm.SVC(random_state=self.random_state)
result = df.learning_curve.validation_curve(svc, 'gamma',
param_range)
expected = lc.validation_curve(svm.SVC(random_state=self.random_state),
digits.data, digits.target,
'gamma', param_range)
self.assertEqual(len(result), 2)
self.assert_numpy_array_almost_equal(result[0], expected[0])
self.assert_numpy_array_almost_equal(result[1], expected[1])
3
Example 11
Project: pyensemble Source File: model_library.py
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
3
Example 12
Project: hyperion Source File: test_optical_properties.py
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
3
Example 13
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()
3
Example 14
Project: hyperion Source File: test_optical_properties.py
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)
3
Example 15
Project: python-control Source File: margin_test.py
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)
3
Example 16
Project: holoviews Source File: testplotinstantiation.py
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)
3
Example 17
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
3
Example 18
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'))
3
Example 19
Project: python-control Source File: frd_test.py
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)
3
Example 20
Project: matplotlib2tikz Source File: loglogplot.py
def plot():
from matplotlib import pyplot as plt
import numpy as np
fig = plt.figure()
x = np.logspace(0, 6, num=5)
plt.loglog(x, x**2, lw=2.1)
return fig
3
Example 21
Project: omesa Source File: components.py
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
3
Example 22
Project: allantools Source File: test_ns.py
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)
3
Example 23
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])
3
Example 24
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)
3
Example 25
Project: ahkab Source File: test_utilities.py
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
3
Example 26
Project: gwpy Source File: test_array.py
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]))
3
Example 27
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)))
3
Example 28
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()
3
Example 29
Project: hyperion Source File: test_optical_properties.py
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
3
Example 30
Project: python-control Source File: frd_test.py
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])
3
Example 31
Project: hyperion Source File: test_optical_properties.py
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
3
Example 32
Project: scipy Source File: test_loggamma.py
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)
3
Example 33
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)
3
Example 34
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
3
Example 35
Project: hyperion Source File: test_functions.py
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)
3
Example 36
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()
3
Example 37
Project: imagen Source File: audio.py
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)
3
Example 38
Project: python-control Source File: margin_test.py
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)
3
Example 39
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])
3
Example 40
Project: hmf Source File: test_integrate_hmf.py
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)
3
Example 41
def test_grid_search():
pipeline = dl.Pipeline([("pca", PCA()),
("select_k", SelectKBest()),
("svm", LinearSVC())])
param_grid = {'select_k__k': [1, 2, 3, 4],
'svm__C': np.logspace(-3, 2, 3)}
grid = dl.GridSearchCV(pipeline, param_grid)
with dask.set_options(get=dask.get):
result = grid.fit(X_train, y_train).score(X_test, y_test)
assert isinstance(result, float)
3
Example 42
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)
3
Example 43
Project: calcuMLator Source File: plot.py
def plot_surface_function(function, rng, title=''):
fig = plt.figure()
ax = fig.gca(projection='3d')
dat1 = np.logspace(-rng, rng, 20)
# print(dat1)
# dat1 = np.linspace(-5, 5, 30)
X = Y = np.append(-np.flipud(dat1), dat1)
X, Y = np.meshgrid(X, Y)
Z = function(X, Y)
surf = ax.plot_surface(X, Y, Z, cmap=cm.magma, cstride=1, rstride=1,
vmin=-10, vmax=10, linewidth=0)
ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.title(title)
plt.show()
3
Example 44
Project: chempy Source File: equilibria.py
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)
3
Example 45
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)
3
Example 46
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) )
3
Example 47
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])
3
Example 48
Project: python-control Source File: frd_test.py
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])
3
Example 49
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)
3
Example 50
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.