Ejemplo n.º 1
0
def test_initialize_InitRiseVelFromDist_normal():
    """
    test initialize data_arrays with normal dist
    assume normal distribution works fine - so statistics (mean, var) are not
    tested
    """
    num_elems = 1000
    data_arrays = mock_append_data_arrays(rise_vel_array, num_elems)

    dist = NormalDistribution(mean=0, sigma=0.1)
    fcn = InitRiseVelFromDist(distribution=dist)
    fcn.initialize(num_elems, None, data_arrays)

    assert_dataarray_shape_size(rise_vel_array, data_arrays, num_elems)

    assert np.all(0 != data_arrays['rise_vel'])
Ejemplo n.º 2
0
                                               'droplet_diameter'])

num_elems = 10
oil = test_oil


def assert_dataarray_shape_size(arr_types, data_arrays, num_released):
    for key, val in arr_types.iteritems():
        assert data_arrays[key].dtype == val.dtype
        assert data_arrays[key].shape == (num_released,) + val.shape


""" Initializers - following are used for parameterizing tests """
fcn_list = (InitWindages(),
            InitRiseVelFromDist(distribution=UniformDistribution()),
            InitRiseVelFromDist(distribution=NormalDistribution(mean=0,
                                                                sigma=0.1)),
            InitRiseVelFromDist(distribution=LogNormalDistribution(mean=0,
                                                                   sigma=0.1)),
            InitRiseVelFromDist(distribution=WeibullDistribution(alpha=1.8,
                                                                 lambda_=(1 / (.693 ** (1 / 1.8)))
                                                                 )),
            InitRiseVelFromDropletSizeFromDist(NormalDistribution(mean=0,
                                                                  sigma=0.1))
            )

arrays_ = (windages,
           rise_vel_array, rise_vel_array, rise_vel_array, rise_vel_array,
           rise_vel_diameter_array)

spill_list = (None, None, None, None, None,
              Spill(Release(datetime.now()), water=Water()))
Ejemplo n.º 3
0
rise_vel_diameter_array = mock_sc_array_types(['rise_vel', 'droplet_diameter'])

num_elems = 10
oil = test_oil


def assert_dataarray_shape_size(arr_types, data_arrays, num_released):
    for key, val in arr_types.iteritems():
        assert data_arrays[key].dtype == val.dtype
        assert data_arrays[key].shape == (num_released, ) + val.shape


""" Initializers - following are used for parameterizing tests """
fcn_list = (InitWindages(), InitRiseVelFromDist(),
            InitRiseVelFromDist(
                distribution=NormalDistribution(mean=0, sigma=0.1)),
            InitRiseVelFromDist(
                distribution=LogNormalDistribution(mean=0, sigma=0.1)),
            InitRiseVelFromDist(distribution=WeibullDistribution(
                alpha=1.8, lambda_=(1 / (.693**(1 / 1.8))))),
            InitRiseVelFromDropletSizeFromDist(
                NormalDistribution(mean=0, sigma=0.1)))

arrays_ = (windages, rise_vel_array, rise_vel_array, rise_vel_array,
           rise_vel_array, rise_vel_diameter_array)

spill_list = (None, None, None, None, None, Spill(Release(datetime.now())))


@pytest.mark.parametrize(("fcn", "arr_types", "spill"),
                         zip(fcn_list, arrays_, spill_list))