# Buggy code
def deposit(self, positions, fields=None, method=None, kernel_name="cubic"):
    # Here we perform our particle deposition.
    cls = getattr(particle_deposit, "deposit_%s" % method, None)
    if cls is None:
        raise YTParticleDepositionNotImplemented(method)
    # We allocate number of zones, not number of octs
    # Everything inside this is fortran ordered, so we reverse it here.
    op = cls(tuple(self.ActiveDimensions)[::-1], kernel_name)
    op.initialize()
    op.process_grid(self, positions, fields)
    vals = op.finalize()
    if vals is None:
        return
    return vals.transpose()  # Fortran-ordered, so transpose.


# Traceback (IndexError)
yt : [INFO     ] 2017-05-08 14:18:25,422 integer runtime parameter checkpointfilenumber overwrites a simulation scalar of the same name
yt : [INFO     ] 2017-05-08 14:18:25,422 integer runtime parameter particlefilenumber overwrites a simulation scalar of the same name
yt : [INFO     ] 2017-05-08 14:18:25,422 integer runtime parameter plotfilenumber overwrites a simulation scalar of the same name
yt : [INFO     ] 2017-05-08 14:18:25,437 Parameters: current_time              = 50.0034519855
yt : [INFO     ] 2017-05-08 14:18:25,437 Parameters: domain_dimensions         = [2 2 2]
yt : [INFO     ] 2017-05-08 14:18:25,438 Parameters: domain_left_edge          = [ 0.  0.  0.]
yt : [INFO     ] 2017-05-08 14:18:25,438 Parameters: domain_right_edge         = [ 20.    0.5   0.5]
yt : [INFO     ] 2017-05-08 14:18:25,438 Parameters: cosmological_simulation   = 0.0
yt : [INFO     ] 2017-05-08 14:18:25,441 Allocating for 9.480e+04 particles (index particle type 'all')
yt : [INFO     ] 2017-05-08 14:18:25,468 Identified 3.969e+03 octs
Traceback (most recent call last):
File "to_grid.py", line 8, in <module>
print(vol["deposit", "all_density"].max())
File "/Applications/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 281, in __getitem__
self.get_data(f)
File "/Applications/anaconda/lib/python2.7/site-packages/yt/data_objects/construction_data_containers.py", line 640, in get_data
if len(gen) > 0: self._generate_fields(gen)
File "/Applications/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 1353, in _generate_fields
fd = self._generate_field(field)
File "/Applications/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 318, in _generate_field
tr = self._generate_fluid_field(field)
File "/Applications/anaconda/lib/python2.7/site-packages/yt/data_objects/data_containers.py", line 338, in _generate_fluid_field
rv = finfo(gen_obj)
File "/Applications/anaconda/lib/python2.7/site-packages/yt/fields/derived_field.py", line 234, in __call__
dd = self._function(self, data)
File "/Applications/anaconda/lib/python2.7/site-packages/yt/fields/particle_fields.py", line 129, in particle_density
d = data.deposit(pos, [mass], method = "sum")
File "/Applications/anaconda/lib/python2.7/site-packages/yt/data_objects/construction_data_containers.py", line 733, in deposit
op.process_grid(self, positions, fields)
File "yt/geometry/particle_deposit.pyx", line 144, in yt.geometry.particle_deposit.ParticleDepositOperation.process_grid (yt/geometry/particle_deposit.c:5633)
File "yt/geometry/particle_deposit.pyx", line 271, in yt.geometry.particle_deposit.SumParticleField.process (yt/geometry/particle_deposit.c:7204)
IndexError: Out of bounds on buffer access (axis 2)

# Fixed code
def deposit(self, positions, fields=None, method=None, kernel_name="cubic"):
    # Here we perform our particle deposition.
    cls = getattr(particle_deposit, "deposit_%s" % method, None)
    if cls is None:
        raise YTParticleDepositionNotImplemented(method)
    # We allocate number of zones, not number of octs. Everything inside
    # this is Fortran ordered because of the ordering in the octree deposit
    # routines, so we reverse it here to match the convention there
    op = cls(tuple(self.ActiveDimensions[::-1]), kernel_name)
    op.initialize()
    op.process_grid(self, positions, fields)
    vals = op.finalize()
    if vals is None:
        return
    # Fortran-ordered, so transpose.
    return vals.transpose()