Python numpy.testing.assert_array_equal() Examples

The following are code examples for showing how to use numpy.testing.assert_array_equal(). They are from open source Python projects. You can vote up the examples you like or vote down the ones you don't like.

Example 1
Project: QCElemental   Author: MolSSI   File: test_scipy_hungarian.py    BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def test_linear_sum_assignment_input_validation():
    assert_raises(ValueError, linear_sum_assignment, [1, 2, 3])

    C = [[1, 2, 3], [4, 5, 6]]
    assert_array_equal(linear_sum_assignment(C), linear_sum_assignment(np.asarray(C)))
    # assert_array_equal(linear_sum_assignment(C),
    #                    linear_sum_assignment(matrix(C)))

    I = np.identity(3)
    assert_array_equal(linear_sum_assignment(I.astype(np.bool)), linear_sum_assignment(I))
    assert_raises(ValueError, linear_sum_assignment, I.astype(str))

    I[0][0] = np.nan
    assert_raises(ValueError, linear_sum_assignment, I)

    I = np.identity(3)
    I[1][1] = np.inf
    assert_raises(ValueError, linear_sum_assignment, I) 
Example 2
Project: geonum   Author: jgliss   File: test_elevationprofile.py    GNU General Public License v3.0 6 votes vote down vote up
def test_ElevationProfile():
    
    lat_taranaki = -39.296571
    lon_observer = 173.9224
    
    obs = GeoPoint(lat_taranaki, lon_observer)
    
    npt.assert_almost_equal(obs.altitude, 324)
    
    prof = obs.get_elevation_profile(azimuth=90, dist_hor=50)
    
    prof_nans = obs.get_elevation_profile(azimuth=45, dist_hor=50)
    prof2 = obs.get_elevation_profile(azimuth=45, dist_hor=50,
                                      order=1)
    
    npt.assert_array_equal([len(prof.dists), len(prof.profile),
                            np.sum(np.isnan(prof_nans.profile))],
                            [10092,10092,10263])
    npt.assert_array_almost_equal([prof.profile.max(), prof.profile.min(), 
                                   prof.profile.mean(), prof.profile.std(),
                                   prof.dists.max(),
                                   prof2.profile.max(), prof2.profile.min()],
                                  [2482.598405, 176.008484, 583.012202,  
                                   486.57815, 50.033677, 1005.208932, 0.]) 
Example 3
Project: tenpy   Author: tenpy   File: test_np_conserved.py    GNU General Public License v3.0 6 votes vote down vote up
def test_pickle():
    import pickle
    a = npc.Array.from_ndarray(arr, [lc, lc_add.conj()])
    b = random_Array((20, 15, 10), chinfo2, sort=False)
    a.test_sanity()
    b.test_sanity()
    aflat = a.to_ndarray()
    bflat = b.to_ndarray()
    data = {'a': a, 'b': b}
    stream = pickle.dumps(data)
    data2 = pickle.loads(stream)
    a2 = data2['a']
    b2 = data2['b']
    a.test_sanity()
    b.test_sanity()
    a2.test_sanity()
    b2.test_sanity()
    a2flat = a2.to_ndarray()
    b2flat = b2.to_ndarray()
    npt.assert_array_equal(aflat, a2flat)
    npt.assert_array_equal(bflat, b2flat) 
Example 4
Project: astroNN   Author: henrysky   File: test_gaia_tools.py    MIT License 6 votes vote down vote up
def test_logsol(self):
        # Test conversion tools related to log solar luminosity
        from astroNN.gaia import fakemag_to_logsol, absmag_to_logsol, logsol_to_absmag, logsol_to_fakemag
        self.assertEqual(logsol_to_fakemag(fakemag_to_logsol(100.)), 100.)
        npt.assert_array_equal(logsol_to_fakemag(fakemag_to_logsol([100., 100.])), [100., 100.])
        npt.assert_array_equal(logsol_to_fakemag(fakemag_to_logsol(np.array([100, 100, 100]))), [100., 100., 100.])
        self.assertEqual(fakemag_to_logsol(MAGIC_NUMBER), MAGIC_NUMBER)
        self.assertEqual(logsol_to_fakemag(fakemag_to_logsol(MAGIC_NUMBER)), MAGIC_NUMBER)
        self.assertEqual(np.any(fakemag_to_logsol([MAGIC_NUMBER, 1000]) == MAGIC_NUMBER), True)

        self.assertEqual(logsol_to_absmag(absmag_to_logsol(99.)), 99.)
        self.assertAlmostEqual(logsol_to_absmag(absmag_to_logsol(-99.)), -99.)
        npt.assert_array_equal(logsol_to_absmag(absmag_to_logsol([99., 99.])), [99., 99.])
        npt.assert_array_almost_equal(logsol_to_absmag(absmag_to_logsol([-99., -99.])), [-99., -99.])
        npt.assert_array_almost_equal(logsol_to_absmag(absmag_to_logsol(np.array([99., 99., 99.]))), [99., 99., 99.])
        self.assertEqual(absmag_to_logsol(MAGIC_NUMBER), MAGIC_NUMBER)
        self.assertEqual(logsol_to_absmag(absmag_to_logsol(MAGIC_NUMBER)), MAGIC_NUMBER)
        self.assertEqual(np.any(absmag_to_logsol([MAGIC_NUMBER, 1000]) == MAGIC_NUMBER), True) 
Example 5
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: times_test.py    MIT License 6 votes vote down vote up
def test_group_from():
        # test grouping values backward or forward from a given value and given hours unit
        yr = '2018-01-01 '
        time = pd.to_datetime([yr + ' 12', yr + ' 15', yr + '16', yr + '17', yr + '18'], utc=True).tolist()
        value = [2, 2, 3, 4, 5]
        # expected to group (2, 2, 3) into 9:00, 12:00 and 15:00
        # where 9:00 is expected to be the repetition of 12:00
        grouped_back = times.group_from(time, value, index=2, step=-3, group_hours=3)
        np_test.assert_array_equal(grouped_back, [2, 2, 2.5])
        # expected to group (3, 4) forward into 15:00, and (5) into 18:00
        grouped_forward = times.group_from(time, value, index=2, step=2, group_hours=3)
        np_test.assert_array_equal(grouped_forward, [3.5, 5])
        # redo the test including the group boundaries
        # group boundary of 16:00 is 17:00 for backward grouping
        boundary_grouped_back = times.group_from(time, value, index=2, step=-3, group_hours=3,
                                                 whole_group=True)
        np_test.assert_array_equal(boundary_grouped_back, [2, 2, 3])
        # group boundary of 16:00 is [15:00, 17:00) for forward grouping
        boundary_grouped_back = times.group_from(time, value, index=2, step=3, group_hours=3,
                                                 whole_group=True)
        np_test.assert_array_equal(boundary_grouped_back, [3, 5, 5]) 
Example 6
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: times_test.py    MIT License 6 votes vote down vote up
def test_split():
        yr = '2018-01-01 '
        time = pd.to_datetime([yr + ' 13', yr + '14', yr + ' 15', yr + '16', yr + '18'], utc=True).tolist()
        value = [2, 3, 4, 5, 6]
        # time groups: 12:00, 15:00, and 18:00
        # averaging from group start until given index
        split = times.split(time=time, value=value, group_hours=3, step=-3, region=(0, -1))
        expected = [[2, 2, 2], [2.5, 2.5, 2.5], [2.5, 2.5, 4], [2.5, 2.5, 4.5], [2.5, 4.5, 6]]
        np_test.assert_array_equal(x=expected, y=split)

        # time groups: 12:00, 15:00, and 18:00
        # averaging from group start until given index
        split = times.split(time=time, value=value, group_hours=3, step=3, region=(0, -1))
        expected = [[2.5, 4.5, 6], [3, 4.5, 6], [4.5, 6, 6], [5, 6, 6], [6, 6, 6]]
        np_test.assert_array_equal(x=expected, y=split)

        # first index skipped
        # total group average is considered for each member regardless of index
        split = times.split(time=time, value=value, group_hours=3, step=3, region=(1, -1), whole_group=True)
        expected = [[2.5, 4.5, 6], [4.5, 6, 6], [4.5, 6, 6], [6, 6, 6]]
        np_test.assert_array_equal(x=expected, y=split)

        split = times.split(time=time, value=value, group_hours=3, step=-3, region=(4, 4), whole_group=True)
        expected = [[2.5, 4.5, 6]]
        np_test.assert_array_equal(x=expected, y=split) 
Example 7
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: reform_test.py    MIT License 6 votes vote down vote up
def test_split_hours():
        """
            Test splitting a time series into hours
        :return:
        """
        values = [1, 2, 3, 4, 5]
        yr = '2018-01-01 '
        times = pd.to_datetime([yr + '12:00:00', yr + '13:00:00', yr + '14:00:00', yr + '15:00:00'],
                               utc=True).tolist()
        t, x, y = reform.split_dual(times, values, unit_x=2, unit_y=2)
        # day of week (1: monday), hour, value of two hours
        expected_x = [[1, 2], [2, 3]]
        expected_y = [[3, 4], [4, 5]]
        expected_t = pd.to_datetime(pd.Series(
            [yr + '12:00:00', yr + '13:00:00']
        ), utc=True).tolist()
        np_test.assert_array_equal(expected_t, t)
        np_test.assert_array_equal(expected_x, x)
        np_test.assert_array_equal(expected_y, y) 
Example 8
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 6 votes vote down vote up
def photons_tests(self, dset, num_dset=1, first_dset=True):
        # Output of $ ./make_data -T -t 4
        self.assertEqual(dset.num_data, 3000)
        self.assertEqual(dset.num_pix, 10201)
        self.assertEqual(os.path.normpath(dset.filename), os.path.normpath(recon_folder+b'/data/photons.emc'))
        self.assertAlmostEqual(dset.mean_count, 1424.309)
        if first_dset:
            self.assertEqual(dset.tot_num_data, num_dset*3000)
            self.assertAlmostEqual(dset.tot_mean_count, 1424.309)
        if dset.type == 0:
            npt.assert_array_equal(dset.ones_accum, dset.ones.cumsum() - dset.ones)
            npt.assert_array_equal(dset.multi_accum, dset.multi.cumsum() - dset.multi)
            self.assertEqual(dset.ones_total, dset.ones.sum())
            self.assertEqual(dset.multi_total, dset.multi.sum())
            
            npt.assert_array_equal(dset.ones[:3], [541, 426, 429])
            npt.assert_array_equal(dset.ones[-3:], [404, 377, 433])
            npt.assert_array_equal(dset.multi[:3], [384, 326, 226])
            npt.assert_array_equal(dset.multi[-3:], [217, 249, 313])
            npt.assert_array_equal(dset.place_ones[:3], [444, 546, 656])
            npt.assert_array_equal(dset.place_ones[-3:], [8816, 9013, 9274])
            npt.assert_array_equal(dset.place_multi[:3], [1984, 2066, 2161])
            npt.assert_array_equal(dset.place_multi[-3:], [7538, 8015, 8331])
            npt.assert_array_equal(dset.count_multi[11:16], [2,3,2,2,3])
            npt.assert_array_equal(dset.count_multi[-16:-11], [2,2,2,2,3]) 
Example 9
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 6 votes vote down vote up
def test_generate_iterate(self):
        print('=== Testing generate_iterate() ===')
        itr, det, dset, param, qmax = self.allocate_iterate()
        self.assertEqual(itr.size, 145)
        self.assertRaises(AssertionError, itr.generate_iterate, config_fname, qmax, param, det, dset, continue_flag=True)
        itr.generate_iterate(config_fname, qmax, param, det, dset, config_section=b'foobar')
        
        config = DragonflyConfig(config_fname)
        config.modify_entry('emc', 'size', '101')
        config.modify_entry('emc', 'need_scaling', '1')
        itr, det, dset, param, qmax = self.allocate_iterate()
        npt.assert_array_equal(itr.scale, np.ones(dset.tot_num_data, dtype='f8'))
        npt.assert_array_equal(dset.count[:5], [1621, 1382, 1050, 2436, 1450])
        npt.assert_array_equal(dset.count[-5:], [1093, 1597, 1053, 1080, 1315])
        self.assertEqual(itr.size, 101)
        
        config.remove_entry('emc', 'size')
        config.remove_entry('emc', 'need_scaling') 
Example 10
Project: gwdetchar   Author: gwdetchar   File: test_datafind.py    GNU General Public License v3.0 6 votes vote down vote up
def test_get_data_from_cache(tsget, find_data):
    # set return values
    find_data.return_value = ['test.gwf']
    tsget.return_value = HOFT.crop(16, 48)

    # retrieve test frame
    start = 16
    end = start + 32
    channel = 'X1:TEST-STRAIN'
    frametype = 'X1_TEST'
    data = datafind.get_data(channel, start, end, frametype=frametype)

    # test data products
    assert isinstance(data, TimeSeries)
    assert data.duration.value == 32
    assert data.span == Segment(start, end)
    nptest.assert_array_equal(data.value, HOFT.crop(start, end).value) 
Example 11
Project: gwdetchar   Author: gwdetchar   File: test_datafind.py    GNU General Public License v3.0 6 votes vote down vote up
def test_get_data_dict_from_cache(tsdget, remove, find_data):
    # set return values
    tsdget.return_value = TimeSeriesDict({
        'X1:TEST-STRAIN': HOFT.crop(16, 48)})
    remove.return_value = ['X1:TEST-STRAIN']
    find_data.return_value = ['test.gwf']
    # retrieve test frame
    start = 16
    end = start + 32
    channels = ['X1:TEST-STRAIN']
    data = datafind.get_data(channels, start, end, source=True)

    # test data products
    assert isinstance(data, TimeSeriesDict)
    assert data[channels[0]].duration.value == 32
    assert data[channels[0]].span == Segment(start, end)
    nptest.assert_array_equal(data[channels[0]].value,
                              HOFT.crop(start, end).value) 
Example 12
Project: xrft   Author: xgcm   File: test_xrft.py    MIT License 5 votes vote down vote up
def test_dim_dft(self):
        N = 16
        da = xr.DataArray(np.random.rand(N,N), dims=['x','y'],
                        coords={'x':range(N),'y':range(N)}
                         )
        npt.assert_array_equal(xrft.dft(da, dim='y', shift=False).values,
                              xrft.dft(da, dim=['y'], shift=False).values
                              )
        assert xrft.dft(da, dim='y').dims == ('x','freq_y') 
Example 13
Project: xrft   Author: xgcm   File: test_xrft.py    MIT License 5 votes vote down vote up
def test_dft_3d_dask(self, dask):
        """Test the discrete Fourier transform on 3D dask array data"""
        N=16
        da = xr.DataArray(np.random.rand(N,N,N), dims=['time','x','y'],
                          coords={'time':range(N),'x':range(N),
                                  'y':range(N)}
                         )
        if dask:
            da = da.chunk({'time': 1})
            daft = xrft.dft(da, dim=['x','y'], shift=False)
            npt.assert_almost_equal(daft.values,
                                   np.fft.fftn(da.chunk({'time': 1}).values,
                                              axes=[1,2])
                                   )
            da = da.chunk({'x': 1})
            with pytest.raises(ValueError):
                xrft.dft(da, dim=['x'])
            with pytest.raises(ValueError):
                xrft.dft(da, dim='x')

            da = da.chunk({'time':N})
            daft = xrft.dft(da, dim=['time'],
                           shift=False, detrend='linear')
            da_prime = sps.detrend(da, axis=0)
            npt.assert_almost_equal(daft.values,
                                   np.fft.fftn(da_prime, axes=[0])
                                   )
            npt.assert_array_equal(daft.values,
                                   xrft.dft(da, dim='time',
                                            shift=False, detrend='linear')
                                   ) 
Example 14
Project: xrft   Author: xgcm   File: test_xrft.py    MIT License 5 votes vote down vote up
def test_spectrum_dim(self):
        N = 16
        da = xr.DataArray(np.random.rand(2,N,N), dims=['time','y','x'],
                         coords={'time':np.array(['2019-04-18', '2019-04-19'],
                                                dtype='datetime64'),
                                'y':range(N),'x':range(N)}
                         )

        ps = xrft.power_spectrum(da, dim='y', real='x', window=True,
                                density=False, detrend='constant')
        npt.assert_array_equal(ps.values,
                               xrft.power_spectrum(da, dim=['y'],
                                                  real='x', window=True,
                                                  density=False,
                                                  detrend='constant').values)

        da2 = xr.DataArray(np.random.rand(2,N,N), dims=['time','y','x'],
                          coords={'time':np.array(['2019-04-18', '2019-04-19'],
                                                 dtype='datetime64'),
                                  'y':range(N), 'x':range(N)})
        cs = xrft.cross_spectrum(da, da2, dim='y',
                                shift=True, window=True,
                                detrend='constant')
        npt.assert_array_equal(xrft.cross_spectrum(da, da2, dim=['y'],
                                                  shift=True, window=True,
                                                  detrend='constant').values,
                              cs.values
                              )
        assert ps.dims == ('time','freq_y','freq_x')
        assert cs.dims == ('time','freq_y','x') 
Example 15
Project: geonum   Author: jgliss   File: test_base_classes.py    GNU General Public License v3.0 5 votes vote down vote up
def test_GeoVector3D():
    """Test basic arithmetic operations on GeoVectors."""
    v = GeoVector3D(dx=1, dy=1, dz=100)
    
    npt.assert_array_equal([v.dx, v.dy, v.dz], [1,1,100])
    npt.assert_array_almost_equal([v.elevation, 
                                   v.magnitude, 
                                   v.azimuth, 
                                   v.dist_hor], 
                                  [4.044691, 1.417745, 45., 1.414214]) 
Example 16
Project: geonum   Author: jgliss   File: test_srtm_database.py    GNU General Public License v3.0 5 votes vote down vote up
def test_guallatiri_topo(guallatiri_data):
    data = guallatiri_data
    npt.assert_array_equal(data.shape, (242, 122))
    npt.assert_array_almost_equal([data.min, data.max, data.mean(), data.std()],
                                  [4084., 6057., 4690.692827, 393.816227])
    
    return data 
Example 17
Project: me-ica   Author: ME-ICA   File: test_quaternions.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def test_angle_axis2quat():
    q = nq.angle_axis2quat(0, [1, 0, 0])
    yield assert_array_equal, q, [1, 0, 0, 0]
    q = nq.angle_axis2quat(np.pi, [1, 0, 0])
    yield assert_array_almost_equal, q, [0, 1, 0, 0]
    q = nq.angle_axis2quat(np.pi, [1, 0, 0], True)
    yield assert_array_almost_equal, q, [0, 1, 0, 0]
    q = nq.angle_axis2quat(np.pi, [2, 0, 0], False)
    yield assert_array_almost_equal, q, [0, 1, 0, 0] 
Example 18
Project: me-ica   Author: ME-ICA   File: test_euler.py    GNU Lesser General Public License v2.1 5 votes vote down vote up
def test_euler_mat():
    M = nea.euler2mat()
    yield assert_array_equal, M, np.eye(3)
    for x, y, z in eg_rots:
        M1 = nea.euler2mat(z, y, x)
        M2 = sympy_euler(z, y, x)
        yield assert_array_almost_equal, M1, M2
        M3 = np.dot(x_only(x), np.dot(y_only(y), z_only(z)))
        yield assert_array_almost_equal, M1, M3
        zp, yp, xp = nea.mat2euler(M1)
        # The parameters may not be the same as input, but they give the
        # same rotation matrix
        M4 = nea.euler2mat(zp, yp, xp)
        yield assert_array_almost_equal, M1, M4 
Example 19
Project: pyplis   Author: jgliss   File: test_highlevel_examples.py    GNU General Public License v3.0 5 votes vote down vote up
def test_setup(setup):
    """Test some properties of the MeasSetup object."""
    s = setup.source
    vals_exact = [setup.save_dir == setup.base_dir,
                  setup.camera.cam_id]
    vals_approx = [sum([sum(x) for x in setup.cell_info_dict.values()]),
                   s.lon + s.lat + s.altitude]

    nominal_exact = [True, "ecII"]
    nominal_approx = [3.798e18, 3381.750]

    npt.assert_array_equal(vals_exact, nominal_exact)
    npt.assert_allclose(vals_approx, nominal_approx, rtol=1e-4) 
Example 20
Project: pyplis   Author: jgliss   File: test_highlevel_examples.py    GNU General Public License v3.0 5 votes vote down vote up
def test_dataset(plume_dataset):
    """Test certain properties of the dataset object."""
    ds = plume_dataset
    keys = list(ds.img_lists_with_data.keys())
    vals_exact = [ds.img_lists["on"].nof + ds.img_lists["off"].nof,
                  sum(ds.current_image("on").shape),
                  keys[0], keys[1], ds.cam_id]

    nominal_exact = [178, 2368, "on", "off", "ecII"]

    npt.assert_array_equal(vals_exact, nominal_exact) 
Example 21
Project: pyplis   Author: jgliss   File: test_highlevel_examples.py    GNU General Public License v3.0 5 votes vote down vote up
def test_imglists(plume_dataset):
    """Test some properties of the on and offband image lists."""
    on = plume_dataset._lists_intern["F01"]["F01"]
    off = plume_dataset._lists_intern["F02"]["F02"]

    vals_exact = [on.list_id, off.list_id]

    nominal_exact = ["on", "off"]

    npt.assert_array_equal(vals_exact, nominal_exact) 
Example 22
Project: LaserTOF   Author: kyleuckert   File: common_tests.py    MIT License 5 votes vote down vote up
def check_named_args(distfn, x, shape_args, defaults, meths):
    ## Check calling w/ named arguments.

    # check consistency of shapes, numargs and _parse signature
    signature = _getargspec(distfn._parse_args)
    npt.assert_(signature.varargs is None)
    npt.assert_(signature.keywords is None)
    npt.assert_(list(signature.defaults) == list(defaults))

    shape_argnames = signature.args[:-len(defaults)]  # a, b, loc=0, scale=1
    if distfn.shapes:
        shapes_ = distfn.shapes.replace(',', ' ').split()
    else:
        shapes_ = ''
    npt.assert_(len(shapes_) == distfn.numargs)
    npt.assert_(len(shapes_) == len(shape_argnames))

    # check calling w/ named arguments
    shape_args = list(shape_args)

    vals = [meth(x, *shape_args) for meth in meths]
    npt.assert_(np.all(np.isfinite(vals)))

    names, a, k = shape_argnames[:], shape_args[:], {}
    while names:
        k.update({names.pop(): a.pop()})
        v = [meth(x, *a, **k) for meth in meths]
        npt.assert_array_equal(vals, v)
        if 'n' not in k.keys():
            # `n` is first parameter of moment(), so can't be used as named arg
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", UserWarning)
                npt.assert_equal(distfn.moment(1, *a, **k),
                                 distfn.moment(1, *shape_args))

    # unknown arguments should not go through:
    k.update({'kaboom': 42})
    npt.assert_raises(TypeError, distfn.cdf, x, **k) 
Example 23
Project: LaserTOF   Author: kyleuckert   File: test_discrete_basic.py    MIT License 5 votes vote down vote up
def check_cdf_ppf(distfn, arg, supp, msg):
    # cdf is a step function, and ppf(q) = min{k : cdf(k) >= q, k integer}
    npt.assert_array_equal(distfn.ppf(distfn.cdf(supp, *arg), *arg),
                           supp, msg + '-roundtrip')
    npt.assert_array_equal(distfn.ppf(distfn.cdf(supp, *arg) - 1e-8, *arg),
                           supp, msg + '-roundtrip')

    if not hasattr(distfn, 'xk'):
        supp1 = supp[supp < distfn.b]
        npt.assert_array_equal(distfn.ppf(distfn.cdf(supp1, *arg) + 1e-8, *arg),
                               supp1 + distfn.inc, msg + ' ppf-cdf-next')
        # -1e-8 could cause an error if pmf < 1e-8 
Example 24
Project: chainer-deconv   Author: germanRos   File: test_ndarray_get.py    MIT License 5 votes vote down vote up
def check_get(self, f, stream):
        a_gpu = f(cupy)
        a_cpu = f(numpy)
        np_testing.assert_array_equal(a_gpu.get(stream), a_cpu) 
Example 25
Project: plydata   Author: has2k1   File: test_dataframe.py    BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_group_by():
    df = pd.DataFrame({'x': [1, 5, 2, 2, 4, 0, 4],
                       'y': [1, 2, 3, 4, 5, 6, 5],
                       'z': [1, 2, 3, 4, 5, 6, 5],
                       'w': [1, 2, 3, 4, 5, 6, 5],
                       })
    result = df >> group_by('x')
    assert isinstance(result, GroupedDataFrame)
    assert result.plydata_groups == ['x']

    result = df >> group_by('x-1', xsq='x**2')
    assert 'x-1' in result
    assert 'xsq' in result
    assert isinstance(result, GroupedDataFrame)

    result = df >> group_by('x') >> group_by('y')
    assert result.plydata_groups == ['y']

    result = df >> group_by('x') >> group_by('y', add_=True)
    assert result.plydata_groups == ['x', 'y']

    result = df >> group_by('x', 'w') >> group_by('y', 'x', add_=True)
    assert result.plydata_groups == ['x', 'w', 'y']

    result = df >> group_by(x='2*x', y='2*y')
    assert result.plydata_groups == ['x', 'y']
    npt.assert_array_equal(result['x'], 2*df['x']) 
Example 26
Project: tenpy   Author: tenpy   File: test_mps.py    GNU General Public License v3.0 5 votes vote down vote up
def test_compute_K():
    pairs = [(0, 1), (2, 3), (4, 5)]  # singlets on a 3x2 grid -> k_y = pi
    psi = mps.MPS.from_singlets(spin_half, 6, pairs, bc='infinite')
    psi.test_sanity()
    lat = Square(3, 2, spin_half, order='default', bc_MPS='infinite', bc='periodic')
    U, W, q, ov, te = psi.compute_K(lat, verbose=100)
    assert (ov == -1.)
    npt.assert_array_equal(W, [1.]) 
Example 27
Project: tenpy   Author: tenpy   File: test_random_matrix.py    GNU General Public License v3.0 5 votes vote down vote up
def test_random_matrix_GOE():
    for size in [1, 3, 4]:
        a = rmat.GOE((size, size))
        assert (a.dtype == np.float)
        print(a)
        npt.assert_array_equal(a, a.T)
    b = npc.Array.from_func_square(rmat.GOE, leg)
    b.test_sanity()
    assert (b.dtype == np.float)
    print("b =", b)
    assert (npc.norm(b - b.conj().itranspose()) == 0) 
Example 28
Project: tenpy   Author: tenpy   File: test_random_matrix.py    GNU General Public License v3.0 5 votes vote down vote up
def test_random_matrix_GUE():
    for size in [1, 3, 4]:
        a = rmat.GUE((size, size))
        assert (a.dtype == np.complex)
        print(a)
        npt.assert_array_equal(a, a.T.conj())
    b = npc.Array.from_func_square(rmat.GUE, leg)
    b.test_sanity()
    assert (b.dtype == np.complex)
    print("b =", b)
    assert (npc.norm(b - b.conj().itranspose()) == 0) 
Example 29
Project: tenpy   Author: tenpy   File: test_random_matrix.py    GNU General Public License v3.0 5 votes vote down vote up
def test_random_matrix_COE():
    for size in [1, 3, 4]:
        a = rmat.COE((size, size))
        assert (a.dtype == np.complex)
        print(a)
        npt.assert_array_equal(a, a.T)
        npt.assert_allclose(np.dot(a, a.conj().T), np.eye(size), EPS, EPS)
    b = npc.Array.from_func_square(rmat.COE, leg)
    b.test_sanity()
    assert (b.dtype == np.complex)
    print("b =", b)
    assert (npc.norm(b - b.conj(complex_conj=False).itranspose()) == 0)
    id = npc.eye_like(b)
    assert (npc.norm(npc.tensordot(b, b.complex_conj(), axes=[1, 0]) - id) < EPS)
    assert (npc.norm(npc.tensordot(b.complex_conj(), b, axes=[1, 0]) - id) < EPS) 
Example 30
Project: att   Author: Centre-Alt-Rendiment-Esportiu   File: common_tests.py    GNU General Public License v3.0 5 votes vote down vote up
def check_named_args(distfn, x, shape_args, defaults, meths):
    ## Check calling w/ named arguments.

    # check consistency of shapes, numargs and _parse signature
    signature = inspect.getargspec(distfn._parse_args)
    npt.assert_(signature.varargs is None)
    npt.assert_(signature.keywords is None)
    npt.assert_(signature.defaults == defaults)

    shape_argnames = signature.args[1:-len(defaults)]  # self, a, b, loc=0, scale=1
    if distfn.shapes:
        shapes_ = distfn.shapes.replace(',', ' ').split()
    else:
        shapes_ = ''
    npt.assert_(len(shapes_) == distfn.numargs)
    npt.assert_(len(shapes_) == len(shape_argnames))

    # check calling w/ named arguments
    shape_args = list(shape_args)

    vals = [meth(x, *shape_args) for meth in meths]
    npt.assert_(np.all(np.isfinite(vals)))

    names, a, k = shape_argnames[:], shape_args[:], {}
    while names:
        k.update({names.pop(): a.pop()})
        v = [meth(x, *a, **k) for meth in meths]
        npt.assert_array_equal(vals, v)
        if 'n' not in k.keys():
            # `n` is first parameter of moment(), so can't be used as named arg
            with warnings.catch_warnings():
                warnings.simplefilter("ignore", UserWarning)
                npt.assert_equal(distfn.moment(1, *a, **k),
                                 distfn.moment(1, *shape_args))

    # unknown arguments should not go through:
    k.update({'kaboom': 42})
    npt.assert_raises(TypeError, distfn.cdf, x, **k) 
Example 31
Project: att   Author: Centre-Alt-Rendiment-Esportiu   File: test_discrete_basic.py    GNU General Public License v3.0 5 votes vote down vote up
def check_cdf_ppf(distfn, arg, supp, msg):
    # cdf is a step function, and ppf(q) = min{k : cdf(k) >= q, k integer}
    npt.assert_array_equal(distfn.ppf(distfn.cdf(supp, *arg), *arg),
                           supp, msg + '-roundtrip')
    npt.assert_array_equal(distfn.ppf(distfn.cdf(supp, *arg) - 1e-8, *arg),
                           supp, msg + '-roundtrip')
    supp1 = supp[supp < distfn.b]
    npt.assert_array_equal(distfn.ppf(distfn.cdf(supp1, *arg) + 1e-8, *arg),
                     supp1 + distfn.inc, msg + 'ppf-cdf-next')
    # -1e-8 could cause an error if pmf < 1e-8 
Example 32
Project: astroNN   Author: henrysky   File: test_apogee_tools.py    MIT License 5 votes vote down vote up
def test_apogee_tools(self):
        # Example data
        raw_spectra = np.ones((10, 8575))
        raw_spectrum = np.ones(8575)
        wrong_spectrum = np.ones(1024)

        gap_deleted = gap_delete(raw_spectra)
        self.assertEqual(gap_deleted.shape == (10, 7514), True)
        gap_deleted = gap_delete(raw_spectrum)
        self.assertEqual(gap_deleted.shape == (1, 7514), True)
        gap_deleted = gap_delete(raw_spectra, dr=12)
        self.assertEqual(gap_deleted.shape == (10, 7214), True)
        gap_deleted = gap_delete(raw_spectrum, dr=12)
        self.assertEqual(gap_deleted.shape == (1, 7214), True)
        self.assertRaises(EnvironmentError, gap_delete, wrong_spectrum)

        # check gaia default dr
        dr = apogee_default_dr()
        self.assertEqual(dr, 14)
        dr = apogee_default_dr(dr=3)
        self.assertEqual(dr, 3)

        # bitmask
        self.assertEqual(bitmask_decompositor(0), None)
        npt.assert_array_equal(bitmask_decompositor(1), [0])
        npt.assert_array_equal(bitmask_decompositor(3), [0, 1])
        npt.assert_array_equal(bitmask_boolean([0, 1, 2], [0]), [[False, True, False]])
        self.assertRaises(ValueError, bitmask_decompositor, -1)

        # chips_split
        blue, green, red = chips_split(raw_spectra)
        self.assertEqual(np.concatenate((blue, green, red), axis=1).shape == (10, 7514), True)
        blue, green, red = chips_split(raw_spectrum)
        self.assertEqual(np.concatenate((blue, green, red), axis=1).shape == (1, 7514), True)
        self.assertRaises(ValueError, chips_split, raw_spectra, dr=10) 
Example 33
Project: astroNN   Author: henrysky   File: test_apogee_tools.py    MIT License 5 votes vote down vote up
def test_apogee_digit_extractor(self):
        # Test apogeeid digit extractor
        # just to make no error
        apogeeid_digit(["2M00380508+5608579", "2M00380508+5608579"])
        apogeeid_digit(np.array(["2M00380508+5608579", "2M00380508+5608579"]))

        # check accuracy
        self.assertEqual(apogeeid_digit("2M00380508+5608579"), '2003805085608579')
        npt.assert_array_equal(apogeeid_digit(np.array(["2M00380508+5608579", "2M00380508+5608579"])),
                               ['2003805085608579', '2003805085608579']) 
Example 34
Project: astroNN   Author: henrysky   File: test_loss_func.py    MIT License 5 votes vote down vote up
def test_loss_magic(self):
        # =============Magic correction term============= #
        with tf.device("/cpu:0"), context.eager_mode():
            y_true = tf.constant([[2., MAGIC_NUMBER, MAGIC_NUMBER], [2., MAGIC_NUMBER, 4.]])
            npt.assert_array_equal(magic_correction_term(y_true).numpy(), [3., 1.5]) 
Example 35
Project: astroNN   Author: henrysky   File: test_loss_func.py    MIT License 5 votes vote down vote up
def test_loss_acurrancy(self):
        # =============Accuracy============= #
        with tf.device("/cpu:0"), context.eager_mode():
            y_pred = tf.constant([[1., 0., 0.], [1., 0., 0.]])
            y_true = tf.constant([[1., MAGIC_NUMBER, 1.], [0., MAGIC_NUMBER, 1.]])

            npt.assert_array_equal(categorical_accuracy(y_true, y_pred).numpy(), [1., 0.])
            npt.assert_almost_equal(binary_accuracy(y_true, y_pred).numpy(), [1. / 2., 0.]) 
Example 36
Project: astroNN   Author: henrysky   File: test_numpy_tools.py    MIT License 5 votes vote down vote up
def test_relu(self):
        # make sure its the same as tensorflow
        x = np.array([-1., 2., 3., 4.])
        astroNN_x = relu(x)
        with tf.device("/cpu:0"), context.eager_mode():
            tf_x = tf.nn.relu(tf.convert_to_tensor(x))
            npt.assert_array_equal(tf_x.numpy(), astroNN_x) 
Example 37
Project: astroNN   Author: henrysky   File: test_numpy_tools.py    MIT License 5 votes vote down vote up
def test_numpy_metrics(self):
        x = np.array([-2., 2.])
        y = np.array([MAGIC_NUMBER, 4.])

        # ------------------- Mean ------------------- #
        mean_absolute_error([2., 3., 7.], [2., 0., 7.])
        mape = mean_absolute_percentage_error(x * u.kpc, y * u.kpc)
        mape_ubnitless = mean_absolute_percentage_error(x, y)
        npt.assert_array_equal(mape, 50.)
        npt.assert_array_equal(mape, mape_ubnitless)
        # assert error raise if only x or y carries astropy units
        self.assertRaises(TypeError, mean_absolute_percentage_error, x * u.kpc, y)
        self.assertRaises(TypeError, mean_absolute_percentage_error, x, y * u.kpc)

        mae = mean_absolute_error(x * u.kpc, y * u.kpc)
        mae_diffunits = mean_absolute_error((x * u.kpc).to(u.parsec), y * u.kpc) / 1000
        mae_ubnitless = mean_absolute_error(x, y)
        npt.assert_array_equal(mae, 2.)
        npt.assert_array_equal(mae, mae_ubnitless)
        npt.assert_array_equal(mae, mae_diffunits)
        # assert error raise if only x or y carries astropy units
        self.assertRaises(TypeError, mean_absolute_error, x * u.kpc, y)
        self.assertRaises(TypeError, mean_absolute_error, x, y * u.kpc)

        # ------------------- Median ------------------- #

        self.assertEqual(median_absolute_percentage_error([2., 3., 7.], [2., 1., 7.]), 0.)
        self.assertEqual(median_absolute_error([2., 3., 7.], [2., 1., 7.]), 0.) 
Example 38
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: times_test.py    MIT License 5 votes vote down vote up
def test_running_average():
        # test averaging values backward or forward from a given value and given hours unit
        yr = '2018-01-01 '
        time = pd.to_datetime([yr + ' 12', yr + ' 13', yr + ' 15', yr + '16', yr + '17'], utc=True).tolist()
        value = [2, np.nan, 3, 4, 5]
        # expected to forward-average values into 12:00 and 15:00 (unit: 3 hours)
        forward_averaged = times.running_average(time=time, value=value, group_hours=3)
        np_test.assert_array_equal(x=[2, 2, 3, 3.5, 4], y=forward_averaged)
        # expected to backward-average
        backward_averaged = times.running_average(time=time, value=value, group_hours=3, direction=-1)
        np_test.assert_array_equal(x=[2, 0, 4, 4.5, 5], y=backward_averaged)
        # put whole group average for each member
        whole_averaged = times.running_average(time=time, value=value, group_hours=3, whole_group=True)
        np_test.assert_array_equal(x=[2, 2, 4, 4, 4], y=whole_averaged) 
Example 39
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: times_test.py    MIT License 5 votes vote down vote up
def test_group_average(self):
        yr = '2018-01-01 '
        time = pd.to_datetime([yr + ' 13', yr + '14', yr + ' 15', yr + '16', yr + '17', yr + '18'], utc=True).tolist()
        value = [2, 3, 4, np.nan, 5, 6]
        expected_group_time = pd.to_datetime([yr + ' 12', yr + '15', yr + ' 18'], utc=True).tolist()
        group_time, group_average, lookup, count = times.group_average(time=time, value=value, group_hours=3)
        # time groups: 12:00, 15:00, and 18:00
        np_test.assert_array_equal(x=expected_group_time, y=group_time)
        np_test.assert_array_equal(x=[2.5, 4.5, 6], y=group_average)
        np_test.assert_array_equal(x=[2, 2, 1], y=count)
        self.assertEqual(0, lookup[expected_group_time[0]])
        self.assertEqual(1, lookup[expected_group_time[1]])
        self.assertEqual(2, lookup[expected_group_time[2]]) 
Example 40
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: times_test.py    MIT License 5 votes vote down vote up
def test_one_hot():
        columns = ['01', '02', '03', '04']
        s = pd.to_datetime(pd.Series(data=[1, 2, 4]), utc=True, format='%H')
        one_hot = times.one_hot(times=s, columns=columns, time_format='%H')
        np_test.assert_array_equal(x=[[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1]], y=one_hot) 
Example 41
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: reform_test.py    MIT License 5 votes vote down vote up
def test_split():
        values = [1, 2, 3, 4, 5]
        yr = '2018-01-01 '
        times = pd.to_datetime(
            [yr + '12:00:00', yr + '13:00:00', yr + '14:00:00',
             yr + '15:00:00', yr + '16:00:00'], utc=True).tolist()
        t, x = reform.split(times, values, shift=2, step=2, skip=1)
        expected_x = [[2, 3], [4, 5]]
        expected_t = pd.to_datetime(pd.Series(
            [yr + '13:00:00', yr + '14:00:00']
        ), utc=True).tolist()
        np_test.assert_array_equal(expected_t, t)
        np_test.assert_array_equal(expected_x, x) 
Example 42
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: reform_test.py    MIT License 5 votes vote down vote up
def test_form():
        value = [1, 2, 3, 4, 5]
        # expected to average from start to end
        average_forward = reform.average(value, 1)
        np_test.assert_array_equal(x=[1, 1.5, 3, 3.5, 5], y=average_forward)
        # expected to average from end to start
        average_backward = reform.average(value, -1)
        np_test.assert_array_equal(x=[1.5, 2, 3.5, 4, 5], y=average_backward) 
Example 43
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: util_test.py    MIT License 5 votes vote down vote up
def test_dataframe_numpy_convertion(self):
        df = pd.DataFrame(data={'a': [1, 2], 'b': [3, 4]})
        df_to_np = df.values.reshape(df.size)
        array = np.array([[1, 3], [2, 4]]).reshape(df.size)
        np_test.assert_array_equal(df_to_np, array) 
Example 44
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: util_test.py    MIT License 5 votes vote down vote up
def test_shift():
        values = [1, 2, 3]
        util.shift(values)
        np_test.assert_array_equal(x=[2, 3, 1], y=values) 
Example 45
Project: kdd2018_air_pollution_prediction   Author: pouyaesm   File: util_test.py    MIT License 5 votes vote down vote up
def test_reverse():
        matrix = np.array([[1, 2], [3, 4]])
        reversed_row = util.reverse(matrix, axis=0)
        reversed_column = util.reverse(matrix, axis=1)
        np_test.assert_array_equal(x=[[2, 1], [4, 3]], y=reversed_column)
        np_test.assert_array_equal(x=[[3, 4], [1, 2]], y=reversed_row) 
Example 46
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 5 votes vote down vote up
def det_sim_tests(self, det, old_style=False, single=True):
        self.assertEqual(det.num_pix, 10201)
        self.assertEqual(det.rel_num_pix, 7540)
        if not old_style:
            self.assertAlmostEqual(det.detd, 585.9375)
            self.assertAlmostEqual(det.ewald_rad, 585.9375)
        self.assertEqual((det.mask==0).sum(), 7540)
        self.assertEqual((det.mask==1).sum(), 2356)
        self.assertEqual((det.mask==2).sum(), 305)
        arr = np.ones(101, dtype='u1')
        arr[41:60] = 0
        npt.assert_equal(det.mask[101:202], arr)
        if single:
            self.assertEqual(det.num_det, 1)
            npt.assert_array_equal(det.mapping, np.zeros(1024, dtype='i4')) 
Example 47
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 5 votes vote down vote up
def test_parse_detector_list(self):
        print('=== Testing parse_detector_list() ===')
        shutil.copyfile(recon_folder+b'/data/det_sim.dat', recon_folder+b'/data/det_sim_test.dat')
        list_fname = 'test_det_list.txt'
        
        det = detector.detector()
        with open(list_fname, 'w') as f:
            f.writelines([(recon_folder+b'/data/det_sim.dat\n').decode('utf-8'), (recon_folder+b'/data/det_sim.dat\n').decode('utf-8')])
        self.assertAlmostEqual(det.parse_detector_list(bytes(list_fname, 'utf-8')), 70.32817314646061) 
        self.assertEqual(det.num_dfiles, 2)
        self.det_sim_tests(det)
        self.assertIs(det.nth_det(1), None)
        
        det = detector.detector()
        with open(list_fname, 'w') as f:
            f.writelines([(recon_folder+b'/data/det_sim.dat\n').decode('utf-8'), (recon_folder+b'/data/det_sim_test.dat\n').decode('utf-8')])
        det.parse_detector_list(bytes(list_fname, 'utf-8'))
        self.assertEqual(det.num_dfiles, 2)
        self.assertEqual(det.num_det, 2)
        npt.assert_array_equal(det.mapping, [0,1]+1022*[0])
        self.det_sim_tests(det, single=False)
        self.det_sim_tests(det.nth_det(1), single=False)
        self.assertIs(det.nth_det(2), None)
        
        os.remove(list_fname)
        os.remove(recon_folder+b'/data/det_sim_test.dat') 
Example 48
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 5 votes vote down vote up
def test_make_blacklist(self):
        print('=== Testing make_blacklist() ===')
        det = self.create_det()
        dset = dataset.dataset(det)
        dset.parse_dataset(recon_folder+b'/data/photons.emc')
        dset.make_blacklist(b'')
        self.assertEqual(dset.blacklist.shape[0], 3000)
        self.assertEqual(dset.blacklist.sum(), 0)
        
        dset.make_blacklist(b'', odd_flag=2)
        self.assertEqual(dset.blacklist.shape[0], 3000)
        self.assertEqual(dset.blacklist.sum(), 1500)
        npt.assert_array_equal(dset.blacklist[:4], [0,1,0,1])
        
        dset.make_blacklist(b'', odd_flag=1)
        self.assertEqual(dset.blacklist.shape[0], 3000)
        self.assertEqual(dset.blacklist.sum(), 1500)
        npt.assert_array_equal(dset.blacklist[:4], [1,0,1,0])
        
        blist_fname = recon_folder+b'/data/blacklist.dat'
        blist = np.zeros(dset.tot_num_data, dtype='u1')
        blist[:10] = 1
        np.savetxt(blist_fname.decode('utf-8'), blist, fmt='%d')
        dset.make_blacklist(blist_fname)
        self.assertEqual(dset.blacklist.shape[0], 3000)
        self.assertEqual(dset.blacklist.sum(), 10)
        npt.assert_array_equal(dset.blacklist[8:12], [1,1,0,0])
        
        # Behavior when both blacklist file and odd/even selection
        # Alternate frames which are not blacklisted by file are blacklisted
        dset.make_blacklist(blist_fname, odd_flag=2)
        self.assertEqual(dset.blacklist.shape[0], 3000)
        self.assertEqual(dset.blacklist.sum(), 1505)
        npt.assert_array_equal(dset.blacklist[8:12], [1,1,0,1])
        
        dset.make_blacklist(blist_fname, odd_flag=1)
        self.assertEqual(dset.blacklist.shape[0], 3000)
        self.assertEqual(dset.blacklist.sum(), 1505)
        npt.assert_array_equal(dset.blacklist[8:12], [1,1,1,0])
        os.remove(blist_fname) 
Example 49
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 5 votes vote down vote up
def test_allocate_memory(self):
        print('=== Testing static allocate_memory() ===')
        zarr = np.zeros(3000)
        zvol = np.zeros(3*(145,))
        
        data = max_emc.py_max_data(within_openmp=False)
        self.maximize.allocate_memory(data)
        npt.assert_array_equal(data.max_exp, zarr)
        npt.assert_array_equal(data.p_sum, zarr)
        npt.assert_array_equal(data.info, zarr)
        npt.assert_array_equal(data.likelihood, zarr)
        npt.assert_array_equal(data.rmax, np.zeros(3000, dtype='i4'))
        npt.assert_array_equal(data.u, np.zeros(3240))
        npt.assert_array_equal(data.max_exp_p, -np.ones(3000)*sys.float_info.max)
        self.assertEqual(data.probab.shape, (3240,3000))
        self.maximize.free_memory(data)
        
        data = max_emc.py_max_data(within_openmp=True)
        self.maximize.allocate_memory(data)
        npt.assert_array_equal(data.info, zarr)
        npt.assert_array_equal(data.likelihood, zarr)
        npt.assert_array_equal(data.p_sum, np.zeros(1))
        npt.assert_array_equal(data.rmax, np.zeros(3000, dtype='i4'))
        npt.assert_array_equal(data.max_exp_p, -np.ones(3000)*sys.float_info.max)
        npt.assert_array_equal(data.model, zvol)
        npt.assert_array_equal(data.weight, zvol)
        self.assertEqual(len(data.all_views), 1)
        self.assertEqual(len(data.all_views[0]), 10201)
        self.maximize.free_memory(data) 
Example 50
Project: Dragonfly   Author: duaneloh   File: unit.py    GNU General Public License v3.0 5 votes vote down vote up
def test_calculate_prob(self):
        print('=== Testing static calculate_prob() ===')
        common_data = max_emc.py_max_data(within_openmp=False)
        self.maximize.allocate_memory(common_data)
        rescale = self.maximize.calculate_rescale(common_data)
        priv_data = max_emc.py_max_data(within_openmp=True)
        self.maximize.allocate_memory(priv_data)
        self.maximize.calculate_prob(0, priv_data, common_data)
        npt.assert_array_almost_equal(common_data.probab[0,:5], [-4300.60968803, -3913.03874035, -3341.71258934, -5798.14606903, -4048.21180691])
        self.maximize.calculate_prob(1, priv_data, common_data)
        npt.assert_array_equal(np.where(priv_data.rmax==1)[0][:5], [1, 2, 6, 9, 13])
        self.maximize.free_memory(common_data)
        self.maximize.free_memory(priv_data)