# Buggy code
def __init__(
    self, data_source, conditionals, ds=None, field_parameters=None, base_object=None
):
    validate_object(data_source, YTSelectionContainer)
    validate_iterable(conditionals)
    for condition in conditionals:
        validate_object(condition, string_types)
    validate_object(ds, Dataset)
    validate_object(field_parameters, dict)
    validate_object(base_object, YTSelectionContainer)
    if base_object is not None:
        # passing base_object explicitly has been deprecated,
        # but we handle it here for backward compatibility
        if data_source is not None:
            raise RuntimeError("Cannot use both base_object and data_source")
        data_source = base_object
    super(YTCutRegion, self).__init__(
        data_source.center, ds, field_parameters, data_source=data_source
    )
    self.conditionals = ensure_list(conditionals)
    self.base_object = data_source
    self._selector = None
    self._particle_mask = {}


# Traceback (IndexError)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-83-3704089812fe> in <module>
5 sp = ds.sphere((0.5, 0.5, 0.5), (5, "kpc"))
6 dense_sp = sp.cut_region(['obj["H_p0_number_density"]>= 1e-2'])
----> 7 dense_sp.quantities.angular_momentum_vector()

~/.local/lib/python3.6/site-packages/yt-3.6.dev0-py3.6-macosx-10.9-x86_64.egg/yt/data_objects/derived_quantities.py in __call__(self, *args, **kwargs)
67         storage = {}
68         for sto, ds in parallel_objects(chunks, -1, storage = storage):
---> 69             sto.result = self.process_chunk(ds, *args, **kwargs)
70         # Now storage will have everything, and will be done via pickling, so
71         # the units will be preserved.  (Credit to Nathan for this

~/.local/lib/python3.6/site-packages/yt-3.6.dev0-py3.6-macosx-10.9-x86_64.egg/yt/data_objects/derived_quantities.py in process_chunk(self, data, use_gas, use_particles, particle_type)
493             rvals.extend([(data[self.particle_type, "particle_specific_angular_momentum_%s" % axis] *
494                            data[self.particle_type, "particle_mass"]).sum(dtype=np.float64) \
--> 495                           for axis in "xyz"])
496             rvals.append(data[self.particle_type, "particle_mass"].sum(dtype=np.float64))
497         return rvals

~/.local/lib/python3.6/site-packages/yt-3.6.dev0-py3.6-macosx-10.9-x86_64.egg/yt/data_objects/derived_quantities.py in <listcomp>(.0)
493             rvals.extend([(data[self.particle_type, "particle_specific_angular_momentum_%s" % axis] *
494                            data[self.particle_type, "particle_mass"]).sum(dtype=np.float64) \
--> 495                           for axis in "xyz"])
496             rvals.append(data[self.particle_type, "particle_mass"].sum(dtype=np.float64))
497         return rvals

~/.local/lib/python3.6/site-packages/yt-3.6.dev0-py3.6-macosx-10.9-x86_64.egg/yt/data_objects/data_containers.py in __getitem__(self, key)
253                 return self.field_data[f]
254             else:
--> 255                 self.get_data(f)
256         # fi.units is the unit expression string. We depend on the registry
257         # hanging off the dataset to define this unit object.

~/.local/lib/python3.6/site-packages/yt-3.6.dev0-py3.6-macosx-10.9-x86_64.egg/yt/data_objects/selection_data_containers.py in get_data(self, fields)
901                 parent = getattr(self, "parent", self.base_object)
902                 self.field_data[field] = \
--> 903                   parent[field][self._part_ind(field[0])]
904             else:
905                 self.field_data[field] = self.base_object[field][ind]

~/.local/lib/python3.6/site-packages/yt-3.6.dev0-py3.6-macosx-10.9-x86_64.egg/yt/units/yt_array.py in __getitem__(self, item)
1056
1057     def __getitem__(self, item):
-> 1058         ret = super(YTArray, self).__getitem__(item)
1059         if ret.shape == ():
1060             return YTQuantity(ret, self.units, bypass_validation=True)

IndexError: boolean index did not match indexed array along dimension 0; dimension is 44461 but corresponding boolean dimension is 3218

# Fixed code
def __init__(
    self, data_source, conditionals, ds=None, field_parameters=None, base_object=None
):
    validate_object(data_source, YTSelectionContainer)
    validate_iterable(conditionals)
    for condition in conditionals:
        validate_object(condition, string_types)
    validate_object(ds, Dataset)
    validate_object(field_parameters, dict)
    validate_object(base_object, YTSelectionContainer)
    if base_object is not None:
        # passing base_object explicitly has been deprecated,
        # but we handle it here for backward compatibility
        if data_source is not None:
            raise RuntimeError("Cannot use both base_object and data_source")
        data_source = base_object
    super(YTCutRegion, self).__init__(
        data_source.center, ds, field_parameters, data_source=data_source
    )
    self.conditionals = ensure_list(conditionals)
    self.base_object = data_source
    self._selector = None