MCPcopy Create free account
hub / github.com/danieljfarrell/pvtrace / test_sample_range

Method test_sample_range

tests/test_distibution.py:9–21  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7class TestDistribution:
8
9 def test_sample_range(self):
10 x = np.linspace(400, 1010, 2000)
11 abs_spec = np.column_stack((x, bandgap(x, 600, 1000)))
12 ems_spec = thermodynamic_emission(abs_spec, T=300, mu=0.1)
13 dist = Distribution(ems_spec[:, 0], ems_spec[:, 1])
14 xmin = dist.sample(0)
15 assert np.isclose(xmin, x.min())
16 xmax = dist.sample(1)
17 assert np.isclose(xmax, x.max())
18 y_at_xmin = dist.lookup(xmin)
19 assert np.isclose(y_at_xmin, 0.0)
20 y_at_xmax = dist.lookup(xmax)
21 assert np.isclose(y_at_xmin, 0.0)
22
23 def test_step_sample(self):
24 """ Sampling a step function should only return two value.

Callers

nothing calls this directly

Calls 5

sampleMethod · 0.95
lookupMethod · 0.95
bandgapFunction · 0.90
thermodynamic_emissionFunction · 0.90
DistributionClass · 0.90

Tested by

no test coverage detected