Skip to content

Commit

Permalink
Removing usage of deprecated numpy.random.random_integers to use nump…
Browse files Browse the repository at this point in the history
…y.random.randint instead
  • Loading branch information
bsipocz committed May 30, 2016
1 parent 9d99810 commit 77daf9b
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def mean_occupation(self, **kwargs):

def mc_occupation(self, **kwargs):
table = kwargs['table']
result = np.random.random_integers(0, 1, len(table))
result = np.random.randint(0, 2, len(table))
table['halo_num_centrals'] = result
return result

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ def npairs_jackknife_3d(sample1, sample2, rbins, period=None, weights1=None, wei
use randomly assigned sub-volumes as this has no impact on the calling signature:
>>> N_samples = 10
>>> jtags1 = np.random.random_integers(1, N_samples, Npts1)
>>> jtags2 = np.random.random_integers(1, N_samples, Npts2)
>>> jtags1 = np.random.randint(1, N_samples+1, Npts1)
>>> jtags2 = np.random.randint(1, N_samples+1, Npts2)
>>> result = npairs_jackknife_3d(sample1, sample2, rbins, period = period, jtags1=jtags1, jtags2=jtags2, N_samples = N_samples)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_npairs_jackknife_3d_periodic():
#define the jackknife sample labels
Npts = len(random_sample)
N_jsamples=10
jtags1 = np.sort(np.random.random_integers(1, N_jsamples, size=Npts))
jtags1 = np.sort(np.random.randint(1, N_jsamples+1, size=Npts))

#define weights
weights1 = np.random.random(Npts)
Expand Down Expand Up @@ -90,7 +90,7 @@ def test_npairs_jackknife_3d_nonperiodic():
#define the jackknife sample labels
Npts = len(random_sample)
N_jsamples=10
jtags1 = np.sort(np.random.random_integers(1, N_jsamples, size=Npts))
jtags1 = np.sort(np.random.randint(1, N_jsamples+1, size=Npts))

#define weights
weights1 = np.random.random(Npts)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_tpcf_one_two_halo_auto_periodic():
"""
Npts = 100
with NumpyRNGContext(fixed_seed):
IDs1 = np.random.random_integers(0, 10, Npts)
IDs1 = np.random.randint(0, 11, Npts)
sample1 = np.random.random((Npts, 3))

result = tpcf_one_two_halo_decomp(sample1, IDs1, rbins, sample2=None,
Expand All @@ -45,8 +45,8 @@ def test_tpcf_one_two_halo_cross_periodic():
"""
Npts = 100
with NumpyRNGContext(fixed_seed):
IDs1 = np.random.random_integers(0, 10, Npts)
IDs2 = np.random.random_integers(0, 10, Npts)
IDs1 = np.random.randint(0, 11, Npts)
IDs2 = np.random.randint(0, 11, Npts)
sample1 = np.random.random((Npts, 3))
sample2 = np.random.random((Npts, 3))

Expand Down
2 changes: 1 addition & 1 deletion halotools/sim_manager/tests/test_rockstar_hlist_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def write_temporary_ascii(num_halos, temp_fname):
with NumpyRNGContext(fixed_seed):
d['halo_spin_bullock'] = np.random.random(num_halos).astype('f4')
d['halo_id'] = np.arange(num_halos).astype('i8')
d['halo_upid'] = np.random.random_integers(-1, 5, num_halos).astype('i8')
d['halo_upid'] = np.random.randint(-1, 6, num_halos).astype('i8')
d['halo_x'] = np.random.random(num_halos).astype('f4')
d['halo_y'] = np.random.random(num_halos).astype('f4')
d['halo_z'] = np.random.random(num_halos).astype('f4')
Expand Down
2 changes: 1 addition & 1 deletion halotools/utils/crossmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def crossmatch(x, y, skip_bounds_checking=False):
>>> x = np.random.rand(num_galaxies)
>>> objid = np.arange(num_galaxies)
>>> num_groups = int(1e4)
>>> groupid = np.random.random_integers(0, num_groups-1, num_galaxies)
>>> groupid = np.random.randint(0, num_groups, num_galaxies)
>>> galaxy_table = Table({'x': x, 'objid': objid, 'groupid': groupid})
>>> groupmass = np.random.rand(num_groups)
Expand Down
2 changes: 1 addition & 1 deletion halotools/utils/tests/test_crossmatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_crossmatch5():
xmax = 100
numx = 10000
with NumpyRNGContext(fixed_seed):
x = np.random.random_integers(0, xmax, numx)
x = np.random.randint(0, xmax+1, numx)

y = np.arange(-xmax, xmax)[::10]
np.random.shuffle(y)
Expand Down

0 comments on commit 77daf9b

Please sign in to comment.