Open hsgg opened 4 years ago
The methods are moved to module methods under nbodykit/nbodykit/source/mesh/catalog.py.
Freshing the notebooks is not as streamlines as we'd like (I think they are hosted on a different repository but I need to revisit the maintenance doc). It will probably take a while for me to get to fix it -- unless you'd like to file a PR for the fix.
I checked nbodykit/nbodykit/source/mesh/catalog.py, and I found CompensateCIC is not in the CatalogMesh class.I put a series of functions into this class by indentation.This results in the following output:
`---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-4-fabc16e8388b> in <module>
3
4 # compute the 1D power of this mesh
----> 5 r = FFTPower(mesh, mode='1d')
6
7 # create a smooth interpolation
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/algorithms/fftpower.py in __init__(self, first, mode, Nmesh, BoxSize, second, los, Nmu, dk, kmin, kmax, poles)
222 self.attrs['kmax'] = kmax
223
--> 224 self.power, self.poles = self.run()
225
226 # for compatibility, copy power's attrs into self.
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/algorithms/fftpower.py in run(self)
279
280 # measure the 3D power (y3d is a ComplexField)
--> 281 y3d, attrs = self._compute_3d_power(self.first, self.second)
282
283 # binning in k out to the minimum nyquist frequency
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/algorithms/fftpower.py in _compute_3d_power(self, first, second)
103 attrs.update(self.attrs)
104
--> 105 c1 = first.compute(mode='complex', Nmesh=self.attrs['Nmesh'])
106
107 # compute the auto power of single supplied field
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/base/mesh.py in compute(self, mode, Nmesh)
248 Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
249 """
--> 250 return self._paint_XXX(mode=mode, Nmesh=Nmesh)
251
252 def paint(self, mode="real", Nmesh=None):
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/base/mesh.py in _paint_XXX(self, mode, Nmesh)
284
285 # add a dummy action to ensure the right mode of return value
--> 286 actions = self.actions + [(mode, )]
287
288 # if we expect complex, be smart and use complex directly.
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/source/mesh/catalog.py in actions(self)
411 actions = MeshSource.actions.fget(self)
412 if self.compensated:
--> 413 actions = self._get_compensation() + actions
414 return actions
415
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/source/mesh/catalog.py in _get_compensation(self)
415
416 def _get_compensation(self):
--> 417 return get_compensation(self.interlaced, self.resampler)
418 def CompensateTSC(w, v):
419 """
NameError: name 'get_compensation' is not defined`
Then, I'm going to copy and paste the function that I just moved behind the class, but it's not in this class.This results in the following output:
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-5-9af93b1333ff> in <module>
9 mesh = mesh.apply(compensation, kind='circular', mode='complex')
10 # compute the 1D power P(k)
---> 11 r = FFTPower(mesh, mode='1d')
12 Pk = r.power
13 # compare P(k) to the hi-resolution mesh P(k)
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/algorithms/fftpower.py in __init__(self, first, mode, Nmesh, BoxSize, second, los, Nmu, dk, kmin, kmax, poles)
222 self.attrs['kmax'] = kmax
223
--> 224 self.power, self.poles = self.run()
225
226 # for compatibility, copy power's attrs into self.
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/algorithms/fftpower.py in run(self)
279
280 # measure the 3D power (y3d is a ComplexField)
--> 281 y3d, attrs = self._compute_3d_power(self.first, self.second)
282
283 # binning in k out to the minimum nyquist frequency
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/algorithms/fftpower.py in _compute_3d_power(self, first, second)
103 attrs.update(self.attrs)
104
--> 105 c1 = first.compute(mode='complex', Nmesh=self.attrs['Nmesh'])
106
107 # compute the auto power of single supplied field
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/base/mesh.py in compute(self, mode, Nmesh)
248 Compute / Fetch the mesh object into memory as a RealField or ComplexField object.
249 """
--> 250 return self._paint_XXX(mode=mode, Nmesh=Nmesh)
251
252 def paint(self, mode="real", Nmesh=None):
~/anaconda3/envs/nbk/lib/python3.6/site-packages/nbodykit/base/mesh.py in _paint_XXX(self, mode, Nmesh)
311 kwargs['kind'] = action[2]
312 kwargs['out'] = Ellipsis
--> 313 var.apply(**kwargs)
314
315 # FIXME: get rid of this after pmesh 0.1.45+
~/anaconda3/envs/nbk/lib/python3.6/site-packages/pmesh/pm.py in apply(self, func, kind, out)
1068 """
1069 assert kind in ['wavenumber', 'circular', 'index']
-> 1070 return Field.apply(self, func, kind, out)
1071
1072 class UntransposedComplexField(BaseComplexField):
~/anaconda3/envs/nbk/lib/python3.6/site-packages/pmesh/pm.py in apply(self, func, kind, out)
643 elif kind == 'circular':
644 w = [ ki * L / N for ki, L, N in zip(x, self.BoxSize, self.Nmesh)]
--> 645 oslab[...] = func(w, islab)
646 else:
647 raise ValueError("unknown kind of apply function.")
TypeError: CompensateCIC() takes 2 positional arguments but 3 were given`.
I hope I described what I did clearly. How to fix this issue? @rainwoodman
The tutorial on The Effects of Interlaced Painting does not work. The function
mesh.CompensateCIC
no longer exists in the same place.To reproduce, I installed
nbodykit
withpip3 install --user nbodykit
on Debian. Then, copied the non-Jupyter code in the aforementioned tutorial into a text file, and run it on the command line withpython-3.7.3
.This results in the following output:
Expected behavior: Reproduce the example plot shown in the tutorial. Ideally, without the deprecation warnings.
nbodykit
version: