hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
5b1f965490135b8a3462c8b7e157b45a81a5569c
onespacemedia/cms
cms/apps/pages/templatetags/pages.py
[ "BSD-3-Clause" ]
Python
render_navigation
<not_specific>
def render_navigation(context, pages, section=None): ''' Renders a navigation list for the given pages. The pages should all be a subclass of PageBase, and possess a get_absolute_url() method. You can also specify an alias for the navigation, at which point it will be set in the context rather tha...
Renders a navigation list for the given pages. The pages should all be a subclass of PageBase, and possess a get_absolute_url() method. You can also specify an alias for the navigation, at which point it will be set in the context rather than rendered.
Renders a navigation list for the given pages. The pages should all be a subclass of PageBase, and possess a get_absolute_url() method. You can also specify an alias for the navigation, at which point it will be set in the context rather than rendered.
[ "Renders", "a", "navigation", "list", "for", "the", "given", "pages", ".", "The", "pages", "should", "all", "be", "a", "subclass", "of", "PageBase", "and", "possess", "a", "get_absolute_url", "()", "method", ".", "You", "can", "also", "specify", "an", "ali...
def render_navigation(context, pages, section=None): return { 'navigation': _navigation_entries(context, pages, section), }
[ "def", "render_navigation", "(", "context", ",", "pages", ",", "section", "=", "None", ")", ":", "return", "{", "'navigation'", ":", "_navigation_entries", "(", "context", ",", "pages", ",", "section", ")", ",", "}" ]
Renders a navigation list for the given pages.
[ "Renders", "a", "navigation", "list", "for", "the", "given", "pages", "." ]
[ "'''\n Renders a navigation list for the given pages.\n\n The pages should all be a subclass of PageBase, and possess a get_absolute_url() method.\n\n You can also specify an alias for the navigation, at which point it will be set in the\n context rather than rendered.\n '''" ]
[ { "param": "context", "type": null }, { "param": "pages", "type": null }, { "param": "section", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "context", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pages", "type": null, "docstring": null, "docstring_tokens...
b8bf2afde7bbfbbc8577721c8df0d65b01f545b4
onespacemedia/cms
cms/apps/pages/models.py
[ "BSD-3-Clause" ]
Python
children
<not_specific>
def children(self): '''The child pages for this page.''' children = [] page = self.canonical_version if page.right - page.left > 1: # Optimization - don't fetch children # we know aren't there! for child in page.child_set.filter(is_canonical_page=True): ...
The child pages for this page.
The child pages for this page.
[ "The", "child", "pages", "for", "this", "page", "." ]
def children(self): children = [] page = self.canonical_version if page.right - page.left > 1: for child in page.child_set.filter(is_canonical_page=True): child.parent = page children.append(child) return children
[ "def", "children", "(", "self", ")", ":", "children", "=", "[", "]", "page", "=", "self", ".", "canonical_version", "if", "page", ".", "right", "-", "page", ".", "left", ">", "1", ":", "for", "child", "in", "page", ".", "child_set", ".", "filter", ...
The child pages for this page.
[ "The", "child", "pages", "for", "this", "page", "." ]
[ "'''The child pages for this page.'''", "# Optimization - don't fetch children", "# we know aren't there!" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b8bf2afde7bbfbbc8577721c8df0d65b01f545b4
onespacemedia/cms
cms/apps/pages/models.py
[ "BSD-3-Clause" ]
Python
content
<not_specific>
def content(self): '''The associated content model for this page.''' content_cls = ContentType.objects.get_for_id( self.content_type_id).model_class() content = content_cls._default_manager.get(page=self) content.page = self return content
The associated content model for this page.
The associated content model for this page.
[ "The", "associated", "content", "model", "for", "this", "page", "." ]
def content(self): content_cls = ContentType.objects.get_for_id( self.content_type_id).model_class() content = content_cls._default_manager.get(page=self) content.page = self return content
[ "def", "content", "(", "self", ")", ":", "content_cls", "=", "ContentType", ".", "objects", ".", "get_for_id", "(", "self", ".", "content_type_id", ")", ".", "model_class", "(", ")", "content", "=", "content_cls", ".", "_default_manager", ".", "get", "(", ...
The associated content model for this page.
[ "The", "associated", "content", "model", "for", "this", "page", "." ]
[ "'''The associated content model for this page.'''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b8bf2afde7bbfbbc8577721c8df0d65b01f545b4
onespacemedia/cms
cms/apps/pages/models.py
[ "BSD-3-Clause" ]
Python
reverse
<not_specific>
def reverse(self, view_func, args=None, kwargs=None): '''Performs a reverse URL lookup.''' if args is None: args = () if kwargs is None: kwargs = {} urlconf = ContentType.objects.get_for_id( self.content_type_id ).model_class().urlconf ...
Performs a reverse URL lookup.
Performs a reverse URL lookup.
[ "Performs", "a", "reverse", "URL", "lookup", "." ]
def reverse(self, view_func, args=None, kwargs=None): if args is None: args = () if kwargs is None: kwargs = {} urlconf = ContentType.objects.get_for_id( self.content_type_id ).model_class().urlconf return self.get_absolute_url().rstrip('/') + ...
[ "def", "reverse", "(", "self", ",", "view_func", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "if", "args", "is", "None", ":", "args", "=", "(", ")", "if", "kwargs", "is", "None", ":", "kwargs", "=", "{", "}", "urlconf", "=", ...
Performs a reverse URL lookup.
[ "Performs", "a", "reverse", "URL", "lookup", "." ]
[ "'''Performs a reverse URL lookup.'''" ]
[ { "param": "self", "type": null }, { "param": "view_func", "type": null }, { "param": "args", "type": null }, { "param": "kwargs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "view_func", "type": null, "docstring": null, "docstring_token...
b8bf2afde7bbfbbc8577721c8df0d65b01f545b4
onespacemedia/cms
cms/apps/pages/models.py
[ "BSD-3-Clause" ]
Python
_excise_branch
null
def _excise_branch(self): '''Excises this whole branch from the tree.''' branch_width = self._branch_width Page.objects.filter(left__gte=self.left).update( left=F('left') - branch_width, ) Page.objects.filter(right__gte=self.left).update( right=F('right') ...
Excises this whole branch from the tree.
Excises this whole branch from the tree.
[ "Excises", "this", "whole", "branch", "from", "the", "tree", "." ]
def _excise_branch(self): branch_width = self._branch_width Page.objects.filter(left__gte=self.left).update( left=F('left') - branch_width, ) Page.objects.filter(right__gte=self.left).update( right=F('right') - branch_width, )
[ "def", "_excise_branch", "(", "self", ")", ":", "branch_width", "=", "self", ".", "_branch_width", "Page", ".", "objects", ".", "filter", "(", "left__gte", "=", "self", ".", "left", ")", ".", "update", "(", "left", "=", "F", "(", "'left'", ")", "-", ...
Excises this whole branch from the tree.
[ "Excises", "this", "whole", "branch", "from", "the", "tree", "." ]
[ "'''Excises this whole branch from the tree.'''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b8bf2afde7bbfbbc8577721c8df0d65b01f545b4
onespacemedia/cms
cms/apps/pages/models.py
[ "BSD-3-Clause" ]
Python
_insert_branch
null
def _insert_branch(self): '''Inserts this whole branch into the tree.''' branch_width = self._branch_width Page.objects.filter(left__gte=self.left).update( left=F('left') + branch_width, ) Page.objects.filter(right__gte=self.left).update( right=F('right') ...
Inserts this whole branch into the tree.
Inserts this whole branch into the tree.
[ "Inserts", "this", "whole", "branch", "into", "the", "tree", "." ]
def _insert_branch(self): branch_width = self._branch_width Page.objects.filter(left__gte=self.left).update( left=F('left') + branch_width, ) Page.objects.filter(right__gte=self.left).update( right=F('right') + branch_width, )
[ "def", "_insert_branch", "(", "self", ")", ":", "branch_width", "=", "self", ".", "_branch_width", "Page", ".", "objects", ".", "filter", "(", "left__gte", "=", "self", ".", "left", ")", ".", "update", "(", "left", "=", "F", "(", "'left'", ")", "+", ...
Inserts this whole branch into the tree.
[ "Inserts", "this", "whole", "branch", "into", "the", "tree", "." ]
[ "'''Inserts this whole branch into the tree.'''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b8bf2afde7bbfbbc8577721c8df0d65b01f545b4
onespacemedia/cms
cms/apps/pages/models.py
[ "BSD-3-Clause" ]
Python
filter_indexable_pages
<not_specific>
def filter_indexable_pages(queryset): ''' Filters the given queryset of pages to only contain ones that should be indexed by search engines. ''' return queryset.filter( robots_index=True, content_type__in=[ ContentType.objects.get_for_model(content_model) for ...
Filters the given queryset of pages to only contain ones that should be indexed by search engines.
Filters the given queryset of pages to only contain ones that should be indexed by search engines.
[ "Filters", "the", "given", "queryset", "of", "pages", "to", "only", "contain", "ones", "that", "should", "be", "indexed", "by", "search", "engines", "." ]
def filter_indexable_pages(queryset): return queryset.filter( robots_index=True, content_type__in=[ ContentType.objects.get_for_model(content_model) for content_model in get_registered_content() if content_model.robots_index ] )
[ "def", "filter_indexable_pages", "(", "queryset", ")", ":", "return", "queryset", ".", "filter", "(", "robots_index", "=", "True", ",", "content_type__in", "=", "[", "ContentType", ".", "objects", ".", "get_for_model", "(", "content_model", ")", "for", "content_...
Filters the given queryset of pages to only contain ones that should be indexed by search engines.
[ "Filters", "the", "given", "queryset", "of", "pages", "to", "only", "contain", "ones", "that", "should", "be", "indexed", "by", "search", "engines", "." ]
[ "'''\n Filters the given queryset of pages to only contain ones that should be\n indexed by search engines.\n '''" ]
[ { "param": "queryset", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "queryset", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4db633a0d4e27bc2e4d097d367925ee2a89abbc4
onespacemedia/cms
cms/apps/pages/tests/test_admin.py
[ "BSD-3-Clause" ]
Python
_make_page
null
def _make_page(self, title, content_type): ''' Little helper to create a page whose parent is the homepage. ''' content_page = Page.objects.create( title=title, slug=slugify(title), parent=self.homepage, content_type=content_type, ) conten...
Little helper to create a page whose parent is the homepage.
Little helper to create a page whose parent is the homepage.
[ "Little", "helper", "to", "create", "a", "page", "whose", "parent", "is", "the", "homepage", "." ]
def _make_page(self, title, content_type): content_page = Page.objects.create( title=title, slug=slugify(title), parent=self.homepage, content_type=content_type, ) content_type.model_class().objects.create( page=content_page, )
[ "def", "_make_page", "(", "self", ",", "title", ",", "content_type", ")", ":", "content_page", "=", "Page", ".", "objects", ".", "create", "(", "title", "=", "title", ",", "slug", "=", "slugify", "(", "title", ")", ",", "parent", "=", "self", ".", "h...
Little helper to create a page whose parent is the homepage.
[ "Little", "helper", "to", "create", "a", "page", "whose", "parent", "is", "the", "homepage", "." ]
[ "''' Little helper to create a page whose parent is the homepage. '''" ]
[ { "param": "self", "type": null }, { "param": "title", "type": null }, { "param": "content_type", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "title", "type": null, "docstring": null, "docstring_tokens": ...
5f91c0d41c5ed88f7a351aa2a36ee76f437df2c6
nlslzf/Dist_Mask_RCNN_On_Spark_with_Elephas
elephas/ml_model.py
[ "MIT" ]
Python
_fit
<not_specific>
def _fit(self, df): """Private fit method of the Estimator, which trains the model. """ simple_rdd = df_to_simple_rdd(df, categorical=self.get_categorical_labels(), nb_classes=self.get_nb_classes(), features_col=self.getFeaturesCol(), label_col=self.getLabel...
Private fit method of the Estimator, which trains the model.
Private fit method of the Estimator, which trains the model.
[ "Private", "fit", "method", "of", "the", "Estimator", "which", "trains", "the", "model", "." ]
def _fit(self, df): simple_rdd = df_to_simple_rdd(df, categorical=self.get_categorical_labels(), nb_classes=self.get_nb_classes(), features_col=self.getFeaturesCol(), label_col=self.getLabelCol()) simple_rdd = simple_rdd.repartition(self.get_num_workers()) e...
[ "def", "_fit", "(", "self", ",", "df", ")", ":", "simple_rdd", "=", "df_to_simple_rdd", "(", "df", ",", "categorical", "=", "self", ".", "get_categorical_labels", "(", ")", ",", "nb_classes", "=", "self", ".", "get_nb_classes", "(", ")", ",", "features_col...
Private fit method of the Estimator, which trains the model.
[ "Private", "fit", "method", "of", "the", "Estimator", "which", "trains", "the", "model", "." ]
[ "\"\"\"Private fit method of the Estimator, which trains the model.\n \"\"\"", "# TODO: Set default value" ]
[ { "param": "self", "type": null }, { "param": "df", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
5f91c0d41c5ed88f7a351aa2a36ee76f437df2c6
nlslzf/Dist_Mask_RCNN_On_Spark_with_Elephas
elephas/ml_model.py
[ "MIT" ]
Python
_transform
<not_specific>
def _transform(self, df): """Private transform method of a Transformer. This serves as batch-prediction method for our purposes. """ output_col = self.getOutputCol() label_col = self.getLabelCol() new_schema = copy.deepcopy(df.schema) new_schema.add(StructField(output_col...
Private transform method of a Transformer. This serves as batch-prediction method for our purposes.
Private transform method of a Transformer. This serves as batch-prediction method for our purposes.
[ "Private", "transform", "method", "of", "a", "Transformer", ".", "This", "serves", "as", "batch", "-", "prediction", "method", "for", "our", "purposes", "." ]
def _transform(self, df): output_col = self.getOutputCol() label_col = self.getLabelCol() new_schema = copy.deepcopy(df.schema) new_schema.add(StructField(output_col, StringType(), True)) rdd = df.rdd.coalesce(1) features = np.asarray( rdd.map(lambda x: from_v...
[ "def", "_transform", "(", "self", ",", "df", ")", ":", "output_col", "=", "self", ".", "getOutputCol", "(", ")", "label_col", "=", "self", ".", "getLabelCol", "(", ")", "new_schema", "=", "copy", ".", "deepcopy", "(", "df", ".", "schema", ")", "new_sch...
Private transform method of a Transformer.
[ "Private", "transform", "method", "of", "a", "Transformer", "." ]
[ "\"\"\"Private transform method of a Transformer. This serves as batch-prediction method for our purposes.\n \"\"\"", "# Note that we collect, since executing this on the rdd would require model serialization once again", "# TODO: Zipping like this is very likely wrong", "# results_rdd = rdd.zip(predic...
[ { "param": "self", "type": null }, { "param": "df", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "df", "type": null, "docstring": null, "docstring_tokens": [],...
7bf3d87ebf79e2c02ab81da009e5de4c8a793bc2
nlslzf/Dist_Mask_RCNN_On_Spark_with_Elephas
elephas/worker.py
[ "MIT" ]
Python
train
null
def train(self, data_iterator): """Train a keras model on a worker """ optimizer = get_optimizer(self.master_optimizer) self.model = model_from_yaml(self.yaml, self.custom_objects) self.model.compile(optimizer=optimizer, loss=self.master_loss, metrics=s...
Train a keras model on a worker
Train a keras model on a worker
[ "Train", "a", "keras", "model", "on", "a", "worker" ]
def train(self, data_iterator): optimizer = get_optimizer(self.master_optimizer) self.model = model_from_yaml(self.yaml, self.custom_objects) self.model.compile(optimizer=optimizer, loss=self.master_loss, metrics=self.master_metrics) self.model.set_weights(self...
[ "def", "train", "(", "self", ",", "data_iterator", ")", ":", "optimizer", "=", "get_optimizer", "(", "self", ".", "master_optimizer", ")", "self", ".", "model", "=", "model_from_yaml", "(", "self", ".", "yaml", ",", "self", ".", "custom_objects", ")", "sel...
Train a keras model on a worker
[ "Train", "a", "keras", "model", "on", "a", "worker" ]
[ "\"\"\"Train a keras model on a worker\n \"\"\"", "# self.model.compile(optimizer=self.master_optimizer,", "# loss=self.master_loss, metrics=self.master_metrics)" ]
[ { "param": "self", "type": null }, { "param": "data_iterator", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data_iterator", "type": null, "docstring": null, "docstring_t...
7bf3d87ebf79e2c02ab81da009e5de4c8a793bc2
nlslzf/Dist_Mask_RCNN_On_Spark_with_Elephas
elephas/worker.py
[ "MIT" ]
Python
train
<not_specific>
def train(self, data_iterator): """Train a keras model on a worker and send asynchronous updates to parameter server """ feature_iterator, label_iterator = tee(data_iterator, 2) x_train = np.asarray([x for x, y in feature_iterator]) y_train = np.asarray([y for x, y in lab...
Train a keras model on a worker and send asynchronous updates to parameter server
Train a keras model on a worker and send asynchronous updates to parameter server
[ "Train", "a", "keras", "model", "on", "a", "worker", "and", "send", "asynchronous", "updates", "to", "parameter", "server" ]
def train(self, data_iterator): feature_iterator, label_iterator = tee(data_iterator, 2) x_train = np.asarray([x for x, y in feature_iterator]) y_train = np.asarray([y for x, y in label_iterator]) if x_train.size == 0: return optimizer = get_optimizer(self.master_opti...
[ "def", "train", "(", "self", ",", "data_iterator", ")", ":", "feature_iterator", ",", "label_iterator", "=", "tee", "(", "data_iterator", ",", "2", ")", "x_train", "=", "np", ".", "asarray", "(", "[", "x", "for", "x", ",", "y", "in", "feature_iterator", ...
Train a keras model on a worker and send asynchronous updates to parameter server
[ "Train", "a", "keras", "model", "on", "a", "worker", "and", "send", "asynchronous", "updates", "to", "parameter", "server" ]
[ "\"\"\"Train a keras model on a worker and send asynchronous updates\n to parameter server\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "data_iterator", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data_iterator", "type": null, "docstring": null, "docstring_t...
a938d4bc5dd6e0c18fcb4877c371fa8b934ba1d3
nlslzf/Dist_Mask_RCNN_On_Spark_with_Elephas
elephas/optimizers.py
[ "MIT" ]
Python
deserialize
<not_specific>
def deserialize(config, custom_objects=None): """Inverse of the `serialize` function. # Arguments config: Optimizer configuration dictionary. custom_objects: Optional dictionary mapping names (strings) to custom objects (classes and functions) to be considered...
Inverse of the `serialize` function. # Arguments config: Optimizer configuration dictionary. custom_objects: Optional dictionary mapping names (strings) to custom objects (classes and functions) to be considered during deserialization. # Returns A Kera...
Inverse of the `serialize` function. Arguments config: Optimizer configuration dictionary. custom_objects: Optional dictionary mapping names (strings) to custom objects (classes and functions) to be considered during deserialization. Returns A Keras Optimizer instance.
[ "Inverse", "of", "the", "`", "serialize", "`", "function", ".", "Arguments", "config", ":", "Optimizer", "configuration", "dictionary", ".", "custom_objects", ":", "Optional", "dictionary", "mapping", "names", "(", "strings", ")", "to", "custom", "objects", "(",...
def deserialize(config, custom_objects=None): all_classes = { 'sgd': SGD, 'rmsprop': RMSprop, 'adagrad': Adagrad, 'adadelta': Adadelta, 'adam': Adam } if config['class_name'].lower() in all_classes: config['class_name'] = config['class_name'].lower() retur...
[ "def", "deserialize", "(", "config", ",", "custom_objects", "=", "None", ")", ":", "all_classes", "=", "{", "'sgd'", ":", "SGD", ",", "'rmsprop'", ":", "RMSprop", ",", "'adagrad'", ":", "Adagrad", ",", "'adadelta'", ":", "Adadelta", ",", "'adam'", ":", "...
Inverse of the `serialize` function.
[ "Inverse", "of", "the", "`", "serialize", "`", "function", "." ]
[ "\"\"\"Inverse of the `serialize` function.\n # Arguments\n config: Optimizer configuration dictionary.\n custom_objects: Optional dictionary mapping\n names (strings) to custom objects\n (classes and functions)\n to be considered during deserialization.\n # Retu...
[ { "param": "config", "type": null }, { "param": "custom_objects", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "config", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "custom_objects", "type": null, "docstring": null, "docstrin...
d057444e2190483d736aef3c847113adfe84e421
boweeb/querv
querv/querv.py
[ "0BSD" ]
Python
main
null
def main(): """Main entry point for the querv CLI. """ args = docopt(__doc__, version=version("querv")) # print(args) prop_dict = { "subnets": "SubnetId", "images": "ImageId", "keys": "KeyName", "types": "InstanceType", "VPCs": "VpcId", } query_input ...
Main entry point for the querv CLI.
Main entry point for the querv CLI.
[ "Main", "entry", "point", "for", "the", "querv", "CLI", "." ]
def main(): args = docopt(__doc__, version=version("querv")) prop_dict = { "subnets": "SubnetId", "images": "ImageId", "keys": "KeyName", "types": "InstanceType", "VPCs": "VpcId", } query_input = get_option("property", args) query = prop_dict[query_input] ...
[ "def", "main", "(", ")", ":", "args", "=", "docopt", "(", "__doc__", ",", "version", "=", "version", "(", "\"querv\"", ")", ")", "prop_dict", "=", "{", "\"subnets\"", ":", "\"SubnetId\"", ",", "\"images\"", ":", "\"ImageId\"", ",", "\"keys\"", ":", "\"Ke...
Main entry point for the querv CLI.
[ "Main", "entry", "point", "for", "the", "querv", "CLI", "." ]
[ "\"\"\"Main entry point for the querv CLI.\n \"\"\"", "# print(args)" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f806bf105e49f366cd155a79d27ed56aa2272677
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch-serverless/aws/pytorch/prediction.py
[ "MIT" ]
Python
load_model
<not_specific>
def load_model(): """Loads the PyTorch model and the classes into memory from a tar.gz file on S3.""" tmp_dir = '/tmp/pytorch-serverless' local_model = f'{tmp_dir}/model.tar.gz' os.makedirs(tmp_dir, exist_ok=True) logger.info(f'Loading {MODEL} from S3 bucket {S3_BUCKET} to {local_model}') s3.do...
Loads the PyTorch model and the classes into memory from a tar.gz file on S3.
Loads the PyTorch model and the classes into memory from a tar.gz file on S3.
[ "Loads", "the", "PyTorch", "model", "and", "the", "classes", "into", "memory", "from", "a", "tar", ".", "gz", "file", "on", "S3", "." ]
def load_model(): tmp_dir = '/tmp/pytorch-serverless' local_model = f'{tmp_dir}/model.tar.gz' os.makedirs(tmp_dir, exist_ok=True) logger.info(f'Loading {MODEL} from S3 bucket {S3_BUCKET} to {local_model}') s3.download_file(S3_BUCKET, MODEL, local_model) tarfile.open(local_model).extractall(tmp_d...
[ "def", "load_model", "(", ")", ":", "tmp_dir", "=", "'/tmp/pytorch-serverless'", "local_model", "=", "f'{tmp_dir}/model.tar.gz'", "os", ".", "makedirs", "(", "tmp_dir", ",", "exist_ok", "=", "True", ")", "logger", ".", "info", "(", "f'Loading {MODEL} from S3 bucket ...
Loads the PyTorch model and the classes into memory from a tar.gz file on S3.
[ "Loads", "the", "PyTorch", "model", "and", "the", "classes", "into", "memory", "from", "a", "tar", ".", "gz", "file", "on", "S3", "." ]
[ "\"\"\"Loads the PyTorch model and the classes into memory from a tar.gz file on S3.\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f806bf105e49f366cd155a79d27ed56aa2272677
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch-serverless/aws/pytorch/prediction.py
[ "MIT" ]
Python
predict
<not_specific>
def predict(model, classes, image_tensor): """Predicts the class of an image_tensor.""" start_time = time.time() predict_values = model(image_tensor) logger.info("Inference time: {} seconds".format(time.time() - start_time)) softmaxed = F.softmax(predict_values, dim=1) probability_tensor, index...
Predicts the class of an image_tensor.
Predicts the class of an image_tensor.
[ "Predicts", "the", "class", "of", "an", "image_tensor", "." ]
def predict(model, classes, image_tensor): start_time = time.time() predict_values = model(image_tensor) logger.info("Inference time: {} seconds".format(time.time() - start_time)) softmaxed = F.softmax(predict_values, dim=1) probability_tensor, index = torch.max(softmaxed, dim=1) prediction = cl...
[ "def", "predict", "(", "model", ",", "classes", ",", "image_tensor", ")", ":", "start_time", "=", "time", ".", "time", "(", ")", "predict_values", "=", "model", "(", "image_tensor", ")", "logger", ".", "info", "(", "\"Inference time: {} seconds\"", ".", "for...
Predicts the class of an image_tensor.
[ "Predicts", "the", "class", "of", "an", "image_tensor", "." ]
[ "\"\"\"Predicts the class of an image_tensor.\"\"\"" ]
[ { "param": "model", "type": null }, { "param": "classes", "type": null }, { "param": "image_tensor", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "classes", "type": null, "docstring": null, "docstring_tokens...
f806bf105e49f366cd155a79d27ed56aa2272677
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch-serverless/aws/pytorch/prediction.py
[ "MIT" ]
Python
image_to_tensor
<not_specific>
def image_to_tensor(preprocess_pipeline, body): """Transforms the posted image to a PyTorch Tensor.""" data = json.loads(body) name = data['name'] image = data['file'] dec = base64.b64decode(image) img = PIL.Image.open(io.BytesIO(dec)) img_tensor = preprocess_pipeline(img) img_tenso...
Transforms the posted image to a PyTorch Tensor.
Transforms the posted image to a PyTorch Tensor.
[ "Transforms", "the", "posted", "image", "to", "a", "PyTorch", "Tensor", "." ]
def image_to_tensor(preprocess_pipeline, body): data = json.loads(body) name = data['name'] image = data['file'] dec = base64.b64decode(image) img = PIL.Image.open(io.BytesIO(dec)) img_tensor = preprocess_pipeline(img) img_tensor = img_tensor.unsqueeze(0) return img_tensor
[ "def", "image_to_tensor", "(", "preprocess_pipeline", ",", "body", ")", ":", "data", "=", "json", ".", "loads", "(", "body", ")", "name", "=", "data", "[", "'name'", "]", "image", "=", "data", "[", "'file'", "]", "dec", "=", "base64", ".", "b64decode",...
Transforms the posted image to a PyTorch Tensor.
[ "Transforms", "the", "posted", "image", "to", "a", "PyTorch", "Tensor", "." ]
[ "\"\"\"Transforms the posted image to a PyTorch Tensor.\"\"\"", "# 3d to 4d for batch" ]
[ { "param": "preprocess_pipeline", "type": null }, { "param": "body", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "preprocess_pipeline", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "body", "type": null, "docstring": null, "docst...
f806bf105e49f366cd155a79d27ed56aa2272677
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch-serverless/aws/pytorch/prediction.py
[ "MIT" ]
Python
lambda_handler
<not_specific>
def lambda_handler(event, context): """The main function which is called in the lambda function as defined in our template.yml""" image_tensor = image_to_tensor(preprocess_pipeline, event['body']) response = predict(model, classes, image_tensor) return { "statusCode": 200, "body": json....
The main function which is called in the lambda function as defined in our template.yml
The main function which is called in the lambda function as defined in our template.yml
[ "The", "main", "function", "which", "is", "called", "in", "the", "lambda", "function", "as", "defined", "in", "our", "template", ".", "yml" ]
def lambda_handler(event, context): image_tensor = image_to_tensor(preprocess_pipeline, event['body']) response = predict(model, classes, image_tensor) return { "statusCode": 200, "body": json.dumps(response) }
[ "def", "lambda_handler", "(", "event", ",", "context", ")", ":", "image_tensor", "=", "image_to_tensor", "(", "preprocess_pipeline", ",", "event", "[", "'body'", "]", ")", "response", "=", "predict", "(", "model", ",", "classes", ",", "image_tensor", ")", "r...
The main function which is called in the lambda function as defined in our template.yml
[ "The", "main", "function", "which", "is", "called", "in", "the", "lambda", "function", "as", "defined", "in", "our", "template", ".", "yml" ]
[ "\"\"\"The main function which is called in the lambda function as defined in our template.yml\"\"\"" ]
[ { "param": "event", "type": null }, { "param": "context", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "event", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "context", "type": null, "docstring": null, "docstring_tokens...
9b961c1ca8c1ed1bc37c2a8321eabd1ad55f56e1
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/autograd/__init__.py
[ "MIT" ]
Python
backward
null
def backward(tensors, grad_tensors=None, retain_graph=None, create_graph=False, grad_variables=None): r"""Computes the sum of gradients of given tensors w.r.t. graph leaves. The graph is differentiated using the chain rule. If any of ``tensors`` are non-scalar (i.e. their data has more than one element) an...
r"""Computes the sum of gradients of given tensors w.r.t. graph leaves. The graph is differentiated using the chain rule. If any of ``tensors`` are non-scalar (i.e. their data has more than one element) and require gradient, the function additionally requires specifying ``grad_tensors``. It should be a...
r"""Computes the sum of gradients of given tensors w.r.t. graph leaves. The graph is differentiated using the chain rule. This function accumulates gradients in the leaves - you might need to zero them before calling it.
[ "r", "\"", "\"", "\"", "Computes", "the", "sum", "of", "gradients", "of", "given", "tensors", "w", ".", "r", ".", "t", ".", "graph", "leaves", ".", "The", "graph", "is", "differentiated", "using", "the", "chain", "rule", ".", "This", "function", "accum...
def backward(tensors, grad_tensors=None, retain_graph=None, create_graph=False, grad_variables=None): if grad_variables is not None: warnings.warn("'grad_variables' is deprecated. Use 'grad_tensors' instead.") if grad_tensors is None: grad_tensors = grad_variables else: ...
[ "def", "backward", "(", "tensors", ",", "grad_tensors", "=", "None", ",", "retain_graph", "=", "None", ",", "create_graph", "=", "False", ",", "grad_variables", "=", "None", ")", ":", "if", "grad_variables", "is", "not", "None", ":", "warnings", ".", "warn...
r"""Computes the sum of gradients of given tensors w.r.t.
[ "r", "\"", "\"", "\"", "Computes", "the", "sum", "of", "gradients", "of", "given", "tensors", "w", ".", "r", ".", "t", "." ]
[ "r\"\"\"Computes the sum of gradients of given tensors w.r.t. graph leaves.\n\n The graph is differentiated using the chain rule. If any of ``tensors``\n are non-scalar (i.e. their data has more than one element) and require\n gradient, the function additionally requires specifying ``grad_tensors``.\n I...
[ { "param": "tensors", "type": null }, { "param": "grad_tensors", "type": null }, { "param": "retain_graph", "type": null }, { "param": "create_graph", "type": null }, { "param": "grad_variables", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tensors", "type": null, "docstring": "Tensors of which the derivative will be\ncomputed.", "docstring_tokens": [ "Tensors", "of", "which", "the", "derivative", "will", "b...
6c9bebbd97d8ed88318e8e6cae62a3412bd21153
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/caffe2/python/onnx/onnxifi.py
[ "MIT" ]
Python
onnxifi_caffe2_net
<not_specific>
def onnxifi_caffe2_net( pred_net, input_shapes, infer_shapes=False, debug=False): """ Transform the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops """ # Inject an fake input tensor to help popluate the shape if we # do not do shape inference s...
Transform the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
Transform the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
[ "Transform", "the", "caffe2_net", "by", "collapsing", "ONNXIFI", "-", "runnable", "nodes", "into", "Onnxifi", "c2", "ops" ]
def onnxifi_caffe2_net( pred_net, input_shapes, infer_shapes=False, debug=False): shape_hints = {} external_inputs = [] if not infer_shapes: for k, v in input_shapes.items(): need_input_tensor = True if workspace.HasBlob(k): ite...
[ "def", "onnxifi_caffe2_net", "(", "pred_net", ",", "input_shapes", ",", "infer_shapes", "=", "False", ",", "debug", "=", "False", ")", ":", "shape_hints", "=", "{", "}", "external_inputs", "=", "[", "]", "if", "not", "infer_shapes", ":", "for", "k", ",", ...
Transform the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops
[ "Transform", "the", "caffe2_net", "by", "collapsing", "ONNXIFI", "-", "runnable", "nodes", "into", "Onnxifi", "c2", "ops" ]
[ "\"\"\"\n Transform the caffe2_net by collapsing ONNXIFI-runnable nodes into Onnxifi c2 ops\n \"\"\"", "# Inject an fake input tensor to help popluate the shape if we", "# do not do shape inference" ]
[ { "param": "pred_net", "type": null }, { "param": "input_shapes", "type": null }, { "param": "infer_shapes", "type": null }, { "param": "debug", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "pred_net", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "input_shapes", "type": null, "docstring": null, "docstrin...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
einsum
<not_specific>
def einsum(equation, *operands): r"""einsum(equation, *operands) -> Tensor This function provides a way of computing multilinear expressions (i.e. sums of products) using the Einstein summation convention. Args: equation (string): The equation is given in terms of lower case letters (indices) to be associated...
r"""einsum(equation, *operands) -> Tensor This function provides a way of computing multilinear expressions (i.e. sums of products) using the Einstein summation convention. Args: equation (string): The equation is given in terms of lower case letters (indices) to be associated with each dimension of th...
r"""einsum(equation, *operands) -> Tensor This function provides a way of computing multilinear expressions using the Einstein summation convention.
[ "r", "\"", "\"", "\"", "einsum", "(", "equation", "*", "operands", ")", "-", ">", "Tensor", "This", "function", "provides", "a", "way", "of", "computing", "multilinear", "expressions", "using", "the", "Einstein", "summation", "convention", "." ]
def einsum(equation, *operands): if len(operands) == 1 and isinstance(operands[0], (list, tuple)): operands = operands[0] return torch._C._VariableFunctions.einsum(equation, operands)
[ "def", "einsum", "(", "equation", ",", "*", "operands", ")", ":", "if", "len", "(", "operands", ")", "==", "1", "and", "isinstance", "(", "operands", "[", "0", "]", ",", "(", "list", ",", "tuple", ")", ")", ":", "operands", "=", "operands", "[", ...
r"""einsum(equation, *operands) -> Tensor This function provides a way of computing multilinear expressions (i.e.
[ "r", "\"", "\"", "\"", "einsum", "(", "equation", "*", "operands", ")", "-", ">", "Tensor", "This", "function", "provides", "a", "way", "of", "computing", "multilinear", "expressions", "(", "i", ".", "e", "." ]
[ "r\"\"\"einsum(equation, *operands) -> Tensor\n\nThis function provides a way of computing multilinear expressions (i.e. sums of products) using the\nEinstein summation convention.\n\nArgs:\n equation (string): The equation is given in terms of lower case letters (indices) to be associated\n with each ...
[ { "param": "equation", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "equation", "type": null, "docstring": "The equation is given in terms of lower case letters (indices) to be associated\nwith each dimension of the operands and result. The left hand side lists the operands\ndimensions, separated by ...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
isfinite
<not_specific>
def isfinite(tensor): r"""Returns a new tensor with boolean elements representing if each element is `Finite` or not. Arguments: tensor (Tensor): A tensor to check Returns: Tensor: A ``torch.ByteTensor`` containing a 1 at each location of finite elements and 0 otherwise Example:: ...
r"""Returns a new tensor with boolean elements representing if each element is `Finite` or not. Arguments: tensor (Tensor): A tensor to check Returns: Tensor: A ``torch.ByteTensor`` containing a 1 at each location of finite elements and 0 otherwise Example:: >>> torch.isfinite(to...
r"""Returns a new tensor with boolean elements representing if each element is `Finite` or not.
[ "r", "\"", "\"", "\"", "Returns", "a", "new", "tensor", "with", "boolean", "elements", "representing", "if", "each", "element", "is", "`", "Finite", "`", "or", "not", "." ]
def isfinite(tensor): if not isinstance(tensor, torch.Tensor): raise ValueError("The argument is not a tensor", str(tensor)) if not tensor.is_floating_point(): return torch.ones_like(tensor, dtype=torch.uint8) return (tensor == tensor) & (tensor.abs() != inf)
[ "def", "isfinite", "(", "tensor", ")", ":", "if", "not", "isinstance", "(", "tensor", ",", "torch", ".", "Tensor", ")", ":", "raise", "ValueError", "(", "\"The argument is not a tensor\"", ",", "str", "(", "tensor", ")", ")", "if", "not", "tensor", ".", ...
r"""Returns a new tensor with boolean elements representing if each element is `Finite` or not.
[ "r", "\"", "\"", "\"", "Returns", "a", "new", "tensor", "with", "boolean", "elements", "representing", "if", "each", "element", "is", "`", "Finite", "`", "or", "not", "." ]
[ "r\"\"\"Returns a new tensor with boolean elements representing if each element is `Finite` or not.\n\n Arguments:\n tensor (Tensor): A tensor to check\n\n Returns:\n Tensor: A ``torch.ByteTensor`` containing a 1 at each location of finite elements and 0 otherwise\n\n Example::\n\n >>>...
[ { "param": "tensor", "type": null } ]
{ "returns": [ { "docstring": "A ``torch.ByteTensor`` containing a 1 at each location of finite elements and 0 otherwise", "docstring_tokens": [ "A", "`", "`", "torch", ".", "ByteTensor", "`", "`", "containing", "a", ...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
unique
<not_specific>
def unique(input, sorted=False, return_inverse=False, dim=None): r"""Returns the unique scalar elements of the input tensor as a 1-D tensor. Arguments: input (Tensor): the input tensor sorted (bool): Whether to sort the unique elements in ascending order before returning as output. ...
r"""Returns the unique scalar elements of the input tensor as a 1-D tensor. Arguments: input (Tensor): the input tensor sorted (bool): Whether to sort the unique elements in ascending order before returning as output. return_inverse (bool): Whether to also return the indices for...
r"""Returns the unique scalar elements of the input tensor as a 1-D tensor.
[ "r", "\"", "\"", "\"", "Returns", "the", "unique", "scalar", "elements", "of", "the", "input", "tensor", "as", "a", "1", "-", "D", "tensor", "." ]
def unique(input, sorted=False, return_inverse=False, dim=None): if dim is not None: output, inverse_indices = torch._unique_dim( input, dim, sorted=sorted, return_inverse=return_inverse ) else: output, inverse_indices = torch._unique( ...
[ "def", "unique", "(", "input", ",", "sorted", "=", "False", ",", "return_inverse", "=", "False", ",", "dim", "=", "None", ")", ":", "if", "dim", "is", "not", "None", ":", "output", ",", "inverse_indices", "=", "torch", ".", "_unique_dim", "(", "input",...
r"""Returns the unique scalar elements of the input tensor as a 1-D tensor.
[ "r", "\"", "\"", "\"", "Returns", "the", "unique", "scalar", "elements", "of", "the", "input", "tensor", "as", "a", "1", "-", "D", "tensor", "." ]
[ "r\"\"\"Returns the unique scalar elements of the input tensor as a 1-D tensor.\n\n Arguments:\n input (Tensor): the input tensor\n sorted (bool): Whether to sort the unique elements in ascending order\n before returning as output.\n return_inverse (bool): Whether to also return t...
[ { "param": "input", "type": null }, { "param": "sorted", "type": null }, { "param": "return_inverse", "type": null }, { "param": "dim", "type": null } ]
{ "returns": [ { "docstring": "(Tensor, Tensor (optional)): A tensor or a tuple of tensors containing\n\noutput** (*Tensor*): the output list of unique scalar elements.\ninverse_indices** (*Tensor*): (optional) if\n:attr:`return_inverse` is True, there will be a\n2nd returned tensor (same shape as input) re...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
tensordot
<not_specific>
def tensordot(a, b, dims=2): r"""Returns a contraction of a and b over multiple dimensions. :attr:`tensordot` implements a generalizes the matrix product. Args: a (Tensor): Left tensor to contract b (Tensor): Right tensor to contract dims (int or tuple of two lists of integers): number o...
r"""Returns a contraction of a and b over multiple dimensions. :attr:`tensordot` implements a generalizes the matrix product. Args: a (Tensor): Left tensor to contract b (Tensor): Right tensor to contract dims (int or tuple of two lists of integers): number of dimensions to contract...
r"""Returns a contraction of a and b over multiple dimensions. :attr:`tensordot` implements a generalizes the matrix product.
[ "r", "\"", "\"", "\"", "Returns", "a", "contraction", "of", "a", "and", "b", "over", "multiple", "dimensions", ".", ":", "attr", ":", "`", "tensordot", "`", "implements", "a", "generalizes", "the", "matrix", "product", "." ]
def tensordot(a, b, dims=2): if isinstance(dims, (list, tuple)) or \ (isinstance(dims, torch.Tensor) and dims.numel() > 1): dims_a, dims_b = dims else: if isinstance(dims, torch.Tensor): dims = dims.item() dims_a = list(range(-dims, 0)) dims_b = list(range(dims...
[ "def", "tensordot", "(", "a", ",", "b", ",", "dims", "=", "2", ")", ":", "if", "isinstance", "(", "dims", ",", "(", "list", ",", "tuple", ")", ")", "or", "(", "isinstance", "(", "dims", ",", "torch", ".", "Tensor", ")", "and", "dims", ".", "num...
r"""Returns a contraction of a and b over multiple dimensions.
[ "r", "\"", "\"", "\"", "Returns", "a", "contraction", "of", "a", "and", "b", "over", "multiple", "dimensions", "." ]
[ "r\"\"\"Returns a contraction of a and b over multiple dimensions.\n\n :attr:`tensordot` implements a generalizes the matrix product.\n\n Args:\n a (Tensor): Left tensor to contract\n b (Tensor): Right tensor to contract\n dims (int or tuple of two lists of integers): number of dimensions to\n ...
[ { "param": "a", "type": null }, { "param": "b", "type": null }, { "param": "dims", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": null, "docstring": "Left tensor to contract", "docstring_tokens": [ "Left", "tensor", "to", "contract" ], "default": null, "is_optional": false }, { "...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
argsort
<not_specific>
def argsort(input, dim=None, descending=False): r"""Returns the indices that sort a tensor along a given dimension in ascending order by value. This is the second value returned by :meth:`torch.sort`. See its documentation for the exact semantics of this method. Args: input (Tensor): the ...
r"""Returns the indices that sort a tensor along a given dimension in ascending order by value. This is the second value returned by :meth:`torch.sort`. See its documentation for the exact semantics of this method. Args: input (Tensor): the input tensor dim (int, optional): the dimens...
r"""Returns the indices that sort a tensor along a given dimension in ascending order by value. This is the second value returned by :meth:`torch.sort`. See its documentation for the exact semantics of this method.
[ "r", "\"", "\"", "\"", "Returns", "the", "indices", "that", "sort", "a", "tensor", "along", "a", "given", "dimension", "in", "ascending", "order", "by", "value", ".", "This", "is", "the", "second", "value", "returned", "by", ":", "meth", ":", "`", "tor...
def argsort(input, dim=None, descending=False): if dim is None: return torch.sort(input, -1, descending)[1] return torch.sort(input, dim, descending)[1]
[ "def", "argsort", "(", "input", ",", "dim", "=", "None", ",", "descending", "=", "False", ")", ":", "if", "dim", "is", "None", ":", "return", "torch", ".", "sort", "(", "input", ",", "-", "1", ",", "descending", ")", "[", "1", "]", "return", "tor...
r"""Returns the indices that sort a tensor along a given dimension in ascending order by value.
[ "r", "\"", "\"", "\"", "Returns", "the", "indices", "that", "sort", "a", "tensor", "along", "a", "given", "dimension", "in", "ascending", "order", "by", "value", "." ]
[ "r\"\"\"Returns the indices that sort a tensor along a given dimension in ascending\n order by value.\n\n This is the second value returned by :meth:`torch.sort`. See its documentation\n for the exact semantics of this method.\n\n Args:\n input (Tensor): the input tensor\n dim (int, optio...
[ { "param": "input", "type": null }, { "param": "dim", "type": null }, { "param": "descending", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": null, "docstring": "the input tensor", "docstring_tokens": [ "the", "input", "tensor" ], "default": null, "is_optional": false }, { "identifier": "dim", ...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
norm
<not_specific>
def norm(input, p="fro", dim=None, keepdim=False, out=None): r"""Returns the matrix norm or vector norm of a given tensor. Args: input (Tensor): the input tensor p (int, float, inf, -inf, 'fro', 'nuc', optional): the order of norm. Default: ``'fro'`` The following norms can be calcu...
r"""Returns the matrix norm or vector norm of a given tensor. Args: input (Tensor): the input tensor p (int, float, inf, -inf, 'fro', 'nuc', optional): the order of norm. Default: ``'fro'`` The following norms can be calculated: ===== ============================ ========...
r"""Returns the matrix norm or vector norm of a given tensor.
[ "r", "\"", "\"", "\"", "Returns", "the", "matrix", "norm", "or", "vector", "norm", "of", "a", "given", "tensor", "." ]
def norm(input, p="fro", dim=None, keepdim=False, out=None): ndim = input.dim() if dim is None and out is None: if p == "fro": return torch._C._VariableFunctions.frobenius_norm(input) elif p != "nuc": return torch._C._VariableFunctions.norm(input, p) if p == "fro": ...
[ "def", "norm", "(", "input", ",", "p", "=", "\"fro\"", ",", "dim", "=", "None", ",", "keepdim", "=", "False", ",", "out", "=", "None", ")", ":", "ndim", "=", "input", ".", "dim", "(", ")", "if", "dim", "is", "None", "and", "out", "is", "None", ...
r"""Returns the matrix norm or vector norm of a given tensor.
[ "r", "\"", "\"", "\"", "Returns", "the", "matrix", "norm", "or", "vector", "norm", "of", "a", "given", "tensor", "." ]
[ "r\"\"\"Returns the matrix norm or vector norm of a given tensor.\n\n Args:\n input (Tensor): the input tensor\n p (int, float, inf, -inf, 'fro', 'nuc', optional): the order of norm. Default: ``'fro'``\n The following norms can be calculated:\n\n ===== =======================...
[ { "param": "input", "type": null }, { "param": "p", "type": null }, { "param": "dim", "type": null }, { "param": "keepdim", "type": null }, { "param": "out", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "input", "type": null, "docstring": "the input tensor", "docstring_tokens": [ "the", "input", "tensor" ], "default": null, "is_optional": false }, { "identifier": "p", ...
53ad217fdd7050ab89bb9fde59044596d67c90f2
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/functional.py
[ "MIT" ]
Python
chain_matmul
<not_specific>
def chain_matmul(*matrices): r"""Returns the matrix product of the :math:`N` 2-D tensors. This product is efficiently computed using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms of arithmetic operations (`[CLRS]`_). Note that since this is a function to c...
r"""Returns the matrix product of the :math:`N` 2-D tensors. This product is efficiently computed using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms of arithmetic operations (`[CLRS]`_). Note that since this is a function to compute the product, :math:`N` ...
r"""Returns the matrix product of the :math:`N` 2-D tensors. This product is efficiently computed using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms of arithmetic operations (`[CLRS]`_). Note that since this is a function to compute the product, :math:`N` needs to be...
[ "r", "\"", "\"", "\"", "Returns", "the", "matrix", "product", "of", "the", ":", "math", ":", "`", "N", "`", "2", "-", "D", "tensors", ".", "This", "product", "is", "efficiently", "computed", "using", "the", "matrix", "chain", "order", "algorithm", "whi...
def chain_matmul(*matrices): return torch._C._VariableFunctions.chain_matmul(matrices)
[ "def", "chain_matmul", "(", "*", "matrices", ")", ":", "return", "torch", ".", "_C", ".", "_VariableFunctions", ".", "chain_matmul", "(", "matrices", ")" ]
r"""Returns the matrix product of the :math:`N` 2-D tensors.
[ "r", "\"", "\"", "\"", "Returns", "the", "matrix", "product", "of", "the", ":", "math", ":", "`", "N", "`", "2", "-", "D", "tensors", "." ]
[ "r\"\"\"Returns the matrix product of the :math:`N` 2-D tensors. This product is efficiently computed\n using the matrix chain order algorithm which selects the order in which incurs the lowest cost in terms\n of arithmetic operations (`[CLRS]`_). Note that since this is a function to compute the product, :ma...
[]
{ "returns": [ { "docstring": "if the :math:`i^{th}` tensor was of dimensions :math:`p_{i} \\times p_{i + 1}`, then the product\nwould be of dimensions :math:`p_{1} \\times p_{N + 1}`.", "docstring_tokens": [ "if", "the", ":", "math", ":", "`", "...
aece89c149bef5f19df94d0211b43deee16dc286
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/cuda/random.py
[ "MIT" ]
Python
manual_seed
null
def manual_seed(seed): r"""Sets the seed for generating random numbers for the current GPU. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. Args: seed (int): The desired seed. .. warning:: If you are working with a multi-GPU model, th...
r"""Sets the seed for generating random numbers for the current GPU. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. Args: seed (int): The desired seed. .. warning:: If you are working with a multi-GPU model, this function is insufficient...
r"""Sets the seed for generating random numbers for the current GPU. It's safe to call this function if CUDA is not available; in that case, it is silently ignored.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "for", "the", "current", "GPU", ".", "It", "'", "s", "safe", "to", "call", "this", "function", "if", "CUDA", "is", "not", "available", ";", "in", "that", "case", ...
def manual_seed(seed): seed = int(seed) _lazy_call(lambda: _C._cuda_manualSeed(seed))
[ "def", "manual_seed", "(", "seed", ")", ":", "seed", "=", "int", "(", "seed", ")", "_lazy_call", "(", "lambda", ":", "_C", ".", "_cuda_manualSeed", "(", "seed", ")", ")" ]
r"""Sets the seed for generating random numbers for the current GPU.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "for", "the", "current", "GPU", "." ]
[ "r\"\"\"Sets the seed for generating random numbers for the current GPU.\n It's safe to call this function if CUDA is not available; in that\n case, it is silently ignored.\n\n Args:\n seed (int): The desired seed.\n\n .. warning::\n If you are working with a multi-GPU model, this function...
[ { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seed", "type": null, "docstring": "The desired seed.", "docstring_tokens": [ "The", "desired", "seed", "." ], "default": null, "is_optional": false } ], "outlier_params...
aece89c149bef5f19df94d0211b43deee16dc286
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/cuda/random.py
[ "MIT" ]
Python
manual_seed_all
null
def manual_seed_all(seed): r"""Sets the seed for generating random numbers on all GPUs. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. Args: seed (int): The desired seed. """ seed = int(seed) _lazy_call(lambda: _C._cuda_manualSeedAll(...
r"""Sets the seed for generating random numbers on all GPUs. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. Args: seed (int): The desired seed.
r"""Sets the seed for generating random numbers on all GPUs. It's safe to call this function if CUDA is not available; in that case, it is silently ignored.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "on", "all", "GPUs", ".", "It", "'", "s", "safe", "to", "call", "this", "function", "if", "CUDA", "is", "not", "available", ";", "in", "that", "case", "it", "is",...
def manual_seed_all(seed): seed = int(seed) _lazy_call(lambda: _C._cuda_manualSeedAll(seed))
[ "def", "manual_seed_all", "(", "seed", ")", ":", "seed", "=", "int", "(", "seed", ")", "_lazy_call", "(", "lambda", ":", "_C", ".", "_cuda_manualSeedAll", "(", "seed", ")", ")" ]
r"""Sets the seed for generating random numbers on all GPUs.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "on", "all", "GPUs", "." ]
[ "r\"\"\"Sets the seed for generating random numbers on all GPUs.\n It's safe to call this function if CUDA is not available; in that\n case, it is silently ignored.\n\n Args:\n seed (int): The desired seed.\n \"\"\"" ]
[ { "param": "seed", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "seed", "type": null, "docstring": "The desired seed.", "docstring_tokens": [ "The", "desired", "seed", "." ], "default": null, "is_optional": false } ], "outlier_params...
aece89c149bef5f19df94d0211b43deee16dc286
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/cuda/random.py
[ "MIT" ]
Python
seed
null
def seed(): r"""Sets the seed for generating random numbers to a random number for the current GPU. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. .. warning:: If you are working with a multi-GPU model, this function will only initialize ...
r"""Sets the seed for generating random numbers to a random number for the current GPU. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. .. warning:: If you are working with a multi-GPU model, this function will only initialize the seed on one ...
r"""Sets the seed for generating random numbers to a random number for the current GPU. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. : If you are working with a multi-GPU model, this function will only initialize the seed on one GPU.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "to", "a", "random", "number", "for", "the", "current", "GPU", ".", "It", "'", "s", "safe", "to", "call", "this", "function", "if", "CUDA", "is", "not", "available"...
def seed(): _lazy_call(lambda: _C._cuda_seed())
[ "def", "seed", "(", ")", ":", "_lazy_call", "(", "lambda", ":", "_C", ".", "_cuda_seed", "(", ")", ")" ]
r"""Sets the seed for generating random numbers to a random number for the current GPU.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "to", "a", "random", "number", "for", "the", "current", "GPU", "." ]
[ "r\"\"\"Sets the seed for generating random numbers to a random number for the current GPU.\n It's safe to call this function if CUDA is not available; in that\n case, it is silently ignored.\n\n .. warning::\n If you are working with a multi-GPU model, this function will only initialize\n th...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
aece89c149bef5f19df94d0211b43deee16dc286
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/cuda/random.py
[ "MIT" ]
Python
seed_all
null
def seed_all(): r"""Sets the seed for generating random numbers to a random number on all GPUs. It's safe to call this function if CUDA is not available; in that case, it is silently ignored. """ _lazy_call(lambda: _C._cuda_seedAll())
r"""Sets the seed for generating random numbers to a random number on all GPUs. It's safe to call this function if CUDA is not available; in that case, it is silently ignored.
r"""Sets the seed for generating random numbers to a random number on all GPUs. It's safe to call this function if CUDA is not available; in that case, it is silently ignored.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "to", "a", "random", "number", "on", "all", "GPUs", ".", "It", "'", "s", "safe", "to", "call", "this", "function", "if", "CUDA", "is", "not", "available", ";", "i...
def seed_all(): _lazy_call(lambda: _C._cuda_seedAll())
[ "def", "seed_all", "(", ")", ":", "_lazy_call", "(", "lambda", ":", "_C", ".", "_cuda_seedAll", "(", ")", ")" ]
r"""Sets the seed for generating random numbers to a random number on all GPUs.
[ "r", "\"", "\"", "\"", "Sets", "the", "seed", "for", "generating", "random", "numbers", "to", "a", "random", "number", "on", "all", "GPUs", "." ]
[ "r\"\"\"Sets the seed for generating random numbers to a random number on all GPUs.\n It's safe to call this function if CUDA is not available; in that\n case, it is silently ignored.\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
aece89c149bef5f19df94d0211b43deee16dc286
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/cuda/random.py
[ "MIT" ]
Python
initial_seed
<not_specific>
def initial_seed(): r"""Returns the current random seed of the current GPU. .. warning:: This function eagerly initializes CUDA. """ _lazy_init() return _C._cuda_initialSeed()
r"""Returns the current random seed of the current GPU. .. warning:: This function eagerly initializes CUDA.
r"""Returns the current random seed of the current GPU. warning:: This function eagerly initializes CUDA.
[ "r", "\"", "\"", "\"", "Returns", "the", "current", "random", "seed", "of", "the", "current", "GPU", ".", "warning", "::", "This", "function", "eagerly", "initializes", "CUDA", "." ]
def initial_seed(): _lazy_init() return _C._cuda_initialSeed()
[ "def", "initial_seed", "(", ")", ":", "_lazy_init", "(", ")", "return", "_C", ".", "_cuda_initialSeed", "(", ")" ]
r"""Returns the current random seed of the current GPU.
[ "r", "\"", "\"", "\"", "Returns", "the", "current", "random", "seed", "of", "the", "current", "GPU", "." ]
[ "r\"\"\"Returns the current random seed of the current GPU.\n\n .. warning::\n This function eagerly initializes CUDA.\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
39de24157825b11c1e1c8b3886eca5ab27d7a7fe
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/annotations.py
[ "MIT" ]
Python
parse_type_line
<not_specific>
def parse_type_line(type_line): """Parses a type annotation specified as a comment. Example inputs: # type: (Tensor, torch.Tensor) -> Tuple[Tensor] # type: (Tensor, Tuple[Tensor, Tensor]) -> Tensor """ arg_ann_str, ret_ann_str = split_type_line(type_line) try: arg_ann = eva...
Parses a type annotation specified as a comment. Example inputs: # type: (Tensor, torch.Tensor) -> Tuple[Tensor] # type: (Tensor, Tuple[Tensor, Tensor]) -> Tensor
Parses a type annotation specified as a comment.
[ "Parses", "a", "type", "annotation", "specified", "as", "a", "comment", "." ]
def parse_type_line(type_line): arg_ann_str, ret_ann_str = split_type_line(type_line) try: arg_ann = eval(arg_ann_str, _eval_env) except SyntaxError: raise RuntimeError("Failed to parse the argument list of a type annotation") if not isinstance(arg_ann, tuple): arg_ann = (arg_ann...
[ "def", "parse_type_line", "(", "type_line", ")", ":", "arg_ann_str", ",", "ret_ann_str", "=", "split_type_line", "(", "type_line", ")", "try", ":", "arg_ann", "=", "eval", "(", "arg_ann_str", ",", "_eval_env", ")", "except", "SyntaxError", ":", "raise", "Runti...
Parses a type annotation specified as a comment.
[ "Parses", "a", "type", "annotation", "specified", "as", "a", "comment", "." ]
[ "\"\"\"Parses a type annotation specified as a comment.\n\n Example inputs:\n # type: (Tensor, torch.Tensor) -> Tuple[Tensor]\n # type: (Tensor, Tuple[Tensor, Tensor]) -> Tensor\n \"\"\"" ]
[ { "param": "type_line", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "type_line", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
557eabdb8cd7a11b94e869da08cc484b1127ccee
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/utils/checkpoint.py
[ "MIT" ]
Python
checkpoint_sequential
<not_specific>
def checkpoint_sequential(functions, segments, *inputs): r"""A helper function for checkpointing sequential models. Sequential models execute a list of modules/functions in order (sequentially). Therefore, we can divide such a model in various segments and checkpoint each segment. All segments except t...
r"""A helper function for checkpointing sequential models. Sequential models execute a list of modules/functions in order (sequentially). Therefore, we can divide such a model in various segments and checkpoint each segment. All segments except the last will run in :func:`torch.no_grad` manner, i.e., n...
r"""A helper function for checkpointing sequential models. Sequential models execute a list of modules/functions in order (sequentially). Therefore, we can divide such a model in various segments and checkpoint each segment. All segments except the last will run in :func:`torch.no_grad` manner, i.e., not storing the in...
[ "r", "\"", "\"", "\"", "A", "helper", "function", "for", "checkpointing", "sequential", "models", ".", "Sequential", "models", "execute", "a", "list", "of", "modules", "/", "functions", "in", "order", "(", "sequentially", ")", ".", "Therefore", "we", "can", ...
def checkpoint_sequential(functions, segments, *inputs): def run_function(start, end, functions): def forward(*inputs): for j in range(start, end + 1): if isinstance(inputs, tuple): inputs = functions[j](*inputs) else: input...
[ "def", "checkpoint_sequential", "(", "functions", ",", "segments", ",", "*", "inputs", ")", ":", "def", "run_function", "(", "start", ",", "end", ",", "functions", ")", ":", "def", "forward", "(", "*", "inputs", ")", ":", "for", "j", "in", "range", "("...
r"""A helper function for checkpointing sequential models.
[ "r", "\"", "\"", "\"", "A", "helper", "function", "for", "checkpointing", "sequential", "models", "." ]
[ "r\"\"\"A helper function for checkpointing sequential models.\n\n Sequential models execute a list of modules/functions in order\n (sequentially). Therefore, we can divide such a model in various segments\n and checkpoint each segment. All segments except the last will run in\n :func:`torch.no_grad` ma...
[ { "param": "functions", "type": null }, { "param": "segments", "type": null } ]
{ "returns": [ { "docstring": "Output of running :attr:`functions` sequentially on :attr:`*inputs`", "docstring_tokens": [ "Output", "of", "running", ":", "attr", ":", "`", "functions", "`", "sequentially", "on", ...
5594d414590280b3520f4e97e41c8949dd486ae1
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/_jit_internal.py
[ "MIT" ]
Python
weak_script
<not_specific>
def weak_script(fn, _frames_up=0): """ Marks a function as a weak script function. When used in a script function or ScriptModule, the weak script function will be lazily compiled and inlined in the graph. When not used in a script function, the weak script annotation has no effect. """ _com...
Marks a function as a weak script function. When used in a script function or ScriptModule, the weak script function will be lazily compiled and inlined in the graph. When not used in a script function, the weak script annotation has no effect.
Marks a function as a weak script function. When used in a script function or ScriptModule, the weak script function will be lazily compiled and inlined in the graph. When not used in a script function, the weak script annotation has no effect.
[ "Marks", "a", "function", "as", "a", "weak", "script", "function", ".", "When", "used", "in", "a", "script", "function", "or", "ScriptModule", "the", "weak", "script", "function", "will", "be", "lazily", "compiled", "and", "inlined", "in", "the", "graph", ...
def weak_script(fn, _frames_up=0): _compiled_weak_fns[fn] = { "status": COMPILATION_PENDING, "compiled_fn": None, "rcb": createResolutionCallback(_frames_up + 1) } return fn
[ "def", "weak_script", "(", "fn", ",", "_frames_up", "=", "0", ")", ":", "_compiled_weak_fns", "[", "fn", "]", "=", "{", "\"status\"", ":", "COMPILATION_PENDING", ",", "\"compiled_fn\"", ":", "None", ",", "\"rcb\"", ":", "createResolutionCallback", "(", "_frame...
Marks a function as a weak script function.
[ "Marks", "a", "function", "as", "a", "weak", "script", "function", "." ]
[ "\"\"\"\n Marks a function as a weak script function. When used in a script function\n or ScriptModule, the weak script function will be lazily compiled and\n inlined in the graph. When not used in a script function, the weak script\n annotation has no effect.\n \"\"\"" ]
[ { "param": "fn", "type": null }, { "param": "_frames_up", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "fn", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "_frames_up", "type": null, "docstring": null, "docstring_tokens...
5594d414590280b3520f4e97e41c8949dd486ae1
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/_jit_internal.py
[ "MIT" ]
Python
boolean_dispatch
<not_specific>
def boolean_dispatch(arg_name, arg_index, default, if_true, if_false): """ Dispatches to either of 2 weak script functions based on a boolean argument. In TorchScript, the boolean argument must be constant so that the correct function to use can be determined at compile time. """ if _compiled_we...
Dispatches to either of 2 weak script functions based on a boolean argument. In TorchScript, the boolean argument must be constant so that the correct function to use can be determined at compile time.
Dispatches to either of 2 weak script functions based on a boolean argument. In TorchScript, the boolean argument must be constant so that the correct function to use can be determined at compile time.
[ "Dispatches", "to", "either", "of", "2", "weak", "script", "functions", "based", "on", "a", "boolean", "argument", ".", "In", "TorchScript", "the", "boolean", "argument", "must", "be", "constant", "so", "that", "the", "correct", "function", "to", "use", "can...
def boolean_dispatch(arg_name, arg_index, default, if_true, if_false): if _compiled_weak_fns.get(if_true) is None or _compiled_weak_fns.get(if_false) is None: raise RuntimeError("both functions must be weak script") def fn(*args, **kwargs): dispatch_flag = False if arg_name in kwargs: ...
[ "def", "boolean_dispatch", "(", "arg_name", ",", "arg_index", ",", "default", ",", "if_true", ",", "if_false", ")", ":", "if", "_compiled_weak_fns", ".", "get", "(", "if_true", ")", "is", "None", "or", "_compiled_weak_fns", ".", "get", "(", "if_false", ")", ...
Dispatches to either of 2 weak script functions based on a boolean argument.
[ "Dispatches", "to", "either", "of", "2", "weak", "script", "functions", "based", "on", "a", "boolean", "argument", "." ]
[ "\"\"\"\n Dispatches to either of 2 weak script functions based on a boolean argument.\n In TorchScript, the boolean argument must be constant so that the correct\n function to use can be determined at compile time.\n \"\"\"", "# neither function has a docstring" ]
[ { "param": "arg_name", "type": null }, { "param": "arg_index", "type": null }, { "param": "default", "type": null }, { "param": "if_true", "type": null }, { "param": "if_false", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "arg_name", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "arg_index", "type": null, "docstring": null, "docstring_t...
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
load
<not_specific>
def load(f, map_location=None): r""" Load a ``ScriptModule`` previously saved with :func:`save <torch.jit.save>` All previously saved modules, no matter their device, are first loaded onto CPU, and then are moved to the devices they were saved from. If this fails (e.g. because the r...
r""" Load a ``ScriptModule`` previously saved with :func:`save <torch.jit.save>` All previously saved modules, no matter their device, are first loaded onto CPU, and then are moved to the devices they were saved from. If this fails (e.g. because the run time system doesn't have certain ...
All previously saved modules, no matter their device, are first loaded onto CPU, and then are moved to the devices they were saved from. If this fails , an exception is raised. However, storages can be dynamically remapped to an alternative set of devices using the `map_location` argument. Comparing to :func:`torch.l...
[ "All", "previously", "saved", "modules", "no", "matter", "their", "device", "are", "first", "loaded", "onto", "CPU", "and", "then", "are", "moved", "to", "the", "devices", "they", "were", "saved", "from", ".", "If", "this", "fails", "an", "exception", "is"...
def load(f, map_location=None): m = ScriptModule() def module_lookup(names): curr = m for name in names: if not hasattr(curr, name): setattr(curr, name, ScriptModule()) curr = getattr(curr, name) return curr if isinstance(map_location, string_c...
[ "def", "load", "(", "f", ",", "map_location", "=", "None", ")", ":", "m", "=", "ScriptModule", "(", ")", "def", "module_lookup", "(", "names", ")", ":", "curr", "=", "m", "for", "name", "in", "names", ":", "if", "not", "hasattr", "(", "curr", ",", ...
r""" Load a ``ScriptModule`` previously saved with :func:`save <torch.jit.save>`
[ "r", "\"", "\"", "\"", "Load", "a", "`", "`", "ScriptModule", "`", "`", "previously", "saved", "with", ":", "func", ":", "`", "save", "<torch", ".", "jit", ".", "save", ">", "`" ]
[ "r\"\"\"\n Load a ``ScriptModule`` previously saved with :func:`save <torch.jit.save>`\n\n All previously saved modules, no matter their device, are first loaded onto CPU,\n and then are moved to the devices they were saved from. If this fails (e.g. because\n the run time system doesn't ...
[ { "param": "f", "type": null }, { "param": "map_location", "type": null } ]
{ "returns": [ { "docstring": "A ``ScriptModule`` object.", "docstring_tokens": [ "A", "`", "`", "ScriptModule", "`", "`", "object", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "f", ...
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
save
null
def save(m, f): """ Saves a ScriptModule to a file. Args: m: a ScriptModule to save f: a file-like object (has to implement write and flush) or a string containing a file name .. warning:: If you are using Python 2, torch.save does NOT sup...
Saves a ScriptModule to a file. Args: m: a ScriptModule to save f: a file-like object (has to implement write and flush) or a string containing a file name .. warning:: If you are using Python 2, torch.save does NOT support StringIO.StringIO ...
Saves a ScriptModule to a file.
[ "Saves", "a", "ScriptModule", "to", "a", "file", "." ]
def save(m, f): if isinstance(f, str) or \ (sys.version_info[0] == 2 and isinstance(f, unicode)) or \ (sys.version_info[0] == 3 and isinstance(f, pathlib.Path)): m.save(f) else: ret = m.save_to_buffer() f.write(ret)
[ "def", "save", "(", "m", ",", "f", ")", ":", "if", "isinstance", "(", "f", ",", "str", ")", "or", "(", "sys", ".", "version_info", "[", "0", "]", "==", "2", "and", "isinstance", "(", "f", ",", "unicode", ")", ")", "or", "(", "sys", ".", "vers...
Saves a ScriptModule to a file.
[ "Saves", "a", "ScriptModule", "to", "a", "file", "." ]
[ "\"\"\"\n Saves a ScriptModule to a file.\n\n Args:\n m: a ScriptModule to save\n f: a file-like object (has to implement write and flush) or a string\n containing a file name\n\n .. warning::\n If you are using Python 2, torch.save does NOT suppor...
[ { "param": "m", "type": null }, { "param": "f", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "m", "type": null, "docstring": "a ScriptModule to save", "docstring_tokens": [ "a", "ScriptModule", "to", "save" ], "default": null, "is_optional": null }, { "ide...
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
trace
<not_specific>
def trace(func, example_inputs, optimize=True, check_trace=True, check_inputs=None, check_tolerance=1e-5, _force_outplace=False): """ Trace a function and return an executable trace that will be optimized using just-in-time compilation. .. war...
Trace a function and return an executable trace that will be optimized using just-in-time compilation. .. warning:: Tracing only correctly records functions and modules which are not data dependent (e.g., have conditionals on data in tensors) and do not have any untracked external...
Trace a function and return an executable trace that will be optimized using just-in-time compilation. Tracing only correctly records functions and modules which are not data dependent and do not have any untracked external dependencies . If you trace such models, you may silently get incorrect results on subsequen...
[ "Trace", "a", "function", "and", "return", "an", "executable", "trace", "that", "will", "be", "optimized", "using", "just", "-", "in", "-", "time", "compilation", ".", "Tracing", "only", "correctly", "records", "functions", "and", "modules", "which", "are", ...
def trace(func, example_inputs, optimize=True, check_trace=True, check_inputs=None, check_tolerance=1e-5, _force_outplace=False): if not _enabled: return func executor_options = {'optimize': bool(optimize)} if isinstance(example_inputs, tor...
[ "def", "trace", "(", "func", ",", "example_inputs", ",", "optimize", "=", "True", ",", "check_trace", "=", "True", ",", "check_inputs", "=", "None", ",", "check_tolerance", "=", "1e-5", ",", "_force_outplace", "=", "False", ")", ":", "if", "not", "_enabled...
Trace a function and return an executable trace that will be optimized using just-in-time compilation.
[ "Trace", "a", "function", "and", "return", "an", "executable", "trace", "that", "will", "be", "optimized", "using", "just", "-", "in", "-", "time", "compilation", "." ]
[ "\"\"\"\n Trace a function and return an executable trace that will be optimized\n using just-in-time compilation.\n\n .. warning::\n\n Tracing only correctly records functions and modules which are not data\n dependent (e.g., have conditionals on data in tensors) and do not have\n any...
[ { "param": "func", "type": null }, { "param": "example_inputs", "type": null }, { "param": "optimize", "type": null }, { "param": "check_trace", "type": null }, { "param": "check_inputs", "type": null }, { "param": "check_tolerance", "type": null ...
{ "returns": [ { "docstring": "A ``ScriptModule`` object with a single ``forward()`` method containing the traced code.\nWhen func is a ``torch.nn.Module``, the returned ``ScriptModule`` will have the same set of\nsub-modules and parameters as func.", "docstring_tokens": [ "A", "`", ...
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
_try_get_weak_module
<not_specific>
def _try_get_weak_module(mod): """ Get the WeakScriptModuleProxy corresponding to mod if it exists """ if not isinstance(mod, Module): return None return _weak_modules.get(mod)
Get the WeakScriptModuleProxy corresponding to mod if it exists
Get the WeakScriptModuleProxy corresponding to mod if it exists
[ "Get", "the", "WeakScriptModuleProxy", "corresponding", "to", "mod", "if", "it", "exists" ]
def _try_get_weak_module(mod): if not isinstance(mod, Module): return None return _weak_modules.get(mod)
[ "def", "_try_get_weak_module", "(", "mod", ")", ":", "if", "not", "isinstance", "(", "mod", ",", "Module", ")", ":", "return", "None", "return", "_weak_modules", ".", "get", "(", "mod", ")" ]
Get the WeakScriptModuleProxy corresponding to mod if it exists
[ "Get", "the", "WeakScriptModuleProxy", "corresponding", "to", "mod", "if", "it", "exists" ]
[ "\"\"\"\n Get the WeakScriptModuleProxy corresponding to mod if it exists\n \"\"\"" ]
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
_is_weak_type
<not_specific>
def _is_weak_type(cls): """ Check if a type has been annotated with `weak_module` """ return cls in _weak_types
Check if a type has been annotated with `weak_module`
Check if a type has been annotated with `weak_module`
[ "Check", "if", "a", "type", "has", "been", "annotated", "with", "`", "weak_module", "`" ]
def _is_weak_type(cls): return cls in _weak_types
[ "def", "_is_weak_type", "(", "cls", ")", ":", "return", "cls", "in", "_weak_types" ]
Check if a type has been annotated with `weak_module`
[ "Check", "if", "a", "type", "has", "been", "annotated", "with", "`", "weak_module", "`" ]
[ "\"\"\"\n Check if a type has been annotated with `weak_module`\n \"\"\"" ]
[ { "param": "cls", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
_get_weak_stubs
<not_specific>
def _get_weak_stubs(cls): """ Calls script_method for each method on the type of the object passed in and returns the generated ScriptMethodStubs """ stubs = [] for name in dir(cls): func = get_function_from_type(cls, name) if func in _weak_script_methods: entry = _we...
Calls script_method for each method on the type of the object passed in and returns the generated ScriptMethodStubs
Calls script_method for each method on the type of the object passed in and returns the generated ScriptMethodStubs
[ "Calls", "script_method", "for", "each", "method", "on", "the", "type", "of", "the", "object", "passed", "in", "and", "returns", "the", "generated", "ScriptMethodStubs" ]
def _get_weak_stubs(cls): stubs = [] for name in dir(cls): func = get_function_from_type(cls, name) if func in _weak_script_methods: entry = _weak_script_methods[func] stub = script_method(entry["original_method"], entry["rcb"]) stubs.append(stub) return s...
[ "def", "_get_weak_stubs", "(", "cls", ")", ":", "stubs", "=", "[", "]", "for", "name", "in", "dir", "(", "cls", ")", ":", "func", "=", "get_function_from_type", "(", "cls", ",", "name", ")", "if", "func", "in", "_weak_script_methods", ":", "entry", "="...
Calls script_method for each method on the type of the object passed in and returns the generated ScriptMethodStubs
[ "Calls", "script_method", "for", "each", "method", "on", "the", "type", "of", "the", "object", "passed", "in", "and", "returns", "the", "generated", "ScriptMethodStubs" ]
[ "\"\"\"\n Calls script_method for each method on the type of the object passed in and\n returns the generated ScriptMethodStubs\n \"\"\"" ]
[ { "param": "cls", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
909c772fdc6a96e5de768d2f17b2fc843f05f30d
YevhenVieskov/ML-DL-in-production
aws_lambda/pytorch/source/torch/jit/__init__.py
[ "MIT" ]
Python
_make_strong
<not_specific>
def _make_strong(mod): """ Converts a weak module into a subclass of ScriptModule """ if mod in _weak_modules: return _weak_modules[mod] stubs = _weak_types.get(type(mod))["method_stubs"] if stubs is None: # Generate stubs and and store on _weak_types in case this type is ...
Converts a weak module into a subclass of ScriptModule
Converts a weak module into a subclass of ScriptModule
[ "Converts", "a", "weak", "module", "into", "a", "subclass", "of", "ScriptModule" ]
def _make_strong(mod): if mod in _weak_modules: return _weak_modules[mod] stubs = _weak_types.get(type(mod))["method_stubs"] if stubs is None: stubs = _get_weak_stubs(type(mod)) _weak_types[type(mod)]["method_stubs"] = stubs proxy = WeakScriptModuleProxy(mod, stubs) _weak_mod...
[ "def", "_make_strong", "(", "mod", ")", ":", "if", "mod", "in", "_weak_modules", ":", "return", "_weak_modules", "[", "mod", "]", "stubs", "=", "_weak_types", ".", "get", "(", "type", "(", "mod", ")", ")", "[", "\"method_stubs\"", "]", "if", "stubs", "...
Converts a weak module into a subclass of ScriptModule
[ "Converts", "a", "weak", "module", "into", "a", "subclass", "of", "ScriptModule" ]
[ "\"\"\"\n Converts a weak module into a subclass of ScriptModule\n \"\"\"", "# Generate stubs and and store on _weak_types in case this type is", "# used again", "# Create proxy with stubs" ]
[ { "param": "mod", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "mod", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
41b9bff92579f9dba3dfb5f91648c5dc83a723bb
tiberiucorbu/gallery-website
main/util.py
[ "MIT" ]
Python
param
<not_specific>
def param(name, cast=None): """ Gets a parameter from the request by name and casts by the desired type """ value = None if flask.request.json: return flask.request.json.get(name, None) if value is None: value = flask.request.args.get(name, None) if value is None and flask.request.form: value...
Gets a parameter from the request by name and casts by the desired type
Gets a parameter from the request by name and casts by the desired type
[ "Gets", "a", "parameter", "from", "the", "request", "by", "name", "and", "casts", "by", "the", "desired", "type" ]
def param(name, cast=None): value = None if flask.request.json: return flask.request.json.get(name, None) if value is None: value = flask.request.args.get(name, None) if value is None and flask.request.form: value = flask.request.form.get(name, None) if cast and value is not None: if cast is b...
[ "def", "param", "(", "name", ",", "cast", "=", "None", ")", ":", "value", "=", "None", "if", "flask", ".", "request", ".", "json", ":", "return", "flask", ".", "request", ".", "json", ".", "get", "(", "name", ",", "None", ")", "if", "value", "is"...
Gets a parameter from the request by name and casts by the desired type
[ "Gets", "a", "parameter", "from", "the", "request", "by", "name", "and", "casts", "by", "the", "desired", "type" ]
[ "\"\"\"\n Gets a parameter from the request by name and casts by the desired type\n \"\"\"" ]
[ { "param": "name", "type": null }, { "param": "cast", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "name", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cast", "type": null, "docstring": null, "docstring_tokens": [...
63ca61ace4c1f058feec04e97b5c480a58939a7d
onlyjus/qt_examples
animations/stacked_animation.py
[ "MIT" ]
Python
make_callback
<not_specific>
def make_callback(func, *param): ''' Helper function to make sure lambda functions are cached and not lost. ''' return lambda: func(*param)
Helper function to make sure lambda functions are cached and not lost.
Helper function to make sure lambda functions are cached and not lost.
[ "Helper", "function", "to", "make", "sure", "lambda", "functions", "are", "cached", "and", "not", "lost", "." ]
def make_callback(func, *param): return lambda: func(*param)
[ "def", "make_callback", "(", "func", ",", "*", "param", ")", ":", "return", "lambda", ":", "func", "(", "*", "param", ")" ]
Helper function to make sure lambda functions are cached and not lost.
[ "Helper", "function", "to", "make", "sure", "lambda", "functions", "are", "cached", "and", "not", "lost", "." ]
[ "'''\n Helper function to make sure lambda functions are cached and not lost.\n '''" ]
[ { "param": "func", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
configure
<not_specific>
def configure(self, config=None): """ Configure and compile the action value network. For now, just an MLP, but CNNs will be supported soon. :return: Compiled TF Keras model """ batch_shape = tuple([None] + self._state_dim) if self._state_type == "vector": ...
Configure and compile the action value network. For now, just an MLP, but CNNs will be supported soon. :return: Compiled TF Keras model
Configure and compile the action value network. For now, just an MLP, but CNNs will be supported soon.
[ "Configure", "and", "compile", "the", "action", "value", "network", ".", "For", "now", "just", "an", "MLP", "but", "CNNs", "will", "be", "supported", "soon", "." ]
def configure(self, config=None): batch_shape = tuple([None] + self._state_dim) if self._state_type == "vector": config_ = { "dense_dims": list(range(self._action_dim+1, self._state_dim[0]+1))[::-1], "dense_activation": "relu", ...
[ "def", "configure", "(", "self", ",", "config", "=", "None", ")", ":", "batch_shape", "=", "tuple", "(", "[", "None", "]", "+", "self", ".", "_state_dim", ")", "if", "self", ".", "_state_type", "==", "\"vector\"", ":", "config_", "=", "{", "\"dense_dim...
Configure and compile the action value network.
[ "Configure", "and", "compile", "the", "action", "value", "network", "." ]
[ "\"\"\"\n Configure and compile the action value network. For now, just an\n MLP, but CNNs will be supported soon.\n :return: Compiled TF Keras model\n \"\"\"", "# compiled model" ]
[ { "param": "self", "type": null }, { "param": "config", "type": null } ]
{ "returns": [ { "docstring": "Compiled TF Keras model", "docstring_tokens": [ "Compiled", "TF", "Keras", "model" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "d...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
q_eval
<not_specific>
def q_eval(self, state, freeze_flag=False, reshape=None): """ Evaluate the q network (or frozen q network) at the current state array :param state: State array (or array of state arrays) :param freeze_flag: Boolean for whether we should use a frozen network for eval :param reshap...
Evaluate the q network (or frozen q network) at the current state array :param state: State array (or array of state arrays) :param freeze_flag: Boolean for whether we should use a frozen network for eval :param reshape: A shape to reshape the output to (if needed) :return: Acti...
Evaluate the q network (or frozen q network) at the current state array
[ "Evaluate", "the", "q", "network", "(", "or", "frozen", "q", "network", ")", "at", "the", "current", "state", "array" ]
def q_eval(self, state, freeze_flag=False, reshape=None): if freeze_flag: assert self._frozen_q_network is not None, \ "Asked for the frozen q network evaluation, but no frozen q network available." preds = self._frozen_q_network.predict(state) else: p...
[ "def", "q_eval", "(", "self", ",", "state", ",", "freeze_flag", "=", "False", ",", "reshape", "=", "None", ")", ":", "if", "freeze_flag", ":", "assert", "self", ".", "_frozen_q_network", "is", "not", "None", ",", "\"Asked for the frozen q network evaluation, but...
Evaluate the q network (or frozen q network) at the current state array
[ "Evaluate", "the", "q", "network", "(", "or", "frozen", "q", "network", ")", "at", "the", "current", "state", "array" ]
[ "\"\"\"\n Evaluate the q network (or frozen q network) at the current state array\n :param state: State array (or array of state arrays)\n :param freeze_flag: Boolean for whether we should use a frozen network for eval\n :param reshape: A shape to reshape the output to (if needed)\n ...
[ { "param": "self", "type": null }, { "param": "state", "type": null }, { "param": "freeze_flag", "type": null }, { "param": "reshape", "type": null } ]
{ "returns": [ { "docstring": "Action value predictions", "docstring_tokens": [ "Action", "value", "predictions" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
greedy_policy
<not_specific>
def greedy_policy(self, state): """ Greedy action for the provided state :param state: State :return: Action index """ return np.argmax(self.q_eval(state, reshape=self._action_dim))
Greedy action for the provided state :param state: State :return: Action index
Greedy action for the provided state
[ "Greedy", "action", "for", "the", "provided", "state" ]
def greedy_policy(self, state): return np.argmax(self.q_eval(state, reshape=self._action_dim))
[ "def", "greedy_policy", "(", "self", ",", "state", ")", ":", "return", "np", ".", "argmax", "(", "self", ".", "q_eval", "(", "state", ",", "reshape", "=", "self", ".", "_action_dim", ")", ")" ]
Greedy action for the provided state
[ "Greedy", "action", "for", "the", "provided", "state" ]
[ "\"\"\"\n Greedy action for the provided state\n :param state: State\n :return: Action index\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "state", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
_return
<not_specific>
def _return(self, rewards): """ Return the total discounted reward for a given sequential list of rewards and a discount rate :param rewards: List of rewards :return: MC Target (total discounted rewards) """ return sum([rewards[i]*pow(self._discount, i) for i in r...
Return the total discounted reward for a given sequential list of rewards and a discount rate :param rewards: List of rewards :return: MC Target (total discounted rewards)
Return the total discounted reward for a given sequential list of rewards and a discount rate
[ "Return", "the", "total", "discounted", "reward", "for", "a", "given", "sequential", "list", "of", "rewards", "and", "a", "discount", "rate" ]
def _return(self, rewards): return sum([rewards[i]*pow(self._discount, i) for i in range(len(rewards))])
[ "def", "_return", "(", "self", ",", "rewards", ")", ":", "return", "sum", "(", "[", "rewards", "[", "i", "]", "*", "pow", "(", "self", ".", "_discount", ",", "i", ")", "for", "i", "in", "range", "(", "len", "(", "rewards", ")", ")", "]", ")" ]
Return the total discounted reward for a given sequential list of rewards and a discount rate
[ "Return", "the", "total", "discounted", "reward", "for", "a", "given", "sequential", "list", "of", "rewards", "and", "a", "discount", "rate" ]
[ "\"\"\"\n Return the total discounted reward for a given sequential\n list of rewards and a discount rate\n :param rewards: List of rewards\n :return: MC Target (total discounted rewards)\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "rewards", "type": null } ]
{ "returns": [ { "docstring": "MC Target (total discounted rewards)", "docstring_tokens": [ "MC", "Target", "(", "total", "discounted", "rewards", ")" ], "type": null } ], "raises": [], "params": [ { "identifier": ...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
_batch
<not_specific>
def _batch(self, data): """ Parse the raw state, action, reward episode data into a batch for updating the action value network. :param data: Data collected from train loop :return: Numpy batches """ states, actions, rewards = zip(*data) state_array = np....
Parse the raw state, action, reward episode data into a batch for updating the action value network. :param data: Data collected from train loop :return: Numpy batches
Parse the raw state, action, reward episode data into a batch for updating the action value network.
[ "Parse", "the", "raw", "state", "action", "reward", "episode", "data", "into", "a", "batch", "for", "updating", "the", "action", "value", "network", "." ]
def _batch(self, data): states, actions, rewards = zip(*data) state_array = np.array(states).reshape([len(data)] + self._state_dim) target_array = np.zeros((len(data), self._action_dim)) for i, s in enumerate(states): target_vector = self.q_eval(s, reshape=self._action_dim) ...
[ "def", "_batch", "(", "self", ",", "data", ")", ":", "states", ",", "actions", ",", "rewards", "=", "zip", "(", "*", "data", ")", "state_array", "=", "np", ".", "array", "(", "states", ")", ".", "reshape", "(", "[", "len", "(", "data", ")", "]", ...
Parse the raw state, action, reward episode data into a batch for updating the action value network.
[ "Parse", "the", "raw", "state", "action", "reward", "episode", "data", "into", "a", "batch", "for", "updating", "the", "action", "value", "network", "." ]
[ "\"\"\"\n Parse the raw state, action, reward episode data into a batch\n for updating the action value network.\n :param data: Data collected from train loop\n :return: Numpy batches\n \"\"\"", "# iterate over states and construct mc-target", "#TODO: refactor to compute targe...
[ { "param": "self", "type": null }, { "param": "data", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
train
null
def train(self, n_episodes, max_steps=1000, epsilon=0.01, epsilon_schedule=False, network=None): """ For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards. Once the episode is up, use the true reward to prep a batch and update the action value ...
For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards. Once the episode is up, use the true reward to prep a batch and update the action value network. :param n_episodes: :param max_steps: :param epsilon: :param epsilon...
For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards. Once the episode is up, use the true reward to prep a batch and update the action value network.
[ "For", "each", "episode", "play", "with", "the", "epsilon", "-", "greedy", "policy", "and", "record", "the", "states", "actions", "and", "rewards", ".", "Once", "the", "episode", "is", "up", "use", "the", "true", "reward", "to", "prep", "a", "batch", "an...
def train(self, n_episodes, max_steps=1000, epsilon=0.01, epsilon_schedule=False, network=None): if self._q_network is None: self._q_network = self.configure(network) max_reward = 0.0 for i in range(n_episodes): if epsilon_schedule is not None: if i % epsi...
[ "def", "train", "(", "self", ",", "n_episodes", ",", "max_steps", "=", "1000", ",", "epsilon", "=", "0.01", ",", "epsilon_schedule", "=", "False", ",", "network", "=", "None", ")", ":", "if", "self", ".", "_q_network", "is", "None", ":", "self", ".", ...
For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards.
[ "For", "each", "episode", "play", "with", "the", "epsilon", "-", "greedy", "policy", "and", "record", "the", "states", "actions", "and", "rewards", "." ]
[ "\"\"\"\n For each episode, play with the epsilon-greedy policy and record\n the states, actions, and rewards. Once the episode is up, use the\n true reward to prep a batch and update the action value network.\n :param n_episodes:\n :param max_steps:\n :param epsilon:\n ...
[ { "param": "self", "type": null }, { "param": "n_episodes", "type": null }, { "param": "max_steps", "type": null }, { "param": "epsilon", "type": null }, { "param": "epsilon_schedule", "type": null }, { "param": "network", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
_batch
<not_specific>
def _batch(self, data, q_freeze): """ Construct a batch for learning using the provided tuples and the action value function. :param data: :param q_freeze: :return: """ states, actions, rewards, states_prime = zip(*data) state_shape = [len(data)] ...
Construct a batch for learning using the provided tuples and the action value function. :param data: :param q_freeze: :return:
Construct a batch for learning using the provided tuples and the action value function.
[ "Construct", "a", "batch", "for", "learning", "using", "the", "provided", "tuples", "and", "the", "action", "value", "function", "." ]
def _batch(self, data, q_freeze): states, actions, rewards, states_prime = zip(*data) state_shape = [len(data)] + self._state_dim action_shape = [len(data), self._action_dim] state_array = np.array(states).reshape(state_shape) state_prime_array = np.array(states_prime).reshape(st...
[ "def", "_batch", "(", "self", ",", "data", ",", "q_freeze", ")", ":", "states", ",", "actions", ",", "rewards", ",", "states_prime", "=", "zip", "(", "*", "data", ")", "state_shape", "=", "[", "len", "(", "data", ")", "]", "+", "self", ".", "_state...
Construct a batch for learning using the provided tuples and the action value function.
[ "Construct", "a", "batch", "for", "learning", "using", "the", "provided", "tuples", "and", "the", "action", "value", "function", "." ]
[ "\"\"\"\n Construct a batch for learning using the provided tuples and\n the action value function.\n :param data:\n :param q_freeze:\n :return:\n \"\"\"", "# get the current q values for the current state and next", "# state over the entire batch simultaneously", "# ...
[ { "param": "self", "type": null }, { "param": "data", "type": null }, { "param": "q_freeze", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
026eb3535033a2e8d5b1148db05d5f9c0d107d33
abw-24/deep-RL
autorl/agents.py
[ "MIT" ]
Python
train
null
def train(self, n_episodes, max_steps=1000, epsilon=0.01, epsilon_schedule=10, buffer_size=128, batch_size=16, weight_freeze=None, network=None): """ For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards. At each step, use the action valu...
For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards. At each step, use the action value function and a set of random 4-tuples from the replay buffer to bootstrap the q-learning targets and update the network. :param n_episodes: ...
For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards. At each step, use the action value function and a set of random 4-tuples from the replay buffer to bootstrap the q-learning targets and update the network.
[ "For", "each", "episode", "play", "with", "the", "epsilon", "-", "greedy", "policy", "and", "record", "the", "states", "actions", "and", "rewards", ".", "At", "each", "step", "use", "the", "action", "value", "function", "and", "a", "set", "of", "random", ...
def train(self, n_episodes, max_steps=1000, epsilon=0.01, epsilon_schedule=10, buffer_size=128, batch_size=16, weight_freeze=None, network=None): if self._q_network is None: self._q_network = self.configure(network) self._buffer_size = buffer_size if weight_freeze is no...
[ "def", "train", "(", "self", ",", "n_episodes", ",", "max_steps", "=", "1000", ",", "epsilon", "=", "0.01", ",", "epsilon_schedule", "=", "10", ",", "buffer_size", "=", "128", ",", "batch_size", "=", "16", ",", "weight_freeze", "=", "None", ",", "network...
For each episode, play with the epsilon-greedy policy and record the states, actions, and rewards.
[ "For", "each", "episode", "play", "with", "the", "epsilon", "-", "greedy", "policy", "and", "record", "the", "states", "actions", "and", "rewards", "." ]
[ "\"\"\"\n For each episode, play with the epsilon-greedy policy and record\n the states, actions, and rewards. At each step, use the action value\n function and a set of random 4-tuples from the replay buffer to bootstrap\n the q-learning targets and update the network.\n\n :param...
[ { "param": "self", "type": null }, { "param": "n_episodes", "type": null }, { "param": "max_steps", "type": null }, { "param": "epsilon", "type": null }, { "param": "epsilon_schedule", "type": null }, { "param": "buffer_size", "type": null }, {...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
642d69ec63c52e9793d791cb7af9480447690341
iankuoli/OSNet-TopDrop
torchreid/data/datasets/image/deepinsight.py
[ "MIT" ]
Python
prepare_split
null
def prepare_split(self): """ Image name format: 0001001.png, where first four digits represent identity and last four digits represent cameras. Camera 1&2 are considered the same view and camera 3&4 are considered the same view. """ if not osp.exists(self.split_path): ...
Image name format: 0001001.png, where first four digits represent identity and last four digits represent cameras. Camera 1&2 are considered the same view and camera 3&4 are considered the same view.
Image name format: 0001001.png, where first four digits represent identity and last four digits represent cameras. Camera 1&2 are considered the same view and camera 3&4 are considered the same view.
[ "Image", "name", "format", ":", "0001001", ".", "png", "where", "first", "four", "digits", "represent", "identity", "and", "last", "four", "digits", "represent", "cameras", ".", "Camera", "1&2", "are", "considered", "the", "same", "view", "and", "camera", "3...
def prepare_split(self): if not osp.exists(self.split_path): print('Creating 10 random splits of train ids and test ids') img_paths = sorted(glob.glob(osp.join(self.dataset_dir, '*.jpg'))) img_list = [] pid_container = set() camid_container = set() ...
[ "def", "prepare_split", "(", "self", ")", ":", "if", "not", "osp", ".", "exists", "(", "self", ".", "split_path", ")", ":", "print", "(", "'Creating 10 random splits of train ids and test ids'", ")", "img_paths", "=", "sorted", "(", "glob", ".", "glob", "(", ...
Image name format: 0001001.png, where first four digits represent identity and last four digits represent cameras.
[ "Image", "name", "format", ":", "0001001", ".", "png", "where", "first", "four", "digits", "represent", "identity", "and", "last", "four", "digits", "represent", "cameras", "." ]
[ "\"\"\"\n Image name format: 0001001.png, where first four digits represent identity\n and last four digits represent cameras. Camera 1&2 are considered the same\n view and camera 3&4 are considered the same view.\n \"\"\"", "# Shuffle the pids", "# Shuffle the camids", "# (img_pat...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
650704196681045d348b03bfbca49007b9a6ec09
iankuoli/OSNet-TopDrop
torchreid/models/__init__.py
[ "MIT" ]
Python
build_model
<not_specific>
def build_model(name, num_classes, loss='softmax', pretrained=True, use_gpu=True, backbone='resnet50'): """A function wrapper for building a model. Args: name (str): model name. num_classes (int): number of training identities. loss (str, optional): loss function to optimize the model. ...
A function wrapper for building a model. Args: name (str): model name. num_classes (int): number of training identities. loss (str, optional): loss function to optimize the model. Currently supports "softmax" and "triplet". Default is "softmax". pretrained (bool, optiona...
A function wrapper for building a model.
[ "A", "function", "wrapper", "for", "building", "a", "model", "." ]
def build_model(name, num_classes, loss='softmax', pretrained=True, use_gpu=True, backbone='resnet50'): avai_models = list(__model_factory.keys()) if name not in avai_models: raise KeyError('Unknown model: {}. Must be one of {}'.format(name, avai_models)) return __model_factory[name]( num_cl...
[ "def", "build_model", "(", "name", ",", "num_classes", ",", "loss", "=", "'softmax'", ",", "pretrained", "=", "True", ",", "use_gpu", "=", "True", ",", "backbone", "=", "'resnet50'", ")", ":", "avai_models", "=", "list", "(", "__model_factory", ".", "keys"...
A function wrapper for building a model.
[ "A", "function", "wrapper", "for", "building", "a", "model", "." ]
[ "\"\"\"A function wrapper for building a model.\n\n Args:\n name (str): model name.\n num_classes (int): number of training identities.\n loss (str, optional): loss function to optimize the model. Currently\n supports \"softmax\" and \"triplet\". Default is \"softmax\".\n p...
[ { "param": "name", "type": null }, { "param": "num_classes", "type": null }, { "param": "loss", "type": null }, { "param": "pretrained", "type": null }, { "param": "use_gpu", "type": null }, { "param": "backbone", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "name", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, ...
179d49163c73dc771e849f9741243b4ac34159f6
iankuoli/OSNet-TopDrop
torchreid/models/osnet_ain_lambda.py
[ "MIT" ]
Python
init_pretrained_weights
<not_specific>
def init_pretrained_weights(model, key=''): """Initializes model with pretrained weights. Layers that don't match with pretrained layers in name or size are kept unchanged. """ import os import errno import gdown from collections import OrderedDict def _get_torch_home(): EN...
Initializes model with pretrained weights. Layers that don't match with pretrained layers in name or size are kept unchanged.
Initializes model with pretrained weights. Layers that don't match with pretrained layers in name or size are kept unchanged.
[ "Initializes", "model", "with", "pretrained", "weights", ".", "Layers", "that", "don", "'", "t", "match", "with", "pretrained", "layers", "in", "name", "or", "size", "are", "kept", "unchanged", "." ]
def init_pretrained_weights(model, key=''): import os import errno import gdown from collections import OrderedDict def _get_torch_home(): ENV_TORCH_HOME = 'TORCH_HOME' ENV_XDG_CACHE_HOME = 'XDG_CACHE_HOME' DEFAULT_CACHE_DIR = '~/.cache' torch_home = os.path.expanduse...
[ "def", "init_pretrained_weights", "(", "model", ",", "key", "=", "''", ")", ":", "import", "os", "import", "errno", "import", "gdown", "from", "collections", "import", "OrderedDict", "def", "_get_torch_home", "(", ")", ":", "ENV_TORCH_HOME", "=", "'TORCH_HOME'",...
Initializes model with pretrained weights.
[ "Initializes", "model", "with", "pretrained", "weights", "." ]
[ "\"\"\"Initializes model with pretrained weights.\n \n Layers that don't match with pretrained layers in name or size are kept unchanged.\n \"\"\"", "# Directory already exists, ignore.", "# Unexpected OSError, re-raise.", "# discard module." ]
[ { "param": "model", "type": null }, { "param": "key", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "model", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "key", "type": null, "docstring": null, "docstring_tokens": [...
7cf2d4e5fe7058d25a00303283d3de0892de2ef3
iankuoli/OSNet-TopDrop
torchreid/engine/engine.py
[ "MIT" ]
Python
run
<not_specific>
def run(self, aim_sess, save_dir='log', max_epoch=0, start_epoch=0, fixbase_epoch=0, open_layers=None, start_eval=0, eval_freq=-1, test_only=False, print_freq=10, dist_metric='euclidean', normalize_feature=False, visrank=False, visrankactiv=False, visrankactivthr=False, maskthr=0.7, ...
A unified pipeline for training and evaluating a model. :param aim_sess: aim recorder :param save_dir: directory to save model. :param max_epoch: maximum epoch. :param start_epoch: (int, optional) starting epoch. Default is 0. :param fixbase_epoch: (int, optional) number of epoch...
A unified pipeline for training and evaluating a model.
[ "A", "unified", "pipeline", "for", "training", "and", "evaluating", "a", "model", "." ]
def run(self, aim_sess, save_dir='log', max_epoch=0, start_epoch=0, fixbase_epoch=0, open_layers=None, start_eval=0, eval_freq=-1, test_only=False, print_freq=10, dist_metric='euclidean', normalize_feature=False, visrank=False, visrankactiv=False, visrankactivthr=False, maskthr=0.7, ...
[ "def", "run", "(", "self", ",", "aim_sess", ",", "save_dir", "=", "'log'", ",", "max_epoch", "=", "0", ",", "start_epoch", "=", "0", ",", "fixbase_epoch", "=", "0", ",", "open_layers", "=", "None", ",", "start_eval", "=", "0", ",", "eval_freq", "=", ...
A unified pipeline for training and evaluating a model.
[ "A", "unified", "pipeline", "for", "training", "and", "evaluating", "a", "model", "." ]
[ "\"\"\"A unified pipeline for training and evaluating a model.\n :param aim_sess: aim recorder\n :param save_dir: directory to save model.\n :param max_epoch: maximum epoch.\n :param start_epoch: (int, optional) starting epoch. Default is 0.\n :param fixbase_epoch: (int, optional)...
[ { "param": "self", "type": null }, { "param": "aim_sess", "type": null }, { "param": "save_dir", "type": null }, { "param": "max_epoch", "type": null }, { "param": "start_epoch", "type": null }, { "param": "fixbase_epoch", "type": null }, { ...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
7cf2d4e5fe7058d25a00303283d3de0892de2ef3
iankuoli/OSNet-TopDrop
torchreid/engine/engine.py
[ "MIT" ]
Python
visactmap
null
def visactmap(self, testloader, save_dir, width, height, print_freq): """Visualizes CNN activation maps to see where the CNN focuses on to extract features. This function takes as input the query images of target datasets Reference: - Zagoruyko and Komodakis. Paying more attention ...
Visualizes CNN activation maps to see where the CNN focuses on to extract features. This function takes as input the query images of target datasets Reference: - Zagoruyko and Komodakis. Paying more attention to attention: Improving the performance of convolutional neural net...
Visualizes CNN activation maps to see where the CNN focuses on to extract features. This function takes as input the query images of target datasets Zagoruyko and Komodakis. Paying more attention to attention: Improving the performance of convolutional neural networks via attention transfer. ICLR, 2017 Zhou et al. Omn...
[ "Visualizes", "CNN", "activation", "maps", "to", "see", "where", "the", "CNN", "focuses", "on", "to", "extract", "features", ".", "This", "function", "takes", "as", "input", "the", "query", "images", "of", "target", "datasets", "Zagoruyko", "and", "Komodakis",...
def visactmap(self, testloader, save_dir, width, height, print_freq): self.model.eval() imagenet_mean = [0.485, 0.456, 0.406] imagenet_std = [0.229, 0.224, 0.225] for target in list(testloader.keys()): queryloader = testloader[target]['query'] actmap_dir = osp.joi...
[ "def", "visactmap", "(", "self", ",", "testloader", ",", "save_dir", ",", "width", ",", "height", ",", "print_freq", ")", ":", "self", ".", "model", ".", "eval", "(", ")", "imagenet_mean", "=", "[", "0.485", ",", "0.456", ",", "0.406", "]", "imagenet_s...
Visualizes CNN activation maps to see where the CNN focuses on to extract features.
[ "Visualizes", "CNN", "activation", "maps", "to", "see", "where", "the", "CNN", "focuses", "on", "to", "extract", "features", "." ]
[ "\"\"\"Visualizes CNN activation maps to see where the CNN focuses on to extract features.\n\n This function takes as input the query images of target datasets\n\n Reference:\n - Zagoruyko and Komodakis. Paying more attention to attention: Improving the\n performance of convolu...
[ { "param": "self", "type": null }, { "param": "testloader", "type": null }, { "param": "save_dir", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "print_freq", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "testloader", "type": null, "docstring": null, "docstring_toke...
7cf2d4e5fe7058d25a00303283d3de0892de2ef3
iankuoli/OSNet-TopDrop
torchreid/engine/engine.py
[ "MIT" ]
Python
two_stepped_transfer_learning
<not_specific>
def two_stepped_transfer_learning(self, epoch, fixbase_epoch, open_layers, model=None): """Two-stepped transfer learning. The idea is to freeze base layers for a certain number of epochs and then open all layers for training. Reference: https://arxiv.org/abs/1611.05244 """ ...
Two-stepped transfer learning. The idea is to freeze base layers for a certain number of epochs and then open all layers for training. Reference: https://arxiv.org/abs/1611.05244
Two-stepped transfer learning. The idea is to freeze base layers for a certain number of epochs and then open all layers for training.
[ "Two", "-", "stepped", "transfer", "learning", ".", "The", "idea", "is", "to", "freeze", "base", "layers", "for", "a", "certain", "number", "of", "epochs", "and", "then", "open", "all", "layers", "for", "training", "." ]
def two_stepped_transfer_learning(self, epoch, fixbase_epoch, open_layers, model=None): model = self.model if model is None else model if model is None: return if (epoch + 1) <= fixbase_epoch and open_layers is not None: print('* Only train {} (epoch: {}/{})'.format(open_...
[ "def", "two_stepped_transfer_learning", "(", "self", ",", "epoch", ",", "fixbase_epoch", ",", "open_layers", ",", "model", "=", "None", ")", ":", "model", "=", "self", ".", "model", "if", "model", "is", "None", "else", "model", "if", "model", "is", "None",...
Two-stepped transfer learning.
[ "Two", "-", "stepped", "transfer", "learning", "." ]
[ "\"\"\"Two-stepped transfer learning.\n\n The idea is to freeze base layers for a certain number of epochs\n and then open all layers for training.\n\n Reference: https://arxiv.org/abs/1611.05244\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "epoch", "type": null }, { "param": "fixbase_epoch", "type": null }, { "param": "open_layers", "type": null }, { "param": "model", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "epoch", "type": null, "docstring": null, "docstring_tokens": ...
d4d1f463b7f7a015b13739847b195445831225a7
topspinj/topic-modeling-lyrics
scripts/preprocess.py
[ "BSD-3-Clause" ]
Python
lemmatize_lyrics
<not_specific>
def lemmatize_lyrics(tokens): """ Lemmatizes tokens using NLTK's lemmatizer tool. """ lemmatized = [nltk.stem.WordNetLemmatizer().lemmatize(t) for t in tokens] return lemmatized
Lemmatizes tokens using NLTK's lemmatizer tool.
Lemmatizes tokens using NLTK's lemmatizer tool.
[ "Lemmatizes", "tokens", "using", "NLTK", "'", "s", "lemmatizer", "tool", "." ]
def lemmatize_lyrics(tokens): lemmatized = [nltk.stem.WordNetLemmatizer().lemmatize(t) for t in tokens] return lemmatized
[ "def", "lemmatize_lyrics", "(", "tokens", ")", ":", "lemmatized", "=", "[", "nltk", ".", "stem", ".", "WordNetLemmatizer", "(", ")", ".", "lemmatize", "(", "t", ")", "for", "t", "in", "tokens", "]", "return", "lemmatized" ]
Lemmatizes tokens using NLTK's lemmatizer tool.
[ "Lemmatizes", "tokens", "using", "NLTK", "'", "s", "lemmatizer", "tool", "." ]
[ "\"\"\"\n Lemmatizes tokens using NLTK's lemmatizer tool.\n \"\"\"" ]
[ { "param": "tokens", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tokens", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8596b320d697463f702b81c1b0c65699dff25850
kitfactory/optuna-pyspark
tests/test_optuna_pyspark.py
[ "MIT" ]
Python
create_new_study
int
def create_new_study(self, study_name: Optional[str] = None) -> int: """Create a new study from a name. If no name is specified, the storage class generates a name. The returned study ID is unique among all current and deleted studies. Args: study_name: Name o...
Create a new study from a name. If no name is specified, the storage class generates a name. The returned study ID is unique among all current and deleted studies. Args: study_name: Name of the new study to create. Returns: ID of the created study....
Create a new study from a name. If no name is specified, the storage class generates a name. The returned study ID is unique among all current and deleted studies.
[ "Create", "a", "new", "study", "from", "a", "name", ".", "If", "no", "name", "is", "specified", "the", "storage", "class", "generates", "a", "name", ".", "The", "returned", "study", "ID", "is", "unique", "among", "all", "current", "and", "deleted", "stud...
def create_new_study(self, study_name: Optional[str] = None) -> int: return 1
[ "def", "create_new_study", "(", "self", ",", "study_name", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "int", ":", "return", "1" ]
Create a new study from a name.
[ "Create", "a", "new", "study", "from", "a", "name", "." ]
[ "\"\"\"Create a new study from a name.\n If no name is specified, the storage class generates a name.\n The returned study ID is unique among all current and deleted studies.\n Args:\n study_name:\n Name of the new study to create.\n Returns:\n ID of ...
[ { "param": "self", "type": null }, { "param": "study_name", "type": "Optional[str]" } ]
{ "returns": [ { "docstring": "ID of the created study.", "docstring_tokens": [ "ID", "of", "the", "created", "study", "." ], "type": null } ], "raises": [ { "docstring": "`optuna.exceptions.DuplicatedStudyError`:\nIf a stud...
8596b320d697463f702b81c1b0c65699dff25850
kitfactory/optuna-pyspark
tests/test_optuna_pyspark.py
[ "MIT" ]
Python
create_new_trial
int
def create_new_trial(self, study_id: int, template_trial: Optional[FrozenTrial] = None) -> int: """Create and add a new trial to a study. The returned trial ID is unique among all current and deleted trials. Args: study_id: ID of the study. template_trial:...
Create and add a new trial to a study. The returned trial ID is unique among all current and deleted trials. Args: study_id: ID of the study. template_trial: Template :class:`~optuna.trial.FronzenTrial` with default user-attributes, ...
Create and add a new trial to a study. The returned trial ID is unique among all current and deleted trials.
[ "Create", "and", "add", "a", "new", "trial", "to", "a", "study", ".", "The", "returned", "trial", "ID", "is", "unique", "among", "all", "current", "and", "deleted", "trials", "." ]
def create_new_trial(self, study_id: int, template_trial: Optional[FrozenTrial] = None) -> int: return 1
[ "def", "create_new_trial", "(", "self", ",", "study_id", ":", "int", ",", "template_trial", ":", "Optional", "[", "FrozenTrial", "]", "=", "None", ")", "->", "int", ":", "return", "1" ]
Create and add a new trial to a study.
[ "Create", "and", "add", "a", "new", "trial", "to", "a", "study", "." ]
[ "\"\"\"Create and add a new trial to a study.\n The returned trial ID is unique among all current and deleted trials.\n Args:\n study_id:\n ID of the study.\n template_trial:\n Template :class:`~optuna.trial.FronzenTrial` with default user-attributes...
[ { "param": "self", "type": null }, { "param": "study_id", "type": "int" }, { "param": "template_trial", "type": "Optional[FrozenTrial]" } ]
{ "returns": [ { "docstring": "ID of the created trial.", "docstring_tokens": [ "ID", "of", "the", "created", "trial", "." ], "type": null } ], "raises": [ { "docstring": "`KeyError`:\nIf no study with the matching ``study_i...
605d47e7bbc24bcb126fe1df0e244a9ac06850e8
yuewu57/mental_health_AMoSS
classifiers.py
[ "Apache-2.0" ]
Python
data_model
<not_specific>
def data_model(collection, order=2,minlen=20, standardise=True, count=True, feedforward=True,\ missing_clean=False,start_average=False, naive=False,time=True,cumsum=True): """process data before fitting into machine learning models. Parameters ---------- collection : list ...
process data before fitting into machine learning models. Parameters ---------- collection : list The out-of-sample set. order : int, optional Order of the signature. Default is 2. minlen: int the length of data considered for each patient. Default ...
process data before fitting into machine learning models. Parameters collection : list The out-of-sample set. order : int, optional Order of the signature. Default is 2. int the length of data considered for each patient. Default is 20. True or False whether or not the piece of data being standardised True or Fals...
[ "process", "data", "before", "fitting", "into", "machine", "learning", "models", ".", "Parameters", "collection", ":", "list", "The", "out", "-", "of", "-", "sample", "set", ".", "order", ":", "int", "optional", "Order", "of", "the", "signature", ".", "Def...
def data_model(collection, order=2,minlen=20, standardise=True, count=True, feedforward=True,\ missing_clean=False,start_average=False, naive=False,time=True,cumsum=True): x=[] y=[] for participant in collection: par_data=participant.data if missing_clean: part...
[ "def", "data_model", "(", "collection", ",", "order", "=", "2", ",", "minlen", "=", "20", ",", "standardise", "=", "True", ",", "count", "=", "True", ",", "feedforward", "=", "True", ",", "missing_clean", "=", "False", ",", "start_average", "=", "False",...
process data before fitting into machine learning models.
[ "process", "data", "before", "fitting", "into", "machine", "learning", "models", "." ]
[ "\"\"\"process data before fitting into machine learning models.\n\n Parameters\n ----------\n collection : list\n The out-of-sample set.\n\n order : int, optional\n Order of the signature.\n Default is 2.\n \n minlen: int\n the length of data considered for each pa...
[ { "param": "collection", "type": null }, { "param": "order", "type": null }, { "param": "minlen", "type": null }, { "param": "standardise", "type": null }, { "param": "count", "type": null }, { "param": "feedforward", "type": null }, { "par...
{ "returns": [], "raises": [], "params": [ { "identifier": "collection", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "order", "type": null, "docstring": null, "docstring_tok...
605d47e7bbc24bcb126fe1df0e244a9ac06850e8
yuewu57/mental_health_AMoSS
classifiers.py
[ "Apache-2.0" ]
Python
model_onego
<not_specific>
def model_onego(Participants, minlen, training=0.7, sample_size=50, \ start_average=False, cv=False,cumsum=True, class_=None): """ trying models with different parameters in len(set) or order in one-go. Parameters ---------- Participants: class of participants for the co...
trying models with different parameters in len(set) or order in one-go. Parameters ---------- Participants: class of participants for the corresponding 2 tests minlen: num size of each participant data. training : scalar Training set proportional. sample_si...
trying models with different parameters in len(set) or order in one-go. Parameters class of participants for the corresponding 2 tests num size of each participant data. training : scalar Training set proportional. Returns average accuracy for each case
[ "trying", "models", "with", "different", "parameters", "in", "len", "(", "set", ")", "or", "order", "in", "one", "-", "go", ".", "Parameters", "class", "of", "participants", "for", "the", "corresponding", "2", "tests", "num", "size", "of", "each", "partici...
def model_onego(Participants, minlen, training=0.7, sample_size=50, \ start_average=False, cv=False,cumsum=True, class_=None): random.seed(42) standardise_set=[False,True, True] count_set=[False, True,True] feedforward_set=[False,True,True] naive_set=[True, False,False] time_set=...
[ "def", "model_onego", "(", "Participants", ",", "minlen", ",", "training", "=", "0.7", ",", "sample_size", "=", "50", ",", "start_average", "=", "False", ",", "cv", "=", "False", ",", "cumsum", "=", "True", ",", "class_", "=", "None", ")", ":", "random...
trying models with different parameters in len(set) or order in one-go.
[ "trying", "models", "with", "different", "parameters", "in", "len", "(", "set", ")", "or", "order", "in", "one", "-", "go", "." ]
[ "\"\"\"\n trying models with different parameters in len(set) or order in one-go.\n\n Parameters\n ----------\n Participants: class of participants for the corresponding 2 tests\n\n minlen: num\n size of each participant data.\n training : scalar\n Training set proport...
[ { "param": "Participants", "type": null }, { "param": "minlen", "type": null }, { "param": "training", "type": null }, { "param": "sample_size", "type": null }, { "param": "start_average", "type": null }, { "param": "cv", "type": null }, { ...
{ "returns": [], "raises": [], "params": [ { "identifier": "Participants", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "minlen", "type": null, "docstring": null, "docstring_...
f9616069c3b49c91ca187492ebdc4bed0e829369
yuewu57/mental_health_AMoSS
data_transforms.py
[ "Apache-2.0" ]
Python
normalise
<not_specific>
def normalise(data,cumsum=True,count=True,time=True): """Normalises the data of the patient with missing count. Parameters ---------- data : two dim data, consisting of ALTMAN and QIDS scores Returns ------- normalised_data: data that are normalised and cumulated. """ normalised...
Normalises the data of the patient with missing count. Parameters ---------- data : two dim data, consisting of ALTMAN and QIDS scores Returns ------- normalised_data: data that are normalised and cumulated.
Normalises the data of the patient with missing count. Parameters data : two dim data, consisting of ALTMAN and QIDS scores Returns data that are normalised and cumulated.
[ "Normalises", "the", "data", "of", "the", "patient", "with", "missing", "count", ".", "Parameters", "data", ":", "two", "dim", "data", "consisting", "of", "ALTMAN", "and", "QIDS", "scores", "Returns", "data", "that", "are", "normalised", "and", "cumulated", ...
def normalise(data,cumsum=True,count=True,time=True): normalised_data=np.zeros((data.shape[0],data.shape[1])) scoreMAX=[20,27] scoreMIN=[0,0] if count: if time: len_data=data.shape[1]-2 else: len_data=data.shape[1]-1 else: len_data=data.shape[1] fo...
[ "def", "normalise", "(", "data", ",", "cumsum", "=", "True", ",", "count", "=", "True", ",", "time", "=", "True", ")", ":", "normalised_data", "=", "np", ".", "zeros", "(", "(", "data", ".", "shape", "[", "0", "]", ",", "data", ".", "shape", "[",...
Normalises the data of the patient with missing count.
[ "Normalises", "the", "data", "of", "the", "patient", "with", "missing", "count", "." ]
[ "\"\"\"Normalises the data of the patient with missing count.\n\n Parameters\n ----------\n data : two dim data, consisting of ALTMAN and QIDS scores\n\n\n Returns\n -------\n normalised_data: data that are normalised and cumulated.\n\n \"\"\"", "# if data[0][-1]!=data[-1][-1]:", "#...
[ { "param": "data", "type": null }, { "param": "cumsum", "type": null }, { "param": "count", "type": null }, { "param": "time", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "cumsum", "type": null, "docstring": null, "docstring_tokens":...
0c2067264f6903f3ae3a91c4c7ecd2ec443ec542
yuewu57/mental_health_AMoSS
spectrum_functions.py
[ "Apache-2.0" ]
Python
test
<not_specific>
def test(self,\ path,\ order=2,\ standardise=True,\ count=True,\ feedforward=True,\ missing_clean=False,\ start_average=False,\ naive=False,\ time=False,\ cumsum=True): """Tests the ...
Tests the model against a particular participant. Parameters ---------- path : str Path of the pickle file containing the streams of data from the participant. order : int, optional Order of the signature. Default is 2. mi...
Tests the model against a particular participant. Parameters path : str Path of the pickle file containing the streams of data from the participant. order : int, optional Order of the signature. Default is 2. int; the length of data considered for each patient. Default is 20. data whether or not standardised Default...
[ "Tests", "the", "model", "against", "a", "particular", "participant", ".", "Parameters", "path", ":", "str", "Path", "of", "the", "pickle", "file", "containing", "the", "streams", "of", "data", "from", "the", "participant", ".", "order", ":", "int", "optiona...
def test(self,\ path,\ order=2,\ standardise=True,\ count=True,\ feedforward=True,\ missing_clean=False,\ start_average=False,\ naive=False,\ time=False,\ cumsum=True): file = open(p...
[ "def", "test", "(", "self", ",", "path", ",", "order", "=", "2", ",", "standardise", "=", "True", ",", "count", "=", "True", ",", "feedforward", "=", "True", ",", "missing_clean", "=", "False", ",", "start_average", "=", "False", ",", "naive", "=", "...
Tests the model against a particular participant.
[ "Tests", "the", "model", "against", "a", "particular", "participant", "." ]
[ "\"\"\"Tests the model against a particular participant.\n\n Parameters\n ----------\n path : str\n Path of the pickle file containing the streams\n of data from the participant.\n order : int, optional\n Order of the signature.\n Default is 2....
[ { "param": "self", "type": null }, { "param": "path", "type": null }, { "param": "order", "type": null }, { "param": "standardise", "type": null }, { "param": "count", "type": null }, { "param": "feedforward", "type": null }, { "param": "mi...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [...
0c2067264f6903f3ae3a91c4c7ecd2ec443ec542
yuewu57/mental_health_AMoSS
spectrum_functions.py
[ "Apache-2.0" ]
Python
train
<not_specific>
def train(path,\ order=2,\ minlen=20,\ standardise=True,\ count=True,\ feedforward=True,\ missing_clean=False,\ start_average=False, \ naive=False,\ time=False,\ cumsum=True): """ Trains the mod...
Trains the model, as specified in the original paper. Parameters ---------- path : str Path of the pickle file containing the streams of data from the participant. order : int, optional Order of the signature. Default is ...
Trains the model, as specified in the original paper. Parameters path : str Path of the pickle file containing the streams of data from the participant. order : int, optional Order of the signature. Default is 2. int; the length of data considered for each patient. Default is 20. data whether or not standardised Def...
[ "Trains", "the", "model", "as", "specified", "in", "the", "original", "paper", ".", "Parameters", "path", ":", "str", "Path", "of", "the", "pickle", "file", "containing", "the", "streams", "of", "data", "from", "the", "participant", ".", "order", ":", "int...
def train(path,\ order=2,\ minlen=20,\ standardise=True,\ count=True,\ feedforward=True,\ missing_clean=False,\ start_average=False, \ naive=False,\ time=False,\ cumsum=True): file = open(path,'rb') collection = ...
[ "def", "train", "(", "path", ",", "order", "=", "2", ",", "minlen", "=", "20", ",", "standardise", "=", "True", ",", "count", "=", "True", ",", "feedforward", "=", "True", ",", "missing_clean", "=", "False", ",", "start_average", "=", "False", ",", "...
Trains the model, as specified in the original paper.
[ "Trains", "the", "model", "as", "specified", "in", "the", "original", "paper", "." ]
[ "\"\"\"\n \n Trains the model, as specified in the original paper.\n\n Parameters\n ----------\n path : str\n Path of the pickle file containing the streams\n of data from the participant.\n order : int, optional\n Order of the signature.\n ...
[ { "param": "path", "type": null }, { "param": "order", "type": null }, { "param": "minlen", "type": null }, { "param": "standardise", "type": null }, { "param": "count", "type": null }, { "param": "feedforward", "type": null }, { "param": "...
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "order", "type": null, "docstring": null, "docstring_tokens": ...
0c2067264f6903f3ae3a91c4c7ecd2ec443ec542
yuewu57/mental_health_AMoSS
spectrum_functions.py
[ "Apache-2.0" ]
Python
export
null
def export(coll,\ ID,\ sample_length=20,\ test_size=5,\ path_save="./dataset_spectrum/"): """ Saves as a pickle file the training or testing sets. Parameters ---------- coll : list List of participants that should be exported. If the ...
Saves as a pickle file the training or testing sets. Parameters ---------- coll : list List of participants that should be exported. If the length of the list is 1, the set is the out-of-sample set. Otherwise, it is the training set. ID : int A random ID th...
Saves as a pickle file the training or testing sets. Parameters coll : list List of participants that should be exported. If the length of the list is 1, the set is the out-of-sample set. Otherwise, it is the training set. ID : int A random ID that will be used to export the file. Number of observations of each strea...
[ "Saves", "as", "a", "pickle", "file", "the", "training", "or", "testing", "sets", ".", "Parameters", "coll", ":", "list", "List", "of", "participants", "that", "should", "be", "exported", ".", "If", "the", "length", "of", "the", "list", "is", "1", "the",...
def export(coll,\ ID,\ sample_length=20,\ test_size=5,\ path_save="./dataset_spectrum/"): try: os.mkdir(path_save) print("Directory " , path_save , " Created ") except FileExistsError: continue if not os.path.exists(path_save+str(ID)): ...
[ "def", "export", "(", "coll", ",", "ID", ",", "sample_length", "=", "20", ",", "test_size", "=", "5", ",", "path_save", "=", "\"./dataset_spectrum/\"", ")", ":", "try", ":", "os", ".", "mkdir", "(", "path_save", ")", "print", "(", "\"Directory \"", ",", ...
Saves as a pickle file the training or testing sets.
[ "Saves", "as", "a", "pickle", "file", "the", "training", "or", "testing", "sets", "." ]
[ "\"\"\"\n \n Saves as a pickle file the training or testing sets.\n\n Parameters\n ----------\n coll : list\n List of participants that should be exported. If the\n length of the list is 1, the set is the out-of-sample\n set. Otherwise, it is the training set.\n ID : int\n...
[ { "param": "coll", "type": null }, { "param": "ID", "type": null }, { "param": "sample_length", "type": null }, { "param": "test_size", "type": null }, { "param": "path_save", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "coll", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "ID", "type": null, "docstring": null, "docstring_tokens": [],...
0c2067264f6903f3ae3a91c4c7ecd2ec443ec542
yuewu57/mental_health_AMoSS
spectrum_functions.py
[ "Apache-2.0" ]
Python
trim_triangle
<not_specific>
def trim_triangle(col,index=1): """trim healthy data such that plot can be seen. Parameters ---------- col : a collection of healthy data Returns ------- list of str List of data can has been trim by threshold 0.03. """ try1=copy.deepcopy(col) for md in try1...
trim healthy data such that plot can be seen. Parameters ---------- col : a collection of healthy data Returns ------- list of str List of data can has been trim by threshold 0.03.
trim healthy data such that plot can be seen. Parameters col : a collection of healthy data Returns list of str List of data can has been trim by threshold 0.03.
[ "trim", "healthy", "data", "such", "that", "plot", "can", "be", "seen", ".", "Parameters", "col", ":", "a", "collection", "of", "healthy", "data", "Returns", "list", "of", "str", "List", "of", "data", "can", "has", "been", "trim", "by", "threshold", "0",...
def trim_triangle(col,index=1): try1=copy.deepcopy(col) for md in try1: if md[0]==0.0: if md[int(index)]<0.95: md[0]=0.03 md[2]-=0.03 return try1
[ "def", "trim_triangle", "(", "col", ",", "index", "=", "1", ")", ":", "try1", "=", "copy", ".", "deepcopy", "(", "col", ")", "for", "md", "in", "try1", ":", "if", "md", "[", "0", "]", "==", "0.0", ":", "if", "md", "[", "int", "(", "index", ")...
trim healthy data such that plot can be seen.
[ "trim", "healthy", "data", "such", "that", "plot", "can", "be", "seen", "." ]
[ "\"\"\"trim healthy data such that plot can be seen.\n\n Parameters\n ----------\n col : a collection of healthy data\n\n Returns\n -------\n list of str\n List of data can has been trim by threshold 0.03.\n\n \"\"\"" ]
[ { "param": "col", "type": null }, { "param": "index", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "col", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "index", "type": null, "docstring": null, "docstring_tokens": [...
0c2067264f6903f3ae3a91c4c7ecd2ec443ec542
yuewu57/mental_health_AMoSS
spectrum_functions.py
[ "Apache-2.0" ]
Python
plotDensityMap
<not_specific>
def plotDensityMap(scores): """Plots, given a set of scores, the density map on a triangle. Parameters ---------- scores : list List of scores, where each score is a 3-dimensional list. """ TRIANGLE = np.array([[math.cos(math.pi*0.5), math.sin(math.pi*0.5)], [...
Plots, given a set of scores, the density map on a triangle. Parameters ---------- scores : list List of scores, where each score is a 3-dimensional list.
Plots, given a set of scores, the density map on a triangle. Parameters scores : list List of scores, where each score is a 3-dimensional list.
[ "Plots", "given", "a", "set", "of", "scores", "the", "density", "map", "on", "a", "triangle", ".", "Parameters", "scores", ":", "list", "List", "of", "scores", "where", "each", "score", "is", "a", "3", "-", "dimensional", "list", "." ]
def plotDensityMap(scores): TRIANGLE = np.array([[math.cos(math.pi*0.5), math.sin(math.pi*0.5)], [math.cos(math.pi*1.166), math.sin(math.pi*1.166)], [math.cos(math.pi*1.833), math.sin(math.pi*1.833)]]) pointsX = [score.dot(TRIANGLE)[0] for score in scores] poi...
[ "def", "plotDensityMap", "(", "scores", ")", ":", "TRIANGLE", "=", "np", ".", "array", "(", "[", "[", "math", ".", "cos", "(", "math", ".", "pi", "*", "0.5", ")", ",", "math", ".", "sin", "(", "math", ".", "pi", "*", "0.5", ")", "]", ",", "["...
Plots, given a set of scores, the density map on a triangle.
[ "Plots", "given", "a", "set", "of", "scores", "the", "density", "map", "on", "a", "triangle", "." ]
[ "\"\"\"Plots, given a set of scores, the density map on a triangle.\n\n Parameters\n ----------\n scores : list\n List of scores, where each score is a 3-dimensional list.\n\n \"\"\"" ]
[ { "param": "scores", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "scores", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4d1767108e45bb009a7da837da1b3360bcdb8aad
yuewu57/mental_health_AMoSS
prediction_functions.py
[ "Apache-2.0" ]
Python
data_model
<not_specific>
def data_model(collection,\ minlen=20,\ order=2,\ standardise=True,\ count=True,\ feedforward=True,\ missing_clean=False,\ start_average=False, \ naive=False,\ time=True,\ ...
process data before fitting into machine learning models. Parameters ---------- collection : list The out-of-sample set. order : int, optional Order of the signature. Default is 2. minlen: int the length of data considere...
process data before fitting into machine learning models. Parameters collection : list The out-of-sample set. order : int, optional Order of the signature. Default is 2. int the length of data considered for each patient. Default is 20. True or False whether or not the piece of data being standardised count: True or...
[ "process", "data", "before", "fitting", "into", "machine", "learning", "models", ".", "Parameters", "collection", ":", "list", "The", "out", "-", "of", "-", "sample", "set", ".", "order", ":", "int", "optional", "Order", "of", "the", "signature", ".", "Def...
def data_model(collection,\ minlen=20,\ order=2,\ standardise=True,\ count=True,\ feedforward=True,\ missing_clean=False,\ start_average=False, \ naive=False,\ time=True,\ ...
[ "def", "data_model", "(", "collection", ",", "minlen", "=", "20", ",", "order", "=", "2", ",", "standardise", "=", "True", ",", "count", "=", "True", ",", "feedforward", "=", "True", ",", "missing_clean", "=", "False", ",", "start_average", "=", "False",...
process data before fitting into machine learning models.
[ "process", "data", "before", "fitting", "into", "machine", "learning", "models", "." ]
[ "\"\"\"\n \n process data before fitting into machine learning models.\n \n \n Parameters\n ----------\n collection : list\n The out-of-sample set.\n order : int, optional\n Order of the signature.\n Default is 2.\n \n minlen: int\n the...
[ { "param": "collection", "type": null }, { "param": "minlen", "type": null }, { "param": "order", "type": null }, { "param": "standardise", "type": null }, { "param": "count", "type": null }, { "param": "feedforward", "type": null }, { "par...
{ "returns": [], "raises": [], "params": [ { "identifier": "collection", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "minlen", "type": null, "docstring": null, "docstring_to...
4d1767108e45bb009a7da837da1b3360bcdb8aad
yuewu57/mental_health_AMoSS
prediction_functions.py
[ "Apache-2.0" ]
Python
MAE
<not_specific>
def MAE(c,d,feature=int(0),scaling=False): """ Computing the mean absolute error for two lists of lists c and d """ a = [item for sublist in c for item in sublist] b= [item for sublist in d for item in sublist] if not scaling: a=scaling_list(a1,feature=feature)...
Computing the mean absolute error for two lists of lists c and d
Computing the mean absolute error for two lists of lists c and d
[ "Computing", "the", "mean", "absolute", "error", "for", "two", "lists", "of", "lists", "c", "and", "d" ]
def MAE(c,d,feature=int(0),scaling=False): a = [item for sublist in c for item in sublist] b= [item for sublist in d for item in sublist] if not scaling: a=scaling_list(a1,feature=feature) b=scaling_list(b1,feature=feature) if len(a)!=len(b): print("something is wrong.") el...
[ "def", "MAE", "(", "c", ",", "d", ",", "feature", "=", "int", "(", "0", ")", ",", "scaling", "=", "False", ")", ":", "a", "=", "[", "item", "for", "sublist", "in", "c", "for", "item", "in", "sublist", "]", "b", "=", "[", "item", "for", "subli...
Computing the mean absolute error for two lists of lists c and d
[ "Computing", "the", "mean", "absolute", "error", "for", "two", "lists", "of", "lists", "c", "and", "d" ]
[ "\"\"\" \n Computing the mean absolute error for two lists of lists c and d\n \n \"\"\"" ]
[ { "param": "c", "type": null }, { "param": "d", "type": null }, { "param": "feature", "type": null }, { "param": "scaling", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "c", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "d", "type": null, "docstring": null, "docstring_tokens": [], ...
4d1767108e45bb009a7da837da1b3360bcdb8aad
yuewu57/mental_health_AMoSS
prediction_functions.py
[ "Apache-2.0" ]
Python
comprehensive_model
<not_specific>
def comprehensive_model(Participants,\ class_,\ minlen=10,\ training=0.7,\ sample_size=10,\ cumsum=True): """ trying models (stateMRSPM, level 2, naive model) with different paramete...
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go. Parameters ---------- Participants: class of participants for the corresponding 2 tests class_: which class we are working on (0/1/2) minlen_set : list size of e...
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go. Parameters class of participants for the corresponding 2 tests which class we are working on (0/1/2) minlen_set : list size of each participant data. training : scalar Training set proportional. number for lo...
[ "trying", "models", "(", "stateMRSPM", "level", "2", "naive", "model", ")", "with", "different", "parameters", "in", "len", "(", "set", ")", "or", "order", "in", "one", "-", "go", ".", "Parameters", "class", "of", "participants", "for", "the", "correspondi...
def comprehensive_model(Participants,\ class_,\ minlen=10,\ training=0.7,\ sample_size=10,\ cumsum=True): random.seed(42) random_state=42 standardise_set=[False, True] count_set=[False...
[ "def", "comprehensive_model", "(", "Participants", ",", "class_", ",", "minlen", "=", "10", ",", "training", "=", "0.7", ",", "sample_size", "=", "10", ",", "cumsum", "=", "True", ")", ":", "random", ".", "seed", "(", "42", ")", "random_state", "=", "4...
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.
[ "trying", "models", "(", "stateMRSPM", "level", "2", "naive", "model", ")", "with", "different", "parameters", "in", "len", "(", "set", ")", "or", "order", "in", "one", "-", "go", "." ]
[ "\"\"\"\n trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.\n\n Parameters\n ----------\n Participants: class of participants for the corresponding 2 tests\n \n class_: which class we are working on (0/1/2)\n \n minlen_set : li...
[ { "param": "Participants", "type": null }, { "param": "class_", "type": null }, { "param": "minlen", "type": null }, { "param": "training", "type": null }, { "param": "sample_size", "type": null }, { "param": "cumsum", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Participants", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "class_", "type": null, "docstring": null, "docstring_...
4d1767108e45bb009a7da837da1b3360bcdb8aad
yuewu57/mental_health_AMoSS
prediction_functions.py
[ "Apache-2.0" ]
Python
comprehensive_nomissing_model
<not_specific>
def comprehensive_nomissing_model(Participants,\ class_,\ minlen=10,\ training=0.7,\ sample_size=10,\ scaling=False,\ ...
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go. Parameters ---------- Participants: class of participants for the corresponding 2 tests class_: which class we are working on (0/1/2) minlen_set : list size of e...
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go. Parameters class of participants for the corresponding 2 tests which class we are working on (0/1/2) minlen_set : list size of each participant data. training : scalar Training set proportional. number for lo...
[ "trying", "models", "(", "stateMRSPM", "level", "2", "naive", "model", ")", "with", "different", "parameters", "in", "len", "(", "set", ")", "or", "order", "in", "one", "-", "go", ".", "Parameters", "class", "of", "participants", "for", "the", "correspondi...
def comprehensive_nomissing_model(Participants,\ class_,\ minlen=10,\ training=0.7,\ sample_size=10,\ scaling=False,\ ...
[ "def", "comprehensive_nomissing_model", "(", "Participants", ",", "class_", ",", "minlen", "=", "10", ",", "training", "=", "0.7", ",", "sample_size", "=", "10", ",", "scaling", "=", "False", ",", "cumsum", "=", "True", ")", ":", "random", ".", "seed", "...
trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.
[ "trying", "models", "(", "stateMRSPM", "level", "2", "naive", "model", ")", "with", "different", "parameters", "in", "len", "(", "set", ")", "or", "order", "in", "one", "-", "go", "." ]
[ "\"\"\"\n trying models (stateMRSPM, level 2, naive model) with different parameters in len(set) or order in one-go.\n\n Parameters\n ----------\n Participants: class of participants for the corresponding 2 tests\n \n class_: which class we are working on (0/1/2)\n \n minlen_set : li...
[ { "param": "Participants", "type": null }, { "param": "class_", "type": null }, { "param": "minlen", "type": null }, { "param": "training", "type": null }, { "param": "sample_size", "type": null }, { "param": "scaling", "type": null }, { "p...
{ "returns": [], "raises": [], "params": [ { "identifier": "Participants", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "class_", "type": null, "docstring": null, "docstring_...
24fded9d7a7c08a6628d6afcc100bc6ef6e8b956
yuewu57/mental_health_AMoSS
data_cleaning.py
[ "Apache-2.0" ]
Python
make_classes
<not_specific>
def make_classes(participants_data_list,participants_time_list,participants_list): """data process to make class Participant Parameters List of corresponding test1 & test2, test1 time & test 2 time, id list ---------- Returns ------- class of participants for the corresponding 2 tests...
data process to make class Participant Parameters List of corresponding test1 & test2, test1 time & test 2 time, id list ---------- Returns ------- class of participants for the corresponding 2 tests
data process to make class Participant Parameters List of corresponding test1 & test2, test1 time & test 2 time, id list Returns class of participants for the corresponding 2 tests
[ "data", "process", "to", "make", "class", "Participant", "Parameters", "List", "of", "corresponding", "test1", "&", "test2", "test1", "time", "&", "test", "2", "time", "id", "list", "Returns", "class", "of", "participants", "for", "the", "corresponding", "2", ...
def make_classes(participants_data_list,participants_time_list,participants_list): num=len(participants_list) Participants=sorted(list(csv.reader(open("./source_data/patients.csv")))) participants=[] t=0 for i in range(num): n=int(participants_list[i]) for l in Participants: ...
[ "def", "make_classes", "(", "participants_data_list", ",", "participants_time_list", ",", "participants_list", ")", ":", "num", "=", "len", "(", "participants_list", ")", "Participants", "=", "sorted", "(", "list", "(", "csv", ".", "reader", "(", "open", "(", ...
data process to make class Participant Parameters
[ "data", "process", "to", "make", "class", "Participant", "Parameters" ]
[ "\"\"\"data process to make class Participant\n\n Parameters\n \n List of corresponding test1 & test2, test1 time & test 2 time, id list\n ----------\n\n Returns\n -------\n class of participants for the corresponding 2 tests\n\n\n \"\"\"" ]
[ { "param": "participants_data_list", "type": null }, { "param": "participants_time_list", "type": null }, { "param": "participants_list", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "participants_data_list", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "participants_time_list", "type": null, "docstring...
24fded9d7a7c08a6628d6afcc100bc6ef6e8b956
yuewu57/mental_health_AMoSS
data_cleaning.py
[ "Apache-2.0" ]
Python
cleaning_same_data
<not_specific>
def cleaning_same_data(Participants): """cleaning redundant data: if two data are stored in the same day, and scores are the same, keep one; if one score is recorded as missing, then keep the other one. Parameters class participant data ---------- Returns ------- sh...
cleaning redundant data: if two data are stored in the same day, and scores are the same, keep one; if one score is recorded as missing, then keep the other one. Parameters class participant data ---------- Returns ------- shortened participant data
cleaning redundant data: if two data are stored in the same day, and scores are the same, keep one; if one score is recorded as missing, then keep the other one. Parameters class participant data Returns shortened participant data
[ "cleaning", "redundant", "data", ":", "if", "two", "data", "are", "stored", "in", "the", "same", "day", "and", "scores", "are", "the", "same", "keep", "one", ";", "if", "one", "score", "is", "recorded", "as", "missing", "then", "keep", "the", "other", ...
def cleaning_same_data(Participants): Pars=copy.deepcopy(Participants) n=len(Pars[0].data) for par in Pars: for i in range(n): t=0 total_len=len(par.time[i]) for j in range(total_len)[:-1]: while int(par.time[i][j+1])==int(par.time[i][j]): ...
[ "def", "cleaning_same_data", "(", "Participants", ")", ":", "Pars", "=", "copy", ".", "deepcopy", "(", "Participants", ")", "n", "=", "len", "(", "Pars", "[", "0", "]", ".", "data", ")", "for", "par", "in", "Pars", ":", "for", "i", "in", "range", "...
cleaning redundant data: if two data are stored in the same day, and scores are the same, keep one; if one score is recorded as missing, then keep the other one.
[ "cleaning", "redundant", "data", ":", "if", "two", "data", "are", "stored", "in", "the", "same", "day", "and", "scores", "are", "the", "same", "keep", "one", ";", "if", "one", "score", "is", "recorded", "as", "missing", "then", "keep", "the", "other", ...
[ "\"\"\"cleaning redundant data: if two data are stored in the same day,\n and scores are the same, keep one; if one score is recorded as missing, then keep the\n other one.\n\n\n Parameters\n \n class participant data\n ----------\n\n Returns\n -------\n \n shortened participant data\n...
[ { "param": "Participants", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "Participants", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
24fded9d7a7c08a6628d6afcc100bc6ef6e8b956
yuewu57/mental_health_AMoSS
data_cleaning.py
[ "Apache-2.0" ]
Python
cutoff_list
<not_specific>
def cutoff_list(a,feature=int(0)): """ for list a, apply function cutoff to each element """ for i in range(len(a)): a[i]=cutoff(a[i],feature=feature) return a
for list a, apply function cutoff to each element
for list a, apply function cutoff to each element
[ "for", "list", "a", "apply", "function", "cutoff", "to", "each", "element" ]
def cutoff_list(a,feature=int(0)): for i in range(len(a)): a[i]=cutoff(a[i],feature=feature) return a
[ "def", "cutoff_list", "(", "a", ",", "feature", "=", "int", "(", "0", ")", ")", ":", "for", "i", "in", "range", "(", "len", "(", "a", ")", ")", ":", "a", "[", "i", "]", "=", "cutoff", "(", "a", "[", "i", "]", ",", "feature", "=", "feature",...
for list a, apply function cutoff to each element
[ "for", "list", "a", "apply", "function", "cutoff", "to", "each", "element" ]
[ "\"\"\"\n for list a, apply function cutoff to each element\n \"\"\"" ]
[ { "param": "a", "type": null }, { "param": "feature", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "feature", "type": null, "docstring": null, "docstring_tokens": [...
24fded9d7a7c08a6628d6afcc100bc6ef6e8b956
yuewu57/mental_health_AMoSS
data_cleaning.py
[ "Apache-2.0" ]
Python
scaling_list
<not_specific>
def scaling_list(a,feature=int(0)): """ for list a, apply function scaling to each element """ b=np.zeros(len(a)) for i in range(len(a)): b[i]=scaling(a[i],feature=feature) return list(b)
for list a, apply function scaling to each element
for list a, apply function scaling to each element
[ "for", "list", "a", "apply", "function", "scaling", "to", "each", "element" ]
def scaling_list(a,feature=int(0)): b=np.zeros(len(a)) for i in range(len(a)): b[i]=scaling(a[i],feature=feature) return list(b)
[ "def", "scaling_list", "(", "a", ",", "feature", "=", "int", "(", "0", ")", ")", ":", "b", "=", "np", ".", "zeros", "(", "len", "(", "a", ")", ")", "for", "i", "in", "range", "(", "len", "(", "a", ")", ")", ":", "b", "[", "i", "]", "=", ...
for list a, apply function scaling to each element
[ "for", "list", "a", "apply", "function", "scaling", "to", "each", "element" ]
[ "\"\"\"\n for list a, apply function scaling to each element\n \"\"\"" ]
[ { "param": "a", "type": null }, { "param": "feature", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "a", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "feature", "type": null, "docstring": null, "docstring_tokens": [...
8bcbc6f9508b99204a8c6a420ac27d638c96518c
folse/MTS
account/views.py
[ "MIT" ]
Python
login
<not_specific>
def login(request, template_name='account/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm): """Displays the login form and handles the login action.""" redirect_to = request.REQUEST.get(redirect_field_name, '') if request.method == "POS...
Displays the login form and handles the login action.
Displays the login form and handles the login action.
[ "Displays", "the", "login", "form", "and", "handles", "the", "login", "action", "." ]
def login(request, template_name='account/login.html', redirect_field_name=REDIRECT_FIELD_NAME, authentication_form=AuthenticationForm): redirect_to = request.REQUEST.get(redirect_field_name, '') if request.method == "POST": form = authentication_form(data=request.POST) if fo...
[ "def", "login", "(", "request", ",", "template_name", "=", "'account/login.html'", ",", "redirect_field_name", "=", "REDIRECT_FIELD_NAME", ",", "authentication_form", "=", "AuthenticationForm", ")", ":", "redirect_to", "=", "request", ".", "REQUEST", ".", "get", "("...
Displays the login form and handles the login action.
[ "Displays", "the", "login", "form", "and", "handles", "the", "login", "action", "." ]
[ "\"\"\"Displays the login form and handles the login action.\"\"\"", "# Light security check -- make sure redirect_to isn't garbage.\r", "# Heavier security check -- redirects to http://example.com should \r", "# not be allowed, but things like /view/?param=http://example.com \r", "# should be allowed. This...
[ { "param": "request", "type": null }, { "param": "template_name", "type": null }, { "param": "redirect_field_name", "type": null }, { "param": "authentication_form", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "request", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "template_name", "type": null, "docstring": null, "docstrin...
3420431cd13adda3ed28fa3b6ce7c059895b9722
Jerem2360/multitools
multi_tools/functional/decorator.py
[ "Unlicense" ]
Python
_wrap
<not_specific>
def _wrap(self, f: Union[FunctionType, MethodType]): """ The function's wrapper. The actual 'decorator' that is applied to the decorated function. """ # call _func with function to decorate / additional parameters, and return: return self._func(f, *self._args, **s...
The function's wrapper. The actual 'decorator' that is applied to the decorated function.
The function's wrapper. The actual 'decorator' that is applied to the decorated function.
[ "The", "function", "'", "s", "wrapper", ".", "The", "actual", "'", "decorator", "'", "that", "is", "applied", "to", "the", "decorated", "function", "." ]
def _wrap(self, f: Union[FunctionType, MethodType]): return self._func(f, *self._args, **self._kwargs)
[ "def", "_wrap", "(", "self", ",", "f", ":", "Union", "[", "FunctionType", ",", "MethodType", "]", ")", ":", "return", "self", ".", "_func", "(", "f", ",", "*", "self", ".", "_args", ",", "**", "self", ".", "_kwargs", ")" ]
The function's wrapper.
[ "The", "function", "'", "s", "wrapper", "." ]
[ "\"\"\"\n The function's wrapper.\n The actual 'decorator' that is applied to the\n decorated function.\n \"\"\"", "# call _func with function to decorate / additional parameters, and return:" ]
[ { "param": "self", "type": null }, { "param": "f", "type": "Union[FunctionType, MethodType]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "f", "type": "Union[FunctionType, MethodType]", "docstring": null, ...
3420431cd13adda3ed28fa3b6ce7c059895b9722
Jerem2360/multitools
multi_tools/functional/decorator.py
[ "Unlicense" ]
Python
unwrapped
<not_specific>
def unwrapped(self): """ An unwrapped version of the function. """ return self._func
An unwrapped version of the function.
An unwrapped version of the function.
[ "An", "unwrapped", "version", "of", "the", "function", "." ]
def unwrapped(self): return self._func
[ "def", "unwrapped", "(", "self", ")", ":", "return", "self", ".", "_func" ]
An unwrapped version of the function.
[ "An", "unwrapped", "version", "of", "the", "function", "." ]
[ "\"\"\"\n An unwrapped version of the function.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d24ff151960f8fbc7a3c5224a3b92cffa06cf168
Jerem2360/multitools
multi_tools/errors/exceptions.py
[ "Unlicense" ]
Python
raise_
null
def raise_(error: Type[ErrorImitation], name, text): """ Used to raise an ErrorImitation with more flexibility. """ error.__raise__(error(name, text))
Used to raise an ErrorImitation with more flexibility.
Used to raise an ErrorImitation with more flexibility.
[ "Used", "to", "raise", "an", "ErrorImitation", "with", "more", "flexibility", "." ]
def raise_(error: Type[ErrorImitation], name, text): error.__raise__(error(name, text))
[ "def", "raise_", "(", "error", ":", "Type", "[", "ErrorImitation", "]", ",", "name", ",", "text", ")", ":", "error", ".", "__raise__", "(", "error", "(", "name", ",", "text", ")", ")" ]
Used to raise an ErrorImitation with more flexibility.
[ "Used", "to", "raise", "an", "ErrorImitation", "with", "more", "flexibility", "." ]
[ "\"\"\"\n Used to raise an ErrorImitation with more flexibility.\n \"\"\"" ]
[ { "param": "error", "type": "Type[ErrorImitation]" }, { "param": "name", "type": null }, { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "error", "type": "Type[ErrorImitation]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name", "type": null, "docstring": null, "d...
f8c6454f7f05662346a2b92419bef723cef3b34d
Jerem2360/multitools
multi_tools/console/__init__.py
[ "Unlicense" ]
Python
configure
null
def configure(): """ Activate ansi codes for the command prompt. **Only works on Windows!** """ colors.Ansi.enable_ansi()
Activate ansi codes for the command prompt. **Only works on Windows!**
Activate ansi codes for the command prompt. Only works on Windows!
[ "Activate", "ansi", "codes", "for", "the", "command", "prompt", ".", "Only", "works", "on", "Windows!" ]
def configure(): colors.Ansi.enable_ansi()
[ "def", "configure", "(", ")", ":", "colors", ".", "Ansi", ".", "enable_ansi", "(", ")" ]
Activate ansi codes for the command prompt.
[ "Activate", "ansi", "codes", "for", "the", "command", "prompt", "." ]
[ "\"\"\"\n Activate ansi codes for the command prompt.\n **Only works on Windows!**\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
f57b954f9354519c4eecd4ef2cc2612c2d9fdf4e
Jerem2360/multitools
multi_tools/system/dll.py
[ "Unlicense" ]
Python
HasFunc_NoBody
bool
def HasFunc_NoBody(f: Union[FunctionType, MethodType]) -> bool: """ Return whether f() has not declared a body, in other words, if it does nothing. """ if f.__code__.co_code == b'd\x01S\x00': # bytecode for doc and empty code return True if f.__code__.co_code...
Return whether f() has not declared a body, in other words, if it does nothing.
Return whether f() has not declared a body, in other words, if it does nothing.
[ "Return", "whether", "f", "()", "has", "not", "declared", "a", "body", "in", "other", "words", "if", "it", "does", "nothing", "." ]
def HasFunc_NoBody(f: Union[FunctionType, MethodType]) -> bool: if f.__code__.co_code == b'd\x01S\x00': return True if f.__code__.co_code == b'd\x00S\x00': return True return False
[ "def", "HasFunc_NoBody", "(", "f", ":", "Union", "[", "FunctionType", ",", "MethodType", "]", ")", "->", "bool", ":", "if", "f", ".", "__code__", ".", "co_code", "==", "b'd\\x01S\\x00'", ":", "return", "True", "if", "f", ".", "__code__", ".", "co_code", ...
Return whether f() has not declared a body, in other words, if it does nothing.
[ "Return", "whether", "f", "()", "has", "not", "declared", "a", "body", "in", "other", "words", "if", "it", "does", "nothing", "." ]
[ "\"\"\"\n Return whether f() has not declared a body,\n in other words, if it does nothing.\n \"\"\"", "# bytecode for doc and empty code", "# bytecode for empty code" ]
[ { "param": "f", "type": "Union[FunctionType, MethodType]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "f", "type": "Union[FunctionType, MethodType]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f57b954f9354519c4eecd4ef2cc2612c2d9fdf4e
Jerem2360/multitools
multi_tools/system/dll.py
[ "Unlicense" ]
Python
DllImport
<not_specific>
def DllImport(func: Union[FunctionType, MethodType], file: Union[str, PathLike], type_: type[Dll.AnyDll] = Dll.WinDll): """ Function decorator that implements dll functions with custom type hints and documentation. This method is similar to the C# method System.Runtime.InteropServices.DllImport(). ...
Function decorator that implements dll functions with custom type hints and documentation. This method is similar to the C# method System.Runtime.InteropServices.DllImport(). Decorated functions must have not declared any body and have the name of the wanted dll's function. e.g: class M...
Function decorator that implements dll functions with custom type hints and documentation. This method is similar to the C# method System.Runtime.InteropServices.DllImport(). Decorated functions must have not declared any body and have the name of the wanted dll's function. >>a Decorated functions can't take ...
[ "Function", "decorator", "that", "implements", "dll", "functions", "with", "custom", "type", "hints", "and", "documentation", ".", "This", "method", "is", "similar", "to", "the", "C#", "method", "System", ".", "Runtime", ".", "InteropServices", ".", "DllImport",...
def DllImport(func: Union[FunctionType, MethodType], file: Union[str, PathLike], type_: type[Dll.AnyDll] = Dll.WinDll): dll = Dll(file, type_) name = func.__name__ dll_name = file.split('/')[-1] if not hasattr(dll, name): raise AttributeError("Dll \"{0}\" has no function named \"{1}\".".format(d...
[ "def", "DllImport", "(", "func", ":", "Union", "[", "FunctionType", ",", "MethodType", "]", ",", "file", ":", "Union", "[", "str", ",", "PathLike", "]", ",", "type_", ":", "type", "[", "Dll", ".", "AnyDll", "]", "=", "Dll", ".", "WinDll", ")", ":",...
Function decorator that implements dll functions with custom type hints and documentation.
[ "Function", "decorator", "that", "implements", "dll", "functions", "with", "custom", "type", "hints", "and", "documentation", "." ]
[ "\"\"\"\n Function decorator that implements dll functions\n with custom type hints and documentation.\n\n This method is similar to the C# method System.Runtime.InteropServices.DllImport().\n\n Decorated functions must have not declared any body\n and have the name of the wanted dll's function.\n\n ...
[ { "param": "func", "type": "Union[FunctionType, MethodType]" }, { "param": "file", "type": "Union[str, PathLike]" }, { "param": "type_", "type": "type[Dll.AnyDll]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "func", "type": "Union[FunctionType, MethodType]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "file", "type": "Union[str, PathLike]", ...
e0d9c75d06fb6d1c0c5d7feaad0f6240cb344e49
Jerem2360/multitools
multi_tools/system/registry.py
[ "Unlicense" ]
Python
name
<not_specific>
def name(self): """ Get a string representing the name of the key. """ return self._names[self._value]
Get a string representing the name of the key.
Get a string representing the name of the key.
[ "Get", "a", "string", "representing", "the", "name", "of", "the", "key", "." ]
def name(self): return self._names[self._value]
[ "def", "name", "(", "self", ")", ":", "return", "self", ".", "_names", "[", "self", ".", "_value", "]" ]
Get a string representing the name of the key.
[ "Get", "a", "string", "representing", "the", "name", "of", "the", "key", "." ]
[ "\"\"\"\n Get a string representing the name of the key.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
99795d60a58ba6ffe33455cb163f02ce1940ea30
Jerem2360/multitools
multi_tools/stdio/text_io.py
[ "Unlicense" ]
Python
configure
null
def configure(self, new_target: str or TextIOWrapper): """ Changes the file on which the IO stream points for new_target. As the above '@final' suggests, this method isn't overrideable. """ self.__redirect__(new_target)
Changes the file on which the IO stream points for new_target. As the above '@final' suggests, this method isn't overrideable.
Changes the file on which the IO stream points for new_target. As the above '@final' suggests, this method isn't overrideable.
[ "Changes", "the", "file", "on", "which", "the", "IO", "stream", "points", "for", "new_target", ".", "As", "the", "above", "'", "@final", "'", "suggests", "this", "method", "isn", "'", "t", "overrideable", "." ]
def configure(self, new_target: str or TextIOWrapper): self.__redirect__(new_target)
[ "def", "configure", "(", "self", ",", "new_target", ":", "str", "or", "TextIOWrapper", ")", ":", "self", ".", "__redirect__", "(", "new_target", ")" ]
Changes the file on which the IO stream points for new_target.
[ "Changes", "the", "file", "on", "which", "the", "IO", "stream", "points", "for", "new_target", "." ]
[ "\"\"\"\n Changes the file on which the IO stream points for new_target.\n As the above '@final' suggests, this method isn't\n overrideable.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "new_target", "type": "str or TextIOWrapper" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "new_target", "type": "str or TextIOWrapper", "docstring": null, ...
615e013be5ceb2effa70d19bd9715c9a72048003
Jerem2360/multitools
multi_tools/math/geometry/vector.py
[ "Unlicense" ]
Python
_dot_product
Union[int, float]
def _dot_product(self, other) -> Union[int, float]: """ The dot product between two vectors, here it's self and other. """ return (self._coordinates[0] * other.x) + (self._coordinates[1] * other.y)
The dot product between two vectors, here it's self and other.
The dot product between two vectors, here it's self and other.
[ "The", "dot", "product", "between", "two", "vectors", "here", "it", "'", "s", "self", "and", "other", "." ]
def _dot_product(self, other) -> Union[int, float]: return (self._coordinates[0] * other.x) + (self._coordinates[1] * other.y)
[ "def", "_dot_product", "(", "self", ",", "other", ")", "->", "Union", "[", "int", ",", "float", "]", ":", "return", "(", "self", ".", "_coordinates", "[", "0", "]", "*", "other", ".", "x", ")", "+", "(", "self", ".", "_coordinates", "[", "1", "]"...
The dot product between two vectors, here it's self and other.
[ "The", "dot", "product", "between", "two", "vectors", "here", "it", "'", "s", "self", "and", "other", "." ]
[ "\"\"\"\n The dot product between two vectors, here it's self and other.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "other", "type": null, "docstring": null, "docstring_tokens": ...
615e013be5ceb2effa70d19bd9715c9a72048003
Jerem2360/multitools
multi_tools/math/geometry/vector.py
[ "Unlicense" ]
Python
_product
__class__
def _product(self, item) -> __class__: """ The product between a vector and a real number, here it's self and item """ x = item * self._coordinates[0] y = item * self._coordinates[1] return Vector2D(x, y)
The product between a vector and a real number, here it's self and item
The product between a vector and a real number, here it's self and item
[ "The", "product", "between", "a", "vector", "and", "a", "real", "number", "here", "it", "'", "s", "self", "and", "item" ]
def _product(self, item) -> __class__: x = item * self._coordinates[0] y = item * self._coordinates[1] return Vector2D(x, y)
[ "def", "_product", "(", "self", ",", "item", ")", "->", "__class__", ":", "x", "=", "item", "*", "self", ".", "_coordinates", "[", "0", "]", "y", "=", "item", "*", "self", ".", "_coordinates", "[", "1", "]", "return", "Vector2D", "(", "x", ",", "...
The product between a vector and a real number, here it's self and item
[ "The", "product", "between", "a", "vector", "and", "a", "real", "number", "here", "it", "'", "s", "self", "and", "item" ]
[ "\"\"\"\n The product between a vector and a real number, here it's self and item\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "item", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "item", "type": null, "docstring": null, "docstring_tokens": [...
d7a219bac57714fa3564842fe1520c21cc0e7970
Jerem2360/multitools
multi_tools/math/geometrical.py
[ "Unlicense" ]
Python
_dot_product
<not_specific>
def _dot_product(self, other): """ The dot product between two vectors, here it's self and other. """ return (self._coordinates[0] * other.x) + (self._coordinates[1] * other.y)
The dot product between two vectors, here it's self and other.
The dot product between two vectors, here it's self and other.
[ "The", "dot", "product", "between", "two", "vectors", "here", "it", "'", "s", "self", "and", "other", "." ]
def _dot_product(self, other): return (self._coordinates[0] * other.x) + (self._coordinates[1] * other.y)
[ "def", "_dot_product", "(", "self", ",", "other", ")", ":", "return", "(", "self", ".", "_coordinates", "[", "0", "]", "*", "other", ".", "x", ")", "+", "(", "self", ".", "_coordinates", "[", "1", "]", "*", "other", ".", "y", ")" ]
The dot product between two vectors, here it's self and other.
[ "The", "dot", "product", "between", "two", "vectors", "here", "it", "'", "s", "self", "and", "other", "." ]
[ "\"\"\"\n The dot product between two vectors, here it's self and other.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "other", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "other", "type": null, "docstring": null, "docstring_tokens": ...
d7a219bac57714fa3564842fe1520c21cc0e7970
Jerem2360/multitools
multi_tools/math/geometrical.py
[ "Unlicense" ]
Python
_product
<not_specific>
def _product(self, item): """ The product between a vector and a real number, here it's self and item """ x = item * self._coordinates[0] y = item * self._coordinates[1] return Vector2D(x, y)
The product between a vector and a real number, here it's self and item
The product between a vector and a real number, here it's self and item
[ "The", "product", "between", "a", "vector", "and", "a", "real", "number", "here", "it", "'", "s", "self", "and", "item" ]
def _product(self, item): x = item * self._coordinates[0] y = item * self._coordinates[1] return Vector2D(x, y)
[ "def", "_product", "(", "self", ",", "item", ")", ":", "x", "=", "item", "*", "self", ".", "_coordinates", "[", "0", "]", "y", "=", "item", "*", "self", ".", "_coordinates", "[", "1", "]", "return", "Vector2D", "(", "x", ",", "y", ")" ]
The product between a vector and a real number, here it's self and item
[ "The", "product", "between", "a", "vector", "and", "a", "real", "number", "here", "it", "'", "s", "self", "and", "item" ]
[ "\"\"\"\n The product between a vector and a real number, here it's self and item\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "item", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "item", "type": null, "docstring": null, "docstring_tokens": [...
7788573c5dd59c498bba9f2dd9e848cf819c0956
Jerem2360/multitools
multi_tools/graphical/_user32_impl.py
[ "Unlicense" ]
Python
CreateWindowExA
HWND
def CreateWindowExA(dwExStyle: DWORD, lpClassName: str, lpWindowName: str, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID) -> HWND: """ Create and return a new HWND window handle. Return...
Create and return a new HWND window handle. Return None upon failure.
Create and return a new HWND window handle. Return None upon failure.
[ "Create", "and", "return", "a", "new", "HWND", "window", "handle", ".", "Return", "None", "upon", "failure", "." ]
def CreateWindowExA(dwExStyle: DWORD, lpClassName: str, lpWindowName: str, dwStyle: DWORD, X: int, Y: int, nWidth: int, nHeight: int, hWndParent: HWND, hMenu: HMENU, hInstance: HINSTANCE, lpParam: LPVOID) -> HWND:
[ "def", "CreateWindowExA", "(", "dwExStyle", ":", "DWORD", ",", "lpClassName", ":", "str", ",", "lpWindowName", ":", "str", ",", "dwStyle", ":", "DWORD", ",", "X", ":", "int", ",", "Y", ":", "int", ",", "nWidth", ":", "int", ",", "nHeight", ":", "int"...
Create and return a new HWND window handle.
[ "Create", "and", "return", "a", "new", "HWND", "window", "handle", "." ]
[ "\"\"\"\n Create and return a new HWND window handle.\n Return None upon failure.\n \"\"\"" ]
[ { "param": "dwExStyle", "type": "DWORD" }, { "param": "lpClassName", "type": "str" }, { "param": "lpWindowName", "type": "str" }, { "param": "dwStyle", "type": "DWORD" }, { "param": "X", "type": "int" }, { "param": "Y", "type": "int" }, { "...
{ "returns": [], "raises": [], "params": [ { "identifier": "dwExStyle", "type": "DWORD", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "lpClassName", "type": "str", "docstring": null, "docs...
425e4b8c7a6eca27d972110d5f0d8b0625479acd
Jerem2360/multitools
multi_tools/math/geometry/bases.py
[ "Unlicense" ]
Python
typename
<not_specific>
def typename(obj): """ Get the string name of a type. """ return eval("type(obj).__name__", {'obj': obj, **globals()}, locals())
Get the string name of a type.
Get the string name of a type.
[ "Get", "the", "string", "name", "of", "a", "type", "." ]
def typename(obj): return eval("type(obj).__name__", {'obj': obj, **globals()}, locals())
[ "def", "typename", "(", "obj", ")", ":", "return", "eval", "(", "\"type(obj).__name__\"", ",", "{", "'obj'", ":", "obj", ",", "**", "globals", "(", ")", "}", ",", "locals", "(", ")", ")" ]
Get the string name of a type.
[ "Get", "the", "string", "name", "of", "a", "type", "." ]
[ "\"\"\"\n Get the string name of a type.\n \"\"\"" ]
[ { "param": "obj", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "obj", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07df424cc07e2e9e400d7f10a47f808b923d80b6
Jerem2360/multitools
multi_tools/file_io.py
[ "Unlicense" ]
Python
file
<not_specific>
def file(file_: str): """ Open file <file_> for reading and writing, without the system considering it as open by the actual process. """ return text_io.TextIO(file_)
Open file <file_> for reading and writing, without the system considering it as open by the actual process.
Open file for reading and writing, without the system considering it as open by the actual process.
[ "Open", "file", "for", "reading", "and", "writing", "without", "the", "system", "considering", "it", "as", "open", "by", "the", "actual", "process", "." ]
def file(file_: str): return text_io.TextIO(file_)
[ "def", "file", "(", "file_", ":", "str", ")", ":", "return", "text_io", ".", "TextIO", "(", "file_", ")" ]
Open file <file_> for reading and writing, without the system considering it as open by the actual process.
[ "Open", "file", "<file_", ">", "for", "reading", "and", "writing", "without", "the", "system", "considering", "it", "as", "open", "by", "the", "actual", "process", "." ]
[ "\"\"\"\n Open file <file_> for reading and writing,\n without the system considering it as open by\n the actual process.\n \"\"\"" ]
[ { "param": "file_", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file_", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
07df424cc07e2e9e400d7f10a47f808b923d80b6
Jerem2360/multitools
multi_tools/file_io.py
[ "Unlicense" ]
Python
nfile
null
def nfile(path: str): """ Create a new file as per path <path>. """ try: x = open(path, mode="x") x.close() except: raise
Create a new file as per path <path>.
Create a new file as per path .
[ "Create", "a", "new", "file", "as", "per", "path", "." ]
def nfile(path: str): try: x = open(path, mode="x") x.close() except: raise
[ "def", "nfile", "(", "path", ":", "str", ")", ":", "try", ":", "x", "=", "open", "(", "path", ",", "mode", "=", "\"x\"", ")", "x", ".", "close", "(", ")", "except", ":", "raise" ]
Create a new file as per path <path>.
[ "Create", "a", "new", "file", "as", "per", "path", "<path", ">", "." ]
[ "\"\"\"\n Create a new file as per path <path>.\n \"\"\"" ]
[ { "param": "path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e171fe21b3ce8f19d9219d2b46adeda064558e92
Jerem2360/multitools
multi_tools/console/io.py
[ "Unlicense" ]
Python
apply_ansi
null
def apply_ansi(self, code: colors.CustomAnsiObject): """ Apply a CustomAnsiObject to the console. """ self.write(f"\033[{code.code}m")
Apply a CustomAnsiObject to the console.
Apply a CustomAnsiObject to the console.
[ "Apply", "a", "CustomAnsiObject", "to", "the", "console", "." ]
def apply_ansi(self, code: colors.CustomAnsiObject): self.write(f"\033[{code.code}m")
[ "def", "apply_ansi", "(", "self", ",", "code", ":", "colors", ".", "CustomAnsiObject", ")", ":", "self", ".", "write", "(", "f\"\\033[{code.code}m\"", ")" ]
Apply a CustomAnsiObject to the console.
[ "Apply", "a", "CustomAnsiObject", "to", "the", "console", "." ]
[ "\"\"\"\n Apply a CustomAnsiObject to the console.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "code", "type": "colors.CustomAnsiObject" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "code", "type": "colors.CustomAnsiObject", "docstring": null, ...
e171fe21b3ce8f19d9219d2b46adeda064558e92
Jerem2360/multitools
multi_tools/console/io.py
[ "Unlicense" ]
Python
printf
null
def printf(text: bytes): """ A C version of print(): prints bytes to the console. """ pass
A C version of print(): prints bytes to the console.
A C version of print(): prints bytes to the console.
[ "A", "C", "version", "of", "print", "()", ":", "prints", "bytes", "to", "the", "console", "." ]
def printf(text: bytes): pass
[ "def", "printf", "(", "text", ":", "bytes", ")", ":", "pass" ]
A C version of print(): prints bytes to the console.
[ "A", "C", "version", "of", "print", "()", ":", "prints", "bytes", "to", "the", "console", "." ]
[ "\"\"\"\n A C version of print(): prints bytes to the console.\n \"\"\"" ]
[ { "param": "text", "type": "bytes" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": "bytes", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
e171fe21b3ce8f19d9219d2b46adeda064558e92
Jerem2360/multitools
multi_tools/console/io.py
[ "Unlicense" ]
Python
printb
null
def printb(*args, sep: str = ' ', end: str = '\n'): """ A more optimized version of print(). """ text = "" counter = 0 for word in args: word = str(word) text += word if counter < (len(args) - 1): text += sep text += end _Msvcrt.printf(bytes(text))
A more optimized version of print().
A more optimized version of print().
[ "A", "more", "optimized", "version", "of", "print", "()", "." ]
def printb(*args, sep: str = ' ', end: str = '\n'): text = "" counter = 0 for word in args: word = str(word) text += word if counter < (len(args) - 1): text += sep text += end _Msvcrt.printf(bytes(text))
[ "def", "printb", "(", "*", "args", ",", "sep", ":", "str", "=", "' '", ",", "end", ":", "str", "=", "'\\n'", ")", ":", "text", "=", "\"\"", "counter", "=", "0", "for", "word", "in", "args", ":", "word", "=", "str", "(", "word", ")", "text", "...
A more optimized version of print().
[ "A", "more", "optimized", "version", "of", "print", "()", "." ]
[ "\"\"\"\n A more optimized version of print().\n\n \"\"\"" ]
[ { "param": "sep", "type": "str" }, { "param": "end", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "sep", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "end", "type": "str", "docstring": null, "docstring_tokens": [...
45f5a90a02f248e4cb1d9d2b482dcab40ea6da77
Jerem2360/multitools
multi_tools/system/env.py
[ "Unlicense" ]
Python
module_installed
<not_specific>
def module_installed(module: str): """ Search for module and return whether it exists. """ if util.find_spec(module) is not None: return True return False
Search for module and return whether it exists.
Search for module and return whether it exists.
[ "Search", "for", "module", "and", "return", "whether", "it", "exists", "." ]
def module_installed(module: str): if util.find_spec(module) is not None: return True return False
[ "def", "module_installed", "(", "module", ":", "str", ")", ":", "if", "util", ".", "find_spec", "(", "module", ")", "is", "not", "None", ":", "return", "True", "return", "False" ]
Search for module and return whether it exists.
[ "Search", "for", "module", "and", "return", "whether", "it", "exists", "." ]
[ "\"\"\"\n Search for module and return whether it exists.\n \"\"\"" ]
[ { "param": "module", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "module", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6d3883cc0a4afff9df064ad9fd97bcdc8fff4cd6
Jerem2360/multitools
multi_tools/console/colors.py
[ "Unlicense" ]
Python
enable_ansi
null
def enable_ansi(self): """ Enable ansi codes for the command prompt (the console). **Only works on Windows** """ if sys.platform == "win32": self.enabled = True import ctypes kernel32 = ctypes.WinDLL('kernel32') hStdOut = kernel32.G...
Enable ansi codes for the command prompt (the console). **Only works on Windows**
Enable ansi codes for the command prompt (the console). Only works on Windows
[ "Enable", "ansi", "codes", "for", "the", "command", "prompt", "(", "the", "console", ")", ".", "Only", "works", "on", "Windows" ]
def enable_ansi(self): if sys.platform == "win32": self.enabled = True import ctypes kernel32 = ctypes.WinDLL('kernel32') hStdOut = kernel32.GetStdHandle(-11) mode = ctypes.c_ulong() kernel32.GetConsoleMode(hStdOut, ctypes.byref(mode)) ...
[ "def", "enable_ansi", "(", "self", ")", ":", "if", "sys", ".", "platform", "==", "\"win32\"", ":", "self", ".", "enabled", "=", "True", "import", "ctypes", "kernel32", "=", "ctypes", ".", "WinDLL", "(", "'kernel32'", ")", "hStdOut", "=", "kernel32", ".",...
Enable ansi codes for the command prompt (the console).
[ "Enable", "ansi", "codes", "for", "the", "command", "prompt", "(", "the", "console", ")", "." ]
[ "\"\"\"\n Enable ansi codes for the command prompt (the console).\n **Only works on Windows**\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }