func_code_string
stringlengths
52
1.94M
func_documentation_string
stringlengths
1
47.2k
def execute(self): if self.skip: return None result = self.pre_execute() if result is None: try: result = self.do_execute() except Exception as e: result = traceback.format_exc() print(self.full_name + "...
Executes the actor. :return: None if successful, otherwise error message :rtype: str
def output(self): if (self._output is None) or (len(self._output) == 0): result = None else: result = self._output.pop(0) return result
Returns the next available output token. :return: the next token, None if none available :rtype: Token
def expand(self, s): result = s while result.find("@{") > -1: start = result.index("@{") end = result.index("}", start) name = result[start + 2:end] value = self.storage[name] if value is None: raise("Storage value '" +...
Expands all occurrences of "@{...}" within the string with the actual values currently stored in internal storage. :param s: the string to expand :type s: str :return: the expanded string :rtype: str
def extract(cls, padded): if padded.startswith("@{") and padded.endswith("}"): return padded[2:len(padded)-1] else: return padded
Removes the surrounding "@{...}" from the name. :param padded: the padded string :type padded: str :return: the extracted name :rtype: str
def fix_config(self, options): options = super(ActorHandler, self).fix_config(options) opt = "actors" if opt not in options: options[opt] = self.default_actors() if opt not in self.help: self.help[opt] = "The list of sub-actors that this actor manages." ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def to_dict(self): result = super(ActorHandler, self).to_dict() result["type"] = "ActorHandler" del result["config"]["actors"] result["actors"] = [] for actor in self.actors: result["actors"].append(actor.to_dict()) return result
Returns a dictionary that represents this object, to be used for JSONification. :return: the object dictionary :rtype: dict
def from_dict(cls, d): result = super(ActorHandler, cls).from_dict(d) if "actors" in d: l = d["actors"] for e in l: if u"type" in e: typestr = e[u"type"] else: typestr = e["type"] res...
Restores an object state from a dictionary, used in de-JSONification. :param d: the object dictionary :type d: dict :return: the object :rtype: object
def actors(self, actors): if actors is None: actors = self.default_actors() self.check_actors(actors) self.config["actors"] = actors
Sets the sub-actors of the actor. :param actors: the sub-actors :type actors: list
def active(self): result = 0 for actor in self.actors: if not actor.skip: result += 1 return result
Returns the count of non-skipped actors. :return: the count :rtype: int
def first_active(self): result = None for actor in self.actors: if not actor.skip: result = actor break return result
Returns the first non-skipped actor. :return: the first active actor, None if not available :rtype: Actor
def last_active(self): result = None for actor in reversed(self.actors): if not actor.skip: result = actor break return result
Returns the last non-skipped actor. :return: the last active actor, None if not available :rtype: Actor
def index_of(self, name): result = -1 for index, actor in enumerate(self.actors): if actor.name == name: result = index break return result
Returns the index of the actor with the given name. :param name: the name of the Actor to find :type name: str :return: the index, -1 if not found :rtype: int
def setup(self): result = super(ActorHandler, self).setup() if result is None: self.update_parent() try: self.check_actors(self.actors) except Exception as e: result = str(e) if result is None: for actor in ...
Configures the actor before execution. :return: None if successful, otherwise error message :rtype: str
def wrapup(self): for actor in self.actors: if actor.skip: continue actor.wrapup() super(ActorHandler, self).wrapup()
Finishes up after execution finishes, does not remove any graphical output.
def cleanup(self): for actor in self.actors: if actor.skip: continue actor.cleanup() super(ActorHandler, self).cleanup()
Destructive finishing up after execution stopped.
def stop_execution(self): if not (self._stopping or self._stopped): for actor in self.owner.actors: actor.stop_execution() self._stopping = True
Triggers the stopping of the object.
def do_execute(self): self._stopped = False self._stopping = False not_finished_actor = self.owner.first_active pending_actors = [] finished = False actor_result = None while not (self.is_stopping() or self.is_stopped()) and not finished: # de...
Actual execution of the director. :return: None if successful, otherwise error message :rtype: str
def check_actors(self, actors): super(Flow, self).check_actors(actors) actor = self.first_active if (actor is not None) and not base.is_source(actor): raise Exception("First active actor is not a source: " + actor.full_name)
Performs checks on the actors that are to be used. Raises an exception if invalid setup. :param actors: the actors to check :type actors: list
def load(cls, fname): with open(fname) as f: content = f.readlines() return Flow.from_json(''.join(content))
Loads the flow from a JSON file. :param fname: the file to load :type fname: str :return: the flow :rtype: Flow
def new_director(self): result = SequentialDirector(self) result.record_output = False result.allow_source = False return result
Creates the director to use for handling the sub-actors. :return: the director instance :rtype: Director
def check_actors(self, actors): super(Sequence, self).check_actors(actors) actor = self.first_active if (actor is not None) and not isinstance(actor, InputConsumer): raise Exception("First active actor does not accept input: " + actor.full_name)
Performs checks on the actors that are to be used. Raises an exception if invalid setup. :param actors: the actors to check :type actors: list
def do_execute(self): self.first_active.input = self.input result = self._director.execute() if result is None: self._output.append(self.input) return result
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(Tee, self).fix_config(options) opt = "condition" if opt not in options: options[opt] = "True" if opt not in self.help: self.help[opt] = "The (optional) condition for teeing off the tokens; uses the 'eval' met...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def check_actors(self, actors): super(Tee, self).check_actors(actors) actor = self.first_active if actor is None: if self._requires_active_actors: raise Exception("No active actor!") elif not isinstance(actor, InputConsumer): raise Excepti...
Performs checks on the actors that are to be used. Raises an exception if invalid setup. :param actors: the actors to check :type actors: list
def do_execute(self): result = None teeoff = True cond = self.storagehandler.expand(str(self.resolve_option("condition"))) if len(cond) > 0: teeoff = bool(eval(cond)) if teeoff: self.first_active.input = self.input result = self._direc...
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(Trigger, self).fix_config(options) opt = "condition" if opt not in options: options[opt] = "True" if opt not in self.help: self.help[opt] = "The (optional) condition for teeing off the tokens; uses the 'eval'...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def check_actors(self): actors = [] for actor in self.owner.actors: if actor.skip: continue actors.append(actor) if len(actors) == 0: return for actor in actors: if not isinstance(actor, InputConsumer): ...
Checks the actors of the owner. Raises an exception if invalid.
def do_execute(self): result = None self._stopped = False self._stopping = False for actor in self.owner.actors: if self.is_stopping() or self.is_stopped(): break actor.input = self.owner.input result = actor.execute() ...
Actual execution of the director. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(ContainerValuePicker, self).fix_config(options) opt = "value" if opt not in options: options[opt] = "Model" if opt not in self.help: self.help[opt] = "The name of the container value to pick from the containe...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): result = None cont = self.input.payload name = str(self.resolve_option("value")) value = cont.get(name) switch = bool(self.resolve_option("switch")) if switch: if self.first_active is not None: self.first_active.i...
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(CommandlineToAny, self).fix_config(options) opt = "wrapper" if opt not in options: options[opt] = "weka.core.classes.OptionHandler" if opt not in self.help: self.help[opt] = "The name of the wrapper class to ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def check_input(self, obj): if isinstance(obj, str): return if isinstance(obj, unicode): return raise Exception("Unsupported class: " + self._input.__class__.__name__)
Performs checks on the input object. Raises an exception if unsupported. :param obj: the object to check :type obj: object
def convert(self): cname = str(self.config["wrapper"]) self._output = classes.from_commandline(self._input, classname=cname) return None
Performs the actual conversion. :return: None if successful, otherwise errors message :rtype: str
def plot_experiment(mat, title="Experiment", axes_swapped=False, measure="Statistic", show_stdev=False, key_loc="lower right", outfile=None, wait=True): if not plot.matplotlib_available: logger.error("Matplotlib is not installed, plotting unavailable!") return if not isi...
Plots the results from an experiment. :param mat: the result matrix to plot :type mat: ResultMatrix :param title: the title for the experiment :type title: str :param axes_swapped: whether the axes whether swapped ("sets x cls" or "cls x sets") :type axes_swapped: bool :param measure: the m...
def create_subsample(data, percent, seed=1): if percent <= 0 or percent >= 100: return data data = Instances.copy_instances(data) data.randomize(Random(seed)) data = Instances.copy_instances(data, 0, int(round(data.num_instances * percent / 100.0))) return data
Generates a subsample of the dataset. :param data: the data to create the subsample from :type data: Instances :param percent: the percentage (0-100) :type percent: float :param seed: the seed value to use :type seed: int
def predictions_to_instances(data, preds): if len(preds) == 0: return None is_numeric = isinstance(preds[0], NumericPrediction) # create header atts = [] if is_numeric: atts.append(Attribute.create_numeric("index")) atts.append(Attribute.create_numeric("weight")) ...
Turns the predictions turned into an Instances object. :param data: the original dataset format :type data: Instances :param preds: the predictions to convert :type preds: list :return: the predictions, None if no predictions present :rtype: Instances
def distributions_for_instances(self, data): if self.is_batchpredictor: return typeconv.double_matrix_to_ndarray(self.__distributions(data.jobject)) else: return None
Peforms predictions, returning the class distributions. :param data: the Instances to get the class distributions for :type data: Instances :return: the class distribution matrix, None if not a batch predictor :rtype: ndarray
def batch_size(self, size): if self.is_batchpredictor: javabridge.call(self.jobject, "setBatchSize", "(Ljava/lang/String;)V", size)
Sets the batch size, in case this classifier is a batch predictor. :param size: the size of the batch :type size: str
def to_source(self, classname): if not self.check_type(self.jobject, "weka.classifiers.Sourcable"): return None return javabridge.call(self.jobject, "toSource", "(Ljava/lang/String;)Ljava/lang/String;", classname)
Returns the model as Java source code if the classifier implements weka.classifiers.Sourcable. :param classname: the classname for the generated Java code :type classname: str :return: the model as source code string :rtype: str
def evaluation(self, evl): if isinstance(evl, str): evl = self.tags_evaluation.find(evl) if isinstance(evl, Tag): evl = SelectedTag(tag_id=evl.ident, tags=self.tags_evaluation) javabridge.call(self.jobject, "setEvaluation", "(Lweka/core/SelectedTag;)V", evl.jobje...
Sets the statistic to use for evaluation. :param evl: the statistic :type evl: SelectedTag, Tag or str
def x(self): result = {} result["property"] = javabridge.call(self.jobject, "getXProperty", "()Ljava/lang/String;") result["min"] = javabridge.call(self.jobject, "getXMin", "()D") result["max"] = javabridge.call(self.jobject, "getXMax", "()D") result["step"] = javabridge...
Returns a dictionary with all the current values for the X of the grid. Keys for the dictionary: property, min, max, step, base, expression Types: property=str, min=float, max=float, step=float, base=float, expression=str :return: the dictionary with the parameters :rtype: dict
def x(self, d): if "property" in d: javabridge.call(self.jobject, "setXProperty", "(Ljava/lang/String;)V", d["property"]) if "min" in d: javabridge.call(self.jobject, "setXMin", "(D)V", d["min"]) if "max" in d: javabridge.call(self.jobject, "setXMax",...
Allows to configure the X of the grid with one method call. Keys for the dictionary: property, min, max, step, base, expression Types: property=str, min=float, max=float, step=float, base=float, expression=str :param d: the dictionary with the parameters :type d: dict
def y(self): result = {} result["property"] = javabridge.call(self.jobject, "getYProperty", "()Ljava/lang/String;") result["min"] = javabridge.call(self.jobject, "getYMin", "()D") result["max"] = javabridge.call(self.jobject, "getYMax", "()D") result["step"] = javabridge...
Returns a dictionary with all the current values for the Y of the grid. Keys for the dictionary: property, min, max, step, base, expression Types: property=str, min=float, max=float, step=float, base=float, expression=str :return: the dictionary with the parameters :rtype: dict
def y(self, d): if "property" in d: javabridge.call(self.jobject, "setYProperty", "(Ljava/lang/String;)V", d["property"]) if "min" in d: javabridge.call(self.jobject, "setYMin", "(D)V", d["min"]) if "max" in d: javabridge.call(self.jobject, "setYMax",...
Allows to configure the Y of the grid with one method call. Keys for the dictionary: property, min, max, step, base, expression Types: property=str, min=float, max=float, step=float, base=float, expression=str :param d: the dictionary with the parameters :type d: dict
def classifiers(self): objects = javabridge.get_env().get_object_array_elements( javabridge.call(self.jobject, "getClassifiers", "()[Lweka/classifiers/Classifier;")) result = [] for obj in objects: result.append(Classifier(jobject=obj)) return result
Returns the list of base classifiers. :return: the classifier list :rtype: list
def classifiers(self, classifiers): obj = [] for classifier in classifiers: obj.append(classifier.jobject) javabridge.call(self.jobject, "setClassifiers", "([Lweka/classifiers/Classifier;)V", obj)
Sets the base classifiers. :param classifiers: the list of base classifiers to use :type classifiers: list
def eval(self, id1, id2, inst1): jinst1 = None if inst1 is not None: jinst1 = inst1.jobject return javabridge.call(self.jobject, "eval", "(IILweka/core/Instance;)D", id1, id2, jinst1)
Computes the result of the kernel function for two instances. If id1 == -1, eval use inst1 instead of an instance in the dataset. :param id1: the index of the first instance in the dataset :type id1: int :param id2: the index of the second instance in the dataset :type id2: int ...
def kernel(self): result = javabridge.static_call( "weka/classifiers/KernelHelper", "getKernel", "(Ljava/lang/Object;)Lweka/classifiers/functions/supportVector/Kernel;", self.jobject) if result is None: return None else: return...
Returns the current kernel. :return: the kernel or None if none found :rtype: Kernel
def kernel(self, kernel): result = javabridge.static_call( "weka/classifiers/KernelHelper", "setKernel", "(Ljava/lang/Object;Lweka/classifiers/functions/supportVector/Kernel;)Z", self.jobject, kernel.jobject) if not result: raise Exception("Failed...
Sets the kernel. :param kernel: the kernel to set :type kernel: Kernel
def apply_cost_matrix(self, data, rnd): return Instances( javabridge.call( self.jobject, "applyCostMatrix", "(Lweka/core/Instances;Ljava/util/Random;)Lweka/core/Instances;", data.jobject, rnd.jobject))
Applies the cost matrix to the data. :param data: the data to apply to :type data: Instances :param rnd: the random number generator :type rnd: Random
def expected_costs(self, class_probs, inst=None): if inst is None: costs = javabridge.call( self.jobject, "expectedCosts", "([D)[D", javabridge.get_env().make_double_array(class_probs)) return javabridge.get_env().get_double_array_elements(costs) else: ...
Calculates the expected misclassification cost for each possible class value, given class probability estimates. :param class_probs: the class probabilities :type class_probs: ndarray :return: the calculated costs :rtype: ndarray
def get_cell(self, row, col): return javabridge.call( self.jobject, "getCell", "(II)Ljava/lang/Object;", row, col)
Returns the JB_Object at the specified location. :param row: the 0-based index of the row :type row: int :param col: the 0-based index of the column :type col: int :return: the object in that cell :rtype: JB_Object
def set_cell(self, row, col, obj): if isinstance(obj, JavaObject): obj = obj.jobject javabridge.call( self.jobject, "setCell", "(IILjava/lang/Object;)V", row, col, obj)
Sets the JB_Object at the specified location. Automatically unwraps JavaObject. :param row: the 0-based index of the row :type row: int :param col: the 0-based index of the column :type col: int :param obj: the object for that cell :type obj: object
def get_element(self, row, col, inst=None): if inst is None: return javabridge.call( self.jobject, "getElement", "(II)D", row, col) else: return javabridge.call( self.jobject, "getElement", "(IILweka/core/Instance;)D", row, col, inst.jobje...
Returns the value at the specified location. :param row: the 0-based index of the row :type row: int :param col: the 0-based index of the column :type col: int :param inst: the Instace :type inst: Instance :return: the value in that cell :rtype: float
def set_element(self, row, col, value): javabridge.call( self.jobject, "setElement", "(IID)V", row, col, value)
Sets the float value at the specified location. :param row: the 0-based index of the row :type row: int :param col: the 0-based index of the column :type col: int :param value: the float value for that cell :type value: float
def get_max_cost(self, class_value, inst=None): if inst is None: return javabridge.call( self.jobject, "getMaxCost", "(I)D", class_value) else: return javabridge.call( self.jobject, "getElement", "(ILweka/core/Instance;)D", class_value, in...
Gets the maximum cost for a particular class value. :param class_value: the class value to get the maximum cost for :type class_value: int :param inst: the Instance :type inst: Instance :return: the cost :rtype: float
def crossvalidate_model(self, classifier, data, num_folds, rnd, output=None): if output is None: generator = [] else: generator = [output.jobject] javabridge.call( self.jobject, "crossValidateModel", "(Lweka/classifiers/Classifier;Lweka/co...
Crossvalidates the model using the specified data, number of folds and random number generator wrapper. :param classifier: the classifier to cross-validate :type classifier: Classifier :param data: the data to evaluate on :type data: Instances :param num_folds: the number of fol...
def summary(self, title=None, complexity=False): if title is None: return javabridge.call( self.jobject, "toSummaryString", "()Ljava/lang/String;") else: return javabridge.call( self.jobject, "toSummaryString", "(Ljava/lang/String;Z)Ljava/...
Generates a summary. :param title: optional title :type title: str :param complexity: whether to print the complexity information as well :type complexity: bool :return: the summary :rtype: str
def class_details(self, title=None): if title is None: return javabridge.call( self.jobject, "toClassDetailsString", "()Ljava/lang/String;") else: return javabridge.call( self.jobject, "toClassDetailsString", "(Ljava/lang/String;)Ljava/lan...
Generates the class details. :param title: optional title :type title: str :return: the details :rtype: str
def matrix(self, title=None): if title is None: return javabridge.call(self.jobject, "toMatrixString", "()Ljava/lang/String;") else: return javabridge.call(self.jobject, "toMatrixString", "(Ljava/lang/String;)Ljava/lang/String;", title)
Generates the confusion matrix. :param title: optional title :type title: str :return: the matrix :rtype: str
def predictions(self): preds = javabridge.get_collection_wrapper( javabridge.call(self.jobject, "predictions", "()Ljava/util/ArrayList;")) if self.discard_predictions: result = None else: result = [] for pred in preds: if i...
Returns the predictions. :return: the predictions. None if not available :rtype: list
def print_all(self, cls, data): javabridge.call( self.jobject, "print", "(Lweka/classifiers/Classifier;Lweka/core/Instances;)V", cls.jobject, data.jobject)
Prints the header, classifications and footer to the buffer. :param cls: the classifier :type cls: Classifier :param data: the test data :type data: Instances
def print_classifications(self, cls, data): javabridge.call( self.jobject, "printClassifications", "(Lweka/classifiers/Classifier;Lweka/core/Instances;)V", cls.jobject, data.jobject)
Prints the classifications to the buffer. :param cls: the classifier :type cls: Classifier :param data: the test data :type data: Instances
def print_classification(self, cls, inst, index): javabridge.call( self.jobject, "printClassification", "(Lweka/classifiers/Classifier;Lweka/core/Instance;I)V", cls.jobject, inst.jobject, index)
Prints the classification to the buffer. :param cls: the classifier :type cls: Classifier :param inst: the test instance :type inst: Instance :param index: the 0-based index of the test instance :type index: int
def tokenize(self, s): javabridge.call(self.jobject, "tokenize", "(Ljava/lang/String;)V", s) return TokenIterator(self)
Tokenizes the string. :param s: the string to tokenize :type s: str :return: the iterator :rtype: TokenIterator
def main(): parser = argparse.ArgumentParser( description='Executes a data generator from the command-line. Calls JVM start/stop automatically.') parser.add_argument("-j", metavar="classpath", dest="classpath", help="additional classpath, jars/directories") parser.add_argument("-X", metavar="he...
Runs a datagenerator from the command-line. Calls JVM start/stop automatically. Use -h to see all options.
def define_data_format(self): data = javabridge.call(self.jobject, "defineDataFormat", "()Lweka/core/Instances;") if data is None: return None else: return Instances(data)
Returns the data format. :return: the data format :rtype: Instances
def dataset_format(self): data = javabridge.call(self.jobject, "getDatasetFormat", "()Lweka/core/Instances;") if data is None: return None else: return Instances(data)
Returns the dataset format. :return: the format :rtype: Instances
def generate_example(self): data = javabridge.call(self.jobject, "generateExample", "()Lweka/core/Instance;") if data is None: return None else: return Instance(data)
Returns a single Instance. :return: the next example :rtype: Instance
def generate_examples(self): data = javabridge.call(self.jobject, "generateExamples", "()Lweka/core/Instances;") if data is None: return None else: return Instances(data)
Returns complete dataset. :return: the generated dataset :rtype: Instances
def make_copy(cls, generator): return from_commandline( to_commandline(generator), classname=classes.get_classname(DataGenerator()))
Creates a copy of the generator. :param generator: the generator to copy :type generator: DataGenerator :return: the copy of the generator :rtype: DataGenerator
def fix_config(self, options): options = super(FileSupplier, self).fix_config(options) opt = "files" if opt not in options: options[opt] = [] if opt not in self.help: self.help[opt] = "The files to output (list of string)." return options
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): for f in self.resolve_option("files"): self._output.append(Token(f)) return None
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def quickinfo(self): return "dir: " + str(self.config["dir"]) \ + ", files: " + str(self.config["list_files"]) \ + ", dirs: " + str(self.resolve_option("list_dirs")) \ + ", recursive: " + str(self.config["recursive"])
Returns a short string describing some of the options of the actor. :return: the info, None if not available :rtype: str
def fix_config(self, options): options = super(ListFiles, self).fix_config(options) opt = "dir" if opt not in options: options[opt] = "." if opt not in self.help: self.help[opt] = "The directory to search (string)." opt = "recursive" if op...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def _list(self, path, collected): list_files = self.resolve_option("list_files") list_dirs = self.resolve_option("list_dirs") recursive = self.resolve_option("recursive") spattern = str(self.resolve_option("regexp")) pattern = None if (spattern is not None) and (...
Lists all the files/dirs in directory that match the pattern. :param path: the directory to search :type path: str :param collected: the files/dirs collected so far (full path) :type collected: list :return: None if successful, error otherwise :rtype: str
def do_execute(self): directory = str(self.resolve_option("dir")) if not os.path.exists(directory): return "Directory '" + directory + "' does not exist!" if not os.path.isdir(directory): return "Location '" + directory + "' is not a directory!" collected...
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(GetStorageValue, self).fix_config(options) opt = "storage_name" if opt not in options: options[opt] = "unknown" if opt not in self.help: self.help[opt] = "The name of the storage value to retrieve (string)." ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): if self.storagehandler is None: return "No storage handler available!" sname = str(self.resolve_option("storage_name")) if sname not in self.storagehandler.storage: return "No storage item called '" + sname + "' present!" self._outpu...
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(ForLoop, self).fix_config(options) opt = "min" if opt not in options: options[opt] = 1 if opt not in self.help: self.help[opt] = "The minimum for the loop (included, int)." opt = "max" if opt ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): for i in range( int(self.resolve_option("min")), int(self.resolve_option("max")) + 1, int(self.resolve_option("step"))): self._output.append(Token(i)) return None
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): opt = "db_url" if opt not in options: options[opt] = "jdbc:mysql://somehost:3306/somedatabase" if opt not in self.help: self.help[opt] = "The JDBC database URL to connect to (str)." opt = "user" if opt not in options...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): iquery = InstanceQuery() iquery.db_url = str(self.resolve_option("db_url")) iquery.user = str(self.resolve_option("user")) iquery.password = str(self.resolve_option("password")) props = str(self.resolve_option("custom_props")) if (len(props)...
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): opt = "setup" if opt not in options: options[opt] = datagen.DataGenerator(classname="weka.datagenerators.classifiers.classification.Agrawal") if opt not in self.help: self.help[opt] = "The data generator to use (DataGenerator)." ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def to_config(self, k, v): if k == "setup": return base.to_commandline(v) return super(DataGenerator, self).to_config(k, v)
Hook method that allows conversion of individual options. :param k: the key of the option :type k: str :param v: the value :type v: object :return: the potentially processed value :rtype: object
def from_config(self, k, v): if k == "setup": return from_commandline(v, classname=to_commandline(datagen.DataGenerator())) return super(DataGenerator, self).from_config(k, v)
Hook method that allows converting values from the dictionary. :param k: the key in the dictionary :type k: str :param v: the value :type v: object :return: the potentially parsed value :rtype: object
def do_execute(self): generator = datagen.DataGenerator.make_copy(self.resolve_option("setup")) generator.dataset_format = generator.define_data_format() if bool(self.resolve_option("incremental")) and generator.single_mode_flag: for i in range(generator.num_examples_act): ...
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(CombineStorage, self).fix_config(options) opt = "format" if opt not in options: options[opt] = "" if opt not in self.help: self.help[opt] = "The format to use for generating the combined string; use '@{blah}'...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): formatstr = str(self.resolve_option("format")) expanded = self.storagehandler.expand(formatstr) self._output.append(Token(expanded)) return None
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(StringConstants, self).fix_config(options) opt = "strings" if opt not in options: options[opt] = [] if opt not in self.help: self.help[opt] = "The strings to output (list of string)." return options
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): for s in self.resolve_option("strings"): self._output.append(Token(s)) return None
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def post_execute(self): result = super(Sink, self).post_execute() if result is None: self._input = None return result
Gets executed after the actual execution. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(Console, self).fix_config(options) opt = "prefix" if opt not in options: options[opt] = "" if opt not in self.help: self.help[opt] = "The prefix for the output (string)." return options
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def fix_config(self, options): options = super(FileOutputSink, self).fix_config(options) opt = "output" if opt not in options: options[opt] = "." if opt not in self.help: self.help[opt] = "The file to write to (string)." return options
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def fix_config(self, options): options = super(DumpFile, self).fix_config(options) opt = "append" if opt not in options: options[opt] = False if opt not in self.help: self.help[opt] = "Whether to append to the file or overwrite (bool)." return opt...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def do_execute(self): result = None f = None try: if bool(self.resolve_option("append")): f = open(str(self.resolve_option("output")), "a") else: f = open(str(self.resolve_option("output")), "w") f.write(str(self.input....
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def check_input(self, token): if not isinstance(token.payload, ModelContainer): raise Exception(self.full_name + ": Input token is not a ModelContainer!")
Performs checks on the input token. Raises an exception if unsupported. :param token: the token to check :type token: Token
def do_execute(self): result = None cont = self.input.payload serialization.write_all( str(self.resolve_option("output")), [cont.get("Model").jobject, cont.get("Header").jobject]) return result
The actual execution of the actor. :return: None if successful, otherwise error message :rtype: str
def fix_config(self, options): options = super(MatrixPlot, self).fix_config(options) opt = "percent" if opt not in options: options[opt] = 100.0 if opt not in self.help: self.help[opt] = "The percentage of the data to display (0-100, float)." opt ...
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict
def fix_config(self, options): options = super(LinePlot, self).fix_config(options) opt = "attributes" if opt not in options: options[opt] = None if opt not in self.help: self.help[opt] = "The list of 0-based attribute indices to print; None for all (int)....
Fixes the options, if necessary. I.e., it adds all required elements to the dictionary. :param options: the options to fix :type options: dict :return: the (potentially) fixed options :rtype: dict