repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
kajala/django-jacc
jacc/interests.py
calculate_simple_interest
def calculate_simple_interest(entries, rate_pct: Decimal, interest_date: date or None=None, begin: date or None=None) -> Decimal: """ Calculates simple interest of specified entries over time. Does not accumulate interest to interest. :param entries: AccountEntry iterable (e.g. list/QuerySet) ordered by...
python
def calculate_simple_interest(entries, rate_pct: Decimal, interest_date: date or None=None, begin: date or None=None) -> Decimal: """ Calculates simple interest of specified entries over time. Does not accumulate interest to interest. :param entries: AccountEntry iterable (e.g. list/QuerySet) ordered by...
[ "def", "calculate_simple_interest", "(", "entries", ",", "rate_pct", ":", "Decimal", ",", "interest_date", ":", "date", "or", "None", "=", "None", ",", "begin", ":", "date", "or", "None", "=", "None", ")", "->", "Decimal", ":", "if", "interest_date", "is",...
Calculates simple interest of specified entries over time. Does not accumulate interest to interest. :param entries: AccountEntry iterable (e.g. list/QuerySet) ordered by timestamp (ascending) :param rate_pct: Interest rate %, e.g. 8.00 for 8% :param interest_date: Interest end date. Default is current ...
[ "Calculates", "simple", "interest", "of", "specified", "entries", "over", "time", ".", "Does", "not", "accumulate", "interest", "to", "interest", ".", ":", "param", "entries", ":", "AccountEntry", "iterable", "(", "e", ".", "g", ".", "list", "/", "QuerySet",...
train
https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/interests.py#L8-L63
sdss/sdss_access
python/sdss_access/misc/docupaths.py
_format_templates
def _format_templates(name, command, templates): ''' Creates a list-table directive for a set of defined environment variables Parameters: name (str): The name of the config section command (object): The sdss_access path instance templates (dict): ...
python
def _format_templates(name, command, templates): ''' Creates a list-table directive for a set of defined environment variables Parameters: name (str): The name of the config section command (object): The sdss_access path instance templates (dict): ...
[ "def", "_format_templates", "(", "name", ",", "command", ",", "templates", ")", ":", "yield", "'.. list-table:: {0}'", ".", "format", "(", "name", ")", "yield", "_indent", "(", "':widths: 20 50 70'", ")", "yield", "_indent", "(", "':header-rows: 1'", ")", "yield...
Creates a list-table directive for a set of defined environment variables Parameters: name (str): The name of the config section command (object): The sdss_access path instance templates (dict): A dictionary of the path templates Yields: ...
[ "Creates", "a", "list", "-", "table", "directive" ]
train
https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/misc/docupaths.py#L34-L64
sdss/sdss_access
python/sdss_access/misc/docupaths.py
PathDirective._generate_nodes
def _generate_nodes(self, name, command, templates=None): """Generate the relevant Sphinx nodes. Generates a section for the Tree datamodel. Formats a tree section as a list-table directive. Parameters: name (str): The name of the config to be documented, e...
python
def _generate_nodes(self, name, command, templates=None): """Generate the relevant Sphinx nodes. Generates a section for the Tree datamodel. Formats a tree section as a list-table directive. Parameters: name (str): The name of the config to be documented, e...
[ "def", "_generate_nodes", "(", "self", ",", "name", ",", "command", ",", "templates", "=", "None", ")", ":", "# the source name", "source_name", "=", "name", "# Title", "section", "=", "nodes", ".", "section", "(", "''", ",", "nodes", ".", "title", "(", ...
Generate the relevant Sphinx nodes. Generates a section for the Tree datamodel. Formats a tree section as a list-table directive. Parameters: name (str): The name of the config to be documented, e.g. 'sdsswork' command (object): The load...
[ "Generate", "the", "relevant", "Sphinx", "nodes", "." ]
train
https://github.com/sdss/sdss_access/blob/76375bbf37d39d2e4ccbed90bdfa9a4298784470/python/sdss_access/misc/docupaths.py#L105-L145
kpdyer/regex2dfa
third_party/re2/re2/make_unicode_casefold.py
_Delta
def _Delta(a, b): """Compute the delta for b - a. Even/odd and odd/even are handled specially, as described above.""" if a+1 == b: if a%2 == 0: return 'EvenOdd' else: return 'OddEven' if a == b+1: if a%2 == 0: return 'OddEven' else: return 'EvenOdd' return b - a
python
def _Delta(a, b): """Compute the delta for b - a. Even/odd and odd/even are handled specially, as described above.""" if a+1 == b: if a%2 == 0: return 'EvenOdd' else: return 'OddEven' if a == b+1: if a%2 == 0: return 'OddEven' else: return 'EvenOdd' return b - a
[ "def", "_Delta", "(", "a", ",", "b", ")", ":", "if", "a", "+", "1", "==", "b", ":", "if", "a", "%", "2", "==", "0", ":", "return", "'EvenOdd'", "else", ":", "return", "'OddEven'", "if", "a", "==", "b", "+", "1", ":", "if", "a", "%", "2", ...
Compute the delta for b - a. Even/odd and odd/even are handled specially, as described above.
[ "Compute", "the", "delta", "for", "b", "-", "a", ".", "Even", "/", "odd", "and", "odd", "/", "even", "are", "handled", "specially", "as", "described", "above", "." ]
train
https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/make_unicode_casefold.py#L30-L43
kpdyer/regex2dfa
third_party/re2/re2/make_unicode_casefold.py
_AddDelta
def _AddDelta(a, delta): """Return a + delta, handling EvenOdd and OddEven specially.""" if type(delta) == int: return a+delta if delta == 'EvenOdd': if a%2 == 0: return a+1 else: return a-1 if delta == 'OddEven': if a%2 == 1: return a+1 else: return a-1 print >>sys...
python
def _AddDelta(a, delta): """Return a + delta, handling EvenOdd and OddEven specially.""" if type(delta) == int: return a+delta if delta == 'EvenOdd': if a%2 == 0: return a+1 else: return a-1 if delta == 'OddEven': if a%2 == 1: return a+1 else: return a-1 print >>sys...
[ "def", "_AddDelta", "(", "a", ",", "delta", ")", ":", "if", "type", "(", "delta", ")", "==", "int", ":", "return", "a", "+", "delta", "if", "delta", "==", "'EvenOdd'", ":", "if", "a", "%", "2", "==", "0", ":", "return", "a", "+", "1", "else", ...
Return a + delta, handling EvenOdd and OddEven specially.
[ "Return", "a", "+", "delta", "handling", "EvenOdd", "and", "OddEven", "specially", "." ]
train
https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/make_unicode_casefold.py#L45-L60
kpdyer/regex2dfa
third_party/re2/re2/make_unicode_casefold.py
_MakeRanges
def _MakeRanges(pairs): """Turn a list like [(65,97), (66, 98), ..., (90,122)] into [(65, 90, +32)].""" ranges = [] last = -100 def evenodd(last, a, b, r): if a != last+1 or b != _AddDelta(a, r[2]): return False r[1] = a return True def evenoddpair(last, a, b, r): if a != last+2: ...
python
def _MakeRanges(pairs): """Turn a list like [(65,97), (66, 98), ..., (90,122)] into [(65, 90, +32)].""" ranges = [] last = -100 def evenodd(last, a, b, r): if a != last+1 or b != _AddDelta(a, r[2]): return False r[1] = a return True def evenoddpair(last, a, b, r): if a != last+2: ...
[ "def", "_MakeRanges", "(", "pairs", ")", ":", "ranges", "=", "[", "]", "last", "=", "-", "100", "def", "evenodd", "(", "last", ",", "a", ",", "b", ",", "r", ")", ":", "if", "a", "!=", "last", "+", "1", "or", "b", "!=", "_AddDelta", "(", "a", ...
Turn a list like [(65,97), (66, 98), ..., (90,122)] into [(65, 90, +32)].
[ "Turn", "a", "list", "like", "[", "(", "65", "97", ")", "(", "66", "98", ")", "...", "(", "90", "122", ")", "]", "into", "[", "(", "65", "90", "+", "32", ")", "]", "." ]
train
https://github.com/kpdyer/regex2dfa/blob/109f877e60ef0dfcb430f11516d215930b7b9936/third_party/re2/re2/make_unicode_casefold.py#L62-L99
kajala/django-jacc
jacc/admin.py
align_lines
def align_lines(lines: list, column_separator: str='|') -> list: """ Pads lines so that all rows in single column match. Columns separated by '|' in every line. :param lines: list of lines :param column_separator: column separator. default is '|' :return: list of lines """ rows = [] col_...
python
def align_lines(lines: list, column_separator: str='|') -> list: """ Pads lines so that all rows in single column match. Columns separated by '|' in every line. :param lines: list of lines :param column_separator: column separator. default is '|' :return: list of lines """ rows = [] col_...
[ "def", "align_lines", "(", "lines", ":", "list", ",", "column_separator", ":", "str", "=", "'|'", ")", "->", "list", ":", "rows", "=", "[", "]", "col_len", "=", "[", "]", "for", "line", "in", "lines", ":", "line", "=", "str", "(", "line", ")", "c...
Pads lines so that all rows in single column match. Columns separated by '|' in every line. :param lines: list of lines :param column_separator: column separator. default is '|' :return: list of lines
[ "Pads", "lines", "so", "that", "all", "rows", "in", "single", "column", "match", ".", "Columns", "separated", "by", "|", "in", "every", "line", ".", ":", "param", "lines", ":", "list", "of", "lines", ":", "param", "column_separator", ":", "column", "sepa...
train
https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/admin.py#L31-L61
kajala/django-jacc
jacc/admin.py
resend_invoices
def resend_invoices(modeladmin, request: HttpRequest, queryset: QuerySet): """ Marks invoices with as un-sent. :param modeladmin: :param request: :param queryset: :return: """ user = request.user assert isinstance(user, User) for obj in queryset: assert isinstance(obj, In...
python
def resend_invoices(modeladmin, request: HttpRequest, queryset: QuerySet): """ Marks invoices with as un-sent. :param modeladmin: :param request: :param queryset: :return: """ user = request.user assert isinstance(user, User) for obj in queryset: assert isinstance(obj, In...
[ "def", "resend_invoices", "(", "modeladmin", ",", "request", ":", "HttpRequest", ",", "queryset", ":", "QuerySet", ")", ":", "user", "=", "request", ".", "user", "assert", "isinstance", "(", "user", ",", "User", ")", "for", "obj", "in", "queryset", ":", ...
Marks invoices with as un-sent. :param modeladmin: :param request: :param queryset: :return:
[ "Marks", "invoices", "with", "as", "un", "-", "sent", ".", ":", "param", "modeladmin", ":", ":", "param", "request", ":", ":", "param", "queryset", ":", ":", "return", ":" ]
train
https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/admin.py#L507-L520
kajala/django-jacc
jacc/admin.py
AccountEntryInlineFormSet.clean_entries
def clean_entries(self, source_invoice: Invoice or None, settled_invoice: Invoice or None, account: Account, **kw): """ This needs to be called from a derived class clean(). :param source_invoice: :param settled_invoice: :param account: :return: None """ f...
python
def clean_entries(self, source_invoice: Invoice or None, settled_invoice: Invoice or None, account: Account, **kw): """ This needs to be called from a derived class clean(). :param source_invoice: :param settled_invoice: :param account: :return: None """ f...
[ "def", "clean_entries", "(", "self", ",", "source_invoice", ":", "Invoice", "or", "None", ",", "settled_invoice", ":", "Invoice", "or", "None", ",", "account", ":", "Account", ",", "*", "*", "kw", ")", ":", "for", "form", "in", "self", ".", "forms", ":...
This needs to be called from a derived class clean(). :param source_invoice: :param settled_invoice: :param account: :return: None
[ "This", "needs", "to", "be", "called", "from", "a", "derived", "class", "clean", "()", ".", ":", "param", "source_invoice", ":", ":", "param", "settled_invoice", ":", ":", "param", "account", ":", ":", "return", ":", "None" ]
train
https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/admin.py#L335-L357
kajala/django-jacc
jacc/admin.py
InvoiceAdmin._format_date
def _format_date(self, obj) -> str: """ Short date format. :param obj: date or datetime or None :return: str """ if obj is None: return '' if isinstance(obj, datetime): obj = obj.date() return date_format(obj, 'SHORT_DATE_FORMAT')
python
def _format_date(self, obj) -> str: """ Short date format. :param obj: date or datetime or None :return: str """ if obj is None: return '' if isinstance(obj, datetime): obj = obj.date() return date_format(obj, 'SHORT_DATE_FORMAT')
[ "def", "_format_date", "(", "self", ",", "obj", ")", "->", "str", ":", "if", "obj", "is", "None", ":", "return", "''", "if", "isinstance", "(", "obj", ",", "datetime", ")", ":", "obj", "=", "obj", ".", "date", "(", ")", "return", "date_format", "("...
Short date format. :param obj: date or datetime or None :return: str
[ "Short", "date", "format", ".", ":", "param", "obj", ":", "date", "or", "datetime", "or", "None", ":", "return", ":", "str" ]
train
https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/admin.py#L669-L679
kajala/django-jacc
jacc/helpers.py
sum_queryset
def sum_queryset(qs: QuerySet, key: str= 'amount', default=Decimal(0)) -> Decimal: """ Returns aggregate sum of queryset 'amount' field. :param qs: QuerySet :param key: Field to sum (default: 'amount') :param default: Default value if no results :return: Sum of 'amount' field values (coalesced 0...
python
def sum_queryset(qs: QuerySet, key: str= 'amount', default=Decimal(0)) -> Decimal: """ Returns aggregate sum of queryset 'amount' field. :param qs: QuerySet :param key: Field to sum (default: 'amount') :param default: Default value if no results :return: Sum of 'amount' field values (coalesced 0...
[ "def", "sum_queryset", "(", "qs", ":", "QuerySet", ",", "key", ":", "str", "=", "'amount'", ",", "default", "=", "Decimal", "(", "0", ")", ")", "->", "Decimal", ":", "res", "=", "qs", ".", "aggregate", "(", "b", "=", "Sum", "(", "key", ")", ")", ...
Returns aggregate sum of queryset 'amount' field. :param qs: QuerySet :param key: Field to sum (default: 'amount') :param default: Default value if no results :return: Sum of 'amount' field values (coalesced 0 if None)
[ "Returns", "aggregate", "sum", "of", "queryset", "amount", "field", ".", ":", "param", "qs", ":", "QuerySet", ":", "param", "key", ":", "Field", "to", "sum", "(", "default", ":", "amount", ")", ":", "param", "default", ":", "Default", "value", "if", "n...
train
https://github.com/kajala/django-jacc/blob/2c4356a46bc46430569136303488db6a9af65560/jacc/helpers.py#L5-L14
marten-de-vries/Flask-WebSub
flask_websub/subscriber/__init__.py
Subscriber.build_blueprint
def build_blueprint(self, url_prefix=''): """Build a blueprint that contains the endpoints for callback URLs of the current subscriber. Only call this once per instance. Arguments: - url_prefix; this allows you to prefix the callback URLs in your app. """ self.blueprint_name, s...
python
def build_blueprint(self, url_prefix=''): """Build a blueprint that contains the endpoints for callback URLs of the current subscriber. Only call this once per instance. Arguments: - url_prefix; this allows you to prefix the callback URLs in your app. """ self.blueprint_name, s...
[ "def", "build_blueprint", "(", "self", ",", "url_prefix", "=", "''", ")", ":", "self", ".", "blueprint_name", ",", "self", ".", "blueprint", "=", "build_blueprint", "(", "self", ",", "url_prefix", ")", "return", "self", ".", "blueprint" ]
Build a blueprint that contains the endpoints for callback URLs of the current subscriber. Only call this once per instance. Arguments: - url_prefix; this allows you to prefix the callback URLs in your app.
[ "Build", "a", "blueprint", "that", "contains", "the", "endpoints", "for", "callback", "URLs", "of", "the", "current", "subscriber", ".", "Only", "call", "this", "once", "per", "instance", ".", "Arguments", ":" ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/subscriber/__init__.py#L74-L82
marten-de-vries/Flask-WebSub
flask_websub/subscriber/__init__.py
Subscriber.unsubscribe
def unsubscribe(self, callback_id): """Ask the hub to cancel the subscription for callback_id, then delete it from the local database if successful. """ request = self.get_active_subscription(callback_id) request['mode'] = 'unsubscribe' self.subscribe_impl(callback_id, *...
python
def unsubscribe(self, callback_id): """Ask the hub to cancel the subscription for callback_id, then delete it from the local database if successful. """ request = self.get_active_subscription(callback_id) request['mode'] = 'unsubscribe' self.subscribe_impl(callback_id, *...
[ "def", "unsubscribe", "(", "self", ",", "callback_id", ")", ":", "request", "=", "self", ".", "get_active_subscription", "(", "callback_id", ")", "request", "[", "'mode'", "]", "=", "'unsubscribe'", "self", ".", "subscribe_impl", "(", "callback_id", ",", "*", ...
Ask the hub to cancel the subscription for callback_id, then delete it from the local database if successful.
[ "Ask", "the", "hub", "to", "cancel", "the", "subscription", "for", "callback_id", "then", "delete", "it", "from", "the", "local", "database", "if", "successful", "." ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/subscriber/__init__.py#L161-L168
marten-de-vries/Flask-WebSub
flask_websub/subscriber/__init__.py
Subscriber.renew_close_to_expiration
def renew_close_to_expiration(self, margin_in_seconds=A_DAY): """Automatically renew subscriptions that are close to expiring, or have already expired. margin_in_seconds determines if a subscription is in fact close to expiring. By default, said margin is set to be a single day (24 hours...
python
def renew_close_to_expiration(self, margin_in_seconds=A_DAY): """Automatically renew subscriptions that are close to expiring, or have already expired. margin_in_seconds determines if a subscription is in fact close to expiring. By default, said margin is set to be a single day (24 hours...
[ "def", "renew_close_to_expiration", "(", "self", ",", "margin_in_seconds", "=", "A_DAY", ")", ":", "subscriptions", "=", "self", ".", "storage", ".", "close_to_expiration", "(", "margin_in_seconds", ")", "for", "subscription", "in", "subscriptions", ":", "try", ":...
Automatically renew subscriptions that are close to expiring, or have already expired. margin_in_seconds determines if a subscription is in fact close to expiring. By default, said margin is set to be a single day (24 hours). This is a long-running method for any non-trivial usage of th...
[ "Automatically", "renew", "subscriptions", "that", "are", "close", "to", "expiring", "or", "have", "already", "expired", ".", "margin_in_seconds", "determines", "if", "a", "subscription", "is", "in", "fact", "close", "to", "expiring", ".", "By", "default", "said...
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/subscriber/__init__.py#L186-L204
marten-de-vries/Flask-WebSub
flask_websub/subscriber/discovery.py
discover
def discover(url, timeout=None): """Discover the hub url and topic url of a given url. Firstly, by inspecting the page's headers, secondarily by inspecting the content for link tags. timeout determines how long to wait for the url to load. It defaults to 3. """ resp = get_content({'REQUEST_TIMEOUT...
python
def discover(url, timeout=None): """Discover the hub url and topic url of a given url. Firstly, by inspecting the page's headers, secondarily by inspecting the content for link tags. timeout determines how long to wait for the url to load. It defaults to 3. """ resp = get_content({'REQUEST_TIMEOUT...
[ "def", "discover", "(", "url", ",", "timeout", "=", "None", ")", ":", "resp", "=", "get_content", "(", "{", "'REQUEST_TIMEOUT'", ":", "timeout", "}", ",", "url", ")", "parser", "=", "LinkParser", "(", ")", "parser", ".", "hub_url", "=", "(", "resp", ...
Discover the hub url and topic url of a given url. Firstly, by inspecting the page's headers, secondarily by inspecting the content for link tags. timeout determines how long to wait for the url to load. It defaults to 3.
[ "Discover", "the", "hub", "url", "and", "topic", "url", "of", "a", "given", "url", ".", "Firstly", "by", "inspecting", "the", "page", "s", "headers", "secondarily", "by", "inspecting", "the", "content", "for", "link", "tags", "." ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/subscriber/discovery.py#L8-L28
LLNL/certipy
certipy/certipy.py
open_tls_file
def open_tls_file(file_path, mode, private=True): """Context to ensure correct file permissions for certs and directories Ensures: - A containing directory with appropriate permissions - Correct file permissions based on what the file is (0o600 for keys and 0o644 for certs) """ ...
python
def open_tls_file(file_path, mode, private=True): """Context to ensure correct file permissions for certs and directories Ensures: - A containing directory with appropriate permissions - Correct file permissions based on what the file is (0o600 for keys and 0o644 for certs) """ ...
[ "def", "open_tls_file", "(", "file_path", ",", "mode", ",", "private", "=", "True", ")", ":", "containing_dir", "=", "os", ".", "path", ".", "dirname", "(", "file_path", ")", "fh", "=", "None", "try", ":", "if", "'w'", "in", "mode", ":", "os", ".", ...
Context to ensure correct file permissions for certs and directories Ensures: - A containing directory with appropriate permissions - Correct file permissions based on what the file is (0o600 for keys and 0o644 for certs)
[ "Context", "to", "ensure", "correct", "file", "permissions", "for", "certs", "and", "directories" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L49-L74
LLNL/certipy
certipy/certipy.py
TLSFile.load
def load(self): """Load from a file and return an x509 object""" private = self.is_private() with open_tls_file(self.file_path, 'r', private=private) as fh: if private: self.x509 = crypto.load_privatekey(self.encoding, fh.read()) else: sel...
python
def load(self): """Load from a file and return an x509 object""" private = self.is_private() with open_tls_file(self.file_path, 'r', private=private) as fh: if private: self.x509 = crypto.load_privatekey(self.encoding, fh.read()) else: sel...
[ "def", "load", "(", "self", ")", ":", "private", "=", "self", ".", "is_private", "(", ")", "with", "open_tls_file", "(", "self", ".", "file_path", ",", "'r'", ",", "private", "=", "private", ")", "as", "fh", ":", "if", "private", ":", "self", ".", ...
Load from a file and return an x509 object
[ "Load", "from", "a", "file", "and", "return", "an", "x509", "object" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L133-L142
LLNL/certipy
certipy/certipy.py
TLSFile.save
def save(self, x509): """Persist this x509 object to disk""" self.x509 = x509 with open_tls_file(self.file_path, 'w', private=self.is_private()) as fh: fh.write(str(self))
python
def save(self, x509): """Persist this x509 object to disk""" self.x509 = x509 with open_tls_file(self.file_path, 'w', private=self.is_private()) as fh: fh.write(str(self))
[ "def", "save", "(", "self", ",", "x509", ")", ":", "self", ".", "x509", "=", "x509", "with", "open_tls_file", "(", "self", ".", "file_path", ",", "'w'", ",", "private", "=", "self", ".", "is_private", "(", ")", ")", "as", "fh", ":", "fh", ".", "w...
Persist this x509 object to disk
[ "Persist", "this", "x509", "object", "to", "disk" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L144-L150
LLNL/certipy
certipy/certipy.py
TLSFileBundle._setup_tls_files
def _setup_tls_files(self, files): """Initiates TLSFIle objects with the paths given to this bundle""" for file_type in TLSFileType: if file_type.value in files: file_path = files[file_type.value] setattr(self, file_type.value, TLSFile...
python
def _setup_tls_files(self, files): """Initiates TLSFIle objects with the paths given to this bundle""" for file_type in TLSFileType: if file_type.value in files: file_path = files[file_type.value] setattr(self, file_type.value, TLSFile...
[ "def", "_setup_tls_files", "(", "self", ",", "files", ")", ":", "for", "file_type", "in", "TLSFileType", ":", "if", "file_type", ".", "value", "in", "files", ":", "file_path", "=", "files", "[", "file_type", ".", "value", "]", "setattr", "(", "self", ","...
Initiates TLSFIle objects with the paths given to this bundle
[ "Initiates", "TLSFIle", "objects", "with", "the", "paths", "given", "to", "this", "bundle" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L171-L178
LLNL/certipy
certipy/certipy.py
TLSFileBundle.save_x509s
def save_x509s(self, x509s): """Saves the x509 objects to the paths known by this bundle""" for file_type in TLSFileType: if file_type.value in x509s: x509 = x509s[file_type.value] if file_type is not TLSFileType.CA: # persist this key or ...
python
def save_x509s(self, x509s): """Saves the x509 objects to the paths known by this bundle""" for file_type in TLSFileType: if file_type.value in x509s: x509 = x509s[file_type.value] if file_type is not TLSFileType.CA: # persist this key or ...
[ "def", "save_x509s", "(", "self", ",", "x509s", ")", ":", "for", "file_type", "in", "TLSFileType", ":", "if", "file_type", ".", "value", "in", "x509s", ":", "x509", "=", "x509s", "[", "file_type", ".", "value", "]", "if", "file_type", "is", "not", "TLS...
Saves the x509 objects to the paths known by this bundle
[ "Saves", "the", "x509", "objects", "to", "the", "paths", "known", "by", "this", "bundle" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L180-L190
LLNL/certipy
certipy/certipy.py
TLSFileBundle.to_record
def to_record(self): """Create a CertStore record from this TLSFileBundle""" tf_list = [getattr(self, k, None) for k in [_.value for _ in TLSFileType]] # If a cert isn't defined in this bundle, remove it tf_list = filter(lambda x: x, tf_list) files = {tf.file_...
python
def to_record(self): """Create a CertStore record from this TLSFileBundle""" tf_list = [getattr(self, k, None) for k in [_.value for _ in TLSFileType]] # If a cert isn't defined in this bundle, remove it tf_list = filter(lambda x: x, tf_list) files = {tf.file_...
[ "def", "to_record", "(", "self", ")", ":", "tf_list", "=", "[", "getattr", "(", "self", ",", "k", ",", "None", ")", "for", "k", "in", "[", "_", ".", "value", "for", "_", "in", "TLSFileType", "]", "]", "# If a cert isn't defined in this bundle, remove it", ...
Create a CertStore record from this TLSFileBundle
[ "Create", "a", "CertStore", "record", "from", "this", "TLSFileBundle" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L203-L212
LLNL/certipy
certipy/certipy.py
TLSFileBundle.from_record
def from_record(self, record): """Build a bundle from a CertStore record""" self.record = record self._setup_tls_files(self.record['files']) return self
python
def from_record(self, record): """Build a bundle from a CertStore record""" self.record = record self._setup_tls_files(self.record['files']) return self
[ "def", "from_record", "(", "self", ",", "record", ")", ":", "self", ".", "record", "=", "record", "self", ".", "_setup_tls_files", "(", "self", ".", "record", "[", "'files'", "]", ")", "return", "self" ]
Build a bundle from a CertStore record
[ "Build", "a", "bundle", "from", "a", "CertStore", "record" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L214-L219
LLNL/certipy
certipy/certipy.py
CertStore.save
def save(self): """Write the store dict to a file specified by store_file_path""" with open(self.store_file_path, 'w') as fh: fh.write(json.dumps(self.store, indent=4))
python
def save(self): """Write the store dict to a file specified by store_file_path""" with open(self.store_file_path, 'w') as fh: fh.write(json.dumps(self.store, indent=4))
[ "def", "save", "(", "self", ")", ":", "with", "open", "(", "self", ".", "store_file_path", ",", "'w'", ")", "as", "fh", ":", "fh", ".", "write", "(", "json", ".", "dumps", "(", "self", ".", "store", ",", "indent", "=", "4", ")", ")" ]
Write the store dict to a file specified by store_file_path
[ "Write", "the", "store", "dict", "to", "a", "file", "specified", "by", "store_file_path" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L253-L257
LLNL/certipy
certipy/certipy.py
CertStore.load
def load(self): """Read the store dict from file""" with open(self.store_file_path, 'r') as fh: self.store = json.loads(fh.read())
python
def load(self): """Read the store dict from file""" with open(self.store_file_path, 'r') as fh: self.store = json.loads(fh.read())
[ "def", "load", "(", "self", ")", ":", "with", "open", "(", "self", ".", "store_file_path", ",", "'r'", ")", "as", "fh", ":", "self", ".", "store", "=", "json", ".", "loads", "(", "fh", ".", "read", "(", ")", ")" ]
Read the store dict from file
[ "Read", "the", "store", "dict", "from", "file" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L259-L263
LLNL/certipy
certipy/certipy.py
CertStore.get_record
def get_record(self, common_name): """Return the record associated with this common name In most cases, all that's really needed to use an existing cert are the file paths to the files that make up that cert. This method returns just that and doesn't bother loading the associated files....
python
def get_record(self, common_name): """Return the record associated with this common name In most cases, all that's really needed to use an existing cert are the file paths to the files that make up that cert. This method returns just that and doesn't bother loading the associated files....
[ "def", "get_record", "(", "self", ",", "common_name", ")", ":", "try", ":", "record", "=", "self", ".", "store", "[", "common_name", "]", "return", "record", "except", "KeyError", "as", "e", ":", "raise", "CertNotFoundError", "(", "\"Unable to find record of {...
Return the record associated with this common name In most cases, all that's really needed to use an existing cert are the file paths to the files that make up that cert. This method returns just that and doesn't bother loading the associated files.
[ "Return", "the", "record", "associated", "with", "this", "common", "name" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L265-L279
LLNL/certipy
certipy/certipy.py
CertStore.get_files
def get_files(self, common_name): """Return a bundle of TLS files associated with a common name""" record = self.get_record(common_name) return TLSFileBundle(common_name).from_record(record)
python
def get_files(self, common_name): """Return a bundle of TLS files associated with a common name""" record = self.get_record(common_name) return TLSFileBundle(common_name).from_record(record)
[ "def", "get_files", "(", "self", ",", "common_name", ")", ":", "record", "=", "self", ".", "get_record", "(", "common_name", ")", "return", "TLSFileBundle", "(", "common_name", ")", ".", "from_record", "(", "record", ")" ]
Return a bundle of TLS files associated with a common name
[ "Return", "a", "bundle", "of", "TLS", "files", "associated", "with", "a", "common", "name" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L281-L285
LLNL/certipy
certipy/certipy.py
CertStore.add_record
def add_record(self, common_name, serial=0, parent_ca='', signees=None, files=None, record=None, is_ca=False, overwrite=False): """Manually create a record of certs Generally, Certipy can be left to manage certificate locations and storage, but it is occasi...
python
def add_record(self, common_name, serial=0, parent_ca='', signees=None, files=None, record=None, is_ca=False, overwrite=False): """Manually create a record of certs Generally, Certipy can be left to manage certificate locations and storage, but it is occasi...
[ "def", "add_record", "(", "self", ",", "common_name", ",", "serial", "=", "0", ",", "parent_ca", "=", "''", ",", "signees", "=", "None", ",", "files", "=", "None", ",", "record", "=", "None", ",", "is_ca", "=", "False", ",", "overwrite", "=", "False"...
Manually create a record of certs Generally, Certipy can be left to manage certificate locations and storage, but it is occasionally useful to keep track of a set of certs that were created externally (for example, let's encrypt)
[ "Manually", "create", "a", "record", "of", "certs" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L287-L315
LLNL/certipy
certipy/certipy.py
CertStore.add_files
def add_files(self, common_name, x509s, files=None, parent_ca='', is_ca=False, signees=None, serial=0, overwrite=False): """Add a set files comprising a certificate to Certipy Used with all the defaults, Certipy will manage creation of file paths to be used to store these file...
python
def add_files(self, common_name, x509s, files=None, parent_ca='', is_ca=False, signees=None, serial=0, overwrite=False): """Add a set files comprising a certificate to Certipy Used with all the defaults, Certipy will manage creation of file paths to be used to store these file...
[ "def", "add_files", "(", "self", ",", "common_name", ",", "x509s", ",", "files", "=", "None", ",", "parent_ca", "=", "''", ",", "is_ca", "=", "False", ",", "signees", "=", "None", ",", "serial", "=", "0", ",", "overwrite", "=", "False", ")", ":", "...
Add a set files comprising a certificate to Certipy Used with all the defaults, Certipy will manage creation of file paths to be used to store these files to disk and automatically calls save on all TLSFiles that it creates (and where it makes sense to).
[ "Add", "a", "set", "files", "comprising", "a", "certificate", "to", "Certipy" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L317-L355
LLNL/certipy
certipy/certipy.py
CertStore.remove_sign_link
def remove_sign_link(self, ca_name, signee_name): """Removes signee_name to the signee list for ca_name""" ca_record = self.get_record(ca_name) signee_record = self.get_record(signee_name) signees = ca_record['signees'] or {} signees = Counter(signees) if signee_name in ...
python
def remove_sign_link(self, ca_name, signee_name): """Removes signee_name to the signee list for ca_name""" ca_record = self.get_record(ca_name) signee_record = self.get_record(signee_name) signees = ca_record['signees'] or {} signees = Counter(signees) if signee_name in ...
[ "def", "remove_sign_link", "(", "self", ",", "ca_name", ",", "signee_name", ")", ":", "ca_record", "=", "self", ".", "get_record", "(", "ca_name", ")", "signee_record", "=", "self", ".", "get_record", "(", "signee_name", ")", "signees", "=", "ca_record", "["...
Removes signee_name to the signee list for ca_name
[ "Removes", "signee_name", "to", "the", "signee", "list", "for", "ca_name" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L370-L381
LLNL/certipy
certipy/certipy.py
CertStore.update_record
def update_record(self, common_name, **fields): """Update fields in an existing record""" record = self.get_record(common_name) if fields is not None: for field, value in fields: record[field] = value self.save() return record
python
def update_record(self, common_name, **fields): """Update fields in an existing record""" record = self.get_record(common_name) if fields is not None: for field, value in fields: record[field] = value self.save() return record
[ "def", "update_record", "(", "self", ",", "common_name", ",", "*", "*", "fields", ")", ":", "record", "=", "self", ".", "get_record", "(", "common_name", ")", "if", "fields", "is", "not", "None", ":", "for", "field", ",", "value", "in", "fields", ":", ...
Update fields in an existing record
[ "Update", "fields", "in", "an", "existing", "record" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L383-L391
LLNL/certipy
certipy/certipy.py
CertStore.remove_record
def remove_record(self, common_name): """Delete the record associated with this common name""" bundle = self.get_files(common_name) num_signees = len(Counter(bundle.record['signees'])) if bundle.is_ca() and num_signees > 0: raise CertificateAuthorityInUseError( ...
python
def remove_record(self, common_name): """Delete the record associated with this common name""" bundle = self.get_files(common_name) num_signees = len(Counter(bundle.record['signees'])) if bundle.is_ca() and num_signees > 0: raise CertificateAuthorityInUseError( ...
[ "def", "remove_record", "(", "self", ",", "common_name", ")", ":", "bundle", "=", "self", ".", "get_files", "(", "common_name", ")", "num_signees", "=", "len", "(", "Counter", "(", "bundle", ".", "record", "[", "'signees'", "]", ")", ")", "if", "bundle",...
Delete the record associated with this common name
[ "Delete", "the", "record", "associated", "with", "this", "common", "name" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L393-L412
LLNL/certipy
certipy/certipy.py
CertStore.remove_files
def remove_files(self, common_name, delete_dir=False): """Delete files and record associated with this common name""" record = self.remove_record(common_name) if delete_dir: delete_dirs = [] if 'files' in record: key_containing_dir = os.path.dirname(recor...
python
def remove_files(self, common_name, delete_dir=False): """Delete files and record associated with this common name""" record = self.remove_record(common_name) if delete_dir: delete_dirs = [] if 'files' in record: key_containing_dir = os.path.dirname(recor...
[ "def", "remove_files", "(", "self", ",", "common_name", ",", "delete_dir", "=", "False", ")", ":", "record", "=", "self", ".", "remove_record", "(", "common_name", ")", "if", "delete_dir", ":", "delete_dirs", "=", "[", "]", "if", "'files'", "in", "record",...
Delete files and record associated with this common name
[ "Delete", "files", "and", "record", "associated", "with", "this", "common", "name" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L414-L428
LLNL/certipy
certipy/certipy.py
Certipy.create_key_pair
def create_key_pair(self, cert_type, bits): """ Create a public/private key pair. Arguments: type - Key type, must be one of TYPE_RSA and TYPE_DSA bits - Number of bits to use in the key Returns: The public/private key pair in a PKey object """ pkey...
python
def create_key_pair(self, cert_type, bits): """ Create a public/private key pair. Arguments: type - Key type, must be one of TYPE_RSA and TYPE_DSA bits - Number of bits to use in the key Returns: The public/private key pair in a PKey object """ pkey...
[ "def", "create_key_pair", "(", "self", ",", "cert_type", ",", "bits", ")", ":", "pkey", "=", "crypto", ".", "PKey", "(", ")", "pkey", ".", "generate_key", "(", "cert_type", ",", "bits", ")", "return", "pkey" ]
Create a public/private key pair. Arguments: type - Key type, must be one of TYPE_RSA and TYPE_DSA bits - Number of bits to use in the key Returns: The public/private key pair in a PKey object
[ "Create", "a", "public", "/", "private", "key", "pair", "." ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L437-L448
LLNL/certipy
certipy/certipy.py
Certipy.sign
def sign(self, req, issuer_cert_key, validity_period, digest="sha256", extensions=None, serial=0): """ Generate a certificate given a certificate request. Arguments: req - Certificate request to use issuer_cert - The certificate of the issuer ...
python
def sign(self, req, issuer_cert_key, validity_period, digest="sha256", extensions=None, serial=0): """ Generate a certificate given a certificate request. Arguments: req - Certificate request to use issuer_cert - The certificate of the issuer ...
[ "def", "sign", "(", "self", ",", "req", ",", "issuer_cert_key", ",", "validity_period", ",", "digest", "=", "\"sha256\"", ",", "extensions", "=", "None", ",", "serial", "=", "0", ")", ":", "issuer_cert", ",", "issuer_key", "=", "issuer_cert_key", "not_before...
Generate a certificate given a certificate request. Arguments: req - Certificate request to use issuer_cert - The certificate of the issuer issuer_key - The private key of the issuer not_before - Timestamp (relative to now) when the ...
[ "Generate", "a", "certificate", "given", "a", "certificate", "request", "." ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L487-L522
LLNL/certipy
certipy/certipy.py
Certipy.create_ca_bundle_for_names
def create_ca_bundle_for_names(self, bundle_name, names): """Create a CA bundle to trust only certs defined in names """ records = [rec for name, rec in self.store.store.items() if name in names] return self.create_bundle( bundle_name, names=[r['parent_ca'...
python
def create_ca_bundle_for_names(self, bundle_name, names): """Create a CA bundle to trust only certs defined in names """ records = [rec for name, rec in self.store.store.items() if name in names] return self.create_bundle( bundle_name, names=[r['parent_ca'...
[ "def", "create_ca_bundle_for_names", "(", "self", ",", "bundle_name", ",", "names", ")", ":", "records", "=", "[", "rec", "for", "name", ",", "rec", "in", "self", ".", "store", ".", "store", ".", "items", "(", ")", "if", "name", "in", "names", "]", "...
Create a CA bundle to trust only certs defined in names
[ "Create", "a", "CA", "bundle", "to", "trust", "only", "certs", "defined", "in", "names" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L524-L531
LLNL/certipy
certipy/certipy.py
Certipy.create_bundle
def create_bundle(self, bundle_name, names=None, ca_only=True): """Create a bundle of public certs for trust distribution This will create a bundle of both CAs and/or regular certificates. Arguments: names - The names of certs to include in the bundle bundle_name - The ...
python
def create_bundle(self, bundle_name, names=None, ca_only=True): """Create a bundle of public certs for trust distribution This will create a bundle of both CAs and/or regular certificates. Arguments: names - The names of certs to include in the bundle bundle_name - The ...
[ "def", "create_bundle", "(", "self", ",", "bundle_name", ",", "names", "=", "None", ",", "ca_only", "=", "True", ")", ":", "if", "not", "names", ":", "if", "ca_only", ":", "names", "=", "[", "]", "for", "name", ",", "record", "in", "self", ".", "st...
Create a bundle of public certs for trust distribution This will create a bundle of both CAs and/or regular certificates. Arguments: names - The names of certs to include in the bundle bundle_name - The name of the bundle file to output Returns: Path to the bundle fil...
[ "Create", "a", "bundle", "of", "public", "certs", "for", "trust", "distribution" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L545-L569
LLNL/certipy
certipy/certipy.py
Certipy.trust_from_graph
def trust_from_graph(self, graph): """Create a set of trust bundles from a relationship graph. Components in this sense are defined by unique CAs. This method assists in setting up complicated trust between various components that need to do TLS auth. Arguments: graph - dict com...
python
def trust_from_graph(self, graph): """Create a set of trust bundles from a relationship graph. Components in this sense are defined by unique CAs. This method assists in setting up complicated trust between various components that need to do TLS auth. Arguments: graph - dict com...
[ "def", "trust_from_graph", "(", "self", ",", "graph", ")", ":", "# Ensure there are CAs backing all graph components", "def", "distinct_components", "(", "graph", ")", ":", "\"\"\"Return a set of components from the provided graph.\"\"\"", "components", "=", "set", "(", "grap...
Create a set of trust bundles from a relationship graph. Components in this sense are defined by unique CAs. This method assists in setting up complicated trust between various components that need to do TLS auth. Arguments: graph - dict component:list(components) Returns: dic...
[ "Create", "a", "set", "of", "trust", "bundles", "from", "a", "relationship", "graph", "." ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L571-L604
LLNL/certipy
certipy/certipy.py
Certipy.create_ca
def create_ca(self, name, ca_name='', cert_type=crypto.TYPE_RSA, bits=2048, alt_names=None, years=5, serial=0, pathlen=0, overwrite=False): """ Create a certificate authority Arguments: name - The name of the CA cert_type - The type of ...
python
def create_ca(self, name, ca_name='', cert_type=crypto.TYPE_RSA, bits=2048, alt_names=None, years=5, serial=0, pathlen=0, overwrite=False): """ Create a certificate authority Arguments: name - The name of the CA cert_type - The type of ...
[ "def", "create_ca", "(", "self", ",", "name", ",", "ca_name", "=", "''", ",", "cert_type", "=", "crypto", ".", "TYPE_RSA", ",", "bits", "=", "2048", ",", "alt_names", "=", "None", ",", "years", "=", "5", ",", "serial", "=", "0", ",", "pathlen", "="...
Create a certificate authority Arguments: name - The name of the CA cert_type - The type of the cert. TYPE_RSA or TYPE_DSA bits - The number of bits to use alt_names - An array of alternative names in the format: IP...
[ "Create", "a", "certificate", "authority" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L606-L669
LLNL/certipy
certipy/certipy.py
Certipy.create_signed_pair
def create_signed_pair(self, name, ca_name, cert_type=crypto.TYPE_RSA, bits=2048, years=5, alt_names=None, serial=0, overwrite=False): """ Create a key-cert pair Arguments: name - The name of the key-cert pair ca_name ...
python
def create_signed_pair(self, name, ca_name, cert_type=crypto.TYPE_RSA, bits=2048, years=5, alt_names=None, serial=0, overwrite=False): """ Create a key-cert pair Arguments: name - The name of the key-cert pair ca_name ...
[ "def", "create_signed_pair", "(", "self", ",", "name", ",", "ca_name", ",", "cert_type", "=", "crypto", ".", "TYPE_RSA", ",", "bits", "=", "2048", ",", "years", "=", "5", ",", "alt_names", "=", "None", ",", "serial", "=", "0", ",", "overwrite", "=", ...
Create a key-cert pair Arguments: name - The name of the key-cert pair ca_name - The name of the CA to sign this cert cert_type - The type of the cert. TYPE_RSA or TYPE_DSA bits - The number of bits to use alt_names - An arra...
[ "Create", "a", "key", "-", "cert", "pair" ]
train
https://github.com/LLNL/certipy/blob/8705a8ba32655e12021d2893cf1c3c98c697edd7/certipy/certipy.py#L671-L712
marten-de-vries/Flask-WebSub
flask_websub/hub/tasks.py
send_change_notification
def send_change_notification(hub, topic_url, updated_content=None): """7. Content Distribution""" if updated_content: body = base64.b64decode(updated_content['content']) else: body, updated_content = get_new_content(hub.config, topic_url) b64_body = updated_content['content'] heade...
python
def send_change_notification(hub, topic_url, updated_content=None): """7. Content Distribution""" if updated_content: body = base64.b64decode(updated_content['content']) else: body, updated_content = get_new_content(hub.config, topic_url) b64_body = updated_content['content'] heade...
[ "def", "send_change_notification", "(", "hub", ",", "topic_url", ",", "updated_content", "=", "None", ")", ":", "if", "updated_content", ":", "body", "=", "base64", ".", "b64decode", "(", "updated_content", "[", "'content'", "]", ")", "else", ":", "body", ",...
7. Content Distribution
[ "7", ".", "Content", "Distribution" ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/hub/tasks.py#L18-L34
marten-de-vries/Flask-WebSub
flask_websub/hub/tasks.py
subscribe
def subscribe(hub, callback_url, topic_url, lease_seconds, secret, endpoint_hook_data): """5.2 Subscription Validation""" for validate in hub.validators: error = validate(callback_url, topic_url, lease_seconds, secret, endpoint_hook_data) if error: ...
python
def subscribe(hub, callback_url, topic_url, lease_seconds, secret, endpoint_hook_data): """5.2 Subscription Validation""" for validate in hub.validators: error = validate(callback_url, topic_url, lease_seconds, secret, endpoint_hook_data) if error: ...
[ "def", "subscribe", "(", "hub", ",", "callback_url", ",", "topic_url", ",", "lease_seconds", ",", "secret", ",", "endpoint_hook_data", ")", ":", "for", "validate", "in", "hub", ".", "validators", ":", "error", "=", "validate", "(", "callback_url", ",", "topi...
5.2 Subscription Validation
[ "5", ".", "2", "Subscription", "Validation" ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/hub/tasks.py#L87-L103
marten-de-vries/Flask-WebSub
flask_websub/hub/tasks.py
intent_verified
def intent_verified(hub, callback_url, mode, topic_url, lease_seconds): """ 5.3 Hub Verifies Intent of the Subscriber""" challenge = uuid4() params = { 'hub.mode': mode, 'hub.topic': topic_url, 'hub.challenge': challenge, 'hub.lease_seconds': lease_seconds, } try: ...
python
def intent_verified(hub, callback_url, mode, topic_url, lease_seconds): """ 5.3 Hub Verifies Intent of the Subscriber""" challenge = uuid4() params = { 'hub.mode': mode, 'hub.topic': topic_url, 'hub.challenge': challenge, 'hub.lease_seconds': lease_seconds, } try: ...
[ "def", "intent_verified", "(", "hub", ",", "callback_url", ",", "mode", ",", "topic_url", ",", "lease_seconds", ")", ":", "challenge", "=", "uuid4", "(", ")", "params", "=", "{", "'hub.mode'", ":", "mode", ",", "'hub.topic'", ":", "topic_url", ",", "'hub.c...
5.3 Hub Verifies Intent of the Subscriber
[ "5", ".", "3", "Hub", "Verifies", "Intent", "of", "the", "Subscriber" ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/hub/tasks.py#L117-L136
marten-de-vries/Flask-WebSub
flask_websub/hub/__init__.py
Hub.init_celery
def init_celery(self, celery): """Registers the celery tasks on the hub object.""" count = next(self.counter) def task_with_hub(f, **opts): @functools.wraps(f) def wrapper(*args, **kwargs): return f(self, *args, **kwargs) # Make sure newer in...
python
def init_celery(self, celery): """Registers the celery tasks on the hub object.""" count = next(self.counter) def task_with_hub(f, **opts): @functools.wraps(f) def wrapper(*args, **kwargs): return f(self, *args, **kwargs) # Make sure newer in...
[ "def", "init_celery", "(", "self", ",", "celery", ")", ":", "count", "=", "next", "(", "self", ".", "counter", ")", "def", "task_with_hub", "(", "f", ",", "*", "*", "opts", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", ...
Registers the celery tasks on the hub object.
[ "Registers", "the", "celery", "tasks", "on", "the", "hub", "object", "." ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/hub/__init__.py#L66-L103
marten-de-vries/Flask-WebSub
flask_websub/publisher.py
init_publisher
def init_publisher(app): """Calling this with your flask app as argument is required for the publisher decorator to work. """ @app.context_processor def inject_links(): return { 'websub_self_url': stack.top.websub_self_url, 'websub_hub_url': stack.top.websub_hub_url,...
python
def init_publisher(app): """Calling this with your flask app as argument is required for the publisher decorator to work. """ @app.context_processor def inject_links(): return { 'websub_self_url': stack.top.websub_self_url, 'websub_hub_url': stack.top.websub_hub_url,...
[ "def", "init_publisher", "(", "app", ")", ":", "@", "app", ".", "context_processor", "def", "inject_links", "(", ")", ":", "return", "{", "'websub_self_url'", ":", "stack", ".", "top", ".", "websub_self_url", ",", "'websub_hub_url'", ":", "stack", ".", "top"...
Calling this with your flask app as argument is required for the publisher decorator to work.
[ "Calling", "this", "with", "your", "flask", "app", "as", "argument", "is", "required", "for", "the", "publisher", "decorator", "to", "work", "." ]
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/publisher.py#L15-L27
marten-de-vries/Flask-WebSub
flask_websub/publisher.py
publisher
def publisher(self_url=None, hub_url=None): """This decorator makes it easier to implement a websub publisher. You use it on an endpoint, and Link headers will automatically be added. To also include these links in your template html/atom/rss (and you should!) you can use the following to get the raw li...
python
def publisher(self_url=None, hub_url=None): """This decorator makes it easier to implement a websub publisher. You use it on an endpoint, and Link headers will automatically be added. To also include these links in your template html/atom/rss (and you should!) you can use the following to get the raw li...
[ "def", "publisher", "(", "self_url", "=", "None", ",", "hub_url", "=", "None", ")", ":", "def", "decorator", "(", "topic_view", ")", ":", "@", "functools", ".", "wraps", "(", "topic_view", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwar...
This decorator makes it easier to implement a websub publisher. You use it on an endpoint, and Link headers will automatically be added. To also include these links in your template html/atom/rss (and you should!) you can use the following to get the raw links: - {{ websub_self_url }} - {{ websub_h...
[ "This", "decorator", "makes", "it", "easier", "to", "implement", "a", "websub", "publisher", ".", "You", "use", "it", "on", "an", "endpoint", "and", "Link", "headers", "will", "automatically", "be", "added", ".", "To", "also", "include", "these", "links", ...
train
https://github.com/marten-de-vries/Flask-WebSub/blob/422d5b597245554c47e881483f99cae7c57a81ba/flask_websub/publisher.py#L30-L76
openspending/babbage
babbage/query/__init__.py
count_results
def count_results(cube, q): """ Get the count of records matching the query. """ q = select(columns=[func.count(True)], from_obj=q.alias()) return cube.engine.execute(q).scalar()
python
def count_results(cube, q): """ Get the count of records matching the query. """ q = select(columns=[func.count(True)], from_obj=q.alias()) return cube.engine.execute(q).scalar()
[ "def", "count_results", "(", "cube", ",", "q", ")", ":", "q", "=", "select", "(", "columns", "=", "[", "func", ".", "count", "(", "True", ")", "]", ",", "from_obj", "=", "q", ".", "alias", "(", ")", ")", "return", "cube", ".", "engine", ".", "e...
Get the count of records matching the query.
[ "Get", "the", "count", "of", "records", "matching", "the", "query", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/__init__.py#L12-L15
openspending/babbage
babbage/query/__init__.py
generate_results
def generate_results(cube, q): """ Generate the resulting records for this query, applying pagination. Values will be returned by their reference. """ if q._limit is not None and q._limit < 1: return rp = cube.engine.execute(q) while True: row = rp.fetchone() if row is None: ...
python
def generate_results(cube, q): """ Generate the resulting records for this query, applying pagination. Values will be returned by their reference. """ if q._limit is not None and q._limit < 1: return rp = cube.engine.execute(q) while True: row = rp.fetchone() if row is None: ...
[ "def", "generate_results", "(", "cube", ",", "q", ")", ":", "if", "q", ".", "_limit", "is", "not", "None", "and", "q", ".", "_limit", "<", "1", ":", "return", "rp", "=", "cube", ".", "engine", ".", "execute", "(", "q", ")", "while", "True", ":", ...
Generate the resulting records for this query, applying pagination. Values will be returned by their reference.
[ "Generate", "the", "resulting", "records", "for", "this", "query", "applying", "pagination", ".", "Values", "will", "be", "returned", "by", "their", "reference", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/__init__.py#L18-L28
openspending/babbage
babbage/query/ordering.py
Ordering.apply
def apply(self, q, bindings, ordering, distinct=None): """ Sort on a set of field specifications of the type (ref, direction) in order of the submitted list. """ info = [] for (ref, direction) in self.parse(ordering): info.append((ref, direction)) table, column = ...
python
def apply(self, q, bindings, ordering, distinct=None): """ Sort on a set of field specifications of the type (ref, direction) in order of the submitted list. """ info = [] for (ref, direction) in self.parse(ordering): info.append((ref, direction)) table, column = ...
[ "def", "apply", "(", "self", ",", "q", ",", "bindings", ",", "ordering", ",", "distinct", "=", "None", ")", ":", "info", "=", "[", "]", "for", "(", "ref", ",", "direction", ")", "in", "self", ".", "parse", "(", "ordering", ")", ":", "info", ".", ...
Sort on a set of field specifications of the type (ref, direction) in order of the submitted list.
[ "Sort", "on", "a", "set", "of", "field", "specifications", "of", "the", "type", "(", "ref", "direction", ")", "in", "order", "of", "the", "submitted", "list", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/ordering.py#L24-L47
bodylabs/lace
lace/mesh.py
Mesh.copy
def copy(self, only=None): ''' Returns a deep copy with all of the numpy arrays copied If only is a list of strings, i.e. ['f', 'v'], then only those properties will be copied ''' if only is None: return Mesh(self) else: import copy m =...
python
def copy(self, only=None): ''' Returns a deep copy with all of the numpy arrays copied If only is a list of strings, i.e. ['f', 'v'], then only those properties will be copied ''' if only is None: return Mesh(self) else: import copy m =...
[ "def", "copy", "(", "self", ",", "only", "=", "None", ")", ":", "if", "only", "is", "None", ":", "return", "Mesh", "(", "self", ")", "else", ":", "import", "copy", "m", "=", "Mesh", "(", ")", "for", "a", "in", "only", ":", "setattr", "(", "m", ...
Returns a deep copy with all of the numpy arrays copied If only is a list of strings, i.e. ['f', 'v'], then only those properties will be copied
[ "Returns", "a", "deep", "copy", "with", "all", "of", "the", "numpy", "arrays", "copied", "If", "only", "is", "a", "list", "of", "strings", "i", ".", "e", ".", "[", "f", "v", "]", "then", "only", "those", "properties", "will", "be", "copied" ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/mesh.py#L128-L140
bodylabs/lace
lace/mesh.py
Mesh.concatenate
def concatenate(cls, *args): """Concatenates an arbitrary number of meshes. Currently supports vertices, vertex colors, and faces. """ nargs = len(args) if nargs == 1: return args[0] vs = [a.v for a in args if a.v is not None] vcs = [a.vc for a in ar...
python
def concatenate(cls, *args): """Concatenates an arbitrary number of meshes. Currently supports vertices, vertex colors, and faces. """ nargs = len(args) if nargs == 1: return args[0] vs = [a.v for a in args if a.v is not None] vcs = [a.vc for a in ar...
[ "def", "concatenate", "(", "cls", ",", "*", "args", ")", ":", "nargs", "=", "len", "(", "args", ")", "if", "nargs", "==", "1", ":", "return", "args", "[", "0", "]", "vs", "=", "[", "a", ".", "v", "for", "a", "in", "args", "if", "a", ".", "v...
Concatenates an arbitrary number of meshes. Currently supports vertices, vertex colors, and faces.
[ "Concatenates", "an", "arbitrary", "number", "of", "meshes", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/mesh.py#L215-L244
nerdynick/PySQLPool
src/PySQLPool/__init__.py
getNewConnection
def getNewConnection(*args, **kargs): """ Quickly Create a new PySQLConnection class @param host: Hostname for your database @param username: Username to use to connect to database @param password: Password to use to connect to database @param schema: Schema to use @param port: Port to connect on @param comm...
python
def getNewConnection(*args, **kargs): """ Quickly Create a new PySQLConnection class @param host: Hostname for your database @param username: Username to use to connect to database @param password: Password to use to connect to database @param schema: Schema to use @param port: Port to connect on @param comm...
[ "def", "getNewConnection", "(", "*", "args", ",", "*", "*", "kargs", ")", ":", "kargs", "=", "dict", "(", "kargs", ")", "if", "len", "(", "args", ")", ">", "0", ":", "if", "len", "(", "args", ")", ">=", "1", ":", "kargs", "[", "'host'", "]", ...
Quickly Create a new PySQLConnection class @param host: Hostname for your database @param username: Username to use to connect to database @param password: Password to use to connect to database @param schema: Schema to use @param port: Port to connect on @param commitOnEnd: Default False, When query is comple...
[ "Quickly", "Create", "a", "new", "PySQLConnection", "class" ]
train
https://github.com/nerdynick/PySQLPool/blob/a561275fea091e2667b69ce376c507f541b56e7d/src/PySQLPool/__init__.py#L15-L43
nerdynick/PySQLPool
src/PySQLPool/__init__.py
getNewQuery
def getNewQuery(connection = None, commitOnEnd=False, *args, **kargs): """ Create a new PySQLQuery Class @param PySQLConnectionObj: Connection Object representing your connection string @param commitOnEnd: Default False, When query is complete do you wish to auto commit. This is a one time auto commit @author: N...
python
def getNewQuery(connection = None, commitOnEnd=False, *args, **kargs): """ Create a new PySQLQuery Class @param PySQLConnectionObj: Connection Object representing your connection string @param commitOnEnd: Default False, When query is complete do you wish to auto commit. This is a one time auto commit @author: N...
[ "def", "getNewQuery", "(", "connection", "=", "None", ",", "commitOnEnd", "=", "False", ",", "*", "args", ",", "*", "*", "kargs", ")", ":", "if", "connection", "is", "None", ":", "return", "query", ".", "PySQLQuery", "(", "getNewConnection", "(", "*", ...
Create a new PySQLQuery Class @param PySQLConnectionObj: Connection Object representing your connection string @param commitOnEnd: Default False, When query is complete do you wish to auto commit. This is a one time auto commit @author: Nick Verbeck @since: 5/12/2008 @updated: 7/19/2008 - Added commitOnEnd suppo...
[ "Create", "a", "new", "PySQLQuery", "Class" ]
train
https://github.com/nerdynick/PySQLPool/blob/a561275fea091e2667b69ce376c507f541b56e7d/src/PySQLPool/__init__.py#L46-L61
mandeep/Travis-Encrypt
travis/cli.py
cli
def cli(username, repository, path, password, deploy, env, clipboard, env_file): """Encrypt passwords and environment variables for use with Travis CI. Travis Encrypt requires as arguments the user's GitHub username and repository name. Once the arguments are passed, a password prompt will ask for the pass...
python
def cli(username, repository, path, password, deploy, env, clipboard, env_file): """Encrypt passwords and environment variables for use with Travis CI. Travis Encrypt requires as arguments the user's GitHub username and repository name. Once the arguments are passed, a password prompt will ask for the pass...
[ "def", "cli", "(", "username", ",", "repository", ",", "path", ",", "password", ",", "deploy", ",", "env", ",", "clipboard", ",", "env_file", ")", ":", "key", "=", "retrieve_public_key", "(", "'{}/{}'", ".", "format", "(", "username", ",", "repository", ...
Encrypt passwords and environment variables for use with Travis CI. Travis Encrypt requires as arguments the user's GitHub username and repository name. Once the arguments are passed, a password prompt will ask for the password that needs to be encrypted. The given password will then be encrypted via the P...
[ "Encrypt", "passwords", "and", "environment", "variables", "for", "use", "with", "Travis", "CI", "." ]
train
https://github.com/mandeep/Travis-Encrypt/blob/0dd2da1c71feaadcb84bdeb26827e6dfe1bd3b41/travis/cli.py#L53-L107
openspending/babbage
babbage/query/fields.py
Fields.apply
def apply(self, q, bindings, fields, distinct=False): """ Define a set of fields to return for a non-aggregated query. """ info = [] group_by = None for field in self.parse(fields): for concept in self.cube.model.match(field): info.append(concept.ref) ...
python
def apply(self, q, bindings, fields, distinct=False): """ Define a set of fields to return for a non-aggregated query. """ info = [] group_by = None for field in self.parse(fields): for concept in self.cube.model.match(field): info.append(concept.ref) ...
[ "def", "apply", "(", "self", ",", "q", ",", "bindings", ",", "fields", ",", "distinct", "=", "False", ")", ":", "info", "=", "[", "]", "group_by", "=", "None", "for", "field", "in", "self", ".", "parse", "(", "fields", ")", ":", "for", "concept", ...
Define a set of fields to return for a non-aggregated query.
[ "Define", "a", "set", "of", "fields", "to", "return", "for", "a", "non", "-", "aggregated", "query", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/fields.py#L21-L51
bodylabs/lace
lace/arcball.py
ArcBallT.drag
def drag(self, NewPt): # //Mouse drag, calculate rotation (Point2fT Quat4fT) """ drag (Point2fT mouse_coord) -> new_quaternion_rotation_vec """ X = 0 Y = 1 Z = 2 W = 3 self.m_EnVec = self._mapToSphere(NewPt) # //Compute the vector perpendicular t...
python
def drag(self, NewPt): # //Mouse drag, calculate rotation (Point2fT Quat4fT) """ drag (Point2fT mouse_coord) -> new_quaternion_rotation_vec """ X = 0 Y = 1 Z = 2 W = 3 self.m_EnVec = self._mapToSphere(NewPt) # //Compute the vector perpendicular t...
[ "def", "drag", "(", "self", ",", "NewPt", ")", ":", "# //Mouse drag, calculate rotation (Point2fT Quat4fT)", "X", "=", "0", "Y", "=", "1", "Z", "=", "2", "W", "=", "3", "self", ".", "m_EnVec", "=", "self", ".", "_mapToSphere", "(", "NewPt", ")", "# //Com...
drag (Point2fT mouse_coord) -> new_quaternion_rotation_vec
[ "drag", "(", "Point2fT", "mouse_coord", ")", "-", ">", "new_quaternion_rotation_vec" ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/arcball.py#L70-L98
nschloe/meshplex
meshplex/mesh_line.py
MeshLine.create_cell_volumes
def create_cell_volumes(self): """Computes the volumes of the "cells" in the mesh. """ self.cell_volumes = numpy.array( [ abs( self.node_coords[cell["nodes"]][1] - self.node_coords[cell["nodes"]][0] ) ...
python
def create_cell_volumes(self): """Computes the volumes of the "cells" in the mesh. """ self.cell_volumes = numpy.array( [ abs( self.node_coords[cell["nodes"]][1] - self.node_coords[cell["nodes"]][0] ) ...
[ "def", "create_cell_volumes", "(", "self", ")", ":", "self", ".", "cell_volumes", "=", "numpy", ".", "array", "(", "[", "abs", "(", "self", ".", "node_coords", "[", "cell", "[", "\"nodes\"", "]", "]", "[", "1", "]", "-", "self", ".", "node_coords", "...
Computes the volumes of the "cells" in the mesh.
[ "Computes", "the", "volumes", "of", "the", "cells", "in", "the", "mesh", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/mesh_line.py#L21-L33
nschloe/meshplex
meshplex/mesh_line.py
MeshLine.create_control_volumes
def create_control_volumes(self): """Compute the control volumes of all nodes in the mesh. """ self.control_volumes = numpy.zeros(len(self.node_coords), dtype=float) for k, cell in enumerate(self.cells): node_ids = cell["nodes"] self.control_volumes[node_ids] += 0...
python
def create_control_volumes(self): """Compute the control volumes of all nodes in the mesh. """ self.control_volumes = numpy.zeros(len(self.node_coords), dtype=float) for k, cell in enumerate(self.cells): node_ids = cell["nodes"] self.control_volumes[node_ids] += 0...
[ "def", "create_control_volumes", "(", "self", ")", ":", "self", ".", "control_volumes", "=", "numpy", ".", "zeros", "(", "len", "(", "self", ".", "node_coords", ")", ",", "dtype", "=", "float", ")", "for", "k", ",", "cell", "in", "enumerate", "(", "sel...
Compute the control volumes of all nodes in the mesh.
[ "Compute", "the", "control", "volumes", "of", "all", "nodes", "in", "the", "mesh", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/mesh_line.py#L35-L48
bodylabs/lace
lace/shapes.py
create_rectangular_prism
def create_rectangular_prism(origin, size): ''' Return a Mesh which is an axis-aligned rectangular prism. One vertex is `origin`; the diametrically opposite vertex is `origin + size`. size: 3x1 array. ''' from lace.topology import quads_to_tris lower_base_plane = np.array([ # Lowe...
python
def create_rectangular_prism(origin, size): ''' Return a Mesh which is an axis-aligned rectangular prism. One vertex is `origin`; the diametrically opposite vertex is `origin + size`. size: 3x1 array. ''' from lace.topology import quads_to_tris lower_base_plane = np.array([ # Lowe...
[ "def", "create_rectangular_prism", "(", "origin", ",", "size", ")", ":", "from", "lace", ".", "topology", "import", "quads_to_tris", "lower_base_plane", "=", "np", ".", "array", "(", "[", "# Lower base plane", "origin", ",", "origin", "+", "np", ".", "array", ...
Return a Mesh which is an axis-aligned rectangular prism. One vertex is `origin`; the diametrically opposite vertex is `origin + size`. size: 3x1 array.
[ "Return", "a", "Mesh", "which", "is", "an", "axis", "-", "aligned", "rectangular", "prism", ".", "One", "vertex", "is", "origin", ";", "the", "diametrically", "opposite", "vertex", "is", "origin", "+", "size", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/shapes.py#L6-L36
bodylabs/lace
lace/shapes.py
create_triangular_prism
def create_triangular_prism(p1, p2, p3, height): ''' Return a Mesh which is a triangular prism whose base is the triangle p1, p2, p3. If the vertices are oriented in a counterclockwise direction, the prism extends from behind them. ''' from blmath.geometry import Plane base_plane = Plane.f...
python
def create_triangular_prism(p1, p2, p3, height): ''' Return a Mesh which is a triangular prism whose base is the triangle p1, p2, p3. If the vertices are oriented in a counterclockwise direction, the prism extends from behind them. ''' from blmath.geometry import Plane base_plane = Plane.f...
[ "def", "create_triangular_prism", "(", "p1", ",", "p2", ",", "p3", ",", "height", ")", ":", "from", "blmath", ".", "geometry", "import", "Plane", "base_plane", "=", "Plane", ".", "from_points", "(", "p1", ",", "p2", ",", "p3", ")", "lower_base_to_upper_bas...
Return a Mesh which is a triangular prism whose base is the triangle p1, p2, p3. If the vertices are oriented in a counterclockwise direction, the prism extends from behind them.
[ "Return", "a", "Mesh", "which", "is", "a", "triangular", "prism", "whose", "base", "is", "the", "triangle", "p1", "p2", "p3", ".", "If", "the", "vertices", "are", "oriented", "in", "a", "counterclockwise", "direction", "the", "prism", "extends", "from", "b...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/shapes.py#L50-L71
bodylabs/lace
lace/shapes.py
create_horizontal_plane
def create_horizontal_plane(): ''' Creates a horizontal plane. ''' v = np.array([ [1., 0., 0.], [-1., 0., 0.], [0., 0., 1.], [0., 0., -1.] ]) f = [[0, 1, 2], [3, 1, 0]] return Mesh(v=v, f=f)
python
def create_horizontal_plane(): ''' Creates a horizontal plane. ''' v = np.array([ [1., 0., 0.], [-1., 0., 0.], [0., 0., 1.], [0., 0., -1.] ]) f = [[0, 1, 2], [3, 1, 0]] return Mesh(v=v, f=f)
[ "def", "create_horizontal_plane", "(", ")", ":", "v", "=", "np", ".", "array", "(", "[", "[", "1.", ",", "0.", ",", "0.", "]", ",", "[", "-", "1.", ",", "0.", ",", "0.", "]", ",", "[", "0.", ",", "0.", ",", "1.", "]", ",", "[", "0.", ",",...
Creates a horizontal plane.
[ "Creates", "a", "horizontal", "plane", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/shapes.py#L74-L85
openspending/babbage
babbage/model/concept.py
Concept.match_ref
def match_ref(self, ref): """ Check if the ref matches one the concept's aliases. If so, mark the matched ref so that we use it as the column label. """ if ref in self.refs: self._matched_ref = ref return True return False
python
def match_ref(self, ref): """ Check if the ref matches one the concept's aliases. If so, mark the matched ref so that we use it as the column label. """ if ref in self.refs: self._matched_ref = ref return True return False
[ "def", "match_ref", "(", "self", ",", "ref", ")", ":", "if", "ref", "in", "self", ".", "refs", ":", "self", ".", "_matched_ref", "=", "ref", "return", "True", "return", "False" ]
Check if the ref matches one the concept's aliases. If so, mark the matched ref so that we use it as the column label.
[ "Check", "if", "the", "ref", "matches", "one", "the", "concept", "s", "aliases", ".", "If", "so", "mark", "the", "matched", "ref", "so", "that", "we", "use", "it", "as", "the", "column", "label", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/model/concept.py#L40-L47
openspending/babbage
babbage/model/concept.py
Concept._physical_column
def _physical_column(self, cube, column_name): """ Return the SQLAlchemy Column object matching a given, possibly qualified, column name (i.e.: 'table.column'). If no table is named, the fact table is assumed. """ table_name = self.model.fact_table_name if '.' in column_name: ...
python
def _physical_column(self, cube, column_name): """ Return the SQLAlchemy Column object matching a given, possibly qualified, column name (i.e.: 'table.column'). If no table is named, the fact table is assumed. """ table_name = self.model.fact_table_name if '.' in column_name: ...
[ "def", "_physical_column", "(", "self", ",", "cube", ",", "column_name", ")", ":", "table_name", "=", "self", ".", "model", ".", "fact_table_name", "if", "'.'", "in", "column_name", ":", "table_name", ",", "column_name", "=", "column_name", ".", "split", "("...
Return the SQLAlchemy Column object matching a given, possibly qualified, column name (i.e.: 'table.column'). If no table is named, the fact table is assumed.
[ "Return", "the", "SQLAlchemy", "Column", "object", "matching", "a", "given", "possibly", "qualified", "column", "name", "(", "i", ".", "e", ".", ":", "table", ".", "column", ")", ".", "If", "no", "table", "is", "named", "the", "fact", "table", "is", "a...
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/model/concept.py#L49-L61
openspending/babbage
babbage/model/concept.py
Concept.bind
def bind(self, cube): """ Map a model reference to an physical column in the database. """ table, column = self._physical_column(cube, self.column_name) column = column.label(self.matched_ref) column.quote = True return table, column
python
def bind(self, cube): """ Map a model reference to an physical column in the database. """ table, column = self._physical_column(cube, self.column_name) column = column.label(self.matched_ref) column.quote = True return table, column
[ "def", "bind", "(", "self", ",", "cube", ")", ":", "table", ",", "column", "=", "self", ".", "_physical_column", "(", "cube", ",", "self", ".", "column_name", ")", "column", "=", "column", ".", "label", "(", "self", ".", "matched_ref", ")", "column", ...
Map a model reference to an physical column in the database.
[ "Map", "a", "model", "reference", "to", "an", "physical", "column", "in", "the", "database", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/model/concept.py#L63-L68
ArabellaTech/aa-stripe
aa_stripe/models.py
StripeCustomer.add_new_source
def add_new_source(self, source_token, stripe_js_response=None): """Add new source (for example: a new card) to the customer The new source will be automatically set as customer's default payment source. Passing stripe_js_response is optional. If set, StripeCustomer.stripe_js_response will be u...
python
def add_new_source(self, source_token, stripe_js_response=None): """Add new source (for example: a new card) to the customer The new source will be automatically set as customer's default payment source. Passing stripe_js_response is optional. If set, StripeCustomer.stripe_js_response will be u...
[ "def", "add_new_source", "(", "self", ",", "source_token", ",", "stripe_js_response", "=", "None", ")", ":", "customer", "=", "self", ".", "retrieve_from_stripe", "(", ")", "customer", ".", "source", "=", "source_token", "customer", ".", "save", "(", ")", "i...
Add new source (for example: a new card) to the customer The new source will be automatically set as customer's default payment source. Passing stripe_js_response is optional. If set, StripeCustomer.stripe_js_response will be updated.
[ "Add", "new", "source", "(", "for", "example", ":", "a", "new", "card", ")", "to", "the", "customer" ]
train
https://github.com/ArabellaTech/aa-stripe/blob/bda97c233a7513a69947c30f524a6050f984088b/aa_stripe/models.py#L104-L115
ArabellaTech/aa-stripe
aa_stripe/models.py
StripeCoupon.update_from_stripe_data
def update_from_stripe_data(self, stripe_coupon, exclude_fields=None, commit=True): """ Update StripeCoupon object with data from stripe.Coupon without calling stripe.Coupon.retrieve. To only update the object, set the commit param to False. Returns the number of rows altered or None if...
python
def update_from_stripe_data(self, stripe_coupon, exclude_fields=None, commit=True): """ Update StripeCoupon object with data from stripe.Coupon without calling stripe.Coupon.retrieve. To only update the object, set the commit param to False. Returns the number of rows altered or None if...
[ "def", "update_from_stripe_data", "(", "self", ",", "stripe_coupon", ",", "exclude_fields", "=", "None", ",", "commit", "=", "True", ")", ":", "fields_to_update", "=", "self", ".", "STRIPE_FIELDS", "-", "set", "(", "exclude_fields", "or", "[", "]", ")", "upd...
Update StripeCoupon object with data from stripe.Coupon without calling stripe.Coupon.retrieve. To only update the object, set the commit param to False. Returns the number of rows altered or None if commit is False.
[ "Update", "StripeCoupon", "object", "with", "data", "from", "stripe", ".", "Coupon", "without", "calling", "stripe", ".", "Coupon", ".", "retrieve", "." ]
train
https://github.com/ArabellaTech/aa-stripe/blob/bda97c233a7513a69947c30f524a6050f984088b/aa_stripe/models.py#L239-L260
ArabellaTech/aa-stripe
aa_stripe/models.py
StripeCoupon.save
def save(self, force_retrieve=False, *args, **kwargs): """ Use the force_retrieve parameter to create a new StripeCoupon object from an existing coupon created at Stripe API or update the local object with data fetched from Stripe. """ stripe.api_key = stripe_settings.API_KEY ...
python
def save(self, force_retrieve=False, *args, **kwargs): """ Use the force_retrieve parameter to create a new StripeCoupon object from an existing coupon created at Stripe API or update the local object with data fetched from Stripe. """ stripe.api_key = stripe_settings.API_KEY ...
[ "def", "save", "(", "self", ",", "force_retrieve", "=", "False", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "stripe", ".", "api_key", "=", "stripe_settings", ".", "API_KEY", "if", "self", ".", "_previous_is_deleted", "!=", "self", ".", "is_dele...
Use the force_retrieve parameter to create a new StripeCoupon object from an existing coupon created at Stripe API or update the local object with data fetched from Stripe.
[ "Use", "the", "force_retrieve", "parameter", "to", "create", "a", "new", "StripeCoupon", "object", "from", "an", "existing", "coupon", "created", "at", "Stripe" ]
train
https://github.com/ArabellaTech/aa-stripe/blob/bda97c233a7513a69947c30f524a6050f984088b/aa_stripe/models.py#L262-L325
nschloe/meshplex
meshplex/helpers.py
get_signed_simplex_volumes
def get_signed_simplex_volumes(cells, pts): """Signed volume of a simplex in nD. Note that signing only makes sense for n-simplices in R^n. """ n = pts.shape[1] assert cells.shape[1] == n + 1 p = pts[cells] p = numpy.concatenate([p, numpy.ones(list(p.shape[:2]) + [1])], axis=-1) return ...
python
def get_signed_simplex_volumes(cells, pts): """Signed volume of a simplex in nD. Note that signing only makes sense for n-simplices in R^n. """ n = pts.shape[1] assert cells.shape[1] == n + 1 p = pts[cells] p = numpy.concatenate([p, numpy.ones(list(p.shape[:2]) + [1])], axis=-1) return ...
[ "def", "get_signed_simplex_volumes", "(", "cells", ",", "pts", ")", ":", "n", "=", "pts", ".", "shape", "[", "1", "]", "assert", "cells", ".", "shape", "[", "1", "]", "==", "n", "+", "1", "p", "=", "pts", "[", "cells", "]", "p", "=", "numpy", "...
Signed volume of a simplex in nD. Note that signing only makes sense for n-simplices in R^n.
[ "Signed", "volume", "of", "a", "simplex", "in", "nD", ".", "Note", "that", "signing", "only", "makes", "sense", "for", "n", "-", "simplices", "in", "R^n", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/helpers.py#L8-L17
nschloe/meshplex
meshplex/helpers.py
grp_start_len
def grp_start_len(a): """Given a sorted 1D input array `a`, e.g., [0 0, 1, 2, 3, 4, 4, 4], this routine returns the indices where the blocks of equal integers start and how long the blocks are. """ # https://stackoverflow.com/a/50394587/353337 m = numpy.concatenate([[True], a[:-1] != a[1:], [Tru...
python
def grp_start_len(a): """Given a sorted 1D input array `a`, e.g., [0 0, 1, 2, 3, 4, 4, 4], this routine returns the indices where the blocks of equal integers start and how long the blocks are. """ # https://stackoverflow.com/a/50394587/353337 m = numpy.concatenate([[True], a[:-1] != a[1:], [Tru...
[ "def", "grp_start_len", "(", "a", ")", ":", "# https://stackoverflow.com/a/50394587/353337", "m", "=", "numpy", ".", "concatenate", "(", "[", "[", "True", "]", ",", "a", "[", ":", "-", "1", "]", "!=", "a", "[", "1", ":", "]", ",", "[", "True", "]", ...
Given a sorted 1D input array `a`, e.g., [0 0, 1, 2, 3, 4, 4, 4], this routine returns the indices where the blocks of equal integers start and how long the blocks are.
[ "Given", "a", "sorted", "1D", "input", "array", "a", "e", ".", "g", ".", "[", "0", "0", "1", "2", "3", "4", "4", "4", "]", "this", "routine", "returns", "the", "indices", "where", "the", "blocks", "of", "equal", "integers", "start", "and", "how", ...
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/helpers.py#L20-L28
nschloe/meshplex
meshplex/base.py
compute_triangle_circumcenters
def compute_triangle_circumcenters(X, ei_dot_ei, ei_dot_ej): """Computes the circumcenters of all given triangles. """ # The input argument are the dot products # # <e1, e2> # <e2, e0> # <e0, e1> # # of the edges # # e0: x1->x2, # e1: x2->x0, # e2: x0->x1....
python
def compute_triangle_circumcenters(X, ei_dot_ei, ei_dot_ej): """Computes the circumcenters of all given triangles. """ # The input argument are the dot products # # <e1, e2> # <e2, e0> # <e0, e1> # # of the edges # # e0: x1->x2, # e1: x2->x0, # e2: x0->x1....
[ "def", "compute_triangle_circumcenters", "(", "X", ",", "ei_dot_ei", ",", "ei_dot_ej", ")", ":", "# The input argument are the dot products", "#", "# <e1, e2>", "# <e2, e0>", "# <e0, e1>", "#", "# of the edges", "#", "# e0: x1->x2,", "# e1: x2->x0,", "# e2: x0->x1...
Computes the circumcenters of all given triangles.
[ "Computes", "the", "circumcenters", "of", "all", "given", "triangles", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/base.py#L86-L148
nschloe/meshplex
meshplex/base.py
_base_mesh.get_edge_mask
def get_edge_mask(self, subdomain=None): """Get faces which are fully in subdomain. """ if subdomain is None: # https://stackoverflow.com/a/42392791/353337 return numpy.s_[:] if subdomain not in self.subdomains: self._mark_vertices(subdomain) ...
python
def get_edge_mask(self, subdomain=None): """Get faces which are fully in subdomain. """ if subdomain is None: # https://stackoverflow.com/a/42392791/353337 return numpy.s_[:] if subdomain not in self.subdomains: self._mark_vertices(subdomain) ...
[ "def", "get_edge_mask", "(", "self", ",", "subdomain", "=", "None", ")", ":", "if", "subdomain", "is", "None", ":", "# https://stackoverflow.com/a/42392791/353337", "return", "numpy", ".", "s_", "[", ":", "]", "if", "subdomain", "not", "in", "self", ".", "su...
Get faces which are fully in subdomain.
[ "Get", "faces", "which", "are", "fully", "in", "subdomain", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/base.py#L197-L217
nschloe/meshplex
meshplex/base.py
_base_mesh.get_face_mask
def get_face_mask(self, subdomain): """Get faces which are fully in subdomain. """ if subdomain is None: # https://stackoverflow.com/a/42392791/353337 return numpy.s_[:] if subdomain not in self.subdomains: self._mark_vertices(subdomain) # A ...
python
def get_face_mask(self, subdomain): """Get faces which are fully in subdomain. """ if subdomain is None: # https://stackoverflow.com/a/42392791/353337 return numpy.s_[:] if subdomain not in self.subdomains: self._mark_vertices(subdomain) # A ...
[ "def", "get_face_mask", "(", "self", ",", "subdomain", ")", ":", "if", "subdomain", "is", "None", ":", "# https://stackoverflow.com/a/42392791/353337", "return", "numpy", ".", "s_", "[", ":", "]", "if", "subdomain", "not", "in", "self", ".", "subdomains", ":",...
Get faces which are fully in subdomain.
[ "Get", "faces", "which", "are", "fully", "in", "subdomain", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/base.py#L219-L240
nschloe/meshplex
meshplex/base.py
_base_mesh._mark_vertices
def _mark_vertices(self, subdomain): """Mark faces/edges which are fully in subdomain. """ if subdomain is None: is_inside = numpy.ones(len(self.node_coords), dtype=bool) else: is_inside = subdomain.is_inside(self.node_coords.T).T if subdomain.is_boun...
python
def _mark_vertices(self, subdomain): """Mark faces/edges which are fully in subdomain. """ if subdomain is None: is_inside = numpy.ones(len(self.node_coords), dtype=bool) else: is_inside = subdomain.is_inside(self.node_coords.T).T if subdomain.is_boun...
[ "def", "_mark_vertices", "(", "self", ",", "subdomain", ")", ":", "if", "subdomain", "is", "None", ":", "is_inside", "=", "numpy", ".", "ones", "(", "len", "(", "self", ".", "node_coords", ")", ",", "dtype", "=", "bool", ")", "else", ":", "is_inside", ...
Mark faces/edges which are fully in subdomain.
[ "Mark", "faces", "/", "edges", "which", "are", "fully", "in", "subdomain", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/base.py#L259-L273
mandeep/Travis-Encrypt
travis/orderer.py
ordered_dump
def ordered_dump(data, stream=None, Dumper=yaml.SafeDumper, **kwds): """Dump a yaml configuration as an OrderedDict.""" class OrderedDumper(Dumper): pass def dict_representer(dumper, data): return dumper.represent_mapping(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, data.items()) Or...
python
def ordered_dump(data, stream=None, Dumper=yaml.SafeDumper, **kwds): """Dump a yaml configuration as an OrderedDict.""" class OrderedDumper(Dumper): pass def dict_representer(dumper, data): return dumper.represent_mapping(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, data.items()) Or...
[ "def", "ordered_dump", "(", "data", ",", "stream", "=", "None", ",", "Dumper", "=", "yaml", ".", "SafeDumper", ",", "*", "*", "kwds", ")", ":", "class", "OrderedDumper", "(", "Dumper", ")", ":", "pass", "def", "dict_representer", "(", "dumper", ",", "d...
Dump a yaml configuration as an OrderedDict.
[ "Dump", "a", "yaml", "configuration", "as", "an", "OrderedDict", "." ]
train
https://github.com/mandeep/Travis-Encrypt/blob/0dd2da1c71feaadcb84bdeb26827e6dfe1bd3b41/travis/orderer.py#L27-L37
openspending/babbage
babbage/query/cuts.py
Cuts._check_type
def _check_type(self, ref, value): """ Checks whether the type of the cut value matches the type of the concept being cut, and raises a QueryException if it doesn't match """ if isinstance(value, list): return [self._check_type(ref, val) for val in value] mod...
python
def _check_type(self, ref, value): """ Checks whether the type of the cut value matches the type of the concept being cut, and raises a QueryException if it doesn't match """ if isinstance(value, list): return [self._check_type(ref, val) for val in value] mod...
[ "def", "_check_type", "(", "self", ",", "ref", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "return", "[", "self", ".", "_check_type", "(", "ref", ",", "val", ")", "for", "val", "in", "value", "]", "model_type", ...
Checks whether the type of the cut value matches the type of the concept being cut, and raises a QueryException if it doesn't match
[ "Checks", "whether", "the", "type", "of", "the", "cut", "value", "matches", "the", "type", "of", "the", "concept", "being", "cut", "and", "raises", "a", "QueryException", "if", "it", "doesn", "t", "match" ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/cuts.py#L24-L41
openspending/babbage
babbage/query/cuts.py
Cuts._api_type
def _api_type(self, value): """ Returns the API type of the given value based on its python type. """ if isinstance(value, six.string_types): return 'string' elif isinstance(value, six.integer_types): return 'integer' elif type(value) is datetime....
python
def _api_type(self, value): """ Returns the API type of the given value based on its python type. """ if isinstance(value, six.string_types): return 'string' elif isinstance(value, six.integer_types): return 'integer' elif type(value) is datetime....
[ "def", "_api_type", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "return", "'string'", "elif", "isinstance", "(", "value", ",", "six", ".", "integer_types", ")", ":", "return", "'intege...
Returns the API type of the given value based on its python type.
[ "Returns", "the", "API", "type", "of", "the", "given", "value", "based", "on", "its", "python", "type", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/cuts.py#L43-L53
openspending/babbage
babbage/query/cuts.py
Cuts.apply
def apply(self, q, bindings, cuts): """ Apply a set of filters, which can be given as a set of tuples in the form (ref, operator, value), or as a string in query form. If it is ``None``, no filter will be applied. """ info = [] for (ref, operator, value) in self.parse(cuts): ...
python
def apply(self, q, bindings, cuts): """ Apply a set of filters, which can be given as a set of tuples in the form (ref, operator, value), or as a string in query form. If it is ``None``, no filter will be applied. """ info = [] for (ref, operator, value) in self.parse(cuts): ...
[ "def", "apply", "(", "self", ",", "q", ",", "bindings", ",", "cuts", ")", ":", "info", "=", "[", "]", "for", "(", "ref", ",", "operator", ",", "value", ")", "in", "self", ".", "parse", "(", "cuts", ")", ":", "if", "map_is_class", "and", "isinstan...
Apply a set of filters, which can be given as a set of tuples in the form (ref, operator, value), or as a string in query form. If it is ``None``, no filter will be applied.
[ "Apply", "a", "set", "of", "filters", "which", "can", "be", "given", "as", "a", "set", "of", "tuples", "in", "the", "form", "(", "ref", "operator", "value", ")", "or", "as", "a", "string", "in", "query", "form", ".", "If", "it", "is", "None", "no",...
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/query/cuts.py#L55-L68
bodylabs/lace
lace/color.py
colors_like
def colors_like(color, arr, colormap=DEFAULT_COLORMAP): ''' Given an array of size NxM (usually Nx3), we accept color in the following ways: - A string color name. The accepted names are roughly what's in X11's rgb.txt - An explicit rgb triple, in (3, ), (3, 1), or (1, 3) shape - A list of values (N...
python
def colors_like(color, arr, colormap=DEFAULT_COLORMAP): ''' Given an array of size NxM (usually Nx3), we accept color in the following ways: - A string color name. The accepted names are roughly what's in X11's rgb.txt - An explicit rgb triple, in (3, ), (3, 1), or (1, 3) shape - A list of values (N...
[ "def", "colors_like", "(", "color", ",", "arr", ",", "colormap", "=", "DEFAULT_COLORMAP", ")", ":", "import", "numpy", "as", "np", "from", "blmath", ".", "numerics", "import", "is_empty_arraylike", "if", "is_empty_arraylike", "(", "color", ")", ":", "return", ...
Given an array of size NxM (usually Nx3), we accept color in the following ways: - A string color name. The accepted names are roughly what's in X11's rgb.txt - An explicit rgb triple, in (3, ), (3, 1), or (1, 3) shape - A list of values (N, ), (N, 1), or (1, N) that are put through a colormap to get per ve...
[ "Given", "an", "array", "of", "size", "NxM", "(", "usually", "Nx3", ")", "we", "accept", "color", "in", "the", "following", "ways", ":", "-", "A", "string", "color", "name", ".", "The", "accepted", "names", "are", "roughly", "what", "s", "in", "X11", ...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/color.py#L5-L39
bodylabs/lace
lace/color.py
MeshMixin.color_by_height
def color_by_height(self, axis=1, threshold=None, color=DEFAULT_COLORMAP): # pylint: disable=unused-argument ''' Color each vertex by its height above the floor point. axis: The axis to use. 0 means x, 1 means y, 2 means z. threshold: The top of the range. Points at and above this heigh...
python
def color_by_height(self, axis=1, threshold=None, color=DEFAULT_COLORMAP): # pylint: disable=unused-argument ''' Color each vertex by its height above the floor point. axis: The axis to use. 0 means x, 1 means y, 2 means z. threshold: The top of the range. Points at and above this heigh...
[ "def", "color_by_height", "(", "self", ",", "axis", "=", "1", ",", "threshold", "=", "None", ",", "color", "=", "DEFAULT_COLORMAP", ")", ":", "# pylint: disable=unused-argument", "import", "numpy", "as", "np", "heights", "=", "self", ".", "v", "[", ":", ",...
Color each vertex by its height above the floor point. axis: The axis to use. 0 means x, 1 means y, 2 means z. threshold: The top of the range. Points at and above this height will be the same color.
[ "Color", "each", "vertex", "by", "its", "height", "above", "the", "floor", "point", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/color.py#L85-L105
bodylabs/lace
lace/color.py
MeshMixin.color_as_heatmap
def color_as_heatmap(self, weights, max_weight=1.0, color=DEFAULT_COLORMAP): ''' Truncate weights to the range [0, max_weight] and rescale, as you would want for a heatmap with known scale. ''' import numpy as np adjusted_weights = np.clip(weights, 0., max_weight) / max_w...
python
def color_as_heatmap(self, weights, max_weight=1.0, color=DEFAULT_COLORMAP): ''' Truncate weights to the range [0, max_weight] and rescale, as you would want for a heatmap with known scale. ''' import numpy as np adjusted_weights = np.clip(weights, 0., max_weight) / max_w...
[ "def", "color_as_heatmap", "(", "self", ",", "weights", ",", "max_weight", "=", "1.0", ",", "color", "=", "DEFAULT_COLORMAP", ")", ":", "import", "numpy", "as", "np", "adjusted_weights", "=", "np", ".", "clip", "(", "weights", ",", "0.", ",", "max_weight",...
Truncate weights to the range [0, max_weight] and rescale, as you would want for a heatmap with known scale.
[ "Truncate", "weights", "to", "the", "range", "[", "0", "max_weight", "]", "and", "rescale", "as", "you", "would", "want", "for", "a", "heatmap", "with", "known", "scale", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/color.py#L107-L114
bodylabs/lace
lace/topology.py
quads_to_tris
def quads_to_tris(quads): ''' Convert quad faces to triangular faces. quads: An nx4 array. Return a 2nx3 array. ''' import numpy as np tris = np.empty((2 * len(quads), 3)) tris[0::2, :] = quads[:, [0, 1, 2]] tris[1::2, :] = quads[:, [0, 2, 3]] return tris
python
def quads_to_tris(quads): ''' Convert quad faces to triangular faces. quads: An nx4 array. Return a 2nx3 array. ''' import numpy as np tris = np.empty((2 * len(quads), 3)) tris[0::2, :] = quads[:, [0, 1, 2]] tris[1::2, :] = quads[:, [0, 2, 3]] return tris
[ "def", "quads_to_tris", "(", "quads", ")", ":", "import", "numpy", "as", "np", "tris", "=", "np", ".", "empty", "(", "(", "2", "*", "len", "(", "quads", ")", ",", "3", ")", ")", "tris", "[", "0", ":", ":", "2", ",", ":", "]", "=", "quads", ...
Convert quad faces to triangular faces. quads: An nx4 array. Return a 2nx3 array.
[ "Convert", "quad", "faces", "to", "triangular", "faces", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L4-L17
bodylabs/lace
lace/topology.py
MeshMixin.all_faces_with_verts
def all_faces_with_verts(self, v_indices, as_boolean=False): ''' returns all of the faces that contain at least one of the vertices in v_indices ''' import numpy as np included_vertices = np.zeros(self.v.shape[0], dtype=bool) included_vertices[np.array(v_indices, dtype=np...
python
def all_faces_with_verts(self, v_indices, as_boolean=False): ''' returns all of the faces that contain at least one of the vertices in v_indices ''' import numpy as np included_vertices = np.zeros(self.v.shape[0], dtype=bool) included_vertices[np.array(v_indices, dtype=np...
[ "def", "all_faces_with_verts", "(", "self", ",", "v_indices", ",", "as_boolean", "=", "False", ")", ":", "import", "numpy", "as", "np", "included_vertices", "=", "np", ".", "zeros", "(", "self", ".", "v", ".", "shape", "[", "0", "]", ",", "dtype", "=",...
returns all of the faces that contain at least one of the vertices in v_indices
[ "returns", "all", "of", "the", "faces", "that", "contain", "at", "least", "one", "of", "the", "vertices", "in", "v_indices" ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L47-L57
bodylabs/lace
lace/topology.py
MeshMixin.vertex_indices_in_segments
def vertex_indices_in_segments(self, segments, ret_face_indices=False): ''' Given a list of segment names, return an array of vertex indices for all the vertices in those faces. Args: segments: a list of segment names, ret_face_indices: if it is `True`, returns f...
python
def vertex_indices_in_segments(self, segments, ret_face_indices=False): ''' Given a list of segment names, return an array of vertex indices for all the vertices in those faces. Args: segments: a list of segment names, ret_face_indices: if it is `True`, returns f...
[ "def", "vertex_indices_in_segments", "(", "self", ",", "segments", ",", "ret_face_indices", "=", "False", ")", ":", "import", "numpy", "as", "np", "import", "warnings", "face_indices", "=", "np", ".", "array", "(", "[", "]", ")", "vertex_indices", "=", "np",...
Given a list of segment names, return an array of vertex indices for all the vertices in those faces. Args: segments: a list of segment names, ret_face_indices: if it is `True`, returns face indices
[ "Given", "a", "list", "of", "segment", "names", "return", "an", "array", "of", "vertex", "indices", "for", "all", "the", "vertices", "in", "those", "faces", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L76-L103
bodylabs/lace
lace/topology.py
MeshMixin.keep_segments
def keep_segments(self, segments_to_keep, preserve_segmentation=True): ''' Keep the faces and vertices for given segments, discarding all others. When preserve_segmentation is false self.segm is discarded for speed. ''' v_ind, f_ind = self.vertex_indices_in_segments(segments_to_k...
python
def keep_segments(self, segments_to_keep, preserve_segmentation=True): ''' Keep the faces and vertices for given segments, discarding all others. When preserve_segmentation is false self.segm is discarded for speed. ''' v_ind, f_ind = self.vertex_indices_in_segments(segments_to_k...
[ "def", "keep_segments", "(", "self", ",", "segments_to_keep", ",", "preserve_segmentation", "=", "True", ")", ":", "v_ind", ",", "f_ind", "=", "self", ".", "vertex_indices_in_segments", "(", "segments_to_keep", ",", "ret_face_indices", "=", "True", ")", "self", ...
Keep the faces and vertices for given segments, discarding all others. When preserve_segmentation is false self.segm is discarded for speed.
[ "Keep", "the", "faces", "and", "vertices", "for", "given", "segments", "discarding", "all", "others", ".", "When", "preserve_segmentation", "is", "false", "self", ".", "segm", "is", "discarded", "for", "speed", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L110-L124
bodylabs/lace
lace/topology.py
MeshMixin.remove_segments
def remove_segments(self, segments_to_remove): ''' Remove the faces and vertices for given segments, keeping all others. Args: segments_to_remove: a list of segnments whose vertices will be removed ''' v_ind = self.vertex_indices_in_segments(segments_to_remove) self....
python
def remove_segments(self, segments_to_remove): ''' Remove the faces and vertices for given segments, keeping all others. Args: segments_to_remove: a list of segnments whose vertices will be removed ''' v_ind = self.vertex_indices_in_segments(segments_to_remove) self....
[ "def", "remove_segments", "(", "self", ",", "segments_to_remove", ")", ":", "v_ind", "=", "self", ".", "vertex_indices_in_segments", "(", "segments_to_remove", ")", "self", ".", "segm", "=", "{", "name", ":", "faces", "for", "name", ",", "faces", "in", "self...
Remove the faces and vertices for given segments, keeping all others. Args: segments_to_remove: a list of segnments whose vertices will be removed
[ "Remove", "the", "faces", "and", "vertices", "for", "given", "segments", "keeping", "all", "others", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L126-L134
bodylabs/lace
lace/topology.py
MeshMixin.verts_in_common
def verts_in_common(self, segments): """ returns array of all vertex indices common to each segment in segments""" verts_by_segm = self.verts_by_segm return sorted(reduce(lambda s0, s1: s0.intersection(s1), [set(verts_by_segm[segm]) for segm in segments]))
python
def verts_in_common(self, segments): """ returns array of all vertex indices common to each segment in segments""" verts_by_segm = self.verts_by_segm return sorted(reduce(lambda s0, s1: s0.intersection(s1), [set(verts_by_segm[segm]) for segm in segments]))
[ "def", "verts_in_common", "(", "self", ",", "segments", ")", ":", "verts_by_segm", "=", "self", ".", "verts_by_segm", "return", "sorted", "(", "reduce", "(", "lambda", "s0", ",", "s1", ":", "s0", ".", "intersection", "(", "s1", ")", ",", "[", "set", "(...
returns array of all vertex indices common to each segment in segments
[ "returns", "array", "of", "all", "vertex", "indices", "common", "to", "each", "segment", "in", "segments" ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L147-L152
bodylabs/lace
lace/topology.py
MeshMixin.uniquified_mesh
def uniquified_mesh(self): """This function returns a copy of the mesh in which vertices are copied such that each vertex appears in only one face, and hence has only one texture""" import numpy as np from lace.mesh import Mesh new_mesh = Mesh(v=self.v[self.f.flatten()], f=np.arr...
python
def uniquified_mesh(self): """This function returns a copy of the mesh in which vertices are copied such that each vertex appears in only one face, and hence has only one texture""" import numpy as np from lace.mesh import Mesh new_mesh = Mesh(v=self.v[self.f.flatten()], f=np.arr...
[ "def", "uniquified_mesh", "(", "self", ")", ":", "import", "numpy", "as", "np", "from", "lace", ".", "mesh", "import", "Mesh", "new_mesh", "=", "Mesh", "(", "v", "=", "self", ".", "v", "[", "self", ".", "f", ".", "flatten", "(", ")", "]", ",", "f...
This function returns a copy of the mesh in which vertices are copied such that each vertex appears in only one face, and hence has only one texture
[ "This", "function", "returns", "a", "copy", "of", "the", "mesh", "in", "which", "vertices", "are", "copied", "such", "that", "each", "vertex", "appears", "in", "only", "one", "face", "and", "hence", "has", "only", "one", "texture" ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L179-L193
bodylabs/lace
lace/topology.py
MeshMixin.downsampled_mesh
def downsampled_mesh(self, step): """Returns a downsampled copy of this mesh. Args: step: the step size for the sampling Returns: a new, downsampled Mesh object. Raises: ValueError if this Mesh has faces. """ from lace.mesh import Me...
python
def downsampled_mesh(self, step): """Returns a downsampled copy of this mesh. Args: step: the step size for the sampling Returns: a new, downsampled Mesh object. Raises: ValueError if this Mesh has faces. """ from lace.mesh import Me...
[ "def", "downsampled_mesh", "(", "self", ",", "step", ")", ":", "from", "lace", ".", "mesh", "import", "Mesh", "if", "self", ".", "f", "is", "not", "None", ":", "raise", "ValueError", "(", "'Function `downsampled_mesh` does not support faces.'", ")", "low", "="...
Returns a downsampled copy of this mesh. Args: step: the step size for the sampling Returns: a new, downsampled Mesh object. Raises: ValueError if this Mesh has faces.
[ "Returns", "a", "downsampled", "copy", "of", "this", "mesh", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L195-L218
bodylabs/lace
lace/topology.py
MeshMixin.keep_vertices
def keep_vertices(self, indices_to_keep, ret_kept_faces=False): ''' Keep the given vertices and discard the others, and any faces to which they may belong. If `ret_kept_faces` is `True`, return the original indices of the kept faces. Otherwise return `self` for chaining. ...
python
def keep_vertices(self, indices_to_keep, ret_kept_faces=False): ''' Keep the given vertices and discard the others, and any faces to which they may belong. If `ret_kept_faces` is `True`, return the original indices of the kept faces. Otherwise return `self` for chaining. ...
[ "def", "keep_vertices", "(", "self", ",", "indices_to_keep", ",", "ret_kept_faces", "=", "False", ")", ":", "import", "numpy", "as", "np", "if", "self", ".", "v", "is", "None", ":", "return", "indices_to_keep", "=", "np", ".", "array", "(", "indices_to_kee...
Keep the given vertices and discard the others, and any faces to which they may belong. If `ret_kept_faces` is `True`, return the original indices of the kept faces. Otherwise return `self` for chaining.
[ "Keep", "the", "given", "vertices", "and", "discard", "the", "others", "and", "any", "faces", "to", "which", "they", "may", "belong", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L220-L279
bodylabs/lace
lace/topology.py
MeshMixin.create_from_mesh_and_lines
def create_from_mesh_and_lines(cls, mesh, lines): ''' Return a copy of mesh with line vertices and edges added. mesh: A Mesh lines: A list of Polyline or Lines objects. ''' mesh_with_lines = mesh.copy() mesh_with_lines.add_lines(lines) return mesh_with_l...
python
def create_from_mesh_and_lines(cls, mesh, lines): ''' Return a copy of mesh with line vertices and edges added. mesh: A Mesh lines: A list of Polyline or Lines objects. ''' mesh_with_lines = mesh.copy() mesh_with_lines.add_lines(lines) return mesh_with_l...
[ "def", "create_from_mesh_and_lines", "(", "cls", ",", "mesh", ",", "lines", ")", ":", "mesh_with_lines", "=", "mesh", ".", "copy", "(", ")", "mesh_with_lines", ".", "add_lines", "(", "lines", ")", "return", "mesh_with_lines" ]
Return a copy of mesh with line vertices and edges added. mesh: A Mesh lines: A list of Polyline or Lines objects.
[ "Return", "a", "copy", "of", "mesh", "with", "line", "vertices", "and", "edges", "added", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L367-L377
bodylabs/lace
lace/topology.py
MeshMixin.add_lines
def add_lines(self, lines): ''' Add line vertices and edges to the mesh. lines: A list of Polyline or Lines objects. ''' import numpy as np if not lines: return v_lines = np.vstack([l.v for l in lines]) v_index_offset = np.cumsum([0] + [len(...
python
def add_lines(self, lines): ''' Add line vertices and edges to the mesh. lines: A list of Polyline or Lines objects. ''' import numpy as np if not lines: return v_lines = np.vstack([l.v for l in lines]) v_index_offset = np.cumsum([0] + [len(...
[ "def", "add_lines", "(", "self", ",", "lines", ")", ":", "import", "numpy", "as", "np", "if", "not", "lines", ":", "return", "v_lines", "=", "np", ".", "vstack", "(", "[", "l", ".", "v", "for", "l", "in", "lines", "]", ")", "v_index_offset", "=", ...
Add line vertices and edges to the mesh. lines: A list of Polyline or Lines objects.
[ "Add", "line", "vertices", "and", "edges", "to", "the", "mesh", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L379-L395
bodylabs/lace
lace/topology.py
MeshMixin.vert_connectivity
def vert_connectivity(self): """Returns a sparse matrix (of size #verts x #verts) where each nonzero element indicates a neighborhood relation. For example, if there is a nonzero element in position (15, 12), that means vertex 15 is connected by an edge to vertex 12.""" import nu...
python
def vert_connectivity(self): """Returns a sparse matrix (of size #verts x #verts) where each nonzero element indicates a neighborhood relation. For example, if there is a nonzero element in position (15, 12), that means vertex 15 is connected by an edge to vertex 12.""" import nu...
[ "def", "vert_connectivity", "(", "self", ")", ":", "import", "numpy", "as", "np", "import", "scipy", ".", "sparse", "as", "sp", "from", "blmath", ".", "numerics", ".", "matlab", "import", "row", "vpv", "=", "sp", ".", "csc_matrix", "(", "(", "len", "("...
Returns a sparse matrix (of size #verts x #verts) where each nonzero element indicates a neighborhood relation. For example, if there is a nonzero element in position (15, 12), that means vertex 15 is connected by an edge to vertex 12.
[ "Returns", "a", "sparse", "matrix", "(", "of", "size", "#verts", "x", "#verts", ")", "where", "each", "nonzero", "element", "indicates", "a", "neighborhood", "relation", ".", "For", "example", "if", "there", "is", "a", "nonzero", "element", "in", "position",...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L398-L415
bodylabs/lace
lace/topology.py
MeshMixin.vert_opposites_per_edge
def vert_opposites_per_edge(self): """Returns a dictionary from vertidx-pairs to opposites. For example, a key consist of [4, 5)] meaning the edge between vertices 4 and 5, and a value might be [10, 11] which are the indices of the vertices opposing this edge.""" result = {} ...
python
def vert_opposites_per_edge(self): """Returns a dictionary from vertidx-pairs to opposites. For example, a key consist of [4, 5)] meaning the edge between vertices 4 and 5, and a value might be [10, 11] which are the indices of the vertices opposing this edge.""" result = {} ...
[ "def", "vert_opposites_per_edge", "(", "self", ")", ":", "result", "=", "{", "}", "for", "f", "in", "self", ".", "f", ":", "for", "i", "in", "range", "(", "3", ")", ":", "key", "=", "[", "f", "[", "i", "]", ",", "f", "[", "(", "i", "+", "1"...
Returns a dictionary from vertidx-pairs to opposites. For example, a key consist of [4, 5)] meaning the edge between vertices 4 and 5, and a value might be [10, 11] which are the indices of the vertices opposing this edge.
[ "Returns", "a", "dictionary", "from", "vertidx", "-", "pairs", "to", "opposites", ".", "For", "example", "a", "key", "consist", "of", "[", "4", "5", ")", "]", "meaning", "the", "edge", "between", "vertices", "4", "and", "5", "and", "a", "value", "might...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L418-L435
bodylabs/lace
lace/topology.py
MeshMixin.faces_per_edge
def faces_per_edge(self): """Returns an Ex2 array of adjacencies between faces, where each element in the array is a face index. Each edge is included only once. Edges that are not shared by 2 faces are not included.""" import numpy as np import scipy.sparse as sp from bl...
python
def faces_per_edge(self): """Returns an Ex2 array of adjacencies between faces, where each element in the array is a face index. Each edge is included only once. Edges that are not shared by 2 faces are not included.""" import numpy as np import scipy.sparse as sp from bl...
[ "def", "faces_per_edge", "(", "self", ")", ":", "import", "numpy", "as", "np", "import", "scipy", ".", "sparse", "as", "sp", "from", "blmath", ".", "numerics", ".", "matlab", "import", "col", "IS", "=", "np", ".", "repeat", "(", "np", ".", "arange", ...
Returns an Ex2 array of adjacencies between faces, where each element in the array is a face index. Each edge is included only once. Edges that are not shared by 2 faces are not included.
[ "Returns", "an", "Ex2", "array", "of", "adjacencies", "between", "faces", "where", "each", "element", "in", "the", "array", "is", "a", "face", "index", ".", "Each", "edge", "is", "included", "only", "once", ".", "Edges", "that", "are", "not", "shared", "...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L438-L453
bodylabs/lace
lace/topology.py
MeshMixin.vertices_per_edge
def vertices_per_edge(self): """Returns an Ex2 array of adjacencies between vertices, where each element in the array is a vertex index. Each edge is included only once. Edges that are not shared by 2 faces are not included.""" import numpy as np return np.asarray([vertices_in_co...
python
def vertices_per_edge(self): """Returns an Ex2 array of adjacencies between vertices, where each element in the array is a vertex index. Each edge is included only once. Edges that are not shared by 2 faces are not included.""" import numpy as np return np.asarray([vertices_in_co...
[ "def", "vertices_per_edge", "(", "self", ")", ":", "import", "numpy", "as", "np", "return", "np", ".", "asarray", "(", "[", "vertices_in_common", "(", "e", "[", "0", "]", ",", "e", "[", "1", "]", ")", "for", "e", "in", "self", ".", "f", "[", "sel...
Returns an Ex2 array of adjacencies between vertices, where each element in the array is a vertex index. Each edge is included only once. Edges that are not shared by 2 faces are not included.
[ "Returns", "an", "Ex2", "array", "of", "adjacencies", "between", "vertices", "where", "each", "element", "in", "the", "array", "is", "a", "vertex", "index", ".", "Each", "edge", "is", "included", "only", "once", ".", "Edges", "that", "are", "not", "shared"...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L456-L461
bodylabs/lace
lace/topology.py
MeshMixin.get_vertices_to_edges_matrix
def get_vertices_to_edges_matrix(self, want_xyz=True): """Returns a matrix M, which if multiplied by vertices, gives back edges (so "e = M.dot(v)"). Note that this generates one edge per edge, *not* two edges per triangle. Args: want_xyz: if true, takes and returns xyz coord...
python
def get_vertices_to_edges_matrix(self, want_xyz=True): """Returns a matrix M, which if multiplied by vertices, gives back edges (so "e = M.dot(v)"). Note that this generates one edge per edge, *not* two edges per triangle. Args: want_xyz: if true, takes and returns xyz coord...
[ "def", "get_vertices_to_edges_matrix", "(", "self", ",", "want_xyz", "=", "True", ")", ":", "import", "numpy", "as", "np", "import", "scipy", ".", "sparse", "as", "sp", "vpe", "=", "np", ".", "asarray", "(", "self", ".", "vertices_per_edge", ",", "dtype", ...
Returns a matrix M, which if multiplied by vertices, gives back edges (so "e = M.dot(v)"). Note that this generates one edge per edge, *not* two edges per triangle. Args: want_xyz: if true, takes and returns xyz coordinates, otherwise takes and returns x *or* y *or* ...
[ "Returns", "a", "matrix", "M", "which", "if", "multiplied", "by", "vertices", "gives", "back", "edges", "(", "so", "e", "=", "M", ".", "dot", "(", "v", ")", ")", ".", "Note", "that", "this", "generates", "one", "edge", "per", "edge", "*", "not", "*...
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L463-L488
bodylabs/lace
lace/topology.py
MeshMixin.remove_redundant_verts
def remove_redundant_verts(self, eps=1e-10): """Given verts and faces, this remove colocated vertices""" import numpy as np from scipy.spatial import cKDTree # FIXME pylint: disable=no-name-in-module fshape = self.f.shape tree = cKDTree(self.v) close_pairs = list(tree.que...
python
def remove_redundant_verts(self, eps=1e-10): """Given verts and faces, this remove colocated vertices""" import numpy as np from scipy.spatial import cKDTree # FIXME pylint: disable=no-name-in-module fshape = self.f.shape tree = cKDTree(self.v) close_pairs = list(tree.que...
[ "def", "remove_redundant_verts", "(", "self", ",", "eps", "=", "1e-10", ")", ":", "import", "numpy", "as", "np", "from", "scipy", ".", "spatial", "import", "cKDTree", "# FIXME pylint: disable=no-name-in-module", "fshape", "=", "self", ".", "f", ".", "shape", "...
Given verts and faces, this remove colocated vertices
[ "Given", "verts", "and", "faces", "this", "remove", "colocated", "vertices" ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/topology.py#L498-L518
openspending/babbage
babbage/model/dimension.py
Dimension.cardinality_class
def cardinality_class(self): """ Group the cardinality of the dimension into one of four buckets, from very small (less than 5) to very large (more than 1000). """ if self.cardinality: if self.cardinality > 1000: return 'high' if self.cardinality > 50: ...
python
def cardinality_class(self): """ Group the cardinality of the dimension into one of four buckets, from very small (less than 5) to very large (more than 1000). """ if self.cardinality: if self.cardinality > 1000: return 'high' if self.cardinality > 50: ...
[ "def", "cardinality_class", "(", "self", ")", ":", "if", "self", ".", "cardinality", ":", "if", "self", ".", "cardinality", ">", "1000", ":", "return", "'high'", "if", "self", ".", "cardinality", ">", "50", ":", "return", "'medium'", "if", "self", ".", ...
Group the cardinality of the dimension into one of four buckets, from very small (less than 5) to very large (more than 1000).
[ "Group", "the", "cardinality", "of", "the", "dimension", "into", "one", "of", "four", "buckets", "from", "very", "small", "(", "less", "than", "5", ")", "to", "very", "large", "(", "more", "than", "1000", ")", "." ]
train
https://github.com/openspending/babbage/blob/9e03efe62e0be0cceabafd4de2a09cb8ec794b92/babbage/model/dimension.py#L50-L60
bodylabs/lace
lace/serialization/obj/__init__.py
_dump
def _dump(f, obj, flip_faces=False, ungroup=False, comments=None, split_normals=False, write_mtl=True): # pylint: disable=redefined-outer-name ''' write_mtl: When True and mesh has a texture, includes a mtllib reference in the .obj and writes a .mtl alongside. ''' import os import numpy as np...
python
def _dump(f, obj, flip_faces=False, ungroup=False, comments=None, split_normals=False, write_mtl=True): # pylint: disable=redefined-outer-name ''' write_mtl: When True and mesh has a texture, includes a mtllib reference in the .obj and writes a .mtl alongside. ''' import os import numpy as np...
[ "def", "_dump", "(", "f", ",", "obj", ",", "flip_faces", "=", "False", ",", "ungroup", "=", "False", ",", "comments", "=", "None", ",", "split_normals", "=", "False", ",", "write_mtl", "=", "True", ")", ":", "# pylint: disable=redefined-outer-name", "import"...
write_mtl: When True and mesh has a texture, includes a mtllib reference in the .obj and writes a .mtl alongside.
[ "write_mtl", ":", "When", "True", "and", "mesh", "has", "a", "texture", "includes", "a", "mtllib", "reference", "in", "the", ".", "obj", "and", "writes", "a", ".", "mtl", "alongside", "." ]
train
https://github.com/bodylabs/lace/blob/b68f4a60a4cac66c0607ffbae38ef9d07d37f459/lace/serialization/obj/__init__.py#L105-L223
nschloe/meshplex
meshplex/mesh_tri.py
MeshTri.signed_cell_areas
def signed_cell_areas(self): """Signed area of a triangle in 2D. """ # http://mathworld.wolfram.com/TriangleArea.html assert ( self.node_coords.shape[1] == 2 ), "Signed areas only make sense for triangles in 2D." if self._signed_cell_areas is None: ...
python
def signed_cell_areas(self): """Signed area of a triangle in 2D. """ # http://mathworld.wolfram.com/TriangleArea.html assert ( self.node_coords.shape[1] == 2 ), "Signed areas only make sense for triangles in 2D." if self._signed_cell_areas is None: ...
[ "def", "signed_cell_areas", "(", "self", ")", ":", "# http://mathworld.wolfram.com/TriangleArea.html", "assert", "(", "self", ".", "node_coords", ".", "shape", "[", "1", "]", "==", "2", ")", ",", "\"Signed areas only make sense for triangles in 2D.\"", "if", "self", "...
Signed area of a triangle in 2D.
[ "Signed", "area", "of", "a", "triangle", "in", "2D", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/mesh_tri.py#L282-L300
nschloe/meshplex
meshplex/mesh_tri.py
MeshTri.create_edges
def create_edges(self): """Set up edge-node and edge-cell relations. """ # Reshape into individual edges. # Sort the columns to make it possible for `unique()` to identify # individual edges. s = self.idx_hierarchy.shape a = numpy.sort(self.idx_hierarchy.reshape(s...
python
def create_edges(self): """Set up edge-node and edge-cell relations. """ # Reshape into individual edges. # Sort the columns to make it possible for `unique()` to identify # individual edges. s = self.idx_hierarchy.shape a = numpy.sort(self.idx_hierarchy.reshape(s...
[ "def", "create_edges", "(", "self", ")", ":", "# Reshape into individual edges.", "# Sort the columns to make it possible for `unique()` to identify", "# individual edges.", "s", "=", "self", ".", "idx_hierarchy", ".", "shape", "a", "=", "numpy", ".", "sort", "(", "self",...
Set up edge-node and edge-cell relations.
[ "Set", "up", "edge", "-", "node", "and", "edge", "-", "cell", "relations", "." ]
train
https://github.com/nschloe/meshplex/blob/376cfe8ce7b9917e5398c5d60c87455ff5590913/meshplex/mesh_tri.py#L334-L366