def test_property_num_per_timestep_elements(self): ''' test either num_elements or num_per_timestep is set but not both also test the num_elements_to_release references correct method ''' r = PointLineRelease(self.rel_time, self.pos, num_per_timestep=100) r.num_elements = 10 assert r.num_per_timestep is None assert r.num_elements_to_release(self.rel_time, 900) == 10 r.num_per_timestep = 100 assert r.num_elements is None assert r.num_elements_to_release(self.rel_time, 900) == 100
def test_rewind(self): ''' test rewind resets all parameters of interest ''' r = PointLineRelease(self.rel_time, self.pos, end_position=(1, 2, 3), num_per_timestep=100, end_release_time=self.rel_time + timedelta(hours=2)) num = r.num_elements_to_release(self.rel_time, 900) assert not r.start_time_invalid # updated only after set_newparticle_positions is called assert r.num_released == 0 pos = {'positions': positions.initialize(num)} r.set_newparticle_positions(num, self.rel_time, 900, pos) assert r.num_released == num assert r._delta_pos is not None assert np.any(r._next_release_pos != r.start_position) r.rewind() assert r.start_time_invalid is None assert r._delta_pos is None assert np.all(r._next_release_pos == r.start_position)
def test_num_per_timestep(self): 'test PointLineRelease when a fixed rate per timestep is given' r = PointLineRelease(self.rel_time, self.pos, num_per_timestep=100) assert r.num_elements is None for ts in (100, 400): num = r.num_elements_to_release(self.rel_time, ts) assert num == 100