# Buggy code
def _set_center(self, center):
    if center is None:
        self.center = None
        return
    elif isinstance(center, YTArray):
        self.center = self.ds.arr(center.astype("float64"))
        self.center.convert_to_units("code_length")
    elif isinstance(center, (list, tuple, np.ndarray)):
        if isinstance(center[0], YTQuantity):
            self.center = self.ds.arr([c.copy() for c in center], dtype="float64")
            self.center.convert_to_units("code_length")
        else:
            self.center = self.ds.arr(center, "code_length", dtype="float64")
    elif isinstance(center, str):
        if center.lower() in ("c", "center"):
            self.center = self.ds.domain_center
        # is this dangerous for race conditions?
        elif center.lower() in ("max", "m"):
            self.center = self.ds.find_max(("gas", "density"))[1]
        elif center.startswith("max_"):
            self.center = self.ds.find_max(center[4:])[1]
        elif center.lower() == "min":
            self.center = self.ds.find_min(("gas", "density"))[1]
        elif center.startswith("min_"):
            self.center = self.ds.find_min(center[4:])[1]
    else:
        self.center = self.ds.arr(center, "code_length", dtype="float64")
    self.set_field_parameter("center", self.center)


# Traceback (TypeError)
Traceback (most recent call last):
File "/tmp/fail.py", line 13, in <module>
sp['density']
File "/home/ccc/Documents/prog/yt/yt/data_objects/data_containers.py", line 256, in __getitem__
self.get_data(f)
File "/home/ccc/Documents/prog/yt/yt/data_objects/data_containers.py", line 1482, in get_data
self.index._identify_base_chunk(self)
File "/home/ccc/Documents/prog/yt/yt/frontends/ramses/data_structures.py", line 277, in _identify_base_chunk
domains = [dom for dom in self.domains if
File "/home/ccc/Documents/prog/yt/yt/frontends/ramses/data_structures.py", line 278, in <listcomp>
dom.included(dobj.selector)]
File "/home/ccc/Documents/prog/yt/yt/data_objects/data_containers.py", line 1434, in selector
self._selector = sclass(self)
File "yt/geometry/selection_routines.pyx", line 717, in yt.geometry.selection_routines.SphereSelector.__init__
self.center[i] = _ensure_code(dobj.center[i])
TypeError: only size-1 arrays can be converted to Python scalars

# Fixed code
def _set_center(self, center):
    if center is None:
        self.center = None
        return
    elif isinstance(center, YTArray):
        self.center = self.ds.arr(center.astype("float64"))
        self.center.convert_to_units("code_length")
    elif isinstance(center, (list, tuple, np.ndarray)):
        if isinstance(center[0], YTQuantity):
            self.center = self.ds.arr([c.copy() for c in center], dtype="float64")
            self.center.convert_to_units("code_length")
        else:
            self.center = self.ds.arr(center, "code_length", dtype="float64")
    elif isinstance(center, str):
        if center.lower() in ("c", "center"):
            self.center = self.ds.domain_center
        # is this dangerous for race conditions?
        elif center.lower() in ("max", "m"):
            self.center = self.ds.find_max(("gas", "density"))[1]
        elif center.startswith("max_"):
            self.center = self.ds.find_max(center[4:])[1]
        elif center.lower() == "min":
            self.center = self.ds.find_min(("gas", "density"))[1]
        elif center.startswith("min_"):
            self.center = self.ds.find_min(center[4:])[1]
    else:
        self.center = self.ds.arr(center, "code_length", dtype="float64")

    if self.center.ndim > 1:
        mylog.debug("Removing singleton dimensions from 'center'.")
        self.center = np.squeeze(self.center)
        if self.center.ndim > 1:
            msg = (
                "center array must be 1 dimensional, supplied center has "
                f"{self.center.ndim} dimensions with shape {self.center.shape}."
            )
            raise YTException(msg)

    self.set_field_parameter("center", self.center)