id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
225,500
danielfrg/word2vec
word2vec/wordvectors.py
WordVectors.from_text
def from_text(cls, fname, vocabUnicodeSize=78, desired_vocab=None, encoding="utf-8"): """ Create a WordVectors class based on a word2vec text file Parameters ---------- fname : path to file vocabUnicodeSize: the maximum string length (78, by default) desired_voca...
python
def from_text(cls, fname, vocabUnicodeSize=78, desired_vocab=None, encoding="utf-8"): """ Create a WordVectors class based on a word2vec text file Parameters ---------- fname : path to file vocabUnicodeSize: the maximum string length (78, by default) desired_voca...
[ "def", "from_text", "(", "cls", ",", "fname", ",", "vocabUnicodeSize", "=", "78", ",", "desired_vocab", "=", "None", ",", "encoding", "=", "\"utf-8\"", ")", ":", "with", "open", "(", "fname", ",", "\"rb\"", ")", "as", "fin", ":", "header", "=", "fin", ...
Create a WordVectors class based on a word2vec text file Parameters ---------- fname : path to file vocabUnicodeSize: the maximum string length (78, by default) desired_vocab: if set, this will ignore any word and vector that doesn't fall inside desired_vo...
[ "Create", "a", "WordVectors", "class", "based", "on", "a", "word2vec", "text", "file" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordvectors.py#L233-L267
225,501
danielfrg/word2vec
word2vec/wordvectors.py
WordVectors.from_mmap
def from_mmap(cls, fname): """ Create a WordVectors class from a memory map Parameters ---------- fname : path to file Returns ------- WordVectors instance """ memmaped = joblib.load(fname, mmap_mode="r+") return cls(vocab=memmape...
python
def from_mmap(cls, fname): """ Create a WordVectors class from a memory map Parameters ---------- fname : path to file Returns ------- WordVectors instance """ memmaped = joblib.load(fname, mmap_mode="r+") return cls(vocab=memmape...
[ "def", "from_mmap", "(", "cls", ",", "fname", ")", ":", "memmaped", "=", "joblib", ".", "load", "(", "fname", ",", "mmap_mode", "=", "\"r+\"", ")", "return", "cls", "(", "vocab", "=", "memmaped", ".", "vocab", ",", "vectors", "=", "memmaped", ".", "v...
Create a WordVectors class from a memory map Parameters ---------- fname : path to file Returns ------- WordVectors instance
[ "Create", "a", "WordVectors", "class", "from", "a", "memory", "map" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/wordvectors.py#L270-L283
225,502
danielfrg/word2vec
word2vec/utils.py
distance
def distance(a, b, metric="cosine"): """ Calculate distance between two vectors based on a Metric Metrics: 1. cosine distance. Note that in word2vec all the norms are 1 so the dot product is the same as cosine distance """ if metric == "cosine": return np.dot(a, b.T) raise Exception...
python
def distance(a, b, metric="cosine"): """ Calculate distance between two vectors based on a Metric Metrics: 1. cosine distance. Note that in word2vec all the norms are 1 so the dot product is the same as cosine distance """ if metric == "cosine": return np.dot(a, b.T) raise Exception...
[ "def", "distance", "(", "a", ",", "b", ",", "metric", "=", "\"cosine\"", ")", ":", "if", "metric", "==", "\"cosine\"", ":", "return", "np", ".", "dot", "(", "a", ",", "b", ".", "T", ")", "raise", "Exception", "(", "\"Unknown metric '{metric}'\"", ".", ...
Calculate distance between two vectors based on a Metric Metrics: 1. cosine distance. Note that in word2vec all the norms are 1 so the dot product is the same as cosine distance
[ "Calculate", "distance", "between", "two", "vectors", "based", "on", "a", "Metric" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/utils.py#L8-L17
225,503
danielfrg/word2vec
word2vec/io.py
load
def load(fname, kind="auto", *args, **kwargs): """ Loads a word vectors file """ if kind == "auto": if fname.endswith(".bin"): kind = "bin" elif fname.endswith(".txt"): kind = "txt" else: raise Exception("Could not identify kind") if kind =...
python
def load(fname, kind="auto", *args, **kwargs): """ Loads a word vectors file """ if kind == "auto": if fname.endswith(".bin"): kind = "bin" elif fname.endswith(".txt"): kind = "txt" else: raise Exception("Could not identify kind") if kind =...
[ "def", "load", "(", "fname", ",", "kind", "=", "\"auto\"", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kind", "==", "\"auto\"", ":", "if", "fname", ".", "endswith", "(", "\".bin\"", ")", ":", "kind", "=", "\"bin\"", "elif", "fname",...
Loads a word vectors file
[ "Loads", "a", "word", "vectors", "file" ]
762200acec2941a030abed69e946838af35eb2ae
https://github.com/danielfrg/word2vec/blob/762200acec2941a030abed69e946838af35eb2ae/word2vec/io.py#L4-L22
225,504
django-crispy-forms/django-crispy-forms
crispy_forms/templatetags/crispy_forms_tags.py
ForLoopSimulator.iterate
def iterate(self): """ Updates values as if we had iterated over the for """ self.counter += 1 self.counter0 += 1 self.revcounter -= 1 self.revcounter0 -= 1 self.first = False self.last = (self.revcounter0 == self.len_values - 1)
python
def iterate(self): """ Updates values as if we had iterated over the for """ self.counter += 1 self.counter0 += 1 self.revcounter -= 1 self.revcounter0 -= 1 self.first = False self.last = (self.revcounter0 == self.len_values - 1)
[ "def", "iterate", "(", "self", ")", ":", "self", ".", "counter", "+=", "1", "self", ".", "counter0", "+=", "1", "self", ".", "revcounter", "-=", "1", "self", ".", "revcounter0", "-=", "1", "self", ".", "first", "=", "False", "self", ".", "last", "=...
Updates values as if we had iterated over the for
[ "Updates", "values", "as", "if", "we", "had", "iterated", "over", "the", "for" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/templatetags/crispy_forms_tags.py#L43-L52
225,505
django-crispy-forms/django-crispy-forms
crispy_forms/templatetags/crispy_forms_tags.py
BasicNode.get_render
def get_render(self, context): """ Returns a `Context` object with all the necessary stuff for rendering the form :param context: `django.template.Context` variable holding the context for the node `self.form` and `self.helper` are resolved into real Python objects resolving them ...
python
def get_render(self, context): """ Returns a `Context` object with all the necessary stuff for rendering the form :param context: `django.template.Context` variable holding the context for the node `self.form` and `self.helper` are resolved into real Python objects resolving them ...
[ "def", "get_render", "(", "self", ",", "context", ")", ":", "# Nodes are not thread safe in multithreaded environments", "# https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#thread-safety-considerations", "if", "self", "not", "in", "context", ".", "render_context", ...
Returns a `Context` object with all the necessary stuff for rendering the form :param context: `django.template.Context` variable holding the context for the node `self.form` and `self.helper` are resolved into real Python objects resolving them from the `context`. The `actual_form` can be a f...
[ "Returns", "a", "Context", "object", "with", "all", "the", "necessary", "stuff", "for", "rendering", "the", "form" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/templatetags/crispy_forms_tags.py#L71-L133
225,506
django-crispy-forms/django-crispy-forms
crispy_forms/templatetags/crispy_forms_utils.py
specialspaceless
def specialspaceless(parser, token): """ Removes whitespace between HTML tags, and introduces a whitespace after buttons an inputs, necessary for Bootstrap to place them correctly in the layout. """ nodelist = parser.parse(('endspecialspaceless',)) parser.delete_first_token() return Spe...
python
def specialspaceless(parser, token): """ Removes whitespace between HTML tags, and introduces a whitespace after buttons an inputs, necessary for Bootstrap to place them correctly in the layout. """ nodelist = parser.parse(('endspecialspaceless',)) parser.delete_first_token() return Spe...
[ "def", "specialspaceless", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "'endspecialspaceless'", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "SpecialSpacelessNode", "(", "nodelist", ")" ]
Removes whitespace between HTML tags, and introduces a whitespace after buttons an inputs, necessary for Bootstrap to place them correctly in the layout.
[ "Removes", "whitespace", "between", "HTML", "tags", "and", "introduces", "a", "whitespace", "after", "buttons", "an", "inputs", "necessary", "for", "Bootstrap", "to", "place", "them", "correctly", "in", "the", "layout", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/templatetags/crispy_forms_utils.py#L38-L47
225,507
django-crispy-forms/django-crispy-forms
crispy_forms/bootstrap.py
ContainerHolder.first_container_with_errors
def first_container_with_errors(self, errors): """ Returns the first container with errors, otherwise returns None. """ for tab in self.fields: errors_here = any(error in tab for error in errors) if errors_here: return tab return None
python
def first_container_with_errors(self, errors): """ Returns the first container with errors, otherwise returns None. """ for tab in self.fields: errors_here = any(error in tab for error in errors) if errors_here: return tab return None
[ "def", "first_container_with_errors", "(", "self", ",", "errors", ")", ":", "for", "tab", "in", "self", ".", "fields", ":", "errors_here", "=", "any", "(", "error", "in", "tab", "for", "error", "in", "errors", ")", "if", "errors_here", ":", "return", "ta...
Returns the first container with errors, otherwise returns None.
[ "Returns", "the", "first", "container", "with", "errors", "otherwise", "returns", "None", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/bootstrap.py#L230-L238
225,508
django-crispy-forms/django-crispy-forms
crispy_forms/bootstrap.py
ContainerHolder.open_target_group_for_form
def open_target_group_for_form(self, form): """ Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False. """ target = se...
python
def open_target_group_for_form(self, form): """ Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False. """ target = se...
[ "def", "open_target_group_for_form", "(", "self", ",", "form", ")", ":", "target", "=", "self", ".", "first_container_with_errors", "(", "form", ".", "errors", ".", "keys", "(", ")", ")", "if", "target", "is", "None", ":", "target", "=", "self", ".", "fi...
Makes sure that the first group that should be open is open. This is either the first group with errors or the first group in the container, unless that first group was originally set to active=False.
[ "Makes", "sure", "that", "the", "first", "group", "that", "should", "be", "open", "is", "open", ".", "This", "is", "either", "the", "first", "group", "with", "errors", "or", "the", "first", "group", "in", "the", "container", "unless", "that", "first", "g...
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/bootstrap.py#L240-L255
225,509
django-crispy-forms/django-crispy-forms
crispy_forms/bootstrap.py
Tab.render_link
def render_link(self, template_pack=TEMPLATE_PACK, **kwargs): """ Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed. """ link_template = self.link_template % template_pack return render_to_string(link_template, ...
python
def render_link(self, template_pack=TEMPLATE_PACK, **kwargs): """ Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed. """ link_template = self.link_template % template_pack return render_to_string(link_template, ...
[ "def", "render_link", "(", "self", ",", "template_pack", "=", "TEMPLATE_PACK", ",", "*", "*", "kwargs", ")", ":", "link_template", "=", "self", ".", "link_template", "%", "template_pack", "return", "render_to_string", "(", "link_template", ",", "{", "'link'", ...
Render the link for the tab-pane. It must be called after render so css_class is updated with active if needed.
[ "Render", "the", "link", "for", "the", "tab", "-", "pane", ".", "It", "must", "be", "called", "after", "render", "so", "css_class", "is", "updated", "with", "active", "if", "needed", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/bootstrap.py#L268-L274
225,510
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.wrapped_object
def wrapped_object(self, LayoutClass, fields, *args, **kwargs): """ Returns a layout object of type `LayoutClass` with `args` and `kwargs` that wraps `fields` inside. """ if args: if isinstance(fields, list): fields = tuple(fields) else: ...
python
def wrapped_object(self, LayoutClass, fields, *args, **kwargs): """ Returns a layout object of type `LayoutClass` with `args` and `kwargs` that wraps `fields` inside. """ if args: if isinstance(fields, list): fields = tuple(fields) else: ...
[ "def", "wrapped_object", "(", "self", ",", "LayoutClass", ",", "fields", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", ":", "if", "isinstance", "(", "fields", ",", "list", ")", ":", "fields", "=", "tuple", "(", "fields", ")", "...
Returns a layout object of type `LayoutClass` with `args` and `kwargs` that wraps `fields` inside.
[ "Returns", "a", "layout", "object", "of", "type", "LayoutClass", "with", "args", "and", "kwargs", "that", "wraps", "fields", "inside", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L19-L40
225,511
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.pre_map
def pre_map(self, function): """ Iterates over layout objects pointed in `self.slice` executing `function` on them. It passes `function` penultimate layout object and the position where to find last one """ if isinstance(self.slice, slice): for i in range(*self.slice....
python
def pre_map(self, function): """ Iterates over layout objects pointed in `self.slice` executing `function` on them. It passes `function` penultimate layout object and the position where to find last one """ if isinstance(self.slice, slice): for i in range(*self.slice....
[ "def", "pre_map", "(", "self", ",", "function", ")", ":", "if", "isinstance", "(", "self", ".", "slice", ",", "slice", ")", ":", "for", "i", "in", "range", "(", "*", "self", ".", "slice", ".", "indices", "(", "len", "(", "self", ".", "layout", "....
Iterates over layout objects pointed in `self.slice` executing `function` on them. It passes `function` penultimate layout object and the position where to find last one
[ "Iterates", "over", "layout", "objects", "pointed", "in", "self", ".", "slice", "executing", "function", "on", "them", ".", "It", "passes", "function", "penultimate", "layout", "object", "and", "the", "position", "where", "to", "find", "last", "one" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L42-L70
225,512
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.wrap
def wrap(self, LayoutClass, *args, **kwargs): """ Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with `args` and `kwargs` passed. """ def wrap_object(layout_object, j): layout_object.fields[j] = self.wrapped_object( La...
python
def wrap(self, LayoutClass, *args, **kwargs): """ Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with `args` and `kwargs` passed. """ def wrap_object(layout_object, j): layout_object.fields[j] = self.wrapped_object( La...
[ "def", "wrap", "(", "self", ",", "LayoutClass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "wrap_object", "(", "layout_object", ",", "j", ")", ":", "layout_object", ".", "fields", "[", "j", "]", "=", "self", ".", "wrapped_object", "(...
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with `args` and `kwargs` passed.
[ "Wraps", "every", "layout", "object", "pointed", "in", "self", ".", "slice", "under", "a", "LayoutClass", "instance", "with", "args", "and", "kwargs", "passed", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L72-L82
225,513
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.wrap_once
def wrap_once(self, LayoutClass, *args, **kwargs): """ Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with `args` and `kwargs` passed, unless layout object's parent is already a subclass of `LayoutClass`. """ def wrap_object_once(layout_o...
python
def wrap_once(self, LayoutClass, *args, **kwargs): """ Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with `args` and `kwargs` passed, unless layout object's parent is already a subclass of `LayoutClass`. """ def wrap_object_once(layout_o...
[ "def", "wrap_once", "(", "self", ",", "LayoutClass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "wrap_object_once", "(", "layout_object", ",", "j", ")", ":", "if", "not", "isinstance", "(", "layout_object", ",", "LayoutClass", ")", ":", ...
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with `args` and `kwargs` passed, unless layout object's parent is already a subclass of `LayoutClass`.
[ "Wraps", "every", "layout", "object", "pointed", "in", "self", ".", "slice", "under", "a", "LayoutClass", "instance", "with", "args", "and", "kwargs", "passed", "unless", "layout", "object", "s", "parent", "is", "already", "a", "subclass", "of", "LayoutClass",...
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L84-L96
225,514
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.wrap_together
def wrap_together(self, LayoutClass, *args, **kwargs): """ Wraps all layout objects pointed in `self.slice` together under a `LayoutClass` instance with `args` and `kwargs` passed. """ if isinstance(self.slice, slice): # The start of the slice is replaced ...
python
def wrap_together(self, LayoutClass, *args, **kwargs): """ Wraps all layout objects pointed in `self.slice` together under a `LayoutClass` instance with `args` and `kwargs` passed. """ if isinstance(self.slice, slice): # The start of the slice is replaced ...
[ "def", "wrap_together", "(", "self", ",", "LayoutClass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "self", ".", "slice", ",", "slice", ")", ":", "# The start of the slice is replaced", "start", "=", "self", ".", "slice",...
Wraps all layout objects pointed in `self.slice` together under a `LayoutClass` instance with `args` and `kwargs` passed.
[ "Wraps", "all", "layout", "objects", "pointed", "in", "self", ".", "slice", "together", "under", "a", "LayoutClass", "instance", "with", "args", "and", "kwargs", "passed", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L98-L116
225,515
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.map
def map(self, function): """ Iterates over layout objects pointed in `self.slice` executing `function` on them It passes `function` last layout object """ if isinstance(self.slice, slice): for i in range(*self.slice.indices(len(self.layout.fields))): f...
python
def map(self, function): """ Iterates over layout objects pointed in `self.slice` executing `function` on them It passes `function` last layout object """ if isinstance(self.slice, slice): for i in range(*self.slice.indices(len(self.layout.fields))): f...
[ "def", "map", "(", "self", ",", "function", ")", ":", "if", "isinstance", "(", "self", ".", "slice", ",", "slice", ")", ":", "for", "i", "in", "range", "(", "*", "self", ".", "slice", ".", "indices", "(", "len", "(", "self", ".", "layout", ".", ...
Iterates over layout objects pointed in `self.slice` executing `function` on them It passes `function` last layout object
[ "Iterates", "over", "layout", "objects", "pointed", "in", "self", ".", "slice", "executing", "function", "on", "them", "It", "passes", "function", "last", "layout", "object" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L118-L144
225,516
django-crispy-forms/django-crispy-forms
crispy_forms/layout_slice.py
LayoutSlice.update_attributes
def update_attributes(self, **original_kwargs): """ Updates attributes of every layout object pointed in `self.slice` using kwargs """ def update_attrs(layout_object): kwargs = original_kwargs.copy() if hasattr(layout_object, 'attrs'): if 'css_clas...
python
def update_attributes(self, **original_kwargs): """ Updates attributes of every layout object pointed in `self.slice` using kwargs """ def update_attrs(layout_object): kwargs = original_kwargs.copy() if hasattr(layout_object, 'attrs'): if 'css_clas...
[ "def", "update_attributes", "(", "self", ",", "*", "*", "original_kwargs", ")", ":", "def", "update_attrs", "(", "layout_object", ")", ":", "kwargs", "=", "original_kwargs", ".", "copy", "(", ")", "if", "hasattr", "(", "layout_object", ",", "'attrs'", ")", ...
Updates attributes of every layout object pointed in `self.slice` using kwargs
[ "Updates", "attributes", "of", "every", "layout", "object", "pointed", "in", "self", ".", "slice", "using", "kwargs" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/layout_slice.py#L146-L160
225,517
django-crispy-forms/django-crispy-forms
crispy_forms/helper.py
DynamicLayoutHandler.all
def all(self): """ Returns all layout objects of first level of depth """ self._check_layout() return LayoutSlice(self.layout, slice(0, len(self.layout.fields), 1))
python
def all(self): """ Returns all layout objects of first level of depth """ self._check_layout() return LayoutSlice(self.layout, slice(0, len(self.layout.fields), 1))
[ "def", "all", "(", "self", ")", ":", "self", ".", "_check_layout", "(", ")", "return", "LayoutSlice", "(", "self", ".", "layout", ",", "slice", "(", "0", ",", "len", "(", "self", ".", "layout", ".", "fields", ")", ",", "1", ")", ")" ]
Returns all layout objects of first level of depth
[ "Returns", "all", "layout", "objects", "of", "first", "level", "of", "depth" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/helper.py#L31-L36
225,518
django-crispy-forms/django-crispy-forms
crispy_forms/helper.py
DynamicLayoutHandler.filter
def filter(self, *LayoutClasses, **kwargs): """ Returns a LayoutSlice pointing to layout objects of type `LayoutClass` """ self._check_layout() max_level = kwargs.pop('max_level', 0) greedy = kwargs.pop('greedy', False) filtered_layout_objects = self.layout.get_la...
python
def filter(self, *LayoutClasses, **kwargs): """ Returns a LayoutSlice pointing to layout objects of type `LayoutClass` """ self._check_layout() max_level = kwargs.pop('max_level', 0) greedy = kwargs.pop('greedy', False) filtered_layout_objects = self.layout.get_la...
[ "def", "filter", "(", "self", ",", "*", "LayoutClasses", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_check_layout", "(", ")", "max_level", "=", "kwargs", ".", "pop", "(", "'max_level'", ",", "0", ")", "greedy", "=", "kwargs", ".", "pop", "(", ...
Returns a LayoutSlice pointing to layout objects of type `LayoutClass`
[ "Returns", "a", "LayoutSlice", "pointing", "to", "layout", "objects", "of", "type", "LayoutClass" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/helper.py#L38-L47
225,519
django-crispy-forms/django-crispy-forms
crispy_forms/helper.py
DynamicLayoutHandler.filter_by_widget
def filter_by_widget(self, widget_type): """ Returns a LayoutSlice pointing to fields with widgets of `widget_type` """ self._check_layout_and_form() layout_field_names = self.layout.get_field_names() # Let's filter all fields with widgets like widget_type filter...
python
def filter_by_widget(self, widget_type): """ Returns a LayoutSlice pointing to fields with widgets of `widget_type` """ self._check_layout_and_form() layout_field_names = self.layout.get_field_names() # Let's filter all fields with widgets like widget_type filter...
[ "def", "filter_by_widget", "(", "self", ",", "widget_type", ")", ":", "self", ".", "_check_layout_and_form", "(", ")", "layout_field_names", "=", "self", ".", "layout", ".", "get_field_names", "(", ")", "# Let's filter all fields with widgets like widget_type", "filtere...
Returns a LayoutSlice pointing to fields with widgets of `widget_type`
[ "Returns", "a", "LayoutSlice", "pointing", "to", "fields", "with", "widgets", "of", "widget_type" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/helper.py#L49-L62
225,520
django-crispy-forms/django-crispy-forms
crispy_forms/helper.py
FormHelper.get_attributes
def get_attributes(self, template_pack=TEMPLATE_PACK): """ Used by crispy_forms_tags to get helper attributes """ items = { 'form_method': self.form_method.strip(), 'form_tag': self.form_tag, 'form_style': self.form_style.strip(), 'form_sho...
python
def get_attributes(self, template_pack=TEMPLATE_PACK): """ Used by crispy_forms_tags to get helper attributes """ items = { 'form_method': self.form_method.strip(), 'form_tag': self.form_tag, 'form_style': self.form_style.strip(), 'form_sho...
[ "def", "get_attributes", "(", "self", ",", "template_pack", "=", "TEMPLATE_PACK", ")", ":", "items", "=", "{", "'form_method'", ":", "self", ".", "form_method", ".", "strip", "(", ")", ",", "'form_tag'", ":", "self", ".", "form_tag", ",", "'form_style'", "...
Used by crispy_forms_tags to get helper attributes
[ "Used", "by", "crispy_forms_tags", "to", "get", "helper", "attributes" ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/helper.py#L353-L421
225,521
django-crispy-forms/django-crispy-forms
crispy_forms/utils.py
flatatt
def flatatt(attrs): """ Convert a dictionary of attributes to a single string. Passed attributes are redirected to `django.forms.utils.flatatt()` with replaced "_" (underscores) by "-" (dashes) in their names. """ return _flatatt({k.replace('_', '-'): v for k, v in attrs.items()})
python
def flatatt(attrs): """ Convert a dictionary of attributes to a single string. Passed attributes are redirected to `django.forms.utils.flatatt()` with replaced "_" (underscores) by "-" (dashes) in their names. """ return _flatatt({k.replace('_', '-'): v for k, v in attrs.items()})
[ "def", "flatatt", "(", "attrs", ")", ":", "return", "_flatatt", "(", "{", "k", ".", "replace", "(", "'_'", ",", "'-'", ")", ":", "v", "for", "k", ",", "v", "in", "attrs", ".", "items", "(", ")", "}", ")" ]
Convert a dictionary of attributes to a single string. Passed attributes are redirected to `django.forms.utils.flatatt()` with replaced "_" (underscores) by "-" (dashes) in their names.
[ "Convert", "a", "dictionary", "of", "attributes", "to", "a", "single", "string", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/utils.py#L153-L160
225,522
django-crispy-forms/django-crispy-forms
crispy_forms/utils.py
render_crispy_form
def render_crispy_form(form, helper=None, context=None): """ Renders a form and returns its HTML output. This function wraps the template logic in a function easy to use in a Django view. """ from crispy_forms.templatetags.crispy_forms_tags import CrispyFormNode if helper is not None: ...
python
def render_crispy_form(form, helper=None, context=None): """ Renders a form and returns its HTML output. This function wraps the template logic in a function easy to use in a Django view. """ from crispy_forms.templatetags.crispy_forms_tags import CrispyFormNode if helper is not None: ...
[ "def", "render_crispy_form", "(", "form", ",", "helper", "=", "None", ",", "context", "=", "None", ")", ":", "from", "crispy_forms", ".", "templatetags", ".", "crispy_forms_tags", "import", "CrispyFormNode", "if", "helper", "is", "not", "None", ":", "node", ...
Renders a form and returns its HTML output. This function wraps the template logic in a function easy to use in a Django view.
[ "Renders", "a", "form", "and", "returns", "its", "HTML", "output", "." ]
cd476927a756133c667c199bb12120f877bf6b7e
https://github.com/django-crispy-forms/django-crispy-forms/blob/cd476927a756133c667c199bb12120f877bf6b7e/crispy_forms/utils.py#L163-L182
225,523
moderngl/moderngl
moderngl/vertex_array.py
VertexArray.bind
def bind(self, attribute, cls, buffer, fmt, *, offset=0, stride=0, divisor=0, normalize=False) -> None: ''' Bind individual attributes to buffers. Args: location (int): The attribute location. cls (str): The attribute class. Valid values are ``f``, ``i`` ...
python
def bind(self, attribute, cls, buffer, fmt, *, offset=0, stride=0, divisor=0, normalize=False) -> None: ''' Bind individual attributes to buffers. Args: location (int): The attribute location. cls (str): The attribute class. Valid values are ``f``, ``i`` ...
[ "def", "bind", "(", "self", ",", "attribute", ",", "cls", ",", "buffer", ",", "fmt", ",", "*", ",", "offset", "=", "0", ",", "stride", "=", "0", ",", "divisor", "=", "0", ",", "normalize", "=", "False", ")", "->", "None", ":", "self", ".", "mgl...
Bind individual attributes to buffers. Args: location (int): The attribute location. cls (str): The attribute class. Valid values are ``f``, ``i`` or ``d``. buffer (Buffer): The buffer. format (str): The buffer format. Keyword Arg...
[ "Bind", "individual", "attributes", "to", "buffers", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/vertex_array.py#L173-L190
225,524
moderngl/moderngl
examples/08_compute_shader.py
source
def source(uri, consts): ''' read gl code ''' with open(uri, 'r') as fp: content = fp.read() # feed constant values for key, value in consts.items(): content = content.replace(f"%%{key}%%", str(value)) return content
python
def source(uri, consts): ''' read gl code ''' with open(uri, 'r') as fp: content = fp.read() # feed constant values for key, value in consts.items(): content = content.replace(f"%%{key}%%", str(value)) return content
[ "def", "source", "(", "uri", ",", "consts", ")", ":", "with", "open", "(", "uri", ",", "'r'", ")", "as", "fp", ":", "content", "=", "fp", ".", "read", "(", ")", "# feed constant values", "for", "key", ",", "value", "in", "consts", ".", "items", "("...
read gl code
[ "read", "gl", "code" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/08_compute_shader.py#L17-L25
225,525
moderngl/moderngl
moderngl/context.py
create_standalone_context
def create_standalone_context(require=None, **settings) -> 'Context': ''' Create a standalone ModernGL context. Example:: # Create a context with highest possible supported version ctx = moderngl.create_context() # Require at least OpenGL 4.3 ctx = ...
python
def create_standalone_context(require=None, **settings) -> 'Context': ''' Create a standalone ModernGL context. Example:: # Create a context with highest possible supported version ctx = moderngl.create_context() # Require at least OpenGL 4.3 ctx = ...
[ "def", "create_standalone_context", "(", "require", "=", "None", ",", "*", "*", "settings", ")", "->", "'Context'", ":", "backend", "=", "os", ".", "environ", ".", "get", "(", "'MODERNGL_BACKEND'", ")", "if", "backend", "is", "not", "None", ":", "settings"...
Create a standalone ModernGL context. Example:: # Create a context with highest possible supported version ctx = moderngl.create_context() # Require at least OpenGL 4.3 ctx = moderngl.create_context(require=430) Keyword Arguments: require (...
[ "Create", "a", "standalone", "ModernGL", "context", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L1135-L1169
225,526
moderngl/moderngl
moderngl/context.py
Context.copy_buffer
def copy_buffer(self, dst, src, size=-1, *, read_offset=0, write_offset=0) -> None: ''' Copy buffer content. Args: dst (Buffer): The destination buffer. src (Buffer): The source buffer. size (int): The number of bytes to copy. ...
python
def copy_buffer(self, dst, src, size=-1, *, read_offset=0, write_offset=0) -> None: ''' Copy buffer content. Args: dst (Buffer): The destination buffer. src (Buffer): The source buffer. size (int): The number of bytes to copy. ...
[ "def", "copy_buffer", "(", "self", ",", "dst", ",", "src", ",", "size", "=", "-", "1", ",", "*", ",", "read_offset", "=", "0", ",", "write_offset", "=", "0", ")", "->", "None", ":", "self", ".", "mglo", ".", "copy_buffer", "(", "dst", ".", "mglo"...
Copy buffer content. Args: dst (Buffer): The destination buffer. src (Buffer): The source buffer. size (int): The number of bytes to copy. Keyword Args: read_offset (int): The read offset. write_offset (int): The w...
[ "Copy", "buffer", "content", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L505-L519
225,527
moderngl/moderngl
moderngl/context.py
Context.copy_framebuffer
def copy_framebuffer(self, dst, src) -> None: ''' Copy framebuffer content. Use this method to: - blit framebuffers. - copy framebuffer content into a texture. - downsample framebuffers. (it will allow to read the framebuffer's content) ...
python
def copy_framebuffer(self, dst, src) -> None: ''' Copy framebuffer content. Use this method to: - blit framebuffers. - copy framebuffer content into a texture. - downsample framebuffers. (it will allow to read the framebuffer's content) ...
[ "def", "copy_framebuffer", "(", "self", ",", "dst", ",", "src", ")", "->", "None", ":", "self", ".", "mglo", ".", "copy_framebuffer", "(", "dst", ".", "mglo", ",", "src", ".", "mglo", ")" ]
Copy framebuffer content. Use this method to: - blit framebuffers. - copy framebuffer content into a texture. - downsample framebuffers. (it will allow to read the framebuffer's content) - downsample a framebuffer directly to a texture. ...
[ "Copy", "framebuffer", "content", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L521-L537
225,528
moderngl/moderngl
moderngl/context.py
Context.detect_framebuffer
def detect_framebuffer(self, glo=None) -> 'Framebuffer': ''' Detect framebuffer. Args: glo (int): Framebuffer object. Returns: :py:class:`Framebuffer` object ''' res = Framebuffer.__new__(Framebuffer) res.mglo, res._s...
python
def detect_framebuffer(self, glo=None) -> 'Framebuffer': ''' Detect framebuffer. Args: glo (int): Framebuffer object. Returns: :py:class:`Framebuffer` object ''' res = Framebuffer.__new__(Framebuffer) res.mglo, res._s...
[ "def", "detect_framebuffer", "(", "self", ",", "glo", "=", "None", ")", "->", "'Framebuffer'", ":", "res", "=", "Framebuffer", ".", "__new__", "(", "Framebuffer", ")", "res", ".", "mglo", ",", "res", ".", "_size", ",", "res", ".", "_samples", ",", "res...
Detect framebuffer. Args: glo (int): Framebuffer object. Returns: :py:class:`Framebuffer` object
[ "Detect", "framebuffer", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L539-L556
225,529
moderngl/moderngl
moderngl/context.py
Context.core_profile_check
def core_profile_check(self) -> None: ''' Core profile check. FOR DEBUG PURPOSES ONLY ''' profile_mask = self.info['GL_CONTEXT_PROFILE_MASK'] if profile_mask != 1: warnings.warn('The window should request a CORE OpenGL profile') version_code...
python
def core_profile_check(self) -> None: ''' Core profile check. FOR DEBUG PURPOSES ONLY ''' profile_mask = self.info['GL_CONTEXT_PROFILE_MASK'] if profile_mask != 1: warnings.warn('The window should request a CORE OpenGL profile') version_code...
[ "def", "core_profile_check", "(", "self", ")", "->", "None", ":", "profile_mask", "=", "self", ".", "info", "[", "'GL_CONTEXT_PROFILE_MASK'", "]", "if", "profile_mask", "!=", "1", ":", "warnings", ".", "warn", "(", "'The window should request a CORE OpenGL profile'"...
Core profile check. FOR DEBUG PURPOSES ONLY
[ "Core", "profile", "check", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/context.py#L1072-L1089
225,530
moderngl/moderngl
examples/window/glfw/window.py
Window.mouse_button_callback
def mouse_button_callback(self, window, button, action, mods): """ Handle mouse button events and forward them to the example """ # Offset button index by 1 to make it match the other libraries button += 1 # Support left and right mouse button for now if bu...
python
def mouse_button_callback(self, window, button, action, mods): """ Handle mouse button events and forward them to the example """ # Offset button index by 1 to make it match the other libraries button += 1 # Support left and right mouse button for now if bu...
[ "def", "mouse_button_callback", "(", "self", ",", "window", ",", "button", ",", "action", ",", "mods", ")", ":", "# Offset button index by 1 to make it match the other libraries\r", "button", "+=", "1", "# Support left and right mouse button for now\r", "if", "button", "not...
Handle mouse button events and forward them to the example
[ "Handle", "mouse", "button", "events", "and", "forward", "them", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/glfw/window.py#L121-L136
225,531
moderngl/moderngl
moderngl/buffer.py
Buffer.write_chunks
def write_chunks(self, data, start, step, count) -> None: ''' Split data to count equal parts. Write the chunks using offsets calculated from start, step and stop. Args: data (bytes): The data. start (int): First offset. step ...
python
def write_chunks(self, data, start, step, count) -> None: ''' Split data to count equal parts. Write the chunks using offsets calculated from start, step and stop. Args: data (bytes): The data. start (int): First offset. step ...
[ "def", "write_chunks", "(", "self", ",", "data", ",", "start", ",", "step", ",", "count", ")", "->", "None", ":", "self", ".", "mglo", ".", "write_chunks", "(", "data", ",", "start", ",", "step", ",", "count", ")" ]
Split data to count equal parts. Write the chunks using offsets calculated from start, step and stop. Args: data (bytes): The data. start (int): First offset. step (int): Offset increment. count (int): The number of offsets.
[ "Split", "data", "to", "count", "equal", "parts", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/buffer.py#L72-L85
225,532
moderngl/moderngl
moderngl/buffer.py
Buffer.read_into
def read_into(self, buffer, size=-1, *, offset=0, write_offset=0) -> None: ''' Read the content into a buffer. Args: buffer (bytarray): The buffer that will receive the content. size (int): The size. Value ``-1`` means all. Keyword Args: ...
python
def read_into(self, buffer, size=-1, *, offset=0, write_offset=0) -> None: ''' Read the content into a buffer. Args: buffer (bytarray): The buffer that will receive the content. size (int): The size. Value ``-1`` means all. Keyword Args: ...
[ "def", "read_into", "(", "self", ",", "buffer", ",", "size", "=", "-", "1", ",", "*", ",", "offset", "=", "0", ",", "write_offset", "=", "0", ")", "->", "None", ":", "return", "self", ".", "mglo", ".", "read_into", "(", "buffer", ",", "size", ","...
Read the content into a buffer. Args: buffer (bytarray): The buffer that will receive the content. size (int): The size. Value ``-1`` means all. Keyword Args: offset (int): The read offset. write_offset (int): The write offset.
[ "Read", "the", "content", "into", "a", "buffer", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/buffer.py#L103-L116
225,533
moderngl/moderngl
moderngl/buffer.py
Buffer.clear
def clear(self, size=-1, *, offset=0, chunk=None) -> None: ''' Clear the content. Args: size (int): The size. Value ``-1`` means all. Keyword Args: offset (int): The offset. chunk (bytes): The chunk to use repeatedly. ...
python
def clear(self, size=-1, *, offset=0, chunk=None) -> None: ''' Clear the content. Args: size (int): The size. Value ``-1`` means all. Keyword Args: offset (int): The offset. chunk (bytes): The chunk to use repeatedly. ...
[ "def", "clear", "(", "self", ",", "size", "=", "-", "1", ",", "*", ",", "offset", "=", "0", ",", "chunk", "=", "None", ")", "->", "None", ":", "self", ".", "mglo", ".", "clear", "(", "size", ",", "offset", ",", "chunk", ")" ]
Clear the content. Args: size (int): The size. Value ``-1`` means all. Keyword Args: offset (int): The offset. chunk (bytes): The chunk to use repeatedly.
[ "Clear", "the", "content", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/buffer.py#L157-L169
225,534
moderngl/moderngl
moderngl/buffer.py
Buffer.bind_to_uniform_block
def bind_to_uniform_block(self, binding=0, *, offset=0, size=-1) -> None: ''' Bind the buffer to a uniform block. Args: binding (int): The uniform block binding. Keyword Args: offset (int): The offset. size (int): The size. Va...
python
def bind_to_uniform_block(self, binding=0, *, offset=0, size=-1) -> None: ''' Bind the buffer to a uniform block. Args: binding (int): The uniform block binding. Keyword Args: offset (int): The offset. size (int): The size. Va...
[ "def", "bind_to_uniform_block", "(", "self", ",", "binding", "=", "0", ",", "*", ",", "offset", "=", "0", ",", "size", "=", "-", "1", ")", "->", "None", ":", "self", ".", "mglo", ".", "bind_to_uniform_block", "(", "binding", ",", "offset", ",", "size...
Bind the buffer to a uniform block. Args: binding (int): The uniform block binding. Keyword Args: offset (int): The offset. size (int): The size. Value ``-1`` means all.
[ "Bind", "the", "buffer", "to", "a", "uniform", "block", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/buffer.py#L171-L183
225,535
moderngl/moderngl
moderngl/buffer.py
Buffer.bind_to_storage_buffer
def bind_to_storage_buffer(self, binding=0, *, offset=0, size=-1) -> None: ''' Bind the buffer to a shader storage buffer. Args: binding (int): The shader storage binding. Keyword Args: offset (int): The offset. size (int): Th...
python
def bind_to_storage_buffer(self, binding=0, *, offset=0, size=-1) -> None: ''' Bind the buffer to a shader storage buffer. Args: binding (int): The shader storage binding. Keyword Args: offset (int): The offset. size (int): Th...
[ "def", "bind_to_storage_buffer", "(", "self", ",", "binding", "=", "0", ",", "*", ",", "offset", "=", "0", ",", "size", "=", "-", "1", ")", "->", "None", ":", "self", ".", "mglo", ".", "bind_to_storage_buffer", "(", "binding", ",", "offset", ",", "si...
Bind the buffer to a shader storage buffer. Args: binding (int): The shader storage binding. Keyword Args: offset (int): The offset. size (int): The size. Value ``-1`` means all.
[ "Bind", "the", "buffer", "to", "a", "shader", "storage", "buffer", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/buffer.py#L185-L197
225,536
moderngl/moderngl
examples/window/pyqt5/window.py
Window.swap_buffers
def swap_buffers(self): """ Swap buffers, set viewport, trigger events and increment frame counter """ self.widget.swapBuffers() self.set_default_viewport() self.app.processEvents() self.frames += 1
python
def swap_buffers(self): """ Swap buffers, set viewport, trigger events and increment frame counter """ self.widget.swapBuffers() self.set_default_viewport() self.app.processEvents() self.frames += 1
[ "def", "swap_buffers", "(", "self", ")", ":", "self", ".", "widget", ".", "swapBuffers", "(", ")", "self", ".", "set_default_viewport", "(", ")", "self", ".", "app", ".", "processEvents", "(", ")", "self", ".", "frames", "+=", "1" ]
Swap buffers, set viewport, trigger events and increment frame counter
[ "Swap", "buffers", "set", "viewport", "trigger", "events", "and", "increment", "frame", "counter" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L100-L107
225,537
moderngl/moderngl
examples/window/pyqt5/window.py
Window.resize
def resize(self, width: int, height: int): """ Replacement for Qt's resizeGL method. """ self.width = width // self.widget.devicePixelRatio() self.height = height // self.widget.devicePixelRatio() self.buffer_width = width self.buffer_height = height ...
python
def resize(self, width: int, height: int): """ Replacement for Qt's resizeGL method. """ self.width = width // self.widget.devicePixelRatio() self.height = height // self.widget.devicePixelRatio() self.buffer_width = width self.buffer_height = height ...
[ "def", "resize", "(", "self", ",", "width", ":", "int", ",", "height", ":", "int", ")", ":", "self", ".", "width", "=", "width", "//", "self", ".", "widget", ".", "devicePixelRatio", "(", ")", "self", ".", "height", "=", "height", "//", "self", "."...
Replacement for Qt's resizeGL method.
[ "Replacement", "for", "Qt", "s", "resizeGL", "method", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L109-L122
225,538
moderngl/moderngl
examples/window/pyqt5/window.py
Window.key_pressed_event
def key_pressed_event(self, event): """ Process Qt key press events forwarding them to the example """ if event.key() == self.keys.ESCAPE: self.close() self.example.key_event(event.key(), self.keys.ACTION_PRESS)
python
def key_pressed_event(self, event): """ Process Qt key press events forwarding them to the example """ if event.key() == self.keys.ESCAPE: self.close() self.example.key_event(event.key(), self.keys.ACTION_PRESS)
[ "def", "key_pressed_event", "(", "self", ",", "event", ")", ":", "if", "event", ".", "key", "(", ")", "==", "self", ".", "keys", ".", "ESCAPE", ":", "self", ".", "close", "(", ")", "self", ".", "example", ".", "key_event", "(", "event", ".", "key",...
Process Qt key press events forwarding them to the example
[ "Process", "Qt", "key", "press", "events", "forwarding", "them", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L124-L131
225,539
moderngl/moderngl
examples/window/pyqt5/window.py
Window.key_release_event
def key_release_event(self, event): """ Process Qt key release events forwarding them to the example """ self.example.key_event(event.key(), self.keys.ACTION_RELEASE)
python
def key_release_event(self, event): """ Process Qt key release events forwarding them to the example """ self.example.key_event(event.key(), self.keys.ACTION_RELEASE)
[ "def", "key_release_event", "(", "self", ",", "event", ")", ":", "self", ".", "example", ".", "key_event", "(", "event", ".", "key", "(", ")", ",", "self", ".", "keys", ".", "ACTION_RELEASE", ")" ]
Process Qt key release events forwarding them to the example
[ "Process", "Qt", "key", "release", "events", "forwarding", "them", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L133-L137
225,540
moderngl/moderngl
examples/window/pyqt5/window.py
Window.mouse_move_event
def mouse_move_event(self, event): """ Forward mouse cursor position events to the example """ self.example.mouse_position_event(event.x(), event.y())
python
def mouse_move_event(self, event): """ Forward mouse cursor position events to the example """ self.example.mouse_position_event(event.x(), event.y())
[ "def", "mouse_move_event", "(", "self", ",", "event", ")", ":", "self", ".", "example", ".", "mouse_position_event", "(", "event", ".", "x", "(", ")", ",", "event", ".", "y", "(", ")", ")" ]
Forward mouse cursor position events to the example
[ "Forward", "mouse", "cursor", "position", "events", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L139-L143
225,541
moderngl/moderngl
examples/window/pyqt5/window.py
Window.mouse_press_event
def mouse_press_event(self, event): """ Forward mouse press events to the example """ # Support left and right mouse button for now if event.button() not in [1, 2]: return self.example.mouse_press_event(event.x(), event.y(), event.button())
python
def mouse_press_event(self, event): """ Forward mouse press events to the example """ # Support left and right mouse button for now if event.button() not in [1, 2]: return self.example.mouse_press_event(event.x(), event.y(), event.button())
[ "def", "mouse_press_event", "(", "self", ",", "event", ")", ":", "# Support left and right mouse button for now\r", "if", "event", ".", "button", "(", ")", "not", "in", "[", "1", ",", "2", "]", ":", "return", "self", ".", "example", ".", "mouse_press_event", ...
Forward mouse press events to the example
[ "Forward", "mouse", "press", "events", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L145-L153
225,542
moderngl/moderngl
examples/window/pyqt5/window.py
Window.mouse_release_event
def mouse_release_event(self, event): """ Forward mouse release events to the example """ # Support left and right mouse button for now if event.button() not in [1, 2]: return self.example.mouse_release_event(event.x(), event.y(), event.button())
python
def mouse_release_event(self, event): """ Forward mouse release events to the example """ # Support left and right mouse button for now if event.button() not in [1, 2]: return self.example.mouse_release_event(event.x(), event.y(), event.button())
[ "def", "mouse_release_event", "(", "self", ",", "event", ")", ":", "# Support left and right mouse button for now\r", "if", "event", ".", "button", "(", ")", "not", "in", "[", "1", ",", "2", "]", ":", "return", "self", ".", "example", ".", "mouse_release_event...
Forward mouse release events to the example
[ "Forward", "mouse", "release", "events", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyqt5/window.py#L155-L163
225,543
moderngl/moderngl
moderngl/framebuffer.py
Framebuffer.read
def read(self, viewport=None, components=3, *, attachment=0, alignment=1, dtype='f1') -> bytes: ''' Read the content of the framebuffer. Args: viewport (tuple): The viewport. components (int): The number of components to read. Keyword Args: ...
python
def read(self, viewport=None, components=3, *, attachment=0, alignment=1, dtype='f1') -> bytes: ''' Read the content of the framebuffer. Args: viewport (tuple): The viewport. components (int): The number of components to read. Keyword Args: ...
[ "def", "read", "(", "self", ",", "viewport", "=", "None", ",", "components", "=", "3", ",", "*", ",", "attachment", "=", "0", ",", "alignment", "=", "1", ",", "dtype", "=", "'f1'", ")", "->", "bytes", ":", "return", "self", ".", "mglo", ".", "rea...
Read the content of the framebuffer. Args: viewport (tuple): The viewport. components (int): The number of components to read. Keyword Args: attachment (int): The color attachment. alignment (int): The byte alignment of the pixels...
[ "Read", "the", "content", "of", "the", "framebuffer", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/framebuffer.py#L174-L191
225,544
moderngl/moderngl
moderngl/framebuffer.py
Framebuffer.read_into
def read_into(self, buffer, viewport=None, components=3, *, attachment=0, alignment=1, dtype='f1', write_offset=0) -> None: ''' Read the content of the framebuffer into a buffer. Args: buffer (bytearray): The buffer that will receive the pixels. ...
python
def read_into(self, buffer, viewport=None, components=3, *, attachment=0, alignment=1, dtype='f1', write_offset=0) -> None: ''' Read the content of the framebuffer into a buffer. Args: buffer (bytearray): The buffer that will receive the pixels. ...
[ "def", "read_into", "(", "self", ",", "buffer", ",", "viewport", "=", "None", ",", "components", "=", "3", ",", "*", ",", "attachment", "=", "0", ",", "alignment", "=", "1", ",", "dtype", "=", "'f1'", ",", "write_offset", "=", "0", ")", "->", "None...
Read the content of the framebuffer into a buffer. Args: buffer (bytearray): The buffer that will receive the pixels. viewport (tuple): The viewport. components (int): The number of components to read. Keyword Args: attachment (in...
[ "Read", "the", "content", "of", "the", "framebuffer", "into", "a", "buffer", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/framebuffer.py#L193-L213
225,545
moderngl/moderngl
examples/window/base.py
BaseWindow.resize
def resize(self, width, height): """ Should be called every time window is resized so the example can adapt to the new size if needed """ if self.example: self.example.resize(width, height)
python
def resize(self, width, height): """ Should be called every time window is resized so the example can adapt to the new size if needed """ if self.example: self.example.resize(width, height)
[ "def", "resize", "(", "self", ",", "width", ",", "height", ")", ":", "if", "self", ".", "example", ":", "self", ".", "example", ".", "resize", "(", "width", ",", "height", ")" ]
Should be called every time window is resized so the example can adapt to the new size if needed
[ "Should", "be", "called", "every", "time", "window", "is", "resized", "so", "the", "example", "can", "adapt", "to", "the", "new", "size", "if", "needed" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/base.py#L136-L142
225,546
moderngl/moderngl
examples/window/base.py
BaseWindow.set_default_viewport
def set_default_viewport(self): """ Calculates the viewport based on the configured aspect ratio. Will add black borders and center the viewport if the window do not match the configured viewport. If aspect ratio is None the viewport will be scaled to the entire w...
python
def set_default_viewport(self): """ Calculates the viewport based on the configured aspect ratio. Will add black borders and center the viewport if the window do not match the configured viewport. If aspect ratio is None the viewport will be scaled to the entire w...
[ "def", "set_default_viewport", "(", "self", ")", ":", "if", "self", ".", "aspect_ratio", ":", "expected_width", "=", "int", "(", "self", ".", "buffer_height", "*", "self", ".", "aspect_ratio", ")", "expected_height", "=", "int", "(", "expected_width", "/", "...
Calculates the viewport based on the configured aspect ratio. Will add black borders and center the viewport if the window do not match the configured viewport. If aspect ratio is None the viewport will be scaled to the entire window size regardless of size.
[ "Calculates", "the", "viewport", "based", "on", "the", "configured", "aspect", "ratio", ".", "Will", "add", "black", "borders", "and", "center", "the", "viewport", "if", "the", "window", "do", "not", "match", "the", "configured", "viewport", ".", "If", "aspe...
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/base.py#L150-L177
225,547
moderngl/moderngl
examples/window/base.py
BaseWindow.print_context_info
def print_context_info(self): """ Prints moderngl context info. """ print("Context Version:") print('ModernGL:', moderngl.__version__) print('vendor:', self.ctx.info['GL_VENDOR']) print('renderer:', self.ctx.info['GL_RENDERER']) print('version:', s...
python
def print_context_info(self): """ Prints moderngl context info. """ print("Context Version:") print('ModernGL:', moderngl.__version__) print('vendor:', self.ctx.info['GL_VENDOR']) print('renderer:', self.ctx.info['GL_RENDERER']) print('version:', s...
[ "def", "print_context_info", "(", "self", ")", ":", "print", "(", "\"Context Version:\"", ")", "print", "(", "'ModernGL:'", ",", "moderngl", ".", "__version__", ")", "print", "(", "'vendor:'", ",", "self", ".", "ctx", ".", "info", "[", "'GL_VENDOR'", "]", ...
Prints moderngl context info.
[ "Prints", "moderngl", "context", "info", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/base.py#L187-L198
225,548
moderngl/moderngl
moderngl/texture.py
Texture.read
def read(self, *, level=0, alignment=1) -> bytes: ''' Read the content of the texture into a buffer. Keyword Args: level (int): The mipmap level. alignment (int): The byte alignment of the pixels. Returns: bytes ''' ...
python
def read(self, *, level=0, alignment=1) -> bytes: ''' Read the content of the texture into a buffer. Keyword Args: level (int): The mipmap level. alignment (int): The byte alignment of the pixels. Returns: bytes ''' ...
[ "def", "read", "(", "self", ",", "*", ",", "level", "=", "0", ",", "alignment", "=", "1", ")", "->", "bytes", ":", "return", "self", ".", "mglo", ".", "read", "(", "level", ",", "alignment", ")" ]
Read the content of the texture into a buffer. Keyword Args: level (int): The mipmap level. alignment (int): The byte alignment of the pixels. Returns: bytes
[ "Read", "the", "content", "of", "the", "texture", "into", "a", "buffer", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/texture.py#L270-L282
225,549
moderngl/moderngl
examples/window/__init__.py
parse_args
def parse_args(args=None): """Parse arguments from sys.argv""" parser = argparse.ArgumentParser() parser.add_argument( '-w', '--window', default="pyqt5", choices=find_window_classes(), help='Name for the window type to use', ) parser.add_argument( ...
python
def parse_args(args=None): """Parse arguments from sys.argv""" parser = argparse.ArgumentParser() parser.add_argument( '-w', '--window', default="pyqt5", choices=find_window_classes(), help='Name for the window type to use', ) parser.add_argument( ...
[ "def", "parse_args", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-w'", ",", "'--window'", ",", "default", "=", "\"pyqt5\"", ",", "choices", "=", "find_window_classes", ...
Parse arguments from sys.argv
[ "Parse", "arguments", "from", "sys", ".", "argv" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/__init__.py#L65-L99
225,550
moderngl/moderngl
moderngl/compute_shader.py
ComputeShader.run
def run(self, group_x=1, group_y=1, group_z=1) -> None: ''' Run the compute shader. Args: group_x (int): The number of work groups to be launched in the X dimension. group_y (int): The number of work groups to be launched in the Y dimension. ...
python
def run(self, group_x=1, group_y=1, group_z=1) -> None: ''' Run the compute shader. Args: group_x (int): The number of work groups to be launched in the X dimension. group_y (int): The number of work groups to be launched in the Y dimension. ...
[ "def", "run", "(", "self", ",", "group_x", "=", "1", ",", "group_y", "=", "1", ",", "group_z", "=", "1", ")", "->", "None", ":", "return", "self", ".", "mglo", ".", "run", "(", "group_x", ",", "group_y", ",", "group_z", ")" ]
Run the compute shader. Args: group_x (int): The number of work groups to be launched in the X dimension. group_y (int): The number of work groups to be launched in the Y dimension. group_z (int): The number of work groups to be launched in the Z dimension.
[ "Run", "the", "compute", "shader", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/compute_shader.py#L54-L64
225,551
moderngl/moderngl
moderngl/compute_shader.py
ComputeShader.get
def get(self, key, default) -> Union[Uniform, UniformBlock, Subroutine, Attribute, Varying]: ''' Returns a Uniform, UniformBlock, Subroutine, Attribute or Varying. Args: default: This is the value to be returned in case key does not exist. Returns: ...
python
def get(self, key, default) -> Union[Uniform, UniformBlock, Subroutine, Attribute, Varying]: ''' Returns a Uniform, UniformBlock, Subroutine, Attribute or Varying. Args: default: This is the value to be returned in case key does not exist. Returns: ...
[ "def", "get", "(", "self", ",", "key", ",", "default", ")", "->", "Union", "[", "Uniform", ",", "UniformBlock", ",", "Subroutine", ",", "Attribute", ",", "Varying", "]", ":", "return", "self", ".", "_members", ".", "get", "(", "key", ",", "default", ...
Returns a Uniform, UniformBlock, Subroutine, Attribute or Varying. Args: default: This is the value to be returned in case key does not exist. Returns: :py:class:`Uniform`, :py:class:`UniformBlock`, :py:class:`Subroutine`, :py:class:`Attribute` o...
[ "Returns", "a", "Uniform", "UniformBlock", "Subroutine", "Attribute", "or", "Varying", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/compute_shader.py#L66-L78
225,552
moderngl/moderngl
examples/window/sdl2/window.py
Window.resize
def resize(self, width, height): """ Sets the new size and buffer size internally """ self.width = width self.height = height self.buffer_width, self.buffer_height = self.width, self.height self.set_default_viewport() super().resize(self.buffer_w...
python
def resize(self, width, height): """ Sets the new size and buffer size internally """ self.width = width self.height = height self.buffer_width, self.buffer_height = self.width, self.height self.set_default_viewport() super().resize(self.buffer_w...
[ "def", "resize", "(", "self", ",", "width", ",", "height", ")", ":", "self", ".", "width", "=", "width", "self", ".", "height", "=", "height", "self", ".", "buffer_width", ",", "self", ".", "buffer_height", "=", "self", ".", "width", ",", "self", "."...
Sets the new size and buffer size internally
[ "Sets", "the", "new", "size", "and", "buffer", "size", "internally" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/sdl2/window.py#L76-L85
225,553
moderngl/moderngl
examples/window/sdl2/window.py
Window.process_events
def process_events(self): """ Loop through and handle all the queued events. """ for event in sdl2.ext.get_events(): if event.type == sdl2.SDL_MOUSEMOTION: self.example.mouse_position_event(event.motion.x, event.motion.y) elif event.type =...
python
def process_events(self): """ Loop through and handle all the queued events. """ for event in sdl2.ext.get_events(): if event.type == sdl2.SDL_MOUSEMOTION: self.example.mouse_position_event(event.motion.x, event.motion.y) elif event.type =...
[ "def", "process_events", "(", "self", ")", ":", "for", "event", "in", "sdl2", ".", "ext", ".", "get_events", "(", ")", ":", "if", "event", ".", "type", "==", "sdl2", ".", "SDL_MOUSEMOTION", ":", "self", ".", "example", ".", "mouse_position_event", "(", ...
Loop through and handle all the queued events.
[ "Loop", "through", "and", "handle", "all", "the", "queued", "events", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/sdl2/window.py#L87-L122
225,554
moderngl/moderngl
examples/window/sdl2/window.py
Window.destroy
def destroy(self): """ Gracefully close the window """ sdl2.SDL_GL_DeleteContext(self.context) sdl2.SDL_DestroyWindow(self.window) sdl2.SDL_Quit()
python
def destroy(self): """ Gracefully close the window """ sdl2.SDL_GL_DeleteContext(self.context) sdl2.SDL_DestroyWindow(self.window) sdl2.SDL_Quit()
[ "def", "destroy", "(", "self", ")", ":", "sdl2", ".", "SDL_GL_DeleteContext", "(", "self", ".", "context", ")", "sdl2", ".", "SDL_DestroyWindow", "(", "self", ".", "window", ")", "sdl2", ".", "SDL_Quit", "(", ")" ]
Gracefully close the window
[ "Gracefully", "close", "the", "window" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/sdl2/window.py#L124-L130
225,555
moderngl/moderngl
examples/window/pyglet/window.py
Window.on_key_press
def on_key_press(self, symbol, modifiers): """ Pyglet specific key press callback. Forwards and translates the events to the example """ self.example.key_event(symbol, self.keys.ACTION_PRESS)
python
def on_key_press(self, symbol, modifiers): """ Pyglet specific key press callback. Forwards and translates the events to the example """ self.example.key_event(symbol, self.keys.ACTION_PRESS)
[ "def", "on_key_press", "(", "self", ",", "symbol", ",", "modifiers", ")", ":", "self", ".", "example", ".", "key_event", "(", "symbol", ",", "self", ".", "keys", ".", "ACTION_PRESS", ")" ]
Pyglet specific key press callback. Forwards and translates the events to the example
[ "Pyglet", "specific", "key", "press", "callback", ".", "Forwards", "and", "translates", "the", "events", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyglet/window.py#L96-L101
225,556
moderngl/moderngl
examples/window/pyglet/window.py
Window.on_key_release
def on_key_release(self, symbol, modifiers): """ Pyglet specific key release callback. Forwards and translates the events to the example """ self.example.key_event(symbol, self.keys.ACTION_RELEASE)
python
def on_key_release(self, symbol, modifiers): """ Pyglet specific key release callback. Forwards and translates the events to the example """ self.example.key_event(symbol, self.keys.ACTION_RELEASE)
[ "def", "on_key_release", "(", "self", ",", "symbol", ",", "modifiers", ")", ":", "self", ".", "example", ".", "key_event", "(", "symbol", ",", "self", ".", "keys", ".", "ACTION_RELEASE", ")" ]
Pyglet specific key release callback. Forwards and translates the events to the example
[ "Pyglet", "specific", "key", "release", "callback", ".", "Forwards", "and", "translates", "the", "events", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyglet/window.py#L103-L108
225,557
moderngl/moderngl
examples/window/pyglet/window.py
Window.on_mouse_motion
def on_mouse_motion(self, x, y, dx, dy): """ Pyglet specific mouse motion callback. Forwards and traslates the event to the example """ # Screen coordinates relative to the lower-left corner # so we have to flip the y axis to make this consistent with # oth...
python
def on_mouse_motion(self, x, y, dx, dy): """ Pyglet specific mouse motion callback. Forwards and traslates the event to the example """ # Screen coordinates relative to the lower-left corner # so we have to flip the y axis to make this consistent with # oth...
[ "def", "on_mouse_motion", "(", "self", ",", "x", ",", "y", ",", "dx", ",", "dy", ")", ":", "# Screen coordinates relative to the lower-left corner\r", "# so we have to flip the y axis to make this consistent with\r", "# other window libraries\r", "self", ".", "example", ".", ...
Pyglet specific mouse motion callback. Forwards and traslates the event to the example
[ "Pyglet", "specific", "mouse", "motion", "callback", ".", "Forwards", "and", "traslates", "the", "event", "to", "the", "example" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyglet/window.py#L110-L118
225,558
moderngl/moderngl
examples/window/pyglet/window.py
Window.on_mouse_press
def on_mouse_press(self, x: int, y: int, button, mods): """ Handle mouse press events and forward to example window """ if button in [1, 4]: self.example.mouse_press_event( x, self.buffer_height - y, 1 if button == 1 else 2, ...
python
def on_mouse_press(self, x: int, y: int, button, mods): """ Handle mouse press events and forward to example window """ if button in [1, 4]: self.example.mouse_press_event( x, self.buffer_height - y, 1 if button == 1 else 2, ...
[ "def", "on_mouse_press", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "button", ",", "mods", ")", ":", "if", "button", "in", "[", "1", ",", "4", "]", ":", "self", ".", "example", ".", "mouse_press_event", "(", "x", ",", "self", ...
Handle mouse press events and forward to example window
[ "Handle", "mouse", "press", "events", "and", "forward", "to", "example", "window" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyglet/window.py#L120-L128
225,559
moderngl/moderngl
examples/window/pyglet/window.py
Window.on_mouse_release
def on_mouse_release(self, x: int, y: int, button, mods): """ Handle mouse release events and forward to example window """ if button in [1, 4]: self.example.mouse_release_event( x, self.buffer_height - y, 1 if button == 1 else 2, ...
python
def on_mouse_release(self, x: int, y: int, button, mods): """ Handle mouse release events and forward to example window """ if button in [1, 4]: self.example.mouse_release_event( x, self.buffer_height - y, 1 if button == 1 else 2, ...
[ "def", "on_mouse_release", "(", "self", ",", "x", ":", "int", ",", "y", ":", "int", ",", "button", ",", "mods", ")", ":", "if", "button", "in", "[", "1", ",", "4", "]", ":", "self", ".", "example", ".", "mouse_release_event", "(", "x", ",", "self...
Handle mouse release events and forward to example window
[ "Handle", "mouse", "release", "events", "and", "forward", "to", "example", "window" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/window/pyglet/window.py#L130-L138
225,560
moderngl/moderngl
moderngl/texture_cube.py
TextureCube.write
def write(self, face, data, viewport=None, *, alignment=1) -> None: ''' Update the content of the texture. Args: face (int): The face to update. data (bytes): The pixel data. viewport (tuple): The viewport. Keyword Args: ...
python
def write(self, face, data, viewport=None, *, alignment=1) -> None: ''' Update the content of the texture. Args: face (int): The face to update. data (bytes): The pixel data. viewport (tuple): The viewport. Keyword Args: ...
[ "def", "write", "(", "self", ",", "face", ",", "data", ",", "viewport", "=", "None", ",", "*", ",", "alignment", "=", "1", ")", "->", "None", ":", "if", "type", "(", "data", ")", "is", "Buffer", ":", "data", "=", "data", ".", "mglo", "self", "....
Update the content of the texture. Args: face (int): The face to update. data (bytes): The pixel data. viewport (tuple): The viewport. Keyword Args: alignment (int): The byte alignment of the pixels.
[ "Update", "the", "content", "of", "the", "texture", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/texture_cube.py#L170-L186
225,561
moderngl/moderngl
examples/00_empty_window.py
EmptyWindow.key_event
def key_event(self, key, action): """ Handle key events in a generic way supporting all window types. """ if action == self.wnd.keys.ACTION_PRESS: if key == self.wnd.keys.SPACE: print("Space was pressed") if action == self.wnd.keys.ACTION_RELE...
python
def key_event(self, key, action): """ Handle key events in a generic way supporting all window types. """ if action == self.wnd.keys.ACTION_PRESS: if key == self.wnd.keys.SPACE: print("Space was pressed") if action == self.wnd.keys.ACTION_RELE...
[ "def", "key_event", "(", "self", ",", "key", ",", "action", ")", ":", "if", "action", "==", "self", ".", "wnd", ".", "keys", ".", "ACTION_PRESS", ":", "if", "key", "==", "self", ".", "wnd", ".", "keys", ".", "SPACE", ":", "print", "(", "\"Space was...
Handle key events in a generic way supporting all window types.
[ "Handle", "key", "events", "in", "a", "generic", "way", "supporting", "all", "window", "types", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/00_empty_window.py#L24-L35
225,562
moderngl/moderngl
examples/00_empty_window.py
EmptyWindow.mouse_press_event
def mouse_press_event(self, x, y, button): """Reports left and right mouse button presses + position""" if button == 1: print("Left mouse button pressed @", x, y) if button == 2: print("Right mouse button pressed @", x, y)
python
def mouse_press_event(self, x, y, button): """Reports left and right mouse button presses + position""" if button == 1: print("Left mouse button pressed @", x, y) if button == 2: print("Right mouse button pressed @", x, y)
[ "def", "mouse_press_event", "(", "self", ",", "x", ",", "y", ",", "button", ")", ":", "if", "button", "==", "1", ":", "print", "(", "\"Left mouse button pressed @\"", ",", "x", ",", "y", ")", "if", "button", "==", "2", ":", "print", "(", "\"Right mouse...
Reports left and right mouse button presses + position
[ "Reports", "left", "and", "right", "mouse", "button", "presses", "+", "position" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/00_empty_window.py#L44-L49
225,563
moderngl/moderngl
examples/00_empty_window.py
EmptyWindow.mouse_release_event
def mouse_release_event(self, x, y, button): """Reports left and right mouse button releases + position""" if button == 1: print("Left mouse button released @", x, y) if button == 2: print("Right mouse button released @", x, y)
python
def mouse_release_event(self, x, y, button): """Reports left and right mouse button releases + position""" if button == 1: print("Left mouse button released @", x, y) if button == 2: print("Right mouse button released @", x, y)
[ "def", "mouse_release_event", "(", "self", ",", "x", ",", "y", ",", "button", ")", ":", "if", "button", "==", "1", ":", "print", "(", "\"Left mouse button released @\"", ",", "x", ",", "y", ")", "if", "button", "==", "2", ":", "print", "(", "\"Right mo...
Reports left and right mouse button releases + position
[ "Reports", "left", "and", "right", "mouse", "button", "releases", "+", "position" ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/examples/00_empty_window.py#L51-L56
225,564
moderngl/moderngl
moderngl/program.py
detect_format
def detect_format(program, attributes) -> str: ''' Detect format for vertex attributes. The format returned does not contain padding. Args: program (Program): The program. attributes (list): A list of attribute names. Returns: str ''' de...
python
def detect_format(program, attributes) -> str: ''' Detect format for vertex attributes. The format returned does not contain padding. Args: program (Program): The program. attributes (list): A list of attribute names. Returns: str ''' de...
[ "def", "detect_format", "(", "program", ",", "attributes", ")", "->", "str", ":", "def", "fmt", "(", "attr", ")", ":", "'''\n For internal use only.\n '''", "return", "attr", ".", "array_length", "*", "attr", ".", "dimension", ",", "attr", ".",...
Detect format for vertex attributes. The format returned does not contain padding. Args: program (Program): The program. attributes (list): A list of attribute names. Returns: str
[ "Detect", "format", "for", "vertex", "attributes", ".", "The", "format", "returned", "does", "not", "contain", "padding", "." ]
a8f5dce8dc72ae84a2f9523887fb5f6b620049b9
https://github.com/moderngl/moderngl/blob/a8f5dce8dc72ae84a2f9523887fb5f6b620049b9/moderngl/program.py#L115-L135
225,565
dswah/pyGAM
pygam/callbacks.py
validate_callback_data
def validate_callback_data(method): """ wraps a callback's method to pull the desired arguments from the vars dict also checks to ensure the method's arguments are in the vars dict Parameters ---------- method : callable Returns ------- validated callable """ @wraps(method)...
python
def validate_callback_data(method): """ wraps a callback's method to pull the desired arguments from the vars dict also checks to ensure the method's arguments are in the vars dict Parameters ---------- method : callable Returns ------- validated callable """ @wraps(method)...
[ "def", "validate_callback_data", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "method_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "\"\"\"\n\n Parameters\n ----------\n *args\n **kwargs\n\n Returns\...
wraps a callback's method to pull the desired arguments from the vars dict also checks to ensure the method's arguments are in the vars dict Parameters ---------- method : callable Returns ------- validated callable
[ "wraps", "a", "callback", "s", "method", "to", "pull", "the", "desired", "arguments", "from", "the", "vars", "dict", "also", "checks", "to", "ensure", "the", "method", "s", "arguments", "are", "in", "the", "vars", "dict" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/callbacks.py#L13-L66
225,566
dswah/pyGAM
pygam/callbacks.py
validate_callback
def validate_callback(callback): """ validates a callback's on_loop_start and on_loop_end methods Parameters ---------- callback : Callback object Returns ------- validated callback """ if not(hasattr(callback, '_validated')) or callback._validated == False: assert hasa...
python
def validate_callback(callback): """ validates a callback's on_loop_start and on_loop_end methods Parameters ---------- callback : Callback object Returns ------- validated callback """ if not(hasattr(callback, '_validated')) or callback._validated == False: assert hasa...
[ "def", "validate_callback", "(", "callback", ")", ":", "if", "not", "(", "hasattr", "(", "callback", ",", "'_validated'", ")", ")", "or", "callback", ".", "_validated", "==", "False", ":", "assert", "hasattr", "(", "callback", ",", "'on_loop_start'", ")", ...
validates a callback's on_loop_start and on_loop_end methods Parameters ---------- callback : Callback object Returns ------- validated callback
[ "validates", "a", "callback", "s", "on_loop_start", "and", "on_loop_end", "methods" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/callbacks.py#L68-L91
225,567
dswah/pyGAM
pygam/distributions.py
Distribution.phi
def phi(self, y, mu, edof, weights): """ GLM scale parameter. for Binomial and Poisson families this is unity for Normal family this is variance Parameters ---------- y : array-like of length n target values mu : array-like of length n ...
python
def phi(self, y, mu, edof, weights): """ GLM scale parameter. for Binomial and Poisson families this is unity for Normal family this is variance Parameters ---------- y : array-like of length n target values mu : array-like of length n ...
[ "def", "phi", "(", "self", ",", "y", ",", "mu", ",", "edof", ",", "weights", ")", ":", "if", "self", ".", "_known_scale", ":", "return", "self", ".", "scale", "else", ":", "return", "(", "np", ".", "sum", "(", "weights", "*", "self", ".", "V", ...
GLM scale parameter. for Binomial and Poisson families this is unity for Normal family this is variance Parameters ---------- y : array-like of length n target values mu : array-like of length n expected values edof : float est...
[ "GLM", "scale", "parameter", ".", "for", "Binomial", "and", "Poisson", "families", "this", "is", "unity", "for", "Normal", "family", "this", "is", "variance" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/distributions.py#L61-L87
225,568
dswah/pyGAM
pygam/distributions.py
GammaDist.sample
def sample(self, mu): """ Return random samples from this Gamma distribution. Parameters ---------- mu : array-like of shape n_samples or shape (n_simulations, n_samples) expected values Returns ------- random_samples : np.array of same shape...
python
def sample(self, mu): """ Return random samples from this Gamma distribution. Parameters ---------- mu : array-like of shape n_samples or shape (n_simulations, n_samples) expected values Returns ------- random_samples : np.array of same shape...
[ "def", "sample", "(", "self", ",", "mu", ")", ":", "# in numpy.random.gamma, `shape` is the parameter sometimes denoted by", "# `k` that corresponds to `nu` in S. Wood (2006) Table 2.1", "shape", "=", "1.", "/", "self", ".", "scale", "# in numpy.random.gamma, `scale` is the paramet...
Return random samples from this Gamma distribution. Parameters ---------- mu : array-like of shape n_samples or shape (n_simulations, n_samples) expected values Returns ------- random_samples : np.array of same shape as mu
[ "Return", "random", "samples", "from", "this", "Gamma", "distribution", "." ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/distributions.py#L535-L554
225,569
dswah/pyGAM
pygam/datasets/load_datasets.py
_clean_X_y
def _clean_X_y(X, y): """ensure that X and y data are float and correct shapes """ return make_2d(X, verbose=False).astype('float'), y.astype('float')
python
def _clean_X_y(X, y): """ensure that X and y data are float and correct shapes """ return make_2d(X, verbose=False).astype('float'), y.astype('float')
[ "def", "_clean_X_y", "(", "X", ",", "y", ")", ":", "return", "make_2d", "(", "X", ",", "verbose", "=", "False", ")", ".", "astype", "(", "'float'", ")", ",", "y", ".", "astype", "(", "'float'", ")" ]
ensure that X and y data are float and correct shapes
[ "ensure", "that", "X", "and", "y", "data", "are", "float", "and", "correct", "shapes" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L17-L20
225,570
dswah/pyGAM
pygam/datasets/load_datasets.py
mcycle
def mcycle(return_X_y=True): """motorcyle acceleration dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame...
python
def mcycle(return_X_y=True): """motorcyle acceleration dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame...
[ "def", "mcycle", "(", "return_X_y", "=", "True", ")", ":", "# y is real", "# recommend LinearGAM", "motor", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/mcycle.csv'", ",", "index_col", "=", "0", ")", "if", "return_X_y", ":", "X", "=", "motor", ".", "...
motorcyle acceleration dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- X contains...
[ "motorcyle", "acceleration", "dataset" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L22-L52
225,571
dswah/pyGAM
pygam/datasets/load_datasets.py
coal
def coal(return_X_y=True): """coal-mining accidents dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame ...
python
def coal(return_X_y=True): """coal-mining accidents dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame ...
[ "def", "coal", "(", "return_X_y", "=", "True", ")", ":", "# y is counts", "# recommend PoissonGAM", "coal", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/coal.csv'", ",", "index_col", "=", "0", ")", "if", "return_X_y", ":", "y", ",", "x", "=", "np", ...
coal-mining accidents dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- The (X, y) ...
[ "coal", "-", "mining", "accidents", "dataset" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L54-L88
225,572
dswah/pyGAM
pygam/datasets/load_datasets.py
faithful
def faithful(return_X_y=True): """old-faithful dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame No...
python
def faithful(return_X_y=True): """old-faithful dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame No...
[ "def", "faithful", "(", "return_X_y", "=", "True", ")", ":", "# y is counts", "# recommend PoissonGAM", "faithful", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/faithful.csv'", ",", "index_col", "=", "0", ")", "if", "return_X_y", ":", "y", ",", "x", "=...
old-faithful dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- The (X, y) tuple is ...
[ "old", "-", "faithful", "dataset" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L90-L124
225,573
dswah/pyGAM
pygam/datasets/load_datasets.py
trees
def trees(return_X_y=True): """cherry trees dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes...
python
def trees(return_X_y=True): """cherry trees dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes...
[ "def", "trees", "(", "return_X_y", "=", "True", ")", ":", "# y is real.", "# recommend InvGaussGAM, or GAM(distribution='gamma', link='log')", "trees", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/trees.csv'", ",", "index_col", "=", "0", ")", "if", "return_X_y",...
cherry trees dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- X contains the girth...
[ "cherry", "trees", "dataset" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L161-L191
225,574
dswah/pyGAM
pygam/datasets/load_datasets.py
default
def default(return_X_y=True): """credit default dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame N...
python
def default(return_X_y=True): """credit default dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame N...
[ "def", "default", "(", "return_X_y", "=", "True", ")", ":", "# y is binary", "# recommend LogisticGAM", "default", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/default.csv'", ",", "index_col", "=", "0", ")", "if", "return_X_y", ":", "default", "=", "defa...
credit default dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- X contains the cat...
[ "credit", "default", "dataset" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L193-L228
225,575
dswah/pyGAM
pygam/datasets/load_datasets.py
hepatitis
def hepatitis(return_X_y=True): """hepatitis in Bulgaria dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFra...
python
def hepatitis(return_X_y=True): """hepatitis in Bulgaria dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFra...
[ "def", "hepatitis", "(", "return_X_y", "=", "True", ")", ":", "# y is real", "# recommend LinearGAM", "hep", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/hepatitis_A_bulgaria.csv'", ")", ".", "astype", "(", "float", ")", "if", "return_X_y", ":", "# elimina...
hepatitis in Bulgaria dataset Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- X contains ...
[ "hepatitis", "in", "Bulgaria", "dataset" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L266-L304
225,576
dswah/pyGAM
pygam/datasets/load_datasets.py
toy_classification
def toy_classification(return_X_y=True, n=5000): """toy classification dataset with irrelevant features fitting a logistic model on this data and performing a model summary should reveal that features 2,3,4 are not significant. Parameters ---------- return_X_y : bool, if True, returns ...
python
def toy_classification(return_X_y=True, n=5000): """toy classification dataset with irrelevant features fitting a logistic model on this data and performing a model summary should reveal that features 2,3,4 are not significant. Parameters ---------- return_X_y : bool, if True, returns ...
[ "def", "toy_classification", "(", "return_X_y", "=", "True", ",", "n", "=", "5000", ")", ":", "# make features", "X", "=", "np", ".", "random", ".", "rand", "(", "n", ",", "5", ")", "*", "10", "-", "5", "cat", "=", "np", ".", "random", ".", "rand...
toy classification dataset with irrelevant features fitting a logistic model on this data and performing a model summary should reveal that features 2,3,4 are not significant. Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, re...
[ "toy", "classification", "dataset", "with", "irrelevant", "features" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L306-L361
225,577
dswah/pyGAM
pygam/datasets/load_datasets.py
head_circumference
def head_circumference(return_X_y=True): """head circumference for dutch boys Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR P...
python
def head_circumference(return_X_y=True): """head circumference for dutch boys Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR P...
[ "def", "head_circumference", "(", "return_X_y", "=", "True", ")", ":", "# y is real", "# recommend ExpectileGAM", "head", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/head_circumference.csv'", ",", "index_col", "=", "0", ")", ".", "astype", "(", "float", "...
head circumference for dutch boys Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- X conta...
[ "head", "circumference", "for", "dutch", "boys" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L363-L391
225,578
dswah/pyGAM
pygam/datasets/load_datasets.py
chicago
def chicago(return_X_y=True): """Chicago air pollution and death rate data Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pand...
python
def chicago(return_X_y=True): """Chicago air pollution and death rate data Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pand...
[ "def", "chicago", "(", "return_X_y", "=", "True", ")", ":", "# recommend PoissonGAM", "chi", "=", "pd", ".", "read_csv", "(", "PATH", "+", "'/chicago.csv'", ",", "index_col", "=", "0", ")", ".", "astype", "(", "float", ")", "if", "return_X_y", ":", "chi"...
Chicago air pollution and death rate data Parameters ---------- return_X_y : bool, if True, returns a model-ready tuple of data (X, y) otherwise, returns a Pandas DataFrame Returns ------- model-ready tuple of data (X, y) OR Pandas DataFrame Notes ----- ...
[ "Chicago", "air", "pollution", "and", "death", "rate", "data" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L393-L442
225,579
dswah/pyGAM
pygam/datasets/load_datasets.py
toy_interaction
def toy_interaction(return_X_y=True, n=50000, stddev=0.1): """a sinusoid modulated by a linear function this is a simple dataset to test a model's capacity to fit interactions between features. a GAM with no interaction terms will have an R-squared close to 0, while a GAM with a tensor product wil...
python
def toy_interaction(return_X_y=True, n=50000, stddev=0.1): """a sinusoid modulated by a linear function this is a simple dataset to test a model's capacity to fit interactions between features. a GAM with no interaction terms will have an R-squared close to 0, while a GAM with a tensor product wil...
[ "def", "toy_interaction", "(", "return_X_y", "=", "True", ",", "n", "=", "50000", ",", "stddev", "=", "0.1", ")", ":", "X", "=", "np", ".", "random", ".", "uniform", "(", "-", "1", ",", "1", ",", "size", "=", "(", "n", ",", "2", ")", ")", "X"...
a sinusoid modulated by a linear function this is a simple dataset to test a model's capacity to fit interactions between features. a GAM with no interaction terms will have an R-squared close to 0, while a GAM with a tensor product will have R-squared close to 1. the data is random, and will var...
[ "a", "sinusoid", "modulated", "by", "a", "linear", "function" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/datasets/load_datasets.py#L444-L493
225,580
dswah/pyGAM
gen_imgs.py
gen_multi_data
def gen_multi_data(n=5000): """ multivariate Logistic problem """ X, y = toy_classification(return_X_y=True, n=10000) lgam = LogisticGAM(s(0) + s(1) + s(2) + s(3) + s(4) + f(5)) lgam.fit(X, y) plt.figure() for i, term in enumerate(lgam.terms): if term.isintercept: c...
python
def gen_multi_data(n=5000): """ multivariate Logistic problem """ X, y = toy_classification(return_X_y=True, n=10000) lgam = LogisticGAM(s(0) + s(1) + s(2) + s(3) + s(4) + f(5)) lgam.fit(X, y) plt.figure() for i, term in enumerate(lgam.terms): if term.isintercept: c...
[ "def", "gen_multi_data", "(", "n", "=", "5000", ")", ":", "X", ",", "y", "=", "toy_classification", "(", "return_X_y", "=", "True", ",", "n", "=", "10000", ")", "lgam", "=", "LogisticGAM", "(", "s", "(", "0", ")", "+", "s", "(", "1", ")", "+", ...
multivariate Logistic problem
[ "multivariate", "Logistic", "problem" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/gen_imgs.py#L229-L248
225,581
dswah/pyGAM
gen_imgs.py
gen_tensor_data
def gen_tensor_data(): """ toy interaction data """ X, y = toy_interaction(return_X_y=True, n=10000) gam = LinearGAM(te(0, 1,lam=0.1)).fit(X, y) XX = gam.generate_X_grid(term=0, meshgrid=True) Z = gam.partial_dependence(term=0, meshgrid=True) fig = plt.figure(figsize=(9,6)) ax = p...
python
def gen_tensor_data(): """ toy interaction data """ X, y = toy_interaction(return_X_y=True, n=10000) gam = LinearGAM(te(0, 1,lam=0.1)).fit(X, y) XX = gam.generate_X_grid(term=0, meshgrid=True) Z = gam.partial_dependence(term=0, meshgrid=True) fig = plt.figure(figsize=(9,6)) ax = p...
[ "def", "gen_tensor_data", "(", ")", ":", "X", ",", "y", "=", "toy_interaction", "(", "return_X_y", "=", "True", ",", "n", "=", "10000", ")", "gam", "=", "LinearGAM", "(", "te", "(", "0", ",", "1", ",", "lam", "=", "0.1", ")", ")", ".", "fit", "...
toy interaction data
[ "toy", "interaction", "data" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/gen_imgs.py#L250-L267
225,582
dswah/pyGAM
gen_imgs.py
expectiles
def expectiles(): """ a bunch of expectiles """ X, y = mcycle(return_X_y=True) # lets fit the mean model first by CV gam50 = ExpectileGAM(expectile=0.5).gridsearch(X, y) # and copy the smoothing to the other models lam = gam50.lam # now fit a few more models gam95 = Expectile...
python
def expectiles(): """ a bunch of expectiles """ X, y = mcycle(return_X_y=True) # lets fit the mean model first by CV gam50 = ExpectileGAM(expectile=0.5).gridsearch(X, y) # and copy the smoothing to the other models lam = gam50.lam # now fit a few more models gam95 = Expectile...
[ "def", "expectiles", "(", ")", ":", "X", ",", "y", "=", "mcycle", "(", "return_X_y", "=", "True", ")", "# lets fit the mean model first by CV", "gam50", "=", "ExpectileGAM", "(", "expectile", "=", "0.5", ")", ".", "gridsearch", "(", "X", ",", "y", ")", "...
a bunch of expectiles
[ "a", "bunch", "of", "expectiles" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/gen_imgs.py#L287-L318
225,583
dswah/pyGAM
pygam/utils.py
cholesky
def cholesky(A, sparse=True, verbose=True): """ Choose the best possible cholesky factorizor. if possible, import the Scikit-Sparse sparse Cholesky method. Permutes the output L to ensure A = L.H . L otherwise defaults to numpy's non-sparse version Parameters ---------- A : array-like...
python
def cholesky(A, sparse=True, verbose=True): """ Choose the best possible cholesky factorizor. if possible, import the Scikit-Sparse sparse Cholesky method. Permutes the output L to ensure A = L.H . L otherwise defaults to numpy's non-sparse version Parameters ---------- A : array-like...
[ "def", "cholesky", "(", "A", ",", "sparse", "=", "True", ",", "verbose", "=", "True", ")", ":", "if", "SKSPIMPORT", ":", "A", "=", "sp", ".", "sparse", ".", "csc_matrix", "(", "A", ")", "try", ":", "F", "=", "spcholesky", "(", "A", ")", "# permut...
Choose the best possible cholesky factorizor. if possible, import the Scikit-Sparse sparse Cholesky method. Permutes the output L to ensure A = L.H . L otherwise defaults to numpy's non-sparse version Parameters ---------- A : array-like array to decompose sparse : boolean, defaul...
[ "Choose", "the", "best", "possible", "cholesky", "factorizor", "." ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L33-L90
225,584
dswah/pyGAM
pygam/utils.py
make_2d
def make_2d(array, verbose=True): """ tiny tool to expand 1D arrays the way i want Parameters ---------- array : array-like verbose : bool, default: True whether to print warnings Returns ------- np.array of with ndim = 2 """ array = np.asarray(array) if array....
python
def make_2d(array, verbose=True): """ tiny tool to expand 1D arrays the way i want Parameters ---------- array : array-like verbose : bool, default: True whether to print warnings Returns ------- np.array of with ndim = 2 """ array = np.asarray(array) if array....
[ "def", "make_2d", "(", "array", ",", "verbose", "=", "True", ")", ":", "array", "=", "np", ".", "asarray", "(", "array", ")", "if", "array", ".", "ndim", "<", "2", ":", "msg", "=", "'Expected 2D input data array, but found {}D. '", "'Expanding to 2D.'", ".",...
tiny tool to expand 1D arrays the way i want Parameters ---------- array : array-like verbose : bool, default: True whether to print warnings Returns ------- np.array of with ndim = 2
[ "tiny", "tool", "to", "expand", "1D", "arrays", "the", "way", "i", "want" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L93-L115
225,585
dswah/pyGAM
pygam/utils.py
check_array
def check_array(array, force_2d=False, n_feats=None, ndim=None, min_samples=1, name='Input data', verbose=True): """ tool to perform basic data validation. called by check_X and check_y. ensures that data: - is ndim dimensional - contains float-compatible data-types - has at...
python
def check_array(array, force_2d=False, n_feats=None, ndim=None, min_samples=1, name='Input data', verbose=True): """ tool to perform basic data validation. called by check_X and check_y. ensures that data: - is ndim dimensional - contains float-compatible data-types - has at...
[ "def", "check_array", "(", "array", ",", "force_2d", "=", "False", ",", "n_feats", "=", "None", ",", "ndim", "=", "None", ",", "min_samples", "=", "1", ",", "name", "=", "'Input data'", ",", "verbose", "=", "True", ")", ":", "# make array", "if", "forc...
tool to perform basic data validation. called by check_X and check_y. ensures that data: - is ndim dimensional - contains float-compatible data-types - has at least min_samples - has n_feats - is finite Parameters ---------- array : array-like force_2d : boolean, default: F...
[ "tool", "to", "perform", "basic", "data", "validation", ".", "called", "by", "check_X", "and", "check_y", "." ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L118-L192
225,586
dswah/pyGAM
pygam/utils.py
check_param
def check_param(param, param_name, dtype, constraint=None, iterable=True, max_depth=2): """ checks the dtype of a parameter, and whether it satisfies a numerical contraint Parameters --------- param : object param_name : str, name of the parameter dtype : str, desired dt...
python
def check_param(param, param_name, dtype, constraint=None, iterable=True, max_depth=2): """ checks the dtype of a parameter, and whether it satisfies a numerical contraint Parameters --------- param : object param_name : str, name of the parameter dtype : str, desired dt...
[ "def", "check_param", "(", "param", ",", "param_name", ",", "dtype", ",", "constraint", "=", "None", ",", "iterable", "=", "True", ",", "max_depth", "=", "2", ")", ":", "msg", "=", "[", "]", "msg", ".", "append", "(", "param_name", "+", "\" must be \""...
checks the dtype of a parameter, and whether it satisfies a numerical contraint Parameters --------- param : object param_name : str, name of the parameter dtype : str, desired dtype of the parameter contraint : str, default: None numerical constraint of the parameter. ...
[ "checks", "the", "dtype", "of", "a", "parameter", "and", "whether", "it", "satisfies", "a", "numerical", "contraint" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L341-L400
225,587
dswah/pyGAM
pygam/utils.py
get_link_domain
def get_link_domain(link, dist): """ tool to identify the domain of a given monotonic link function Parameters ---------- link : Link object dist : Distribution object Returns ------- domain : list of length 2, representing the interval of the domain. """ domain = np.array(...
python
def get_link_domain(link, dist): """ tool to identify the domain of a given monotonic link function Parameters ---------- link : Link object dist : Distribution object Returns ------- domain : list of length 2, representing the interval of the domain. """ domain = np.array(...
[ "def", "get_link_domain", "(", "link", ",", "dist", ")", ":", "domain", "=", "np", ".", "array", "(", "[", "-", "np", ".", "inf", ",", "-", "1", ",", "0", ",", "1", ",", "np", ".", "inf", "]", ")", "domain", "=", "domain", "[", "~", "np", "...
tool to identify the domain of a given monotonic link function Parameters ---------- link : Link object dist : Distribution object Returns ------- domain : list of length 2, representing the interval of the domain.
[ "tool", "to", "identify", "the", "domain", "of", "a", "given", "monotonic", "link", "function" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L402-L417
225,588
dswah/pyGAM
pygam/utils.py
load_diagonal
def load_diagonal(cov, load=None): """Return the given square matrix with a small amount added to the diagonal to make it positive semi-definite. """ n, m = cov.shape assert n == m, "matrix must be square, but found shape {}".format((n, m)) if load is None: l...
python
def load_diagonal(cov, load=None): """Return the given square matrix with a small amount added to the diagonal to make it positive semi-definite. """ n, m = cov.shape assert n == m, "matrix must be square, but found shape {}".format((n, m)) if load is None: l...
[ "def", "load_diagonal", "(", "cov", ",", "load", "=", "None", ")", ":", "n", ",", "m", "=", "cov", ".", "shape", "assert", "n", "==", "m", ",", "\"matrix must be square, but found shape {}\"", ".", "format", "(", "(", "n", ",", "m", ")", ")", "if", "...
Return the given square matrix with a small amount added to the diagonal to make it positive semi-definite.
[ "Return", "the", "given", "square", "matrix", "with", "a", "small", "amount", "added", "to", "the", "diagonal", "to", "make", "it", "positive", "semi", "-", "definite", "." ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L420-L429
225,589
dswah/pyGAM
pygam/utils.py
round_to_n_decimal_places
def round_to_n_decimal_places(array, n=3): """ tool to keep round a float to n decimal places. n=3 by default Parameters ---------- array : np.array n : int. number of decimal places to keep Returns ------- array : rounded np.array """ # check if in scientific notation...
python
def round_to_n_decimal_places(array, n=3): """ tool to keep round a float to n decimal places. n=3 by default Parameters ---------- array : np.array n : int. number of decimal places to keep Returns ------- array : rounded np.array """ # check if in scientific notation...
[ "def", "round_to_n_decimal_places", "(", "array", ",", "n", "=", "3", ")", ":", "# check if in scientific notation", "if", "issubclass", "(", "array", ".", "__class__", ",", "float", ")", "and", "'%.e'", "%", "array", "==", "str", "(", "array", ")", ":", "...
tool to keep round a float to n decimal places. n=3 by default Parameters ---------- array : np.array n : int. number of decimal places to keep Returns ------- array : rounded np.array
[ "tool", "to", "keep", "round", "a", "float", "to", "n", "decimal", "places", "." ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L432-L453
225,590
dswah/pyGAM
pygam/utils.py
space_row
def space_row(left, right, filler=' ', total_width=-1): """space the data in a row with optional filling Arguments --------- left : str, to be aligned left right : str, to be aligned right filler : str, default ' '. must be of length 1 total_width : int, width of line. if ne...
python
def space_row(left, right, filler=' ', total_width=-1): """space the data in a row with optional filling Arguments --------- left : str, to be aligned left right : str, to be aligned right filler : str, default ' '. must be of length 1 total_width : int, width of line. if ne...
[ "def", "space_row", "(", "left", ",", "right", ",", "filler", "=", "' '", ",", "total_width", "=", "-", "1", ")", ":", "left", "=", "str", "(", "left", ")", "right", "=", "str", "(", "right", ")", "filler", "=", "str", "(", "filler", ")", "[", ...
space the data in a row with optional filling Arguments --------- left : str, to be aligned left right : str, to be aligned right filler : str, default ' '. must be of length 1 total_width : int, width of line. if negative number is specified, then that number of spaces ...
[ "space", "the", "data", "in", "a", "row", "with", "optional", "filling" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L489-L515
225,591
dswah/pyGAM
pygam/utils.py
gen_edge_knots
def gen_edge_knots(data, dtype, verbose=True): """ generate uniform knots from data including the edges of the data for discrete data, assumes k categories in [0, k-1] interval Parameters ---------- data : array-like with one dimension dtype : str in {'categorical', 'numerical'} verbos...
python
def gen_edge_knots(data, dtype, verbose=True): """ generate uniform knots from data including the edges of the data for discrete data, assumes k categories in [0, k-1] interval Parameters ---------- data : array-like with one dimension dtype : str in {'categorical', 'numerical'} verbos...
[ "def", "gen_edge_knots", "(", "data", ",", "dtype", ",", "verbose", "=", "True", ")", ":", "if", "dtype", "not", "in", "[", "'categorical'", ",", "'numerical'", "]", ":", "raise", "ValueError", "(", "'unsupported dtype: {}'", ".", "format", "(", "dtype", "...
generate uniform knots from data including the edges of the data for discrete data, assumes k categories in [0, k-1] interval Parameters ---------- data : array-like with one dimension dtype : str in {'categorical', 'numerical'} verbose : bool, default: True whether to print warnings ...
[ "generate", "uniform", "knots", "from", "data", "including", "the", "edges", "of", "the", "data" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L539-L566
225,592
dswah/pyGAM
pygam/utils.py
ylogydu
def ylogydu(y, u): """ tool to give desired output for the limit as y -> 0, which is 0 Parameters ---------- y : array-like of len(n) u : array-like of len(n) Returns ------- np.array len(n) """ mask = (np.atleast_1d(y)!=0.) out = np.zeros_like(u) out[mask] = y[mask...
python
def ylogydu(y, u): """ tool to give desired output for the limit as y -> 0, which is 0 Parameters ---------- y : array-like of len(n) u : array-like of len(n) Returns ------- np.array len(n) """ mask = (np.atleast_1d(y)!=0.) out = np.zeros_like(u) out[mask] = y[mask...
[ "def", "ylogydu", "(", "y", ",", "u", ")", ":", "mask", "=", "(", "np", ".", "atleast_1d", "(", "y", ")", "!=", "0.", ")", "out", "=", "np", ".", "zeros_like", "(", "u", ")", "out", "[", "mask", "]", "=", "y", "[", "mask", "]", "*", "np", ...
tool to give desired output for the limit as y -> 0, which is 0 Parameters ---------- y : array-like of len(n) u : array-like of len(n) Returns ------- np.array len(n)
[ "tool", "to", "give", "desired", "output", "for", "the", "limit", "as", "y", "-", ">", "0", "which", "is", "0" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L710-L726
225,593
dswah/pyGAM
pygam/utils.py
combine
def combine(*args): """ tool to perform tree search via recursion useful for developing the grid in a grid search Parameters ---------- args : list of lists Returns ------- list of all the combinations of the elements in the input lists """ if hasattr(args, '__iter__') and ...
python
def combine(*args): """ tool to perform tree search via recursion useful for developing the grid in a grid search Parameters ---------- args : list of lists Returns ------- list of all the combinations of the elements in the input lists """ if hasattr(args, '__iter__') and ...
[ "def", "combine", "(", "*", "args", ")", ":", "if", "hasattr", "(", "args", ",", "'__iter__'", ")", "and", "(", "len", "(", "args", ")", ">", "1", ")", ":", "subtree", "=", "combine", "(", "*", "args", "[", ":", "-", "1", "]", ")", "tree", "=...
tool to perform tree search via recursion useful for developing the grid in a grid search Parameters ---------- args : list of lists Returns ------- list of all the combinations of the elements in the input lists
[ "tool", "to", "perform", "tree", "search", "via", "recursion", "useful", "for", "developing", "the", "grid", "in", "a", "grid", "search" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L729-L753
225,594
dswah/pyGAM
pygam/utils.py
isiterable
def isiterable(obj, reject_string=True): """convenience tool to detect if something is iterable. in python3, strings count as iterables to we have the option to exclude them Parameters: ----------- obj : object to analyse reject_string : bool, whether to ignore strings Returns: -------...
python
def isiterable(obj, reject_string=True): """convenience tool to detect if something is iterable. in python3, strings count as iterables to we have the option to exclude them Parameters: ----------- obj : object to analyse reject_string : bool, whether to ignore strings Returns: -------...
[ "def", "isiterable", "(", "obj", ",", "reject_string", "=", "True", ")", ":", "iterable", "=", "hasattr", "(", "obj", ",", "'__len__'", ")", "if", "reject_string", ":", "iterable", "=", "iterable", "and", "not", "isinstance", "(", "obj", ",", "str", ")",...
convenience tool to detect if something is iterable. in python3, strings count as iterables to we have the option to exclude them Parameters: ----------- obj : object to analyse reject_string : bool, whether to ignore strings Returns: -------- bool, if the object is itereable.
[ "convenience", "tool", "to", "detect", "if", "something", "is", "iterable", ".", "in", "python3", "strings", "count", "as", "iterables", "to", "we", "have", "the", "option", "to", "exclude", "them" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L755-L774
225,595
dswah/pyGAM
pygam/utils.py
check_iterable_depth
def check_iterable_depth(obj, max_depth=100): """find the maximum depth of nesting of the iterable Parameters ---------- obj : iterable max_depth : int, default: 100 maximum depth beyond which we stop counting Returns ------- int """ def find_iterables(obj): ite...
python
def check_iterable_depth(obj, max_depth=100): """find the maximum depth of nesting of the iterable Parameters ---------- obj : iterable max_depth : int, default: 100 maximum depth beyond which we stop counting Returns ------- int """ def find_iterables(obj): ite...
[ "def", "check_iterable_depth", "(", "obj", ",", "max_depth", "=", "100", ")", ":", "def", "find_iterables", "(", "obj", ")", ":", "iterables", "=", "[", "]", "for", "item", "in", "obj", ":", "if", "isiterable", "(", "item", ")", ":", "iterables", "+=",...
find the maximum depth of nesting of the iterable Parameters ---------- obj : iterable max_depth : int, default: 100 maximum depth beyond which we stop counting Returns ------- int
[ "find", "the", "maximum", "depth", "of", "nesting", "of", "the", "iterable" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L776-L800
225,596
dswah/pyGAM
pygam/utils.py
flatten
def flatten(iterable): """convenience tool to flatten any nested iterable example: flatten([[[],[4]],[[[5,[6,7, []]]]]]) >>> [4, 5, 6, 7] flatten('hello') >>> 'hello' Parameters ---------- iterable Returns ------- flattened object """ if isite...
python
def flatten(iterable): """convenience tool to flatten any nested iterable example: flatten([[[],[4]],[[[5,[6,7, []]]]]]) >>> [4, 5, 6, 7] flatten('hello') >>> 'hello' Parameters ---------- iterable Returns ------- flattened object """ if isite...
[ "def", "flatten", "(", "iterable", ")", ":", "if", "isiterable", "(", "iterable", ")", ":", "flat", "=", "[", "]", "for", "item", "in", "list", "(", "iterable", ")", ":", "item", "=", "flatten", "(", "item", ")", "if", "not", "isiterable", "(", "it...
convenience tool to flatten any nested iterable example: flatten([[[],[4]],[[[5,[6,7, []]]]]]) >>> [4, 5, 6, 7] flatten('hello') >>> 'hello' Parameters ---------- iterable Returns ------- flattened object
[ "convenience", "tool", "to", "flatten", "any", "nested", "iterable" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L802-L830
225,597
dswah/pyGAM
pygam/utils.py
tensor_product
def tensor_product(a, b, reshape=True): """ compute the tensor protuct of two matrices a and b if a is (n, m_a), b is (n, m_b), then the result is (n, m_a * m_b) if reshape = True. or (n, m_a, m_b) otherwise Parameters --------- a : array-like of shape (n, m_a) b :...
python
def tensor_product(a, b, reshape=True): """ compute the tensor protuct of two matrices a and b if a is (n, m_a), b is (n, m_b), then the result is (n, m_a * m_b) if reshape = True. or (n, m_a, m_b) otherwise Parameters --------- a : array-like of shape (n, m_a) b :...
[ "def", "tensor_product", "(", "a", ",", "b", ",", "reshape", "=", "True", ")", ":", "assert", "a", ".", "ndim", "==", "2", ",", "'matrix a must be 2-dimensional, but found {} dimensions'", ".", "format", "(", "a", ".", "ndim", ")", "assert", "b", ".", "ndi...
compute the tensor protuct of two matrices a and b if a is (n, m_a), b is (n, m_b), then the result is (n, m_a * m_b) if reshape = True. or (n, m_a, m_b) otherwise Parameters --------- a : array-like of shape (n, m_a) b : array-like of shape (n, m_b) reshape : bool, d...
[ "compute", "the", "tensor", "protuct", "of", "two", "matrices", "a", "and", "b" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/utils.py#L833-L882
225,598
dswah/pyGAM
pygam/links.py
LogitLink.link
def link(self, mu, dist): """ glm link function this is useful for going from mu to the linear prediction Parameters ---------- mu : array-like of legth n dist : Distribution instance Returns ------- lp : np.array of length n """ ...
python
def link(self, mu, dist): """ glm link function this is useful for going from mu to the linear prediction Parameters ---------- mu : array-like of legth n dist : Distribution instance Returns ------- lp : np.array of length n """ ...
[ "def", "link", "(", "self", ",", "mu", ",", "dist", ")", ":", "return", "np", ".", "log", "(", "mu", ")", "-", "np", ".", "log", "(", "dist", ".", "levels", "-", "mu", ")" ]
glm link function this is useful for going from mu to the linear prediction Parameters ---------- mu : array-like of legth n dist : Distribution instance Returns ------- lp : np.array of length n
[ "glm", "link", "function", "this", "is", "useful", "for", "going", "from", "mu", "to", "the", "linear", "prediction" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/links.py#L103-L117
225,599
dswah/pyGAM
pygam/links.py
LogitLink.mu
def mu(self, lp, dist): """ glm mean function, ie inverse of link function this is useful for going from the linear prediction to mu Parameters ---------- lp : array-like of legth n dist : Distribution instance Returns ------- mu : np.arr...
python
def mu(self, lp, dist): """ glm mean function, ie inverse of link function this is useful for going from the linear prediction to mu Parameters ---------- lp : array-like of legth n dist : Distribution instance Returns ------- mu : np.arr...
[ "def", "mu", "(", "self", ",", "lp", ",", "dist", ")", ":", "elp", "=", "np", ".", "exp", "(", "lp", ")", "return", "dist", ".", "levels", "*", "elp", "/", "(", "elp", "+", "1", ")" ]
glm mean function, ie inverse of link function this is useful for going from the linear prediction to mu Parameters ---------- lp : array-like of legth n dist : Distribution instance Returns ------- mu : np.array of length n
[ "glm", "mean", "function", "ie", "inverse", "of", "link", "function", "this", "is", "useful", "for", "going", "from", "the", "linear", "prediction", "to", "mu" ]
b3e5c3cd580f0a3ad69f9372861624f67760c325
https://github.com/dswah/pyGAM/blob/b3e5c3cd580f0a3ad69f9372861624f67760c325/pygam/links.py#L119-L134