Code
stringlengths
103
85.9k
Summary
listlengths
0
94
Please provide a description of the function:def registerXPathFunction(self, name, ns_uri, f): ret = libxml2mod.xmlRegisterXPathFunction(self._o, name, ns_uri, f) return ret
[ "Register a Python written function to the XPath interpreter " ]
Please provide a description of the function:def xpathRegisterVariable(self, name, ns_uri, value): ret = libxml2mod.xmlXPathRegisterVariable(self._o, name, ns_uri, value) return ret
[ "Register a variable with the XPath context " ]
Please provide a description of the function:def xpathContextSetCache(self, active, value, options): ret = libxml2mod.xmlXPathContextSetCache(self._o, active, value, options) return ret
[ "Creates/frees an object cache on the XPath context. If\n activates XPath objects (xmlXPathObject) will be cached\n internally to be reused. @options: 0: This will set the\n XPath object caching: @value: This will set the maximum\n number of XPath objects to be cached per slot Th...
Please provide a description of the function:def xpathEval(self, str): ret = libxml2mod.xmlXPathEval(str, self._o) if ret is None:raise xpathError('xmlXPathEval() failed') return xpathObjectRet(ret)
[ "Evaluate the XPath Location Path in the given context. " ]
Please provide a description of the function:def xpathEvalExpression(self, str): ret = libxml2mod.xmlXPathEvalExpression(str, self._o) if ret is None:raise xpathError('xmlXPathEvalExpression() failed') return xpathObjectRet(ret)
[ "Evaluate the XPath expression in the given context. " ]
Please provide a description of the function:def xpathNewParserContext(self, str): ret = libxml2mod.xmlXPathNewParserContext(str, self._o) if ret is None:raise xpathError('xmlXPathNewParserContext() failed') __tmp = xpathParserContext(_obj=ret) return __tmp
[ "Create a new xmlXPathParserContext " ]
Please provide a description of the function:def xpathNsLookup(self, prefix): ret = libxml2mod.xmlXPathNsLookup(self._o, prefix) return ret
[ "Search in the namespace declaration array of the context\n for the given namespace name associated to the given prefix " ]
Please provide a description of the function:def xpathRegisterNs(self, prefix, ns_uri): ret = libxml2mod.xmlXPathRegisterNs(self._o, prefix, ns_uri) return ret
[ "Register a new namespace. If @ns_uri is None it unregisters\n the namespace " ]
Please provide a description of the function:def xpathVariableLookup(self, name): ret = libxml2mod.xmlXPathVariableLookup(self._o, name) if ret is None:raise xpathError('xmlXPathVariableLookup() failed') return xpathObjectRet(ret)
[ "Search in the Variable array of the context for the given\n variable value. " ]
Please provide a description of the function:def xpathVariableLookupNS(self, name, ns_uri): ret = libxml2mod.xmlXPathVariableLookupNS(self._o, name, ns_uri) if ret is None:raise xpathError('xmlXPathVariableLookupNS() failed') return xpathObjectRet(ret)
[ "Search in the Variable array of the context for the given\n variable value. " ]
Please provide a description of the function:def xpointerEval(self, str): ret = libxml2mod.xmlXPtrEval(str, self._o) if ret is None:raise treeError('xmlXPtrEval() failed') return xpathObjectRet(ret)
[ "Evaluate the XPath Location Path in the given context. " ]
Please provide a description of the function:def context(self): ret = libxml2mod.xmlXPathParserGetContext(self._o) if ret is None:raise xpathError('xmlXPathParserGetContext() failed') __tmp = xpathContext(_obj=ret) return __tmp
[ "Get the xpathContext from an xpathParserContext " ]
Please provide a description of the function:def xpathCompareValues(self, inf, strict): ret = libxml2mod.xmlXPathCompareValues(self._o, inf, strict) return ret
[ "Implement the compare operation on XPath objects: @arg1 <\n @arg2 (1, 1, ... @arg1 <= @arg2 (1, 0, ... @arg1 >\n @arg2 (0, 1, ... @arg1 >= @arg2 (0, 0, ... When\n neither object to be compared is a node-set and the\n operator is <=, <, >=, >, then the objects are comp...
Please provide a description of the function:def xpathNextAncestor(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextAncestor(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextAncestor() failed') __tmp = xmlNode(_obj...
[ "Traversal function for the \"ancestor\" direction the\n ancestor axis contains the ancestors of the context node;\n the ancestors of the context node consist of the parent of\n context node and the parent's parent and so on; the nodes\n are ordered in reverse document order; thu...
Please provide a description of the function:def xpathNextAncestorOrSelf(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextAncestorOrSelf(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextAncestorOrSelf() failed') __...
[ "Traversal function for the \"ancestor-or-self\" direction he\n ancestor-or-self axis contains the context node and\n ancestors of the context node in reverse document order;\n thus the context node is the first node on the axis, and\n the context node's parent the second; parent...
Please provide a description of the function:def xpathNextAttribute(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextAttribute(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextAttribute() failed') __tmp = xmlNode(_...
[ "Traversal function for the \"attribute\" direction TODO:\n support DTD inherited default attributes " ]
Please provide a description of the function:def xpathNextChild(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextChild(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextChild() failed') __tmp = xmlNode(_obj=ret) ...
[ "Traversal function for the \"child\" direction The child axis\n contains the children of the context node in document order. " ]
Please provide a description of the function:def xpathNextDescendant(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextDescendant(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextDescendant() failed') __tmp = xmlNod...
[ "Traversal function for the \"descendant\" direction the\n descendant axis contains the descendants of the context\n node in document order; a descendant is a child or a child\n of a child and so on. " ]
Please provide a description of the function:def xpathNextDescendantOrSelf(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextDescendantOrSelf(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextDescendantOrSelf() failed') ...
[ "Traversal function for the \"descendant-or-self\" direction\n the descendant-or-self axis contains the context node and\n the descendants of the context node in document order; thus\n the context node is the first node on the axis, and the\n first child of the context node is th...
Please provide a description of the function:def xpathNextFollowing(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextFollowing(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextFollowing() failed') __tmp = xmlNode(_...
[ "Traversal function for the \"following\" direction The\n following axis contains all nodes in the same document as\n the context node that are after the context node in\n document order, excluding any descendants and excluding\n attribute nodes and namespace nodes; the nodes are...
Please provide a description of the function:def xpathNextFollowingSibling(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextFollowingSibling(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextFollowingSibling() failed') ...
[ "Traversal function for the \"following-sibling\" direction\n The following-sibling axis contains the following siblings\n of the context node in document order. " ]
Please provide a description of the function:def xpathNextNamespace(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextNamespace(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextNamespace() failed') __tmp = xmlNode(_...
[ "Traversal function for the \"namespace\" direction the\n namespace axis contains the namespace nodes of the context\n node; the order of nodes on this axis is\n implementation-defined; the axis will be empty unless the\n context node is an element We keep the XML namespace node...
Please provide a description of the function:def xpathNextParent(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextParent(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextParent() failed') __tmp = xmlNode(_obj=ret) ...
[ "Traversal function for the \"parent\" direction The parent\n axis contains the parent of the context node, if there is\n one. " ]
Please provide a description of the function:def xpathNextPreceding(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextPreceding(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextPreceding() failed') __tmp = xmlNode(_...
[ "Traversal function for the \"preceding\" direction the\n preceding axis contains all nodes in the same document as\n the context node that are before the context node in\n document order, excluding any ancestors and excluding\n attribute nodes and namespace nodes; the nodes are ...
Please provide a description of the function:def xpathNextPrecedingSibling(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextPrecedingSibling(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextPrecedingSibling() failed') ...
[ "Traversal function for the \"preceding-sibling\" direction\n The preceding-sibling axis contains the preceding siblings\n of the context node in reverse document order; the first\n preceding sibling is first on the axis; the sibling\n preceding that node is the second on the ax...
Please provide a description of the function:def xpathNextSelf(self, cur): if cur is None: cur__o = None else: cur__o = cur._o ret = libxml2mod.xmlXPathNextSelf(self._o, cur__o) if ret is None:raise xpathError('xmlXPathNextSelf() failed') __tmp = xmlNode(_obj=ret) ...
[ "Traversal function for the \"self\" direction The self axis\n contains just the context node itself " ]
Please provide a description of the function:def xpatherror(self, file, line, no): libxml2mod.xmlXPatherror(self._o, file, line, no)
[ "Formats an error message. " ]
Please provide a description of the function:def _get_summary_struct(self): model_fields = [ ('Number of coefficients', 'num_coefficients'), ('Number of examples', 'num_examples'), ('Number of classes', 'num_classes'), ('Number of feature columns', 'num_...
[ "\n Returns a structured description of the model, including (where relevant)\n the schema of the training data, description of the training data,\n training statistics, and model hyperparameters.\n\n Returns\n -------\n sections : list (of list of tuples)\n A li...
Please provide a description of the function:def classify(self, dataset, missing_value_action='auto'): return super(LogisticClassifier, self).classify(dataset, missing_value_action=missing_value_action)
[ "\n Return a classification, for each example in the ``dataset``, using the\n trained logistic regression model. The output SFrame contains predictions\n as both class labels (0 or 1) as well as probabilities that the predicted\n value is the associated label.\n\n Parameters\n ...
Please provide a description of the function:def add_prefix_and_suffix(specified_name, type, property_set): property_set = b2.util.jam_to_value_maybe(property_set) suffix = "" if type: suffix = b2.build.type.generated_target_suffix(type, property_set) # Handle suffixes for which no leadi...
[ "Appends the suffix appropriate to 'type/property-set' combination\n to the specified name and returns the result." ]
Please provide a description of the function:def traverse (target, include_roots = False, include_sources = False): assert isinstance(target, VirtualTarget) assert isinstance(include_roots, (int, bool)) assert isinstance(include_sources, (int, bool)) result = [] if target.action (): ac...
[ " Traverses the dependency graph of 'target' and return all targets that will\n be created before this one is created. If root of some dependency graph is\n found during traversal, it's either included or not, dependencing of the\n value of 'include_roots'. In either case, sources of root are n...
Please provide a description of the function:def clone_action (action, new_project, new_action_name, new_properties): if __debug__: from .targets import ProjectTarget assert isinstance(action, Action) assert isinstance(new_project, ProjectTarget) assert isinstance(new_action_nam...
[ "Takes an 'action' instances and creates new instance of it\n and all produced target. The rule-name and properties are set\n to 'new-rule-name' and 'new-properties', if those are specified.\n Returns the cloned action." ]
Please provide a description of the function:def register (self, target): assert isinstance(target, VirtualTarget) if target.path(): signature = target.path() + "-" + target.name() else: signature = "-" + target.name() result = None if signature ...
[ " Registers a new virtual target. Checks if there's already registered target, with the same\n name, type, project and subvariant properties, and also with the same sources\n and equal action. If such target is found it is retured and 'target' is not registered.\n Otherwise, 'target...
Please provide a description of the function:def from_file (self, file, file_location, project): if __debug__: from .targets import ProjectTarget assert isinstance(file, basestring) assert isinstance(file_location, basestring) assert isinstance(project, P...
[ " Creates a virtual target with appropriate name and type from 'file'.\n If a target with that name in that project was already created, returns that already\n created target.\n TODO: more correct way would be to compute path to the file, based on name and source location\n ...
Please provide a description of the function:def add_suffix (self, specified_name, file_type, prop_set): assert isinstance(specified_name, basestring) assert isinstance(file_type, basestring) assert isinstance(prop_set, property_set.PropertySet) suffix = b2.build.type.generated_...
[ " Appends the suffix appropriate to 'type/property_set' combination\n to the specified name and returns the result.\n " ]
Please provide a description of the function:def depends (self, d): self.dependencies_ = unique (self.dependencies_ + d).sort ()
[ " Adds additional instances of 'VirtualTarget' that this\n one depends on.\n " ]
Please provide a description of the function:def actualize (self, scanner = None): if __debug__: from .scanner import Scanner assert scanner is None or isinstance(scanner, Scanner) actual_name = self.actualize_no_scanner () if self.always_: bjam.call...
[ " Generates all the actual targets and sets up build actions for\n this target.\n\n If 'scanner' is specified, creates an additional target\n with the same location as actual target, which will depend on the\n actual target and be associated with 'scanner'. That additiona...
Please provide a description of the function:def set_path (self, path): assert isinstance(path, basestring) self.path_ = os.path.normpath(path)
[ " Sets the path. When generating target name, it will override any path\n computation from properties.\n " ]
Please provide a description of the function:def root (self, set = None): assert isinstance(set, (int, bool, type(None))) if set: self.root_ = True return self.root_
[ " Sets/gets the 'root' flag. Target is root is it directly correspods to some\n variant of a main target.\n " ]
Please provide a description of the function:def creating_subvariant (self, s = None): assert s is None or isinstance(s, Subvariant) if s and not self.creating_subvariant (): if self.creating_subvariant (): raise BaseException ("Attempt to change 'dg'") ...
[ " Gets or sets the subvariant which created this target. Subvariant\n is set when target is brought into existance, and is never changed\n after that. In particual, if target is shared by subvariant, only\n the first is stored.\n s: If specified, specified the value to set,\n ...
Please provide a description of the function:def grist (self): # Depending on target, there may be different approaches to generating # unique prefixes. We'll generate prefixes in the form # <one letter approach code> <the actual prefix> path = self.path () if path: ...
[ "Helper to 'actual_name', above. Compute unique prefix used to distinguish\n this target from other targets with the same name which create different\n file.\n " ]
Please provide a description of the function:def __adjust_name(self, specified_name): assert isinstance(specified_name, basestring) if self.action_: ps = self.action_.properties() else: ps = property_set.empty() # FIXME: I'm not sure how this is used, ne...
[ "Given the target name specified in constructor, returns the\n name which should be really used, by looking at the <tag> properties.\n The tag properties come in two flavour:\n - <tag>value,\n - <tag>@rule-name\n In the first case, value is just added to name\n In the s...
Please provide a description of the function:def path (self): if not self.path_: if self.action_: p = self.action_.properties () (target_path, relative_to_build_dir) = p.target_path () if relative_to_build_dir: # Indicates...
[ " Returns the directory for this target.\n " ]
Please provide a description of the function:def actualize (self): if self.actualized_: return self.actualized_ = True ps = self.properties () properties = self.adjust_properties (ps) actual_targets = [] for i in self.targets (): actu...
[ " Generates actual build instructions.\n " ]
Please provide a description of the function:def actualize_source_type (self, sources, prop_set): assert is_iterable_typed(sources, VirtualTarget) assert isinstance(prop_set, property_set.PropertySet) result = [] for i in sources: scanner = None # FIXME: what's this...
[ " Helper for 'actualize_sources'.\n For each passed source, actualizes it with the appropriate scanner.\n Returns the actualized virtual targets.\n " ]
Please provide a description of the function:def actualize_sources (self, sources, prop_set): assert is_iterable_typed(sources, VirtualTarget) assert isinstance(prop_set, property_set.PropertySet) dependencies = self.properties_.get ('<dependency>') self.dependency_only_sources...
[ " Creates actual jam targets for sources. Initializes two member\n variables:\n 'self.actual_sources_' -- sources which are passed to updating action\n 'self.dependency_only_sources_' -- sources which are made dependencies, but\n are not used otherwise.\n\n New...
Please provide a description of the function:def all_referenced_targets(self, result): if __debug__: from .property import Property assert is_iterable_typed(result, (VirtualTarget, Property)) # Find directly referenced targets. deps = self.build_properties().depe...
[ "Returns all targets referenced by this subvariant,\n either directly or indirectly, and either as sources,\n or as dependency properties. Targets referred with\n dependency property are returned a properties, not targets." ]
Please provide a description of the function:def implicit_includes (self, feature, target_type): assert isinstance(feature, basestring) assert isinstance(target_type, basestring) if not target_type: key = feature else: key = feature + "-" + target_type ...
[ " Returns the properties which specify implicit include paths to\n generated headers. This traverses all targets in this subvariant,\n and subvariants referred by <implcit-dependecy>properties.\n For all targets which are of type 'target-type' (or for all targets,\n if 't...
Please provide a description of the function:def cmp_ast(node1, node2): ''' Compare if two nodes are equal. ''' if type(node1) != type(node2): return False if isinstance(node1, (list, tuple)): if len(node1) != len(node2): return False for left, right in zip(nod...
[]
Please provide a description of the function:def create_more_container_files(sourceDir, suffix, maxElements, containers, containers2): # Create files for each MPL-container with 20 to 'maxElements' elements # which will be used during generation. for container in containers: for i in range(20,...
[ "Creates additional files for the individual MPL-containers." ]
Please provide a description of the function:def create_input_for_numbered_sequences(headerDir, sourceDir, containers, maxElements): # Create additional container-list without "map". containersWithoutMap = containers[:] try: containersWithoutMap.remove('map') except ValueError: # We...
[ "Creates additional source- and header-files for the numbered sequence MPL-containers." ]
Please provide a description of the function:def adjust_container_limits_for_variadic_sequences(headerDir, containers, maxElements): for container in containers: headerFile = os.path.join( headerDir, "limits", container + ".hpp" ) regexMatch = r'(define\s+BOOST_MPL_LIMIT_' + container.upper()...
[ "Adjusts the limits of variadic sequence MPL-containers." ]
Please provide a description of the function:def current_boost_dir(): # Path to directory containing this script. path = os.path.dirname( os.path.realpath(__file__) ) # Making sure it is located in "${boost-dir}/libs/mpl/preprocessed". for directory in reversed( ["libs", "mpl", "preprocessed"] ): ...
[ "Returns the (relative) path to the Boost source-directory this file is located in (if any)." ]
Please provide a description of the function:def to_positive_multiple_of_10(string): try: value = int(string) except ValueError: msg = '"%r" is not a positive multiple of 10 (greater zero).' % string raise argparse.ArgumentTypeError(msg) if value <= 0 or value % 10 != 0: ...
[ "Converts a string into its encoded positive integer (greater zero) or throws an exception." ]
Please provide a description of the function:def main(): # Find the current Boost source-directory in which this script is located. sourceDir = current_boost_dir() if sourceDir == None: sourceDir = "" # Prepare and run cmdline-parser. cmdlineParser = argparse.ArgumentParser(de...
[ "The main function." ]
Please provide a description of the function:def add_inner_product(self, name, W, b, input_channels, output_channels, has_bias, input_name, output_name, **kwargs): spec = self.spec nn_spec = self.nn_spec # Add a new layer spec_layer = nn_spec.layers.a...
[ "\n Add an inner product layer to the model.\n\n Parameters\n ----------\n name: str\n The name of this layer\n W: numpy.array or bytes()\n Weight matrix of shape (output_channels, input_channels)\n If W is of type bytes(), i.e. quantized, other qu...
Please provide a description of the function:def add_convolution(self, name, kernel_channels, output_channels, height, width, stride_height, stride_width, border_mode, groups, W, b, has_bias, is_deconv = False, output_shape = None, input_name = 'data', output_name = 'out', ...
[ "\n Add a convolution layer to the network.\n\n Please see the ConvolutionLayerParams in Core ML neural network\n protobuf message for more information about input and output blob dimensions.\n\n Parameters\n ----------\n name: str\n The name of this layer.\n ...
Please provide a description of the function:def add_resize_bilinear(self, name, input_name, output_name, target_height=1, target_width=1, mode='ALIGN_ENDPOINTS_MODE'): spec = self.spec nn_spec = self.nn_spec # Add a new inner-product layer spec_laye...
[ "\n Add resize bilinear layer to the model. A layer that resizes the input to a given spatial size using bilinear interpolation.\n\n Parameters\n ----------\n name: str\n The name of this layer.\n input_name: str\n The input blob name of this layer.\n ...
Please provide a description of the function:def add_crop_resize(self, name, input_names, output_name, target_height=1, target_width=1, mode='STRICT_ALIGN_ENDPOINTS_MODE', normalized_roi=False, box_indices_mode='CORNERS_HEIGHT_FIRST', ...
[ "\n Add crop resize layer to the model. A layer that extracts cropped spatial patches or RoIs (regions of interest)\n from the input and resizes them to a pre-specified size using bilinear interpolation.\n Note that RoI Align layer can be implemented with this layer followed by a pooling layer....
Please provide a description of the function:def _toolkit_serialize_summary_struct(model, sections, section_titles): output_dict = dict() output_dict['sections'] = [ [ ( field[0], __extract_model_summary_value(model, field[1]) ) \ ...
[ "\n Serialize model summary into a dict with ordered lists of sections and section titles\n\n Parameters\n ----------\n model : Model object\n sections : Ordered list of lists (sections) of tuples (field,value)\n [\n [(field1, value1), (field2, value2)],\n [(field3, value3), (fie...
Please provide a description of the function:def _add_docstring(format_dict): def add_docstring_context(func): def wrapper(*args, **kwargs): return func(*args, **kwargs) wrapper.__doc__ = func.__doc__.format(**format_dict) return wrapper return add_docstring_context
[ "\n Format a doc-string on the fly.\n @arg format_dict: A dictionary to format the doc-strings\n Example:\n\n @add_docstring({'context': __doc_string_context})\n def predict(x):\n '''\n {context}\n >> model.predict(data)\n '''\n return x\...
Please provide a description of the function:def _find_only_column_of_type(sframe, target_type, type_name, col_name): image_column_name = None if type(target_type) != list: target_type = [target_type] for name, ctype in zip(sframe.column_names(), sframe.column_types()): if ctype in targ...
[ "\n Finds the only column in `SFrame` with a type specified by `target_type`.\n If there are zero or more than one such columns, an exception will be\n raised. The name and type of the target column should be provided as\n strings for the purpose of error feedback.\n " ]
Please provide a description of the function:def _find_only_image_column(sframe): from turicreate import Image return _find_only_column_of_type(sframe, target_type=Image, type_name='image', col_name='feature')
[ "\n Finds the only column in `sframe` with a type of turicreate.Image. \n If there are zero or more than one image columns, an exception will \n be raised.\n " ]
Please provide a description of the function:def _find_only_drawing_column(sframe): from turicreate import Image bitmap_success, stroke_success = False, False bitmap_error, stroke_error = None, None feature = None try: feature = _find_only_column_of_type(sframe, target_type...
[ "\n Finds the only column that can be interpreted as a drawing feature column.\n A drawing column can be a stroke-based drawing column (with dtype list)\n or a bitmap-based drawing column (with dtype turicreate.Image)\n \n If there are zero or more than one drawing columns, an exception will be\n ...
Please provide a description of the function:def _SGraphFromJsonTree(json_str): g = json.loads(json_str) vertices = [_Vertex(x['id'], dict([(str(k), v) for k, v in _six.iteritems(x) if k != 'id'])) for x in g['vertices']] edges = [_E...
[ "\n Convert the Json Tree to SGraph\n " ]
Please provide a description of the function:def _summarize_coefficients(top_coefs, bottom_coefs): def get_row_name(row): if row['index'] is None: return row['name'] else: return "%s[%s]" % (row['name'], row['index']) if len(top_coefs) == 0: top_coefs_list ...
[ "\n Return a tuple of sections and section titles.\n Sections are pretty print of model coefficients\n\n Parameters\n ----------\n top_coefs : SFrame of top k coefficients\n\n bottom_coefs : SFrame of bottom k coefficients\n\n Returns\n -------\n (sections, section_titles) : tuple\n ...
Please provide a description of the function:def _toolkit_get_topk_bottomk(values, k=5): top_values = values.topk('value', k=k) top_values = top_values[top_values['value'] > 0] bottom_values = values.topk('value', k=k, reverse=True) bottom_values = bottom_values[bottom_values['value'] < 0] r...
[ "\n Returns a tuple of the top k values from the positive and\n negative values in a SArray\n\n Parameters\n ----------\n values : SFrame of model coefficients\n\n k: Maximum number of largest positive and k lowest negative numbers to return\n\n Returns\n -------\n (topk_positive, bottomk...
Please provide a description of the function:def __extract_model_summary_value(model, value): field_value = None if isinstance(value, _precomputed_field): field_value = value.field else: field_value = model._get(value) if isinstance(field_value, float): try: fiel...
[ "\n Extract a model summary field value\n " ]
Please provide a description of the function:def _make_repr_table_from_sframe(X): assert isinstance(X, _SFrame) column_names = X.column_names() out_data = [ [None]*len(column_names) for i in range(X.num_rows())] column_sizes = [len(s) for s in column_names] for i, c in enumerate(column_nam...
[ "\n Serializes an SFrame to a list of strings, that, when printed, creates a well-formatted table.\n " ]
Please provide a description of the function:def _toolkit_repr_print(model, fields, section_titles, width = None): assert len(section_titles) == len(fields), \ "The number of section titles ({0}) ".format(len(section_titles)) +\ "doesn't match the number of groups of fields, {0}.".format(len(f...
[ "\n Display a toolkit repr according to some simple rules.\n\n Parameters\n ----------\n model : Turi Create model\n\n fields: List of lists of tuples\n Each tuple should be (display_name, field_name), where field_name can\n be a string or a _precomputed_field object.\n\n\n section_t...
Please provide a description of the function:def _map_unity_proxy_to_object(value): vtype = type(value) if vtype in _proxy_map: return _proxy_map[vtype](value) elif vtype == list: return [_map_unity_proxy_to_object(v) for v in value] elif vtype == dict: return {k:_map_unity_...
[ "\n Map returning value, if it is unity SFrame, SArray, map it\n " ]
Please provide a description of the function:def _toolkits_select_columns(dataset, columns): try: return dataset.select_columns(columns) except RuntimeError: missing_features = list(set(columns).difference(set(dataset.column_names()))) raise ToolkitError("Input data does not contain...
[ "\n Same as select columns but redirect runtime error to ToolkitError.\n " ]
Please provide a description of the function:def _raise_error_if_column_exists(dataset, column_name = 'dataset', dataset_variable_name = 'dataset', column_name_error_message_name = 'column_name'): err_msg = 'The SFrame {0} must contain the column {1}.'.fo...
[ "\n Check if a column exists in an SFrame with error message.\n " ]
Please provide a description of the function:def _check_categorical_option_type(option_name, option_value, possible_values): err_msg = '{0} is not a valid option for {1}. '.format(option_value, option_name) err_msg += ' Expected one of: '.format(possible_values) err_msg += ', '.join(map(str, possible_...
[ "\n Check whether or not the requested option is one of the allowed values.\n " ]
Please provide a description of the function:def _raise_error_if_not_sarray(dataset, variable_name="SArray"): err_msg = "Input %s is not an SArray." if not isinstance(dataset, _SArray): raise ToolkitError(err_msg % variable_name)
[ "\n Check if the input is an SArray. Provide a proper error\n message otherwise.\n " ]
Please provide a description of the function:def _raise_error_if_not_sframe(dataset, variable_name="SFrame"): err_msg = "Input %s is not an SFrame. If it is a Pandas DataFrame," err_msg += " you may use the to_sframe() function to convert it to an SFrame." if not isinstance(dataset, _SFrame): ra...
[ "\n Check if the input is an SFrame. Provide a proper error\n message otherwise.\n " ]
Please provide a description of the function:def _raise_error_if_sframe_empty(dataset, variable_name="SFrame"): err_msg = "Input %s either has no rows or no columns. A non-empty SFrame " err_msg += "is required." if dataset.num_rows() == 0 or dataset.num_columns() == 0: raise ToolkitError(err_...
[ "\n Check if the input is empty.\n " ]
Please provide a description of the function:def _raise_error_evaluation_metric_is_valid(metric, allowed_metrics): err_msg = "Evaluation metric '%s' not recognized. The supported evaluation" err_msg += " metrics are (%s)." if metric not in allowed_metrics: raise ToolkitError(err_msg % (metric, ...
[ "\n Check if the input is an SFrame. Provide a proper error\n message otherwise.\n " ]
Please provide a description of the function:def _numeric_param_check_range(variable_name, variable_value, range_bottom, range_top): err_msg = "%s must be between %i and %i" if variable_value < range_bottom or variable_value > range_top: raise ToolkitError(err_msg % (variable_name, range_bottom, r...
[ "\n Checks if numeric parameter is within given range\n " ]
Please provide a description of the function:def _validate_data(dataset, target, features=None, validation_set='auto'): _raise_error_if_not_sframe(dataset, "training dataset") # Determine columns to keep if features is None: features = [feat for feat in dataset.column_names() if feat != targe...
[ "\n Validate and canonicalize training and validation data.\n\n Parameters\n ----------\n dataset : SFrame\n Dataset for training the model.\n\n target : string\n Name of the column containing the target variable.\n\n features : list[string], optional\n List of feature names u...
Please provide a description of the function:def _validate_row_label(dataset, label=None, default_label='__id'): ## If no label is provided, set it to be a default and add a row number to # dataset. Check that this new name does not conflict with an existing # name. if not label: ## Try ...
[ "\n Validate a row label column. If the row label is not specified, a column is\n created with row numbers, named with the string in the `default_label`\n parameter.\n\n Parameters\n ----------\n dataset : SFrame\n Input dataset.\n\n label : str, optional\n Name of the column cont...
Please provide a description of the function:def _mac_ver(): import platform import sys if sys.platform == 'darwin': ver_str = platform.mac_ver()[0] return tuple([int(v) for v in ver_str.split('.')]) else: return ()
[ "\n Returns Mac version as a tuple of integers, making it easy to do proper\n version comparisons. On non-Macs, it returns an empty tuple.\n " ]
Please provide a description of the function:def _print_neural_compute_device(cuda_gpus, use_mps, cuda_mem_req=None, has_mps_impl=True): num_cuda_gpus = len(cuda_gpus) if num_cuda_gpus >= 1: gpu_names = ', '.join(gpu['name'] for gpu in cuda_gpus) if use_mps: from ._mps_utils import mps...
[ "\n Print a message making it clear to the user what compute resource is used in\n neural network training.\n " ]
Please provide a description of the function:def _GetMessageFromFactory(factory, full_name): proto_descriptor = factory.pool.FindMessageTypeByName(full_name) proto_cls = factory.GetPrototype(proto_descriptor) return proto_cls
[ "Get a proto class from the MessageFactory by name.\n\n Args:\n factory: a MessageFactory instance.\n full_name: str, the fully qualified name of the proto type.\n Returns:\n A class, for the type identified by full_name.\n Raises:\n KeyError, if the proto is not found in the factory's descriptor poo...
Please provide a description of the function:def MakeSimpleProtoClass(fields, full_name=None, pool=None): factory = message_factory.MessageFactory(pool=pool) if full_name is not None: try: proto_cls = _GetMessageFromFactory(factory, full_name) return proto_cls except KeyError: # The fa...
[ "Create a Protobuf class whose fields are basic types.\n\n Note: this doesn't validate field names!\n\n Args:\n fields: dict of {name: field_type} mappings for each field in the proto. If\n this is an OrderedDict the order will be maintained, otherwise the\n fields will be sorted by name.\n fu...
Please provide a description of the function:def _MakeFileDescriptorProto(proto_file_name, full_name, field_items): package, name = full_name.rsplit('.', 1) file_proto = descriptor_pb2.FileDescriptorProto() file_proto.name = os.path.join(package.replace('.', '/'), proto_file_name) file_proto.package = packag...
[ "Populate FileDescriptorProto for MessageFactory's DescriptorPool." ]
Please provide a description of the function:def convert(model, input_name, output_features): if not(HAS_SKLEARN): raise RuntimeError('scikit-learn not found. scikit-learn conversion API is disabled.') _sklearn_util.check_expected_type(model, _tree.DecisionTreeClassifier) _sklearn_util.check_f...
[ "Convert a decision tree model to protobuf format.\n\n Parameters\n ----------\n decision_tree : DecisionTreeClassifier\n A trained scikit-learn tree model.\n\n input_name: str\n Name of the input columns.\n\n output_name: str\n Name of the output columns.\n\n Returns\n ---...
Please provide a description of the function:def _get_model_metadata(model_class, metadata, version=None): from turicreate import __version__ info = { 'turicreate_version': __version__, 'type': model_class, } if version is not None: info['version'] = str(version) info.up...
[ "\n Returns user-defined metadata, making sure information all models should \n have is also available, as a dictionary\n " ]
Please provide a description of the function:def _set_model_metadata(mlmodel, model_class, metadata, version=None): info = _get_model_metadata(model_class, metadata, version) mlmodel.user_defined_metadata.update(info)
[ "\n Sets user-defined metadata, making sure information all models should have\n is also available\n " ]
Please provide a description of the function:def _ToCamelCase(name): capitalize_next = False result = [] for c in name: if c == '_': if result: capitalize_next = True elif capitalize_next: result.append(c.upper()) capitalize_next = False else: result += c # Lower...
[ "Converts name to camel-case and returns it." ]
Please provide a description of the function:def _ToJsonName(name): capitalize_next = False result = [] for c in name: if c == '_': capitalize_next = True elif capitalize_next: result.append(c.upper()) capitalize_next = False else: result += c return ''.join(result)
[ "Converts name to Json name and returns it." ]
Please provide a description of the function:def _SetOptions(self, options, options_class_name): self._options = options self._options_class_name = options_class_name # Does this descriptor have non-default options? self.has_options = options is not None
[ "Sets the descriptor's options\n\n This function is used in generated proto2 files to update descriptor\n options. It must not be used outside proto2.\n " ]
Please provide a description of the function:def GetOptions(self): if self._options: return self._options from google.protobuf import descriptor_pb2 try: options_class = getattr(descriptor_pb2, self._options_class_name) except AttributeError: raise RuntimeError('Unknown options cl...
[ "Retrieves descriptor options.\n\n This method returns the options set or creates the default options for the\n descriptor.\n " ]
Please provide a description of the function:def CopyToProto(self, proto): if (self.file is not None and self._serialized_start is not None and self._serialized_end is not None): proto.ParseFromString(self.file.serialized_pb[ self._serialized_start:self._serialized_end]) els...
[ "Copies this to the matching proto in descriptor_pb2.\n\n Args:\n proto: An empty proto instance from descriptor_pb2.\n\n Raises:\n Error: If self couldnt be serialized, due to to few constructor arguments.\n " ]
Please provide a description of the function:def EnumValueName(self, enum, value): return self.enum_types_by_name[enum].values_by_number[value].name
[ "Returns the string name of an enum value.\n\n This is just a small helper method to simplify a common operation.\n\n Args:\n enum: string name of the Enum.\n value: int, value of the enum.\n\n Returns:\n string name of the enum value.\n\n Raises:\n KeyError if either the Enum doesn'...
Please provide a description of the function:def resolve_reference(target_reference, project): # Separate target name from properties override assert isinstance(target_reference, basestring) assert isinstance(project, ProjectTarget) split = _re_separate_target_from_properties.match (target_referenc...
[ " Given a target_reference, made in context of 'project',\n returns the AbstractTarget instance that is referred to, as well\n as properties explicitly specified for this reference.\n " ]
Please provide a description of the function:def generate_from_reference(target_reference, project, property_set_): assert isinstance(target_reference, basestring) assert isinstance(project, ProjectTarget) assert isinstance(property_set_, property_set.PropertySet) target, sproperties = resolve_refe...
[ " Attempts to generate the target given by target reference, which\n can refer both to a main target or to a file.\n Returns a list consisting of\n - usage requirements\n - generated virtual targets, if any\n target_reference: Target reference\n project: Project where the reference is m...
Please provide a description of the function:def main_target_alternative (self, target): assert isinstance(target, AbstractTarget) target.project ().add_alternative (target) return target
[ " Registers the specified target as a main target alternatives.\n Returns 'target'.\n " ]
Please provide a description of the function:def main_target_sources (self, sources, main_target_name, no_renaming=0): assert is_iterable_typed(sources, basestring) assert isinstance(main_target_name, basestring) assert isinstance(no_renaming, (int, bool)) result = [] f...
[ "Return the list of sources to use, if main target rule is invoked\n with 'sources'. If there are any objects in 'sources', they are treated\n as main target instances, and the name of such targets are adjusted to\n be '<name_of_this_target>__<name_of_source_target>'. Such renaming\n is ...
Please provide a description of the function:def main_target_requirements(self, specification, project): assert is_iterable_typed(specification, basestring) assert isinstance(project, ProjectTarget) # create a copy since the list is being modified specification = list(specificat...
[ "Returns the requirement to use when declaring a main target,\n which are obtained by\n - translating all specified property paths, and\n - refining project requirements with the one specified for the target\n\n 'specification' are the properties xplicitly specified for a\n ...