repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.add_quantity_modifier
def add_quantity_modifier(self, quantity, modifier, overwrite=False): """ Add a quantify modifier. Consider useing the high-level function `add_derived_quantity` instead! Parameters ---------- quantity : str name of the derived quantity to add modifi...
python
def add_quantity_modifier(self, quantity, modifier, overwrite=False): """ Add a quantify modifier. Consider useing the high-level function `add_derived_quantity` instead! Parameters ---------- quantity : str name of the derived quantity to add modifi...
[ "def", "add_quantity_modifier", "(", "self", ",", "quantity", ",", "modifier", ",", "overwrite", "=", "False", ")", ":", "if", "quantity", "in", "self", ".", "_quantity_modifiers", "and", "not", "overwrite", ":", "raise", "ValueError", "(", "'quantity `{}` alrea...
Add a quantify modifier. Consider useing the high-level function `add_derived_quantity` instead! Parameters ---------- quantity : str name of the derived quantity to add modifier : None or str or tuple If the quantity modifier is a tuple of length >=2 an...
[ "Add", "a", "quantify", "modifier", ".", "Consider", "useing", "the", "high", "-", "level", "function", "add_derived_quantity", "instead!" ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L194-L217
train
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.get_normalized_quantity_modifier
def get_normalized_quantity_modifier(self, quantity): """ Retrive a quantify modifier, normalized. This function would also return a tuple, with the first item a callable, and the rest native quantity names Parameters ---------- quantity : str name of...
python
def get_normalized_quantity_modifier(self, quantity): """ Retrive a quantify modifier, normalized. This function would also return a tuple, with the first item a callable, and the rest native quantity names Parameters ---------- quantity : str name of...
[ "def", "get_normalized_quantity_modifier", "(", "self", ",", "quantity", ")", ":", "modifier", "=", "self", ".", "_quantity_modifiers", ".", "get", "(", "quantity", ",", "self", ".", "_default_quantity_modifier", ")", "if", "modifier", "is", "None", ":", "return...
Retrive a quantify modifier, normalized. This function would also return a tuple, with the first item a callable, and the rest native quantity names Parameters ---------- quantity : str name of the derived quantity to get Returns ------- tupl...
[ "Retrive", "a", "quantify", "modifier", "normalized", ".", "This", "function", "would", "also", "return", "a", "tuple", "with", "the", "first", "item", "a", "callable", "and", "the", "rest", "native", "quantity", "names" ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L234-L259
train
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.add_derived_quantity
def add_derived_quantity(self, derived_quantity, func, *quantities): """ Add a derived quantify modifier. Parameters ---------- derived_quantity : str name of the derived quantity to be added func : callable function to calculate the derived quan...
python
def add_derived_quantity(self, derived_quantity, func, *quantities): """ Add a derived quantify modifier. Parameters ---------- derived_quantity : str name of the derived quantity to be added func : callable function to calculate the derived quan...
[ "def", "add_derived_quantity", "(", "self", ",", "derived_quantity", ",", "func", ",", "*", "quantities", ")", ":", "if", "derived_quantity", "in", "self", ".", "_quantity_modifiers", ":", "raise", "ValueError", "(", "'quantity name `{}` already exists'", ".", "form...
Add a derived quantify modifier. Parameters ---------- derived_quantity : str name of the derived quantity to be added func : callable function to calculate the derived quantity the number of arguments should equal number of following `quantities` ...
[ "Add", "a", "derived", "quantify", "modifier", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L261-L304
train
yymao/generic-catalog-reader
GCR/base.py
BaseGenericCatalog.add_modifier_on_derived_quantities
def add_modifier_on_derived_quantities(self, new_quantity, func, *quantities): """ Deprecated. Use `add_derived_quantity` instead. """ warnings.warn("Use `add_derived_quantity` instead.", DeprecationWarning) self.add_derived_quantity(new_quantity, func, *quantities)
python
def add_modifier_on_derived_quantities(self, new_quantity, func, *quantities): """ Deprecated. Use `add_derived_quantity` instead. """ warnings.warn("Use `add_derived_quantity` instead.", DeprecationWarning) self.add_derived_quantity(new_quantity, func, *quantities)
[ "def", "add_modifier_on_derived_quantities", "(", "self", ",", "new_quantity", ",", "func", ",", "*", "quantities", ")", ":", "warnings", ".", "warn", "(", "\"Use `add_derived_quantity` instead.\"", ",", "DeprecationWarning", ")", "self", ".", "add_derived_quantity", ...
Deprecated. Use `add_derived_quantity` instead.
[ "Deprecated", ".", "Use", "add_derived_quantity", "instead", "." ]
bc6267ac41b9f68106ed6065184469ac13fdc0b6
https://github.com/yymao/generic-catalog-reader/blob/bc6267ac41b9f68106ed6065184469ac13fdc0b6/GCR/base.py#L306-L311
train
brutus/wdiffhtml
wdiffhtml/utils.py
check_for_wdiff
def check_for_wdiff(): """ Checks if the `wdiff` command can be found. Raises: WdiffNotFoundError: if ``wdiff`` is not found. """ cmd = ['which', CMD_WDIFF] DEVNULL = open(os.devnull, 'wb') proc = sub.Popen(cmd, stdout=DEVNULL) proc.wait() DEVNULL.close() if proc.returncode != 0: msg = "t...
python
def check_for_wdiff(): """ Checks if the `wdiff` command can be found. Raises: WdiffNotFoundError: if ``wdiff`` is not found. """ cmd = ['which', CMD_WDIFF] DEVNULL = open(os.devnull, 'wb') proc = sub.Popen(cmd, stdout=DEVNULL) proc.wait() DEVNULL.close() if proc.returncode != 0: msg = "t...
[ "def", "check_for_wdiff", "(", ")", ":", "cmd", "=", "[", "'which'", ",", "CMD_WDIFF", "]", "DEVNULL", "=", "open", "(", "os", ".", "devnull", ",", "'wb'", ")", "proc", "=", "sub", ".", "Popen", "(", "cmd", ",", "stdout", "=", "DEVNULL", ")", "proc...
Checks if the `wdiff` command can be found. Raises: WdiffNotFoundError: if ``wdiff`` is not found.
[ "Checks", "if", "the", "wdiff", "command", "can", "be", "found", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L36-L52
train
brutus/wdiffhtml
wdiffhtml/utils.py
generate_wdiff
def generate_wdiff(org_file, new_file, fold_tags=False, html=True): """ Returns the results from the `wdiff` command as a string. HTML `<ins>` and `<del>` tags will be used instead of the default markings, unless *html* is set to `False`. If *fold_tags* is set, `<ins>` and `<del>` tags are allowed to span l...
python
def generate_wdiff(org_file, new_file, fold_tags=False, html=True): """ Returns the results from the `wdiff` command as a string. HTML `<ins>` and `<del>` tags will be used instead of the default markings, unless *html* is set to `False`. If *fold_tags* is set, `<ins>` and `<del>` tags are allowed to span l...
[ "def", "generate_wdiff", "(", "org_file", ",", "new_file", ",", "fold_tags", "=", "False", ",", "html", "=", "True", ")", ":", "check_for_wdiff", "(", ")", "cmd", "=", "[", "CMD_WDIFF", "]", "if", "html", ":", "cmd", ".", "extend", "(", "OPTIONS_OUTPUT",...
Returns the results from the `wdiff` command as a string. HTML `<ins>` and `<del>` tags will be used instead of the default markings, unless *html* is set to `False`. If *fold_tags* is set, `<ins>` and `<del>` tags are allowed to span line breaks (option `-n` is not used). Raises: subrocess.CalledProc...
[ "Returns", "the", "results", "from", "the", "wdiff", "command", "as", "a", "string", "." ]
e97b524a7945f7a626e33ec141343120c524d9fa
https://github.com/brutus/wdiffhtml/blob/e97b524a7945f7a626e33ec141343120c524d9fa/wdiffhtml/utils.py#L55-L79
train
mesbahamin/chronophore
chronophore/tkview.py
TkUserTypeSelectionDialog.body
def body(self, master): """Create dialog body. Return widget that should have initial focus. Inherited from tkinter.simpledialog.Dialog """ self.frame = ttk.Frame(master, padding=(5, 5, 10, 10)) self.lbl_message = ttk.Label( self.frame, text='Sel...
python
def body(self, master): """Create dialog body. Return widget that should have initial focus. Inherited from tkinter.simpledialog.Dialog """ self.frame = ttk.Frame(master, padding=(5, 5, 10, 10)) self.lbl_message = ttk.Label( self.frame, text='Sel...
[ "def", "body", "(", "self", ",", "master", ")", ":", "self", ".", "frame", "=", "ttk", ".", "Frame", "(", "master", ",", "padding", "=", "(", "5", ",", "5", ",", "10", ",", "10", ")", ")", "self", ".", "lbl_message", "=", "ttk", ".", "Label", ...
Create dialog body. Return widget that should have initial focus. Inherited from tkinter.simpledialog.Dialog
[ "Create", "dialog", "body", ".", "Return", "widget", "that", "should", "have", "initial", "focus", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L240-L289
train
mesbahamin/chronophore
chronophore/tkview.py
TkUserTypeSelectionDialog.apply
def apply(self): """Inherited from tkinter.simpledialog.Dialog""" user_type = self.rb_choice.get() if user_type == 'student' or user_type == 'tutor': self.result = user_type
python
def apply(self): """Inherited from tkinter.simpledialog.Dialog""" user_type = self.rb_choice.get() if user_type == 'student' or user_type == 'tutor': self.result = user_type
[ "def", "apply", "(", "self", ")", ":", "user_type", "=", "self", ".", "rb_choice", ".", "get", "(", ")", "if", "user_type", "==", "'student'", "or", "user_type", "==", "'tutor'", ":", "self", ".", "result", "=", "user_type" ]
Inherited from tkinter.simpledialog.Dialog
[ "Inherited", "from", "tkinter", ".", "simpledialog", ".", "Dialog" ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/tkview.py#L321-L325
train
mesbahamin/chronophore
chronophore/controller.py
flag_forgotten_entries
def flag_forgotten_entries(session, today=None): """Flag any entries from previous days where users forgot to sign out. :param session: SQLAlchemy session through which to access the database. :param today: (optional) The current date as a `datetime.date` object. Used for testing. """ # noqa to...
python
def flag_forgotten_entries(session, today=None): """Flag any entries from previous days where users forgot to sign out. :param session: SQLAlchemy session through which to access the database. :param today: (optional) The current date as a `datetime.date` object. Used for testing. """ # noqa to...
[ "def", "flag_forgotten_entries", "(", "session", ",", "today", "=", "None", ")", ":", "today", "=", "date", ".", "today", "(", ")", "if", "today", "is", "None", "else", "today", "forgotten", "=", "(", "session", ".", "query", "(", "Entry", ")", ".", ...
Flag any entries from previous days where users forgot to sign out. :param session: SQLAlchemy session through which to access the database. :param today: (optional) The current date as a `datetime.date` object. Used for testing.
[ "Flag", "any", "entries", "from", "previous", "days", "where", "users", "forgot", "to", "sign", "out", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L65-L87
train
mesbahamin/chronophore
chronophore/controller.py
signed_in_users
def signed_in_users(session=None, today=None, full_name=True): """Return list of names of currently signed in users. :param session: SQLAlchemy session through which to access the database. :param today: (optional) The current date as a `datetime.date` object. Used for testing. :param full_name: (optio...
python
def signed_in_users(session=None, today=None, full_name=True): """Return list of names of currently signed in users. :param session: SQLAlchemy session through which to access the database. :param today: (optional) The current date as a `datetime.date` object. Used for testing. :param full_name: (optio...
[ "def", "signed_in_users", "(", "session", "=", "None", ",", "today", "=", "None", ",", "full_name", "=", "True", ")", ":", "if", "session", "is", "None", ":", "session", "=", "Session", "(", ")", "else", ":", "session", "=", "session", "if", "today", ...
Return list of names of currently signed in users. :param session: SQLAlchemy session through which to access the database. :param today: (optional) The current date as a `datetime.date` object. Used for testing. :param full_name: (optional) Whether to display full user names, or just first names. :ret...
[ "Return", "list", "of", "names", "of", "currently", "signed", "in", "users", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L90-L118
train
mesbahamin/chronophore
chronophore/controller.py
get_user_name
def get_user_name(user, full_name=True): """Return the user's name as a string. :param user: `models.User` object. The user to get the name of. :param full_name: (optional) Whether to return full user name, or just first name. :return: The user's name. """ # noqa try: if full_name: ...
python
def get_user_name(user, full_name=True): """Return the user's name as a string. :param user: `models.User` object. The user to get the name of. :param full_name: (optional) Whether to return full user name, or just first name. :return: The user's name. """ # noqa try: if full_name: ...
[ "def", "get_user_name", "(", "user", ",", "full_name", "=", "True", ")", ":", "try", ":", "if", "full_name", ":", "name", "=", "' '", ".", "join", "(", "[", "user", ".", "first_name", ",", "user", ".", "last_name", "]", ")", "else", ":", "name", "=...
Return the user's name as a string. :param user: `models.User` object. The user to get the name of. :param full_name: (optional) Whether to return full user name, or just first name. :return: The user's name.
[ "Return", "the", "user", "s", "name", "as", "a", "string", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L121-L136
train
mesbahamin/chronophore
chronophore/controller.py
sign_in
def sign_in(user, user_type=None, date=None, time_in=None): """Add a new entry to the timesheet. :param user: `models.User` object. The user to sign in. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`. :param date: (optional) `datetime.date` object. Specify...
python
def sign_in(user, user_type=None, date=None, time_in=None): """Add a new entry to the timesheet. :param user: `models.User` object. The user to sign in. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`. :param date: (optional) `datetime.date` object. Specify...
[ "def", "sign_in", "(", "user", ",", "user_type", "=", "None", ",", "date", "=", "None", ",", "time_in", "=", "None", ")", ":", "now", "=", "datetime", ".", "today", "(", ")", "if", "date", "is", "None", ":", "date", "=", "now", ".", "date", "(", ...
Add a new entry to the timesheet. :param user: `models.User` object. The user to sign in. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`. :param date: (optional) `datetime.date` object. Specify the entry date. :param time_in: (optional) `datetime.time` obj...
[ "Add", "a", "new", "entry", "to", "the", "timesheet", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L139-L174
train
mesbahamin/chronophore
chronophore/controller.py
sign_out
def sign_out(entry, time_out=None, forgot=False): """Sign out of an existing entry in the timesheet. If the user forgot to sign out, flag the entry. :param entry: `models.Entry` object. The entry to sign out. :param time_out: (optional) `datetime.time` object. Specify the sign out time. :param forg...
python
def sign_out(entry, time_out=None, forgot=False): """Sign out of an existing entry in the timesheet. If the user forgot to sign out, flag the entry. :param entry: `models.Entry` object. The entry to sign out. :param time_out: (optional) `datetime.time` object. Specify the sign out time. :param forg...
[ "def", "sign_out", "(", "entry", ",", "time_out", "=", "None", ",", "forgot", "=", "False", ")", ":", "if", "time_out", "is", "None", ":", "time_out", "=", "datetime", ".", "today", "(", ")", ".", "time", "(", ")", "if", "forgot", ":", "entry", "."...
Sign out of an existing entry in the timesheet. If the user forgot to sign out, flag the entry. :param entry: `models.Entry` object. The entry to sign out. :param time_out: (optional) `datetime.time` object. Specify the sign out time. :param forgot: (optional) If true, user forgot to sign out. Entry wi...
[ "Sign", "out", "of", "an", "existing", "entry", "in", "the", "timesheet", ".", "If", "the", "user", "forgot", "to", "sign", "out", "flag", "the", "entry", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L177-L199
train
mesbahamin/chronophore
chronophore/controller.py
undo_sign_in
def undo_sign_in(entry, session=None): """Delete a signed in entry. :param entry: `models.Entry` object. The entry to delete. :param session: (optional) SQLAlchemy session through which to access the database. """ # noqa if session is None: session = Session() else: session = se...
python
def undo_sign_in(entry, session=None): """Delete a signed in entry. :param entry: `models.Entry` object. The entry to delete. :param session: (optional) SQLAlchemy session through which to access the database. """ # noqa if session is None: session = Session() else: session = se...
[ "def", "undo_sign_in", "(", "entry", ",", "session", "=", "None", ")", ":", "if", "session", "is", "None", ":", "session", "=", "Session", "(", ")", "else", ":", "session", "=", "session", "entry_to_delete", "=", "(", "session", ".", "query", "(", "Ent...
Delete a signed in entry. :param entry: `models.Entry` object. The entry to delete. :param session: (optional) SQLAlchemy session through which to access the database.
[ "Delete", "a", "signed", "in", "entry", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L202-L228
train
mesbahamin/chronophore
chronophore/controller.py
undo_sign_out
def undo_sign_out(entry, session=None): """Sign in a signed out entry. :param entry: `models.Entry` object. The entry to sign back in. :param session: (optional) SQLAlchemy session through which to access the database. """ # noqa if session is None: session = Session() else: ses...
python
def undo_sign_out(entry, session=None): """Sign in a signed out entry. :param entry: `models.Entry` object. The entry to sign back in. :param session: (optional) SQLAlchemy session through which to access the database. """ # noqa if session is None: session = Session() else: ses...
[ "def", "undo_sign_out", "(", "entry", ",", "session", "=", "None", ")", ":", "if", "session", "is", "None", ":", "session", "=", "Session", "(", ")", "else", ":", "session", "=", "session", "entry_to_sign_in", "=", "(", "session", ".", "query", "(", "E...
Sign in a signed out entry. :param entry: `models.Entry` object. The entry to sign back in. :param session: (optional) SQLAlchemy session through which to access the database.
[ "Sign", "in", "a", "signed", "out", "entry", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L231-L258
train
mesbahamin/chronophore
chronophore/controller.py
sign
def sign(user_id, user_type=None, today=None, session=None): """Check user id for validity, then sign user in if they are signed out, or out if they are signed in. :param user_id: The ID of the user to sign in or out. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `...
python
def sign(user_id, user_type=None, today=None, session=None): """Check user id for validity, then sign user in if they are signed out, or out if they are signed in. :param user_id: The ID of the user to sign in or out. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `...
[ "def", "sign", "(", "user_id", ",", "user_type", "=", "None", ",", "today", "=", "None", ",", "session", "=", "None", ")", ":", "if", "session", "is", "None", ":", "session", "=", "Session", "(", ")", "else", ":", "session", "=", "session", "if", "...
Check user id for validity, then sign user in if they are signed out, or out if they are signed in. :param user_id: The ID of the user to sign in or out. :param user_type: (optional) Specify whether user is signing in as a `'student'` or `'tutor'`. :param today: (optional) The current date as a `dateti...
[ "Check", "user", "id", "for", "validity", "then", "sign", "user", "in", "if", "they", "are", "signed", "out", "or", "out", "if", "they", "are", "signed", "in", "." ]
ee140c61b4dfada966f078de8304bac737cec6f7
https://github.com/mesbahamin/chronophore/blob/ee140c61b4dfada966f078de8304bac737cec6f7/chronophore/controller.py#L261-L330
train
reorx/torext
torext/gevent_wsgi.py
FormattedWSGIHandler.format_request
def format_request(self): """Override for better log format Tornado format: [INFO 2015-03-24 11:29:57 app:521] 200 GET /static/css/lib/pure-min.css (127.0.0.1) 6.76ms Current format: [gevent.wsgi] INFO 127.0.0.1 - - [2015-03-24 11:18:45] "GET /test HTTP/1.1" 200 304 0.000793 ...
python
def format_request(self): """Override for better log format Tornado format: [INFO 2015-03-24 11:29:57 app:521] 200 GET /static/css/lib/pure-min.css (127.0.0.1) 6.76ms Current format: [gevent.wsgi] INFO 127.0.0.1 - - [2015-03-24 11:18:45] "GET /test HTTP/1.1" 200 304 0.000793 ...
[ "def", "format_request", "(", "self", ")", ":", "fmt", "=", "'{now} {status} {requestline} ({client_address}) {response_length} {delta}ms'", "requestline", "=", "getattr", "(", "self", ",", "'requestline'", ")", "if", "requestline", ":", "requestline", "=", "' '", ".", ...
Override for better log format Tornado format: [INFO 2015-03-24 11:29:57 app:521] 200 GET /static/css/lib/pure-min.css (127.0.0.1) 6.76ms Current format: [gevent.wsgi] INFO 127.0.0.1 - - [2015-03-24 11:18:45] "GET /test HTTP/1.1" 200 304 0.000793
[ "Override", "for", "better", "log", "format" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/gevent_wsgi.py#L21-L52
train
reorx/torext
torext/gevent_wsgi.py
FormattedWSGIHandler.handle_error
def handle_error(self, type_, value, tb): """This method copies the code from pywsgi.WSGIHandler.handle_error, change the write part to be a reflection of traceback and environ """ if not issubclass(type_, pywsgi.GreenletExit): self.server.loop.handle_error(self.environ, type...
python
def handle_error(self, type_, value, tb): """This method copies the code from pywsgi.WSGIHandler.handle_error, change the write part to be a reflection of traceback and environ """ if not issubclass(type_, pywsgi.GreenletExit): self.server.loop.handle_error(self.environ, type...
[ "def", "handle_error", "(", "self", ",", "type_", ",", "value", ",", "tb", ")", ":", "if", "not", "issubclass", "(", "type_", ",", "pywsgi", ".", "GreenletExit", ")", ":", "self", ".", "server", ".", "loop", ".", "handle_error", "(", "self", ".", "en...
This method copies the code from pywsgi.WSGIHandler.handle_error, change the write part to be a reflection of traceback and environ
[ "This", "method", "copies", "the", "code", "from", "pywsgi", ".", "WSGIHandler", ".", "handle_error", "change", "the", "write", "part", "to", "be", "a", "reflection", "of", "traceback", "and", "environ" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/gevent_wsgi.py#L82-L100
train
geophysics-ubonn/crtomo_tools
lib/crtomo/configManager.py
ConfigManager.clear_measurements
def clear_measurements(self): """Remove all measurements from self.measurements. Reset the measurement counter. All ID are invalidated. """ keys = list(self.measurements.keys()) for key in keys: del(self.measurements[key]) self.meas_counter = -1
python
def clear_measurements(self): """Remove all measurements from self.measurements. Reset the measurement counter. All ID are invalidated. """ keys = list(self.measurements.keys()) for key in keys: del(self.measurements[key]) self.meas_counter = -1
[ "def", "clear_measurements", "(", "self", ")", ":", "keys", "=", "list", "(", "self", ".", "measurements", ".", "keys", "(", ")", ")", "for", "key", "in", "keys", ":", "del", "(", "self", ".", "measurements", "[", "key", "]", ")", "self", ".", "mea...
Remove all measurements from self.measurements. Reset the measurement counter. All ID are invalidated.
[ "Remove", "all", "measurements", "from", "self", ".", "measurements", ".", "Reset", "the", "measurement", "counter", ".", "All", "ID", "are", "invalidated", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L56-L63
train
geophysics-ubonn/crtomo_tools
lib/crtomo/configManager.py
ConfigManager.add_measurements
def add_measurements(self, measurements): """Add new measurements to this instance Parameters ---------- measurements: numpy.ndarray one or more measurement sets. It must either be 1D or 2D, with the first dimension the number of measurement sets (K), and the sec...
python
def add_measurements(self, measurements): """Add new measurements to this instance Parameters ---------- measurements: numpy.ndarray one or more measurement sets. It must either be 1D or 2D, with the first dimension the number of measurement sets (K), and the sec...
[ "def", "add_measurements", "(", "self", ",", "measurements", ")", ":", "subdata", "=", "np", ".", "atleast_2d", "(", "measurements", ")", "if", "self", ".", "configs", "is", "None", ":", "raise", "Exception", "(", "'must read in configuration before measurements c...
Add new measurements to this instance Parameters ---------- measurements: numpy.ndarray one or more measurement sets. It must either be 1D or 2D, with the first dimension the number of measurement sets (K), and the second the number of measurements (N): K x N...
[ "Add", "new", "measurements", "to", "this", "instance" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L120-L173
train
geophysics-ubonn/crtomo_tools
lib/crtomo/configManager.py
ConfigManager.gen_all_voltages_for_injections
def gen_all_voltages_for_injections(self, injections_raw): """For a given set of current injections AB, generate all possible unique potential measurements. After Noel and Xu, 1991, for N electrodes, the number of possible voltage dipoles for a given current dipole is :math:`(N - 2)(N -...
python
def gen_all_voltages_for_injections(self, injections_raw): """For a given set of current injections AB, generate all possible unique potential measurements. After Noel and Xu, 1991, for N electrodes, the number of possible voltage dipoles for a given current dipole is :math:`(N - 2)(N -...
[ "def", "gen_all_voltages_for_injections", "(", "self", ",", "injections_raw", ")", ":", "injections", "=", "injections_raw", ".", "astype", "(", "int", ")", "N", "=", "self", ".", "nr_electrodes", "all_quadpoles", "=", "[", "]", "for", "idipole", "in", "inject...
For a given set of current injections AB, generate all possible unique potential measurements. After Noel and Xu, 1991, for N electrodes, the number of possible voltage dipoles for a given current dipole is :math:`(N - 2)(N - 3) / 2`. This includes normal and reciprocal measurements. ...
[ "For", "a", "given", "set", "of", "current", "injections", "AB", "generate", "all", "possible", "unique", "potential", "measurements", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L893-L954
train
geophysics-ubonn/crtomo_tools
lib/crtomo/configManager.py
ConfigManager.gen_wenner
def gen_wenner(self, a): """Generate Wenner measurement configurations. Parameters ---------- a: int distance (in electrodes) between subsequent electrodes of each four-point configuration. Returns ------- configs: Kx4 numpy.ndarray ...
python
def gen_wenner(self, a): """Generate Wenner measurement configurations. Parameters ---------- a: int distance (in electrodes) between subsequent electrodes of each four-point configuration. Returns ------- configs: Kx4 numpy.ndarray ...
[ "def", "gen_wenner", "(", "self", ",", "a", ")", ":", "configs", "=", "[", "]", "for", "i", "in", "range", "(", "1", ",", "self", ".", "nr_electrodes", "-", "3", "*", "a", "+", "1", ")", ":", "configs", ".", "append", "(", "(", "i", ",", "i",...
Generate Wenner measurement configurations. Parameters ---------- a: int distance (in electrodes) between subsequent electrodes of each four-point configuration. Returns ------- configs: Kx4 numpy.ndarray array holding the configurati...
[ "Generate", "Wenner", "measurement", "configurations", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1108-L1129
train
geophysics-ubonn/crtomo_tools
lib/crtomo/configManager.py
ConfigManager.gen_reciprocals
def gen_reciprocals(self, quadrupoles): """For a given set of quadrupoles, generate and return reciprocals """ reciprocals = quadrupoles[:, ::-1].copy() reciprocals[:, 0:2] = np.sort(reciprocals[:, 0:2], axis=1) reciprocals[:, 2:4] = np.sort(reciprocals[:, 2:4], axis=1) r...
python
def gen_reciprocals(self, quadrupoles): """For a given set of quadrupoles, generate and return reciprocals """ reciprocals = quadrupoles[:, ::-1].copy() reciprocals[:, 0:2] = np.sort(reciprocals[:, 0:2], axis=1) reciprocals[:, 2:4] = np.sort(reciprocals[:, 2:4], axis=1) r...
[ "def", "gen_reciprocals", "(", "self", ",", "quadrupoles", ")", ":", "reciprocals", "=", "quadrupoles", "[", ":", ",", ":", ":", "-", "1", "]", ".", "copy", "(", ")", "reciprocals", "[", ":", ",", "0", ":", "2", "]", "=", "np", ".", "sort", "(", ...
For a given set of quadrupoles, generate and return reciprocals
[ "For", "a", "given", "set", "of", "quadrupoles", "generate", "and", "return", "reciprocals" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1253-L1259
train
geophysics-ubonn/crtomo_tools
lib/crtomo/configManager.py
ConfigManager.compute_K_factors
def compute_K_factors(self, spacing=None, configs=None, numerical=False, elem_file=None, elec_file=None): """Compute analytical geometrical factors. TODO: use real electrode positions from self.grid """ if configs is None: use_configs = self.configs...
python
def compute_K_factors(self, spacing=None, configs=None, numerical=False, elem_file=None, elec_file=None): """Compute analytical geometrical factors. TODO: use real electrode positions from self.grid """ if configs is None: use_configs = self.configs...
[ "def", "compute_K_factors", "(", "self", ",", "spacing", "=", "None", ",", "configs", "=", "None", ",", "numerical", "=", "False", ",", "elem_file", "=", "None", ",", "elec_file", "=", "None", ")", ":", "if", "configs", "is", "None", ":", "use_configs", ...
Compute analytical geometrical factors. TODO: use real electrode positions from self.grid
[ "Compute", "analytical", "geometrical", "factors", "." ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/configManager.py#L1299-L1319
train
albert12132/templar
templar/api/rules/core.py
Rule.applies
def applies(self, src, dst): """Checks if this rule applies to the given src and dst paths, based on the src pattern and dst pattern given in the constructor. If src pattern was None, this rule will apply to any given src path (same for dst). """ if self._src_pattern and (src is...
python
def applies(self, src, dst): """Checks if this rule applies to the given src and dst paths, based on the src pattern and dst pattern given in the constructor. If src pattern was None, this rule will apply to any given src path (same for dst). """ if self._src_pattern and (src is...
[ "def", "applies", "(", "self", ",", "src", ",", "dst", ")", ":", "if", "self", ".", "_src_pattern", "and", "(", "src", "is", "None", "or", "re", ".", "search", "(", "self", ".", "_src_pattern", ",", "src", ")", "is", "None", ")", ":", "return", "...
Checks if this rule applies to the given src and dst paths, based on the src pattern and dst pattern given in the constructor. If src pattern was None, this rule will apply to any given src path (same for dst).
[ "Checks", "if", "this", "rule", "applies", "to", "the", "given", "src", "and", "dst", "paths", "based", "on", "the", "src", "pattern", "and", "dst", "pattern", "given", "in", "the", "constructor", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/rules/core.py#L33-L43
train
NJDFan/ctypes-bitfield
bitfield/walk.py
_createunbound
def _createunbound(kls, **info): """Create a new UnboundNode representing a given class.""" if issubclass(kls, Bitfield): nodetype = UnboundBitfieldNode elif hasattr(kls, '_fields_'): nodetype = UnboundStructureNode elif issubclass(kls, ctypes.Array): nodetype = UnboundArray...
python
def _createunbound(kls, **info): """Create a new UnboundNode representing a given class.""" if issubclass(kls, Bitfield): nodetype = UnboundBitfieldNode elif hasattr(kls, '_fields_'): nodetype = UnboundStructureNode elif issubclass(kls, ctypes.Array): nodetype = UnboundArray...
[ "def", "_createunbound", "(", "kls", ",", "**", "info", ")", ":", "if", "issubclass", "(", "kls", ",", "Bitfield", ")", ":", "nodetype", "=", "UnboundBitfieldNode", "elif", "hasattr", "(", "kls", ",", "'_fields_'", ")", ":", "nodetype", "=", "UnboundStruct...
Create a new UnboundNode representing a given class.
[ "Create", "a", "new", "UnboundNode", "representing", "a", "given", "class", "." ]
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L240-L251
train
NJDFan/ctypes-bitfield
bitfield/walk.py
_createbound
def _createbound(obj): """Create a new BoundNode representing a given object.""" # Start by allowing objects to define custom unbound reference hooks try: kls = obj._unboundreference_() except AttributeError: kls = type(obj) unbound = _createunbound(kls) def valueget(): ...
python
def _createbound(obj): """Create a new BoundNode representing a given object.""" # Start by allowing objects to define custom unbound reference hooks try: kls = obj._unboundreference_() except AttributeError: kls = type(obj) unbound = _createunbound(kls) def valueget(): ...
[ "def", "_createbound", "(", "obj", ")", ":", "try", ":", "kls", "=", "obj", ".", "_unboundreference_", "(", ")", "except", "AttributeError", ":", "kls", "=", "type", "(", "obj", ")", "unbound", "=", "_createunbound", "(", "kls", ")", "def", "valueget", ...
Create a new BoundNode representing a given object.
[ "Create", "a", "new", "BoundNode", "representing", "a", "given", "object", "." ]
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L361-L380
train
NJDFan/ctypes-bitfield
bitfield/walk.py
display
def display(obj, skiphidden=True, **printargs): """Print a view of obj, where obj is either a ctypes-derived class or an instance of such a class. Any additional keyword arguments are passed directly to the print function. This is mostly useful to introspect structures from an interactive session....
python
def display(obj, skiphidden=True, **printargs): """Print a view of obj, where obj is either a ctypes-derived class or an instance of such a class. Any additional keyword arguments are passed directly to the print function. This is mostly useful to introspect structures from an interactive session....
[ "def", "display", "(", "obj", ",", "skiphidden", "=", "True", ",", "**", "printargs", ")", ":", "top", "=", "findnode", "(", "obj", ")", "maxhex", "=", "len", "(", "hex", "(", "ctypes", ".", "sizeof", "(", "top", ".", "type", ")", ")", ")", "-", ...
Print a view of obj, where obj is either a ctypes-derived class or an instance of such a class. Any additional keyword arguments are passed directly to the print function. This is mostly useful to introspect structures from an interactive session.
[ "Print", "a", "view", "of", "obj", "where", "obj", "is", "either", "a", "ctypes", "-", "derived", "class", "or", "an", "instance", "of", "such", "a", "class", ".", "Any", "additional", "keyword", "arguments", "are", "passed", "directly", "to", "the", "pr...
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L507-L567
train
NJDFan/ctypes-bitfield
bitfield/walk.py
Node.pathparts
def pathparts(self): """A list of the parts of the path, with the root node returning an empty list. """ try: parts = self.parent.pathparts() parts.append(self.name) return parts except AttributeError: return []
python
def pathparts(self): """A list of the parts of the path, with the root node returning an empty list. """ try: parts = self.parent.pathparts() parts.append(self.name) return parts except AttributeError: return []
[ "def", "pathparts", "(", "self", ")", ":", "try", ":", "parts", "=", "self", ".", "parent", ".", "pathparts", "(", ")", "parts", ".", "append", "(", "self", ".", "name", ")", "return", "parts", "except", "AttributeError", ":", "return", "[", "]" ]
A list of the parts of the path, with the root node returning an empty list.
[ "A", "list", "of", "the", "parts", "of", "the", "path", "with", "the", "root", "node", "returning", "an", "empty", "list", "." ]
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L166-L175
train
NJDFan/ctypes-bitfield
bitfield/walk.py
Node.baseoffset
def baseoffset(self): """The offset of this node from the root node.""" try: return self.parent.baseoffset + self.offset except AttributeError: return self.offset
python
def baseoffset(self): """The offset of this node from the root node.""" try: return self.parent.baseoffset + self.offset except AttributeError: return self.offset
[ "def", "baseoffset", "(", "self", ")", ":", "try", ":", "return", "self", ".", "parent", ".", "baseoffset", "+", "self", ".", "offset", "except", "AttributeError", ":", "return", "self", ".", "offset" ]
The offset of this node from the root node.
[ "The", "offset", "of", "this", "node", "from", "the", "root", "node", "." ]
ae76b1dcfef7ecc90bd1900735b94ddee41a6376
https://github.com/NJDFan/ctypes-bitfield/blob/ae76b1dcfef7ecc90bd1900735b94ddee41a6376/bitfield/walk.py#L192-L197
train
geophysics-ubonn/crtomo_tools
src/grid_translate_model.py
_almost_equal
def _almost_equal(a, b): """Check if the two numbers are almost equal """ # arbitrary small number!!! threshold = 1e-9 diff = np.abs(a - b) return (diff < threshold)
python
def _almost_equal(a, b): """Check if the two numbers are almost equal """ # arbitrary small number!!! threshold = 1e-9 diff = np.abs(a - b) return (diff < threshold)
[ "def", "_almost_equal", "(", "a", ",", "b", ")", ":", "threshold", "=", "1e-9", "diff", "=", "np", ".", "abs", "(", "a", "-", "b", ")", "return", "(", "diff", "<", "threshold", ")" ]
Check if the two numbers are almost equal
[ "Check", "if", "the", "two", "numbers", "are", "almost", "equal" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_translate_model.py#L62-L68
train
pgxcentre/geneparse
geneparse/core.py
Variant.complement_alleles
def complement_alleles(self): """Complement the alleles of this variant. This will call this module's `complement_alleles` function. Note that this will not create a new object, but modify the state of the current instance. """ self.alleles = self._encode_alleles( ...
python
def complement_alleles(self): """Complement the alleles of this variant. This will call this module's `complement_alleles` function. Note that this will not create a new object, but modify the state of the current instance. """ self.alleles = self._encode_alleles( ...
[ "def", "complement_alleles", "(", "self", ")", ":", "self", ".", "alleles", "=", "self", ".", "_encode_alleles", "(", "[", "complement_alleles", "(", "i", ")", "for", "i", "in", "self", ".", "alleles", "]", ")" ]
Complement the alleles of this variant. This will call this module's `complement_alleles` function. Note that this will not create a new object, but modify the state of the current instance.
[ "Complement", "the", "alleles", "of", "this", "variant", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L139-L150
train
pgxcentre/geneparse
geneparse/core.py
Genotypes.flip_coded
def flip_coded(self): """Flips the coding of the alleles.""" self.genotypes = 2 - self.genotypes self.reference, self.coded = self.coded, self.reference
python
def flip_coded(self): """Flips the coding of the alleles.""" self.genotypes = 2 - self.genotypes self.reference, self.coded = self.coded, self.reference
[ "def", "flip_coded", "(", "self", ")", ":", "self", ".", "genotypes", "=", "2", "-", "self", ".", "genotypes", "self", ".", "reference", ",", "self", ".", "coded", "=", "self", ".", "coded", ",", "self", ".", "reference" ]
Flips the coding of the alleles.
[ "Flips", "the", "coding", "of", "the", "alleles", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L229-L232
train
pgxcentre/geneparse
geneparse/core.py
Genotypes.flip_strand
def flip_strand(self): """Flips the strand of the alleles.""" self.reference = complement_alleles(self.reference) self.coded = complement_alleles(self.coded) self.variant.complement_alleles()
python
def flip_strand(self): """Flips the strand of the alleles.""" self.reference = complement_alleles(self.reference) self.coded = complement_alleles(self.coded) self.variant.complement_alleles()
[ "def", "flip_strand", "(", "self", ")", ":", "self", ".", "reference", "=", "complement_alleles", "(", "self", ".", "reference", ")", "self", ".", "coded", "=", "complement_alleles", "(", "self", ".", "coded", ")", "self", ".", "variant", ".", "complement_...
Flips the strand of the alleles.
[ "Flips", "the", "strand", "of", "the", "alleles", "." ]
f698f9708af4c7962d384a70a5a14006b1cb7108
https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/core.py#L234-L238
train
aglie/meerkat
meerkat/det2lab_xds.py
rotvec2mat
def rotvec2mat(u, phi): """Convert rotation from axis and angle to matrix representation""" phi = np.squeeze(phi) norm_u = np.linalg.norm(u) if norm_u < 1e-12: raise Exception("the rotation vector is equal to zero") u = u / norm_u # http://en.wikipedia.org/wiki/Rotation_matrix s =...
python
def rotvec2mat(u, phi): """Convert rotation from axis and angle to matrix representation""" phi = np.squeeze(phi) norm_u = np.linalg.norm(u) if norm_u < 1e-12: raise Exception("the rotation vector is equal to zero") u = u / norm_u # http://en.wikipedia.org/wiki/Rotation_matrix s =...
[ "def", "rotvec2mat", "(", "u", ",", "phi", ")", ":", "phi", "=", "np", ".", "squeeze", "(", "phi", ")", "norm_u", "=", "np", ".", "linalg", ".", "norm", "(", "u", ")", "if", "norm_u", "<", "1e-12", ":", "raise", "Exception", "(", "\"the rotation ve...
Convert rotation from axis and angle to matrix representation
[ "Convert", "rotation", "from", "axis", "and", "angle", "to", "matrix", "representation" ]
f056a3da7ed3d7cd43edb56a38903cfa146e4b24
https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/det2lab_xds.py#L4-L26
train
aglie/meerkat
meerkat/det2lab_xds.py
det2lab_xds
def det2lab_xds( pixels_coord, frame_number, starting_frame, starting_angle, oscillation_angle, rotation_axis, wavelength, wavevector, NX, NY, pixelsize_x, pixelsize_y, distance_to_detector, x_center, y_center, detector_x, detector_y, detector_normal, **kwargs): ...
python
def det2lab_xds( pixels_coord, frame_number, starting_frame, starting_angle, oscillation_angle, rotation_axis, wavelength, wavevector, NX, NY, pixelsize_x, pixelsize_y, distance_to_detector, x_center, y_center, detector_x, detector_y, detector_normal, **kwargs): ...
[ "def", "det2lab_xds", "(", "pixels_coord", ",", "frame_number", ",", "starting_frame", ",", "starting_angle", ",", "oscillation_angle", ",", "rotation_axis", ",", "wavelength", ",", "wavevector", ",", "NX", ",", "NY", ",", "pixelsize_x", ",", "pixelsize_y", ",", ...
Converts pixels coordinates from the frame into q-vector
[ "Converts", "pixels", "coordinates", "from", "the", "frame", "into", "q", "-", "vector" ]
f056a3da7ed3d7cd43edb56a38903cfa146e4b24
https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/det2lab_xds.py#L29-L75
train
KnightConan/sspdatatables
src/sspdatatables/datatables.py
DataTables.get_query_dict
def get_query_dict(self, **kwargs): """ function to generate a filter dictionary, in which the key is the keyword used in django filter function in string form, and the value is the searched value. :param kwargs:dict: query dict sent by data tables package :return: dict:...
python
def get_query_dict(self, **kwargs): """ function to generate a filter dictionary, in which the key is the keyword used in django filter function in string form, and the value is the searched value. :param kwargs:dict: query dict sent by data tables package :return: dict:...
[ "def", "get_query_dict", "(", "self", ",", "**", "kwargs", ")", ":", "total_cols", "=", "ensure", "(", "int", ",", "kwargs", ".", "get", "(", "'total_cols'", ",", "[", "0", "]", ")", "[", "0", "]", ",", "0", ")", "mapping", "=", "self", ".", "map...
function to generate a filter dictionary, in which the key is the keyword used in django filter function in string form, and the value is the searched value. :param kwargs:dict: query dict sent by data tables package :return: dict: filtering dictionary
[ "function", "to", "generate", "a", "filter", "dictionary", "in", "which", "the", "key", "is", "the", "keyword", "used", "in", "django", "filter", "function", "in", "string", "form", "and", "the", "value", "is", "the", "searched", "value", "." ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L199-L230
train
KnightConan/sspdatatables
src/sspdatatables/datatables.py
DataTables.get_order_key
def get_order_key(self, **kwargs): """ function to get the order key to apply it in the filtered queryset :param kwargs: dict: query dict sent by data tables package :return: str: order key, which can be used directly in queryset's order_by function """ # get t...
python
def get_order_key(self, **kwargs): """ function to get the order key to apply it in the filtered queryset :param kwargs: dict: query dict sent by data tables package :return: str: order key, which can be used directly in queryset's order_by function """ # get t...
[ "def", "get_order_key", "(", "self", ",", "**", "kwargs", ")", ":", "mapping", "=", "self", ".", "mapping", "order_column", "=", "kwargs", ".", "get", "(", "'order[0][column]'", ",", "[", "mapping", ".", "keys", "(", ")", "[", "0", "]", "]", ")", "["...
function to get the order key to apply it in the filtered queryset :param kwargs: dict: query dict sent by data tables package :return: str: order key, which can be used directly in queryset's order_by function
[ "function", "to", "get", "the", "order", "key", "to", "apply", "it", "in", "the", "filtered", "queryset" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L232-L252
train
KnightConan/sspdatatables
src/sspdatatables/datatables.py
DataTables.filtering
def filtering(queryset, query_dict): """ function to apply the pre search condition to the queryset to narrow down the queryset's size :param queryset: Django Queryset: queryset of all objects :param query_dict: dict: contains selected_related, filter and other customi...
python
def filtering(queryset, query_dict): """ function to apply the pre search condition to the queryset to narrow down the queryset's size :param queryset: Django Queryset: queryset of all objects :param query_dict: dict: contains selected_related, filter and other customi...
[ "def", "filtering", "(", "queryset", ",", "query_dict", ")", ":", "for", "key", ",", "value", "in", "query_dict", ".", "items", "(", ")", ":", "assert", "hasattr", "(", "queryset", ",", "key", ")", ",", "\"Parameter 'query_dict' contains\"", "\" non-existent a...
function to apply the pre search condition to the queryset to narrow down the queryset's size :param queryset: Django Queryset: queryset of all objects :param query_dict: dict: contains selected_related, filter and other customized filter functions :return: queryset: result af...
[ "function", "to", "apply", "the", "pre", "search", "condition", "to", "the", "queryset", "to", "narrow", "down", "the", "queryset", "s", "size" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L255-L275
train
KnightConan/sspdatatables
src/sspdatatables/datatables.py
DataTables.slicing
def slicing(queryset, **kwargs): """ function to slice the queryset according to the display length :param queryset: Django Queryset: filtered and ordered queryset result :param kwargs: dict: query dict sent by data tables package :return: queryset: result after slicing ...
python
def slicing(queryset, **kwargs): """ function to slice the queryset according to the display length :param queryset: Django Queryset: filtered and ordered queryset result :param kwargs: dict: query dict sent by data tables package :return: queryset: result after slicing ...
[ "def", "slicing", "(", "queryset", ",", "**", "kwargs", ")", ":", "length", "=", "ensure", "(", "int", ",", "kwargs", ".", "get", "(", "'length'", ",", "[", "0", "]", ")", "[", "0", "]", ",", "0", ")", "start", "=", "ensure", "(", "int", ",", ...
function to slice the queryset according to the display length :param queryset: Django Queryset: filtered and ordered queryset result :param kwargs: dict: query dict sent by data tables package :return: queryset: result after slicing
[ "function", "to", "slice", "the", "queryset", "according", "to", "the", "display", "length" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L278-L292
train
KnightConan/sspdatatables
src/sspdatatables/datatables.py
DataTables.query_by_args
def query_by_args(self, pre_search_condition=None, **kwargs): """ intends to process the queries sent by data tables package in frontend. The model_cls indicates the model class, get_query_dict is a function implemented by you, such that it can return a query dictionary, in which...
python
def query_by_args(self, pre_search_condition=None, **kwargs): """ intends to process the queries sent by data tables package in frontend. The model_cls indicates the model class, get_query_dict is a function implemented by you, such that it can return a query dictionary, in which...
[ "def", "query_by_args", "(", "self", ",", "pre_search_condition", "=", "None", ",", "**", "kwargs", ")", ":", "if", "pre_search_condition", "and", "not", "isinstance", "(", "pre_search_condition", ",", "OrderedDict", ")", ":", "raise", "TypeError", "(", "\"Param...
intends to process the queries sent by data tables package in frontend. The model_cls indicates the model class, get_query_dict is a function implemented by you, such that it can return a query dictionary, in which the key is the query keyword in str form and the value is the queried val...
[ "intends", "to", "process", "the", "queries", "sent", "by", "data", "tables", "package", "in", "frontend", ".", "The", "model_cls", "indicates", "the", "model", "class", "get_query_dict", "is", "a", "function", "implemented", "by", "you", "such", "that", "it",...
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L294-L345
train
KnightConan/sspdatatables
src/sspdatatables/datatables.py
DataTables.process
def process(self, pre_search_condition=None, **kwargs): """ function to be called outside to get the footer search condition, apply the search in DB and render the serialized result. :param pre_search_condition: None/OrderedDict: pre search condition to be applied before apply...
python
def process(self, pre_search_condition=None, **kwargs): """ function to be called outside to get the footer search condition, apply the search in DB and render the serialized result. :param pre_search_condition: None/OrderedDict: pre search condition to be applied before apply...
[ "def", "process", "(", "self", ",", "pre_search_condition", "=", "None", ",", "**", "kwargs", ")", ":", "records", "=", "self", ".", "query_by_args", "(", "pre_search_condition", "=", "pre_search_condition", ",", "**", "kwargs", ")", "serializer", "=", "self",...
function to be called outside to get the footer search condition, apply the search in DB and render the serialized result. :param pre_search_condition: None/OrderedDict: pre search condition to be applied before applying the one getting from footer :param kwargs: dict: search paramete...
[ "function", "to", "be", "called", "outside", "to", "get", "the", "footer", "search", "condition", "apply", "the", "search", "in", "DB", "and", "render", "the", "serialized", "result", "." ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/datatables.py#L347-L367
train
reorx/torext
torext/sql.py
MutationDict.coerce
def coerce(cls, key, value): """Convert plain dictionary to MutationDict""" self = MutationDict((k,MutationObj.coerce(key, v)) for (k, v) in value.items()) self._key = key return self
python
def coerce(cls, key, value): """Convert plain dictionary to MutationDict""" self = MutationDict((k,MutationObj.coerce(key, v)) for (k, v) in value.items()) self._key = key return self
[ "def", "coerce", "(", "cls", ",", "key", ",", "value", ")", ":", "self", "=", "MutationDict", "(", "(", "k", ",", "MutationObj", ".", "coerce", "(", "key", ",", "v", ")", ")", "for", "(", "k", ",", "v", ")", "in", "value", ".", "items", "(", ...
Convert plain dictionary to MutationDict
[ "Convert", "plain", "dictionary", "to", "MutationDict" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/sql.py#L361-L365
train
reorx/torext
torext/sql.py
MutationList.coerce
def coerce(cls, key, value): """Convert plain list to MutationList""" self = MutationList((MutationObj.coerce(key, v) for v in value)) self._key = key return self
python
def coerce(cls, key, value): """Convert plain list to MutationList""" self = MutationList((MutationObj.coerce(key, v) for v in value)) self._key = key return self
[ "def", "coerce", "(", "cls", ",", "key", ",", "value", ")", ":", "self", "=", "MutationList", "(", "(", "MutationObj", ".", "coerce", "(", "key", ",", "v", ")", "for", "v", "in", "value", ")", ")", "self", ".", "_key", "=", "key", "return", "self...
Convert plain list to MutationList
[ "Convert", "plain", "list", "to", "MutationList" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/sql.py#L378-L382
train
althonos/moclo
moclo/moclo/core/vectors.py
AbstractVector.structure
def structure(cls): # type: () -> Text """Get the vector structure, as a DNA regex pattern. Warning: If overloading this method, the returned pattern must include 3 capture groups to capture the following features: 1. The downstream (3') overhang sequence ...
python
def structure(cls): # type: () -> Text """Get the vector structure, as a DNA regex pattern. Warning: If overloading this method, the returned pattern must include 3 capture groups to capture the following features: 1. The downstream (3') overhang sequence ...
[ "def", "structure", "(", "cls", ")", ":", "downstream", "=", "cls", ".", "cutter", ".", "elucidate", "(", ")", "upstream", "=", "str", "(", "Seq", "(", "downstream", ")", ".", "reverse_complement", "(", ")", ")", "return", "\"\"", ".", "join", "(", "...
Get the vector structure, as a DNA regex pattern. Warning: If overloading this method, the returned pattern must include 3 capture groups to capture the following features: 1. The downstream (3') overhang sequence 2. The vector placeholder sequence 3...
[ "Get", "the", "vector", "structure", "as", "a", "DNA", "regex", "pattern", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L39-L60
train
althonos/moclo
moclo/moclo/core/vectors.py
AbstractVector.placeholder_sequence
def placeholder_sequence(self): # type: () -> SeqRecord """Get the placeholder sequence in the vector. The placeholder sequence is replaced by the concatenation of modules during the assembly. It often contains a dropout sequence, such as a GFP expression cassette that can be us...
python
def placeholder_sequence(self): # type: () -> SeqRecord """Get the placeholder sequence in the vector. The placeholder sequence is replaced by the concatenation of modules during the assembly. It often contains a dropout sequence, such as a GFP expression cassette that can be us...
[ "def", "placeholder_sequence", "(", "self", ")", ":", "if", "self", ".", "cutter", ".", "is_3overhang", "(", ")", ":", "return", "self", ".", "_match", ".", "group", "(", "2", ")", "+", "self", ".", "overhang_end", "(", ")", "else", ":", "return", "s...
Get the placeholder sequence in the vector. The placeholder sequence is replaced by the concatenation of modules during the assembly. It often contains a dropout sequence, such as a GFP expression cassette that can be used to measure the progress of the assembly.
[ "Get", "the", "placeholder", "sequence", "in", "the", "vector", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L74-L86
train
althonos/moclo
moclo/moclo/core/vectors.py
AbstractVector.target_sequence
def target_sequence(self): # type: () -> SeqRecord """Get the target sequence in the vector. The target sequence if the part of the plasmid that is not discarded during the assembly (everything except the placeholder sequence). """ if self.cutter.is_3overhang(): ...
python
def target_sequence(self): # type: () -> SeqRecord """Get the target sequence in the vector. The target sequence if the part of the plasmid that is not discarded during the assembly (everything except the placeholder sequence). """ if self.cutter.is_3overhang(): ...
[ "def", "target_sequence", "(", "self", ")", ":", "if", "self", ".", "cutter", ".", "is_3overhang", "(", ")", ":", "start", ",", "end", "=", "self", ".", "_match", ".", "span", "(", "2", ")", "[", "0", "]", ",", "self", ".", "_match", ".", "span",...
Get the target sequence in the vector. The target sequence if the part of the plasmid that is not discarded during the assembly (everything except the placeholder sequence).
[ "Get", "the", "target", "sequence", "in", "the", "vector", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L88-L99
train
althonos/moclo
moclo/moclo/core/vectors.py
AbstractVector.assemble
def assemble(self, module, *modules, **kwargs): # type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord """Assemble the provided modules into the vector. Arguments: module (`~moclo.base.modules.AbstractModule`): a module to insert in the vector. mod...
python
def assemble(self, module, *modules, **kwargs): # type: (AbstractModule, *AbstractModule, **Any) -> SeqRecord """Assemble the provided modules into the vector. Arguments: module (`~moclo.base.modules.AbstractModule`): a module to insert in the vector. mod...
[ "def", "assemble", "(", "self", ",", "module", ",", "*", "modules", ",", "**", "kwargs", ")", ":", "mgr", "=", "AssemblyManager", "(", "vector", "=", "self", ",", "modules", "=", "[", "module", "]", "+", "list", "(", "modules", ")", ",", "name", "=...
Assemble the provided modules into the vector. Arguments: module (`~moclo.base.modules.AbstractModule`): a module to insert in the vector. modules (`~moclo.base.modules.AbstractModule`, optional): additional modules to insert in the vector. The order of t...
[ "Assemble", "the", "provided", "modules", "into", "the", "vector", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/vectors.py#L108-L145
train
eventifyio/eventify
eventify/drivers/base.py
BaseComponent.onConnect
async def onConnect(self): """ Configure the component """ # Add extra attribute # This allows for following crossbar/autobahn spec # without changing legacy configuration if not hasattr(self.config, 'extra'): original_config = {'config': self.config} ...
python
async def onConnect(self): """ Configure the component """ # Add extra attribute # This allows for following crossbar/autobahn spec # without changing legacy configuration if not hasattr(self.config, 'extra'): original_config = {'config': self.config} ...
[ "async", "def", "onConnect", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ".", "config", ",", "'extra'", ")", ":", "original_config", "=", "{", "'config'", ":", "self", ".", "config", "}", "self", ".", "config", "=", "objdict", "(", "s...
Configure the component
[ "Configure", "the", "component" ]
0e519964a56bd07a879b266f21f177749c63aaed
https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/drivers/base.py#L20-L66
train
peterbe/gg
gg/builtins/getback/gg_getback.py
getback
def getback(config, force=False): """Goes back to the master branch, deletes the current branch locally and remotely.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") if repo.is_dirty(): ...
python
def getback(config, force=False): """Goes back to the master branch, deletes the current branch locally and remotely.""" repo = config.repo active_branch = repo.active_branch if active_branch.name == "master": error_out("You're already on the master branch.") if repo.is_dirty(): ...
[ "def", "getback", "(", "config", ",", "force", "=", "False", ")", ":", "repo", "=", "config", ".", "repo", "active_branch", "=", "repo", ".", "active_branch", "if", "active_branch", ".", "name", "==", "\"master\"", ":", "error_out", "(", "\"You're already on...
Goes back to the master branch, deletes the current branch locally and remotely.
[ "Goes", "back", "to", "the", "master", "branch", "deletes", "the", "current", "branch", "locally", "and", "remotely", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/getback/gg_getback.py#L11-L79
train
nhfruchter/pgh-bustime
pghbustime/datatypes.py
Bus.get
def get(_class, api, vid): """ Return a Bus object for a certain vehicle ID `vid` using API instance `api`. """ busses = api.vehicles(vid=vid)['vehicle'] return _class.fromapi(api, api.vehicles(vid=vid)['vehicle'])
python
def get(_class, api, vid): """ Return a Bus object for a certain vehicle ID `vid` using API instance `api`. """ busses = api.vehicles(vid=vid)['vehicle'] return _class.fromapi(api, api.vehicles(vid=vid)['vehicle'])
[ "def", "get", "(", "_class", ",", "api", ",", "vid", ")", ":", "busses", "=", "api", ".", "vehicles", "(", "vid", "=", "vid", ")", "[", "'vehicle'", "]", "return", "_class", ".", "fromapi", "(", "api", ",", "api", ".", "vehicles", "(", "vid", "="...
Return a Bus object for a certain vehicle ID `vid` using API instance `api`.
[ "Return", "a", "Bus", "object", "for", "a", "certain", "vehicle", "ID", "vid", "using", "API", "instance", "api", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L13-L19
train
nhfruchter/pgh-bustime
pghbustime/datatypes.py
Bus.fromapi
def fromapi(_class, api, apiresponse): """ Return a Bus object from an API response dict. """ bus = apiresponse return _class( api = api, vid = bus['vid'], timeupdated = datetime.strptime(bus['tmstmp'], api.STRPTIME), lat = float(bu...
python
def fromapi(_class, api, apiresponse): """ Return a Bus object from an API response dict. """ bus = apiresponse return _class( api = api, vid = bus['vid'], timeupdated = datetime.strptime(bus['tmstmp'], api.STRPTIME), lat = float(bu...
[ "def", "fromapi", "(", "_class", ",", "api", ",", "apiresponse", ")", ":", "bus", "=", "apiresponse", "return", "_class", "(", "api", "=", "api", ",", "vid", "=", "bus", "[", "'vid'", "]", ",", "timeupdated", "=", "datetime", ".", "strptime", "(", "b...
Return a Bus object from an API response dict.
[ "Return", "a", "Bus", "object", "from", "an", "API", "response", "dict", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L22-L40
train
nhfruchter/pgh-bustime
pghbustime/datatypes.py
Bus.update
def update(self): """Update this bus by creating a new one and transplanting dictionaries.""" vehicle = self.api.vehicles(vid=self.vid)['vehicle'] newbus = self.fromapi(self.api, vehicle) self.__dict__ = newbus.__dict__ del newbus
python
def update(self): """Update this bus by creating a new one and transplanting dictionaries.""" vehicle = self.api.vehicles(vid=self.vid)['vehicle'] newbus = self.fromapi(self.api, vehicle) self.__dict__ = newbus.__dict__ del newbus
[ "def", "update", "(", "self", ")", ":", "vehicle", "=", "self", ".", "api", ".", "vehicles", "(", "vid", "=", "self", ".", "vid", ")", "[", "'vehicle'", "]", "newbus", "=", "self", ".", "fromapi", "(", "self", ".", "api", ",", "vehicle", ")", "se...
Update this bus by creating a new one and transplanting dictionaries.
[ "Update", "this", "bus", "by", "creating", "a", "new", "one", "and", "transplanting", "dictionaries", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L61-L66
train
nhfruchter/pgh-bustime
pghbustime/datatypes.py
Bus.predictions
def predictions(self): """Generator that yields prediction objects from an API response.""" for prediction in self.api.predictions(vid=self.vid)['prd']: pobj = Prediction.fromapi(self.api, prediction) pobj._busobj = self yield pobj
python
def predictions(self): """Generator that yields prediction objects from an API response.""" for prediction in self.api.predictions(vid=self.vid)['prd']: pobj = Prediction.fromapi(self.api, prediction) pobj._busobj = self yield pobj
[ "def", "predictions", "(", "self", ")", ":", "for", "prediction", "in", "self", ".", "api", ".", "predictions", "(", "vid", "=", "self", ".", "vid", ")", "[", "'prd'", "]", ":", "pobj", "=", "Prediction", ".", "fromapi", "(", "self", ".", "api", ",...
Generator that yields prediction objects from an API response.
[ "Generator", "that", "yields", "prediction", "objects", "from", "an", "API", "response", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L73-L78
train
nhfruchter/pgh-bustime
pghbustime/datatypes.py
Bus.next_stop
def next_stop(self): """Return the next stop for this bus.""" p = self.api.predictions(vid=self.vid)['prd'] pobj = Prediction.fromapi(self.api, p[0]) pobj._busobj = self return pobj
python
def next_stop(self): """Return the next stop for this bus.""" p = self.api.predictions(vid=self.vid)['prd'] pobj = Prediction.fromapi(self.api, p[0]) pobj._busobj = self return pobj
[ "def", "next_stop", "(", "self", ")", ":", "p", "=", "self", ".", "api", ".", "predictions", "(", "vid", "=", "self", ".", "vid", ")", "[", "'prd'", "]", "pobj", "=", "Prediction", ".", "fromapi", "(", "self", ".", "api", ",", "p", "[", "0", "]...
Return the next stop for this bus.
[ "Return", "the", "next", "stop", "for", "this", "bus", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L81-L86
train
nhfruchter/pgh-bustime
pghbustime/datatypes.py
Route.get
def get(_class, api, rt): """ Return a Route object for route `rt` using API instance `api`. """ if not _class.all_routes: _class.all_routes = _class.update_list(api, api.routes()['route']) return _class.all_routes[str(rt)]
python
def get(_class, api, rt): """ Return a Route object for route `rt` using API instance `api`. """ if not _class.all_routes: _class.all_routes = _class.update_list(api, api.routes()['route']) return _class.all_routes[str(rt)]
[ "def", "get", "(", "_class", ",", "api", ",", "rt", ")", ":", "if", "not", "_class", ".", "all_routes", ":", "_class", ".", "all_routes", "=", "_class", ".", "update_list", "(", "api", ",", "api", ".", "routes", "(", ")", "[", "'route'", "]", ")", ...
Return a Route object for route `rt` using API instance `api`.
[ "Return", "a", "Route", "object", "for", "route", "rt", "using", "API", "instance", "api", "." ]
b915e8fea28541612f0e79783c2cf12fd3daaac0
https://github.com/nhfruchter/pgh-bustime/blob/b915e8fea28541612f0e79783c2cf12fd3daaac0/pghbustime/datatypes.py#L114-L122
train
gebn/wood
wood/__init__.py
_normalise_path
def _normalise_path(path: Union[str, pathlib.Path]) -> pathlib.Path: """ Ensures a path is parsed. :param path: A path string or Path object. :return: The path as a Path object. """ if isinstance(path, str): return pathlib.Path(path) return path
python
def _normalise_path(path: Union[str, pathlib.Path]) -> pathlib.Path: """ Ensures a path is parsed. :param path: A path string or Path object. :return: The path as a Path object. """ if isinstance(path, str): return pathlib.Path(path) return path
[ "def", "_normalise_path", "(", "path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ")", "->", "pathlib", ".", "Path", ":", "if", "isinstance", "(", "path", ",", "str", ")", ":", "return", "pathlib", ".", "Path", "(", "path", ")", "r...
Ensures a path is parsed. :param path: A path string or Path object. :return: The path as a Path object.
[ "Ensures", "a", "path", "is", "parsed", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L30-L39
train
gebn/wood
wood/__init__.py
root
def root(path: Union[str, pathlib.Path]) -> _Root: """ Retrieve a root directory object from a path. :param path: The path string or Path object. :return: The created root object. """ return _Root.from_path(_normalise_path(path))
python
def root(path: Union[str, pathlib.Path]) -> _Root: """ Retrieve a root directory object from a path. :param path: The path string or Path object. :return: The created root object. """ return _Root.from_path(_normalise_path(path))
[ "def", "root", "(", "path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ")", "->", "_Root", ":", "return", "_Root", ".", "from_path", "(", "_normalise_path", "(", "path", ")", ")" ]
Retrieve a root directory object from a path. :param path: The path string or Path object. :return: The created root object.
[ "Retrieve", "a", "root", "directory", "object", "from", "a", "path", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L42-L49
train
gebn/wood
wood/__init__.py
entity
def entity(path: Union[str, pathlib.Path]) -> _Entity: """ Retrieve an appropriate entity object from a path. :param path: The path of the entity to represent, either a string or Path object. :return: An entity representing the input path. """ return _Entity.from_path(_normalis...
python
def entity(path: Union[str, pathlib.Path]) -> _Entity: """ Retrieve an appropriate entity object from a path. :param path: The path of the entity to represent, either a string or Path object. :return: An entity representing the input path. """ return _Entity.from_path(_normalis...
[ "def", "entity", "(", "path", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", "]", ")", "->", "_Entity", ":", "return", "_Entity", ".", "from_path", "(", "_normalise_path", "(", "path", ")", ")" ]
Retrieve an appropriate entity object from a path. :param path: The path of the entity to represent, either a string or Path object. :return: An entity representing the input path.
[ "Retrieve", "an", "appropriate", "entity", "object", "from", "a", "path", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L52-L60
train
gebn/wood
wood/__init__.py
compare
def compare(left: Union[str, pathlib.Path, _Entity], right: Union[str, pathlib.Path, _Entity]) -> Comparison: """ Compare two paths. :param left: The left side or "before" entity. :param right: The right side or "after" entity. :return: A comparison details what has changed from the lef...
python
def compare(left: Union[str, pathlib.Path, _Entity], right: Union[str, pathlib.Path, _Entity]) -> Comparison: """ Compare two paths. :param left: The left side or "before" entity. :param right: The right side or "after" entity. :return: A comparison details what has changed from the lef...
[ "def", "compare", "(", "left", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", ",", "_Entity", "]", ",", "right", ":", "Union", "[", "str", ",", "pathlib", ".", "Path", ",", "_Entity", "]", ")", "->", "Comparison", ":", "def", "normalise", "...
Compare two paths. :param left: The left side or "before" entity. :param right: The right side or "after" entity. :return: A comparison details what has changed from the left side to the right side.
[ "Compare", "two", "paths", "." ]
efc71879890dbd2f2d7a0b1a65ed22a0843139dd
https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/__init__.py#L63-L88
train
aglie/meerkat
meerkat/meerkat.py
read_XPARM
def read_XPARM(path_to_XPARM='.'): """Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location""" if not os.path.exists(path_to_XPARM): raise Exception("path " + path_to_XPARM + "does not exist") if os.path.isdir(path_to_XPARM): candidate ...
python
def read_XPARM(path_to_XPARM='.'): """Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location""" if not os.path.exists(path_to_XPARM): raise Exception("path " + path_to_XPARM + "does not exist") if os.path.isdir(path_to_XPARM): candidate ...
[ "def", "read_XPARM", "(", "path_to_XPARM", "=", "'.'", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "path_to_XPARM", ")", ":", "raise", "Exception", "(", "\"path \"", "+", "path_to_XPARM", "+", "\"does not exist\"", ")", "if", "os", ".", ...
Loads the instrumental geometry information from the XPARM.XDS or GXPARM.XDS files at the proposed location
[ "Loads", "the", "instrumental", "geometry", "information", "from", "the", "XPARM", ".", "XDS", "or", "GXPARM", ".", "XDS", "files", "at", "the", "proposed", "location" ]
f056a3da7ed3d7cd43edb56a38903cfa146e4b24
https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/meerkat.py#L18-L82
train
aglie/meerkat
meerkat/meerkat.py
create_h5py_with_large_cache
def create_h5py_with_large_cache(filename, cache_size_mb): """ Allows to open the hdf5 file with specified cache size """ # h5py does not allow to control the cache size from the high level # we employ the workaround # sources: #http://stackoverflow.com/questions/14653259/how-to-set-cache-settin...
python
def create_h5py_with_large_cache(filename, cache_size_mb): """ Allows to open the hdf5 file with specified cache size """ # h5py does not allow to control the cache size from the high level # we employ the workaround # sources: #http://stackoverflow.com/questions/14653259/how-to-set-cache-settin...
[ "def", "create_h5py_with_large_cache", "(", "filename", ",", "cache_size_mb", ")", ":", "propfaid", "=", "h5py", ".", "h5p", ".", "create", "(", "h5py", ".", "h5p", ".", "FILE_ACCESS", ")", "settings", "=", "list", "(", "propfaid", ".", "get_cache", "(", "...
Allows to open the hdf5 file with specified cache size
[ "Allows", "to", "open", "the", "hdf5", "file", "with", "specified", "cache", "size" ]
f056a3da7ed3d7cd43edb56a38903cfa146e4b24
https://github.com/aglie/meerkat/blob/f056a3da7ed3d7cd43edb56a38903cfa146e4b24/meerkat/meerkat.py#L203-L218
train
kblin/bioinf-helperlibs
helperlibs/bio/featurematch.py
find_features
def find_features(seqs, locus_tag="all", utr_len=200): """Find features in sequences by locus tag""" found_features = [] for seq_i in seqs: for feature in seq_i.features: if feature.type == "CDS" and (locus_tag == "all" or \ ('locus_tag' in feature.qualifiers and \ ...
python
def find_features(seqs, locus_tag="all", utr_len=200): """Find features in sequences by locus tag""" found_features = [] for seq_i in seqs: for feature in seq_i.features: if feature.type == "CDS" and (locus_tag == "all" or \ ('locus_tag' in feature.qualifiers and \ ...
[ "def", "find_features", "(", "seqs", ",", "locus_tag", "=", "\"all\"", ",", "utr_len", "=", "200", ")", ":", "found_features", "=", "[", "]", "for", "seq_i", "in", "seqs", ":", "for", "feature", "in", "seq_i", ".", "features", ":", "if", "feature", "."...
Find features in sequences by locus tag
[ "Find", "features", "in", "sequences", "by", "locus", "tag" ]
3a732d62b4b3cc42675631db886ba534672cb134
https://github.com/kblin/bioinf-helperlibs/blob/3a732d62b4b3cc42675631db886ba534672cb134/helperlibs/bio/featurematch.py#L111-L127
train
Nic30/hwtGraph
hwtGraph/elk/containers/lPort.py
LPort.getLevel
def getLevel(self): """ Get nest-level of this port """ lvl = 0 p = self while True: p = p.parent if not isinstance(p, LPort): break lvl += 1 return lvl
python
def getLevel(self): """ Get nest-level of this port """ lvl = 0 p = self while True: p = p.parent if not isinstance(p, LPort): break lvl += 1 return lvl
[ "def", "getLevel", "(", "self", ")", ":", "lvl", "=", "0", "p", "=", "self", "while", "True", ":", "p", "=", "p", ".", "parent", "if", "not", "isinstance", "(", "p", ",", "LPort", ")", ":", "break", "lvl", "+=", "1", "return", "lvl" ]
Get nest-level of this port
[ "Get", "nest", "-", "level", "of", "this", "port" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/containers/lPort.py#L44-L55
train
unt-libraries/pyuntl
pyuntl/util.py
normalize_LCSH
def normalize_LCSH(subject): """Normalize a LCSH subject heading prior to indexing.""" # Strip then divide on -- which is a delimiter for LCSH; # rejoin after stripping parts. subject_parts = subject.strip().split('--') joined_subject = ' -- '.join([part.strip() for part in subject_parts]) # Ch...
python
def normalize_LCSH(subject): """Normalize a LCSH subject heading prior to indexing.""" # Strip then divide on -- which is a delimiter for LCSH; # rejoin after stripping parts. subject_parts = subject.strip().split('--') joined_subject = ' -- '.join([part.strip() for part in subject_parts]) # Ch...
[ "def", "normalize_LCSH", "(", "subject", ")", ":", "subject_parts", "=", "subject", ".", "strip", "(", ")", ".", "split", "(", "'--'", ")", "joined_subject", "=", "' -- '", ".", "join", "(", "[", "part", ".", "strip", "(", ")", "for", "part", "in", "...
Normalize a LCSH subject heading prior to indexing.
[ "Normalize", "a", "LCSH", "subject", "heading", "prior", "to", "indexing", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L4-L16
train
unt-libraries/pyuntl
pyuntl/util.py
normalize_UNTL
def normalize_UNTL(subject): """Normalize a UNTL subject heading for consistency.""" subject = subject.strip() subject = re.sub(r'[\s]+', ' ', subject) return subject
python
def normalize_UNTL(subject): """Normalize a UNTL subject heading for consistency.""" subject = subject.strip() subject = re.sub(r'[\s]+', ' ', subject) return subject
[ "def", "normalize_UNTL", "(", "subject", ")", ":", "subject", "=", "subject", ".", "strip", "(", ")", "subject", "=", "re", ".", "sub", "(", "r'[\\s]+'", ",", "' '", ",", "subject", ")", "return", "subject" ]
Normalize a UNTL subject heading for consistency.
[ "Normalize", "a", "UNTL", "subject", "heading", "for", "consistency", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L19-L23
train
unt-libraries/pyuntl
pyuntl/util.py
UNTL_to_encodedUNTL
def UNTL_to_encodedUNTL(subject): """Normalize a UNTL subject heading to be used in SOLR.""" subject = normalize_UNTL(subject) subject = subject.replace(' ', '_') subject = subject.replace('_-_', '/') return subject
python
def UNTL_to_encodedUNTL(subject): """Normalize a UNTL subject heading to be used in SOLR.""" subject = normalize_UNTL(subject) subject = subject.replace(' ', '_') subject = subject.replace('_-_', '/') return subject
[ "def", "UNTL_to_encodedUNTL", "(", "subject", ")", ":", "subject", "=", "normalize_UNTL", "(", "subject", ")", "subject", "=", "subject", ".", "replace", "(", "' '", ",", "'_'", ")", "subject", "=", "subject", ".", "replace", "(", "'_-_'", ",", "'/'", ")...
Normalize a UNTL subject heading to be used in SOLR.
[ "Normalize", "a", "UNTL", "subject", "heading", "to", "be", "used", "in", "SOLR", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L26-L31
train
unt-libraries/pyuntl
pyuntl/util.py
untldict_normalizer
def untldict_normalizer(untl_dict, normalizations): """Normalize UNTL elements by their qualifier. Takes a UNTL descriptive metadata dictionary and a dictionary of the elements and the qualifiers for normalization: {'element1': ['qualifier1', 'qualifier2'], 'element2': ['qualifier3']} and norm...
python
def untldict_normalizer(untl_dict, normalizations): """Normalize UNTL elements by their qualifier. Takes a UNTL descriptive metadata dictionary and a dictionary of the elements and the qualifiers for normalization: {'element1': ['qualifier1', 'qualifier2'], 'element2': ['qualifier3']} and norm...
[ "def", "untldict_normalizer", "(", "untl_dict", ",", "normalizations", ")", ":", "for", "element_type", ",", "element_list", "in", "untl_dict", ".", "items", "(", ")", ":", "if", "element_type", "in", "normalizations", ":", "norm_qualifier_list", "=", "normalizati...
Normalize UNTL elements by their qualifier. Takes a UNTL descriptive metadata dictionary and a dictionary of the elements and the qualifiers for normalization: {'element1': ['qualifier1', 'qualifier2'], 'element2': ['qualifier3']} and normalizes the elements with that qualifier.
[ "Normalize", "UNTL", "elements", "by", "their", "qualifier", "." ]
f92413302897dab948aac18ee9e482ace0187bd4
https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/util.py#L41-L73
train
peterbe/gg
gg/builtins/start/gg_start.py
start
def start(config, bugnumber=""): """Create a new topic branch.""" repo = config.repo if bugnumber: summary, bugnumber, url = get_summary(config, bugnumber) else: url = None summary = None if summary: summary = input('Summary ["{}"]: '.format(summary)).strip() or sum...
python
def start(config, bugnumber=""): """Create a new topic branch.""" repo = config.repo if bugnumber: summary, bugnumber, url = get_summary(config, bugnumber) else: url = None summary = None if summary: summary = input('Summary ["{}"]: '.format(summary)).strip() or sum...
[ "def", "start", "(", "config", ",", "bugnumber", "=", "\"\"", ")", ":", "repo", "=", "config", ".", "repo", "if", "bugnumber", ":", "summary", ",", "bugnumber", ",", "url", "=", "get_summary", "(", "config", ",", "bugnumber", ")", "else", ":", "url", ...
Create a new topic branch.
[ "Create", "a", "new", "topic", "branch", "." ]
2aace5bdb4a9b1cb65bea717784edf54c63b7bad
https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/start/gg_start.py#L18-L65
train
255BITS/hyperchamber
examples/shared/ops.py
conv_cond_concat
def conv_cond_concat(x, y): """Concatenate conditioning vector on feature map axis.""" x_shapes = x.get_shape() y_shapes = y.get_shape() return tf.concat(3, [x, y*tf.ones([x_shapes[0], x_shapes[1], x_shapes[2], y_shapes[3]])])
python
def conv_cond_concat(x, y): """Concatenate conditioning vector on feature map axis.""" x_shapes = x.get_shape() y_shapes = y.get_shape() return tf.concat(3, [x, y*tf.ones([x_shapes[0], x_shapes[1], x_shapes[2], y_shapes[3]])])
[ "def", "conv_cond_concat", "(", "x", ",", "y", ")", ":", "x_shapes", "=", "x", ".", "get_shape", "(", ")", "y_shapes", "=", "y", ".", "get_shape", "(", ")", "return", "tf", ".", "concat", "(", "3", ",", "[", "x", ",", "y", "*", "tf", ".", "ones...
Concatenate conditioning vector on feature map axis.
[ "Concatenate", "conditioning", "vector", "on", "feature", "map", "axis", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/ops.py#L106-L110
train
255BITS/hyperchamber
examples/shared/ops.py
lrelu_sq
def lrelu_sq(x): """ Concatenates lrelu and square """ dim = len(x.get_shape()) - 1 return tf.concat(dim, [lrelu(x), tf.minimum(tf.abs(x), tf.square(x))])
python
def lrelu_sq(x): """ Concatenates lrelu and square """ dim = len(x.get_shape()) - 1 return tf.concat(dim, [lrelu(x), tf.minimum(tf.abs(x), tf.square(x))])
[ "def", "lrelu_sq", "(", "x", ")", ":", "dim", "=", "len", "(", "x", ".", "get_shape", "(", ")", ")", "-", "1", "return", "tf", ".", "concat", "(", "dim", ",", "[", "lrelu", "(", "x", ")", ",", "tf", ".", "minimum", "(", "tf", ".", "abs", "(...
Concatenates lrelu and square
[ "Concatenates", "lrelu", "and", "square" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/ops.py#L223-L228
train
255BITS/hyperchamber
examples/shared/ops.py
avg_grads
def avg_grads(tower_grads): """Calculate the average gradient for each shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over individual gradients. The inner ...
python
def avg_grads(tower_grads): """Calculate the average gradient for each shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over individual gradients. The inner ...
[ "def", "avg_grads", "(", "tower_grads", ")", ":", "average_grads", "=", "[", "]", "for", "grad_and_vars", "in", "zip", "(", "*", "tower_grads", ")", ":", "grads", "=", "[", "]", "for", "g", ",", "_", "in", "grad_and_vars", ":", "expanded_g", "=", "tf",...
Calculate the average gradient for each shared variable across all towers. Note that this function provides a synchronization point across all towers. Args: tower_grads: List of lists of (gradient, variable) tuples. The outer list is over individual gradients. The inner list is over the gradient c...
[ "Calculate", "the", "average", "gradient", "for", "each", "shared", "variable", "across", "all", "towers", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/ops.py#L264-L299
train
kwlzn/blast
blast/main.py
unescape_utf8
def unescape_utf8(msg): ''' convert escaped unicode web entities to unicode ''' def sub(m): text = m.group(0) if text[:3] == "&#x": return unichr(int(text[3:-1], 16)) else: return unichr(int(text[2:-1])) return re.sub("&#?\w+;", sub, urllib.unquote(msg))
python
def unescape_utf8(msg): ''' convert escaped unicode web entities to unicode ''' def sub(m): text = m.group(0) if text[:3] == "&#x": return unichr(int(text[3:-1], 16)) else: return unichr(int(text[2:-1])) return re.sub("&#?\w+;", sub, urllib.unquote(msg))
[ "def", "unescape_utf8", "(", "msg", ")", ":", "def", "sub", "(", "m", ")", ":", "text", "=", "m", ".", "group", "(", "0", ")", "if", "text", "[", ":", "3", "]", "==", "\"&#x\"", ":", "return", "unichr", "(", "int", "(", "text", "[", "3", ":",...
convert escaped unicode web entities to unicode
[ "convert", "escaped", "unicode", "web", "entities", "to", "unicode" ]
ae18a19182a6884c453bf9b2a3c6386bd3b2655a
https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/main.py#L41-L47
train
KnightConan/sspdatatables
src/sspdatatables/utils/data_type_ensure.py
ensure
def ensure(data_type, check_value, default_value=None): """ function to ensure the given check value is in the given data type, if yes, return the check value directly, otherwise return the default value :param data_type: different data type: can be int, str, list, tuple etc, must be python suppo...
python
def ensure(data_type, check_value, default_value=None): """ function to ensure the given check value is in the given data type, if yes, return the check value directly, otherwise return the default value :param data_type: different data type: can be int, str, list, tuple etc, must be python suppo...
[ "def", "ensure", "(", "data_type", ",", "check_value", ",", "default_value", "=", "None", ")", ":", "if", "default_value", "is", "not", "None", "and", "not", "isinstance", "(", "default_value", ",", "data_type", ")", ":", "raise", "ValueError", "(", "\"defau...
function to ensure the given check value is in the given data type, if yes, return the check value directly, otherwise return the default value :param data_type: different data type: can be int, str, list, tuple etc, must be python supportable data type or new defined data type :param check_value: di...
[ "function", "to", "ensure", "the", "given", "check", "value", "is", "in", "the", "given", "data", "type", "if", "yes", "return", "the", "check", "value", "directly", "otherwise", "return", "the", "default", "value" ]
1179a11358734e5e472e5eee703e8d34fa49e9bf
https://github.com/KnightConan/sspdatatables/blob/1179a11358734e5e472e5eee703e8d34fa49e9bf/src/sspdatatables/utils/data_type_ensure.py#L7-L27
train
edx/edx-celeryutils
celery_utils/tasks.py
mark_resolved
def mark_resolved(task_id): """ Mark the specified task as resolved in the FailedTask table. If more than one record exists with the specified task id, they will all be marked resolved. """ from . import models models.FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).update...
python
def mark_resolved(task_id): """ Mark the specified task as resolved in the FailedTask table. If more than one record exists with the specified task id, they will all be marked resolved. """ from . import models models.FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).update...
[ "def", "mark_resolved", "(", "task_id", ")", ":", "from", ".", "import", "models", "models", ".", "FailedTask", ".", "objects", ".", "filter", "(", "task_id", "=", "task_id", ",", "datetime_resolved", "=", "None", ")", ".", "update", "(", "datetime_resolved"...
Mark the specified task as resolved in the FailedTask table. If more than one record exists with the specified task id, they will all be marked resolved.
[ "Mark", "the", "specified", "task", "as", "resolved", "in", "the", "FailedTask", "table", "." ]
d8745f5f0929ad154fad779a19fbefe7f51e9498
https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/tasks.py#L13-L21
train
flo-compbio/xlmhg
xlmhg/mhg.py
is_equal
def is_equal(a, b, tol): """Ratio test to check if two floating point numbers are equal. Parameters ---------- a: float The first floating point number. b: float The second floating point number. tol: float The tolerance used. Returns ------- bool Wh...
python
def is_equal(a, b, tol): """Ratio test to check if two floating point numbers are equal. Parameters ---------- a: float The first floating point number. b: float The second floating point number. tol: float The tolerance used. Returns ------- bool Wh...
[ "def", "is_equal", "(", "a", ",", "b", ",", "tol", ")", ":", "if", "a", "==", "b", "or", "abs", "(", "a", "-", "b", ")", "<=", "tol", "*", "max", "(", "abs", "(", "a", ")", ",", "abs", "(", "b", ")", ")", ":", "return", "True", "else", ...
Ratio test to check if two floating point numbers are equal. Parameters ---------- a: float The first floating point number. b: float The second floating point number. tol: float The tolerance used. Returns ------- bool Whether or not the two numbers are...
[ "Ratio", "test", "to", "check", "if", "two", "floating", "point", "numbers", "are", "equal", "." ]
8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1
https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/mhg.py#L28-L48
train
Nic30/hwtGraph
hwtGraph/elk/containers/lNode.py
LNode.getPortSideView
def getPortSideView(self, side) -> List["LPort"]: """ Returns a sublist view for all ports of given side. :attention: Use this only after port sides are fixed! This is currently the case after running the {@link org.eclipse.elk.alg.layered.intermediate.PortListSorter}. Non-stru...
python
def getPortSideView(self, side) -> List["LPort"]: """ Returns a sublist view for all ports of given side. :attention: Use this only after port sides are fixed! This is currently the case after running the {@link org.eclipse.elk.alg.layered.intermediate.PortListSorter}. Non-stru...
[ "def", "getPortSideView", "(", "self", ",", "side", ")", "->", "List", "[", "\"LPort\"", "]", ":", "if", "side", "==", "PortSide", ".", "WEST", ":", "return", "self", ".", "west", "elif", "side", "==", "PortSide", ".", "EAST", ":", "return", "self", ...
Returns a sublist view for all ports of given side. :attention: Use this only after port sides are fixed! This is currently the case after running the {@link org.eclipse.elk.alg.layered.intermediate.PortListSorter}. Non-structural changes to this list are reflected in the original list. A stru...
[ "Returns", "a", "sublist", "view", "for", "all", "ports", "of", "given", "side", "." ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/containers/lNode.py#L53-L76
train
Nic30/hwtGraph
hwtGraph/elk/containers/lNode.py
LNode.iterEdges
def iterEdges(self, filterSelfLoops=False): """ Iter edges connected from outside of this unit """ for p in self.iterPorts(): yield from p.iterEdges(filterSelfLoops=filterSelfLoops)
python
def iterEdges(self, filterSelfLoops=False): """ Iter edges connected from outside of this unit """ for p in self.iterPorts(): yield from p.iterEdges(filterSelfLoops=filterSelfLoops)
[ "def", "iterEdges", "(", "self", ",", "filterSelfLoops", "=", "False", ")", ":", "for", "p", "in", "self", ".", "iterPorts", "(", ")", ":", "yield", "from", "p", ".", "iterEdges", "(", "filterSelfLoops", "=", "filterSelfLoops", ")" ]
Iter edges connected from outside of this unit
[ "Iter", "edges", "connected", "from", "outside", "of", "this", "unit" ]
6b7d4fdd759f263a0fdd2736f02f123e44e4354f
https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/containers/lNode.py#L94-L99
train
albert12132/templar
templar/linker.py
link
def link(source_path): """Links the content found at source_path and represents a Block that represents the content.""" if not os.path.isfile(source_path): raise SourceNotFound(source_path) with open(source_path, 'r') as f: content = f.read() block_map = BlockMap() # The map will be pop...
python
def link(source_path): """Links the content found at source_path and represents a Block that represents the content.""" if not os.path.isfile(source_path): raise SourceNotFound(source_path) with open(source_path, 'r') as f: content = f.read() block_map = BlockMap() # The map will be pop...
[ "def", "link", "(", "source_path", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "source_path", ")", ":", "raise", "SourceNotFound", "(", "source_path", ")", "with", "open", "(", "source_path", ",", "'r'", ")", "as", "f", ":", "content"...
Links the content found at source_path and represents a Block that represents the content.
[ "Links", "the", "content", "found", "at", "source_path", "and", "represents", "a", "Block", "that", "represents", "the", "content", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/linker.py#L10-L19
train
albert12132/templar
templar/linker.py
process_links
def process_links(include_match, block_map, link_stack, source_path): """Process a string of content for include tags. This function assumes there are no blocks in the content. The content is split into segments, with include tags being replaced by Block objects. PARAMETERS: content -- str; co...
python
def process_links(include_match, block_map, link_stack, source_path): """Process a string of content for include tags. This function assumes there are no blocks in the content. The content is split into segments, with include tags being replaced by Block objects. PARAMETERS: content -- str; co...
[ "def", "process_links", "(", "include_match", ",", "block_map", ",", "link_stack", ",", "source_path", ")", ":", "leading_whitespace", "=", "include_match", ".", "group", "(", "1", ")", "include_path", "=", "include_match", ".", "group", "(", "2", ")", "block_...
Process a string of content for include tags. This function assumes there are no blocks in the content. The content is split into segments, with include tags being replaced by Block objects. PARAMETERS: content -- str; content to be converted into a Block. block_map -- BlockMap link_stac...
[ "Process", "a", "string", "of", "content", "for", "include", "tags", "." ]
39851c89730ab69e5c73d0a46adca2a44ecc4165
https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/linker.py#L232-L263
train
althonos/moclo
moclo/moclo/_utils.py
catch_warnings
def catch_warnings(action, category=Warning, lineno=0, append=False): """Wrap the function in a `warnings.catch_warnings` context. It can be used to silence some particular specific warnings, or instead to treat them as errors within the function body. Example: >>> import warnings >>> ...
python
def catch_warnings(action, category=Warning, lineno=0, append=False): """Wrap the function in a `warnings.catch_warnings` context. It can be used to silence some particular specific warnings, or instead to treat them as errors within the function body. Example: >>> import warnings >>> ...
[ "def", "catch_warnings", "(", "action", ",", "category", "=", "Warning", ",", "lineno", "=", "0", ",", "append", "=", "False", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "newfunc", "(...
Wrap the function in a `warnings.catch_warnings` context. It can be used to silence some particular specific warnings, or instead to treat them as errors within the function body. Example: >>> import warnings >>> from moclo.utils import catch_warnings >>> @catch_warnings('ignore') ...
[ "Wrap", "the", "function", "in", "a", "warnings", ".", "catch_warnings", "context", "." ]
28a03748df8a2fa43f0c0c8098ca64d11559434e
https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/_utils.py#L27-L54
train
reorx/torext
torext/app.py
_guess_caller
def _guess_caller(): """ try to guess which module import app.py """ import inspect global _caller_path caller = inspect.stack()[1] caller_module = inspect.getmodule(caller[0]) if hasattr(caller_module, '__file__'): _caller_path = os.path.abspath(caller_module.__file__) retu...
python
def _guess_caller(): """ try to guess which module import app.py """ import inspect global _caller_path caller = inspect.stack()[1] caller_module = inspect.getmodule(caller[0]) if hasattr(caller_module, '__file__'): _caller_path = os.path.abspath(caller_module.__file__) retu...
[ "def", "_guess_caller", "(", ")", ":", "import", "inspect", "global", "_caller_path", "caller", "=", "inspect", ".", "stack", "(", ")", "[", "1", "]", "caller_module", "=", "inspect", ".", "getmodule", "(", "caller", "[", "0", "]", ")", "if", "hasattr", ...
try to guess which module import app.py
[ "try", "to", "guess", "which", "module", "import", "app", ".", "py" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L564-L575
train
reorx/torext
torext/app.py
TorextApp._fix_paths
def _fix_paths(self, options): """ fix `static_path` and `template_path` to be absolute path according to self.root_path so that PWD can be ignoreed. """ for k in ('template_path', 'static_path'): if k in options: v = options.pop(k) if ...
python
def _fix_paths(self, options): """ fix `static_path` and `template_path` to be absolute path according to self.root_path so that PWD can be ignoreed. """ for k in ('template_path', 'static_path'): if k in options: v = options.pop(k) if ...
[ "def", "_fix_paths", "(", "self", ",", "options", ")", ":", "for", "k", "in", "(", "'template_path'", ",", "'static_path'", ")", ":", "if", "k", "in", "options", ":", "v", "=", "options", ".", "pop", "(", "k", ")", "if", "v", "is", "None", ":", "...
fix `static_path` and `template_path` to be absolute path according to self.root_path so that PWD can be ignoreed.
[ "fix", "static_path", "and", "template_path", "to", "be", "absolute", "path", "according", "to", "self", ".", "root_path", "so", "that", "PWD", "can", "be", "ignoreed", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L190-L204
train
reorx/torext
torext/app.py
TorextApp.route
def route(self, url, host=None): """This is a decorator """ def fn(handler_cls): handlers = self._get_handlers_on_host(host) handlers.insert(0, (url, handler_cls)) return handler_cls return fn
python
def route(self, url, host=None): """This is a decorator """ def fn(handler_cls): handlers = self._get_handlers_on_host(host) handlers.insert(0, (url, handler_cls)) return handler_cls return fn
[ "def", "route", "(", "self", ",", "url", ",", "host", "=", "None", ")", ":", "def", "fn", "(", "handler_cls", ")", ":", "handlers", "=", "self", ".", "_get_handlers_on_host", "(", "host", ")", "handlers", ".", "insert", "(", "0", ",", "(", "url", "...
This is a decorator
[ "This", "is", "a", "decorator" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L214-L221
train
reorx/torext
torext/app.py
TorextApp.command_line_config
def command_line_config(self): """ settings.py is the basis if wants to change them by command line arguments, the existing option will be transformed to the value type in settings.py the unexisting option will be treated as string by default, and transform to certain ty...
python
def command_line_config(self): """ settings.py is the basis if wants to change them by command line arguments, the existing option will be transformed to the value type in settings.py the unexisting option will be treated as string by default, and transform to certain ty...
[ "def", "command_line_config", "(", "self", ")", ":", "args", "=", "sys", ".", "argv", "[", "1", ":", "]", "args_dict", "=", "{", "}", "existed_keys", "=", "[", "]", "new_keys", "=", "[", "]", "for", "t", "in", "args", ":", "if", "not", "t", ".", ...
settings.py is the basis if wants to change them by command line arguments, the existing option will be transformed to the value type in settings.py the unexisting option will be treated as string by default, and transform to certain type if `!<type>` was added after the value. ...
[ "settings", ".", "py", "is", "the", "basis" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L266-L325
train
reorx/torext
torext/app.py
TorextApp.setup
def setup(self): """This function will be called both before `run` and testing started. """ testing = settings.get('TESTING') if testing: # Fix nose handler in testing situation. config = settings['LOGGERS'].get('', {}) set_nose_formatter(config) ...
python
def setup(self): """This function will be called both before `run` and testing started. """ testing = settings.get('TESTING') if testing: # Fix nose handler in testing situation. config = settings['LOGGERS'].get('', {}) set_nose_formatter(config) ...
[ "def", "setup", "(", "self", ")", ":", "testing", "=", "settings", ".", "get", "(", "'TESTING'", ")", "if", "testing", ":", "config", "=", "settings", "[", "'LOGGERS'", "]", ".", "get", "(", "''", ",", "{", "}", ")", "set_nose_formatter", "(", "confi...
This function will be called both before `run` and testing started.
[ "This", "function", "will", "be", "called", "both", "before", "run", "and", "testing", "started", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L327-L367
train
reorx/torext
torext/app.py
TorextApp._init_application
def _init_application(self, application=None): """Initialize application object for torext app, if a existed application is passed, then just use this one without make a new one""" if application: self.application = application else: self.application = self.make_a...
python
def _init_application(self, application=None): """Initialize application object for torext app, if a existed application is passed, then just use this one without make a new one""" if application: self.application = application else: self.application = self.make_a...
[ "def", "_init_application", "(", "self", ",", "application", "=", "None", ")", ":", "if", "application", ":", "self", ".", "application", "=", "application", "else", ":", "self", ".", "application", "=", "self", ".", "make_application", "(", ")" ]
Initialize application object for torext app, if a existed application is passed, then just use this one without make a new one
[ "Initialize", "application", "object", "for", "torext", "app", "if", "a", "existed", "application", "is", "passed", "then", "just", "use", "this", "one", "without", "make", "a", "new", "one" ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L530-L536
train
reorx/torext
torext/app.py
TorextApp._log_function
def _log_function(self, handler): """Override Application.log_function so that what to log can be controlled. """ if handler.get_status() < 400: log_method = request_log.info elif handler.get_status() < 500: log_method = request_log.warning else: ...
python
def _log_function(self, handler): """Override Application.log_function so that what to log can be controlled. """ if handler.get_status() < 400: log_method = request_log.info elif handler.get_status() < 500: log_method = request_log.warning else: ...
[ "def", "_log_function", "(", "self", ",", "handler", ")", ":", "if", "handler", ".", "get_status", "(", ")", "<", "400", ":", "log_method", "=", "request_log", ".", "info", "elif", "handler", ".", "get_status", "(", ")", "<", "500", ":", "log_method", ...
Override Application.log_function so that what to log can be controlled.
[ "Override", "Application", ".", "log_function", "so", "that", "what", "to", "log", "can", "be", "controlled", "." ]
84c4300ebc7fab0dbd11cf8b020bc7d4d1570171
https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/app.py#L542-L558
train
255BITS/hyperchamber
examples/shared/variational_autoencoder.py
xavier_init
def xavier_init(fan_in, fan_out, constant=1): """ Xavier initialization of network weights""" # https://stackoverflow.com/questions/33640581/how-to-do-xavier-initialization-on-tensorflow low = -constant*np.sqrt(6.0/(fan_in + fan_out)) high = constant*np.sqrt(6.0/(fan_in + fan_out)) return tf.rando...
python
def xavier_init(fan_in, fan_out, constant=1): """ Xavier initialization of network weights""" # https://stackoverflow.com/questions/33640581/how-to-do-xavier-initialization-on-tensorflow low = -constant*np.sqrt(6.0/(fan_in + fan_out)) high = constant*np.sqrt(6.0/(fan_in + fan_out)) return tf.rando...
[ "def", "xavier_init", "(", "fan_in", ",", "fan_out", ",", "constant", "=", "1", ")", ":", "low", "=", "-", "constant", "*", "np", ".", "sqrt", "(", "6.0", "/", "(", "fan_in", "+", "fan_out", ")", ")", "high", "=", "constant", "*", "np", ".", "sqr...
Xavier initialization of network weights
[ "Xavier", "initialization", "of", "network", "weights" ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/variational_autoencoder.py#L8-L15
train
255BITS/hyperchamber
examples/shared/variational_autoencoder.py
VariationalAutoencoder.partial_fit
def partial_fit(self, X): """Train model based on mini-batch of input data. Return cost of mini-batch. """ opt, cost = self.sess.run((self.optimizer, self.cost), feed_dict={self.x: X}) return cost
python
def partial_fit(self, X): """Train model based on mini-batch of input data. Return cost of mini-batch. """ opt, cost = self.sess.run((self.optimizer, self.cost), feed_dict={self.x: X}) return cost
[ "def", "partial_fit", "(", "self", ",", "X", ")", ":", "opt", ",", "cost", "=", "self", ".", "sess", ".", "run", "(", "(", "self", ".", "optimizer", ",", "self", ".", "cost", ")", ",", "feed_dict", "=", "{", "self", ".", "x", ":", "X", "}", "...
Train model based on mini-batch of input data. Return cost of mini-batch.
[ "Train", "model", "based", "on", "mini", "-", "batch", "of", "input", "data", ".", "Return", "cost", "of", "mini", "-", "batch", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/variational_autoencoder.py#L155-L162
train
255BITS/hyperchamber
examples/shared/variational_autoencoder.py
VariationalAutoencoder.transform
def transform(self, X): """Transform data by mapping it into the latent space.""" # Note: This maps to mean of distribution, we could alternatively # sample from Gaussian distribution return self.sess.run(self.z_mean, feed_dict={self.x: X})
python
def transform(self, X): """Transform data by mapping it into the latent space.""" # Note: This maps to mean of distribution, we could alternatively # sample from Gaussian distribution return self.sess.run(self.z_mean, feed_dict={self.x: X})
[ "def", "transform", "(", "self", ",", "X", ")", ":", "return", "self", ".", "sess", ".", "run", "(", "self", ".", "z_mean", ",", "feed_dict", "=", "{", "self", ".", "x", ":", "X", "}", ")" ]
Transform data by mapping it into the latent space.
[ "Transform", "data", "by", "mapping", "it", "into", "the", "latent", "space", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/variational_autoencoder.py#L164-L168
train
255BITS/hyperchamber
examples/shared/variational_autoencoder.py
VariationalAutoencoder.generate
def generate(self, z_mu=None): """ Generate data by sampling from latent space. If z_mu is not None, data for this point in latent space is generated. Otherwise, z_mu is drawn from prior in latent space. """ if z_mu is None: z_mu = np.random....
python
def generate(self, z_mu=None): """ Generate data by sampling from latent space. If z_mu is not None, data for this point in latent space is generated. Otherwise, z_mu is drawn from prior in latent space. """ if z_mu is None: z_mu = np.random....
[ "def", "generate", "(", "self", ",", "z_mu", "=", "None", ")", ":", "if", "z_mu", "is", "None", ":", "z_mu", "=", "np", ".", "random", ".", "normal", "(", "size", "=", "self", ".", "network_architecture", "[", "\"n_z\"", "]", ")", "return", "self", ...
Generate data by sampling from latent space. If z_mu is not None, data for this point in latent space is generated. Otherwise, z_mu is drawn from prior in latent space.
[ "Generate", "data", "by", "sampling", "from", "latent", "space", ".", "If", "z_mu", "is", "not", "None", "data", "for", "this", "point", "in", "latent", "space", "is", "generated", ".", "Otherwise", "z_mu", "is", "drawn", "from", "prior", "in", "latent", ...
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/variational_autoencoder.py#L170-L182
train
255BITS/hyperchamber
examples/shared/variational_autoencoder.py
VariationalAutoencoder.reconstruct
def reconstruct(self, X): """ Use VAE to reconstruct given data. """ return self.sess.run(self.x_reconstr_mean, feed_dict={self.x: X})
python
def reconstruct(self, X): """ Use VAE to reconstruct given data. """ return self.sess.run(self.x_reconstr_mean, feed_dict={self.x: X})
[ "def", "reconstruct", "(", "self", ",", "X", ")", ":", "return", "self", ".", "sess", ".", "run", "(", "self", ".", "x_reconstr_mean", ",", "feed_dict", "=", "{", "self", ".", "x", ":", "X", "}", ")" ]
Use VAE to reconstruct given data.
[ "Use", "VAE", "to", "reconstruct", "given", "data", "." ]
4d5774bde9ea6ce1113f77a069ffc605148482b8
https://github.com/255BITS/hyperchamber/blob/4d5774bde9ea6ce1113f77a069ffc605148482b8/examples/shared/variational_autoencoder.py#L184-L187
train
geophysics-ubonn/crtomo_tools
src/cr_trig_parse_gmsh.py
get_ajd_bound
def get_ajd_bound(mesh): """ Determine triangular elements adjacend to the boundary elements """ print('Get elements adjacent to boundaries') boundary_elements = [] str_adj_boundaries = '' # for boundary in mesh['elements']['1']: boundaries = mesh['boundaries']['12'] + mesh['boundaries']...
python
def get_ajd_bound(mesh): """ Determine triangular elements adjacend to the boundary elements """ print('Get elements adjacent to boundaries') boundary_elements = [] str_adj_boundaries = '' # for boundary in mesh['elements']['1']: boundaries = mesh['boundaries']['12'] + mesh['boundaries']...
[ "def", "get_ajd_bound", "(", "mesh", ")", ":", "print", "(", "'Get elements adjacent to boundaries'", ")", "boundary_elements", "=", "[", "]", "str_adj_boundaries", "=", "''", "boundaries", "=", "mesh", "[", "'boundaries'", "]", "[", "'12'", "]", "+", "mesh", ...
Determine triangular elements adjacend to the boundary elements
[ "Determine", "triangular", "elements", "adjacend", "to", "the", "boundary", "elements" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_parse_gmsh.py#L385-L405
train
geophysics-ubonn/crtomo_tools
src/cr_trig_parse_gmsh.py
write_elec_file
def write_elec_file(filename, mesh): """ Read in the electrode positions and return the indices of the electrodes # TODO: Check if you find all electrodes """ elecs = [] # print('Write electrodes') electrodes = np.loadtxt(filename) for i in electrodes: # find for nr, j i...
python
def write_elec_file(filename, mesh): """ Read in the electrode positions and return the indices of the electrodes # TODO: Check if you find all electrodes """ elecs = [] # print('Write electrodes') electrodes = np.loadtxt(filename) for i in electrodes: # find for nr, j i...
[ "def", "write_elec_file", "(", "filename", ",", "mesh", ")", ":", "elecs", "=", "[", "]", "electrodes", "=", "np", ".", "loadtxt", "(", "filename", ")", "for", "i", "in", "electrodes", ":", "for", "nr", ",", "j", "in", "enumerate", "(", "mesh", "[", ...
Read in the electrode positions and return the indices of the electrodes # TODO: Check if you find all electrodes
[ "Read", "in", "the", "electrode", "positions", "and", "return", "the", "indices", "of", "the", "electrodes" ]
27c3e21a557f8df1c12455b96c4c2e00e08a5b4a
https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/cr_trig_parse_gmsh.py#L408-L427
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell.state_size
def state_size(self) -> Sequence[Shape]: '''Returns the MDP state size.''' return self._sizes(self._compiler.rddl.state_size)
python
def state_size(self) -> Sequence[Shape]: '''Returns the MDP state size.''' return self._sizes(self._compiler.rddl.state_size)
[ "def", "state_size", "(", "self", ")", "->", "Sequence", "[", "Shape", "]", ":", "return", "self", ".", "_sizes", "(", "self", ".", "_compiler", ".", "rddl", ".", "state_size", ")" ]
Returns the MDP state size.
[ "Returns", "the", "MDP", "state", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L77-L79
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell.action_size
def action_size(self) -> Sequence[Shape]: '''Returns the MDP action size.''' return self._sizes(self._compiler.rddl.action_size)
python
def action_size(self) -> Sequence[Shape]: '''Returns the MDP action size.''' return self._sizes(self._compiler.rddl.action_size)
[ "def", "action_size", "(", "self", ")", "->", "Sequence", "[", "Shape", "]", ":", "return", "self", ".", "_sizes", "(", "self", ".", "_compiler", ".", "rddl", ".", "action_size", ")" ]
Returns the MDP action size.
[ "Returns", "the", "MDP", "action", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L82-L84
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell.interm_size
def interm_size(self) -> Sequence[Shape]: '''Returns the MDP intermediate state size.''' return self._sizes(self._compiler.rddl.interm_size)
python
def interm_size(self) -> Sequence[Shape]: '''Returns the MDP intermediate state size.''' return self._sizes(self._compiler.rddl.interm_size)
[ "def", "interm_size", "(", "self", ")", "->", "Sequence", "[", "Shape", "]", ":", "return", "self", ".", "_sizes", "(", "self", ".", "_compiler", ".", "rddl", ".", "interm_size", ")" ]
Returns the MDP intermediate state size.
[ "Returns", "the", "MDP", "intermediate", "state", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L87-L89
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell.output_size
def output_size(self) -> Tuple[Sequence[Shape], Sequence[Shape], Sequence[Shape], int]: '''Returns the simulation cell output size.''' return (self.state_size, self.action_size, self.interm_size, 1)
python
def output_size(self) -> Tuple[Sequence[Shape], Sequence[Shape], Sequence[Shape], int]: '''Returns the simulation cell output size.''' return (self.state_size, self.action_size, self.interm_size, 1)
[ "def", "output_size", "(", "self", ")", "->", "Tuple", "[", "Sequence", "[", "Shape", "]", ",", "Sequence", "[", "Shape", "]", ",", "Sequence", "[", "Shape", "]", ",", "int", "]", ":", "return", "(", "self", ".", "state_size", ",", "self", ".", "ac...
Returns the simulation cell output size.
[ "Returns", "the", "simulation", "cell", "output", "size", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L92-L94
train
thiagopbueno/tf-rddlsim
tfrddlsim/simulation/policy_simulator.py
PolicySimulationCell.initial_state
def initial_state(self) -> StateTensor: '''Returns the initial state tensor.''' s0 = [] for fluent in self._compiler.compile_initial_state(self._batch_size): s0.append(self._output_size(fluent)) s0 = tuple(s0) return s0
python
def initial_state(self) -> StateTensor: '''Returns the initial state tensor.''' s0 = [] for fluent in self._compiler.compile_initial_state(self._batch_size): s0.append(self._output_size(fluent)) s0 = tuple(s0) return s0
[ "def", "initial_state", "(", "self", ")", "->", "StateTensor", ":", "s0", "=", "[", "]", "for", "fluent", "in", "self", ".", "_compiler", ".", "compile_initial_state", "(", "self", ".", "_batch_size", ")", ":", "s0", ".", "append", "(", "self", ".", "_...
Returns the initial state tensor.
[ "Returns", "the", "initial", "state", "tensor", "." ]
d7102a0ad37d179dbb23141640254ea383d3b43f
https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/simulation/policy_simulator.py#L96-L102
train