def decayCyclesHaveInputThatWillBeIgnored(): """Check if there is any decay-related input that will be ignored.""" try: powerFracs = utils.expandRepeatedFloats(self.cs["powerFractions"]) availabilities = utils.expandRepeatedFloats( self.cs["availabilityFactors"] ) or ([self.cs["availabilityFactor"]] * self.cs["nCycles"]) except: # pylint: disable=bare-except return True for pf, af in zip(powerFracs, availabilities): if pf > 0.0 and af == 0.0: # this will be a full decay step and any power fraction will be ignored. May be ok, but warn. return True return False
def _factorsAreValid(factors, maxVal=1.0): try: expandedList = utils.expandRepeatedFloats(factors) except (ValueError, IndexError): return False return (all(0.0 <= val <= maxVal for val in expandedList) and len(expandedList) == self.cs["nCycles"])
def test_expandRepeatedFloats(self): repeatedFloats = ["150", "2R", 200.0, 175, "4r", 180.0, "0R"] expectedFloats = [150] * 3 + [200] + [175] * 5 + [180] self.assertEqual(utils.expandRepeatedFloats(repeatedFloats), expectedFloats)
def _getPowerFractions(self): """Return the power fractions for each cycle of the system as a list.""" return utils.expandRepeatedFloats( self.cs["powerFractions"]) or ([1.0 for _cl in self.cycleLengths])
def _getAvailabilityFactors(self): """Return the availability factors (capacity factor) for each cycle of the system as a list.""" return utils.expandRepeatedFloats(self.cs["availabilityFactors"]) or ( [self.cs["availabilityFactor"]] * self.cs["nCycles"])
def _getCycleLengths(self): """Return the cycle length for each cycle of the system as a list.""" return utils.expandRepeatedFloats( self.cs["cycleLengths"]) or ([self.cs["cycleLength"]] * self.cs["nCycles"])