# Buggy code
def _parse_enzo2_parameter_file(self, f):
    for line in (l.strip() for l in f):
        if len(line) < 2:
            continue
        param, vals = (i.strip() for i in line.split("=", 1))
        # First we try to decipher what type of value it is.
        vals = vals.split()
        # Special case approaching.
        if "(do" in vals:
            vals = vals[:1]
        if len(vals) == 0:
            pcast = str  # Assume NULL output
        else:
            v = vals[0]
            # Figure out if it's castable to floating point:
            try:
                float(v)
            except ValueError:
                pcast = str
            else:
                if any("." in v or "e+" in v or "e-" in v for v in vals):
                    pcast = float
                elif v == "inf":
                    pcast = str
                else:
                    pcast = int
        # Now we figure out what to do with it.
        if len(vals) == 0:
            vals = ""
        elif len(vals) == 1:
            vals = pcast(vals[0])
        else:
            vals = np.array([pcast(i) for i in vals if i != "-99999"])
        if param.startswith("Append"):
            if param not in self.parameters:
                self.parameters[param] = []
            self.parameters[param].append(vals)
        else:
            self.parameters[param] = vals
    self.refine_by = self.parameters["RefineBy"]
    self.periodicity = ensure_tuple(self.parameters["LeftFaceBoundaryCondition"] == 3)
    self.dimensionality = self.parameters["TopGridRank"]
    if "MetaDataDatasetUUID" in self.parameters:
        self.unique_identifier = self.parameters["MetaDataDatasetUUID"]
    elif "CurrentTimeIdentifier" in self.parameters:
        self.unique_identifier = self.parameters["CurrentTimeIdentifier"]
    else:
        self.unique_identifier = str(
            int(os.stat(self.parameter_filename)[stat.ST_CTIME])
        )
    if self.dimensionality > 1:
        self.domain_dimensions = self.parameters["TopGridDimensions"]
        if len(self.domain_dimensions) < 3:
            tmp = self.domain_dimensions.tolist()
            tmp.append(1)
            self.domain_dimensions = np.array(tmp)
            self.periodicity += (False,)
        self.domain_left_edge = np.array(
            self.parameters["DomainLeftEdge"], "float64"
        ).copy()
        self.domain_right_edge = np.array(
            self.parameters["DomainRightEdge"], "float64"
        ).copy()
    else:
        self.domain_left_edge = np.array(self.parameters["DomainLeftEdge"], "float64")
        self.domain_right_edge = np.array(self.parameters["DomainRightEdge"], "float64")
        self.domain_dimensions = np.array([self.parameters["TopGridDimensions"], 1, 1])
        self.periodicity += (False, False)

    self.gamma = self.parameters["Gamma"]
    if self.parameters["ComovingCoordinates"]:
        self.cosmological_simulation = 1
        self.current_redshift = self.parameters["CosmologyCurrentRedshift"]
        self.omega_lambda = self.parameters["CosmologyOmegaLambdaNow"]
        self.omega_matter = self.parameters["CosmologyOmegaMatterNow"]
        self.hubble_constant = self.parameters["CosmologyHubbleConstantNow"]
    else:
        self.current_redshift = self.omega_lambda = self.omega_matter = (
            self.hubble_constant
        ) = self.cosmological_simulation = 0.0
    self.particle_types = []
    self.current_time = self.parameters["InitialTime"]
    if (
        self.parameters["NumberOfParticles"] > 0
        and "AppendActiveParticleType" in self.parameters.keys()
    ):
        # If this is the case, then we know we should have a DarkMatter
        # particle type, and we don't need the "io" type.
        self.parameters["AppendActiveParticleType"].append("DarkMatter")
    else:
        # We do not have an "io" type for Enzo particles if the
        # ActiveParticle machinery is on, as we simply will ignore any of
        # the non-DarkMatter particles in that case.  However, for older
        # datasets, we call this particle type "io".
        self.particle_types = ["io"]
    for ptype in self.parameters.get("AppendActiveParticleType", []):
        self.particle_types.append(ptype)
    self.particle_types = tuple(self.particle_types)
    self.particle_types_raw = self.particle_types

    if self.dimensionality == 1:
        self._setup_1d()
    elif self.dimensionality == 2:
        self._setup_2d()


# Traceback (ValueError)
ValueError                                Traceback (most recent call last)
<ipython-input-2-d4d26e2f34da> in <module>()
----> 1 ds = yt.load("RD0027/RD0027")
/Users/molly/anaconda2/envs/astroconda/lib/python2.7/site-packages/yt/convenience.pyc in load(*args, **kwargs)
84     candidates = find_lowest_subclasses(candidates)
85     if len(candidates) == 1:
---> 86         return candidates[0](*args, **kwargs)
87     if len(candidates) == 0:
88         if ytcfg.get("yt", "enzo_db") != '' \
/Users/molly/anaconda2/envs/astroconda/lib/python2.7/site-packages/yt/frontends/enzo/data_structures.pyc in __init__(self, filename, dataset_type, file_style, parameter_override, conversion_override, storage_filename, units_override, unit_system)
680         self.storage_filename = storage_filename
681         Dataset.__init__(self, filename, dataset_type, file_style=file_style,
--> 682                          units_override=units_override, unit_system=unit_system)
683
684     def _setup_1d(self):
/Users/molly/anaconda2/envs/astroconda/lib/python2.7/site-packages/yt/data_objects/static_output.pyc in __init__(self, filename, dataset_type, file_style, units_override, unit_system)
304         self._create_unit_registry()
305
--> 306         self._parse_parameter_file()
307         self.set_units()
308         self._assign_unit_system(unit_system)
/Users/molly/anaconda2/envs/astroconda/lib/python2.7/site-packages/yt/frontends/enzo/data_structures.pyc in _parse_parameter_file(self)
741                 self._parse_enzo3_parameter_file(f)
742             else:
--> 743                 self._parse_enzo2_parameter_file(f)
744
745     def _parse_enzo3_parameter_file(self, f):
/Users/molly/anaconda2/envs/astroconda/lib/python2.7/site-packages/yt/frontends/enzo/data_structures.pyc in _parse_enzo2_parameter_file(self, f)
783         for line in (l.strip() for l in f):
784             if len(line) < 2: continue
--> 785             param, vals = (i.strip() for i in line.split("=",1))
786             # First we try to decipher what type of value it is.
787             vals = vals.split()
ValueError: need more than 1 value to unpack

# Fixed code
def _parse_enzo2_parameter_file(self, f):
    for line in (l.strip() for l in f):
        if (len(line) < 2) or (line[0] == "#"):
            continue
        param, vals = (i.strip() for i in line.split("=", 1))
        # First we try to decipher what type of value it is.
        vals = vals.split()
        # Special case approaching.
        if "(do" in vals:
            vals = vals[:1]
        if len(vals) == 0:
            pcast = str  # Assume NULL output
        else:
            v = vals[0]
            # Figure out if it's castable to floating point:
            try:
                float(v)
            except ValueError:
                pcast = str
            else:
                if any("." in v or "e+" in v or "e-" in v for v in vals):
                    pcast = float
                elif v == "inf":
                    pcast = str
                else:
                    pcast = int
        # Now we figure out what to do with it.
        if len(vals) == 0:
            vals = ""
        elif len(vals) == 1:
            vals = pcast(vals[0])
        else:
            vals = np.array([pcast(i) for i in vals if i != "-99999"])
        if param.startswith("Append"):
            if param not in self.parameters:
                self.parameters[param] = []
            self.parameters[param].append(vals)
        else:
            self.parameters[param] = vals
    self.refine_by = self.parameters["RefineBy"]
    self.periodicity = ensure_tuple(self.parameters["LeftFaceBoundaryCondition"] == 3)
    self.dimensionality = self.parameters["TopGridRank"]
    if "MetaDataDatasetUUID" in self.parameters:
        self.unique_identifier = self.parameters["MetaDataDatasetUUID"]
    elif "CurrentTimeIdentifier" in self.parameters:
        self.unique_identifier = self.parameters["CurrentTimeIdentifier"]
    else:
        self.unique_identifier = str(
            int(os.stat(self.parameter_filename)[stat.ST_CTIME])
        )
    if self.dimensionality > 1:
        self.domain_dimensions = self.parameters["TopGridDimensions"]
        if len(self.domain_dimensions) < 3:
            tmp = self.domain_dimensions.tolist()
            tmp.append(1)
            self.domain_dimensions = np.array(tmp)
            self.periodicity += (False,)
        self.domain_left_edge = np.array(
            self.parameters["DomainLeftEdge"], "float64"
        ).copy()
        self.domain_right_edge = np.array(
            self.parameters["DomainRightEdge"], "float64"
        ).copy()
    else:
        self.domain_left_edge = np.array(self.parameters["DomainLeftEdge"], "float64")
        self.domain_right_edge = np.array(self.parameters["DomainRightEdge"], "float64")
        self.domain_dimensions = np.array([self.parameters["TopGridDimensions"], 1, 1])
        self.periodicity += (False, False)

    self.gamma = self.parameters["Gamma"]
    if self.parameters["ComovingCoordinates"]:
        self.cosmological_simulation = 1
        self.current_redshift = self.parameters["CosmologyCurrentRedshift"]
        self.omega_lambda = self.parameters["CosmologyOmegaLambdaNow"]
        self.omega_matter = self.parameters["CosmologyOmegaMatterNow"]
        self.hubble_constant = self.parameters["CosmologyHubbleConstantNow"]
    else:
        self.current_redshift = self.omega_lambda = self.omega_matter = (
            self.hubble_constant
        ) = self.cosmological_simulation = 0.0
    self.particle_types = []
    self.current_time = self.parameters["InitialTime"]
    if (
        self.parameters["NumberOfParticles"] > 0
        and "AppendActiveParticleType" in self.parameters.keys()
    ):
        # If this is the case, then we know we should have a DarkMatter
        # particle type, and we don't need the "io" type.
        self.parameters["AppendActiveParticleType"].append("DarkMatter")
    else:
        # We do not have an "io" type for Enzo particles if the
        # ActiveParticle machinery is on, as we simply will ignore any of
        # the non-DarkMatter particles in that case.  However, for older
        # datasets, we call this particle type "io".
        self.particle_types = ["io"]
    for ptype in self.parameters.get("AppendActiveParticleType", []):
        self.particle_types.append(ptype)
    self.particle_types = tuple(self.particle_types)
    self.particle_types_raw = self.particle_types

    if self.dimensionality == 1:
        self._setup_1d()
    elif self.dimensionality == 2:
        self._setup_2d()