repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
apple/turicreate | src/unity/python/turicreate/visualization/show.py | box_plot | def box_plot(x, y, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT):
"""
Plots the data in `x` on the X axis and the data in `y` on the Y axis
in a 2d box and whiskers plot, and returns the resulting Plot object.
The function x as SArray of dtype str and y as SArray of dtype: int, f... | python | def box_plot(x, y, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT):
"""
Plots the data in `x` on the X axis and the data in `y` on the Y axis
in a 2d box and whiskers plot, and returns the resulting Plot object.
The function x as SArray of dtype str and y as SArray of dtype: int, f... | [
"def",
"box_plot",
"(",
"x",
",",
"y",
",",
"xlabel",
"=",
"LABEL_DEFAULT",
",",
"ylabel",
"=",
"LABEL_DEFAULT",
",",
"title",
"=",
"LABEL_DEFAULT",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"x",
",",
"tc",
".",
"data_structures",
".",
"sarray",
"... | Plots the data in `x` on the X axis and the data in `y` on the Y axis
in a 2d box and whiskers plot, and returns the resulting Plot object.
The function x as SArray of dtype str and y as SArray of dtype: int, float.
Parameters
----------
x : SArray
The data to plot on the X axis of the b... | [
"Plots",
"the",
"data",
"in",
"x",
"on",
"the",
"X",
"axis",
"and",
"the",
"data",
"in",
"y",
"on",
"the",
"Y",
"axis",
"in",
"a",
"2d",
"box",
"and",
"whiskers",
"plot",
"and",
"returns",
"the",
"resulting",
"Plot",
"object",
".",
"The",
"function",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/visualization/show.py#L292-L337 | train |
apple/turicreate | src/unity/python/turicreate/visualization/show.py | columnwise_summary | def columnwise_summary(sf):
"""
Plots a columnwise summary of the sframe provided as input,
and returns the resulting Plot object.
The function supports SFrames.
Parameters
----------
sf : SFrame
The data to get a columnwise summary for.
Returns
-------
out : Pl... | python | def columnwise_summary(sf):
"""
Plots a columnwise summary of the sframe provided as input,
and returns the resulting Plot object.
The function supports SFrames.
Parameters
----------
sf : SFrame
The data to get a columnwise summary for.
Returns
-------
out : Pl... | [
"def",
"columnwise_summary",
"(",
"sf",
")",
":",
"if",
"not",
"isinstance",
"(",
"sf",
",",
"tc",
".",
"data_structures",
".",
"sframe",
".",
"SFrame",
")",
":",
"raise",
"ValueError",
"(",
"\"turicreate.visualization.columnwise_summary \"",
"+",
"\"supports SFra... | Plots a columnwise summary of the sframe provided as input,
and returns the resulting Plot object.
The function supports SFrames.
Parameters
----------
sf : SFrame
The data to get a columnwise summary for.
Returns
-------
out : Plot
A :class: Plot object that is t... | [
"Plots",
"a",
"columnwise",
"summary",
"of",
"the",
"sframe",
"provided",
"as",
"input",
"and",
"returns",
"the",
"resulting",
"Plot",
"object",
".",
"The",
"function",
"supports",
"SFrames",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/visualization/show.py#L339-L369 | train |
apple/turicreate | src/unity/python/turicreate/visualization/show.py | histogram | def histogram(sa, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT):
"""
Plots a histogram of the sarray provided as input, and returns the
resulting Plot object.
The function supports numeric SArrays with dtypes int or float.
Parameters
----------
sa : SArray
The... | python | def histogram(sa, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT):
"""
Plots a histogram of the sarray provided as input, and returns the
resulting Plot object.
The function supports numeric SArrays with dtypes int or float.
Parameters
----------
sa : SArray
The... | [
"def",
"histogram",
"(",
"sa",
",",
"xlabel",
"=",
"LABEL_DEFAULT",
",",
"ylabel",
"=",
"LABEL_DEFAULT",
",",
"title",
"=",
"LABEL_DEFAULT",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"sa",
",",
"tc",
".",
"data_structures",
".",
"sarray",
".",
"SArr... | Plots a histogram of the sarray provided as input, and returns the
resulting Plot object.
The function supports numeric SArrays with dtypes int or float.
Parameters
----------
sa : SArray
The data to get a histogram for. Must be numeric (int/float).
xlabel : str (optional)
The... | [
"Plots",
"a",
"histogram",
"of",
"the",
"sarray",
"provided",
"as",
"input",
"and",
"returns",
"the",
"resulting",
"Plot",
"object",
".",
"The",
"function",
"supports",
"numeric",
"SArrays",
"with",
"dtypes",
"int",
"or",
"float",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/visualization/show.py#L371-L411 | train |
apple/turicreate | src/unity/python/turicreate/visualization/show.py | item_frequency | def item_frequency(sa, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT):
"""
Plots an item frequency of the sarray provided as input, and returns the
resulting Plot object.
The function supports SArrays with dtype str.
Parameters
----------
sa : SArray
The data t... | python | def item_frequency(sa, xlabel=LABEL_DEFAULT, ylabel=LABEL_DEFAULT, title=LABEL_DEFAULT):
"""
Plots an item frequency of the sarray provided as input, and returns the
resulting Plot object.
The function supports SArrays with dtype str.
Parameters
----------
sa : SArray
The data t... | [
"def",
"item_frequency",
"(",
"sa",
",",
"xlabel",
"=",
"LABEL_DEFAULT",
",",
"ylabel",
"=",
"LABEL_DEFAULT",
",",
"title",
"=",
"LABEL_DEFAULT",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"sa",
",",
"tc",
".",
"data_structures",
".",
"sarray",
".",
... | Plots an item frequency of the sarray provided as input, and returns the
resulting Plot object.
The function supports SArrays with dtype str.
Parameters
----------
sa : SArray
The data to get an item frequency for. Must have dtype str
xlabel : str (optional)
The text label for... | [
"Plots",
"an",
"item",
"frequency",
"of",
"the",
"sarray",
"provided",
"as",
"input",
"and",
"returns",
"the",
"resulting",
"Plot",
"object",
".",
"The",
"function",
"supports",
"SArrays",
"with",
"dtype",
"str",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/visualization/show.py#L413-L453 | train |
apple/turicreate | deps/src/libevent-2.0.18-stable/event_rpcgen.py | Parse | def Parse(factory, file):
"""
Parses the input file and returns C code and corresponding header file.
"""
entities = []
while 1:
# Just gets the whole struct nicely formatted
data = GetNextStruct(file)
if not data:
break
entities.extend(ProcessStruct(f... | python | def Parse(factory, file):
"""
Parses the input file and returns C code and corresponding header file.
"""
entities = []
while 1:
# Just gets the whole struct nicely formatted
data = GetNextStruct(file)
if not data:
break
entities.extend(ProcessStruct(f... | [
"def",
"Parse",
"(",
"factory",
",",
"file",
")",
":",
"entities",
"=",
"[",
"]",
"while",
"1",
":",
"# Just gets the whole struct nicely formatted",
"data",
"=",
"GetNextStruct",
"(",
"file",
")",
"if",
"not",
"data",
":",
"break",
"entities",
".",
"extend"... | Parses the input file and returns C code and corresponding header file. | [
"Parses",
"the",
"input",
"file",
"and",
"returns",
"C",
"code",
"and",
"corresponding",
"header",
"file",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libevent-2.0.18-stable/event_rpcgen.py#L1509-L1525 | train |
apple/turicreate | deps/src/libevent-2.0.18-stable/event_rpcgen.py | Struct.EntryTagName | def EntryTagName(self, entry):
"""Creates the name inside an enumeration for distinguishing data
types."""
name = "%s_%s" % (self._name, entry.Name())
return name.upper() | python | def EntryTagName(self, entry):
"""Creates the name inside an enumeration for distinguishing data
types."""
name = "%s_%s" % (self._name, entry.Name())
return name.upper() | [
"def",
"EntryTagName",
"(",
"self",
",",
"entry",
")",
":",
"name",
"=",
"\"%s_%s\"",
"%",
"(",
"self",
".",
"_name",
",",
"entry",
".",
"Name",
"(",
")",
")",
"return",
"name",
".",
"upper",
"(",
")"
] | Creates the name inside an enumeration for distinguishing data
types. | [
"Creates",
"the",
"name",
"inside",
"an",
"enumeration",
"for",
"distinguishing",
"data",
"types",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libevent-2.0.18-stable/event_rpcgen.py#L66-L70 | train |
apple/turicreate | deps/src/libevent-2.0.18-stable/event_rpcgen.py | Struct.PrintIndented | def PrintIndented(self, file, ident, code):
"""Takes an array, add indentation to each entry and prints it."""
for entry in code:
print >>file, '%s%s' % (ident, entry) | python | def PrintIndented(self, file, ident, code):
"""Takes an array, add indentation to each entry and prints it."""
for entry in code:
print >>file, '%s%s' % (ident, entry) | [
"def",
"PrintIndented",
"(",
"self",
",",
"file",
",",
"ident",
",",
"code",
")",
":",
"for",
"entry",
"in",
"code",
":",
"print",
">>",
"file",
",",
"'%s%s'",
"%",
"(",
"ident",
",",
"entry",
")"
] | Takes an array, add indentation to each entry and prints it. | [
"Takes",
"an",
"array",
"add",
"indentation",
"to",
"each",
"entry",
"and",
"prints",
"it",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libevent-2.0.18-stable/event_rpcgen.py#L72-L75 | train |
apple/turicreate | deps/src/libevent-2.0.18-stable/event_rpcgen.py | StructCCode.PrintTags | def PrintTags(self, file):
"""Prints the tag definitions for a structure."""
print >>file, '/* Tag definition for %s */' % self._name
print >>file, 'enum %s_ {' % self._name.lower()
for entry in self._entries:
print >>file, ' %s=%d,' % (self.EntryTagName(entry),
... | python | def PrintTags(self, file):
"""Prints the tag definitions for a structure."""
print >>file, '/* Tag definition for %s */' % self._name
print >>file, 'enum %s_ {' % self._name.lower()
for entry in self._entries:
print >>file, ' %s=%d,' % (self.EntryTagName(entry),
... | [
"def",
"PrintTags",
"(",
"self",
",",
"file",
")",
":",
"print",
">>",
"file",
",",
"'/* Tag definition for %s */'",
"%",
"self",
".",
"_name",
"print",
">>",
"file",
",",
"'enum %s_ {'",
"%",
"self",
".",
"_name",
".",
"lower",
"(",
")",
"for",
"entry",... | Prints the tag definitions for a structure. | [
"Prints",
"the",
"tag",
"definitions",
"for",
"a",
"structure",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/libevent-2.0.18-stable/event_rpcgen.py#L83-L91 | train |
apple/turicreate | src/unity/python/turicreate/aggregate.py | QUANTILE | def QUANTILE(src_column, *args):
"""
Builtin approximate quantile aggregator for groupby.
Accepts as an argument, one or more of a list of quantiles to query.
For instance:
To extract the median
>>> sf.groupby("user",
... {'rating_quantiles':tc.aggregate.QUANTILE('rating', 0.5)})
To... | python | def QUANTILE(src_column, *args):
"""
Builtin approximate quantile aggregator for groupby.
Accepts as an argument, one or more of a list of quantiles to query.
For instance:
To extract the median
>>> sf.groupby("user",
... {'rating_quantiles':tc.aggregate.QUANTILE('rating', 0.5)})
To... | [
"def",
"QUANTILE",
"(",
"src_column",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"quantiles",
"=",
"args",
"[",
"0",
"]",
"else",
":",
"quantiles",
"=",
"list",
"(",
"args",
")",
"if",
"not",
"_is_non_string_iterable",... | Builtin approximate quantile aggregator for groupby.
Accepts as an argument, one or more of a list of quantiles to query.
For instance:
To extract the median
>>> sf.groupby("user",
... {'rating_quantiles':tc.aggregate.QUANTILE('rating', 0.5)})
To extract a few quantiles
>>> sf.groupby(... | [
"Builtin",
"approximate",
"quantile",
"aggregator",
"for",
"groupby",
".",
"Accepts",
"as",
"an",
"argument",
"one",
"or",
"more",
"of",
"a",
"list",
"of",
"quantiles",
"to",
"query",
".",
"For",
"instance",
":"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/aggregate.py#L226-L259 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/graph_analytics/kcore.py | create | def create(graph, kmin=0, kmax=10, verbose=True):
"""
Compute the K-core decomposition of the graph. Return a model object with
total number of cores as well as the core id for each vertex in the graph.
Parameters
----------
graph : SGraph
The graph on which to compute the k-core decomp... | python | def create(graph, kmin=0, kmax=10, verbose=True):
"""
Compute the K-core decomposition of the graph. Return a model object with
total number of cores as well as the core id for each vertex in the graph.
Parameters
----------
graph : SGraph
The graph on which to compute the k-core decomp... | [
"def",
"create",
"(",
"graph",
",",
"kmin",
"=",
"0",
",",
"kmax",
"=",
"10",
",",
"verbose",
"=",
"True",
")",
":",
"from",
"turicreate",
".",
"_cython",
".",
"cy_server",
"import",
"QuietProgress",
"if",
"not",
"isinstance",
"(",
"graph",
",",
"_SGra... | Compute the K-core decomposition of the graph. Return a model object with
total number of cores as well as the core id for each vertex in the graph.
Parameters
----------
graph : SGraph
The graph on which to compute the k-core decomposition.
kmin : int, optional
Minimum core id. Ve... | [
"Compute",
"the",
"K",
"-",
"core",
"decomposition",
"of",
"the",
"graph",
".",
"Return",
"a",
"model",
"object",
"with",
"total",
"number",
"of",
"cores",
"as",
"well",
"as",
"the",
"core",
"id",
"for",
"each",
"vertex",
"in",
"the",
"graph",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/graph_analytics/kcore.py#L86-L150 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_utils.py | raise_error_unsupported_categorical_option | def raise_error_unsupported_categorical_option(option_name, option_value, layer_type, layer_name):
"""
Raise an error if an option is not supported.
"""
raise RuntimeError("Unsupported option %s=%s in layer %s(%s)" % (option_name, option_value,
layer_type, layer_name)) | python | def raise_error_unsupported_categorical_option(option_name, option_value, layer_type, layer_name):
"""
Raise an error if an option is not supported.
"""
raise RuntimeError("Unsupported option %s=%s in layer %s(%s)" % (option_name, option_value,
layer_type, layer_name)) | [
"def",
"raise_error_unsupported_categorical_option",
"(",
"option_name",
",",
"option_value",
",",
"layer_type",
",",
"layer_name",
")",
":",
"raise",
"RuntimeError",
"(",
"\"Unsupported option %s=%s in layer %s(%s)\"",
"%",
"(",
"option_name",
",",
"option_value",
",",
"... | Raise an error if an option is not supported. | [
"Raise",
"an",
"error",
"if",
"an",
"option",
"is",
"not",
"supported",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_utils.py#L7-L12 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/_feature_management.py | process_or_validate_classifier_output_features | def process_or_validate_classifier_output_features(
output_features, class_labels, supports_class_scores = True):
"""
Given a list of class labels and a list of output_features, validate the
list and return a valid version of output_features with all the correct
data type information included.
... | python | def process_or_validate_classifier_output_features(
output_features, class_labels, supports_class_scores = True):
"""
Given a list of class labels and a list of output_features, validate the
list and return a valid version of output_features with all the correct
data type information included.
... | [
"def",
"process_or_validate_classifier_output_features",
"(",
"output_features",
",",
"class_labels",
",",
"supports_class_scores",
"=",
"True",
")",
":",
"def",
"raise_error",
"(",
"msg",
")",
":",
"raise",
"ValueError",
"(",
"\"Classifier error: %s\"",
"%",
"msg",
"... | Given a list of class labels and a list of output_features, validate the
list and return a valid version of output_features with all the correct
data type information included. | [
"Given",
"a",
"list",
"of",
"class",
"labels",
"and",
"a",
"list",
"of",
"output_features",
"validate",
"the",
"list",
"and",
"return",
"a",
"valid",
"version",
"of",
"output_features",
"with",
"all",
"the",
"correct",
"data",
"type",
"information",
"included"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/_feature_management.py#L19-L103 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/_feature_management.py | process_or_validate_features | def process_or_validate_features(features, num_dimensions = None, feature_type_map = {}):
"""
Puts features into a standard form from a number of different possible forms.
The standard form is a list of 2-tuples of (name, datatype) pairs. The name
is a string and the datatype is an object as defined i... | python | def process_or_validate_features(features, num_dimensions = None, feature_type_map = {}):
"""
Puts features into a standard form from a number of different possible forms.
The standard form is a list of 2-tuples of (name, datatype) pairs. The name
is a string and the datatype is an object as defined i... | [
"def",
"process_or_validate_features",
"(",
"features",
",",
"num_dimensions",
"=",
"None",
",",
"feature_type_map",
"=",
"{",
"}",
")",
":",
"original_features",
"=",
"copy",
"(",
"features",
")",
"if",
"num_dimensions",
"is",
"not",
"None",
"and",
"not",
"is... | Puts features into a standard form from a number of different possible forms.
The standard form is a list of 2-tuples of (name, datatype) pairs. The name
is a string and the datatype is an object as defined in the _datatype module.
The possible input forms are as follows:
* A list of strings. in t... | [
"Puts",
"features",
"into",
"a",
"standard",
"form",
"from",
"a",
"number",
"of",
"different",
"possible",
"forms",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/_feature_management.py#L130-L317 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/kernel/bootstrap.py | bootstrap | def bootstrap(root_path):
"""Performs python-side bootstrapping of Boost.Build/Python.
This function arranges for 'b2.whatever' package names to work, while also
allowing to put python files alongside corresponding jam modules.
"""
m = imp.new_module("b2")
# Note that:
# 1. If __path__ is ... | python | def bootstrap(root_path):
"""Performs python-side bootstrapping of Boost.Build/Python.
This function arranges for 'b2.whatever' package names to work, while also
allowing to put python files alongside corresponding jam modules.
"""
m = imp.new_module("b2")
# Note that:
# 1. If __path__ is ... | [
"def",
"bootstrap",
"(",
"root_path",
")",
":",
"m",
"=",
"imp",
".",
"new_module",
"(",
"\"b2\"",
")",
"# Note that:",
"# 1. If __path__ is not list of strings, nothing will work",
"# 2. root_path is already list of strings.",
"m",
".",
"__path__",
"=",
"root_path",
"sys... | Performs python-side bootstrapping of Boost.Build/Python.
This function arranges for 'b2.whatever' package names to work, while also
allowing to put python files alongside corresponding jam modules. | [
"Performs",
"python",
"-",
"side",
"bootstrapping",
"of",
"Boost",
".",
"Build",
"/",
"Python",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/kernel/bootstrap.py#L9-L24 | train |
apple/turicreate | deps/src/boost_1_68_0/libs/metaparse/tools/build_environment.py | main | def main():
"""The main function of the utility"""
parser = argparse.ArgumentParser(
description='Manage the build environment of Boost.Metaparse'
)
parser.add_argument(
'--dep_json',
required=True,
help='The json file describing the dependencies'
)
parser.add_arg... | python | def main():
"""The main function of the utility"""
parser = argparse.ArgumentParser(
description='Manage the build environment of Boost.Metaparse'
)
parser.add_argument(
'--dep_json',
required=True,
help='The json file describing the dependencies'
)
parser.add_arg... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Manage the build environment of Boost.Metaparse'",
")",
"parser",
".",
"add_argument",
"(",
"'--dep_json'",
",",
"required",
"=",
"True",
",",
"help",
"=",
... | The main function of the utility | [
"The",
"main",
"function",
"of",
"the",
"utility"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/libs/metaparse/tools/build_environment.py#L81-L130 | train |
apple/turicreate | src/unity/python/turicreate/data_structures/sarray_builder.py | SArrayBuilder.read_history | def read_history(self, num=10, segment=0):
"""
Outputs the last `num` elements that were appended either by `append` or
`append_multiple`.
Returns
-------
out : list
"""
if num < 0:
num = 0
if segment < 0:
raise TypeError(... | python | def read_history(self, num=10, segment=0):
"""
Outputs the last `num` elements that were appended either by `append` or
`append_multiple`.
Returns
-------
out : list
"""
if num < 0:
num = 0
if segment < 0:
raise TypeError(... | [
"def",
"read_history",
"(",
"self",
",",
"num",
"=",
"10",
",",
"segment",
"=",
"0",
")",
":",
"if",
"num",
"<",
"0",
":",
"num",
"=",
"0",
"if",
"segment",
"<",
"0",
":",
"raise",
"TypeError",
"(",
"\"segment must be >= 0\"",
")",
"return",
"self",
... | Outputs the last `num` elements that were appended either by `append` or
`append_multiple`.
Returns
-------
out : list | [
"Outputs",
"the",
"last",
"num",
"elements",
"that",
"were",
"appended",
"either",
"by",
"append",
"or",
"append_multiple",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/data_structures/sarray_builder.py#L114-L128 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/toolset.py | flags | def flags(rule_or_module, variable_name, condition, values = []):
""" Specifies the flags (variables) that must be set on targets under certain
conditions, described by arguments.
rule_or_module: If contains dot, should be a rule name.
The flags will be applied when that ... | python | def flags(rule_or_module, variable_name, condition, values = []):
""" Specifies the flags (variables) that must be set on targets under certain
conditions, described by arguments.
rule_or_module: If contains dot, should be a rule name.
The flags will be applied when that ... | [
"def",
"flags",
"(",
"rule_or_module",
",",
"variable_name",
",",
"condition",
",",
"values",
"=",
"[",
"]",
")",
":",
"assert",
"isinstance",
"(",
"rule_or_module",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"variable_name",
",",
"basestring",
")",
... | Specifies the flags (variables) that must be set on targets under certain
conditions, described by arguments.
rule_or_module: If contains dot, should be a rule name.
The flags will be applied when that rule is
used to set up build actions.
... | [
"Specifies",
"the",
"flags",
"(",
"variables",
")",
"that",
"must",
"be",
"set",
"on",
"targets",
"under",
"certain",
"conditions",
"described",
"by",
"arguments",
".",
"rule_or_module",
":",
"If",
"contains",
"dot",
"should",
"be",
"a",
"rule",
"name",
".",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/toolset.py#L92-L169 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/toolset.py | find_satisfied_condition | def find_satisfied_condition(conditions, ps):
"""Returns the first element of 'property-sets' which is a subset of
'properties', or an empty list if no such element exists."""
assert is_iterable_typed(conditions, property_set.PropertySet)
assert isinstance(ps, property_set.PropertySet)
for conditio... | python | def find_satisfied_condition(conditions, ps):
"""Returns the first element of 'property-sets' which is a subset of
'properties', or an empty list if no such element exists."""
assert is_iterable_typed(conditions, property_set.PropertySet)
assert isinstance(ps, property_set.PropertySet)
for conditio... | [
"def",
"find_satisfied_condition",
"(",
"conditions",
",",
"ps",
")",
":",
"assert",
"is_iterable_typed",
"(",
"conditions",
",",
"property_set",
".",
"PropertySet",
")",
"assert",
"isinstance",
"(",
"ps",
",",
"property_set",
".",
"PropertySet",
")",
"for",
"co... | Returns the first element of 'property-sets' which is a subset of
'properties', or an empty list if no such element exists. | [
"Returns",
"the",
"first",
"element",
"of",
"property",
"-",
"sets",
"which",
"is",
"a",
"subset",
"of",
"properties",
"or",
"an",
"empty",
"list",
"if",
"no",
"such",
"element",
"exists",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/toolset.py#L184-L216 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/toolset.py | inherit_flags | def inherit_flags(toolset, base, prohibited_properties = []):
"""Brings all flag definitions from the 'base' toolset into the 'toolset'
toolset. Flag definitions whose conditions make use of properties in
'prohibited-properties' are ignored. Don't confuse property and feature, for
example <debug-symbols... | python | def inherit_flags(toolset, base, prohibited_properties = []):
"""Brings all flag definitions from the 'base' toolset into the 'toolset'
toolset. Flag definitions whose conditions make use of properties in
'prohibited-properties' are ignored. Don't confuse property and feature, for
example <debug-symbols... | [
"def",
"inherit_flags",
"(",
"toolset",
",",
"base",
",",
"prohibited_properties",
"=",
"[",
"]",
")",
":",
"assert",
"isinstance",
"(",
"toolset",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"base",
",",
"basestring",
")",
"assert",
"is_iterable_type... | Brings all flag definitions from the 'base' toolset into the 'toolset'
toolset. Flag definitions whose conditions make use of properties in
'prohibited-properties' are ignored. Don't confuse property and feature, for
example <debug-symbols>on and <debug-symbols>off, so blocking one of them does
not bloc... | [
"Brings",
"all",
"flag",
"definitions",
"from",
"the",
"base",
"toolset",
"into",
"the",
"toolset",
"toolset",
".",
"Flag",
"definitions",
"whose",
"conditions",
"make",
"use",
"of",
"properties",
"in",
"prohibited",
"-",
"properties",
"are",
"ignored",
".",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/toolset.py#L251-L280 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/toolset.py | __set_target_variables_aux | def __set_target_variables_aux (manager, rule_or_module, ps):
""" Given a rule name and a property set, returns a list of tuples of
variables names and values, which must be set on targets for that
rule/properties combination.
"""
assert isinstance(rule_or_module, basestring)
assert isin... | python | def __set_target_variables_aux (manager, rule_or_module, ps):
""" Given a rule name and a property set, returns a list of tuples of
variables names and values, which must be set on targets for that
rule/properties combination.
"""
assert isinstance(rule_or_module, basestring)
assert isin... | [
"def",
"__set_target_variables_aux",
"(",
"manager",
",",
"rule_or_module",
",",
"ps",
")",
":",
"assert",
"isinstance",
"(",
"rule_or_module",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"ps",
",",
"property_set",
".",
"PropertySet",
")",
"result",
"="... | Given a rule name and a property set, returns a list of tuples of
variables names and values, which must be set on targets for that
rule/properties combination. | [
"Given",
"a",
"rule",
"name",
"and",
"a",
"property",
"set",
"returns",
"a",
"list",
"of",
"tuples",
"of",
"variables",
"names",
"and",
"values",
"which",
"must",
"be",
"set",
"on",
"targets",
"for",
"that",
"rule",
"/",
"properties",
"combination",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/toolset.py#L301-L329 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/toolset.py | __add_flag | def __add_flag (rule_or_module, variable_name, condition, values):
""" Adds a new flag setting with the specified values.
Does no checking.
"""
assert isinstance(rule_or_module, basestring)
assert isinstance(variable_name, basestring)
assert is_iterable_typed(condition, property_set.Property... | python | def __add_flag (rule_or_module, variable_name, condition, values):
""" Adds a new flag setting with the specified values.
Does no checking.
"""
assert isinstance(rule_or_module, basestring)
assert isinstance(variable_name, basestring)
assert is_iterable_typed(condition, property_set.Property... | [
"def",
"__add_flag",
"(",
"rule_or_module",
",",
"variable_name",
",",
"condition",
",",
"values",
")",
":",
"assert",
"isinstance",
"(",
"rule_or_module",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"variable_name",
",",
"basestring",
")",
"assert",
"i... | Adds a new flag setting with the specified values.
Does no checking. | [
"Adds",
"a",
"new",
"flag",
"setting",
"with",
"the",
"specified",
"values",
".",
"Does",
"no",
"checking",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/toolset.py#L365-L382 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_logistic_regression.py | convert | def convert(model, feature_names, target):
"""Convert a Logistic Regression model to the protobuf spec.
Parameters
----------
model: LogisticRegression
A trained LogisticRegression model.
feature_names: [str], optional (default=None)
Name of the input columns.
target: str, opti... | python | def convert(model, feature_names, target):
"""Convert a Logistic Regression model to the protobuf spec.
Parameters
----------
model: LogisticRegression
A trained LogisticRegression model.
feature_names: [str], optional (default=None)
Name of the input columns.
target: str, opti... | [
"def",
"convert",
"(",
"model",
",",
"feature_names",
",",
"target",
")",
":",
"if",
"not",
"(",
"_HAS_SKLEARN",
")",
":",
"raise",
"RuntimeError",
"(",
"'scikit-learn not found. scikit-learn conversion API is disabled.'",
")",
"_sklearn_util",
".",
"check_expected_type... | Convert a Logistic Regression model to the protobuf spec.
Parameters
----------
model: LogisticRegression
A trained LogisticRegression model.
feature_names: [str], optional (default=None)
Name of the input columns.
target: str, optional (default=None)
Name of the output col... | [
"Convert",
"a",
"Logistic",
"Regression",
"model",
"to",
"the",
"protobuf",
"spec",
".",
"Parameters",
"----------",
"model",
":",
"LogisticRegression",
"A",
"trained",
"LogisticRegression",
"model",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/sklearn/_logistic_regression.py#L21-L45 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/path.py | root | def root (path, root):
""" If 'path' is relative, it is rooted at 'root'. Otherwise, it's unchanged.
"""
if os.path.isabs (path):
return path
else:
return os.path.join (root, path) | python | def root (path, root):
""" If 'path' is relative, it is rooted at 'root'. Otherwise, it's unchanged.
"""
if os.path.isabs (path):
return path
else:
return os.path.join (root, path) | [
"def",
"root",
"(",
"path",
",",
"root",
")",
":",
"if",
"os",
".",
"path",
".",
"isabs",
"(",
"path",
")",
":",
"return",
"path",
"else",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"path",
")"
] | If 'path' is relative, it is rooted at 'root'. Otherwise, it's unchanged. | [
"If",
"path",
"is",
"relative",
"it",
"is",
"rooted",
"at",
"root",
".",
"Otherwise",
"it",
"s",
"unchanged",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/path.py#L28-L34 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/path.py | reverse | def reverse(path):
"""Returns path2 such that `os.path.join(path, path2) == '.'`.
`path` may not contain '..' or be rooted.
Args:
path (str): the path to reverse
Returns:
the string of the reversed path
Example:
>>> p1 = 'path/to/somewhere'
>>> p2 = reverse('path/... | python | def reverse(path):
"""Returns path2 such that `os.path.join(path, path2) == '.'`.
`path` may not contain '..' or be rooted.
Args:
path (str): the path to reverse
Returns:
the string of the reversed path
Example:
>>> p1 = 'path/to/somewhere'
>>> p2 = reverse('path/... | [
"def",
"reverse",
"(",
"path",
")",
":",
"if",
"is_rooted",
"(",
"path",
")",
"or",
"'..'",
"in",
"path",
":",
"from",
"b2",
".",
"manager",
"import",
"get_manager",
"get_manager",
"(",
")",
".",
"errors",
"(",
")",
"(",
"'reverse(path): path is either roo... | Returns path2 such that `os.path.join(path, path2) == '.'`.
`path` may not contain '..' or be rooted.
Args:
path (str): the path to reverse
Returns:
the string of the reversed path
Example:
>>> p1 = 'path/to/somewhere'
>>> p2 = reverse('path/to/somewhere')
>>>... | [
"Returns",
"path2",
"such",
"that",
"os",
".",
"path",
".",
"join",
"(",
"path",
"path2",
")",
"==",
".",
".",
"path",
"may",
"not",
"contain",
"..",
"or",
"be",
"rooted",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/path.py#L197-L225 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/path.py | glob | def glob (dirs, patterns):
""" Returns the list of files matching the given pattern in the
specified directory. Both directories and patterns are
supplied as portable paths. Each pattern should be non-absolute
path, and can't contain "." or ".." elements. Each slash separated
element of pattern can... | python | def glob (dirs, patterns):
""" Returns the list of files matching the given pattern in the
specified directory. Both directories and patterns are
supplied as portable paths. Each pattern should be non-absolute
path, and can't contain "." or ".." elements. Each slash separated
element of pattern can... | [
"def",
"glob",
"(",
"dirs",
",",
"patterns",
")",
":",
"# {",
"# local result ;",
"# if $(patterns:D)",
"# {",
"# # When a pattern has a directory element, we first glob for",
"# # directory, and then glob for file name is the found directories.",
... | Returns the list of files matching the given pattern in the
specified directory. Both directories and patterns are
supplied as portable paths. Each pattern should be non-absolute
path, and can't contain "." or ".." elements. Each slash separated
element of pattern can contain the following special char... | [
"Returns",
"the",
"list",
"of",
"files",
"matching",
"the",
"given",
"pattern",
"in",
"the",
"specified",
"directory",
".",
"Both",
"directories",
"and",
"patterns",
"are",
"supplied",
"as",
"portable",
"paths",
".",
"Each",
"pattern",
"should",
"be",
"non",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/path.py#L260-L338 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/path.py | glob | def glob(dirs, patterns, exclude_patterns=None):
"""Returns the list of files matching the given pattern in the
specified directory. Both directories and patterns are
supplied as portable paths. Each pattern should be non-absolute
path, and can't contain '.' or '..' elements. Each slash separated
e... | python | def glob(dirs, patterns, exclude_patterns=None):
"""Returns the list of files matching the given pattern in the
specified directory. Both directories and patterns are
supplied as portable paths. Each pattern should be non-absolute
path, and can't contain '.' or '..' elements. Each slash separated
e... | [
"def",
"glob",
"(",
"dirs",
",",
"patterns",
",",
"exclude_patterns",
"=",
"None",
")",
":",
"assert",
"(",
"isinstance",
"(",
"patterns",
",",
"list",
")",
")",
"assert",
"(",
"isinstance",
"(",
"dirs",
",",
"list",
")",
")",
"if",
"not",
"exclude_pat... | Returns the list of files matching the given pattern in the
specified directory. Both directories and patterns are
supplied as portable paths. Each pattern should be non-absolute
path, and can't contain '.' or '..' elements. Each slash separated
element of pattern can contain the following special char... | [
"Returns",
"the",
"list",
"of",
"files",
"matching",
"the",
"given",
"pattern",
"in",
"the",
"specified",
"directory",
".",
"Both",
"directories",
"and",
"patterns",
"are",
"supplied",
"as",
"portable",
"paths",
".",
"Each",
"pattern",
"should",
"be",
"non",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/path.py#L839-L870 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/path.py | glob_tree | def glob_tree(roots, patterns, exclude_patterns=None):
"""Recursive version of GLOB. Builds the glob of files while
also searching in the subdirectories of the given roots. An
optional set of exclusion patterns will filter out the
matching entries from the result. The exclusions also apply
to the su... | python | def glob_tree(roots, patterns, exclude_patterns=None):
"""Recursive version of GLOB. Builds the glob of files while
also searching in the subdirectories of the given roots. An
optional set of exclusion patterns will filter out the
matching entries from the result. The exclusions also apply
to the su... | [
"def",
"glob_tree",
"(",
"roots",
",",
"patterns",
",",
"exclude_patterns",
"=",
"None",
")",
":",
"if",
"not",
"exclude_patterns",
":",
"exclude_patterns",
"=",
"[",
"]",
"result",
"=",
"glob",
"(",
"roots",
",",
"patterns",
",",
"exclude_patterns",
")",
... | Recursive version of GLOB. Builds the glob of files while
also searching in the subdirectories of the given roots. An
optional set of exclusion patterns will filter out the
matching entries from the result. The exclusions also apply
to the subdirectory scanning, such that directories that
match the ... | [
"Recursive",
"version",
"of",
"GLOB",
".",
"Builds",
"the",
"glob",
"of",
"files",
"while",
"also",
"searching",
"in",
"the",
"subdirectories",
"of",
"the",
"given",
"roots",
".",
"An",
"optional",
"set",
"of",
"exclusion",
"patterns",
"will",
"filter",
"out... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/path.py#L872-L888 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/util/path.py | glob_in_parents | def glob_in_parents(dir, patterns, upper_limit=None):
"""Recursive version of GLOB which glob sall parent directories
of dir until the first match is found. Returns an empty result if no match
is found"""
assert(isinstance(dir, str))
assert(isinstance(patterns, list))
result = []
absolute... | python | def glob_in_parents(dir, patterns, upper_limit=None):
"""Recursive version of GLOB which glob sall parent directories
of dir until the first match is found. Returns an empty result if no match
is found"""
assert(isinstance(dir, str))
assert(isinstance(patterns, list))
result = []
absolute... | [
"def",
"glob_in_parents",
"(",
"dir",
",",
"patterns",
",",
"upper_limit",
"=",
"None",
")",
":",
"assert",
"(",
"isinstance",
"(",
"dir",
",",
"str",
")",
")",
"assert",
"(",
"isinstance",
"(",
"patterns",
",",
"list",
")",
")",
"result",
"=",
"[",
... | Recursive version of GLOB which glob sall parent directories
of dir until the first match is found. Returns an empty result if no match
is found | [
"Recursive",
"version",
"of",
"GLOB",
"which",
"glob",
"sall",
"parent",
"directories",
"of",
"dir",
"until",
"the",
"first",
"match",
"is",
"found",
".",
"Returns",
"an",
"empty",
"result",
"if",
"no",
"match",
"is",
"found"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/util/path.py#L890-L911 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _wrap_function_return | def _wrap_function_return(val):
"""
Recursively walks each thing in val, opening lists and dictionaries,
converting all occurrences of UnityGraphProxy to an SGraph,
UnitySFrameProxy to SFrame, and UnitySArrayProxy to SArray.
"""
if type(val) is _UnityGraphProxy:
return _SGraph(_proxy = ... | python | def _wrap_function_return(val):
"""
Recursively walks each thing in val, opening lists and dictionaries,
converting all occurrences of UnityGraphProxy to an SGraph,
UnitySFrameProxy to SFrame, and UnitySArrayProxy to SArray.
"""
if type(val) is _UnityGraphProxy:
return _SGraph(_proxy = ... | [
"def",
"_wrap_function_return",
"(",
"val",
")",
":",
"if",
"type",
"(",
"val",
")",
"is",
"_UnityGraphProxy",
":",
"return",
"_SGraph",
"(",
"_proxy",
"=",
"val",
")",
"elif",
"type",
"(",
"val",
")",
"is",
"_UnitySFrameProxy",
":",
"return",
"_SFrame",
... | Recursively walks each thing in val, opening lists and dictionaries,
converting all occurrences of UnityGraphProxy to an SGraph,
UnitySFrameProxy to SFrame, and UnitySArrayProxy to SArray. | [
"Recursively",
"walks",
"each",
"thing",
"in",
"val",
"opening",
"lists",
"and",
"dictionaries",
"converting",
"all",
"occurrences",
"of",
"UnityGraphProxy",
"to",
"an",
"SGraph",
"UnitySFrameProxy",
"to",
"SFrame",
"and",
"UnitySArrayProxy",
"to",
"SArray",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L82-L107 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _setattr_wrapper | def _setattr_wrapper(mod, key, value):
"""
A setattr wrapper call used only by _publish(). This ensures that anything
published into this module is also published into tc.extensions
"""
setattr(mod, key, value)
if mod == _thismodule:
setattr(_sys.modules[__name__], key, value) | python | def _setattr_wrapper(mod, key, value):
"""
A setattr wrapper call used only by _publish(). This ensures that anything
published into this module is also published into tc.extensions
"""
setattr(mod, key, value)
if mod == _thismodule:
setattr(_sys.modules[__name__], key, value) | [
"def",
"_setattr_wrapper",
"(",
"mod",
",",
"key",
",",
"value",
")",
":",
"setattr",
"(",
"mod",
",",
"key",
",",
"value",
")",
"if",
"mod",
"==",
"_thismodule",
":",
"setattr",
"(",
"_sys",
".",
"modules",
"[",
"__name__",
"]",
",",
"key",
",",
"... | A setattr wrapper call used only by _publish(). This ensures that anything
published into this module is also published into tc.extensions | [
"A",
"setattr",
"wrapper",
"call",
"used",
"only",
"by",
"_publish",
"()",
".",
"This",
"ensures",
"that",
"anything",
"published",
"into",
"this",
"module",
"is",
"also",
"published",
"into",
"tc",
".",
"extensions"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L109-L116 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _run_toolkit_function | def _run_toolkit_function(fnname, arguments, args, kwargs):
"""
Dispatches arguments to a toolkit function.
Parameters
----------
fnname : string
The toolkit function to run
arguments : list[string]
The list of all the arguments the function takes.
args : list
The ... | python | def _run_toolkit_function(fnname, arguments, args, kwargs):
"""
Dispatches arguments to a toolkit function.
Parameters
----------
fnname : string
The toolkit function to run
arguments : list[string]
The list of all the arguments the function takes.
args : list
The ... | [
"def",
"_run_toolkit_function",
"(",
"fnname",
",",
"arguments",
",",
"args",
",",
"kwargs",
")",
":",
"# scan for all the arguments in args",
"num_args_got",
"=",
"len",
"(",
"args",
")",
"+",
"len",
"(",
"kwargs",
")",
"num_args_required",
"=",
"len",
"(",
"... | Dispatches arguments to a toolkit function.
Parameters
----------
fnname : string
The toolkit function to run
arguments : list[string]
The list of all the arguments the function takes.
args : list
The arguments that were passed
kwargs : dictionary
The keyword ... | [
"Dispatches",
"arguments",
"to",
"a",
"toolkit",
"function",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L118-L167 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _class_instance_from_name | def _class_instance_from_name(class_name, *arg, **kwarg):
"""
class_name is of the form modA.modB.modC.class module_path splits on "."
and the import_path is then ['modA','modB','modC'] the __import__ call is
really annoying but essentially it reads like:
import class from modA.modB.modC
- The... | python | def _class_instance_from_name(class_name, *arg, **kwarg):
"""
class_name is of the form modA.modB.modC.class module_path splits on "."
and the import_path is then ['modA','modB','modC'] the __import__ call is
really annoying but essentially it reads like:
import class from modA.modB.modC
- The... | [
"def",
"_class_instance_from_name",
"(",
"class_name",
",",
"*",
"arg",
",",
"*",
"*",
"kwarg",
")",
":",
"# we first look in tc.extensions for the class name",
"module_path",
"=",
"class_name",
".",
"split",
"(",
"'.'",
")",
"import_path",
"=",
"module_path",
"[",
... | class_name is of the form modA.modB.modC.class module_path splits on "."
and the import_path is then ['modA','modB','modC'] the __import__ call is
really annoying but essentially it reads like:
import class from modA.modB.modC
- Then the module variable points to modC
- Then you get the class from... | [
"class_name",
"is",
"of",
"the",
"form",
"modA",
".",
"modB",
".",
"modC",
".",
"class",
"module_path",
"splits",
"on",
".",
"and",
"the",
"import_path",
"is",
"then",
"[",
"modA",
"modB",
"modC",
"]",
"the",
"__import__",
"call",
"is",
"really",
"annoyi... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L172-L190 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _create_class_instance | def _create_class_instance(class_name, _proxy):
"""
Look for the class in .extensions in case it has already been
imported (perhaps as a builtin extensions hard compiled into unity_server).
"""
try:
return _class_instance_from_name('turicreate.extensions.' + class_name, _proxy=_proxy)
ex... | python | def _create_class_instance(class_name, _proxy):
"""
Look for the class in .extensions in case it has already been
imported (perhaps as a builtin extensions hard compiled into unity_server).
"""
try:
return _class_instance_from_name('turicreate.extensions.' + class_name, _proxy=_proxy)
ex... | [
"def",
"_create_class_instance",
"(",
"class_name",
",",
"_proxy",
")",
":",
"try",
":",
"return",
"_class_instance_from_name",
"(",
"'turicreate.extensions.'",
"+",
"class_name",
",",
"_proxy",
"=",
"_proxy",
")",
"except",
":",
"pass",
"return",
"_class_instance_f... | Look for the class in .extensions in case it has already been
imported (perhaps as a builtin extensions hard compiled into unity_server). | [
"Look",
"for",
"the",
"class",
"in",
".",
"extensions",
"in",
"case",
"it",
"has",
"already",
"been",
"imported",
"(",
"perhaps",
"as",
"a",
"builtin",
"extensions",
"hard",
"compiled",
"into",
"unity_server",
")",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L192-L201 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _publish | def _publish():
import copy
"""
Publishes all functions and classes registered in unity_server.
The functions and classes will appear in the module turicreate.extensions
"""
unity = _get_unity()
fnlist = unity.list_toolkit_functions()
# Loop through all the functions and inject it into
... | python | def _publish():
import copy
"""
Publishes all functions and classes registered in unity_server.
The functions and classes will appear in the module turicreate.extensions
"""
unity = _get_unity()
fnlist = unity.list_toolkit_functions()
# Loop through all the functions and inject it into
... | [
"def",
"_publish",
"(",
")",
":",
"import",
"copy",
"unity",
"=",
"_get_unity",
"(",
")",
"fnlist",
"=",
"unity",
".",
"list_toolkit_functions",
"(",
")",
"# Loop through all the functions and inject it into",
"# turicreate.extensions.[blah]",
"# Note that [blah] may be som... | Publishes all functions and classes registered in unity_server.
The functions and classes will appear in the module turicreate.extensions | [
"Publishes",
"all",
"functions",
"and",
"classes",
"registered",
"in",
"unity_server",
".",
"The",
"functions",
"and",
"classes",
"will",
"appear",
"in",
"the",
"module",
"turicreate",
".",
"extensions"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L319-L396 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | ext_import | def ext_import(soname, module_subpath=""):
"""
Loads a turicreate toolkit module (a shared library) into the
tc.extensions namespace.
Toolkit module created via SDK can either be directly imported,
e.g. ``import example`` or via this function, e.g. ``turicreate.ext_import("example.so")``.
Use `... | python | def ext_import(soname, module_subpath=""):
"""
Loads a turicreate toolkit module (a shared library) into the
tc.extensions namespace.
Toolkit module created via SDK can either be directly imported,
e.g. ``import example`` or via this function, e.g. ``turicreate.ext_import("example.so")``.
Use `... | [
"def",
"ext_import",
"(",
"soname",
",",
"module_subpath",
"=",
"\"\"",
")",
":",
"unity",
"=",
"_get_unity",
"(",
")",
"import",
"os",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"soname",
")",
":",
"soname",
"=",
"os",
".",
"path",
".",
"abspath",... | Loads a turicreate toolkit module (a shared library) into the
tc.extensions namespace.
Toolkit module created via SDK can either be directly imported,
e.g. ``import example`` or via this function, e.g. ``turicreate.ext_import("example.so")``.
Use ``ext_import`` when you need more namespace control, or ... | [
"Loads",
"a",
"turicreate",
"toolkit",
"module",
"(",
"a",
"shared",
"library",
")",
"into",
"the",
"tc",
".",
"extensions",
"namespace",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L501-L584 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _get_argument_list_from_toolkit_function_name | def _get_argument_list_from_toolkit_function_name(fn):
"""
Given a toolkit function name, return the argument list
"""
unity = _get_unity()
fnprops = unity.describe_toolkit_function(fn)
argnames = fnprops['arguments']
return argnames | python | def _get_argument_list_from_toolkit_function_name(fn):
"""
Given a toolkit function name, return the argument list
"""
unity = _get_unity()
fnprops = unity.describe_toolkit_function(fn)
argnames = fnprops['arguments']
return argnames | [
"def",
"_get_argument_list_from_toolkit_function_name",
"(",
"fn",
")",
":",
"unity",
"=",
"_get_unity",
"(",
")",
"fnprops",
"=",
"unity",
".",
"describe_toolkit_function",
"(",
"fn",
")",
"argnames",
"=",
"fnprops",
"[",
"'arguments'",
"]",
"return",
"argnames"
... | Given a toolkit function name, return the argument list | [
"Given",
"a",
"toolkit",
"function",
"name",
"return",
"the",
"argument",
"list"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L602-L609 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _descend_namespace | def _descend_namespace(caller_globals, name):
"""
Given a globals dictionary, and a name of the form "a.b.c.d", recursively
walk the globals expanding caller_globals['a']['b']['c']['d'] returning
the result. Raises an exception (IndexError) on failure.
"""
names = name.split('.')
cur = call... | python | def _descend_namespace(caller_globals, name):
"""
Given a globals dictionary, and a name of the form "a.b.c.d", recursively
walk the globals expanding caller_globals['a']['b']['c']['d'] returning
the result. Raises an exception (IndexError) on failure.
"""
names = name.split('.')
cur = call... | [
"def",
"_descend_namespace",
"(",
"caller_globals",
",",
"name",
")",
":",
"names",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"cur",
"=",
"caller_globals",
"for",
"i",
"in",
"names",
":",
"if",
"type",
"(",
"cur",
")",
"is",
"dict",
":",
"cur",
"="... | Given a globals dictionary, and a name of the form "a.b.c.d", recursively
walk the globals expanding caller_globals['a']['b']['c']['d'] returning
the result. Raises an exception (IndexError) on failure. | [
"Given",
"a",
"globals",
"dictionary",
"and",
"a",
"name",
"of",
"the",
"form",
"a",
".",
"b",
".",
"c",
".",
"d",
"recursively",
"walk",
"the",
"globals",
"expanding",
"caller_globals",
"[",
"a",
"]",
"[",
"b",
"]",
"[",
"c",
"]",
"[",
"d",
"]",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L639-L652 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _build_native_function_call | def _build_native_function_call(fn):
"""
If fn can be interpreted and handled as a native function: i.e.
fn is one of the extensions, or fn is a simple lambda closure using one of
the extensions.
fn = tc.extensions.add
fn = lambda x: tc.extensions.add(5)
Then, this returns a closure ... | python | def _build_native_function_call(fn):
"""
If fn can be interpreted and handled as a native function: i.e.
fn is one of the extensions, or fn is a simple lambda closure using one of
the extensions.
fn = tc.extensions.add
fn = lambda x: tc.extensions.add(5)
Then, this returns a closure ... | [
"def",
"_build_native_function_call",
"(",
"fn",
")",
":",
"# See if fn is the native function itself",
"native_function_name",
"=",
"_get_toolkit_function_name_from_function",
"(",
"fn",
")",
"if",
"native_function_name",
"!=",
"\"\"",
":",
"# yup!",
"# generate an \"identity\... | If fn can be interpreted and handled as a native function: i.e.
fn is one of the extensions, or fn is a simple lambda closure using one of
the extensions.
fn = tc.extensions.add
fn = lambda x: tc.extensions.add(5)
Then, this returns a closure object, which describes the function call
whi... | [
"If",
"fn",
"can",
"be",
"interpreted",
"and",
"handled",
"as",
"a",
"native",
"function",
":",
"i",
".",
"e",
".",
"fn",
"is",
"one",
"of",
"the",
"extensions",
"or",
"fn",
"is",
"a",
"simple",
"lambda",
"closure",
"using",
"one",
"of",
"the",
"exte... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L654-L734 | train |
apple/turicreate | src/unity/python/turicreate/extensions.py | _ExtMetaPath.find_module | def find_module(self, fullname, submodule_path=None):
"""
We have to see if fullname refers to a module we can import.
Some care is needed here because:
import xxx # tries to load xxx.so from any of the python import paths
import aaa.bbb.xxx # tries to load aaa/bbb/xxx.so from... | python | def find_module(self, fullname, submodule_path=None):
"""
We have to see if fullname refers to a module we can import.
Some care is needed here because:
import xxx # tries to load xxx.so from any of the python import paths
import aaa.bbb.xxx # tries to load aaa/bbb/xxx.so from... | [
"def",
"find_module",
"(",
"self",
",",
"fullname",
",",
"submodule_path",
"=",
"None",
")",
":",
"# first see if we have this particular so has been loaded by",
"# turicreate's extension library before",
"ret",
"=",
"self",
".",
"try_find_module",
"(",
"fullname",
",",
"... | We have to see if fullname refers to a module we can import.
Some care is needed here because:
import xxx # tries to load xxx.so from any of the python import paths
import aaa.bbb.xxx # tries to load aaa/bbb/xxx.so from any of the python import paths | [
"We",
"have",
"to",
"see",
"if",
"fullname",
"refers",
"to",
"a",
"module",
"we",
"can",
"import",
".",
"Some",
"care",
"is",
"needed",
"here",
"because",
":"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/extensions.py#L409-L450 | train |
apple/turicreate | src/unity/python/doc/source/sphinx_turicreate_ext/pycon.py | main | def main():
"""
Print lines of input along with output.
"""
source_lines = (line.rstrip() for line in sys.stdin)
console = InteractiveInterpreter()
console.runsource('import turicreate')
source = ''
try:
while True:
source = source_lines.next()
more = cons... | python | def main():
"""
Print lines of input along with output.
"""
source_lines = (line.rstrip() for line in sys.stdin)
console = InteractiveInterpreter()
console.runsource('import turicreate')
source = ''
try:
while True:
source = source_lines.next()
more = cons... | [
"def",
"main",
"(",
")",
":",
"source_lines",
"=",
"(",
"line",
".",
"rstrip",
"(",
")",
"for",
"line",
"in",
"sys",
".",
"stdin",
")",
"console",
"=",
"InteractiveInterpreter",
"(",
")",
"console",
".",
"runsource",
"(",
"'import turicreate'",
")",
"sou... | Print lines of input along with output. | [
"Print",
"lines",
"of",
"input",
"along",
"with",
"output",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/doc/source/sphinx_turicreate_ext/pycon.py#L10-L30 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/type_checkers.py | GetTypeChecker | def GetTypeChecker(field):
"""Returns a type checker for a message field of the specified types.
Args:
field: FieldDescriptor object for this field.
Returns:
An instance of TypeChecker which can be used to verify the types
of values assigned to a field of the specified type.
"""
if (field.cpp_ty... | python | def GetTypeChecker(field):
"""Returns a type checker for a message field of the specified types.
Args:
field: FieldDescriptor object for this field.
Returns:
An instance of TypeChecker which can be used to verify the types
of values assigned to a field of the specified type.
"""
if (field.cpp_ty... | [
"def",
"GetTypeChecker",
"(",
"field",
")",
":",
"if",
"(",
"field",
".",
"cpp_type",
"==",
"_FieldDescriptor",
".",
"CPPTYPE_STRING",
"and",
"field",
".",
"type",
"==",
"_FieldDescriptor",
".",
"TYPE_STRING",
")",
":",
"return",
"UnicodeValueChecker",
"(",
")... | Returns a type checker for a message field of the specified types.
Args:
field: FieldDescriptor object for this field.
Returns:
An instance of TypeChecker which can be used to verify the types
of values assigned to a field of the specified type. | [
"Returns",
"a",
"type",
"checker",
"for",
"a",
"message",
"field",
"of",
"the",
"specified",
"types",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/type_checkers.py#L65-L84 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/type_checkers.py | TypeChecker.CheckValue | def CheckValue(self, proposed_value):
"""Type check the provided value and return it.
The returned value might have been normalized to another type.
"""
if not isinstance(proposed_value, self._acceptable_types):
message = ('%.1024r has type %s, but expected one of: %s' %
(propose... | python | def CheckValue(self, proposed_value):
"""Type check the provided value and return it.
The returned value might have been normalized to another type.
"""
if not isinstance(proposed_value, self._acceptable_types):
message = ('%.1024r has type %s, but expected one of: %s' %
(propose... | [
"def",
"CheckValue",
"(",
"self",
",",
"proposed_value",
")",
":",
"if",
"not",
"isinstance",
"(",
"proposed_value",
",",
"self",
".",
"_acceptable_types",
")",
":",
"message",
"=",
"(",
"'%.1024r has type %s, but expected one of: %s'",
"%",
"(",
"proposed_value",
... | Type check the provided value and return it.
The returned value might have been normalized to another type. | [
"Type",
"check",
"the",
"provided",
"value",
"and",
"return",
"it",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/internal/type_checkers.py#L101-L110 | train |
apple/turicreate | src/unity/python/turicreate/meta/asttools/visitors/pysourcegen.py | python_source | def python_source(ast, file=sys.stdout):
'''
Generate executable python source code from an ast node.
:param ast: ast node
:param file: file to write output to.
'''
gen = SourceGen()
gen.visit(ast)
gen.dump(file) | python | def python_source(ast, file=sys.stdout):
'''
Generate executable python source code from an ast node.
:param ast: ast node
:param file: file to write output to.
'''
gen = SourceGen()
gen.visit(ast)
gen.dump(file) | [
"def",
"python_source",
"(",
"ast",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"gen",
"=",
"SourceGen",
"(",
")",
"gen",
".",
"visit",
"(",
"ast",
")",
"gen",
".",
"dump",
"(",
"file",
")"
] | Generate executable python source code from an ast node.
:param ast: ast node
:param file: file to write output to. | [
"Generate",
"executable",
"python",
"source",
"code",
"from",
"an",
"ast",
"node",
".",
":",
"param",
"ast",
":",
"ast",
"node",
":",
"param",
"file",
":",
"file",
"to",
"write",
"output",
"to",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/meta/asttools/visitors/pysourcegen.py#L854-L863 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_encoding.py | CEscape | def CEscape(text, as_utf8):
"""Escape a bytes string for use in an ascii protocol buffer.
text.encode('string_escape') does not seem to satisfy our needs as it
encodes unprintable characters using two-digit hex escapes whereas our
C++ unescaping function allows hex escapes to be any length. So,
"\0011".enco... | python | def CEscape(text, as_utf8):
"""Escape a bytes string for use in an ascii protocol buffer.
text.encode('string_escape') does not seem to satisfy our needs as it
encodes unprintable characters using two-digit hex escapes whereas our
C++ unescaping function allows hex escapes to be any length. So,
"\0011".enco... | [
"def",
"CEscape",
"(",
"text",
",",
"as_utf8",
")",
":",
"# PY3 hack: make Ord work for str and bytes:",
"# //platforms/networking/data uses unicode here, hence basestring.",
"Ord",
"=",
"ord",
"if",
"isinstance",
"(",
"text",
",",
"six",
".",
"string_types",
")",
"else",... | Escape a bytes string for use in an ascii protocol buffer.
text.encode('string_escape') does not seem to satisfy our needs as it
encodes unprintable characters using two-digit hex escapes whereas our
C++ unescaping function allows hex escapes to be any length. So,
"\0011".encode('string_escape') ends up being... | [
"Escape",
"a",
"bytes",
"string",
"for",
"use",
"in",
"an",
"ascii",
"protocol",
"buffer",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_encoding.py#L59-L79 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_encoding.py | CUnescape | def CUnescape(text):
"""Unescape a text string with C-style escape sequences to UTF-8 bytes."""
def ReplaceHex(m):
# Only replace the match if the number of leading back slashes is odd. i.e.
# the slash itself is not escaped.
if len(m.group(1)) & 1:
return m.group(1) + 'x0' + m.group(2)
retur... | python | def CUnescape(text):
"""Unescape a text string with C-style escape sequences to UTF-8 bytes."""
def ReplaceHex(m):
# Only replace the match if the number of leading back slashes is odd. i.e.
# the slash itself is not escaped.
if len(m.group(1)) & 1:
return m.group(1) + 'x0' + m.group(2)
retur... | [
"def",
"CUnescape",
"(",
"text",
")",
":",
"def",
"ReplaceHex",
"(",
"m",
")",
":",
"# Only replace the match if the number of leading back slashes is odd. i.e.",
"# the slash itself is not escaped.",
"if",
"len",
"(",
"m",
".",
"group",
"(",
"1",
")",
")",
"&",
"1"... | Unescape a text string with C-style escape sequences to UTF-8 bytes. | [
"Unescape",
"a",
"text",
"string",
"with",
"C",
"-",
"style",
"escape",
"sequences",
"to",
"UTF",
"-",
"8",
"bytes",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/deps/protobuf/python/google/protobuf/text_encoding.py#L87-L107 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | reset | def reset ():
""" Clear the module state. This is mainly for testing purposes.
Note that this must be called _after_ resetting the module 'feature'.
"""
global __prefixes_suffixes, __suffixes_to_types, __types, __rule_names_to_types, __target_suffixes_cache
__register_features ()
# Stores ... | python | def reset ():
""" Clear the module state. This is mainly for testing purposes.
Note that this must be called _after_ resetting the module 'feature'.
"""
global __prefixes_suffixes, __suffixes_to_types, __types, __rule_names_to_types, __target_suffixes_cache
__register_features ()
# Stores ... | [
"def",
"reset",
"(",
")",
":",
"global",
"__prefixes_suffixes",
",",
"__suffixes_to_types",
",",
"__types",
",",
"__rule_names_to_types",
",",
"__target_suffixes_cache",
"__register_features",
"(",
")",
"# Stores suffixes for generated targets.",
"__prefixes_suffixes",
"=",
... | Clear the module state. This is mainly for testing purposes.
Note that this must be called _after_ resetting the module 'feature'. | [
"Clear",
"the",
"module",
"state",
".",
"This",
"is",
"mainly",
"for",
"testing",
"purposes",
".",
"Note",
"that",
"this",
"must",
"be",
"called",
"_after_",
"resetting",
"the",
"module",
"feature",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L32-L54 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | register | def register (type, suffixes = [], base_type = None):
""" Registers a target type, possibly derived from a 'base-type'.
If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
Also, the first element gives the suffix to be used when constructing and object of
't... | python | def register (type, suffixes = [], base_type = None):
""" Registers a target type, possibly derived from a 'base-type'.
If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
Also, the first element gives the suffix to be used when constructing and object of
't... | [
"def",
"register",
"(",
"type",
",",
"suffixes",
"=",
"[",
"]",
",",
"base_type",
"=",
"None",
")",
":",
"# Type names cannot contain hyphens, because when used as",
"# feature-values they will be interpreted as composite features",
"# which need to be decomposed.",
"if",
"__re... | Registers a target type, possibly derived from a 'base-type'.
If 'suffixes' are provided, they list all the suffixes that mean a file is of 'type'.
Also, the first element gives the suffix to be used when constructing and object of
'type'.
type: a string
suffixes: None or a seque... | [
"Registers",
"a",
"target",
"type",
"possibly",
"derived",
"from",
"a",
"base",
"-",
"type",
".",
"If",
"suffixes",
"are",
"provided",
"they",
"list",
"all",
"the",
"suffixes",
"that",
"mean",
"a",
"file",
"is",
"of",
"type",
".",
"Also",
"the",
"first",... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L59-L115 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | register_suffixes | def register_suffixes (suffixes, type):
""" Specifies that targets with suffix from 'suffixes' have the type 'type'.
If a different type is already specified for any of syffixes, issues an error.
"""
assert is_iterable_typed(suffixes, basestring)
assert isinstance(type, basestring)
for s in ... | python | def register_suffixes (suffixes, type):
""" Specifies that targets with suffix from 'suffixes' have the type 'type'.
If a different type is already specified for any of syffixes, issues an error.
"""
assert is_iterable_typed(suffixes, basestring)
assert isinstance(type, basestring)
for s in ... | [
"def",
"register_suffixes",
"(",
"suffixes",
",",
"type",
")",
":",
"assert",
"is_iterable_typed",
"(",
"suffixes",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"for",
"s",
"in",
"suffixes",
":",
"if",
"s",
"in",
"__... | Specifies that targets with suffix from 'suffixes' have the type 'type'.
If a different type is already specified for any of syffixes, issues an error. | [
"Specifies",
"that",
"targets",
"with",
"suffix",
"from",
"suffixes",
"have",
"the",
"type",
"type",
".",
"If",
"a",
"different",
"type",
"is",
"already",
"specified",
"for",
"any",
"of",
"syffixes",
"issues",
"an",
"error",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L123-L135 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | set_scanner | def set_scanner (type, scanner):
""" Sets a scanner class that will be used for this 'type'.
"""
if __debug__:
from .scanner import Scanner
assert isinstance(type, basestring)
assert issubclass(scanner, Scanner)
validate (type)
__types [type]['scanner'] = scanner | python | def set_scanner (type, scanner):
""" Sets a scanner class that will be used for this 'type'.
"""
if __debug__:
from .scanner import Scanner
assert isinstance(type, basestring)
assert issubclass(scanner, Scanner)
validate (type)
__types [type]['scanner'] = scanner | [
"def",
"set_scanner",
"(",
"type",
",",
"scanner",
")",
":",
"if",
"__debug__",
":",
"from",
".",
"scanner",
"import",
"Scanner",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"issubclass",
"(",
"scanner",
",",
"Scanner",
")",
"val... | Sets a scanner class that will be used for this 'type'. | [
"Sets",
"a",
"scanner",
"class",
"that",
"will",
"be",
"used",
"for",
"this",
"type",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L150-L158 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | get_scanner | def get_scanner (type, prop_set):
""" Returns a scanner instance appropriate to 'type' and 'property_set'.
"""
if __debug__:
from .property_set import PropertySet
assert isinstance(type, basestring)
assert isinstance(prop_set, PropertySet)
if registered (type):
scanner_ty... | python | def get_scanner (type, prop_set):
""" Returns a scanner instance appropriate to 'type' and 'property_set'.
"""
if __debug__:
from .property_set import PropertySet
assert isinstance(type, basestring)
assert isinstance(prop_set, PropertySet)
if registered (type):
scanner_ty... | [
"def",
"get_scanner",
"(",
"type",
",",
"prop_set",
")",
":",
"if",
"__debug__",
":",
"from",
".",
"property_set",
"import",
"PropertySet",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"prop_set",
",",
"PropertySet"... | Returns a scanner instance appropriate to 'type' and 'property_set'. | [
"Returns",
"a",
"scanner",
"instance",
"appropriate",
"to",
"type",
"and",
"property_set",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L160-L173 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | all_bases | def all_bases (type):
""" Returns type and all of its bases, in the order of their distance from type.
"""
assert isinstance(type, basestring)
result = []
while type:
result.append (type)
type = __types [type]['base']
return result | python | def all_bases (type):
""" Returns type and all of its bases, in the order of their distance from type.
"""
assert isinstance(type, basestring)
result = []
while type:
result.append (type)
type = __types [type]['base']
return result | [
"def",
"all_bases",
"(",
"type",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"result",
"=",
"[",
"]",
"while",
"type",
":",
"result",
".",
"append",
"(",
"type",
")",
"type",
"=",
"__types",
"[",
"type",
"]",
"[",
"'base'",... | Returns type and all of its bases, in the order of their distance from type. | [
"Returns",
"type",
"and",
"all",
"of",
"its",
"bases",
"in",
"the",
"order",
"of",
"their",
"distance",
"from",
"type",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L181-L190 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | all_derived | def all_derived (type):
""" Returns type and all classes that derive from it, in the order of their distance from type.
"""
assert isinstance(type, basestring)
result = [type]
for d in __types [type]['derived']:
result.extend (all_derived (d))
return result | python | def all_derived (type):
""" Returns type and all classes that derive from it, in the order of their distance from type.
"""
assert isinstance(type, basestring)
result = [type]
for d in __types [type]['derived']:
result.extend (all_derived (d))
return result | [
"def",
"all_derived",
"(",
"type",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"result",
"=",
"[",
"type",
"]",
"for",
"d",
"in",
"__types",
"[",
"type",
"]",
"[",
"'derived'",
"]",
":",
"result",
".",
"extend",
"(",
"all_d... | Returns type and all classes that derive from it, in the order of their distance from type. | [
"Returns",
"type",
"and",
"all",
"classes",
"that",
"derive",
"from",
"it",
"in",
"the",
"order",
"of",
"their",
"distance",
"from",
"type",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L192-L200 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | is_derived | def is_derived (type, base):
""" Returns true if 'type' is 'base' or has 'base' as its direct or indirect base.
"""
assert isinstance(type, basestring)
assert isinstance(base, basestring)
# TODO: this isn't very efficient, especially for bases close to type
if base in all_bases (type):
r... | python | def is_derived (type, base):
""" Returns true if 'type' is 'base' or has 'base' as its direct or indirect base.
"""
assert isinstance(type, basestring)
assert isinstance(base, basestring)
# TODO: this isn't very efficient, especially for bases close to type
if base in all_bases (type):
r... | [
"def",
"is_derived",
"(",
"type",
",",
"base",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"base",
",",
"basestring",
")",
"# TODO: this isn't very efficient, especially for bases close to type",
"if",
"base",
... | Returns true if 'type' is 'base' or has 'base' as its direct or indirect base. | [
"Returns",
"true",
"if",
"type",
"is",
"base",
"or",
"has",
"base",
"as",
"its",
"direct",
"or",
"indirect",
"base",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L202-L211 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | is_subtype | def is_subtype (type, base):
""" Same as is_derived. Should be removed.
"""
assert isinstance(type, basestring)
assert isinstance(base, basestring)
# TODO: remove this method
return is_derived (type, base) | python | def is_subtype (type, base):
""" Same as is_derived. Should be removed.
"""
assert isinstance(type, basestring)
assert isinstance(base, basestring)
# TODO: remove this method
return is_derived (type, base) | [
"def",
"is_subtype",
"(",
"type",
",",
"base",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"base",
",",
"basestring",
")",
"# TODO: remove this method",
"return",
"is_derived",
"(",
"type",
",",
"base",
... | Same as is_derived. Should be removed. | [
"Same",
"as",
"is_derived",
".",
"Should",
"be",
"removed",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L213-L219 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | set_generated_target_suffix | def set_generated_target_suffix (type, properties, suffix):
""" Sets a target suffix that should be used when generating target
of 'type' with the specified properties. Can be called with
empty properties if no suffix for 'type' was specified yet.
This does not automatically specify that fil... | python | def set_generated_target_suffix (type, properties, suffix):
""" Sets a target suffix that should be used when generating target
of 'type' with the specified properties. Can be called with
empty properties if no suffix for 'type' was specified yet.
This does not automatically specify that fil... | [
"def",
"set_generated_target_suffix",
"(",
"type",
",",
"properties",
",",
"suffix",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"is_iterable_typed",
"(",
"properties",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
"su... | Sets a target suffix that should be used when generating target
of 'type' with the specified properties. Can be called with
empty properties if no suffix for 'type' was specified yet.
This does not automatically specify that files 'suffix' have
'type' --- two different types can use the ... | [
"Sets",
"a",
"target",
"suffix",
"that",
"should",
"be",
"used",
"when",
"generating",
"target",
"of",
"type",
"with",
"the",
"specified",
"properties",
".",
"Can",
"be",
"called",
"with",
"empty",
"properties",
"if",
"no",
"suffix",
"for",
"type",
"was",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L222-L238 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | change_generated_target_suffix | def change_generated_target_suffix (type, properties, suffix):
""" Change the suffix previously registered for this type/properties
combination. If suffix is not yet specified, sets it.
"""
assert isinstance(type, basestring)
assert is_iterable_typed(properties, basestring)
assert isinstance... | python | def change_generated_target_suffix (type, properties, suffix):
""" Change the suffix previously registered for this type/properties
combination. If suffix is not yet specified, sets it.
"""
assert isinstance(type, basestring)
assert is_iterable_typed(properties, basestring)
assert isinstance... | [
"def",
"change_generated_target_suffix",
"(",
"type",
",",
"properties",
",",
"suffix",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"is_iterable_typed",
"(",
"properties",
",",
"basestring",
")",
"assert",
"isinstance",
"(",
... | Change the suffix previously registered for this type/properties
combination. If suffix is not yet specified, sets it. | [
"Change",
"the",
"suffix",
"previously",
"registered",
"for",
"this",
"type",
"/",
"properties",
"combination",
".",
"If",
"suffix",
"is",
"not",
"yet",
"specified",
"sets",
"it",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L242-L249 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | generated_target_ps | def generated_target_ps(is_suffix, type, prop_set):
""" Returns suffix that should be used when generating target of 'type',
with the specified properties. If not suffix were specified for
'type', returns suffix for base type, if any.
"""
if __debug__:
from .property_set import Prope... | python | def generated_target_ps(is_suffix, type, prop_set):
""" Returns suffix that should be used when generating target of 'type',
with the specified properties. If not suffix were specified for
'type', returns suffix for base type, if any.
"""
if __debug__:
from .property_set import Prope... | [
"def",
"generated_target_ps",
"(",
"is_suffix",
",",
"type",
",",
"prop_set",
")",
":",
"if",
"__debug__",
":",
"from",
".",
"property_set",
"import",
"PropertySet",
"assert",
"isinstance",
"(",
"is_suffix",
",",
"(",
"int",
",",
"bool",
")",
")",
"assert",
... | Returns suffix that should be used when generating target of 'type',
with the specified properties. If not suffix were specified for
'type', returns suffix for base type, if any. | [
"Returns",
"suffix",
"that",
"should",
"be",
"used",
"when",
"generating",
"target",
"of",
"type",
"with",
"the",
"specified",
"properties",
".",
"If",
"not",
"suffix",
"were",
"specified",
"for",
"type",
"returns",
"suffix",
"for",
"base",
"type",
"if",
"an... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L334-L351 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | type | def type(filename):
""" Returns file type given it's name. If there are several dots in filename,
tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and
"so" will be tried.
"""
assert isinstance(filename, basestring)
while 1:
filename, suffix = os.path.splitext... | python | def type(filename):
""" Returns file type given it's name. If there are several dots in filename,
tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and
"so" will be tried.
"""
assert isinstance(filename, basestring)
while 1:
filename, suffix = os.path.splitext... | [
"def",
"type",
"(",
"filename",
")",
":",
"assert",
"isinstance",
"(",
"filename",
",",
"basestring",
")",
"while",
"1",
":",
"filename",
",",
"suffix",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"if",
"not",
"suffix",
":",
"return"... | Returns file type given it's name. If there are several dots in filename,
tries each suffix. E.g. for name of "file.so.1.2" suffixes "2", "1", and
"so" will be tried. | [
"Returns",
"file",
"type",
"given",
"it",
"s",
"name",
".",
"If",
"there",
"are",
"several",
"dots",
"in",
"filename",
"tries",
"each",
"suffix",
".",
"E",
".",
"g",
".",
"for",
"name",
"of",
"file",
".",
"so",
".",
"1",
".",
"2",
"suffixes",
"2",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L353-L365 | train |
apple/turicreate | deps/src/boost_1_68_0/tools/build/src/build/type.py | register_type | def register_type (type, suffixes, base_type = None, os = []):
""" Register the given type on the specified OSes, or on remaining OSes
if os is not specified. This rule is injected into each of the type
modules for the sake of convenience.
"""
assert isinstance(type, basestring)
assert ... | python | def register_type (type, suffixes, base_type = None, os = []):
""" Register the given type on the specified OSes, or on remaining OSes
if os is not specified. This rule is injected into each of the type
modules for the sake of convenience.
"""
assert isinstance(type, basestring)
assert ... | [
"def",
"register_type",
"(",
"type",
",",
"suffixes",
",",
"base_type",
"=",
"None",
",",
"os",
"=",
"[",
"]",
")",
":",
"assert",
"isinstance",
"(",
"type",
",",
"basestring",
")",
"assert",
"is_iterable_typed",
"(",
"suffixes",
",",
"basestring",
")",
... | Register the given type on the specified OSes, or on remaining OSes
if os is not specified. This rule is injected into each of the type
modules for the sake of convenience. | [
"Register",
"the",
"given",
"type",
"on",
"the",
"specified",
"OSes",
"or",
"on",
"remaining",
"OSes",
"if",
"os",
"is",
"not",
"specified",
".",
"This",
"rule",
"is",
"injected",
"into",
"each",
"of",
"the",
"type",
"modules",
"for",
"the",
"sake",
"of"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/deps/src/boost_1_68_0/tools/build/src/build/type.py#L368-L381 | train |
apple/turicreate | src/unity/python/turicreate/util/_progress_table_printer.py | ProgressTablePrinter.print_row | def print_row(self, **kwargs):
'''
keys of kwargs must be the names passed to __init__(...) as `column_names`
'''
meta_string = '|'
for key in self.column_names:
float_specifier = ''
if isinstance(kwargs[key], float):
float_specifier = '.3f... | python | def print_row(self, **kwargs):
'''
keys of kwargs must be the names passed to __init__(...) as `column_names`
'''
meta_string = '|'
for key in self.column_names:
float_specifier = ''
if isinstance(kwargs[key], float):
float_specifier = '.3f... | [
"def",
"print_row",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"meta_string",
"=",
"'|'",
"for",
"key",
"in",
"self",
".",
"column_names",
":",
"float_specifier",
"=",
"''",
"if",
"isinstance",
"(",
"kwargs",
"[",
"key",
"]",
",",
"float",
")",
... | keys of kwargs must be the names passed to __init__(...) as `column_names` | [
"keys",
"of",
"kwargs",
"must",
"be",
"the",
"names",
"passed",
"to",
"__init__",
"(",
"...",
")",
"as",
"column_names"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/util/_progress_table_printer.py#L27-L40 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/_feature_engineering/_internal_utils.py | process_features | def process_features(features, exclude):
"""
Parameters
----------
features : list[str] | str | None, optional
Column names of features to be transformed. If None, all columns
are selected. If string, that column is transformed. If list of strings,
this list of column names is se... | python | def process_features(features, exclude):
"""
Parameters
----------
features : list[str] | str | None, optional
Column names of features to be transformed. If None, all columns
are selected. If string, that column is transformed. If list of strings,
this list of column names is se... | [
"def",
"process_features",
"(",
"features",
",",
"exclude",
")",
":",
"# Check types",
"_raise_error_if_not_of_type",
"(",
"features",
",",
"[",
"NoneType",
",",
"str",
",",
"list",
"]",
",",
"'features'",
")",
"_raise_error_if_not_of_type",
"(",
"exclude",
",",
... | Parameters
----------
features : list[str] | str | None, optional
Column names of features to be transformed. If None, all columns
are selected. If string, that column is transformed. If list of strings,
this list of column names is selected.
exclude : list[str] | str | None, option... | [
"Parameters",
"----------",
"features",
":",
"list",
"[",
"str",
"]",
"|",
"str",
"|",
"None",
"optional",
"Column",
"names",
"of",
"features",
"to",
"be",
"transformed",
".",
"If",
"None",
"all",
"columns",
"are",
"selected",
".",
"If",
"string",
"that",
... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_feature_engineering/_internal_utils.py#L83-L137 | train |
apple/turicreate | src/unity/python/turicreate/toolkits/_feature_engineering/_internal_utils.py | pretty_print_list | def pretty_print_list(lst, name = 'features', repr_format=True):
""" Pretty print a list to be readable.
"""
if not lst or len(lst) < 8:
if repr_format:
return lst.__repr__()
else:
return ', '.join(map(str, lst))
else:
topk = ', '.join(map(str, lst[:3]))
... | python | def pretty_print_list(lst, name = 'features', repr_format=True):
""" Pretty print a list to be readable.
"""
if not lst or len(lst) < 8:
if repr_format:
return lst.__repr__()
else:
return ', '.join(map(str, lst))
else:
topk = ', '.join(map(str, lst[:3]))
... | [
"def",
"pretty_print_list",
"(",
"lst",
",",
"name",
"=",
"'features'",
",",
"repr_format",
"=",
"True",
")",
":",
"if",
"not",
"lst",
"or",
"len",
"(",
"lst",
")",
"<",
"8",
":",
"if",
"repr_format",
":",
"return",
"lst",
".",
"__repr__",
"(",
")",
... | Pretty print a list to be readable. | [
"Pretty",
"print",
"a",
"list",
"to",
"be",
"readable",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/toolkits/_feature_engineering/_internal_utils.py#L140-L159 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | _get_elementwise_name_from_keras_layer | def _get_elementwise_name_from_keras_layer(keras_layer):
"""
Get the keras layer name from the activation name.
"""
mode = keras_layer.mode
if mode == 'sum':
return 'ADD'
elif mode == 'mul':
return 'MULTIPLY'
elif mode == 'concat':
if len(keras_layer.input_shape[0]) =... | python | def _get_elementwise_name_from_keras_layer(keras_layer):
"""
Get the keras layer name from the activation name.
"""
mode = keras_layer.mode
if mode == 'sum':
return 'ADD'
elif mode == 'mul':
return 'MULTIPLY'
elif mode == 'concat':
if len(keras_layer.input_shape[0]) =... | [
"def",
"_get_elementwise_name_from_keras_layer",
"(",
"keras_layer",
")",
":",
"mode",
"=",
"keras_layer",
".",
"mode",
"if",
"mode",
"==",
"'sum'",
":",
"return",
"'ADD'",
"elif",
"mode",
"==",
"'mul'",
":",
"return",
"'MULTIPLY'",
"elif",
"mode",
"==",
"'con... | Get the keras layer name from the activation name. | [
"Get",
"the",
"keras",
"layer",
"name",
"from",
"the",
"activation",
"name",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L68-L105 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | _same_elements_per_channel | def _same_elements_per_channel(x):
"""
Test if a 3D (H,W,C) matrix x has the same element in each (H,W) matrix for each channel
"""
eps = 1e-5
dims = x.shape
for c in range(dims[-1]):
xc = x[:,:,c].flatten()
if not np.all(np.absolute(xc - xc[0]) < eps):
return False
... | python | def _same_elements_per_channel(x):
"""
Test if a 3D (H,W,C) matrix x has the same element in each (H,W) matrix for each channel
"""
eps = 1e-5
dims = x.shape
for c in range(dims[-1]):
xc = x[:,:,c].flatten()
if not np.all(np.absolute(xc - xc[0]) < eps):
return False
... | [
"def",
"_same_elements_per_channel",
"(",
"x",
")",
":",
"eps",
"=",
"1e-5",
"dims",
"=",
"x",
".",
"shape",
"for",
"c",
"in",
"range",
"(",
"dims",
"[",
"-",
"1",
"]",
")",
":",
"xc",
"=",
"x",
"[",
":",
",",
":",
",",
"c",
"]",
".",
"flatte... | Test if a 3D (H,W,C) matrix x has the same element in each (H,W) matrix for each channel | [
"Test",
"if",
"a",
"3D",
"(",
"H",
"W",
"C",
")",
"matrix",
"x",
"has",
"the",
"same",
"element",
"in",
"each",
"(",
"H",
"W",
")",
"matrix",
"for",
"each",
"channel"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L107-L117 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_dense | def convert_dense(builder, layer, input_names, output_names, keras_layer):
"""Convert a dense layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and output... | python | def convert_dense(builder, layer, input_names, output_names, keras_layer):
"""Convert a dense layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and output... | [
"def",
"convert_dense",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0",
... | Convert a dense layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"dense",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L119-L145 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_activation | def convert_activation(builder, layer, input_names, output_names, keras_layer):
"""Convert an activation layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input... | python | def convert_activation(builder, layer, input_names, output_names, keras_layer):
"""Convert an activation layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input... | [
"def",
"convert_activation",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
... | Convert an activation layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"an",
"activation",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L147-L202 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_padding | def convert_padding(builder, layer, input_names, output_names, keras_layer):
"""Convert padding layer from keras to coreml.
Keras only supports zero padding at this time.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural networ... | python | def convert_padding(builder, layer, input_names, output_names, keras_layer):
"""Convert padding layer from keras to coreml.
Keras only supports zero padding at this time.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural networ... | [
"def",
"convert_padding",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0"... | Convert padding layer from keras to coreml.
Keras only supports zero padding at this time.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"padding",
"layer",
"from",
"keras",
"to",
"coreml",
".",
"Keras",
"only",
"supports",
"zero",
"padding",
"at",
"this",
"time",
".",
"Parameters",
"----------",
"keras_layer",
":",
"layer",
"A",
"keras",
"layer",
"object",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L309-L334 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_cropping | def convert_cropping(builder, layer, input_names, output_names, keras_layer):
"""Convert padding layer from keras to coreml.
Keras only supports zero padding at this time.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural netwo... | python | def convert_cropping(builder, layer, input_names, output_names, keras_layer):
"""Convert padding layer from keras to coreml.
Keras only supports zero padding at this time.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural netwo... | [
"def",
"convert_cropping",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0... | Convert padding layer from keras to coreml.
Keras only supports zero padding at this time.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"padding",
"layer",
"from",
"keras",
"to",
"coreml",
".",
"Keras",
"only",
"supports",
"zero",
"padding",
"at",
"this",
"time",
".",
"Parameters",
"----------",
"keras_layer",
":",
"layer",
"A",
"keras",
"layer",
"object",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L336-L361 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_upsample | def convert_upsample(builder, layer, input_names, output_names, keras_layer):
"""Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and... | python | def convert_upsample(builder, layer, input_names, output_names, keras_layer):
"""Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and... | [
"def",
"convert_upsample",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0... | Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"convolution",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L396-L419 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_convolution | def convert_convolution(builder, layer, input_names, output_names, keras_layer):
"""Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input ... | python | def convert_convolution(builder, layer, input_names, output_names, keras_layer):
"""Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input ... | [
"def",
"convert_convolution",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
... | Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"convolution",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L421-L472 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_convolution1d | def convert_convolution1d(builder, layer, input_names, output_names, keras_layer):
"""Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get inpu... | python | def convert_convolution1d(builder, layer, input_names, output_names, keras_layer):
"""Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get inpu... | [
"def",
"convert_convolution1d",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",... | Convert convolution layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"convolution",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L474-L524 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_lstm | def convert_lstm(builder, layer, input_names, output_names, keras_layer):
"""Convert an LSTM layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
hidden_size = keras_la... | python | def convert_lstm(builder, layer, input_names, output_names, keras_layer):
"""Convert an LSTM layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
hidden_size = keras_la... | [
"def",
"convert_lstm",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"hidden_size",
"=",
"keras_layer",
".",
"output_dim",
"input_size",
"=",
"keras_layer",
".",
"input_shape",
"[",
"-",
"1",
"]",
"if",
... | Convert an LSTM layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"an",
"LSTM",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L526-L599 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_simple_rnn | def convert_simple_rnn(builder, layer, input_names, output_names, keras_layer):
"""Convert an SimpleRNN layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input ... | python | def convert_simple_rnn(builder, layer, input_names, output_names, keras_layer):
"""Convert an SimpleRNN layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input ... | [
"def",
"convert_simple_rnn",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"hidden_size",
"=",
"keras_layer",
".",
"output_dim",
"input_size",
"=",
"keras_layer",
".",
"input_shape"... | Convert an SimpleRNN layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"an",
"SimpleRNN",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L602-L649 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_gru | def convert_gru(builder, layer, input_names, output_names, keras_layer):
"""Convert a GRU layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
hidden_size = keras_layer... | python | def convert_gru(builder, layer, input_names, output_names, keras_layer):
"""Convert a GRU layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
hidden_size = keras_layer... | [
"def",
"convert_gru",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"hidden_size",
"=",
"keras_layer",
".",
"output_dim",
"input_size",
"=",
"keras_layer",
".",
"input_shape",
"[",
"-",
"1",
"]",
"output_a... | Convert a GRU layer from keras to coreml.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"GRU",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L651-L705 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_bidirectional | def convert_bidirectional(builder, layer, input_names, output_names, keras_layer):
"""Convert a bidirectional layer from keras to coreml.
Currently assumes the units are LSTMs.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A ne... | python | def convert_bidirectional(builder, layer, input_names, output_names, keras_layer):
"""Convert a bidirectional layer from keras to coreml.
Currently assumes the units are LSTMs.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A ne... | [
"def",
"convert_bidirectional",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"input_size",
"=",
"keras_layer",
".",
"input_shape",
"[",
"-",
"1",
"]",
"lstm_layer",
"=",
"keras_layer",
".",
"forward_layer",... | Convert a bidirectional layer from keras to coreml.
Currently assumes the units are LSTMs.
Parameters
----------
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"bidirectional",
"layer",
"from",
"keras",
"to",
"coreml",
".",
"Currently",
"assumes",
"the",
"units",
"are",
"LSTMs",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L708-L830 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_batchnorm | def convert_batchnorm(builder, layer, input_names, output_names, keras_layer):
"""
Parameters
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and output names
input_name, output_name = (input_names[0], ... | python | def convert_batchnorm(builder, layer, input_names, output_names, keras_layer):
"""
Parameters
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
# Get input and output names
input_name, output_name = (input_names[0], ... | [
"def",
"convert_batchnorm",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"# Get input and output names",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"... | Parameters
keras_layer: layer
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Parameters",
"keras_layer",
":",
"layer",
"A",
"keras",
"layer",
"object",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L832-L876 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_flatten | def convert_flatten(builder, layer, input_names, output_names, keras_layer):
"""Convert a flatten layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
input_name, output... | python | def convert_flatten(builder, layer, input_names, output_names, keras_layer):
"""Convert a flatten layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
input_name, output... | [
"def",
"convert_flatten",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0",
"]",
")",
"# blob_order ==... | Convert a flatten layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"flatten",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L878-L900 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_softmax | def convert_softmax(builder, layer, input_names, output_names, keras_layer):
"""Convert a softmax layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
input_name, output... | python | def convert_softmax(builder, layer, input_names, output_names, keras_layer):
"""Convert a softmax layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
input_name, output... | [
"def",
"convert_softmax",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0",
"]",
")",
"builder",
"."... | Convert a softmax layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"softmax",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L902-L916 | train |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py | convert_permute | def convert_permute(builder, layer, input_names, output_names, keras_layer):
"""Convert a softmax layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
input_name, output... | python | def convert_permute(builder, layer, input_names, output_names, keras_layer):
"""Convert a softmax layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object.
"""
input_name, output... | [
"def",
"convert_permute",
"(",
"builder",
",",
"layer",
",",
"input_names",
",",
"output_names",
",",
"keras_layer",
")",
":",
"input_name",
",",
"output_name",
"=",
"(",
"input_names",
"[",
"0",
"]",
",",
"output_names",
"[",
"0",
"]",
")",
"keras_dims",
... | Convert a softmax layer from keras to coreml.
Parameters
keras_layer: layer
----------
A keras layer object.
builder: NeuralNetworkBuilder
A neural network builder object. | [
"Convert",
"a",
"softmax",
"layer",
"from",
"keras",
"to",
"coreml",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/converters/keras/_layers.py#L918-L950 | train |
apple/turicreate | src/external/xgboost/subtree/rabit/tracker/rabit_sge.py | sge_submit | def sge_submit(nslave, worker_args, worker_envs):
"""
customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional parameters in input
Parameters
nslave number of slave process to start up
args arg... | python | def sge_submit(nslave, worker_args, worker_envs):
"""
customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional parameters in input
Parameters
nslave number of slave process to start up
args arg... | [
"def",
"sge_submit",
"(",
"nslave",
",",
"worker_args",
",",
"worker_envs",
")",
":",
"env_arg",
"=",
"','",
".",
"join",
"(",
"[",
"'%s=\\\"%s\\\"'",
"%",
"(",
"k",
",",
"str",
"(",
"v",
")",
")",
"for",
"k",
",",
"v",
"in",
"worker_envs",
".",
"i... | customized submit script, that submit nslave jobs, each must contain args as parameter
note this can be a lambda function containing additional parameters in input
Parameters
nslave number of slave process to start up
args arguments to launch each job
this usually includes th... | [
"customized",
"submit",
"script",
"that",
"submit",
"nslave",
"jobs",
"each",
"must",
"contain",
"args",
"as",
"parameter",
"note",
"this",
"can",
"be",
"a",
"lambda",
"function",
"containing",
"additional",
"parameters",
"in",
"input",
"Parameters",
"nslave",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/subtree/rabit/tracker/rabit_sge.py#L47-L67 | train |
apple/turicreate | src/unity/python/turicreate/meta/asttools/visitors/print_visitor.py | dump_ast | def dump_ast(ast, indent=' ', newline='\n'):
'''
Returns a string representing the ast.
:param ast: the ast to print.
:param indent: how far to indent a newline.
:param newline: The newline character.
'''
visitor = ASTPrinter(indent=indent, level=0, newline=newline)
v... | python | def dump_ast(ast, indent=' ', newline='\n'):
'''
Returns a string representing the ast.
:param ast: the ast to print.
:param indent: how far to indent a newline.
:param newline: The newline character.
'''
visitor = ASTPrinter(indent=indent, level=0, newline=newline)
v... | [
"def",
"dump_ast",
"(",
"ast",
",",
"indent",
"=",
"' '",
",",
"newline",
"=",
"'\\n'",
")",
":",
"visitor",
"=",
"ASTPrinter",
"(",
"indent",
"=",
"indent",
",",
"level",
"=",
"0",
",",
"newline",
"=",
"newline",
")",
"visitor",
".",
"visit",
"(",
... | Returns a string representing the ast.
:param ast: the ast to print.
:param indent: how far to indent a newline.
:param newline: The newline character. | [
"Returns",
"a",
"string",
"representing",
"the",
"ast",
".",
":",
"param",
"ast",
":",
"the",
"ast",
"to",
"print",
".",
":",
"param",
"indent",
":",
"how",
"far",
"to",
"indent",
"a",
"newline",
".",
":",
"param",
"newline",
":",
"The",
"newline",
"... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/meta/asttools/visitors/print_visitor.py#L151-L164 | train |
apple/turicreate | src/unity/python/turicreate/meta/asttools/visitors/print_visitor.py | print_ast | def print_ast(ast, indent=' ', initlevel=0, newline='\n', file=sys.stdout):
'''
Pretty print an ast node.
:param ast: the ast to print.
:param indent: how far to indent a newline.
:param initlevel: starting indent level
:param newline: The newline character.
:param file: file object to ... | python | def print_ast(ast, indent=' ', initlevel=0, newline='\n', file=sys.stdout):
'''
Pretty print an ast node.
:param ast: the ast to print.
:param indent: how far to indent a newline.
:param initlevel: starting indent level
:param newline: The newline character.
:param file: file object to ... | [
"def",
"print_ast",
"(",
"ast",
",",
"indent",
"=",
"' '",
",",
"initlevel",
"=",
"0",
",",
"newline",
"=",
"'\\n'",
",",
"file",
"=",
"sys",
".",
"stdout",
")",
":",
"visitor",
"=",
"ASTPrinter",
"(",
"indent",
"=",
"indent",
",",
"level",
"=",
"i... | Pretty print an ast node.
:param ast: the ast to print.
:param indent: how far to indent a newline.
:param initlevel: starting indent level
:param newline: The newline character.
:param file: file object to print to
To print a short ast you may want to use::
node = ast.par... | [
"Pretty",
"print",
"an",
"ast",
"node",
".",
":",
"param",
"ast",
":",
"the",
"ast",
"to",
"print",
".",
":",
"param",
"indent",
":",
"how",
"far",
"to",
"indent",
"a",
"newline",
".",
":",
"param",
"initlevel",
":",
"starting",
"indent",
"level",
":... | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/unity/python/turicreate/meta/asttools/visitors/print_visitor.py#L166-L185 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | ctypes2numpy | def ctypes2numpy(cptr, length, dtype):
"""Convert a ctypes pointer array to a numpy array.
"""
if not isinstance(cptr, ctypes.POINTER(ctypes.c_float)):
raise RuntimeError('expected float pointer')
res = np.zeros(length, dtype=dtype)
if not ctypes.memmove(res.ctypes.data, cptr, length * res.s... | python | def ctypes2numpy(cptr, length, dtype):
"""Convert a ctypes pointer array to a numpy array.
"""
if not isinstance(cptr, ctypes.POINTER(ctypes.c_float)):
raise RuntimeError('expected float pointer')
res = np.zeros(length, dtype=dtype)
if not ctypes.memmove(res.ctypes.data, cptr, length * res.s... | [
"def",
"ctypes2numpy",
"(",
"cptr",
",",
"length",
",",
"dtype",
")",
":",
"if",
"not",
"isinstance",
"(",
"cptr",
",",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_float",
")",
")",
":",
"raise",
"RuntimeError",
"(",
"'expected float pointer'",
")",
... | Convert a ctypes pointer array to a numpy array. | [
"Convert",
"a",
"ctypes",
"pointer",
"array",
"to",
"a",
"numpy",
"array",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L109-L117 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | _maybe_from_pandas | def _maybe_from_pandas(data, feature_names, feature_types):
""" Extract internal data from pd.DataFrame """
try:
import pandas as pd
except ImportError:
return data, feature_names, feature_types
if not isinstance(data, pd.DataFrame):
return data, feature_names, feature_types
... | python | def _maybe_from_pandas(data, feature_names, feature_types):
""" Extract internal data from pd.DataFrame """
try:
import pandas as pd
except ImportError:
return data, feature_names, feature_types
if not isinstance(data, pd.DataFrame):
return data, feature_names, feature_types
... | [
"def",
"_maybe_from_pandas",
"(",
"data",
",",
"feature_names",
",",
"feature_types",
")",
":",
"try",
":",
"import",
"pandas",
"as",
"pd",
"except",
"ImportError",
":",
"return",
"data",
",",
"feature_names",
",",
"feature_types",
"if",
"not",
"isinstance",
"... | Extract internal data from pd.DataFrame | [
"Extract",
"internal",
"data",
"from",
"pd",
".",
"DataFrame"
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L141-L161 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix._init_from_csr | def _init_from_csr(self, csr):
"""
Initialize data from a CSR matrix.
"""
if len(csr.indices) != len(csr.data):
raise ValueError('length mismatch: {} vs {}'.format(len(csr.indices), len(csr.data)))
self.handle = ctypes.c_void_p()
_check_call(_LIB.XGDMatrixCrea... | python | def _init_from_csr(self, csr):
"""
Initialize data from a CSR matrix.
"""
if len(csr.indices) != len(csr.data):
raise ValueError('length mismatch: {} vs {}'.format(len(csr.indices), len(csr.data)))
self.handle = ctypes.c_void_p()
_check_call(_LIB.XGDMatrixCrea... | [
"def",
"_init_from_csr",
"(",
"self",
",",
"csr",
")",
":",
"if",
"len",
"(",
"csr",
".",
"indices",
")",
"!=",
"len",
"(",
"csr",
".",
"data",
")",
":",
"raise",
"ValueError",
"(",
"'length mismatch: {} vs {}'",
".",
"format",
"(",
"len",
"(",
"csr",
... | Initialize data from a CSR matrix. | [
"Initialize",
"data",
"from",
"a",
"CSR",
"matrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L235-L246 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix._init_from_csc | def _init_from_csc(self, csc):
"""
Initialize data from a CSC matrix.
"""
if len(csc.indices) != len(csc.data):
raise ValueError('length mismatch: {} vs {}'.format(len(csc.indices), len(csc.data)))
self.handle = ctypes.c_void_p()
_check_call(_LIB.XGDMatrixCrea... | python | def _init_from_csc(self, csc):
"""
Initialize data from a CSC matrix.
"""
if len(csc.indices) != len(csc.data):
raise ValueError('length mismatch: {} vs {}'.format(len(csc.indices), len(csc.data)))
self.handle = ctypes.c_void_p()
_check_call(_LIB.XGDMatrixCrea... | [
"def",
"_init_from_csc",
"(",
"self",
",",
"csc",
")",
":",
"if",
"len",
"(",
"csc",
".",
"indices",
")",
"!=",
"len",
"(",
"csc",
".",
"data",
")",
":",
"raise",
"ValueError",
"(",
"'length mismatch: {} vs {}'",
".",
"format",
"(",
"len",
"(",
"csc",
... | Initialize data from a CSC matrix. | [
"Initialize",
"data",
"from",
"a",
"CSC",
"matrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L248-L259 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix._init_from_npy2d | def _init_from_npy2d(self, mat, missing):
"""
Initialize data from a 2-D numpy matrix.
"""
if len(mat.shape) != 2:
raise ValueError('Input numpy.ndarray must be 2 dimensional')
data = np.array(mat.reshape(mat.size), dtype=np.float32)
self.handle = ctypes.c_voi... | python | def _init_from_npy2d(self, mat, missing):
"""
Initialize data from a 2-D numpy matrix.
"""
if len(mat.shape) != 2:
raise ValueError('Input numpy.ndarray must be 2 dimensional')
data = np.array(mat.reshape(mat.size), dtype=np.float32)
self.handle = ctypes.c_voi... | [
"def",
"_init_from_npy2d",
"(",
"self",
",",
"mat",
",",
"missing",
")",
":",
"if",
"len",
"(",
"mat",
".",
"shape",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"'Input numpy.ndarray must be 2 dimensional'",
")",
"data",
"=",
"np",
".",
"array",
"(",
... | Initialize data from a 2-D numpy matrix. | [
"Initialize",
"data",
"from",
"a",
"2",
"-",
"D",
"numpy",
"matrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L261-L272 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.get_float_info | def get_float_info(self, field):
"""Get float property from the DMatrix.
Parameters
----------
field: str
The field name of the information
Returns
-------
info : array
a numpy array of float information of the data
"""
le... | python | def get_float_info(self, field):
"""Get float property from the DMatrix.
Parameters
----------
field: str
The field name of the information
Returns
-------
info : array
a numpy array of float information of the data
"""
le... | [
"def",
"get_float_info",
"(",
"self",
",",
"field",
")",
":",
"length",
"=",
"ctypes",
".",
"c_ulong",
"(",
")",
"ret",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_float",
")",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixGetFloatInfo",... | Get float property from the DMatrix.
Parameters
----------
field: str
The field name of the information
Returns
-------
info : array
a numpy array of float information of the data | [
"Get",
"float",
"property",
"from",
"the",
"DMatrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L277-L296 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.get_uint_info | def get_uint_info(self, field):
"""Get unsigned integer property from the DMatrix.
Parameters
----------
field: str
The field name of the information
Returns
-------
info : array
a numpy array of float information of the data
"""
... | python | def get_uint_info(self, field):
"""Get unsigned integer property from the DMatrix.
Parameters
----------
field: str
The field name of the information
Returns
-------
info : array
a numpy array of float information of the data
"""
... | [
"def",
"get_uint_info",
"(",
"self",
",",
"field",
")",
":",
"length",
"=",
"ctypes",
".",
"c_ulong",
"(",
")",
"ret",
"=",
"ctypes",
".",
"POINTER",
"(",
"ctypes",
".",
"c_uint",
")",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixGetUIntInfo",
... | Get unsigned integer property from the DMatrix.
Parameters
----------
field: str
The field name of the information
Returns
-------
info : array
a numpy array of float information of the data | [
"Get",
"unsigned",
"integer",
"property",
"from",
"the",
"DMatrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L298-L317 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.set_float_info | def set_float_info(self, field, data):
"""Set float type property into the DMatrix.
Parameters
----------
field: str
The field name of the information
data: numpy array
The array ofdata to be set
"""
_check_call(_LIB.XGDMatrixSetFloatInfo... | python | def set_float_info(self, field, data):
"""Set float type property into the DMatrix.
Parameters
----------
field: str
The field name of the information
data: numpy array
The array ofdata to be set
"""
_check_call(_LIB.XGDMatrixSetFloatInfo... | [
"def",
"set_float_info",
"(",
"self",
",",
"field",
",",
"data",
")",
":",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixSetFloatInfo",
"(",
"self",
".",
"handle",
",",
"c_str",
"(",
"field",
")",
",",
"c_array",
"(",
"ctypes",
".",
"c_float",
",",
"data",
... | Set float type property into the DMatrix.
Parameters
----------
field: str
The field name of the information
data: numpy array
The array ofdata to be set | [
"Set",
"float",
"type",
"property",
"into",
"the",
"DMatrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L319-L333 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.set_uint_info | def set_uint_info(self, field, data):
"""Set uint type property into the DMatrix.
Parameters
----------
field: str
The field name of the information
data: numpy array
The array ofdata to be set
"""
_check_call(_LIB.XGDMatrixSetUIntInfo(se... | python | def set_uint_info(self, field, data):
"""Set uint type property into the DMatrix.
Parameters
----------
field: str
The field name of the information
data: numpy array
The array ofdata to be set
"""
_check_call(_LIB.XGDMatrixSetUIntInfo(se... | [
"def",
"set_uint_info",
"(",
"self",
",",
"field",
",",
"data",
")",
":",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixSetUIntInfo",
"(",
"self",
".",
"handle",
",",
"c_str",
"(",
"field",
")",
",",
"c_array",
"(",
"ctypes",
".",
"c_uint",
",",
"data",
"... | Set uint type property into the DMatrix.
Parameters
----------
field: str
The field name of the information
data: numpy array
The array ofdata to be set | [
"Set",
"uint",
"type",
"property",
"into",
"the",
"DMatrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L335-L349 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.save_binary | def save_binary(self, fname, silent=True):
"""Save DMatrix to an XGBoost buffer.
Parameters
----------
fname : string
Name of the output buffer file.
silent : bool (optional; default: True)
If set, the output is suppressed.
"""
_check_call... | python | def save_binary(self, fname, silent=True):
"""Save DMatrix to an XGBoost buffer.
Parameters
----------
fname : string
Name of the output buffer file.
silent : bool (optional; default: True)
If set, the output is suppressed.
"""
_check_call... | [
"def",
"save_binary",
"(",
"self",
",",
"fname",
",",
"silent",
"=",
"True",
")",
":",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixSaveBinary",
"(",
"self",
".",
"handle",
",",
"c_str",
"(",
"fname",
")",
",",
"int",
"(",
"silent",
")",
")",
")"
] | Save DMatrix to an XGBoost buffer.
Parameters
----------
fname : string
Name of the output buffer file.
silent : bool (optional; default: True)
If set, the output is suppressed. | [
"Save",
"DMatrix",
"to",
"an",
"XGBoost",
"buffer",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L351-L363 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.num_row | def num_row(self):
"""Get the number of rows in the DMatrix.
Returns
-------
number of rows : int
"""
ret = ctypes.c_ulong()
_check_call(_LIB.XGDMatrixNumRow(self.handle,
ctypes.byref(ret)))
return ret.value | python | def num_row(self):
"""Get the number of rows in the DMatrix.
Returns
-------
number of rows : int
"""
ret = ctypes.c_ulong()
_check_call(_LIB.XGDMatrixNumRow(self.handle,
ctypes.byref(ret)))
return ret.value | [
"def",
"num_row",
"(",
"self",
")",
":",
"ret",
"=",
"ctypes",
".",
"c_ulong",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixNumRow",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"ret",
")",
")",
")",
"return",
"ret",
".",
"... | Get the number of rows in the DMatrix.
Returns
-------
number of rows : int | [
"Get",
"the",
"number",
"of",
"rows",
"in",
"the",
"DMatrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L440-L450 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.num_col | def num_col(self):
"""Get the number of columns (features) in the DMatrix.
Returns
-------
number of columns : int
"""
ret = ctypes.c_uint()
_check_call(_LIB.XGDMatrixNumCol(self.handle,
ctypes.byref(ret)))
return ... | python | def num_col(self):
"""Get the number of columns (features) in the DMatrix.
Returns
-------
number of columns : int
"""
ret = ctypes.c_uint()
_check_call(_LIB.XGDMatrixNumCol(self.handle,
ctypes.byref(ret)))
return ... | [
"def",
"num_col",
"(",
"self",
")",
":",
"ret",
"=",
"ctypes",
".",
"c_uint",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"XGDMatrixNumCol",
"(",
"self",
".",
"handle",
",",
"ctypes",
".",
"byref",
"(",
"ret",
")",
")",
")",
"return",
"ret",
".",
"v... | Get the number of columns (features) in the DMatrix.
Returns
-------
number of columns : int | [
"Get",
"the",
"number",
"of",
"columns",
"(",
"features",
")",
"in",
"the",
"DMatrix",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L452-L462 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.slice | def slice(self, rindex):
"""Slice the DMatrix and return a new DMatrix that only contains `rindex`.
Parameters
----------
rindex : list
List of indices to be selected.
Returns
-------
res : DMatrix
A new DMatrix containing only selected i... | python | def slice(self, rindex):
"""Slice the DMatrix and return a new DMatrix that only contains `rindex`.
Parameters
----------
rindex : list
List of indices to be selected.
Returns
-------
res : DMatrix
A new DMatrix containing only selected i... | [
"def",
"slice",
"(",
"self",
",",
"rindex",
")",
":",
"res",
"=",
"DMatrix",
"(",
"None",
",",
"feature_names",
"=",
"self",
".",
"feature_names",
")",
"res",
".",
"handle",
"=",
"ctypes",
".",
"c_void_p",
"(",
")",
"_check_call",
"(",
"_LIB",
".",
"... | Slice the DMatrix and return a new DMatrix that only contains `rindex`.
Parameters
----------
rindex : list
List of indices to be selected.
Returns
-------
res : DMatrix
A new DMatrix containing only selected indices. | [
"Slice",
"the",
"DMatrix",
"and",
"return",
"a",
"new",
"DMatrix",
"that",
"only",
"contains",
"rindex",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L464-L483 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.feature_names | def feature_names(self, feature_names):
"""Set feature names (column labels).
Parameters
----------
feature_names : list or None
Labels for features. None will reset existing feature names
"""
if not feature_names is None:
# validate feature name
... | python | def feature_names(self, feature_names):
"""Set feature names (column labels).
Parameters
----------
feature_names : list or None
Labels for features. None will reset existing feature names
"""
if not feature_names is None:
# validate feature name
... | [
"def",
"feature_names",
"(",
"self",
",",
"feature_names",
")",
":",
"if",
"not",
"feature_names",
"is",
"None",
":",
"# validate feature name",
"if",
"not",
"isinstance",
"(",
"feature_names",
",",
"list",
")",
":",
"feature_names",
"=",
"list",
"(",
"feature... | Set feature names (column labels).
Parameters
----------
feature_names : list or None
Labels for features. None will reset existing feature names | [
"Set",
"feature",
"names",
"(",
"column",
"labels",
")",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L506-L530 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | DMatrix.feature_types | def feature_types(self, feature_types):
"""Set feature types (column types).
This is for displaying the results and unrelated
to the learning process.
Parameters
----------
feature_types : list or None
Labels for features. None will reset existing feature na... | python | def feature_types(self, feature_types):
"""Set feature types (column types).
This is for displaying the results and unrelated
to the learning process.
Parameters
----------
feature_types : list or None
Labels for features. None will reset existing feature na... | [
"def",
"feature_types",
"(",
"self",
",",
"feature_types",
")",
":",
"if",
"not",
"feature_types",
"is",
"None",
":",
"if",
"self",
".",
"feature_names",
"is",
"None",
":",
"msg",
"=",
"'Unable to set feature types before setting names'",
"raise",
"ValueError",
"(... | Set feature types (column types).
This is for displaying the results and unrelated
to the learning process.
Parameters
----------
feature_types : list or None
Labels for features. None will reset existing feature names | [
"Set",
"feature",
"types",
"(",
"column",
"types",
")",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L533-L565 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | Booster.update | def update(self, dtrain, iteration, fobj=None):
"""
Update for one iteration, with objective function calculated internally.
Parameters
----------
dtrain : DMatrix
Training data.
iteration : int
Current iteration number.
fobj : function
... | python | def update(self, dtrain, iteration, fobj=None):
"""
Update for one iteration, with objective function calculated internally.
Parameters
----------
dtrain : DMatrix
Training data.
iteration : int
Current iteration number.
fobj : function
... | [
"def",
"update",
"(",
"self",
",",
"dtrain",
",",
"iteration",
",",
"fobj",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"dtrain",
",",
"DMatrix",
")",
":",
"raise",
"TypeError",
"(",
"'invalid training matrix: {}'",
".",
"format",
"(",
"type",
... | Update for one iteration, with objective function calculated internally.
Parameters
----------
dtrain : DMatrix
Training data.
iteration : int
Current iteration number.
fobj : function
Customized objective function. | [
"Update",
"for",
"one",
"iteration",
"with",
"objective",
"function",
"calculated",
"internally",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L664-L686 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | Booster.boost | def boost(self, dtrain, grad, hess):
"""
Boost the booster for one iteration, with customized gradient statistics.
Parameters
----------
dtrain : DMatrix
The training DMatrix.
grad : list
The first order of gradient.
hess : list
... | python | def boost(self, dtrain, grad, hess):
"""
Boost the booster for one iteration, with customized gradient statistics.
Parameters
----------
dtrain : DMatrix
The training DMatrix.
grad : list
The first order of gradient.
hess : list
... | [
"def",
"boost",
"(",
"self",
",",
"dtrain",
",",
"grad",
",",
"hess",
")",
":",
"if",
"len",
"(",
"grad",
")",
"!=",
"len",
"(",
"hess",
")",
":",
"raise",
"ValueError",
"(",
"'grad / hess length mismatch: {} / {}'",
".",
"format",
"(",
"len",
"(",
"gr... | Boost the booster for one iteration, with customized gradient statistics.
Parameters
----------
dtrain : DMatrix
The training DMatrix.
grad : list
The first order of gradient.
hess : list
The second order of gradient. | [
"Boost",
"the",
"booster",
"for",
"one",
"iteration",
"with",
"customized",
"gradient",
"statistics",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L688-L710 | train |
apple/turicreate | src/external/xgboost/python-package/xgboost/core.py | Booster.eval_set | def eval_set(self, evals, iteration=0, feval=None):
# pylint: disable=invalid-name
"""Evaluate a set of data.
Parameters
----------
evals : list of tuples (DMatrix, string)
List of items to be evaluated.
iteration : int
Current iteration.
... | python | def eval_set(self, evals, iteration=0, feval=None):
# pylint: disable=invalid-name
"""Evaluate a set of data.
Parameters
----------
evals : list of tuples (DMatrix, string)
List of items to be evaluated.
iteration : int
Current iteration.
... | [
"def",
"eval_set",
"(",
"self",
",",
"evals",
",",
"iteration",
"=",
"0",
",",
"feval",
"=",
"None",
")",
":",
"# pylint: disable=invalid-name",
"if",
"feval",
"is",
"None",
":",
"for",
"d",
"in",
"evals",
":",
"if",
"not",
"isinstance",
"(",
"d",
"[",... | Evaluate a set of data.
Parameters
----------
evals : list of tuples (DMatrix, string)
List of items to be evaluated.
iteration : int
Current iteration.
feval : function
Custom evaluation function.
Returns
-------
res... | [
"Evaluate",
"a",
"set",
"of",
"data",
"."
] | 74514c3f99e25b46f22c6e02977fe3da69221c2e | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/xgboost/python-package/xgboost/core.py#L712-L750 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.