Skip to content

Commit

Permalink
Merge pull request #507 from rainwoodman/fix-travis
Browse files Browse the repository at this point in the history
Fix travis by shrinking memory footprint
  • Loading branch information
rainwoodman authored Jul 3, 2018
2 parents 4b2c5bb + 7f4aee1 commit 59f5757
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ python:
- 3.6

env:
- NUMPY_VERSION=1.13
- NUMPY_VERSION=1.14

cache:
directories:
Expand Down
16 changes: 7 additions & 9 deletions nbodykit/algorithms/tests/test_fftcorr.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_fftcorr_poles(comm):
def test_fftcorr_unique(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTCorr(source, mode='1d', Nmesh=32, dr=0)
p = r.corr
Expand All @@ -37,7 +37,7 @@ def test_fftcorr_unique(comm):
def test_fftcorr_padding(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTCorr(source, mode='1d', BoxSize=1024, Nmesh=32)
assert r.attrs['N1'] != 0
Expand All @@ -47,7 +47,7 @@ def test_fftcorr_padding(comm):
def test_fftcorr_save(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTCorr(source, mode='2d', Nmesh=32)
r.save('fftcorr-test.json')
Expand All @@ -67,9 +67,8 @@ def test_fftcorr_mismatch_boxsize(comm):
CurrentMPIComm.set(comm)

# input sources
source1 = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
Plin = cosmology.LinearPower(cosmo, 0.55, transfer='NoWiggleEisensteinHu')
source2 = LinearMesh(Plin, BoxSize=1024, Nmesh=32, seed=33)
source1 = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)
source2 = UniformCatalog(nbar=3e-4, BoxSize=1024., seed=42)

r = FFTCorr(source1, second=source2, mode='1d', BoxSize=1024, Nmesh=32)

Expand All @@ -80,9 +79,8 @@ def test_fftcorr_mismatch_boxsize_fail(comm):
CurrentMPIComm.set(comm)

# input sources
mesh1 = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42).to_mesh(Nmesh=32)
Plin = cosmology.LinearPower(cosmo, 0.55, transfer='NoWiggleEisensteinHu')
mesh2 = LinearMesh(Plin, BoxSize=1024, Nmesh=32, seed=33)
mesh1 = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42).to_mesh(Nmesh=32)
mesh2 = UniformCatalog(nbar=3e-4, BoxSize=1024., seed=42).to_mesh(Nmesh=32)

# raises an exception b/c meshes have different box sizes
with pytest.raises(ValueError):
Expand Down
26 changes: 12 additions & 14 deletions nbodykit/algorithms/tests/test_fftpower.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def test_tsc_aliasing(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-2, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)
mesh = source.to_mesh(window='tsc', Nmesh=64, compensated=True)

# compute the power spectrum -- should be flat shot noise
Expand All @@ -29,7 +29,7 @@ def test_tsc_aliasing(comm):
def test_cic_aliasing(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-2, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)
mesh = source.to_mesh(window='cic', Nmesh=64, compensated=True)

# compute the power spectrum -- should be flat shot noise
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_fftpower_poles(comm):
def test_fftpower_unique(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTPower(source, mode='1d', Nmesh=32, dk=0)
p = r.power
Expand All @@ -74,7 +74,7 @@ def test_fftpower_unique(comm):
def test_fftpower_padding(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTPower(source, mode='1d', BoxSize=1024, Nmesh=32)
assert r.attrs['N1'] != 0
Expand All @@ -84,7 +84,7 @@ def test_fftpower_padding(comm):
def test_fftpower_save(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTPower(source, mode='2d', Nmesh=32)
r.save('fftpower-test.json')
Expand All @@ -100,7 +100,7 @@ def test_fftpower_save(comm):
def test_fftpower(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

r = FFTPower(source, mode='1d', Nmesh=32)
# the zero mode is cleared
Expand All @@ -113,9 +113,8 @@ def test_fftpower_mismatch_boxsize(comm):
CurrentMPIComm.set(comm)

# input sources
source1 = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
Plin = cosmology.LinearPower(cosmo, 0.55, transfer='NoWiggleEisensteinHu')
source2 = LinearMesh(Plin, BoxSize=1024, Nmesh=32, seed=33)
source1 = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)
source2 = UniformCatalog(nbar=3e-4, BoxSize=1024., seed=42)

r = FFTPower(source1, second=source2, mode='1d', BoxSize=1024, Nmesh=32)

Expand All @@ -126,9 +125,8 @@ def test_fftpower_mismatch_boxsize_fail(comm):
CurrentMPIComm.set(comm)

# input sources
mesh1 = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42).to_mesh(Nmesh=32)
Plin = cosmology.LinearPower(cosmo, 0.55, transfer='NoWiggleEisensteinHu')
mesh2 = LinearMesh(Plin, BoxSize=1024, Nmesh=32, seed=33)
mesh1 = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42).to_mesh(Nmesh=32)
mesh2 = UniformCatalog(nbar=3e-4, BoxSize=1024., seed=42).to_mesh(Nmesh=32)

# raises an exception b/c meshes have different box sizes
with pytest.raises(ValueError):
Expand All @@ -138,7 +136,7 @@ def test_fftpower_mismatch_boxsize_fail(comm):
def test_projectedpower(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=3e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=3e-4, BoxSize=512., seed=42)

Nmesh = 64
rp1 = ProjectedFFTPower(source, Nmesh=Nmesh, axes=[1])
Expand All @@ -154,4 +152,4 @@ def test_projectedpower(comm):

# FIXME: why a factor of 2?
assert_allclose(rp1.power['power'][1:].mean() * source.attrs['BoxSize'][0] ** 2, rf.power['power'][1:].mean(), rtol=2 * (Nmesh / 2)**-0.5)
assert_allclose(rp2.power['power'][1:].mean() * source.attrs['BoxSize'][0], rf.power['power'][1:].mean(), rtol=2 * (Nmesh ** 2 / 2)**-0.5)
assert_allclose(rp2.power['power'][1:].mean() * source.attrs['BoxSize'][0], rf.power['power'][1:].mean(), rtol=2 * (Nmesh ** 2 / 2)**-0.5 * 10)
6 changes: 3 additions & 3 deletions nbodykit/algorithms/tests/test_fof.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_fof(comm):

# lognormal particles
Plin = cosmology.LinearPower(cosmo, redshift=0.55, transfer='EisensteinHu')
source = LogNormalCatalog(Plin=Plin, nbar=3e-3, BoxSize=512., Nmesh=128, seed=42)
source = LogNormalCatalog(Plin=Plin, nbar=3e-3, BoxSize=128., Nmesh=32, seed=42)

# compute P(k,mu) and multipoles
fof = FOF(source, linking_length=0.2, nmin=20)
Expand Down Expand Up @@ -43,7 +43,7 @@ def test_fof_parallel_no_merge(comm):
def test_fof_parallel_merge(comm):
CurrentMPIComm.set(comm)
from pmesh.pm import ParticleMesh
pm = ParticleMesh(BoxSize=[32, 32, 32], Nmesh=[32, 32, 32], comm=comm)
pm = ParticleMesh(BoxSize=[8, 8, 8], Nmesh=[8, 8, 8], comm=comm)
Q = pm.generate_uniform_particle_grid(shift=0)
Q1 = Q.copy()
Q1[:] += 0.01
Expand All @@ -68,7 +68,7 @@ def test_fof_nonperiodic(comm):

# lognormal particles
Plin = cosmology.LinearPower(cosmo, redshift=0.55, transfer='EisensteinHu')
source = LogNormalCatalog(Plin=Plin, nbar=3e-3, BoxSize=512., Nmesh=128, seed=42)
source = LogNormalCatalog(Plin=Plin, nbar=3e-3, BoxSize=128., Nmesh=32, seed=42)

source['Density'] = KDDensity(source, margin=1).density

Expand Down
2 changes: 1 addition & 1 deletion nbodykit/algorithms/tests/test_kddensity.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def test_kddensity(comm):
CurrentMPIComm.set(comm)

Plin = cosmology.LinearPower(cosmo, redshift=0.55, transfer='EisensteinHu')
source = LogNormalCatalog(Plin=Plin, nbar=3e-3, BoxSize=512., Nmesh=128, seed=42)
source = LogNormalCatalog(Plin=Plin, nbar=3e-4, BoxSize=64., Nmesh=16, seed=42)

kdden = KDDensity(source)
assert kdden.density.size == source.size
Expand Down
24 changes: 12 additions & 12 deletions nbodykit/base/tests/test_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_save(comm):
tmpfile = comm.bcast(tmpfile)

# initialize a uniform catalog
source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# add a non-array attrs (saved as JSON)
source.attrs['empty'] = None
Expand Down Expand Up @@ -72,7 +72,7 @@ def allconcat(data):
def test_tomesh(comm):
CurrentMPIComm.set(comm)

source = UniformCatalog(nbar=0.2e-2, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)
source['Weight0'] = source['Velocity'][:, 0]
source['Weight1'] = source['Velocity'][:, 1]
source['Weight2'] = source['Velocity'][:, 2]
Expand Down Expand Up @@ -103,7 +103,7 @@ def test_tomesh(comm):
@MPITest([4])
def test_bad_column(comm):
CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# read a missing column
with pytest.raises(ValueError):
Expand All @@ -117,7 +117,7 @@ def test_bad_column(comm):
def test_empty_slice(comm):
CurrentMPIComm.set(comm)

source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# empty slice returns self
source2 = source[source['Selection']]
Expand All @@ -137,7 +137,7 @@ def test_empty_slice(comm):
def test_slice(comm):
CurrentMPIComm.set(comm)

source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# slice a subset
subset = source[:10]
Expand All @@ -161,7 +161,7 @@ def test_slice(comm):
def test_dask_slice(comm):
CurrentMPIComm.set(comm)

source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# add a selection column
index = numpy.random.choice([True, False], size=len(source))
Expand All @@ -175,7 +175,7 @@ def test_dask_slice(comm):
@MPITest([1, 4])
def test_index(comm):

source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42, comm=comm)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42, comm=comm)
r = numpy.concatenate(comm.allgather(source.Index.compute()))
assert_array_equal(r, range(source.csize))

Expand Down Expand Up @@ -212,7 +212,7 @@ def test_transform(comm):
def test_getitem_columns(comm):
CurrentMPIComm.set(comm)

source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# bad column name
with pytest.raises(KeyError):
Expand All @@ -227,7 +227,7 @@ def test_getitem_columns(comm):
def test_delitem(comm):

CurrentMPIComm.set(comm)
source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

# add a test column
test = numpy.ones(source.size)
Expand All @@ -247,7 +247,7 @@ def test_delitem(comm):

def test_columnaccessor():
from nbodykit.base.catalog import ColumnAccessor
source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)

c = source['Position']
truth = c[0].compute()
Expand Down Expand Up @@ -279,7 +279,7 @@ def test_columnaccessor():
@MPITest([1, 4])
def test_copy(comm):

source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42, comm=comm)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42, comm=comm)
source['TEST'] = 10
source.attrs['TEST'] = 'TEST'

Expand Down Expand Up @@ -316,7 +316,7 @@ def test_copy(comm):
@MPITest([4])
def test_view(comm):
# the CatalogSource
source = UniformCatalog(nbar=0.2e-3, BoxSize=512., seed=42, comm=comm)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42, comm=comm)
source['TEST'] = 10.
source.attrs['TEST'] = 10.0

Expand Down
6 changes: 3 additions & 3 deletions nbodykit/base/tests/test_catalogmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_view(comm):
CurrentMPIComm.set(comm)

# the CatalogSource
source = UniformCatalog(nbar=0.2e-3, BoxSize=1024., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)
source['TEST'] = 10.
source.attrs['TEST'] = 10.0

Expand All @@ -129,7 +129,7 @@ def test_apply_nocompensation(comm):
CurrentMPIComm.set(comm)

# the CatalogSource
source = UniformCatalog(nbar=0.2e-3, BoxSize=1024., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512, seed=42)
source['TEST'] = 10.
source['Position2'] = source['Position']
source.attrs['TEST'] = 10.0
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_apply_compensated(comm):
CurrentMPIComm.set(comm)

# the CatalogSource
source = UniformCatalog(nbar=0.2e-3, BoxSize=1024., seed=42)
source = UniformCatalog(nbar=2e-4, BoxSize=512., seed=42)
source['TEST'] = 10.
source['Position2'] = source['Position']
source.attrs['TEST'] = 10.0
Expand Down
10 changes: 6 additions & 4 deletions nbodykit/cosmology/power/zeldovich.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
NUM_PTS = 1024
KMIN = 1e-5
KMAX = 1e2
NMAX = 15

def isiterable(obj):
"""Returns `True` if the given object is iterable."""
Expand Down Expand Up @@ -49,11 +48,14 @@ class ZeldovichPower(object):
the redshift to compute the power at
Plin : class:`LinearPower`
the linear power spectrum class used to compute the Zel'dovich power
nmax : int
max order of integrals.
"""
def __init__(self, cosmo, redshift, transfer='CLASS'):
def __init__(self, cosmo, redshift, transfer='CLASS', nmax=32):

# initialize the linear power
self.Plin = LinearPower(cosmo, redshift, transfer='CLASS')
self.Plin = LinearPower(cosmo, redshift, transfer=transfer)
self.nmax = nmax

self.cosmo = self.Plin.cosmo
self._sigma8 = self.cosmo.sigma8
Expand Down Expand Up @@ -166,7 +168,7 @@ def Pzel_at_k(ki):

# do the full integral
Pzel = 0.0
for n in range(0, NMAX+1):
for n in range(0, self.nmax + 1):

I = ZeldovichPowerIntegral(self._r, n)
if n > 0:
Expand Down
6 changes: 3 additions & 3 deletions nbodykit/cosmology/tests/test_corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
def test_mcfit():

c = Cosmology()
Plin = LinearPower(c, redshift=0)
Plin = LinearPower(c, redshift=0, transfer='EisensteinHu')

for ell in [0, 2, 4]:
# do Pk to CF; use Plin for ell>0 just for testing
Expand All @@ -25,7 +25,7 @@ def test_linear():

# linear power
c = Cosmology()
Plin = LinearPower(c, redshift=0)
Plin = LinearPower(c, redshift=0, transfer='EisensteinHu')

# desired separation (in Mpc/h)
r = numpy.logspace(0, numpy.log10(150), 500)
Expand Down Expand Up @@ -68,7 +68,7 @@ def test_halofit():
def test_zeldovich():

# zeldovich power
Pzel = ZeldovichPower(Cosmology(), redshift=0)
Pzel = ZeldovichPower(Cosmology(), redshift=0, nmax=1, transfer='EisensteinHu')

# desired separation (in Mpc/h)
r = numpy.logspace(0, numpy.log10(150), 500)
Expand Down
2 changes: 1 addition & 1 deletion nbodykit/cosmology/tests/test_power.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_zeldovich():

# initialize the power
c = Cosmology().match(sigma8=0.82)
P = ZeldovichPower(c, redshift=0)
P = ZeldovichPower(c, redshift=0, nmax=1)

# compute for scalar
Pk = P(0.1)
Expand Down
Loading

0 comments on commit 59f5757

Please sign in to comment.