# Buggy code
def _deposit_field(field, data):
    """
    Create a grid field for particle quantities using given method.
    """
    pos = data[ptype, "particle_position"]
    if method == "weighted_mean":
        d = data.ds.arr(
            data.deposit(
                pos,
                [data[ptype, deposit_field], data[ptype, weight_field]],
                method=method,
                kernel_name=kernel_name,
            ),
            input_units=units,
        )
        d[np.isnan(d)] = 0.0
    else:
        d = data.ds.arr(
            data.deposit(
                pos,
                [data[ptype, deposit_field]],
                method=method,
                kernel_name=kernel_name,
            ),
            input_units=units,
        )
    return d


# Traceback (ValueError)
jam:scratch desika$ python vel_proj_idealized.py
yt : [INFO     ] 2017-02-07 11:14:47,621 Omega Lambda is 0.0, so we are turning off Cosmology.
yt : [INFO     ] 2017-02-07 11:14:47,630 Parameters: current_time              = 0.25
yt : [INFO     ] 2017-02-07 11:14:47,630 Parameters: domain_dimensions         = [2 2 2]
yt : [INFO     ] 2017-02-07 11:14:47,631 Parameters: domain_left_edge          = [-1000. -1000. -1000.]
yt : [INFO     ] 2017-02-07 11:14:47,631 Parameters: domain_right_edge         = [ 1000.  1000.  1000.]
yt : [INFO     ] 2017-02-07 11:14:47,632 Parameters: cosmological_simulation   = 0
yt : [INFO     ] 2017-02-07 11:14:47,634 Allocating for 2.515e+07 particles (index particle type 'all')
yt : [INFO     ] 2017-02-07 11:14:51,665 Identified 1.540e+06 octs
[ 0.  0.  0. ...,  0.  0.  0.] code_velocity
Traceback (most recent call last):
File "vel_proj_idealized.py", line 23, in <module>
vy = arb[ ('deposit', 'PartType0_sum_velocity_y')]
File "/Users/desika/yt/yt/data_objects/data_containers.py", line 281, in __getitem__
self.get_data(f)
File "/Users/desika/yt/yt/data_objects/construction_data_containers.py", line 635, in get_data
if len(gen) > 0: self._generate_fields(gen)
File "/Users/desika/yt/yt/data_objects/data_containers.py", line 1353, in _generate_fields
fd = self._generate_field(field)
File "/Users/desika/yt/yt/data_objects/data_containers.py", line 318, in _generate_field
tr = self._generate_fluid_field(field)
File "/Users/desika/yt/yt/data_objects/data_containers.py", line 338, in _generate_fluid_field
rv = finfo(gen_obj)
File "/Users/desika/yt/yt/fields/derived_field.py", line 220, in __call__
dd = self._function(self, data)
File "/Users/desika/yt/yt/data_objects/static_output.py", line 1260, in _deposit_field
method=method, kernel_name=kernel_name),
File "/Users/desika/yt/yt/data_objects/construction_data_containers.py", line 728, in deposit
op.process_grid(self, positions, fields)
File "yt/geometry/particle_deposit.pyx", line 120, in yt.geometry.particle_deposit.ParticleDepositOperation.process_grid (yt/geometry/particle_deposit.c:5181)
ValueError: Buffer and memoryview are not contiguous in the same dimension.

# Fixed code
def _deposit_field(field, data):
    """
    Create a grid field for particle quantities using given method.
    """
    pos = data[ptype, "particle_position"]
    fields = [data[ptype, deposit_field]]
    if method == "weighted_mean":
        fields.append(data[ptype, weight_field])
    fields = [np.ascontiguousarray(f) for f in fields]
    d = data.deposit(pos, fields, method=method, kernel_name=kernel_name)
    d = data.ds.arr(d, input_units=units)
    if method == "weighted_mean":
        d[np.isnan(d)] = 0.0
    return d