def parseKwargs(data, debug, kwargs): """ Parse keyword arguments Args: data: shared alamo data options debug: Additional options may be specified and will be applied to the .alm kwargs: keyword arguments """ for arg in kwargs.keys(): if arg in data["pargs"]["opts"]: data["opts"][arg] = kwargs[arg] elif arg in data["pargs"]["lstopts"]: data["lstopts"][arg] = list() for term in list([kwargs[arg]]): data["lstopts"][arg].append(term) elif arg in data["pargs"]["stropts"]: data["stropts"][arg] = kwargs[arg] elif arg in data["pargs"]["set4"]: data["set4"][arg] = kwargs[arg] elif arg in debug["pargs"]: debug[arg] = kwargs[arg] else: if arg not in (["xlabels", "zlabels", "xval", "zval"]): sys.stdout.write("Problem with option : " + arg) almerror("p3")
def getTrainingData(xdata, zdata, data, debug): """ Structure data for training the model. Modifies data['opts'] Args: xdata: (numpy.array or list[real]) zdata: (numpy.array or list[real) data: shared alamo data options debug: Additional options may be specified and will be applied to the .alm """ dshape = np.shape(xdata) if len(dshape) == 0: debug["traindata"] = False elif len(dshape) == 1: data["opts"]["ndata"] = np.shape(xdata)[0] data["opts"]["ninputs"] = 1 else: data["opts"]["ndata"] = np.shape(xdata)[0] data["opts"]["ninputs"] = np.shape(xdata)[1] xdata = np.asarray(xdata) # Check training data if len(np.shape(zdata)) == 1: zdata = np.reshape(zdata, (data["opts"]["ndata"], 1)) data["opts"]["noutputs"] = 1 else: data["opts"]["noutputs"] = np.shape(zdata)[1] if np.shape(zdata)[0] != data["opts"]["ndata"]: almerror("p1") elif np.shape(xdata)[0] != data["opts"]["ndata"]: almerror("p1") zdata = np.asarray(zdata) return xdata, zdata
def getValidationData(vargs, data, debug): """ Structure data for validating the model. Modifies data['opts'] Args: vargs: validation data valxdata, valzdata data: shared alamo data options debug: Additional options may be specified and will be applied to the .alm """ if vargs != (): debug["validation"] = True xvaldata = vargs[0] zvaldata = vargs[1] temp = np.shape(xvaldata) data["opts"]["nvaldata"] = temp[0] if len(np.shape(zvaldata)) == 1: zvaldata = np.reshape(zvaldata, (data["opts"]["nvaldata"], 1)) if temp[1] != data["opts"]["ninputs"]: writethis( "Number of input variables inconsistent between x and xval") almerror("p2") temp = np.shape(zvaldata) if temp[0] != data["opts"]["nvaldata"] or temp[1] != data["opts"][ "noutputs"]: writethis("Problem with zval") almerror("p2") return xvaldata, zvaldata
def parseKwargs(data, debug, kwargs): """ Parse keyword arguments Args: data: shared alamo data options debug: Additional options may be specified and will be applied to the .alm kwargs: keyword arguments """ for arg in kwargs.keys(): if kwargs[arg] is not None: if arg in data["pargs"]["opts"]: data["opts"][arg] = kwargs[arg] elif arg in data["pargs"]["lstopts"]: data["lstopts"][arg] = list() for term in list([kwargs[arg]]): data["lstopts"][arg].append(term) elif arg in data["pargs"]["stropts"]: data["stropts"][arg] = kwargs[arg] elif arg in data["pargs"]["set4"]: data["set4"][arg] = kwargs[arg] elif arg in debug["pargs"]: debug[arg] = kwargs[arg] else: if arg not in (["xlabels", "zlabels", "xval", "zval"]): sys.stdout.write("Problem with option : " + arg) # PYLINT-TODO-FIX use almerror correctly insted of calling it directly # pylint: disable=not-callable almerror("p3")