nwo
stringlengths
5
106
sha
stringlengths
40
40
path
stringlengths
4
174
language
stringclasses
1 value
identifier
stringlengths
1
140
parameters
stringlengths
0
87.7k
argument_list
stringclasses
1 value
return_statement
stringlengths
0
426k
docstring
stringlengths
0
64.3k
docstring_summary
stringlengths
0
26.3k
docstring_tokens
list
function
stringlengths
18
4.83M
function_tokens
list
url
stringlengths
83
304
rhinstaller/anaconda
63edc8680f1b05cbfe11bef28703acba808c5174
pyanaconda/core/configuration/system.py
python
SystemSection.can_activate_keyboard
(self)
return self._is_boot_iso or self._is_booted_os
Can we activate the keyboard? FIXME: This is a temporary workaround.
Can we activate the keyboard?
[ "Can", "we", "activate", "the", "keyboard?" ]
def can_activate_keyboard(self): """Can we activate the keyboard? FIXME: This is a temporary workaround. """ return self._is_boot_iso or self._is_booted_os
[ "def", "can_activate_keyboard", "(", "self", ")", ":", "return", "self", ".", "_is_boot_iso", "or", "self", ".", "_is_booted_os" ]
https://github.com/rhinstaller/anaconda/blob/63edc8680f1b05cbfe11bef28703acba808c5174/pyanaconda/core/configuration/system.py#L110-L115
crits/crits_services
c7abf91f1865d913cffad4b966599da204f8ae43
taxii_service/handlers.py
python
has_cybox_repr
(obj)
Determine if this indicator is of a type that can successfully be converted to a CybOX object. :return The CybOX representation if possible, else False.
Determine if this indicator is of a type that can successfully be converted to a CybOX object.
[ "Determine", "if", "this", "indicator", "is", "of", "a", "type", "that", "can", "successfully", "be", "converted", "to", "a", "CybOX", "object", "." ]
def has_cybox_repr(obj): """ Determine if this indicator is of a type that can successfully be converted to a CybOX object. :return The CybOX representation if possible, else False. """ try: rep = make_cybox_object(obj.ind_type, obj.value) return rep except: return False
[ "def", "has_cybox_repr", "(", "obj", ")", ":", "try", ":", "rep", "=", "make_cybox_object", "(", "obj", ".", "ind_type", ",", "obj", ".", "value", ")", "return", "rep", "except", ":", "return", "False" ]
https://github.com/crits/crits_services/blob/c7abf91f1865d913cffad4b966599da204f8ae43/taxii_service/handlers.py#L1374-L1385
fgsect/unicorefuzz
f5b27a6dda601ef18cb166f79eb121be8e7b88bd
unicorefuzz/x64utils.py
python
get_msr
(uc: Uc, scratch: int, msr: int)
return (edx << 32) | (eax & 0xFFFFFFFF)
fetch the contents of the given model-specific register (MSR). this will clobber some memory at the given scratch address, as it emits some code.
fetch the contents of the given model-specific register (MSR). this will clobber some memory at the given scratch address, as it emits some code.
[ "fetch", "the", "contents", "of", "the", "given", "model", "-", "specific", "register", "(", "MSR", ")", ".", "this", "will", "clobber", "some", "memory", "at", "the", "given", "scratch", "address", "as", "it", "emits", "some", "code", "." ]
def get_msr(uc: Uc, scratch: int, msr: int) -> int: """ fetch the contents of the given model-specific register (MSR). this will clobber some memory at the given scratch address, as it emits some code. """ # save clobbered registers orax = uc.reg_read(UC_X86_REG_RAX) ordx = uc.reg_read(UC_X86_REG_RDX) orcx = uc.reg_read(UC_X86_REG_RCX) orip = uc.reg_read(UC_X86_REG_RIP) # x86: rdmsr buf = b"\x0f\x32" uc.mem_write(scratch, buf) uc.reg_write(UC_X86_REG_RCX, msr & 0xFFFFFFFF) uc.emu_start(scratch, scratch + len(buf), count=1) eax = uc.reg_read(UC_X86_REG_EAX) edx = uc.reg_read(UC_X86_REG_EDX) # restore clobbered registers uc.reg_write(UC_X86_REG_RAX, orax) uc.reg_write(UC_X86_REG_RDX, ordx) uc.reg_write(UC_X86_REG_RCX, orcx) uc.reg_write(UC_X86_REG_RIP, orip) return (edx << 32) | (eax & 0xFFFFFFFF)
[ "def", "get_msr", "(", "uc", ":", "Uc", ",", "scratch", ":", "int", ",", "msr", ":", "int", ")", "->", "int", ":", "# save clobbered registers", "orax", "=", "uc", ".", "reg_read", "(", "UC_X86_REG_RAX", ")", "ordx", "=", "uc", ".", "reg_read", "(", ...
https://github.com/fgsect/unicorefuzz/blob/f5b27a6dda601ef18cb166f79eb121be8e7b88bd/unicorefuzz/x64utils.py#L50-L75
epfl-lts2/pygsp
a3412ce7696c02c8a55439e89d0c9ab8ae863269
pygsp/features.py
python
compute_norm_tig
(g, **kwargs)
return np.linalg.norm(tig, axis=1, ord=2)
r""" Compute the :math:`\ell_2` norm of the Tig. See :func:`compute_tig`. Parameters ---------- g: Filter The filter or filter bank. kwargs: dict Additional parameters to be passed to the :func:`pygsp.filters.Filter.filter` method.
r""" Compute the :math:`\ell_2` norm of the Tig. See :func:`compute_tig`.
[ "r", "Compute", "the", ":", "math", ":", "\\", "ell_2", "norm", "of", "the", "Tig", ".", "See", ":", "func", ":", "compute_tig", "." ]
def compute_norm_tig(g, **kwargs): r""" Compute the :math:`\ell_2` norm of the Tig. See :func:`compute_tig`. Parameters ---------- g: Filter The filter or filter bank. kwargs: dict Additional parameters to be passed to the :func:`pygsp.filters.Filter.filter` method. """ tig = compute_tig(g, **kwargs) return np.linalg.norm(tig, axis=1, ord=2)
[ "def", "compute_norm_tig", "(", "g", ",", "*", "*", "kwargs", ")", ":", "tig", "=", "compute_tig", "(", "g", ",", "*", "*", "kwargs", ")", "return", "np", ".", "linalg", ".", "norm", "(", "tig", ",", "axis", "=", "1", ",", "ord", "=", "2", ")" ...
https://github.com/epfl-lts2/pygsp/blob/a3412ce7696c02c8a55439e89d0c9ab8ae863269/pygsp/features.py#L47-L61
missionpinball/mpf
8e6b74cff4ba06d2fec9445742559c1068b88582
mpf/platforms/pololu/pololu_ticcmd_wrapper.py
python
PololuTiccmdWrapper.set_max_acceleration
(self, acceleration)
Set the max acceleration of the stepper. Args: ---- acceleration (number): The maximum acceleration of the stepper in microsteps per 100 s^2
Set the max acceleration of the stepper.
[ "Set", "the", "max", "acceleration", "of", "the", "stepper", "." ]
def set_max_acceleration(self, acceleration): """Set the max acceleration of the stepper. Args: ---- acceleration (number): The maximum acceleration of the stepper in microsteps per 100 s^2 """ self._ticcmd('--max-accel', str(int(acceleration)))
[ "def", "set_max_acceleration", "(", "self", ",", "acceleration", ")", ":", "self", ".", "_ticcmd", "(", "'--max-accel'", ",", "str", "(", "int", "(", "acceleration", ")", ")", ")" ]
https://github.com/missionpinball/mpf/blob/8e6b74cff4ba06d2fec9445742559c1068b88582/mpf/platforms/pololu/pololu_ticcmd_wrapper.py#L168-L175
InvestmentSystems/static-frame
0b19d6969bf6c17fb0599871aca79eb3b52cf2ed
static_frame/core/frame.py
python
Frame.index
(self)
return self._index
The ``IndexBase`` instance assigned for row labels.
The ``IndexBase`` instance assigned for row labels.
[ "The", "IndexBase", "instance", "assigned", "for", "row", "labels", "." ]
def index(self) -> Index: '''The ``IndexBase`` instance assigned for row labels. ''' return self._index
[ "def", "index", "(", "self", ")", "->", "Index", ":", "return", "self", ".", "_index" ]
https://github.com/InvestmentSystems/static-frame/blob/0b19d6969bf6c17fb0599871aca79eb3b52cf2ed/static_frame/core/frame.py#L4126-L4129
thinkle/gourmet
8af29c8ded24528030e5ae2ea3461f61c1e5a575
gourmet/gtk_extras/dialog_extras.py
python
ImageSelectorDialog.post_dialog
(self)
[]
def post_dialog (self): self.preview = Gtk.Image() self.fsd.set_preview_widget(self.preview) self.fsd.connect('selection-changed',self.update_preview) self.preview.show()
[ "def", "post_dialog", "(", "self", ")", ":", "self", ".", "preview", "=", "Gtk", ".", "Image", "(", ")", "self", ".", "fsd", ".", "set_preview_widget", "(", "self", ".", "preview", ")", "self", ".", "fsd", ".", "connect", "(", "'selection-changed'", ",...
https://github.com/thinkle/gourmet/blob/8af29c8ded24528030e5ae2ea3461f61c1e5a575/gourmet/gtk_extras/dialog_extras.py#L1116-L1120
suavecode/SUAVE
4f83c467c5662b6cc611ce2ab6c0bdd25fd5c0a5
trunk/SUAVE/Plugins/pint/unit.py
python
UnitRegistry.disable_contexts
(self, n=None)
Disable the last n enabled contexts.
Disable the last n enabled contexts.
[ "Disable", "the", "last", "n", "enabled", "contexts", "." ]
def disable_contexts(self, n=None): """Disable the last n enabled contexts. """ if n is None: n = len(self._contexts) self._active_ctx.remove_contexts(n)
[ "def", "disable_contexts", "(", "self", ",", "n", "=", "None", ")", ":", "if", "n", "is", "None", ":", "n", "=", "len", "(", "self", ".", "_contexts", ")", "self", ".", "_active_ctx", ".", "remove_contexts", "(", "n", ")" ]
https://github.com/suavecode/SUAVE/blob/4f83c467c5662b6cc611ce2ab6c0bdd25fd5c0a5/trunk/SUAVE/Plugins/pint/unit.py#L520-L525
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/rsa-3.4.2/rsa/key.py
python
AbstractKey.save_pkcs1
(self, format='PEM')
return method()
Saves the public key in PKCS#1 DER or PEM format. :param format: the format to save; 'PEM' or 'DER' :returns: the DER- or PEM-encoded public key.
Saves the public key in PKCS#1 DER or PEM format.
[ "Saves", "the", "public", "key", "in", "PKCS#1", "DER", "or", "PEM", "format", "." ]
def save_pkcs1(self, format='PEM'): """Saves the public key in PKCS#1 DER or PEM format. :param format: the format to save; 'PEM' or 'DER' :returns: the DER- or PEM-encoded public key. """ methods = { 'PEM': self._save_pkcs1_pem, 'DER': self._save_pkcs1_der, } method = self._assert_format_exists(format, methods) return method()
[ "def", "save_pkcs1", "(", "self", ",", "format", "=", "'PEM'", ")", ":", "methods", "=", "{", "'PEM'", ":", "self", ".", "_save_pkcs1_pem", ",", "'DER'", ":", "self", ".", "_save_pkcs1_der", ",", "}", "method", "=", "self", ".", "_assert_format_exists", ...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/rsa-3.4.2/rsa/key.py#L89-L102
TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials
5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e
tensorflow_dl_models/research/object_detection/core/box_list_ops.py
python
matched_intersection
(boxlist1, boxlist2, scope=None)
Compute intersection areas between corresponding boxes in two boxlists. Args: boxlist1: BoxList holding N boxes boxlist2: BoxList holding N boxes scope: name scope. Returns: a tensor with shape [N] representing pairwise intersections
Compute intersection areas between corresponding boxes in two boxlists.
[ "Compute", "intersection", "areas", "between", "corresponding", "boxes", "in", "two", "boxlists", "." ]
def matched_intersection(boxlist1, boxlist2, scope=None): """Compute intersection areas between corresponding boxes in two boxlists. Args: boxlist1: BoxList holding N boxes boxlist2: BoxList holding N boxes scope: name scope. Returns: a tensor with shape [N] representing pairwise intersections """ with tf.name_scope(scope, 'MatchedIntersection'): y_min1, x_min1, y_max1, x_max1 = tf.split( value=boxlist1.get(), num_or_size_splits=4, axis=1) y_min2, x_min2, y_max2, x_max2 = tf.split( value=boxlist2.get(), num_or_size_splits=4, axis=1) min_ymax = tf.minimum(y_max1, y_max2) max_ymin = tf.maximum(y_min1, y_min2) intersect_heights = tf.maximum(0.0, min_ymax - max_ymin) min_xmax = tf.minimum(x_max1, x_max2) max_xmin = tf.maximum(x_min1, x_min2) intersect_widths = tf.maximum(0.0, min_xmax - max_xmin) return tf.reshape(intersect_heights * intersect_widths, [-1])
[ "def", "matched_intersection", "(", "boxlist1", ",", "boxlist2", ",", "scope", "=", "None", ")", ":", "with", "tf", ".", "name_scope", "(", "scope", ",", "'MatchedIntersection'", ")", ":", "y_min1", ",", "x_min1", ",", "y_max1", ",", "x_max1", "=", "tf", ...
https://github.com/TarrySingh/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials/blob/5bb97d7e3ffd913abddb4cfa7d78a1b4c868890e/tensorflow_dl_models/research/object_detection/core/box_list_ops.py#L228-L250
newfies-dialer/newfies-dialer
8168b3dd43e9f5ce73a2645b3229def1b2815d47
newfies/dialer_campaign/function_def.py
python
get_phonebook_list
(user)
return result_list
Return phonebook list of logged in user
Return phonebook list of logged in user
[ "Return", "phonebook", "list", "of", "logged", "in", "user" ]
def get_phonebook_list(user): """Return phonebook list of logged in user""" phonebook_list = Phonebook.objects.filter(user=user).order_by('id') result_list = [] for phonebook in phonebook_list: contacts_in_phonebook = phonebook.phonebook_contacts() nbcontact = " -> %d contact(s)" % (contacts_in_phonebook) pb_string = phonebook.name + nbcontact result_list.append((phonebook.id, pb_string)) return result_list
[ "def", "get_phonebook_list", "(", "user", ")", ":", "phonebook_list", "=", "Phonebook", ".", "objects", ".", "filter", "(", "user", "=", "user", ")", ".", "order_by", "(", "'id'", ")", "result_list", "=", "[", "]", "for", "phonebook", "in", "phonebook_list...
https://github.com/newfies-dialer/newfies-dialer/blob/8168b3dd43e9f5ce73a2645b3229def1b2815d47/newfies/dialer_campaign/function_def.py#L26-L35
joaomatosf/jexboss
338b531a2a2aee9d294f394086d6718b60526350
jexboss.py
python
is_proxy_ok
()
[]
def is_proxy_ok(): print_and_flush(GREEN + "\n ** Checking proxy: %s **\n\n" % gl_args.proxy) headers = {"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", "Connection": "keep-alive", "User-Agent": get_random_user_agent()} try: r = gl_http_pool.request('GET', gl_args.host, redirect=False, headers=headers) except: print_and_flush(RED + " * Error: Failed to connect to %s using proxy %s.\n" " See logs for more details...\n" %(gl_args.host,gl_args.proxy) + ENDC) logging.warning("Failed to connect to %s using proxy" %gl_args.host, exc_info=traceback) return False if r.status == 407: print_and_flush(RED + " * Error 407: Proxy authentication is required. \n" " Please enter the correct login and password for authentication. \n" " Example: -P http://proxy.com:3128 -L username:password\n" + ENDC) logging.error("Proxy authentication failed") return False elif r.status == 503 or r.status == 502: print_and_flush(RED + " * Error %s: The service %s is not availabel to your proxy. \n" " See logs for more details...\n" %(r.status,gl_args.host)+ENDC) logging.error("Service unavailable to your proxy") return False else: return True
[ "def", "is_proxy_ok", "(", ")", ":", "print_and_flush", "(", "GREEN", "+", "\"\\n ** Checking proxy: %s **\\n\\n\"", "%", "gl_args", ".", "proxy", ")", "headers", "=", "{", "\"Accept\"", ":", "\"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\"", ",", "\"C...
https://github.com/joaomatosf/jexboss/blob/338b531a2a2aee9d294f394086d6718b60526350/jexboss.py#L130-L157
shellphish/ictf-framework
c0384f12060cf47442a52f516c6e78bd722f208a
database/api/scripts.py
python
script_new
()
return json.dumps({"result": "success", "id": script_id})
The ``/script/new`` endpoint requires authentication. It add a script to the database, and initializes its state. Note that this endpoint requires a POST request. It can be reached at ``/script/new?secret=<API_SECRET>``. It requires the following inputs: - name, an optional name of the script. - upload_id, upload which has the payload. - filename, the name of the file - type, the type of the script, currently exploit, benign, getflag, or setflag. - state, enabled, disabled. Defaults to "enabled" - service_id The JSON response looks like:: { "id" : int, "result": ("success", "failure") } :return: a JSON dictionary containing status information.
The ``/script/new`` endpoint requires authentication. It add a script to the database, and initializes its state.
[ "The", "/", "script", "/", "new", "endpoint", "requires", "authentication", ".", "It", "add", "a", "script", "to", "the", "database", "and", "initializes", "its", "state", "." ]
def script_new(): """The ``/script/new`` endpoint requires authentication. It add a script to the database, and initializes its state. Note that this endpoint requires a POST request. It can be reached at ``/script/new?secret=<API_SECRET>``. It requires the following inputs: - name, an optional name of the script. - upload_id, upload which has the payload. - filename, the name of the file - type, the type of the script, currently exploit, benign, getflag, or setflag. - state, enabled, disabled. Defaults to "enabled" - service_id The JSON response looks like:: { "id" : int, "result": ("success", "failure") } :return: a JSON dictionary containing status information. """ upload_id = request.form.get("upload_id") filename = request.form.get("filename") type_ = request.form.get("type") state = request.form.get("state", "enabled") service_id = request.form.get("service_id") if state not in ("enabled", "disabled"): abort(400) cursor = mysql.cursor() # get the team_id from the uploads cursor.execute("""SELECT team_id FROM uploads WHERE id = %s LIMIT 1""", (upload_id,)) result = cursor.fetchone() team_id = result["team_id"] # add the script cursor.execute("""INSERT INTO scripts (type, team_id, service_id, upload_id, filename, current_state) VALUES (%s, %s, %s, %s, %s, %s)""", (type_, team_id, service_id, upload_id, filename, state)) script_id = cursor.lastrowid # set it in the script state log tick_id, _, _, _ = get_current_tick(cursor) cursor.execute("""INSERT INTO script_state (script_id, state, reason, tick_id) VALUES (%s, %s, %s, %s)""", (script_id, state, "initial state", tick_id)) mysql.database.commit() return json.dumps({"result": "success", "id": script_id})
[ "def", "script_new", "(", ")", ":", "upload_id", "=", "request", ".", "form", ".", "get", "(", "\"upload_id\"", ")", "filename", "=", "request", ".", "form", ".", "get", "(", "\"filename\"", ")", "type_", "=", "request", ".", "form", ".", "get", "(", ...
https://github.com/shellphish/ictf-framework/blob/c0384f12060cf47442a52f516c6e78bd722f208a/database/api/scripts.py#L407-L471
cbanack/comic-vine-scraper
8a7071796c61a9483079ad0e9ade56fcb7596bcd
src/py/gui/forms/searchform.py
python
SearchForm.__key_was_released
(self, sender, args)
Called whenever the user releases any key on this form.
Called whenever the user releases any key on this form.
[ "Called", "whenever", "the", "user", "releases", "any", "key", "on", "this", "form", "." ]
def __key_was_released(self, sender, args): ''' Called whenever the user releases any key on this form. ''' # unhighlight the skip button bold whenever the user releases control key if args.KeyCode == Keys.ControlKey: self.__pressing_controlkey = False; self.__skip_button.Text = i18n.get("SearchFormSkip")
[ "def", "__key_was_released", "(", "self", ",", "sender", ",", "args", ")", ":", "# unhighlight the skip button bold whenever the user releases control key", "if", "args", ".", "KeyCode", "==", "Keys", ".", "ControlKey", ":", "self", ".", "__pressing_controlkey", "=", ...
https://github.com/cbanack/comic-vine-scraper/blob/8a7071796c61a9483079ad0e9ade56fcb7596bcd/src/py/gui/forms/searchform.py#L249-L255
divamgupta/image-segmentation-keras
dc830bbd76371aaedbf8cb997bdedca388c544c4
keras_segmentation/predict.py
python
set_video
(inp, video_name)
return cap, video, fps
[]
def set_video(inp, video_name): cap = cv2.VideoCapture(inp) fps = int(cap.get(cv2.CAP_PROP_FPS)) video_width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) video_height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) size = (video_width, video_height) fourcc = cv2.VideoWriter_fourcc(*"XVID") video = cv2.VideoWriter(video_name, fourcc, fps, size) return cap, video, fps
[ "def", "set_video", "(", "inp", ",", "video_name", ")", ":", "cap", "=", "cv2", ".", "VideoCapture", "(", "inp", ")", "fps", "=", "int", "(", "cap", ".", "get", "(", "cv2", ".", "CAP_PROP_FPS", ")", ")", "video_width", "=", "int", "(", "cap", ".", ...
https://github.com/divamgupta/image-segmentation-keras/blob/dc830bbd76371aaedbf8cb997bdedca388c544c4/keras_segmentation/predict.py#L217-L225
tp4a/teleport
1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad
server/www/packages/packages-windows/x86/ldap3/utils/log.py
python
set_library_log_activation_level
(logging_level)
[]
def set_library_log_activation_level(logging_level): if isinstance(logging_level, int): global _logging_level _logging_level = logging_level else: if log_enabled(ERROR): log(ERROR, 'invalid library log activation level <%s> ', logging_level) raise ValueError('invalid library log activation level')
[ "def", "set_library_log_activation_level", "(", "logging_level", ")", ":", "if", "isinstance", "(", "logging_level", ",", "int", ")", ":", "global", "_logging_level", "_logging_level", "=", "logging_level", "else", ":", "if", "log_enabled", "(", "ERROR", ")", ":",...
https://github.com/tp4a/teleport/blob/1fafd34f1f775d2cf80ea4af6e44468d8e0b24ad/server/www/packages/packages-windows/x86/ldap3/utils/log.py#L138-L145
crdoconnor/strictyaml
b456066a763285532fd75cd274d4a275d8499d6c
strictyaml/utils.py
python
is_infinity
(value)
return compile(r"^[-+]?\.?(?:inf|Inf|INF)$").match(value) is not None
Is string a valid representation for positive or negative infinity? Valid formats are: [+/-]inf, [+/-]INF, [+/-]Inf, [+/-].inf, [+/-].INF and [+/-].Inf >>> is_infinity(".inf") True >>> is_infinity("+.INF") True >>> is_infinity("-.Inf") True >>> is_infinity("Inf") True >>> is_infinity("INF") True >>> is_infinity("-INF") True >>> is_infinity("infinitesimal") False
Is string a valid representation for positive or negative infinity?
[ "Is", "string", "a", "valid", "representation", "for", "positive", "or", "negative", "infinity?" ]
def is_infinity(value): """ Is string a valid representation for positive or negative infinity? Valid formats are: [+/-]inf, [+/-]INF, [+/-]Inf, [+/-].inf, [+/-].INF and [+/-].Inf >>> is_infinity(".inf") True >>> is_infinity("+.INF") True >>> is_infinity("-.Inf") True >>> is_infinity("Inf") True >>> is_infinity("INF") True >>> is_infinity("-INF") True >>> is_infinity("infinitesimal") False """ return compile(r"^[-+]?\.?(?:inf|Inf|INF)$").match(value) is not None
[ "def", "is_infinity", "(", "value", ")", ":", "return", "compile", "(", "r\"^[-+]?\\.?(?:inf|Inf|INF)$\"", ")", ".", "match", "(", "value", ")", "is", "not", "None" ]
https://github.com/crdoconnor/strictyaml/blob/b456066a763285532fd75cd274d4a275d8499d6c/strictyaml/utils.py#L135-L163
ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework
cb692f527e4e819b6c228187c5702d990a180043
external/Scripting Engine/Xenotix Python Scripting Engine/Lib/sysconfig.py
python
get_config_var
(name)
return get_config_vars().get(name)
Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name)
Return the value of a single variable using the dictionary returned by 'get_config_vars()'.
[ "Return", "the", "value", "of", "a", "single", "variable", "using", "the", "dictionary", "returned", "by", "get_config_vars", "()", "." ]
def get_config_var(name): """Return the value of a single variable using the dictionary returned by 'get_config_vars()'. Equivalent to get_config_vars().get(name) """ return get_config_vars().get(name)
[ "def", "get_config_var", "(", "name", ")", ":", "return", "get_config_vars", "(", ")", ".", "get", "(", "name", ")" ]
https://github.com/ajinabraham/OWASP-Xenotix-XSS-Exploit-Framework/blob/cb692f527e4e819b6c228187c5702d990a180043/external/Scripting Engine/Xenotix Python Scripting Engine/Lib/sysconfig.py#L516-L522
greatscottgadgets/luna
08b035c9c2b053d7edffb0d220d948b5c2ca927e
luna/gateware/interface/flash.py
python
ECP5ConfigurationFlashInterface.__init__
(self, *, bus, use_cs=False)
Params: bus -- The SPI bus object to connect to. use_cs -- Whether or not the CS line should be passed through to the target device.
Params: bus -- The SPI bus object to connect to. use_cs -- Whether or not the CS line should be passed through to the target device.
[ "Params", ":", "bus", "--", "The", "SPI", "bus", "object", "to", "connect", "to", ".", "use_cs", "--", "Whether", "or", "not", "the", "CS", "line", "should", "be", "passed", "through", "to", "the", "target", "device", "." ]
def __init__(self, *, bus, use_cs=False): """ Params: bus -- The SPI bus object to connect to. use_cs -- Whether or not the CS line should be passed through to the target device. """ self.bus = bus self.use_cs = use_cs # # I/O port # self.sck = Signal() self.sdi = Signal() self.sdo = Signal() self.cs = Signal()
[ "def", "__init__", "(", "self", ",", "*", ",", "bus", ",", "use_cs", "=", "False", ")", ":", "self", ".", "bus", "=", "bus", "self", ".", "use_cs", "=", "use_cs", "#", "# I/O port", "#", "self", ".", "sck", "=", "Signal", "(", ")", "self", ".", ...
https://github.com/greatscottgadgets/luna/blob/08b035c9c2b053d7edffb0d220d948b5c2ca927e/luna/gateware/interface/flash.py#L27-L42
qutebrowser/qutebrowser
3a2aaaacbf97f4bf0c72463f3da94ed2822a5442
qutebrowser/misc/crashdialog.py
python
dump_exception_info
(exc, pages, cmdhist, qobjects)
Dump exception info to stderr. Args: exc: An exception tuple (type, value, traceback) pages: A list of lists of the open pages (URLs as strings) cmdhist: A list with the command history (as strings) qobjects: A list of all QObjects as string.
Dump exception info to stderr.
[ "Dump", "exception", "info", "to", "stderr", "." ]
def dump_exception_info(exc, pages, cmdhist, qobjects): """Dump exception info to stderr. Args: exc: An exception tuple (type, value, traceback) pages: A list of lists of the open pages (URLs as strings) cmdhist: A list with the command history (as strings) qobjects: A list of all QObjects as string. """ print(file=sys.stderr) print("\n\n===== Handling exception with --no-err-windows... =====\n\n", file=sys.stderr) print("\n---- Exceptions ----", file=sys.stderr) print(''.join(traceback.format_exception(*exc)), file=sys.stderr) print("\n---- Version info ----", file=sys.stderr) try: print(version.version_info(), file=sys.stderr) except Exception: traceback.print_exc() print("\n---- Config ----", file=sys.stderr) try: print(config.instance.dump_userconfig(), file=sys.stderr) except Exception: traceback.print_exc() print("\n---- Commandline args ----", file=sys.stderr) print(' '.join(sys.argv[1:]), file=sys.stderr) print("\n---- Open pages ----", file=sys.stderr) print('\n\n'.join('\n'.join(e) for e in pages), file=sys.stderr) print("\n---- Command history ----", file=sys.stderr) print('\n'.join(cmdhist), file=sys.stderr) print("\n---- Objects ----", file=sys.stderr) print(qobjects, file=sys.stderr) print("\n---- Environment ----", file=sys.stderr) try: print(_get_environment_vars(), file=sys.stderr) except Exception: traceback.print_exc()
[ "def", "dump_exception_info", "(", "exc", ",", "pages", ",", "cmdhist", ",", "qobjects", ")", ":", "print", "(", "file", "=", "sys", ".", "stderr", ")", "print", "(", "\"\\n\\n===== Handling exception with --no-err-windows... =====\\n\\n\"", ",", "file", "=", "sys...
https://github.com/qutebrowser/qutebrowser/blob/3a2aaaacbf97f4bf0c72463f3da94ed2822a5442/qutebrowser/misc/crashdialog.py#L641-L677
inasafe/inasafe
355eb2ce63f516b9c26af0c86a24f99e53f63f87
safe/report/extractors/composer.py
python
QGISComposerContext.substitution_map
(self)
return self._substitution_map
Substitution map. :return: Substitution map containing dict mapping used in QGIS Composition template :rtype: dict
Substitution map.
[ "Substitution", "map", "." ]
def substitution_map(self): """Substitution map. :return: Substitution map containing dict mapping used in QGIS Composition template :rtype: dict """ return self._substitution_map
[ "def", "substitution_map", "(", "self", ")", ":", "return", "self", ".", "_substitution_map" ]
https://github.com/inasafe/inasafe/blob/355eb2ce63f516b9c26af0c86a24f99e53f63f87/safe/report/extractors/composer.py#L57-L64
GoSecure/pyrdp
abd8b8762b6d7fd0e49d4a927b529f892b412743
pyrdp/player/gdi/cache.py
python
BrushCache.get
(self, idx: int)
[]
def get(self, idx: int) -> QBrush: if idx in self.entries: return self.entries[idx] else: return None
[ "def", "get", "(", "self", ",", "idx", ":", "int", ")", "->", "QBrush", ":", "if", "idx", "in", "self", ".", "entries", ":", "return", "self", ".", "entries", "[", "idx", "]", "else", ":", "return", "None" ]
https://github.com/GoSecure/pyrdp/blob/abd8b8762b6d7fd0e49d4a927b529f892b412743/pyrdp/player/gdi/cache.py#L89-L93
wxWidgets/Phoenix
b2199e299a6ca6d866aa6f3d0888499136ead9d6
wx/lib/masked/timectrl.py
python
TimeCtrl.SetInsertionPoint
(self, pos)
This override records the specified position and associated cell before calling base class' function. This is necessary to handle the optional spin button, because the insertion point is lost when the focus shifts to the spin button.
This override records the specified position and associated cell before calling base class' function. This is necessary to handle the optional spin button, because the insertion point is lost when the focus shifts to the spin button.
[ "This", "override", "records", "the", "specified", "position", "and", "associated", "cell", "before", "calling", "base", "class", "function", ".", "This", "is", "necessary", "to", "handle", "the", "optional", "spin", "button", "because", "the", "insertion", "poi...
def SetInsertionPoint(self, pos): """ This override records the specified position and associated cell before calling base class' function. This is necessary to handle the optional spin button, because the insertion point is lost when the focus shifts to the spin button. """ ## dbg('TimeCtrl::SetInsertionPoint', pos, indent=1) BaseMaskedTextCtrl.SetInsertionPoint(self, pos) # (causes EVT_TEXT event to fire) self.__posCurrent = self.GetInsertionPoint()
[ "def", "SetInsertionPoint", "(", "self", ",", "pos", ")", ":", "## dbg('TimeCtrl::SetInsertionPoint', pos, indent=1)", "BaseMaskedTextCtrl", ".", "SetInsertionPoint", "(", "self", ",", "pos", ")", "# (causes EVT_TEXT event to fire)", "self", ".", "__posCurrent", "=",...
https://github.com/wxWidgets/Phoenix/blob/b2199e299a6ca6d866aa6f3d0888499136ead9d6/wx/lib/masked/timectrl.py#L1187-L1196
replit-archive/empythoned
977ec10ced29a3541a4973dc2b59910805695752
cpython/Lib/idlelib/AutoComplete.py
python
AutoComplete.fetch_completions
(self, what, mode)
Return a pair of lists of completions for something. The first list is a sublist of the second. Both are sorted. If there is a Python subprocess, get the comp. list there. Otherwise, either fetch_completions() is running in the subprocess itself or it was called in an IDLE EditorWindow before any script had been run. The subprocess environment is that of the most recently run script. If two unrelated modules are being edited some calltips in the current module may be inoperative if the module was not the last to run.
Return a pair of lists of completions for something. The first list is a sublist of the second. Both are sorted.
[ "Return", "a", "pair", "of", "lists", "of", "completions", "for", "something", ".", "The", "first", "list", "is", "a", "sublist", "of", "the", "second", ".", "Both", "are", "sorted", "." ]
def fetch_completions(self, what, mode): """Return a pair of lists of completions for something. The first list is a sublist of the second. Both are sorted. If there is a Python subprocess, get the comp. list there. Otherwise, either fetch_completions() is running in the subprocess itself or it was called in an IDLE EditorWindow before any script had been run. The subprocess environment is that of the most recently run script. If two unrelated modules are being edited some calltips in the current module may be inoperative if the module was not the last to run. """ try: rpcclt = self.editwin.flist.pyshell.interp.rpcclt except: rpcclt = None if rpcclt: return rpcclt.remotecall("exec", "get_the_completion_list", (what, mode), {}) else: if mode == COMPLETE_ATTRIBUTES: if what == "": namespace = __main__.__dict__.copy() namespace.update(__main__.__builtins__.__dict__) bigl = eval("dir()", namespace) bigl.sort() if "__all__" in bigl: smalll = eval("__all__", namespace) smalll.sort() else: smalll = [s for s in bigl if s[:1] != '_'] else: try: entity = self.get_entity(what) bigl = dir(entity) bigl.sort() if "__all__" in bigl: smalll = entity.__all__ smalll.sort() else: smalll = [s for s in bigl if s[:1] != '_'] except: return [], [] elif mode == COMPLETE_FILES: if what == "": what = "." try: expandedpath = os.path.expanduser(what) bigl = os.listdir(expandedpath) bigl.sort() smalll = [s for s in bigl if s[:1] != '.'] except OSError: return [], [] if not smalll: smalll = bigl return smalll, bigl
[ "def", "fetch_completions", "(", "self", ",", "what", ",", "mode", ")", ":", "try", ":", "rpcclt", "=", "self", ".", "editwin", ".", "flist", ".", "pyshell", ".", "interp", ".", "rpcclt", "except", ":", "rpcclt", "=", "None", "if", "rpcclt", ":", "re...
https://github.com/replit-archive/empythoned/blob/977ec10ced29a3541a4973dc2b59910805695752/cpython/Lib/idlelib/AutoComplete.py#L166-L223
pulp/pulp
a0a28d804f997b6f81c391378aff2e4c90183df9
server/pulp/server/controllers/repository.py
python
download_deferred
()
Downloads all the units with entries in the DeferredDownload collection.
Downloads all the units with entries in the DeferredDownload collection.
[ "Downloads", "all", "the", "units", "with", "entries", "in", "the", "DeferredDownload", "collection", "." ]
def download_deferred(): """ Downloads all the units with entries in the DeferredDownload collection. """ task_description = _('Download Cached On-Demand Content') deferred_content_units = _get_deferred_content_units() download_requests = _create_download_requests(deferred_content_units) download_step = LazyUnitDownloadStep( _('on_demand_download'), task_description, download_requests ) download_step.start()
[ "def", "download_deferred", "(", ")", ":", "task_description", "=", "_", "(", "'Download Cached On-Demand Content'", ")", "deferred_content_units", "=", "_get_deferred_content_units", "(", ")", "download_requests", "=", "_create_download_requests", "(", "deferred_content_unit...
https://github.com/pulp/pulp/blob/a0a28d804f997b6f81c391378aff2e4c90183df9/server/pulp/server/controllers/repository.py#L1440-L1452
robcarver17/pysystemtrade
b0385705b7135c52d39cb6d2400feece881bcca9
syscore/text.py
python
sort_dict_by_underscore_length
(other_args)
return sorted_list_of_dicts
Sort dict according to keys and presence of leading underscores :param other_args: dict :return: list of dict. First element is dict of all keys with no leading underscores. Second element is dict of all keys with 1 leading underscore...and so on
Sort dict according to keys and presence of leading underscores
[ "Sort", "dict", "according", "to", "keys", "and", "presence", "of", "leading", "underscores" ]
def sort_dict_by_underscore_length(other_args): """ Sort dict according to keys and presence of leading underscores :param other_args: dict :return: list of dict. First element is dict of all keys with no leading underscores. Second element is dict of all keys with 1 leading underscore...and so on """ other_arg_keys = list(other_args.keys()) other_arg_keys_sorted = sort_keywords_by_underscore_length(other_arg_keys) sorted_list_of_dicts = [] for list_of_args in other_arg_keys_sorted: extracted_dict = dict([(key, other_args[key]) for key in list_of_args]) sorted_list_of_dicts.append(extracted_dict) return sorted_list_of_dicts
[ "def", "sort_dict_by_underscore_length", "(", "other_args", ")", ":", "other_arg_keys", "=", "list", "(", "other_args", ".", "keys", "(", ")", ")", "other_arg_keys_sorted", "=", "sort_keywords_by_underscore_length", "(", "other_arg_keys", ")", "sorted_list_of_dicts", "=...
https://github.com/robcarver17/pysystemtrade/blob/b0385705b7135c52d39cb6d2400feece881bcca9/syscore/text.py#L5-L21
llcshappy/Monocular-3D-Human-Pose
29bc314737d549d112b15d6fdd144338fbf6cab0
3DLabelGen/Left2Right/predict_right_pose_1.py
python
create_model
( session, batch_size )
return model
Create model and initialize it or load its parameters in a session Args session: tensorflow session actions: list of string. Actions to train/test on batch_size: integer. Number of examples in each batch Returns model: The created (or loaded) model Raises ValueError if asked to load a model, but the checkpoint specified by FLAGS.load cannot be found.
Create model and initialize it or load its parameters in a session
[ "Create", "model", "and", "initialize", "it", "or", "load", "its", "parameters", "in", "a", "session" ]
def create_model( session, batch_size ): """ Create model and initialize it or load its parameters in a session Args session: tensorflow session actions: list of string. Actions to train/test on batch_size: integer. Number of examples in each batch Returns model: The created (or loaded) model Raises ValueError if asked to load a model, but the checkpoint specified by FLAGS.load cannot be found. """ model = linear_model.LinearModel( FLAGS.linear_size, FLAGS.num_layers, FLAGS.residual, FLAGS.batch_norm, FLAGS.max_norm, batch_size, FLAGS.learning_rate, summaries_dir, FLAGS.predict_14, dtype=tf.float16 if FLAGS.use_fp16 else tf.float32) if FLAGS.load <= 0: # Create a new model from scratch print("Creating model with fresh parameters.") session.run( tf.global_variables_initializer() ) return model # Load a previously saved model ckpt = tf.train.get_checkpoint_state( train_dir, latest_filename="checkpoint") print( "train_dir", train_dir ) if ckpt and ckpt.model_checkpoint_path: # Check if the specific checkpoint exists if FLAGS.load > 0: if os.path.isfile(os.path.join(train_dir,"checkpoint-{0}.index".format(FLAGS.load))): ckpt_name = os.path.join( os.path.join(train_dir,"checkpoint-{0}".format(FLAGS.load)) ) else: raise ValueError("Asked to load checkpoint {0}, but it does not seem to exist".format(FLAGS.load)) else: ckpt_name = os.path.basename( ckpt.model_checkpoint_path ) print("Loading model {0}".format( ckpt_name )) model.saver.restore( session, ckpt.model_checkpoint_path ) return model else: print("Could not find checkpoint. Aborting.") raise( ValueError, "Checkpoint {0} does not seem to exist".format( ckpt.model_checkpoint_path ) ) return model
[ "def", "create_model", "(", "session", ",", "batch_size", ")", ":", "model", "=", "linear_model", ".", "LinearModel", "(", "FLAGS", ".", "linear_size", ",", "FLAGS", ".", "num_layers", ",", "FLAGS", ".", "residual", ",", "FLAGS", ".", "batch_norm", ",", "F...
https://github.com/llcshappy/Monocular-3D-Human-Pose/blob/29bc314737d549d112b15d6fdd144338fbf6cab0/3DLabelGen/Left2Right/predict_right_pose_1.py#L76-L131
Galvant/InstrumentKit
6d216bd7f8e9ec7918762fe5fb7a306d5bd0eb1f
instruments/newport/newportesp301.py
python
NewportESP301Axis.feedback_configuration
(self)
return int(self._newport_cmd("ZB?", target=self._axis_id)[:-2], 16)
Gets/sets the axis Feedback configuration :type: `int`
Gets/sets the axis Feedback configuration
[ "Gets", "/", "sets", "the", "axis", "Feedback", "configuration" ]
def feedback_configuration(self): """ Gets/sets the axis Feedback configuration :type: `int` """ return int(self._newport_cmd("ZB?", target=self._axis_id)[:-2], 16)
[ "def", "feedback_configuration", "(", "self", ")", ":", "return", "int", "(", "self", ".", "_newport_cmd", "(", "\"ZB?\"", ",", "target", "=", "self", ".", "_axis_id", ")", "[", ":", "-", "2", "]", ",", "16", ")" ]
https://github.com/Galvant/InstrumentKit/blob/6d216bd7f8e9ec7918762fe5fb7a306d5bd0eb1f/instruments/newport/newportesp301.py#L919-L925
iotaledger/iota.py
f596c1ac0d9bcbceda1cf6109cd921943a6599b3
iota/crypto/signing.py
python
KeyIterator.advance
(self)
Advances the generator without creating a key.
Advances the generator without creating a key.
[ "Advances", "the", "generator", "without", "creating", "a", "key", "." ]
def advance(self) -> None: """ Advances the generator without creating a key. """ self.current += self.step
[ "def", "advance", "(", "self", ")", "->", "None", ":", "self", ".", "current", "+=", "self", ".", "step" ]
https://github.com/iotaledger/iota.py/blob/f596c1ac0d9bcbceda1cf6109cd921943a6599b3/iota/crypto/signing.py#L310-L314
SHI-Labs/Decoupled-Classification-Refinement
16202b48eb9cbf79a9b130a98e8c209d4f24693e
faster_rcnn_dcr/symbols/resnet_v1_101_rcnn_dcn_dcr_res2.py
python
resnet_v1_101_rcnn_dcn_dcr_res2.get_symbol
(self, cfg, is_train=True)
return group
[]
def get_symbol(self, cfg, is_train=True): if not is_train: return self.get_symbol_test(cfg, is_train=False) # config alias for convenient num_classes = cfg.dataset.NUM_CLASSES num_reg_classes = (2 if cfg.CLASS_AGNOSTIC else num_classes) num_anchors = cfg.network.NUM_ANCHORS # input init if is_train: data = mx.sym.Variable(name="data") im_info = mx.sym.Variable(name="im_info") gt_boxes = mx.sym.Variable(name="gt_boxes") rpn_label = mx.sym.Variable(name='label') rpn_bbox_target = mx.sym.Variable(name='bbox_target') rpn_bbox_weight = mx.sym.Variable(name='bbox_weight') else: data = mx.sym.Variable(name="data") im_info = mx.sym.Variable(name="im_info") # shared convolutional layers conv_feat, res2 = self.get_resnet_v1_conv4(data) # res5 relu1 = self.get_resnet_v1_conv5(conv_feat) rpn_cls_score, rpn_bbox_pred = self.get_rpn(conv_feat, num_anchors) if is_train: # prepare rpn data rpn_cls_score_reshape = mx.sym.Reshape( data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape") # classification rpn_cls_prob = mx.sym.SoftmaxOutput(data=rpn_cls_score_reshape, label=rpn_label, multi_output=True, normalization='valid', use_ignore=True, ignore_label=-1, name="rpn_cls_prob") # bounding box regression rpn_bbox_loss_ = rpn_bbox_weight * mx.sym.smooth_l1(name='rpn_bbox_loss_', scalar=3.0, data=(rpn_bbox_pred - rpn_bbox_target)) rpn_bbox_loss = mx.sym.MakeLoss(name='rpn_bbox_loss', data=rpn_bbox_loss_, grad_scale=1.0 / cfg.TRAIN.RPN_BATCH_SIZE) # ROI proposal # rpn_cls_act = mx.sym.SoftmaxActivation( # data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_act") rpn_cls_act = mx.sym.softmax( data=rpn_cls_score_reshape, axis=1, name="rpn_cls_act") rpn_cls_act_reshape = mx.sym.Reshape( data=rpn_cls_act, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_act_reshape') if cfg.TRAIN.CXX_PROPOSAL: rois = mx.contrib.sym.Proposal( cls_prob=rpn_cls_act_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS), rpn_pre_nms_top_n=cfg.TRAIN.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TRAIN.RPN_POST_NMS_TOP_N, threshold=cfg.TRAIN.RPN_NMS_THRESH, rpn_min_size=cfg.TRAIN.RPN_MIN_SIZE) else: rois = mx.sym.Custom( cls_prob=rpn_cls_act_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS), rpn_pre_nms_top_n=cfg.TRAIN.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TRAIN.RPN_POST_NMS_TOP_N, threshold=cfg.TRAIN.RPN_NMS_THRESH, rpn_min_size=cfg.TRAIN.RPN_MIN_SIZE) # ROI proposal target gt_boxes_reshape = mx.sym.Reshape(data=gt_boxes, shape=(-1, 5), name='gt_boxes_reshape') rois, label, bbox_target, bbox_weight = mx.sym.Custom(rois=rois, gt_boxes=gt_boxes_reshape, op_type='proposal_target', num_classes=num_reg_classes, batch_images=cfg.TRAIN.BATCH_IMAGES, batch_rois=cfg.TRAIN.BATCH_ROIS, cfg=cPickle.dumps(cfg), fg_fraction=cfg.TRAIN.FG_FRACTION) else: # ROI Proposal rpn_cls_score_reshape = mx.sym.Reshape( data=rpn_cls_score, shape=(0, 2, -1, 0), name="rpn_cls_score_reshape") # rpn_cls_prob = mx.sym.SoftmaxActivation( # data=rpn_cls_score_reshape, mode="channel", name="rpn_cls_prob") rpn_cls_prob = mx.sym.softmax( data=rpn_cls_score_reshape, axis=1, name="rpn_cls_prob") rpn_cls_prob_reshape = mx.sym.Reshape( data=rpn_cls_prob, shape=(0, 2 * num_anchors, -1, 0), name='rpn_cls_prob_reshape') if cfg.TEST.CXX_PROPOSAL: rois = mx.contrib.sym.Proposal( cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', feature_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS), rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N, threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE) else: rois = mx.sym.Custom( cls_prob=rpn_cls_prob_reshape, bbox_pred=rpn_bbox_pred, im_info=im_info, name='rois', op_type='proposal', feat_stride=cfg.network.RPN_FEAT_STRIDE, scales=tuple(cfg.network.ANCHOR_SCALES), ratios=tuple(cfg.network.ANCHOR_RATIOS), rpn_pre_nms_top_n=cfg.TEST.RPN_PRE_NMS_TOP_N, rpn_post_nms_top_n=cfg.TEST.RPN_POST_NMS_TOP_N, threshold=cfg.TEST.RPN_NMS_THRESH, rpn_min_size=cfg.TEST.RPN_MIN_SIZE) conv_new_1 = mx.sym.Convolution(data=relu1, kernel=(1, 1), num_filter=256, name="conv_new_1") conv_new_1_relu = mx.sym.Activation(data=conv_new_1, act_type='relu', name='conv_new_1_relu') offset_t = mx.contrib.sym.DeformablePSROIPooling(name='offset_t', data=conv_new_1_relu, rois=rois, group_size=1, pooled_size=7, sample_per_part=4, no_trans=True, part_size=7, output_dim=256, spatial_scale=0.0625) offset = mx.sym.FullyConnected(name='offset', data=offset_t, num_hidden=7 * 7 * 2, lr_mult=0.01) offset_reshape = mx.sym.Reshape(data=offset, shape=(-1, 2, 7, 7), name="offset_reshape") deformable_roi_pool = mx.contrib.sym.DeformablePSROIPooling(name='deformable_roi_pool', data=conv_new_1_relu, rois=rois, trans=offset_reshape, group_size=1, pooled_size=7, sample_per_part=4, no_trans=False, part_size=7, output_dim=256, spatial_scale=0.0625, trans_std=0.1) # 2 fc fc_new_1 = mx.sym.FullyConnected(name='fc_new_1', data=deformable_roi_pool, num_hidden=1024) fc_new_1_relu = mx.sym.Activation(data=fc_new_1, act_type='relu', name='fc_new_1_relu') fc_new_2 = mx.sym.FullyConnected(name='fc_new_2', data=fc_new_1_relu, num_hidden=1024) fc_new_2_relu = mx.sym.Activation(data=fc_new_2, act_type='relu', name='fc_new_2_relu') # cls_score/bbox_pred cls_score = mx.sym.FullyConnected(name='cls_score', data=fc_new_2_relu, num_hidden=num_classes) bbox_pred = mx.sym.FullyConnected(name='bbox_pred', data=fc_new_2_relu, num_hidden=num_reg_classes * 4) if is_train: if cfg.TRAIN.ENABLE_OHEM: labels_ohem, bbox_weights_ohem = mx.sym.Custom(op_type='BoxAnnotatorOHEM', num_classes=num_classes, num_reg_classes=num_reg_classes, roi_per_img=cfg.TRAIN.BATCH_ROIS_OHEM, cls_score=cls_score, bbox_pred=bbox_pred, labels=label, bbox_targets=bbox_target, bbox_weights=bbox_weight) cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=labels_ohem, normalization='valid', use_ignore=True, ignore_label=-1) bbox_loss_ = bbox_weights_ohem * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target)) bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS_OHEM) rcnn_label = labels_ohem else: cls_prob = mx.sym.SoftmaxOutput(name='cls_prob', data=cls_score, label=label, normalization='valid') bbox_loss_ = bbox_weight * mx.sym.smooth_l1(name='bbox_loss_', scalar=1.0, data=(bbox_pred - bbox_target)) bbox_loss = mx.sym.MakeLoss(name='bbox_loss', data=bbox_loss_, grad_scale=1.0 / cfg.TRAIN.BATCH_ROIS) rcnn_label = label else: cls_prob = mx.sym.softmax(name='cls_prob', data=cls_score) # add dcr-v2 module # TODO: move roi pooling to earlier stage (res3, res4)? if is_train: dcr_rois, dcr_label = mx.sym.Custom( rois=rois, cls_prob=cls_prob, bbox_pred=bbox_pred, im_info=im_info, gt_boxes=gt_boxes_reshape, name='dcr_rois', op_type='dcr_target', cfg=cPickle.dumps(cfg)) else: # dcr_rois = mx.sym.Custom( # rois=rois, bbox_pred=bbox_pred, im_info=im_info, # name='dcr_rois', op_type='dcr_proposal') dcr_rois = mx.sym.Custom( rois=rois, cls_prob=cls_prob, bbox_pred=bbox_pred, im_info=im_info, name='dcr_rois', op_type='dcr_proposal', cfg=cPickle.dumps(cfg)) res2_roi_pool = mx.symbol.ROIPooling( name='res2_roi_pool', data=res2, rois=dcr_rois, pooled_size=(56, 56), spatial_scale=0.25) dcr_branch = self.dcr_branch(res2_roi_pool, dilate=cfg.DCR.dilate) pool1 = mx.sym.Pooling( data=dcr_branch, global_pool=True, kernel=(7, 7), pool_type='avg', name='pool1') flat = mx.sym.Flatten(data=pool1) dcr_fc1 = mx.sym.FullyConnected(data=flat, num_hidden=num_classes, name='dcr_fc1') if is_train: dcr_prob = mx.sym.SoftmaxOutput(name='dcr_prob', data=dcr_fc1, label=dcr_label, normalization='valid') # reshape output rcnn_label = mx.sym.Reshape(data=rcnn_label, shape=(cfg.TRAIN.BATCH_IMAGES, -1), name='label_reshape') dcr_label = mx.sym.Reshape(data=dcr_label, shape=(cfg.TRAIN.BATCH_IMAGES, -1), name='dcr_label_reshape') cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TRAIN.BATCH_IMAGES, -1, num_classes), name='cls_prob_reshape') dcr_prob = mx.sym.Reshape(data=dcr_prob, shape=(cfg.TRAIN.BATCH_IMAGES, -1, num_classes), name='dcr_prob_reshape') bbox_loss = mx.sym.Reshape(data=bbox_loss, shape=(cfg.TRAIN.BATCH_IMAGES, -1, 4 * num_reg_classes), name='bbox_loss_reshape') group = mx.sym.Group([rpn_cls_prob, rpn_bbox_loss, cls_prob, bbox_loss, dcr_prob, mx.sym.BlockGrad(rcnn_label), mx.sym.BlockGrad(dcr_label)]) else: # cls_prob = mx.sym.SoftmaxActivation(name='cls_prob', data=cls_score) # cls_prob = mx.sym.softmax(name='cls_prob', data=cls_score) cls_prob = mx.sym.Reshape(data=cls_prob, shape=(cfg.TEST.BATCH_IMAGES, -1, num_classes), name='cls_prob_reshape') dcr_prob = mx.sym.softmax(name='dcr_prob', data=dcr_fc1) dcr_prob = mx.sym.Reshape(data=dcr_prob, shape=(cfg.TEST.BATCH_IMAGES, -1, num_classes), name='dcr_prob_reshape') bbox_pred = mx.sym.Reshape(data=bbox_pred, shape=(cfg.TEST.BATCH_IMAGES, -1, 4 * num_reg_classes), name='bbox_pred_reshape') group = mx.sym.Group([rois, cls_prob, bbox_pred, dcr_prob]) self.sym = group return group
[ "def", "get_symbol", "(", "self", ",", "cfg", ",", "is_train", "=", "True", ")", ":", "if", "not", "is_train", ":", "return", "self", ".", "get_symbol_test", "(", "cfg", ",", "is_train", "=", "False", ")", "# config alias for convenient", "num_classes", "=",...
https://github.com/SHI-Labs/Decoupled-Classification-Refinement/blob/16202b48eb9cbf79a9b130a98e8c209d4f24693e/faster_rcnn_dcr/symbols/resnet_v1_101_rcnn_dcn_dcr_res2.py#L1481-L1676
wwqgtxx/wwqLyParse
33136508e52821babd9294fdecffbdf02d73a6fc
wwqLyParse/common/js_engine.py
python
VM.call
(self, function_name, *args)
return await self.communicate({ "action": "call", "functionName": function_name, "args": args })
Call a function and return the result. :param str function_name: The function to call. :param args: Function arguments. function_name can include "." to call functions on an object. However, it is called like: .. code-block:: javascript var func = vm.run("function.to.call"); return func(...args); So ``this`` keyword might doesn't work as expected.
Call a function and return the result.
[ "Call", "a", "function", "and", "return", "the", "result", "." ]
async def call(self, function_name, *args): """Call a function and return the result. :param str function_name: The function to call. :param args: Function arguments. function_name can include "." to call functions on an object. However, it is called like: .. code-block:: javascript var func = vm.run("function.to.call"); return func(...args); So ``this`` keyword might doesn't work as expected. """ return await self.communicate({ "action": "call", "functionName": function_name, "args": args })
[ "async", "def", "call", "(", "self", ",", "function_name", ",", "*", "args", ")", ":", "return", "await", "self", ".", "communicate", "(", "{", "\"action\"", ":", "\"call\"", ",", "\"functionName\"", ":", "function_name", ",", "\"args\"", ":", "args", "}",...
https://github.com/wwqgtxx/wwqLyParse/blob/33136508e52821babd9294fdecffbdf02d73a6fc/wwqLyParse/common/js_engine.py#L146-L166
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/serene/preprocessing.py
python
filter_evidence_fn
( example, y_input)
Filter out claims/evidence that have zero length. Args: example: The encoded example y_input: Unused, contains the label, included for API compat Returns: True to preserve example, False to filter it out
Filter out claims/evidence that have zero length.
[ "Filter", "out", "claims", "/", "evidence", "that", "have", "zero", "length", "." ]
def filter_evidence_fn( example, y_input): # pylint: disable=unused-argument """Filter out claims/evidence that have zero length. Args: example: The encoded example y_input: Unused, contains the label, included for API compat Returns: True to preserve example, False to filter it out """ # Bert encodes text in evidence_text_word_ids. # Word embedding model uses evidence_text. if 'evidence_text_word_ids' in example: evidence_length = len(example['evidence_text_word_ids']) else: evidence_length = len(example['evidence_text']) # Explicit length check required. # Implicit length check causes TensorFlow to fail during tracing. if evidence_length != 0: return True else: return False
[ "def", "filter_evidence_fn", "(", "example", ",", "y_input", ")", ":", "# pylint: disable=unused-argument", "# Bert encodes text in evidence_text_word_ids.", "# Word embedding model uses evidence_text.", "if", "'evidence_text_word_ids'", "in", "example", ":", "evidence_length", "="...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/serene/preprocessing.py#L81-L104
dictation-toolbox/aenea
dfd679720b90f92340d4a8cbd4603cab37f18804
client/aenea/alias.py
python
Alias.discard
(self, string_or_alias)
Remove string_or_alias if it is present.
Remove string_or_alias if it is present.
[ "Remove", "string_or_alias", "if", "it", "is", "present", "." ]
def discard(self, string_or_alias): """Remove string_or_alias if it is present.""" self._regex = None sora = string_or_alias if sora in self._map: for alias in self._map[sora]: del self._rmap[alias] del self._map[string_or_alias] if sora in self._rmap: string = self._rmap[sora] self._map[string].remove(sora) del self._rmap[sora]
[ "def", "discard", "(", "self", ",", "string_or_alias", ")", ":", "self", ".", "_regex", "=", "None", "sora", "=", "string_or_alias", "if", "sora", "in", "self", ".", "_map", ":", "for", "alias", "in", "self", ".", "_map", "[", "sora", "]", ":", "del"...
https://github.com/dictation-toolbox/aenea/blob/dfd679720b90f92340d4a8cbd4603cab37f18804/client/aenea/alias.py#L117-L131
WerWolv/EdiZon_CheatsConfigsAndScripts
d16d36c7509c01dca770f402babd83ff2e9ae6e7
Scripts/lib/python3.5/inspect.py
python
getmoduleinfo
(path)
Get the module name, suffix, mode, and module type for a given file.
Get the module name, suffix, mode, and module type for a given file.
[ "Get", "the", "module", "name", "suffix", "mode", "and", "module", "type", "for", "a", "given", "file", "." ]
def getmoduleinfo(path): """Get the module name, suffix, mode, and module type for a given file.""" warnings.warn('inspect.getmoduleinfo() is deprecated', DeprecationWarning, 2) with warnings.catch_warnings(): warnings.simplefilter('ignore', PendingDeprecationWarning) import imp filename = os.path.basename(path) suffixes = [(-len(suffix), suffix, mode, mtype) for suffix, mode, mtype in imp.get_suffixes()] suffixes.sort() # try longest suffixes first, in case they overlap for neglen, suffix, mode, mtype in suffixes: if filename[neglen:] == suffix: return ModuleInfo(filename[:neglen], suffix, mode, mtype)
[ "def", "getmoduleinfo", "(", "path", ")", ":", "warnings", ".", "warn", "(", "'inspect.getmoduleinfo() is deprecated'", ",", "DeprecationWarning", ",", "2", ")", "with", "warnings", ".", "catch_warnings", "(", ")", ":", "warnings", ".", "simplefilter", "(", "'ig...
https://github.com/WerWolv/EdiZon_CheatsConfigsAndScripts/blob/d16d36c7509c01dca770f402babd83ff2e9ae6e7/Scripts/lib/python3.5/inspect.py#L628-L641
exaile/exaile
a7b58996c5c15b3aa7b9975ac13ee8f784ef4689
xlgui/widgets/playback.py
python
SeekProgressBar.do_size_allocate
(self, allocation)
Recalculates the marker points
Recalculates the marker points
[ "Recalculates", "the", "marker", "points" ]
def do_size_allocate(self, allocation): """ Recalculates the marker points """ oldallocation = self.get_allocation() Gtk.EventBox.do_size_allocate(self, allocation) if allocation != oldallocation: for marker in self._points: self._points[marker] = self._get_points(marker)
[ "def", "do_size_allocate", "(", "self", ",", "allocation", ")", ":", "oldallocation", "=", "self", ".", "get_allocation", "(", ")", "Gtk", ".", "EventBox", ".", "do_size_allocate", "(", "self", ",", "allocation", ")", "if", "allocation", "!=", "oldallocation",...
https://github.com/exaile/exaile/blob/a7b58996c5c15b3aa7b9975ac13ee8f784ef4689/xlgui/widgets/playback.py#L790-L800
openimages/dataset
077282972acd0ad8628f1526760ad239a38a8a97
downloader.py
python
download_all_images
(args)
Downloads all images specified in the input file.
Downloads all images specified in the input file.
[ "Downloads", "all", "images", "specified", "in", "the", "input", "file", "." ]
def download_all_images(args): """Downloads all images specified in the input file.""" bucket = boto3.resource( 's3', config=botocore.config.Config( signature_version=botocore.UNSIGNED)).Bucket(BUCKET_NAME) download_folder = args['download_folder'] or os.getcwd() if not os.path.exists(download_folder): os.makedirs(download_folder) try: image_list = list( check_and_homogenize_image_list( read_image_list_file(args['image_list']))) except ValueError as exception: sys.exit(exception) progress_bar = tqdm.tqdm( total=len(image_list), desc='Downloading images', leave=True) with futures.ThreadPoolExecutor( max_workers=args['num_processes']) as executor: all_futures = [ executor.submit(download_one_image, bucket, split, image_id, download_folder) for (split, image_id) in image_list ] for future in futures.as_completed(all_futures): future.result() progress_bar.update(1) progress_bar.close()
[ "def", "download_all_images", "(", "args", ")", ":", "bucket", "=", "boto3", ".", "resource", "(", "'s3'", ",", "config", "=", "botocore", ".", "config", ".", "Config", "(", "signature_version", "=", "botocore", ".", "UNSIGNED", ")", ")", ".", "Bucket", ...
https://github.com/openimages/dataset/blob/077282972acd0ad8628f1526760ad239a38a8a97/downloader.py#L78-L107
google-research/tensorflow_constrained_optimization
723d63f8567aaa988c4ce4761152beee2b462e1d
tensorflow_constrained_optimization/python/rates/deferred_tensor.py
python
DeferredTensorInputList.__add__
(self, other)
return result
Appends two `DeferredTensorInputList`s.
Appends two `DeferredTensorInputList`s.
[ "Appends", "two", "DeferredTensorInputList", "s", "." ]
def __add__(self, other): """Appends two `DeferredTensorInputList`s.""" result = DeferredTensorInputList(self) for element in other: result.append(element) return result
[ "def", "__add__", "(", "self", ",", "other", ")", ":", "result", "=", "DeferredTensorInputList", "(", "self", ")", "for", "element", "in", "other", ":", "result", ".", "append", "(", "element", ")", "return", "result" ]
https://github.com/google-research/tensorflow_constrained_optimization/blob/723d63f8567aaa988c4ce4761152beee2b462e1d/tensorflow_constrained_optimization/python/rates/deferred_tensor.py#L786-L791
chubin/cheat.sh
46d1a5f73c6b88da15d809154245dbf234e9479e
lib/adapter/adapter.py
python
Adapter.save_state
(cls, state)
Save state `state` of the repository. Must be called after the cache clean up.
Save state `state` of the repository. Must be called after the cache clean up.
[ "Save", "state", "state", "of", "the", "repository", ".", "Must", "be", "called", "after", "the", "cache", "clean", "up", "." ]
def save_state(cls, state): """ Save state `state` of the repository. Must be called after the cache clean up. """ local_repository_dir = cls.local_repository_location() state_filename = os.path.join(local_repository_dir, '.cached_revision') open(state_filename, 'w').write(state)
[ "def", "save_state", "(", "cls", ",", "state", ")", ":", "local_repository_dir", "=", "cls", ".", "local_repository_location", "(", ")", "state_filename", "=", "os", ".", "path", ".", "join", "(", "local_repository_dir", ",", "'.cached_revision'", ")", "open", ...
https://github.com/chubin/cheat.sh/blob/46d1a5f73c6b88da15d809154245dbf234e9479e/lib/adapter/adapter.py#L270-L277
google-research/language
61fa7260ac7d690d11ef72ca863e45a37c0bdc80
language/search_agents/muzero/utils.py
python
dcg_score
(relevances: List[float])
return float( sum([ relevance / np.log2(i + 2) for i, relevance in enumerate(relevances) ]))
DCG score computation. Args: relevances: List[float], The list of relevance scores. Returns: The discounted cumulative gain for k == len(relevances).
DCG score computation.
[ "DCG", "score", "computation", "." ]
def dcg_score(relevances: List[float]) -> float: """DCG score computation. Args: relevances: List[float], The list of relevance scores. Returns: The discounted cumulative gain for k == len(relevances). """ return float( sum([ relevance / np.log2(i + 2) for i, relevance in enumerate(relevances) ]))
[ "def", "dcg_score", "(", "relevances", ":", "List", "[", "float", "]", ")", "->", "float", ":", "return", "float", "(", "sum", "(", "[", "relevance", "/", "np", ".", "log2", "(", "i", "+", "2", ")", "for", "i", ",", "relevance", "in", "enumerate", ...
https://github.com/google-research/language/blob/61fa7260ac7d690d11ef72ca863e45a37c0bdc80/language/search_agents/muzero/utils.py#L130-L142
JustDoPython/python-100-day
4e75007195aa4cdbcb899aeb06b9b08996a4606c
wsfriends/wxfriends.py
python
WxFriends.show
(self)
[]
def show(self): labels = self.province_dict.keys() means = self.province_dict.values() index = np.arange(len(labels)) + 1 # 方块宽度 width = 0.5 # 透明度 opacity = 0.4 fig, ax = plt.subplots() rects = ax.bar(index + width, means, width, alpha=opacity, color='blue', label='省份') self.auto_label(rects) ax.set_ylabel('数量', fontproperties=self.get_chinese_font()) ax.set_title('好友省份分布情况', fontproperties=self.get_chinese_font()) ax.set_xticks(index + width) ax.set_xticklabels(labels, fontproperties=self.get_chinese_font()) # 将x轴标签竖列 plt.xticks(rotation=90) # 设置y轴数值上下限 plt.ylim(0, 100) plt.tight_layout() ax.legend() fig.tight_layout() plt.show()
[ "def", "show", "(", "self", ")", ":", "labels", "=", "self", ".", "province_dict", ".", "keys", "(", ")", "means", "=", "self", ".", "province_dict", ".", "values", "(", ")", "index", "=", "np", ".", "arange", "(", "len", "(", "labels", ")", ")", ...
https://github.com/JustDoPython/python-100-day/blob/4e75007195aa4cdbcb899aeb06b9b08996a4606c/wsfriends/wxfriends.py#L76-L99
TengXiaoDai/DistributedCrawling
f5c2439e6ce68dd9b49bde084d76473ff9ed4963
Lib/site-packages/setuptools/command/bdist_egg.py
python
bdist_egg.copy_metadata_to
(self, target_dir)
Copy metadata (egg info) to the target_dir
Copy metadata (egg info) to the target_dir
[ "Copy", "metadata", "(", "egg", "info", ")", "to", "the", "target_dir" ]
def copy_metadata_to(self, target_dir): "Copy metadata (egg info) to the target_dir" # normalize the path (so that a forward-slash in egg_info will # match using startswith below) norm_egg_info = os.path.normpath(self.egg_info) prefix = os.path.join(norm_egg_info, '') for path in self.ei_cmd.filelist.files: if path.startswith(prefix): target = os.path.join(target_dir, path[len(prefix):]) ensure_directory(target) self.copy_file(path, target)
[ "def", "copy_metadata_to", "(", "self", ",", "target_dir", ")", ":", "# normalize the path (so that a forward-slash in egg_info will", "# match using startswith below)", "norm_egg_info", "=", "os", ".", "path", ".", "normpath", "(", "self", ".", "egg_info", ")", "prefix",...
https://github.com/TengXiaoDai/DistributedCrawling/blob/f5c2439e6ce68dd9b49bde084d76473ff9ed4963/Lib/site-packages/setuptools/command/bdist_egg.py#L286-L296
aws-samples/aws-kube-codesuite
ab4e5ce45416b83bffb947ab8d234df5437f4fca
src/urllib3/_collections.py
python
HTTPHeaderDict.add
(self, key, val)
Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz'
Adds a (name, value) pair, doesn't overwrite the value if it already exists.
[ "Adds", "a", "(", "name", "value", ")", "pair", "doesn", "t", "overwrite", "the", "value", "if", "it", "already", "exists", "." ]
def add(self, key, val): """Adds a (name, value) pair, doesn't overwrite the value if it already exists. >>> headers = HTTPHeaderDict(foo='bar') >>> headers.add('Foo', 'baz') >>> headers['foo'] 'bar, baz' """ key_lower = key.lower() new_vals = [key, val] # Keep the common case aka no item present as fast as possible vals = self._container.setdefault(key_lower, new_vals) if new_vals is not vals: vals.append(val)
[ "def", "add", "(", "self", ",", "key", ",", "val", ")", ":", "key_lower", "=", "key", ".", "lower", "(", ")", "new_vals", "=", "[", "key", ",", "val", "]", "# Keep the common case aka no item present as fast as possible", "vals", "=", "self", ".", "_containe...
https://github.com/aws-samples/aws-kube-codesuite/blob/ab4e5ce45416b83bffb947ab8d234df5437f4fca/src/urllib3/_collections.py#L208-L222
rwl/PYPOWER
f5be0406aa54dcebded075de075454f99e2a46e6
pypower/dSbus_dV.py
python
dSbus_dV
(Ybus, V)
return dS_dVm, dS_dVa
Computes partial derivatives of power injection w.r.t. voltage. Returns two matrices containing partial derivatives of the complex bus power injections w.r.t voltage magnitude and voltage angle respectively (for all buses). If C{Ybus} is a sparse matrix, the return values will be also. The following explains the expressions used to form the matrices:: S = diag(V) * conj(Ibus) = diag(conj(Ibus)) * V Partials of V & Ibus w.r.t. voltage magnitudes:: dV/dVm = diag(V / abs(V)) dI/dVm = Ybus * dV/dVm = Ybus * diag(V / abs(V)) Partials of V & Ibus w.r.t. voltage angles:: dV/dVa = j * diag(V) dI/dVa = Ybus * dV/dVa = Ybus * j * diag(V) Partials of S w.r.t. voltage magnitudes:: dS/dVm = diag(V) * conj(dI/dVm) + diag(conj(Ibus)) * dV/dVm = diag(V) * conj(Ybus * diag(V / abs(V))) + conj(diag(Ibus)) * diag(V / abs(V)) Partials of S w.r.t. voltage angles:: dS/dVa = diag(V) * conj(dI/dVa) + diag(conj(Ibus)) * dV/dVa = diag(V) * conj(Ybus * j * diag(V)) + conj(diag(Ibus)) * j * diag(V) = -j * diag(V) * conj(Ybus * diag(V)) + conj(diag(Ibus)) * j * diag(V) = j * diag(V) * conj(diag(Ibus) - Ybus * diag(V)) For more details on the derivations behind the derivative code used in PYPOWER information, see: [TN2] R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and their Derivatives using Complex Matrix Notation", MATPOWER Technical Note 2, February 2010. U{http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf} @author: Ray Zimmerman (PSERC Cornell)
Computes partial derivatives of power injection w.r.t. voltage.
[ "Computes", "partial", "derivatives", "of", "power", "injection", "w", ".", "r", ".", "t", ".", "voltage", "." ]
def dSbus_dV(Ybus, V): """Computes partial derivatives of power injection w.r.t. voltage. Returns two matrices containing partial derivatives of the complex bus power injections w.r.t voltage magnitude and voltage angle respectively (for all buses). If C{Ybus} is a sparse matrix, the return values will be also. The following explains the expressions used to form the matrices:: S = diag(V) * conj(Ibus) = diag(conj(Ibus)) * V Partials of V & Ibus w.r.t. voltage magnitudes:: dV/dVm = diag(V / abs(V)) dI/dVm = Ybus * dV/dVm = Ybus * diag(V / abs(V)) Partials of V & Ibus w.r.t. voltage angles:: dV/dVa = j * diag(V) dI/dVa = Ybus * dV/dVa = Ybus * j * diag(V) Partials of S w.r.t. voltage magnitudes:: dS/dVm = diag(V) * conj(dI/dVm) + diag(conj(Ibus)) * dV/dVm = diag(V) * conj(Ybus * diag(V / abs(V))) + conj(diag(Ibus)) * diag(V / abs(V)) Partials of S w.r.t. voltage angles:: dS/dVa = diag(V) * conj(dI/dVa) + diag(conj(Ibus)) * dV/dVa = diag(V) * conj(Ybus * j * diag(V)) + conj(diag(Ibus)) * j * diag(V) = -j * diag(V) * conj(Ybus * diag(V)) + conj(diag(Ibus)) * j * diag(V) = j * diag(V) * conj(diag(Ibus) - Ybus * diag(V)) For more details on the derivations behind the derivative code used in PYPOWER information, see: [TN2] R. D. Zimmerman, "AC Power Flows, Generalized OPF Costs and their Derivatives using Complex Matrix Notation", MATPOWER Technical Note 2, February 2010. U{http://www.pserc.cornell.edu/matpower/TN2-OPF-Derivatives.pdf} @author: Ray Zimmerman (PSERC Cornell) """ ib = range(len(V)) if issparse(Ybus): Ibus = Ybus * V diagV = sparse((V, (ib, ib))) diagIbus = sparse((Ibus, (ib, ib))) diagVnorm = sparse((V / abs(V), (ib, ib))) else: Ibus = Ybus * asmatrix(V).T diagV = asmatrix(diag(V)) diagIbus = asmatrix(diag( asarray(Ibus).flatten() )) diagVnorm = asmatrix(diag(V / abs(V))) dS_dVm = diagV * conj(Ybus * diagVnorm) + conj(diagIbus) * diagVnorm dS_dVa = 1j * diagV * conj(diagIbus - Ybus * diagV) return dS_dVm, dS_dVa
[ "def", "dSbus_dV", "(", "Ybus", ",", "V", ")", ":", "ib", "=", "range", "(", "len", "(", "V", ")", ")", "if", "issparse", "(", "Ybus", ")", ":", "Ibus", "=", "Ybus", "*", "V", "diagV", "=", "sparse", "(", "(", "V", ",", "(", "ib", ",", "ib"...
https://github.com/rwl/PYPOWER/blob/f5be0406aa54dcebded075de075454f99e2a46e6/pypower/dSbus_dV.py#L12-L71
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/xml/sax/saxutils.py
python
XMLFilterBase.parse
(self, source)
[]
def parse(self, source): self._parent.setContentHandler(self) self._parent.setErrorHandler(self) self._parent.setEntityResolver(self) self._parent.setDTDHandler(self) self._parent.parse(source)
[ "def", "parse", "(", "self", ",", "source", ")", ":", "self", ".", "_parent", ".", "setContentHandler", "(", "self", ")", "self", ".", "_parent", ".", "setErrorHandler", "(", "self", ")", "self", ".", "_parent", ".", "setEntityResolver", "(", "self", ")"...
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/xml/sax/saxutils.py#L278-L283
aleju/imgaug
0101108d4fed06bc5056c4a03e2bcb0216dac326
imgaug/augmenters/blend.py
python
FrequencyNoiseAlpha
(exponent=(-4, 4), first=None, second=None, per_channel=False, size_px_max=(4, 16), upscale_method=None, iterations=(1, 3), aggregation_method=["avg", "max"], sigmoid=0.5, sigmoid_thresh=None, seed=None, name=None, random_state="deprecated", deterministic="deprecated")
return BlendAlphaFrequencyNoise( exponent=exponent, foreground=first, background=second, per_channel=per_channel, size_px_max=size_px_max, upscale_method=upscale_method, iterations=iterations, aggregation_method=aggregation_method, sigmoid=sigmoid, sigmoid_thresh=sigmoid_thresh, seed=seed, name=name, random_state=random_state, deterministic=deterministic)
See :class:`BlendAlphaFrequencyNoise`. Deprecated since 0.4.0.
See :class:`BlendAlphaFrequencyNoise`.
[ "See", ":", "class", ":", "BlendAlphaFrequencyNoise", "." ]
def FrequencyNoiseAlpha(exponent=(-4, 4), first=None, second=None, per_channel=False, size_px_max=(4, 16), upscale_method=None, iterations=(1, 3), aggregation_method=["avg", "max"], sigmoid=0.5, sigmoid_thresh=None, seed=None, name=None, random_state="deprecated", deterministic="deprecated"): """See :class:`BlendAlphaFrequencyNoise`. Deprecated since 0.4.0. """ # pylint: disable=invalid-name, dangerous-default-value return BlendAlphaFrequencyNoise( exponent=exponent, foreground=first, background=second, per_channel=per_channel, size_px_max=size_px_max, upscale_method=upscale_method, iterations=iterations, aggregation_method=aggregation_method, sigmoid=sigmoid, sigmoid_thresh=sigmoid_thresh, seed=seed, name=name, random_state=random_state, deterministic=deterministic)
[ "def", "FrequencyNoiseAlpha", "(", "exponent", "=", "(", "-", "4", ",", "4", ")", ",", "first", "=", "None", ",", "second", "=", "None", ",", "per_channel", "=", "False", ",", "size_px_max", "=", "(", "4", ",", "16", ")", ",", "upscale_method", "=", ...
https://github.com/aleju/imgaug/blob/0101108d4fed06bc5056c4a03e2bcb0216dac326/imgaug/augmenters/blend.py#L4023-L4048
sabri-zaki/EasY_HaCk
2a39ac384dd0d6fc51c0dd22e8d38cece683fdb9
.modules/.sqlmap/thirdparty/fcrypt/fcrypt.py
python
_test
()
return doctest.testmod(fcrypt)
Run doctest on fcrypt module.
Run doctest on fcrypt module.
[ "Run", "doctest", "on", "fcrypt", "module", "." ]
def _test(): """Run doctest on fcrypt module.""" import doctest, fcrypt return doctest.testmod(fcrypt)
[ "def", "_test", "(", ")", ":", "import", "doctest", ",", "fcrypt", "return", "doctest", ".", "testmod", "(", "fcrypt", ")" ]
https://github.com/sabri-zaki/EasY_HaCk/blob/2a39ac384dd0d6fc51c0dd22e8d38cece683fdb9/.modules/.sqlmap/thirdparty/fcrypt/fcrypt.py#L609-L612
kubernetes-client/python
47b9da9de2d02b2b7a34fbe05afb44afd130d73a
kubernetes/client/models/v1_container.py
python
V1Container.__ne__
(self, other)
return self.to_dict() != other.to_dict()
Returns true if both objects are not equal
Returns true if both objects are not equal
[ "Returns", "true", "if", "both", "objects", "are", "not", "equal" ]
def __ne__(self, other): """Returns true if both objects are not equal""" if not isinstance(other, V1Container): return True return self.to_dict() != other.to_dict()
[ "def", "__ne__", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "V1Container", ")", ":", "return", "True", "return", "self", ".", "to_dict", "(", ")", "!=", "other", ".", "to_dict", "(", ")" ]
https://github.com/kubernetes-client/python/blob/47b9da9de2d02b2b7a34fbe05afb44afd130d73a/kubernetes/client/models/v1_container.py#L694-L699
nsacyber/WALKOFF
52d3311abe99d64cd2a902eb998c5e398efe0e07
common/walkoff_client/walkoff_client/api/apps_api.py
python
AppsApi.create_app_api
(self, app_api, **kwargs)
return self.create_app_api_with_http_info(app_api, **kwargs)
Create app api # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_app_api(app_api, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param AppApi app_api: The app api object to be created (required) :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: AppApi If the method is called asynchronously, returns the request thread.
Create app api # noqa: E501
[ "Create", "app", "api", "#", "noqa", ":", "E501" ]
def create_app_api(self, app_api, **kwargs): # noqa: E501 """Create app api # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True >>> thread = api.create_app_api(app_api, async_req=True) >>> result = thread.get() :param async_req bool: execute request asynchronously :param AppApi app_api: The app api object to be created (required) :param _preload_content: if False, the urllib3.HTTPResponse object will be returned without reading/decoding response data. Default is True. :param _request_timeout: timeout setting for this request. If one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. :return: AppApi If the method is called asynchronously, returns the request thread. """ kwargs['_return_http_data_only'] = True return self.create_app_api_with_http_info(app_api, **kwargs)
[ "def", "create_app_api", "(", "self", ",", "app_api", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "kwargs", "[", "'_return_http_data_only'", "]", "=", "True", "return", "self", ".", "create_app_api_with_http_info", "(", "app_api", ",", "*", "*", "kwargs...
https://github.com/nsacyber/WALKOFF/blob/52d3311abe99d64cd2a902eb998c5e398efe0e07/common/walkoff_client/walkoff_client/api/apps_api.py#L40-L62
ktbyers/pynet
f01ca44afe1db1e64828fc93028f67410174719e
pyth_ans_ecourse/class8/ex5_db_show_version.py
python
main
()
Use Netmiko to connect to each of the devices in the database. Execute 'show version' on each device.
Use Netmiko to connect to each of the devices in the database. Execute 'show version' on each device.
[ "Use", "Netmiko", "to", "connect", "to", "each", "of", "the", "devices", "in", "the", "database", ".", "Execute", "show", "version", "on", "each", "device", "." ]
def main(): ''' Use Netmiko to connect to each of the devices in the database. Execute 'show version' on each device. ''' django.setup() start_time = datetime.now() devices = NetworkDevice.objects.all() for a_device in devices: show_version(a_device) elapsed_time = datetime.now() - start_time print "Elapsed time: {}".format(elapsed_time)
[ "def", "main", "(", ")", ":", "django", ".", "setup", "(", ")", "start_time", "=", "datetime", ".", "now", "(", ")", "devices", "=", "NetworkDevice", ".", "objects", ".", "all", "(", ")", "for", "a_device", "in", "devices", ":", "show_version", "(", ...
https://github.com/ktbyers/pynet/blob/f01ca44afe1db1e64828fc93028f67410174719e/pyth_ans_ecourse/class8/ex5_db_show_version.py#L29-L42
oilshell/oil
94388e7d44a9ad879b12615f6203b38596b5a2d3
Python-2.7.13/Lib/idlelib/configDialog.py
python
ConfigDialog.AddChangedItem
(self, typ, section, item, value)
[]
def AddChangedItem(self, typ, section, item, value): value = str(value) #make sure we use a string if section not in self.changedItems[typ]: self.changedItems[typ][section] = {} self.changedItems[typ][section][item] = value
[ "def", "AddChangedItem", "(", "self", ",", "typ", ",", "section", ",", "item", ",", "value", ")", ":", "value", "=", "str", "(", "value", ")", "#make sure we use a string", "if", "section", "not", "in", "self", ".", "changedItems", "[", "typ", "]", ":", ...
https://github.com/oilshell/oil/blob/94388e7d44a9ad879b12615f6203b38596b5a2d3/Python-2.7.13/Lib/idlelib/configDialog.py#L623-L627
entropy1337/infernal-twin
10995cd03312e39a48ade0f114ebb0ae3a711bb8
Modules/build/reportlab/src/reportlab/graphics/charts/axes.py
python
sample5c
()
return drawing
Sample drawing, xvalue/yvalue axes, y connected at right of x.
Sample drawing, xvalue/yvalue axes, y connected at right of x.
[ "Sample", "drawing", "xvalue", "/", "yvalue", "axes", "y", "connected", "at", "right", "of", "x", "." ]
def sample5c(): "Sample drawing, xvalue/yvalue axes, y connected at right of x." drawing = Drawing(400, 200) data = [(10, 20, 30, 42)] xAxis = XValueAxis() xAxis.setPosition(50, 50, 300) xAxis.configure(data) yAxis = YValueAxis() yAxis.setPosition(50, 50, 125) yAxis.joinAxis = xAxis yAxis.joinAxisMode = 'right' yAxis.configure(data) drawing.add(xAxis) drawing.add(yAxis) return drawing
[ "def", "sample5c", "(", ")", ":", "drawing", "=", "Drawing", "(", "400", ",", "200", ")", "data", "=", "[", "(", "10", ",", "20", ",", "30", ",", "42", ")", "]", "xAxis", "=", "XValueAxis", "(", ")", "xAxis", ".", "setPosition", "(", "50", ",",...
https://github.com/entropy1337/infernal-twin/blob/10995cd03312e39a48ade0f114ebb0ae3a711bb8/Modules/build/reportlab/src/reportlab/graphics/charts/axes.py#L2161-L2175
cloudera/hue
23f02102d4547c17c32bd5ea0eb24e9eadd657a4
desktop/core/ext-py/pysaml2-4.9.0/src/saml2/assertion.py
python
_authn_context_decl_ref
(decl_ref, authn_auth=None)
return factory(saml.AuthnContext, authn_context_decl_ref=decl_ref, authenticating_authority=factory( saml.AuthenticatingAuthority, text=authn_auth))
Construct the authn context with a authn context declaration reference :param decl_ref: The authn context declaration reference :param authn_auth: Authenticating Authority :return: An AuthnContext instance
Construct the authn context with a authn context declaration reference :param decl_ref: The authn context declaration reference :param authn_auth: Authenticating Authority :return: An AuthnContext instance
[ "Construct", "the", "authn", "context", "with", "a", "authn", "context", "declaration", "reference", ":", "param", "decl_ref", ":", "The", "authn", "context", "declaration", "reference", ":", "param", "authn_auth", ":", "Authenticating", "Authority", ":", "return"...
def _authn_context_decl_ref(decl_ref, authn_auth=None): """ Construct the authn context with a authn context declaration reference :param decl_ref: The authn context declaration reference :param authn_auth: Authenticating Authority :return: An AuthnContext instance """ return factory(saml.AuthnContext, authn_context_decl_ref=decl_ref, authenticating_authority=factory( saml.AuthenticatingAuthority, text=authn_auth))
[ "def", "_authn_context_decl_ref", "(", "decl_ref", ",", "authn_auth", "=", "None", ")", ":", "return", "factory", "(", "saml", ".", "AuthnContext", ",", "authn_context_decl_ref", "=", "decl_ref", ",", "authenticating_authority", "=", "factory", "(", "saml", ".", ...
https://github.com/cloudera/hue/blob/23f02102d4547c17c32bd5ea0eb24e9eadd657a4/desktop/core/ext-py/pysaml2-4.9.0/src/saml2/assertion.py#L620-L630
KoreLogicSecurity/mastiff
04d569e4fa59513572e77c74b049cad82f9b0310
mastiff/plugins/output/__init__.py
python
table.addtitle
(self, title=None)
Add a title to the table.
Add a title to the table.
[ "Add", "a", "title", "to", "the", "table", "." ]
def addtitle(self, title=None): """ Add a title to the table. """ if title is not None: self.title = title else: self.title = ''
[ "def", "addtitle", "(", "self", ",", "title", "=", "None", ")", ":", "if", "title", "is", "not", "None", ":", "self", ".", "title", "=", "title", "else", ":", "self", ".", "title", "=", "''" ]
https://github.com/KoreLogicSecurity/mastiff/blob/04d569e4fa59513572e77c74b049cad82f9b0310/mastiff/plugins/output/__init__.py#L87-L92
nschloe/quadpy
c4c076d8ddfa968486a2443a95e2fb3780dcde0f
src/quadpy/t2/_lyness_jespersen.py
python
lyness_jespersen_02
()
return T2Scheme("Lyness-Jespersen 2", d, 2, source)
[]
def lyness_jespersen_02(): d = { "centroid": [[frac(3, 4)]], "vertex": [[frac(1, 12)]], } return T2Scheme("Lyness-Jespersen 2", d, 2, source)
[ "def", "lyness_jespersen_02", "(", ")", ":", "d", "=", "{", "\"centroid\"", ":", "[", "[", "frac", "(", "3", ",", "4", ")", "]", "]", ",", "\"vertex\"", ":", "[", "[", "frac", "(", "1", ",", "12", ")", "]", "]", ",", "}", "return", "T2Scheme", ...
https://github.com/nschloe/quadpy/blob/c4c076d8ddfa968486a2443a95e2fb3780dcde0f/src/quadpy/t2/_lyness_jespersen.py#L27-L32
ecdavis/pants
88129d24020e95b71e8d0260a111dc0b457b0676
pants/contrib/irc.py
python
BaseIRC.send_command
(self, command, *args, **kwargs)
Send a command to the remote endpoint. ========= ======== ============ Argument Default Description ========= ======== ============ command The command to send. \*args *Optional.* A list of arguments to send with the command. _prefix None *Optional.* A string that, if provided, will be prepended to the command string before it's sent to the server. ========= ======== ============
Send a command to the remote endpoint.
[ "Send", "a", "command", "to", "the", "remote", "endpoint", "." ]
def send_command(self, command, *args, **kwargs): """ Send a command to the remote endpoint. ========= ======== ============ Argument Default Description ========= ======== ============ command The command to send. \*args *Optional.* A list of arguments to send with the command. _prefix None *Optional.* A string that, if provided, will be prepended to the command string before it's sent to the server. ========= ======== ============ """ if args: args = list(args) for i in xrange(len(args)): arg = args[i] if not isinstance(arg, basestring): args[i] = str(arg) if not args[-1].startswith(':'): args[-1] = ':%s' % args[-1] out = '%s %s\r\n' % (command, ' '.join(args)) else: out = '%s\r\n' % command if '_prefix' in kwargs and kwargs['_prefix']: out = '%s %s' % (kwargs['_prefix'], out) elif self.prefix: out = '%s %s' % (self.prefix, out) # Send it. log.debug('\x1B[0;32m>> %s\x1B[0m' % out.rstrip()) self.write(out.encode(self.encoding))
[ "def", "send_command", "(", "self", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "args", ":", "args", "=", "list", "(", "args", ")", "for", "i", "in", "xrange", "(", "len", "(", "args", ")", ")", ":", "arg", "=", ...
https://github.com/ecdavis/pants/blob/88129d24020e95b71e8d0260a111dc0b457b0676/pants/contrib/irc.py#L172-L206
OpenMDAO/OpenMDAO
f47eb5485a0bb5ea5d2ae5bd6da4b94dc6b296bd
openmdao/components/linear_system_comp.py
python
LinearSystemComp.__init__
(self, **kwargs)
Intialize the LinearSystemComp component.
Intialize the LinearSystemComp component.
[ "Intialize", "the", "LinearSystemComp", "component", "." ]
def __init__(self, **kwargs): """ Intialize the LinearSystemComp component. """ super().__init__(**kwargs) self._lup = None self._no_check_partials = True
[ "def", "__init__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "__init__", "(", "*", "*", "kwargs", ")", "self", ".", "_lup", "=", "None", "self", ".", "_no_check_partials", "=", "True" ]
https://github.com/OpenMDAO/OpenMDAO/blob/f47eb5485a0bb5ea5d2ae5bd6da4b94dc6b296bd/openmdao/components/linear_system_comp.py#L28-L35
clinton-hall/nzbToMedia
27669389216902d1085660167e7bda0bd8527ecf
libs/common/pytz/tzinfo.py
python
StaticTzInfo.localize
(self, dt, is_dst=False)
return dt.replace(tzinfo=self)
Convert naive time to local time
Convert naive time to local time
[ "Convert", "naive", "time", "to", "local", "time" ]
def localize(self, dt, is_dst=False): '''Convert naive time to local time''' if dt.tzinfo is not None: raise ValueError('Not naive datetime (tzinfo is already set)') return dt.replace(tzinfo=self)
[ "def", "localize", "(", "self", ",", "dt", ",", "is_dst", "=", "False", ")", ":", "if", "dt", ".", "tzinfo", "is", "not", "None", ":", "raise", "ValueError", "(", "'Not naive datetime (tzinfo is already set)'", ")", "return", "dt", ".", "replace", "(", "tz...
https://github.com/clinton-hall/nzbToMedia/blob/27669389216902d1085660167e7bda0bd8527ecf/libs/common/pytz/tzinfo.py#L112-L116
microsoft/MPNet
081523a788c1556f28dd90cbc629810f48b083fb
pretraining/fairseq/data/concat_dataset.py
python
ConcatDataset.ordered_indices
(self)
return np.argsort(self.sizes)
Returns indices sorted by length. So less padding is needed.
Returns indices sorted by length. So less padding is needed.
[ "Returns", "indices", "sorted", "by", "length", ".", "So", "less", "padding", "is", "needed", "." ]
def ordered_indices(self): """ Returns indices sorted by length. So less padding is needed. """ return np.argsort(self.sizes)
[ "def", "ordered_indices", "(", "self", ")", ":", "return", "np", ".", "argsort", "(", "self", ".", "sizes", ")" ]
https://github.com/microsoft/MPNet/blob/081523a788c1556f28dd90cbc629810f48b083fb/pretraining/fairseq/data/concat_dataset.py#L87-L91
wistbean/learn_python3_spider
73c873f4845f4385f097e5057407d03dd37a117b
stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/urllib3/contrib/_securetransport/low_level.py
python
_temporary_keychain
()
return keychain, tempdirectory
This function creates a temporary Mac keychain that we can use to work with credentials. This keychain uses a one-time password and a temporary file to store the data. We expect to have one keychain per socket. The returned SecKeychainRef must be freed by the caller, including calling SecKeychainDelete. Returns a tuple of the SecKeychainRef and the path to the temporary directory that contains it.
This function creates a temporary Mac keychain that we can use to work with credentials. This keychain uses a one-time password and a temporary file to store the data. We expect to have one keychain per socket. The returned SecKeychainRef must be freed by the caller, including calling SecKeychainDelete.
[ "This", "function", "creates", "a", "temporary", "Mac", "keychain", "that", "we", "can", "use", "to", "work", "with", "credentials", ".", "This", "keychain", "uses", "a", "one", "-", "time", "password", "and", "a", "temporary", "file", "to", "store", "the"...
def _temporary_keychain(): """ This function creates a temporary Mac keychain that we can use to work with credentials. This keychain uses a one-time password and a temporary file to store the data. We expect to have one keychain per socket. The returned SecKeychainRef must be freed by the caller, including calling SecKeychainDelete. Returns a tuple of the SecKeychainRef and the path to the temporary directory that contains it. """ # Unfortunately, SecKeychainCreate requires a path to a keychain. This # means we cannot use mkstemp to use a generic temporary file. Instead, # we're going to create a temporary directory and a filename to use there. # This filename will be 8 random bytes expanded into base64. We also need # some random bytes to password-protect the keychain we're creating, so we # ask for 40 random bytes. random_bytes = os.urandom(40) filename = base64.b16encode(random_bytes[:8]).decode('utf-8') password = base64.b16encode(random_bytes[8:]) # Must be valid UTF-8 tempdirectory = tempfile.mkdtemp() keychain_path = os.path.join(tempdirectory, filename).encode('utf-8') # We now want to create the keychain itself. keychain = Security.SecKeychainRef() status = Security.SecKeychainCreate( keychain_path, len(password), password, False, None, ctypes.byref(keychain) ) _assert_no_error(status) # Having created the keychain, we want to pass it off to the caller. return keychain, tempdirectory
[ "def", "_temporary_keychain", "(", ")", ":", "# Unfortunately, SecKeychainCreate requires a path to a keychain. This", "# means we cannot use mkstemp to use a generic temporary file. Instead,", "# we're going to create a temporary directory and a filename to use there.", "# This filename will be 8 r...
https://github.com/wistbean/learn_python3_spider/blob/73c873f4845f4385f097e5057407d03dd37a117b/stackoverflow/venv/lib/python3.6/site-packages/pip-19.0.3-py3.6.egg/pip/_vendor/urllib3/contrib/_securetransport/low_level.py#L171-L208
JinnLynn/genpac
2f466d28f403a9a5624e02edcd538475fe475fc8
genpac/formats.py
python
FmtBase.tpl
(self)
return text_type(self._default_tpl)
[]
def tpl(self): if self.options.template: return text_type(TemplateFile(self.options.template)) return text_type(self._default_tpl)
[ "def", "tpl", "(", "self", ")", ":", "if", "self", ".", "options", ".", "template", ":", "return", "text_type", "(", "TemplateFile", "(", "self", ".", "options", ".", "template", ")", ")", "return", "text_type", "(", "self", ".", "_default_tpl", ")" ]
https://github.com/JinnLynn/genpac/blob/2f466d28f403a9a5624e02edcd538475fe475fc8/genpac/formats.py#L48-L51
benedekrozemberczki/DANMF
6726fbfb9a1d4f8a19650ee89773e1c544329321
src/danmf.py
python
DANMF.update_V
(self, i)
Updating right hand factors. :param i: Layer index.
Updating right hand factors. :param i: Layer index.
[ "Updating", "right", "hand", "factors", ".", ":", "param", "i", ":", "Layer", "index", "." ]
def update_V(self, i): """ Updating right hand factors. :param i: Layer index. """ if i < self.p-1: Vu = 2*self.A.dot(self.P).T Vd = self.P.T.dot(self.P).dot(self.V_s[i])+self.V_s[i] self.V_s[i] = self.V_s[i] * Vu/np.maximum(Vd, 10**-10) else: Vu = 2*self.A.dot(self.P).T+(self.args.lamb*self.A.dot(self.V_s[i].T)).T Vd = self.P.T.dot(self.P).dot(self.V_s[i]) Vd = Vd + self.V_s[i]+(self.args.lamb*self.D.dot(self.V_s[i].T)).T self.V_s[i] = self.V_s[i] * Vu/np.maximum(Vd, 10**-10)
[ "def", "update_V", "(", "self", ",", "i", ")", ":", "if", "i", "<", "self", ".", "p", "-", "1", ":", "Vu", "=", "2", "*", "self", ".", "A", ".", "dot", "(", "self", ".", "P", ")", ".", "T", "Vd", "=", "self", ".", "P", ".", "T", ".", ...
https://github.com/benedekrozemberczki/DANMF/blob/6726fbfb9a1d4f8a19650ee89773e1c544329321/src/danmf.py#L98-L111
frappe/erpnext
9d36e30ef7043b391b5ed2523b8288bf46c45d18
erpnext/manufacturing/doctype/work_order/work_order.py
python
WorkOrder.update_reserved_qty_for_production
(self, items=None)
update reserved_qty_for_production in bins
update reserved_qty_for_production in bins
[ "update", "reserved_qty_for_production", "in", "bins" ]
def update_reserved_qty_for_production(self, items=None): '''update reserved_qty_for_production in bins''' for d in self.required_items: if d.source_warehouse: stock_bin = get_bin(d.item_code, d.source_warehouse) stock_bin.update_reserved_qty_for_production()
[ "def", "update_reserved_qty_for_production", "(", "self", ",", "items", "=", "None", ")", ":", "for", "d", "in", "self", ".", "required_items", ":", "if", "d", ".", "source_warehouse", ":", "stock_bin", "=", "get_bin", "(", "d", ".", "item_code", ",", "d",...
https://github.com/frappe/erpnext/blob/9d36e30ef7043b391b5ed2523b8288bf46c45d18/erpnext/manufacturing/doctype/work_order/work_order.py#L648-L653
lena-voita/the-story-of-heads
efaa0dd520400baa760654b5b85396c203d3cbb7
lib/train/tickers.py
python
DevSubscriber.after_dev_run
(self, dev_name, dev_run_values)
Called each dev step after evaluating ops and provides their results
Called each dev step after evaluating ops and provides their results
[ "Called", "each", "dev", "step", "after", "evaluating", "ops", "and", "provides", "their", "results" ]
def after_dev_run(self, dev_name, dev_run_values): """ Called each dev step after evaluating ops and provides their results """ pass
[ "def", "after_dev_run", "(", "self", ",", "dev_name", ",", "dev_run_values", ")", ":", "pass" ]
https://github.com/lena-voita/the-story-of-heads/blob/efaa0dd520400baa760654b5b85396c203d3cbb7/lib/train/tickers.py#L206-L210
python/cpython
e13cdca0f5224ec4e23bdd04bb3120506964bc8b
Lib/bz2.py
python
BZ2File.readline
(self, size=-1)
return self._buffer.readline(size)
Read a line of uncompressed bytes from the file. The terminating newline (if present) is retained. If size is non-negative, no more than size bytes will be read (in which case the line may be incomplete). Returns b'' if already at EOF.
Read a line of uncompressed bytes from the file.
[ "Read", "a", "line", "of", "uncompressed", "bytes", "from", "the", "file", "." ]
def readline(self, size=-1): """Read a line of uncompressed bytes from the file. The terminating newline (if present) is retained. If size is non-negative, no more than size bytes will be read (in which case the line may be incomplete). Returns b'' if already at EOF. """ if not isinstance(size, int): if not hasattr(size, "__index__"): raise TypeError("Integer argument expected") size = size.__index__() self._check_can_read() return self._buffer.readline(size)
[ "def", "readline", "(", "self", ",", "size", "=", "-", "1", ")", ":", "if", "not", "isinstance", "(", "size", ",", "int", ")", ":", "if", "not", "hasattr", "(", "size", ",", "\"__index__\"", ")", ":", "raise", "TypeError", "(", "\"Integer argument expe...
https://github.com/python/cpython/blob/e13cdca0f5224ec4e23bdd04bb3120506964bc8b/Lib/bz2.py#L186-L198
readthedocs/readthedocs.org
0852d7c10d725d954d3e9a93513171baa1116d9f
readthedocs/projects/tasks.py
python
UpdateDocsTaskStep.setup_python_environment
(self)
Build the virtualenv and install the project into it. Always build projects with a virtualenv. :param build_env: Build environment to pass commands and execution through.
Build the virtualenv and install the project into it.
[ "Build", "the", "virtualenv", "and", "install", "the", "project", "into", "it", "." ]
def setup_python_environment(self): """ Build the virtualenv and install the project into it. Always build projects with a virtualenv. :param build_env: Build environment to pass commands and execution through. """ self.build_env.update_build(state=BUILD_STATE_INSTALLING) # Check if the python version/build image in the current venv is the # same to be used in this build and if it differs, wipe the venv to # avoid conflicts. if self.python_env.is_obsolete: self.python_env.delete_existing_venv_dir() else: self.python_env.delete_existing_build_dir() # Install all ``build.tools`` specified by the user if self.config.using_build_tools: self.python_env.install_build_tools() self.python_env.setup_base() self.python_env.save_environment_json() self.python_env.install_core_requirements() self.python_env.install_requirements() if self.project.has_feature(Feature.LIST_PACKAGES_INSTALLED_ENV): self.python_env.list_packages_installed()
[ "def", "setup_python_environment", "(", "self", ")", ":", "self", ".", "build_env", ".", "update_build", "(", "state", "=", "BUILD_STATE_INSTALLING", ")", "# Check if the python version/build image in the current venv is the", "# same to be used in this build and if it differs, wip...
https://github.com/readthedocs/readthedocs.org/blob/0852d7c10d725d954d3e9a93513171baa1116d9f/readthedocs/projects/tasks.py#L1145-L1172
wummel/linkchecker
c2ce810c3fb00b895a841a7be6b2e78c64e7b042
linkcheck/checker/fileurl.py
python
FileUrl.is_directory
(self)
return os.path.isdir(filename) and not os.path.islink(filename)
Check if file is a directory. @return: True iff file is a directory @rtype: bool
Check if file is a directory.
[ "Check", "if", "file", "is", "a", "directory", "." ]
def is_directory (self): """ Check if file is a directory. @return: True iff file is a directory @rtype: bool """ filename = self.get_os_filename() return os.path.isdir(filename) and not os.path.islink(filename)
[ "def", "is_directory", "(", "self", ")", ":", "filename", "=", "self", ".", "get_os_filename", "(", ")", "return", "os", ".", "path", ".", "isdir", "(", "filename", ")", "and", "not", "os", ".", "path", ".", "islink", "(", "filename", ")" ]
https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/linkcheck/checker/fileurl.py#L233-L241
jasperproject/jasper-client
85accbb30a2bc97995ab7991d71941885b848cfa
client/app_utils.py
python
sendEmail
(SUBJECT, BODY, TO, FROM, SENDER, PASSWORD, SMTP_SERVER)
Sends an HTML email.
Sends an HTML email.
[ "Sends", "an", "HTML", "email", "." ]
def sendEmail(SUBJECT, BODY, TO, FROM, SENDER, PASSWORD, SMTP_SERVER): """Sends an HTML email.""" for body_charset in 'US-ASCII', 'ISO-8859-1', 'UTF-8': try: BODY.encode(body_charset) except UnicodeError: pass else: break msg = MIMEText(BODY.encode(body_charset), 'html', body_charset) msg['From'] = SENDER msg['To'] = TO msg['Subject'] = SUBJECT SMTP_PORT = 587 session = smtplib.SMTP(SMTP_SERVER, SMTP_PORT) session.starttls() session.login(FROM, PASSWORD) session.sendmail(SENDER, TO, msg.as_string()) session.quit()
[ "def", "sendEmail", "(", "SUBJECT", ",", "BODY", ",", "TO", ",", "FROM", ",", "SENDER", ",", "PASSWORD", ",", "SMTP_SERVER", ")", ":", "for", "body_charset", "in", "'US-ASCII'", ",", "'ISO-8859-1'", ",", "'UTF-8'", ":", "try", ":", "BODY", ".", "encode",...
https://github.com/jasperproject/jasper-client/blob/85accbb30a2bc97995ab7991d71941885b848cfa/client/app_utils.py#L9-L28
Map-A-Droid/MAD
81375b5c9ccc5ca3161eb487aa81469d40ded221
mapadroid/worker/WorkerQuests.py
python
WorkerQuests._post_move_location_routine
(self, timestamp: float)
[]
def _post_move_location_routine(self, timestamp: float): if self._stop_worker_event.is_set(): raise InternalStopWorkerException position_type = self._mapping_manager.routemanager_get_position_type(self._routemanager_name, self._origin) if position_type is None: self.logger.warning("Mappings/Routemanagers have changed, stopping worker to be created again") raise InternalStopWorkerException if self.get_devicesettings_value('rotate_on_lvl_30', False) and \ self._mitm_mapper.get_playerlevel(self._origin) >= 30 and self._level_mode: # switch if player lvl >= 30 self.switch_account() with self._work_mutex: if not self._mapping_manager.routemanager_get_init(self._routemanager_name): self.logger.info("Processing Stop / Quest...") on_main_menu = self._check_pogo_main_screen(10, False) if not on_main_menu: self._restart_pogo(mitm_mapper=self._mitm_mapper) self.logger.info('Open Stop') self._stop_process_time = math.floor(time.time()) type_received: LatestReceivedType = self._try_to_open_pokestop(timestamp) if type_received is not None and type_received == LatestReceivedType.STOP: self._handle_stop(self._stop_process_time) else: self.logger.debug('Currently in INIT Mode - no Stop processing') time.sleep(5)
[ "def", "_post_move_location_routine", "(", "self", ",", "timestamp", ":", "float", ")", ":", "if", "self", ".", "_stop_worker_event", ".", "is_set", "(", ")", ":", "raise", "InternalStopWorkerException", "position_type", "=", "self", ".", "_mapping_manager", ".", ...
https://github.com/Map-A-Droid/MAD/blob/81375b5c9ccc5ca3161eb487aa81469d40ded221/mapadroid/worker/WorkerQuests.py#L257-L287
saymedia/remoteobjects
d250e9a0e53c53744cb16c5fb2dc136df3785c1f
remoteobjects/promise.py
python
PromiseObject._set_api_data
(self, value)
[]
def _set_api_data(self, value): self.__dict__['api_data'] = value
[ "def", "_set_api_data", "(", "self", ",", "value", ")", ":", "self", ".", "__dict__", "[", "'api_data'", "]", "=", "value" ]
https://github.com/saymedia/remoteobjects/blob/d250e9a0e53c53744cb16c5fb2dc136df3785c1f/remoteobjects/promise.py#L139-L140
securesystemslab/zippy
ff0e84ac99442c2c55fe1d285332cfd4e185e089
zippy/benchmarks/src/benchmarks/sympy/sympy/polys/polyclasses.py
python
DMP.eject
(f, dom, front=False)
return f.__class__(F, dom, f.lev - len(dom.symbols))
Eject selected generators into the ground domain.
Eject selected generators into the ground domain.
[ "Eject", "selected", "generators", "into", "the", "ground", "domain", "." ]
def eject(f, dom, front=False): """Eject selected generators into the ground domain. """ F = dmp_eject(f.rep, f.lev, dom, front=front) return f.__class__(F, dom, f.lev - len(dom.symbols))
[ "def", "eject", "(", "f", ",", "dom", ",", "front", "=", "False", ")", ":", "F", "=", "dmp_eject", "(", "f", ".", "rep", ",", "f", ".", "lev", ",", "dom", ",", "front", "=", "front", ")", "return", "f", ".", "__class__", "(", "F", ",", "dom",...
https://github.com/securesystemslab/zippy/blob/ff0e84ac99442c2c55fe1d285332cfd4e185e089/zippy/benchmarks/src/benchmarks/sympy/sympy/polys/polyclasses.py#L348-L351
wangheda/youtube-8m
07e54b387ee027cb58b0c14f5eb7c88cfa516d58
youtube-8m-zhangteng/eval_embedding.py
python
get_input_evaluation_tensors
(reader, data_pattern, batch_size=1024, num_readers=1)
Creates the section of the graph which reads the evaluation data. Args: reader: A class which parses the training data. data_pattern: A 'glob' style path to the data files. batch_size: How many examples to process at a time. num_readers: How many I/O threads to use. Returns: A tuple containing the features tensor, labels tensor, and optionally a tensor containing the number of frames per video. The exact dimensions depend on the reader being used. Raises: IOError: If no files matching the given pattern were found.
Creates the section of the graph which reads the evaluation data.
[ "Creates", "the", "section", "of", "the", "graph", "which", "reads", "the", "evaluation", "data", "." ]
def get_input_evaluation_tensors(reader, data_pattern, batch_size=1024, num_readers=1): """Creates the section of the graph which reads the evaluation data. Args: reader: A class which parses the training data. data_pattern: A 'glob' style path to the data files. batch_size: How many examples to process at a time. num_readers: How many I/O threads to use. Returns: A tuple containing the features tensor, labels tensor, and optionally a tensor containing the number of frames per video. The exact dimensions depend on the reader being used. Raises: IOError: If no files matching the given pattern were found. """ logging.info("Using batch size of " + str(batch_size) + " for evaluation.") with tf.name_scope("eval_input"): files = gfile.Glob(data_pattern) if not files: raise IOError("Unable to find the evaluation files.") logging.info("number of evaluation files: " + str(len(files))) filename_queue = tf.train.string_input_producer( files, shuffle=False, num_epochs=1) eval_data = [ reader.prepare_reader(filename_queue) for _ in range(num_readers) ] return tf.train.batch_join( eval_data, batch_size=batch_size, capacity=3 * batch_size, allow_smaller_final_batch=True, enqueue_many=True)
[ "def", "get_input_evaluation_tensors", "(", "reader", ",", "data_pattern", ",", "batch_size", "=", "1024", ",", "num_readers", "=", "1", ")", ":", "logging", ".", "info", "(", "\"Using batch size of \"", "+", "str", "(", "batch_size", ")", "+", "\" for evaluatio...
https://github.com/wangheda/youtube-8m/blob/07e54b387ee027cb58b0c14f5eb7c88cfa516d58/youtube-8m-zhangteng/eval_embedding.py#L81-L117
gnuradio/pybombs
17044241bf835b93571026b112f179f2db7448a4
pybombs/commands/autoconfig.py
python
AutoConfigurator._auto_config_makewidth
(self)
return multiprocessing.cpu_count()
Automatically set: makewidth
Automatically set: makewidth
[ "Automatically", "set", ":", "makewidth" ]
def _auto_config_makewidth(self): " Automatically set: makewidth " import multiprocessing return multiprocessing.cpu_count()
[ "def", "_auto_config_makewidth", "(", "self", ")", ":", "import", "multiprocessing", "return", "multiprocessing", ".", "cpu_count", "(", ")" ]
https://github.com/gnuradio/pybombs/blob/17044241bf835b93571026b112f179f2db7448a4/pybombs/commands/autoconfig.py#L41-L44
facetoe/zenpy
e614e973aa4d3c4c2a0b91767c2d8565f48ec717
zenpy/lib/api_objects/__init__.py
python
SuspendedTicket.brand
(self)
| Comment: The id of the brand this ticket is associated with - only applicable for enterprise accounts
| Comment: The id of the brand this ticket is associated with - only applicable for enterprise accounts
[ "|", "Comment", ":", "The", "id", "of", "the", "brand", "this", "ticket", "is", "associated", "with", "-", "only", "applicable", "for", "enterprise", "accounts" ]
def brand(self): """ | Comment: The id of the brand this ticket is associated with - only applicable for enterprise accounts """ if self.api and self.brand_id: return self.api._get_brand(self.brand_id)
[ "def", "brand", "(", "self", ")", ":", "if", "self", ".", "api", "and", "self", ".", "brand_id", ":", "return", "self", ".", "api", ".", "_get_brand", "(", "self", ".", "brand_id", ")" ]
https://github.com/facetoe/zenpy/blob/e614e973aa4d3c4c2a0b91767c2d8565f48ec717/zenpy/lib/api_objects/__init__.py#L3646-L3651
itayhubara/BinaryNet.pytorch
b99870af6e73992896ab5db5ea26b83d2adb1201
models/resnet_binary.py
python
Bottleneck.forward
(self, x)
return out
[]
def forward(self, x): residual = x import pdb; pdb.set_trace() out = self.conv1(x) out = self.bn1(out) out = self.tanh(out) out = self.conv2(out) out = self.bn2(out) out = self.tanh(out) out = self.conv3(out) out = self.bn3(out) if self.downsample is not None: residual = self.downsample(x) out += residual if self.do_bntan: out = self.bn2(out) out = self.tanh2(out) return out
[ "def", "forward", "(", "self", ",", "x", ")", ":", "residual", "=", "x", "import", "pdb", "pdb", ".", "set_trace", "(", ")", "out", "=", "self", ".", "conv1", "(", "x", ")", "out", "=", "self", ".", "bn1", "(", "out", ")", "out", "=", "self", ...
https://github.com/itayhubara/BinaryNet.pytorch/blob/b99870af6e73992896ab5db5ea26b83d2adb1201/models/resnet_binary.py#L85-L107
SeldonIO/alibi
ce961caf995d22648a8338857822c90428af4765
alibi/explainers/backends/tensorflow/cfrl_base.py
python
encode
(X: Union[tf.Tensor, np.ndarray], encoder: keras.Model, **kwargs)
return encoder(X, training=False)
Encodes the input tensor. Parameters ---------- X Input to be encoded. encoder Pretrained encoder network. Returns ------- Input encoding.
Encodes the input tensor.
[ "Encodes", "the", "input", "tensor", "." ]
def encode(X: Union[tf.Tensor, np.ndarray], encoder: keras.Model, **kwargs) -> tf.Tensor: """ Encodes the input tensor. Parameters ---------- X Input to be encoded. encoder Pretrained encoder network. Returns ------- Input encoding. """ return encoder(X, training=False)
[ "def", "encode", "(", "X", ":", "Union", "[", "tf", ".", "Tensor", ",", "np", ".", "ndarray", "]", ",", "encoder", ":", "keras", ".", "Model", ",", "*", "*", "kwargs", ")", "->", "tf", ".", "Tensor", ":", "return", "encoder", "(", "X", ",", "tr...
https://github.com/SeldonIO/alibi/blob/ce961caf995d22648a8338857822c90428af4765/alibi/explainers/backends/tensorflow/cfrl_base.py#L236-L251
XX-net/XX-Net
a9898cfcf0084195fb7e69b6bc834e59aecdf14f
python3.8.2/Lib/site-packages/pip/_internal/req/req_uninstall.py
python
compress_for_output_listing
(paths)
return will_remove, will_skip
Returns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added at the end - to signify that all it's contents are removed. The second set contains files that would have been skipped in the above folders.
Returns a tuple of 2 sets of which paths to display to user
[ "Returns", "a", "tuple", "of", "2", "sets", "of", "which", "paths", "to", "display", "to", "user" ]
def compress_for_output_listing(paths): # type: (Iterable[str]) -> Tuple[Set[str], Set[str]] """Returns a tuple of 2 sets of which paths to display to user The first set contains paths that would be deleted. Files of a package are not added and the top-level directory of the package has a '*' added at the end - to signify that all it's contents are removed. The second set contains files that would have been skipped in the above folders. """ will_remove = set(paths) will_skip = set() # Determine folders and files folders = set() files = set() for path in will_remove: if path.endswith(".pyc"): continue if path.endswith("__init__.py") or ".dist-info" in path: folders.add(os.path.dirname(path)) files.add(path) # probably this one https://github.com/python/mypy/issues/390 _normcased_files = set(map(os.path.normcase, files)) # type: ignore folders = compact(folders) # This walks the tree using os.walk to not miss extra folders # that might get added. for folder in folders: for dirpath, _, dirfiles in os.walk(folder): for fname in dirfiles: if fname.endswith(".pyc"): continue file_ = os.path.join(dirpath, fname) if (os.path.isfile(file_) and os.path.normcase(file_) not in _normcased_files): # We are skipping this file. Add it to the set. will_skip.add(file_) will_remove = files | { os.path.join(folder, "*") for folder in folders } return will_remove, will_skip
[ "def", "compress_for_output_listing", "(", "paths", ")", ":", "# type: (Iterable[str]) -> Tuple[Set[str], Set[str]]", "will_remove", "=", "set", "(", "paths", ")", "will_skip", "=", "set", "(", ")", "# Determine folders and files", "folders", "=", "set", "(", ")", "fi...
https://github.com/XX-net/XX-Net/blob/a9898cfcf0084195fb7e69b6bc834e59aecdf14f/python3.8.2/Lib/site-packages/pip/_internal/req/req_uninstall.py#L151-L199
sagemath/sage
f9b2db94f675ff16963ccdefba4f1a3393b3fe0d
src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py
python
HyperbolicGeodesicKM.plot
(self, boundary=True, **options)
return pic
r""" Plot ``self``. EXAMPLES:: sage: HyperbolicPlane().KM().get_geodesic((0,0), (1,0)).plot() # optional - sage.plot Graphics object consisting of 2 graphics primitives .. PLOT:: KM = HyperbolicPlane().KM() sphinx_plot(KM.get_geodesic((0,0), (1,0)).plot())
r""" Plot ``self``.
[ "r", "Plot", "self", "." ]
def plot(self, boundary=True, **options): r""" Plot ``self``. EXAMPLES:: sage: HyperbolicPlane().KM().get_geodesic((0,0), (1,0)).plot() # optional - sage.plot Graphics object consisting of 2 graphics primitives .. PLOT:: KM = HyperbolicPlane().KM() sphinx_plot(KM.get_geodesic((0,0), (1,0)).plot()) """ opts = {'axes': False, 'aspect_ratio': 1} opts.update(self.graphics_options()) opts.update(options) pic = line([k.coordinates() for k in self.endpoints()], **opts) if boundary: pic += self._model.get_background_graphic() return pic
[ "def", "plot", "(", "self", ",", "boundary", "=", "True", ",", "*", "*", "options", ")", ":", "opts", "=", "{", "'axes'", ":", "False", ",", "'aspect_ratio'", ":", "1", "}", "opts", ".", "update", "(", "self", ".", "graphics_options", "(", ")", ")"...
https://github.com/sagemath/sage/blob/f9b2db94f675ff16963ccdefba4f1a3393b3fe0d/src/sage/geometry/hyperbolic_space/hyperbolic_geodesic.py#L2297-L2318
Yonsm/.homeassistant
4d9a0070d0fcd8a5ded46e7884da9a4494bbbf26
custom_components/xiaomi_fan_circulator/fan.py
python
XiaomiFanFA1.async_set_preset_mode
(self, preset_mode: str)
Set the speed of the fan.
Set the speed of the fan.
[ "Set", "the", "speed", "of", "the", "fan", "." ]
async def async_set_preset_mode(self, preset_mode: str) -> None: """Set the speed of the fan.""" if self.supported_features & SUPPORT_PRESET_MODE == 0: return if preset_mode.isdigit(): preset_mode = int(preset_mode) if preset_mode in [SPEED_OFF, 0]: await self.async_turn_off() return # Map speed level to speed if preset_mode in FAN_SPEED_VALUES_FA1.keys(): preset_mode = FAN_SPEED_VALUES_FA1[preset_mode] await self._try_command( "Setting fan speed of the miio device failed.", self._device.send, "set_properties", [{"piid": 2, "siid": 2, "did": self._did, "value": preset_mode}] )
[ "async", "def", "async_set_preset_mode", "(", "self", ",", "preset_mode", ":", "str", ")", "->", "None", ":", "if", "self", ".", "supported_features", "&", "SUPPORT_PRESET_MODE", "==", "0", ":", "return", "if", "preset_mode", ".", "isdigit", "(", ")", ":", ...
https://github.com/Yonsm/.homeassistant/blob/4d9a0070d0fcd8a5ded46e7884da9a4494bbbf26/custom_components/xiaomi_fan_circulator/fan.py#L668-L689
mlrun/mlrun
4c120719d64327a34b7ee1ab08fb5e01b258b00a
mlrun/data_types/infer.py
python
infer_schema_from_df
( df: pd.DataFrame, features, entities, timestamp_key: str = None, entity_columns=None, options: InferOptions = InferOptions.Null, )
return timestamp_key
infer feature set schema from dataframe
infer feature set schema from dataframe
[ "infer", "feature", "set", "schema", "from", "dataframe" ]
def infer_schema_from_df( df: pd.DataFrame, features, entities, timestamp_key: str = None, entity_columns=None, options: InferOptions = InferOptions.Null, ): """infer feature set schema from dataframe""" timestamp_fields = [] current_entities = list(entities.keys()) entity_columns = entity_columns or [] index_columns = dict() def upsert_entity(name, value_type): if name in current_entities: entities[name].value_type = value_type else: entities[name] = {"name": name, "value_type": value_type} schema = pyarrow.Schema.from_pandas(df) index_type = None for i in range(len(schema)): column = schema.names[i] value_type = pa_type_to_value_type(schema.types[i]) if column in df.index.names: index_columns[column] = value_type continue is_entity = column in entity_columns or column in current_entities if is_entity: upsert_entity(column, value_type) elif ( InferOptions.get_common_options(options, InferOptions.Features) and column != timestamp_key ): if column in features.keys(): features[column].value_type = value_type else: features[column] = {"name": column, "value_type": value_type} if value_type == "datetime" and not is_entity: timestamp_fields.append(column) index_type = None if InferOptions.get_common_options(options, InferOptions.Index): # infer types of index fields if df.index.name: if df.index.name in index_columns: index_type = index_columns[df.index.name] if not index_type: field = convert_pandas_type_to_json_field(df.index) index_type = pd_schema_to_value_type(field["type"]) # Workaround to infer a boolean index correctly, and not as 'str'. upsert_entity(df.index.name, index_type) elif df.index.nlevels > 1: for level, name in zip(df.index.levels, df.index.names): if name in index_columns: index_type = index_columns[name] else: field = convert_pandas_type_to_json_field(df.index) index_type = pd_schema_to_value_type(field["type"]) upsert_entity(name, index_type) if index_type == "datetime": timestamp_fields.append(name) return timestamp_key
[ "def", "infer_schema_from_df", "(", "df", ":", "pd", ".", "DataFrame", ",", "features", ",", "entities", ",", "timestamp_key", ":", "str", "=", "None", ",", "entity_columns", "=", "None", ",", "options", ":", "InferOptions", "=", "InferOptions", ".", "Null",...
https://github.com/mlrun/mlrun/blob/4c120719d64327a34b7ee1ab08fb5e01b258b00a/mlrun/data_types/infer.py#L11-L75
openeventdata/mordecai
9d37110f6cd1275852548fc53fd7a21bb77593f9
mordecai/geoparse.py
python
Geoparser._feature_most_population
(self, results)
Find the placename with the largest population and return its country. More population is a rough measure of importance. Paramaters ---------- results: dict output of `query_geonames` Returns ------- most_pop: str ISO code of country of place with largest population, or empty string if none
Find the placename with the largest population and return its country. More population is a rough measure of importance.
[ "Find", "the", "placename", "with", "the", "largest", "population", "and", "return", "its", "country", ".", "More", "population", "is", "a", "rough", "measure", "of", "importance", "." ]
def _feature_most_population(self, results): """ Find the placename with the largest population and return its country. More population is a rough measure of importance. Paramaters ---------- results: dict output of `query_geonames` Returns ------- most_pop: str ISO code of country of place with largest population, or empty string if none """ try: populations = [i['population'] for i in results['hits']['hits']] most_pop = results['hits']['hits'][np.array(populations).astype("int").argmax()] return most_pop['country_code3'] except Exception as e: return ""
[ "def", "_feature_most_population", "(", "self", ",", "results", ")", ":", "try", ":", "populations", "=", "[", "i", "[", "'population'", "]", "for", "i", "in", "results", "[", "'hits'", "]", "[", "'hits'", "]", "]", "most_pop", "=", "results", "[", "'h...
https://github.com/openeventdata/mordecai/blob/9d37110f6cd1275852548fc53fd7a21bb77593f9/mordecai/geoparse.py#L209-L231
apple/ccs-calendarserver
13c706b985fb728b9aab42dc0fef85aae21921c3
calendarserver/tools/obliterate.py
python
ObliterateService.removeRevisionsForHomeResourceID
(self, resourceID)
[]
def removeRevisionsForHomeResourceID(self, resourceID): if not self.options["dry-run"]: rev = schema.CALENDAR_OBJECT_REVISIONS kwds = {"ResourceID": resourceID} yield Delete( From=rev, Where=( rev.CALENDAR_HOME_RESOURCE_ID == Parameter("ResourceID") ), ).on(self.txn, **kwds)
[ "def", "removeRevisionsForHomeResourceID", "(", "self", ",", "resourceID", ")", ":", "if", "not", "self", ".", "options", "[", "\"dry-run\"", "]", ":", "rev", "=", "schema", ".", "CALENDAR_OBJECT_REVISIONS", "kwds", "=", "{", "\"ResourceID\"", ":", "resourceID",...
https://github.com/apple/ccs-calendarserver/blob/13c706b985fb728b9aab42dc0fef85aae21921c3/calendarserver/tools/obliterate.py#L427-L436
IntelPython/sdc
1ebf55c00ef38dfbd401a70b3945e352a5a38b87
sdc/datatypes/common_functions.py
python
_sdc_asarray_overload
(data)
return None
[]
def _sdc_asarray_overload(data): # TODO: extend with other types if not isinstance(data, types.List): return None if isinstance(data.dtype, types.UnicodeType): def _sdc_asarray_impl(data): return create_str_arr_from_list(data) return _sdc_asarray_impl else: result_dtype = data.dtype def _sdc_asarray_impl(data): # TODO: check if elementwise copy is needed at all res_size = len(data) res_arr = numpy.empty(res_size, dtype=result_dtype) for i in numba.prange(res_size): res_arr[i] = data[i] return res_arr return _sdc_asarray_impl return None
[ "def", "_sdc_asarray_overload", "(", "data", ")", ":", "# TODO: extend with other types", "if", "not", "isinstance", "(", "data", ",", "types", ".", "List", ")", ":", "return", "None", "if", "isinstance", "(", "data", ".", "dtype", ",", "types", ".", "Unicod...
https://github.com/IntelPython/sdc/blob/1ebf55c00ef38dfbd401a70b3945e352a5a38b87/sdc/datatypes/common_functions.py#L556-L581
poppy-project/pypot
c5d384fe23eef9f6ec98467f6f76626cdf20afb9
pypot/server/httpserver.py
python
HTTPRobotServer.make_app
(self)
return Application(url_paths)
[]
def make_app(self): PoppyRequestHandler.restful_robot = self.restful_robot return Application(url_paths)
[ "def", "make_app", "(", "self", ")", ":", "PoppyRequestHandler", ".", "restful_robot", "=", "self", ".", "restful_robot", "return", "Application", "(", "url_paths", ")" ]
https://github.com/poppy-project/pypot/blob/c5d384fe23eef9f6ec98467f6f76626cdf20afb9/pypot/server/httpserver.py#L1116-L1118
landlab/landlab
a5dd80b8ebfd03d1ba87ef6c4368c409485f222c
landlab/components/network_sediment_transporter/network_sediment_transporter.py
python
NetworkSedimentTransporter._calculate_mean_D_and_rho
(self)
Calculate mean grain size and density on each link
Calculate mean grain size and density on each link
[ "Calculate", "mean", "grain", "size", "and", "density", "on", "each", "link" ]
def _calculate_mean_D_and_rho(self): """Calculate mean grain size and density on each link""" current_parcels = self._parcels.dataset.isel(time=self._time_idx) # In the first full timestep, we need to calc grain size & rho_sed. # Assume all parcels are in the active layer for the purposes of # grain size and mean sediment density calculations # FUTURE: make it possible to circumvent this if mean grain size # has already been calculated (e.g. during 'zeroing' runs) # Calculate mean values for density and grain size (weighted by volume). sel_parcels = current_parcels.where( current_parcels.element_id != self.OUT_OF_NETWORK ) d_weighted = sel_parcels.D * sel_parcels.volume rho_weighted = sel_parcels.density * sel_parcels.volume d_weighted.name = "d_weighted" rho_weighted.name = "rho_weighted" grouped_by_element = xr.merge( (sel_parcels.element_id, sel_parcels.volume, d_weighted, rho_weighted) ).groupby("element_id") d_avg = grouped_by_element.sum().d_weighted / grouped_by_element.sum().volume rho_avg = ( grouped_by_element.sum().rho_weighted / grouped_by_element.sum().volume ) self._d_mean_active = np.zeros(self._grid.size("link")) self._d_mean_active[d_avg.element_id.values.astype(int)] = d_avg.values self._rhos_mean_active = np.zeros(self._grid.size("link")) self._rhos_mean_active[rho_avg.element_id.values.astype(int)] = rho_avg.values
[ "def", "_calculate_mean_D_and_rho", "(", "self", ")", ":", "current_parcels", "=", "self", ".", "_parcels", ".", "dataset", ".", "isel", "(", "time", "=", "self", ".", "_time_idx", ")", "# In the first full timestep, we need to calc grain size & rho_sed.", "# Assume all...
https://github.com/landlab/landlab/blob/a5dd80b8ebfd03d1ba87ef6c4368c409485f222c/landlab/components/network_sediment_transporter/network_sediment_transporter.py#L466-L501
oracle/graalpython
577e02da9755d916056184ec441c26e00b70145c
graalpython/lib-python/3/tkinter/__init__.py
python
Variable.trace_add
(self, mode, callback)
return cbname
Define a trace callback for the variable. Mode is one of "read", "write", "unset", or a list or tuple of such strings. Callback must be a function which is called when the variable is read, written or unset. Return the name of the callback.
Define a trace callback for the variable.
[ "Define", "a", "trace", "callback", "for", "the", "variable", "." ]
def trace_add(self, mode, callback): """Define a trace callback for the variable. Mode is one of "read", "write", "unset", or a list or tuple of such strings. Callback must be a function which is called when the variable is read, written or unset. Return the name of the callback. """ cbname = self._register(callback) self._tk.call('trace', 'add', 'variable', self._name, mode, (cbname,)) return cbname
[ "def", "trace_add", "(", "self", ",", "mode", ",", "callback", ")", ":", "cbname", "=", "self", ".", "_register", "(", "callback", ")", "self", ".", "_tk", ".", "call", "(", "'trace'", ",", "'add'", ",", "'variable'", ",", "self", ".", "_name", ",", ...
https://github.com/oracle/graalpython/blob/577e02da9755d916056184ec441c26e00b70145c/graalpython/lib-python/3/tkinter/__init__.py#L390-L403
deezer/spleeter
48e38088370bdc2997040ea3c57f96495bdf75a5
spleeter/model/__init__.py
python
EstimatorSpecBuilder._build_manual_output_waveform
(self, masked_stft)
return output_waveform
Perform ratio mask separation :param output_dict: dictionary of estimated spectrogram (key: instrument name, value: estimated spectrogram of the instrument) :returns: dictionary of separated waveforms (key: instrument name, value: estimated waveform of the instrument)
Perform ratio mask separation
[ "Perform", "ratio", "mask", "separation" ]
def _build_manual_output_waveform(self, masked_stft): """Perform ratio mask separation :param output_dict: dictionary of estimated spectrogram (key: instrument name, value: estimated spectrogram of the instrument) :returns: dictionary of separated waveforms (key: instrument name, value: estimated waveform of the instrument) """ output_waveform = {} for instrument, stft_data in masked_stft.items(): output_waveform[instrument] = self._inverse_stft(stft_data) return output_waveform
[ "def", "_build_manual_output_waveform", "(", "self", ",", "masked_stft", ")", ":", "output_waveform", "=", "{", "}", "for", "instrument", ",", "stft_data", "in", "masked_stft", ".", "items", "(", ")", ":", "output_waveform", "[", "instrument", "]", "=", "self"...
https://github.com/deezer/spleeter/blob/48e38088370bdc2997040ea3c57f96495bdf75a5/spleeter/model/__init__.py#L469-L481
Amulet-Team/Amulet-Map-Editor
e99619ba6aab855173b9f7c203455944ab97f89a
amulet_map_editor/api/opengl/camera/camera.py
python
Camera.orthographic_clipping
(self, clipping: Tuple[float, float])
Set the near and far clipping distance when in orthographic mode.
Set the near and far clipping distance when in orthographic mode.
[ "Set", "the", "near", "and", "far", "clipping", "distance", "when", "in", "orthographic", "mode", "." ]
def orthographic_clipping(self, clipping: Tuple[float, float]): """Set the near and far clipping distance when in orthographic mode.""" self._set_clipping(Projection.TOP_DOWN, clipping)
[ "def", "orthographic_clipping", "(", "self", ",", "clipping", ":", "Tuple", "[", "float", ",", "float", "]", ")", ":", "self", ".", "_set_clipping", "(", "Projection", ".", "TOP_DOWN", ",", "clipping", ")" ]
https://github.com/Amulet-Team/Amulet-Map-Editor/blob/e99619ba6aab855173b9f7c203455944ab97f89a/amulet_map_editor/api/opengl/camera/camera.py#L257-L259
docker-archive/docker-registry
f93b432d3fc7befa508ab27a590e6d0f78c86401
docker_registry/index.py
python
put_repository_auth
(namespace, repository)
return toolkit.response('OK')
[]
def put_repository_auth(namespace, repository): return toolkit.response('OK')
[ "def", "put_repository_auth", "(", "namespace", ",", "repository", ")", ":", "return", "toolkit", ".", "response", "(", "'OK'", ")" ]
https://github.com/docker-archive/docker-registry/blob/f93b432d3fc7befa508ab27a590e6d0f78c86401/docker_registry/index.py#L130-L131
JacquesLucke/animation_nodes
b1e3ace8dcb0a771fd882fc3ac4e490b009fa0d1
animation_nodes/utils/blender_ui.py
python
iterActiveSpacesByType
(type)
[]
def iterActiveSpacesByType(type): for space in iterActiveSpaces(): if space.type == type: yield space
[ "def", "iterActiveSpacesByType", "(", "type", ")", ":", "for", "space", "in", "iterActiveSpaces", "(", ")", ":", "if", "space", ".", "type", "==", "type", ":", "yield", "space" ]
https://github.com/JacquesLucke/animation_nodes/blob/b1e3ace8dcb0a771fd882fc3ac4e490b009fa0d1/animation_nodes/utils/blender_ui.py#L5-L8
dimagi/commcare-hq
d67ff1d3b4c51fa050c19e60c3253a79d3452a39
corehq/apps/hqwebapp/views.py
python
CRUDPaginatedViewMixin.paginated_list
(self)
This should return a list (or generator object) of data formatted as follows: [ { 'itemData': { 'id': <id of item>, <json dict of item data for the knockout model to use> }, 'template': <knockout template id> } ]
This should return a list (or generator object) of data formatted as follows: [ { 'itemData': { 'id': <id of item>, <json dict of item data for the knockout model to use> }, 'template': <knockout template id> } ]
[ "This", "should", "return", "a", "list", "(", "or", "generator", "object", ")", "of", "data", "formatted", "as", "follows", ":", "[", "{", "itemData", ":", "{", "id", ":", "<id", "of", "item", ">", "<json", "dict", "of", "item", "data", "for", "the",...
def paginated_list(self): """ This should return a list (or generator object) of data formatted as follows: [ { 'itemData': { 'id': <id of item>, <json dict of item data for the knockout model to use> }, 'template': <knockout template id> } ] """ raise NotImplementedError("Return a list of data for the request response.")
[ "def", "paginated_list", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "\"Return a list of data for the request response.\"", ")" ]
https://github.com/dimagi/commcare-hq/blob/d67ff1d3b4c51fa050c19e60c3253a79d3452a39/corehq/apps/hqwebapp/views.py#L1100-L1113
microsoft/botbuilder-python
3d410365461dc434df59bdfeaa2f16d28d9df868
libraries/botframework-connector/botframework/connector/token_api/aio/operations_async/_user_token_operations_async.py
python
UserTokenOperations.exchange_async
( self, user_id, connection_name, channel_id, uri=None, token=None, *, custom_headers=None, raw=False, **operation_config )
return deserialized
:param user_id: :type user_id: str :param connection_name: :type connection_name: str :param channel_id: :type channel_id: str :param uri: :type uri: str :param token: :type token: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: object or ClientRawResponse if raw=true :rtype: object or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<botframework.tokenapi.models.ErrorResponseException>`
[]
async def exchange_async( self, user_id, connection_name, channel_id, uri=None, token=None, *, custom_headers=None, raw=False, **operation_config ): """ :param user_id: :type user_id: str :param connection_name: :type connection_name: str :param channel_id: :type channel_id: str :param uri: :type uri: str :param token: :type token: str :param dict custom_headers: headers that will be added to the request :param bool raw: returns the direct response alongside the deserialized response :param operation_config: :ref:`Operation configuration overrides<msrest:optionsforoperations>`. :return: object or ClientRawResponse if raw=true :rtype: object or ~msrest.pipeline.ClientRawResponse :raises: :class:`ErrorResponseException<botframework.tokenapi.models.ErrorResponseException>` """ exchange_request = models.TokenExchangeRequest(uri=uri, token=token) # Construct URL url = self.exchange_async.metadata["url"] # Construct parameters query_parameters = {} query_parameters["userId"] = self._serialize.query("user_id", user_id, "str") query_parameters["connectionName"] = self._serialize.query( "connection_name", connection_name, "str" ) query_parameters["channelId"] = self._serialize.query( "channel_id", channel_id, "str" ) # Construct headers header_parameters = {} header_parameters["Accept"] = "application/json" header_parameters["Content-Type"] = "application/json; charset=utf-8" if custom_headers: header_parameters.update(custom_headers) # Construct body body_content = self._serialize.body(exchange_request, "TokenExchangeRequest") # Construct and send request request = self._client.post( url, query_parameters, header_parameters, body_content ) response = await self._client.async_send( request, stream=False, **operation_config ) if response.status_code not in [200, 400, 404]: raise models.ErrorResponseException(self._deserialize, response) deserialized = None if response.status_code == 200: deserialized = self._deserialize("TokenResponse", response) if response.status_code == 400: deserialized = self._deserialize("ErrorResponse", response) if response.status_code == 404: deserialized = self._deserialize("TokenResponse", response) if raw: client_raw_response = ClientRawResponse(deserialized, response) return client_raw_response return deserialized
[ "async", "def", "exchange_async", "(", "self", ",", "user_id", ",", "connection_name", ",", "channel_id", ",", "uri", "=", "None", ",", "token", "=", "None", ",", "*", ",", "custom_headers", "=", "None", ",", "raw", "=", "False", ",", "*", "*", "operat...
https://github.com/microsoft/botbuilder-python/blob/3d410365461dc434df59bdfeaa2f16d28d9df868/libraries/botframework-connector/botframework/connector/token_api/aio/operations_async/_user_token_operations_async.py#L348-L430
jesparza/peepdf
c74dc65c0ac7e506bae4f2582a2435ec50741f40
PDFCore.py
python
PDFObject.contains
(self, string)
return False
Look for the string inside the object content @param string: A string @return: A boolean to specify if the string has been found or not
Look for the string inside the object content
[ "Look", "for", "the", "string", "inside", "the", "object", "content" ]
def contains(self, string): ''' Look for the string inside the object content @param string: A string @return: A boolean to specify if the string has been found or not ''' value = str(self.value) rawValue = str(self.rawValue) encValue = str(self.encryptedValue) if re.findall(string,value,re.IGNORECASE) != [] or re.findall(string,rawValue,re.IGNORECASE) != [] or re.findall(string,encValue,re.IGNORECASE) != []: return True if self.containsJS(): for js in self.JSCode: if re.findall(string,js,re.IGNORECASE) != []: return True return False
[ "def", "contains", "(", "self", ",", "string", ")", ":", "value", "=", "str", "(", "self", ".", "value", ")", "rawValue", "=", "str", "(", "self", ".", "rawValue", ")", "encValue", "=", "str", "(", "self", ".", "encryptedValue", ")", "if", "re", "....
https://github.com/jesparza/peepdf/blob/c74dc65c0ac7e506bae4f2582a2435ec50741f40/PDFCore.py#L123-L139
JoelBender/bacpypes
41104c2b565b2ae9a637c941dfb0fe04195c5e96
py27/bacpypes/debugging.py
python
DebugContents.debug_contents
(self, indent=1, file=sys.stdout, _ids=None)
Debug the contents of an object.
Debug the contents of an object.
[ "Debug", "the", "contents", "of", "an", "object", "." ]
def debug_contents(self, indent=1, file=sys.stdout, _ids=None): """Debug the contents of an object.""" if _debug: _log.debug("debug_contents indent=%r file=%r _ids=%r", indent, file, _ids) klasses = list(self.__class__.__mro__) klasses.reverse() if _debug: _log.debug(" - klasses: %r", klasses) # loop through the classes and look for _debug_contents attrs = [] cids = [] ownFn = [] for klass in klasses: if klass is DebugContents: continue if not issubclass(klass, DebugContents) and hasattr(klass, 'debug_contents'): for i, seenAlready in enumerate(ownFn): if issubclass(klass, seenAlready): del ownFn[i] break ownFn.append(klass) continue # look for a tuple of attribute names if not hasattr(klass, '_debug_contents'): continue debugContents = klass._debug_contents if not isinstance(debugContents, tuple): raise RuntimeError("%s._debug_contents must be a tuple" % (klass.__name__,)) # already seen it? if id(debugContents) in cids: continue cids.append(id(debugContents)) for attr in debugContents: if attr not in attrs: attrs.append(attr) # a bit of debugging if _debug: _log.debug(" - attrs: %r", attrs) _log.debug(" - ownFn: %r", ownFn) # make/extend the list of objects already seen if _ids is None: _ids = [] # loop through the attributes for attr in attrs: # assume you're going deep, but not into lists and dicts goDeep = True goListDict = False goHexed = False # attribute list might want to go deep if attr.endswith("-"): goDeep = False attr = attr[:-1] elif attr.endswith("*"): goHexed = True attr = attr[:-1] elif attr.endswith("+"): goDeep = False goListDict = True attr = attr[:-1] if attr.endswith("+"): goDeep = True attr = attr[:-1] value = getattr(self, attr, None) # skip None if value is None: continue # standard output if goListDict and isinstance(value, list) and value: file.write("%s%s = [\n" % (' ' * indent, attr)) indent += 1 for i, elem in enumerate(value): file.write("%s[%d] %r\n" % (' ' * indent, i, elem)) if goDeep and hasattr(elem, 'debug_contents'): if id(elem) not in _ids: _ids.append(id(elem)) elem.debug_contents(indent + 1, file, _ids) indent -= 1 file.write("%s ]\n" % (' ' * indent,)) elif goListDict and isinstance(value, dict) and value: file.write("%s%s = {\n" % (' ' * indent, attr)) indent += 1 for key, elem in value.items(): file.write("%s%r : %r\n" % (' ' * indent, key, elem)) if goDeep and hasattr(elem, 'debug_contents'): if id(elem) not in _ids: _ids.append(id(elem)) elem.debug_contents(indent + 1, file, _ids) indent -= 1 file.write("%s }\n" % (' ' * indent,)) elif goHexed and isinstance(value, str): if len(value) > 20: hexed = btox(value[:20], '.') + "..." else: hexed = btox(value, '.') file.write("%s%s = x'%s'\n" % (' ' * indent, attr, hexed)) # elif goHexed and isinstance(value, int): # file.write("%s%s = 0x%X\n" % (' ' * indent, attr, value)) else: file.write("%s%s = %r\n" % (' ' * indent, attr, value)) # go nested if it is debugable if goDeep and hasattr(value, 'debug_contents'): if id(value) not in _ids: _ids.append(id(value)) value.debug_contents(indent + 1, file, _ids) # go through the functions ownFn.reverse() for klass in ownFn: klass.debug_contents(self, indent, file, _ids)
[ "def", "debug_contents", "(", "self", ",", "indent", "=", "1", ",", "file", "=", "sys", ".", "stdout", ",", "_ids", "=", "None", ")", ":", "if", "_debug", ":", "_log", ".", "debug", "(", "\"debug_contents indent=%r file=%r _ids=%r\"", ",", "indent", ",", ...
https://github.com/JoelBender/bacpypes/blob/41104c2b565b2ae9a637c941dfb0fe04195c5e96/py27/bacpypes/debugging.py#L91-L212
seanbell/opensurfaces
7f3e987560faa62cd37f821760683ccd1e053c7c
server/mturk/tasks.py
python
mturk_iteration_task
(show_progress=False)
Update votes and start new tasks
Update votes and start new tasks
[ "Update", "votes", "and", "start", "new", "tasks" ]
def mturk_iteration_task(show_progress=False): """ Update votes and start new tasks """ if not settings.MTURK_PIPELINE_ENABLE: print "mturk_iteration_task: Not running since MTURK_PIPELINE_ENABLE=%s" % ( settings.MTURK_PIPELINE_ENABLE) return if not os.path.isfile('manage.py'): raise RuntimeError('Worker not in server directory') if os.path.exists('.disable-mturk'): print "mturk_iteration_task: Not running since .disable-mturk file exists" return #mturk_update_votes_cubam_task(show_progress=show_progress) consume_pending_objects_task() if settings.MTURK_CONFIGURE_QUALIFICATIONS: configure_qualifications_task()
[ "def", "mturk_iteration_task", "(", "show_progress", "=", "False", ")", ":", "if", "not", "settings", ".", "MTURK_PIPELINE_ENABLE", ":", "print", "\"mturk_iteration_task: Not running since MTURK_PIPELINE_ENABLE=%s\"", "%", "(", "settings", ".", "MTURK_PIPELINE_ENABLE", ")",...
https://github.com/seanbell/opensurfaces/blob/7f3e987560faa62cd37f821760683ccd1e053c7c/server/mturk/tasks.py#L26-L40
dulwich/dulwich
1f66817d712e3563ce1ff53b1218491a2eae39da
dulwich/object_store.py
python
MemoryObjectStore.add_objects
(self, objects, progress=None)
Add a set of objects to this object store. Args: objects: Iterable over a list of (object, path) tuples
Add a set of objects to this object store.
[ "Add", "a", "set", "of", "objects", "to", "this", "object", "store", "." ]
def add_objects(self, objects, progress=None): """Add a set of objects to this object store. Args: objects: Iterable over a list of (object, path) tuples """ for obj, path in objects: self.add_object(obj)
[ "def", "add_objects", "(", "self", ",", "objects", ",", "progress", "=", "None", ")", ":", "for", "obj", ",", "path", "in", "objects", ":", "self", ".", "add_object", "(", "obj", ")" ]
https://github.com/dulwich/dulwich/blob/1f66817d712e3563ce1ff53b1218491a2eae39da/dulwich/object_store.py#L996-L1003
inspurer/WorkAttendanceSystem
1221e2d67bdf5bb15fe99517cc3ded58ccb066df
V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/ipaddress.py
python
IPv6Address.ipv4_mapped
(self)
return IPv4Address(self._ip & 0xFFFFFFFF)
Return the IPv4 mapped address. Returns: If the IPv6 address is a v4 mapped address, return the IPv4 mapped address. Return None otherwise.
Return the IPv4 mapped address.
[ "Return", "the", "IPv4", "mapped", "address", "." ]
def ipv4_mapped(self): """Return the IPv4 mapped address. Returns: If the IPv6 address is a v4 mapped address, return the IPv4 mapped address. Return None otherwise. """ if (self._ip >> 32) != 0xFFFF: return None return IPv4Address(self._ip & 0xFFFFFFFF)
[ "def", "ipv4_mapped", "(", "self", ")", ":", "if", "(", "self", ".", "_ip", ">>", "32", ")", "!=", "0xFFFF", ":", "return", "None", "return", "IPv4Address", "(", "self", ".", "_ip", "&", "0xFFFFFFFF", ")" ]
https://github.com/inspurer/WorkAttendanceSystem/blob/1221e2d67bdf5bb15fe99517cc3ded58ccb066df/V2.0/venv/Lib/site-packages/pip-9.0.1-py3.5.egg/pip/_vendor/ipaddress.py#L2142-L2152
h2non/pook
d2970eff5ef7b611e786422145cff4f6d6df412e
pook/api.py
python
disable_network
()
Disables real traffic networking mode in the current mock engine.
Disables real traffic networking mode in the current mock engine.
[ "Disables", "real", "traffic", "networking", "mode", "in", "the", "current", "mock", "engine", "." ]
def disable_network(): """ Disables real traffic networking mode in the current mock engine. """ _engine.disable_network()
[ "def", "disable_network", "(", ")", ":", "_engine", ".", "disable_network", "(", ")" ]
https://github.com/h2non/pook/blob/d2970eff5ef7b611e786422145cff4f6d6df412e/pook/api.py#L266-L270
ComplianceAsCode/content
6760a14e7fe3fb34205bd1a165095a9334412e95
ssg/ext/boolean/boolean.py
python
NOT.__call__
(self, **kwargs)
return not self.args[0](**kwargs)
Return the evaluated (negated) value for this function.
Return the evaluated (negated) value for this function.
[ "Return", "the", "evaluated", "(", "negated", ")", "value", "for", "this", "function", "." ]
def __call__(self, **kwargs): """ Return the evaluated (negated) value for this function. """ return not self.args[0](**kwargs)
[ "def", "__call__", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "not", "self", ".", "args", "[", "0", "]", "(", "*", "*", "kwargs", ")" ]
https://github.com/ComplianceAsCode/content/blob/6760a14e7fe3fb34205bd1a165095a9334412e95/ssg/ext/boolean/boolean.py#L1106-L1110
sympy/sympy
d822fcba181155b85ff2b29fe525adbafb22b448
sympy/physics/vector/dyadic.py
python
Dyadic.__truediv__
(self, other)
return self.__mul__(1 / other)
Divides the Dyadic by a sympifyable expression.
Divides the Dyadic by a sympifyable expression.
[ "Divides", "the", "Dyadic", "by", "a", "sympifyable", "expression", "." ]
def __truediv__(self, other): """Divides the Dyadic by a sympifyable expression. """ return self.__mul__(1 / other)
[ "def", "__truediv__", "(", "self", ",", "other", ")", ":", "return", "self", ".", "__mul__", "(", "1", "/", "other", ")" ]
https://github.com/sympy/sympy/blob/d822fcba181155b85ff2b29fe525adbafb22b448/sympy/physics/vector/dyadic.py#L110-L112
rwth-i6/returnn
f2d718a197a280b0d5f0fd91a7fcb8658560dddb
returnn/tf/layers/rec.py
python
RecLayer._post_proc_output_cell_strict
(self, y, in_data)
return out_data.placeholder
:param tf.Tensor y: (time,batch,dim) :param Data in_data: :rtype: tf.Tensor :return: (time,batch,dim) or (time,batch,...,dim)
:param tf.Tensor y: (time,batch,dim) :param Data in_data: :rtype: tf.Tensor :return: (time,batch,dim) or (time,batch,...,dim)
[ ":", "param", "tf", ".", "Tensor", "y", ":", "(", "time", "batch", "dim", ")", ":", "param", "Data", "in_data", ":", ":", "rtype", ":", "tf", ".", "Tensor", ":", "return", ":", "(", "time", "batch", "dim", ")", "or", "(", "time", "batch", "...", ...
def _post_proc_output_cell_strict(self, y, in_data): """ :param tf.Tensor y: (time,batch,dim) :param Data in_data: :rtype: tf.Tensor :return: (time,batch,dim) or (time,batch,...,dim) """ if in_data.batch_ndim_dense > 3: y_shape = tf_util.get_shape(in_data.placeholder) if not in_data.sparse: y_shape = y_shape[:-1] y_shape += [tf_util.get_shape_dim(y, -1)] y = tf.reshape(y, y_shape) out_data = in_data.copy_template_dense() out_data = out_data.copy_template_replace_dim_tag( axis=out_data.feature_dim_axis, new_dim_tag=self.output.feature_dim_or_sparse_dim) out_data.placeholder = y if not self.time_dim_tag: out_data = out_data.copy_squeeze_axes(axes=[0]) # The output format should match now. # If this is not the case, we should fix get_out_data_from_opts accordingly # and avoid unnecessary further transformations here, esp any transposes. assert out_data.dim_tags == self.output.dim_tags return out_data.placeholder
[ "def", "_post_proc_output_cell_strict", "(", "self", ",", "y", ",", "in_data", ")", ":", "if", "in_data", ".", "batch_ndim_dense", ">", "3", ":", "y_shape", "=", "tf_util", ".", "get_shape", "(", "in_data", ".", "placeholder", ")", "if", "not", "in_data", ...
https://github.com/rwth-i6/returnn/blob/f2d718a197a280b0d5f0fd91a7fcb8658560dddb/returnn/tf/layers/rec.py#L664-L687