def pmeemt(self, val): var = "pmeemt" if not isinstance(val, oda.oneDimArray): if not (isinstance(val, list) or ti.is_probability(val)): errorMessage = logging.multidimensional_error("pmeemt", True) self.__changeLog.append( logging.changelog_entry(self.__location, "pmeemt", False, repr(getattr(self, "pmeemt")), repr(val), errorMessage)) self.__errorLog.append( logging.errorlog_entry("Setter", errorMessage)) else: if not isinstance(val, list): val = [val] myODA = oda.oneDimArray.listToODA(val, errorLog=self.__errorLog, changeLog=self.__changeLog, location=self.__location, var=var) self.__changeLog.append( logging.changelog_entry(self.__location, "pmeemt", False, repr(getattr(self, "pmeemt")), repr(val), None)) self.__pmeemt = myODA else: self.__changeLog.append( logging.changelog_entry(self.__location, "pmeemt", False, repr(getattr(self, "pmeemt")), repr(val), None)) self.__pmeemt = val
def pmswap(self, val): if ti.is_probability(val): self.__changeLog.append({ 'Date': datetime.datetime.now(), 'Location': self.__location, 'Variable': 'pmswap', 'Success': True, 'Previous': self.__pmswap, 'New': val, 'ErrorMessage': None }) self.__pmswap = val else: errorMessage = "pmswap must be a number less than 1." self.__changeLog.append({ 'Date': datetime.datetime.now(), 'Location': self.__location, 'Variable': 'pmswap', 'Success': False, 'Previous': self.__pmswap, 'New': val, 'ErrorMessage': errorMessage }) self.__errorLog.append({ 'Date': datetime.datetime.now(), 'Type': 'Setter', 'Location': self.__location, 'Variable': 'pmswap', 'ErrorMessage': errorMessage })
def pmswmt(self, val): if not isinstance(val, oda.oneDimArray): if not isinstance(val, list): # Single numbers are OK if not ti.is_probability(val): errorMessage = ( "To properly set pmswmt you have a few options. You can always pass it as a " " python list (e.g. mySim.swap.pmswmt = [1.0,1.0])." " This will automatically convert to the special oneDimArray used by the code." " You can also set it as a oneDimArray object yourself, but this is far more " " tedious and you need to be careful that the errorLog, changeLog, location, " " and variable flags are set properly, which involves passing the right " " reference. Note that single values can be passed as a float/int, but they " " must be less than or equal to 1.0.") self.__changeLog.append({ 'Date': datetime.datetime.now(), 'Location': self.__location, 'Variable': 'pmswmt', 'Success': False, 'Previous': repr(self.__pmswmt), 'New': repr(val), 'ErrorMessage': errorMessage }) self.__errorLog.append({ 'Date': datetime.datetime.now(), 'Type': 'Setter', 'Location': self.__location, 'Variable': 'pmswmt', 'ErrorMessage': errorMessage }) else: # For single values, cast to list val = list(val) myODA = oda.oneDimArray.listToODA(val, errorLog=self.__errorLog, changeLog=self.__changeLog, location=self.__location, var="pmswmt") self.__pmswmt = myODA else: self.__changeLog.append({ 'Date': datetime.datetime.now(), 'Location': self.__location, 'Variable': 'pmswmt', 'Success': True, 'Previous': repr(self.__pmswmt), 'New': repr(val), 'ErrorMessage': None }) self.__pmswmt = val
def pmexpc1(self, val): if not ti.is_probability(val): errorMessage = "pmexpc1 failed test_instance.is_probability check." self.__changeLog.append( logging.changelog_entry(self.__location, "pmexpc1", False, repr(getattr(self, "pmexpc1")), repr(val), errorMessage)) self.__errorLog.append( logging.errorlog_entry("Setter", errorMessage)) else: self.__changeLog.append( logging.changelog_entry(self.__location, "pmexpc1", False, repr(getattr(self, "pmexpc1")), repr(val), None)) self.__pmexpc1 = val