Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
bartlett | (M) |
Return the Bartlett window.
The Bartlett window is very similar to a triangular window, except
that the end points are at zero. It is often used in signal
processing for tapering a signal, without generating too much
ripple in the frequency domain.
Parameters
----------
M : int
... |
Return the Bartlett window. | def bartlett(M):
"""
Return the Bartlett window.
The Bartlett window is very similar to a triangular window, except
that the end points are at zero. It is often used in signal
processing for tapering a signal, without generating too much
ripple in the frequency domain.
Parameters
----... | [
"def",
"bartlett",
"(",
"M",
")",
":",
"if",
"M",
"<",
"1",
":",
"return",
"array",
"(",
"[",
"]",
")",
"if",
"M",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
",",
"float",
")",
"n",
"=",
"arange",
"(",
"0",
",",
"M",
")",
"return",
"where"... | [
2647,
0
] | [
2752,
74
] | python | en | ['en', 'error', 'th'] | False |
hanning | (M) |
Return the Hanning window.
The Hanning window is a taper formed by using a weighted cosine.
Parameters
----------
M : int
Number of points in the output window. If zero or less, an
empty array is returned.
Returns
-------
out : ndarray, shape(M,)
The window, w... |
Return the Hanning window. | def hanning(M):
"""
Return the Hanning window.
The Hanning window is a taper formed by using a weighted cosine.
Parameters
----------
M : int
Number of points in the output window. If zero or less, an
empty array is returned.
Returns
-------
out : ndarray, shape(M,... | [
"def",
"hanning",
"(",
"M",
")",
":",
"if",
"M",
"<",
"1",
":",
"return",
"array",
"(",
"[",
"]",
")",
"if",
"M",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
",",
"float",
")",
"n",
"=",
"arange",
"(",
"0",
",",
"M",
")",
"return",
"0.5",
... | [
2756,
0
] | [
2856,
40
] | python | en | ['en', 'error', 'th'] | False |
hamming | (M) |
Return the Hamming window.
The Hamming window is a taper formed by using a weighted cosine.
Parameters
----------
M : int
Number of points in the output window. If zero or less, an
empty array is returned.
Returns
-------
out : ndarray
The window, with the max... |
Return the Hamming window. | def hamming(M):
"""
Return the Hamming window.
The Hamming window is a taper formed by using a weighted cosine.
Parameters
----------
M : int
Number of points in the output window. If zero or less, an
empty array is returned.
Returns
-------
out : ndarray
T... | [
"def",
"hamming",
"(",
"M",
")",
":",
"if",
"M",
"<",
"1",
":",
"return",
"array",
"(",
"[",
"]",
")",
"if",
"M",
"==",
"1",
":",
"return",
"ones",
"(",
"1",
",",
"float",
")",
"n",
"=",
"arange",
"(",
"0",
",",
"M",
")",
"return",
"0.54",
... | [
2860,
0
] | [
2956,
42
] | python | en | ['en', 'error', 'th'] | False |
StatusBar.text | (self, text) | Set informational text | Set informational text | def text(self, text):
""" Set informational text """
self.text_value.set(str(text)[:120]) | [
"def",
"text",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"text_value",
".",
"set",
"(",
"str",
"(",
"text",
")",
"[",
":",
"120",
"]",
")"
] | [
127,
4
] | [
129,
44
] | python | en | ['en', 'lb', 'en'] | True |
StatusBar.status | (self, status) | Set status text | Set status text | def status(self, status):
""" Set status text """
self.status_value.set(status) | [
"def",
"status",
"(",
"self",
",",
"status",
")",
":",
"self",
".",
"status_value",
".",
"set",
"(",
"status",
")"
] | [
131,
4
] | [
133,
37
] | python | en | ['en', 'el-Latn', 'en'] | True |
StatusBar.indicator | (self, color) | Set or reset indicator color | Set or reset indicator color | def indicator(self, color):
""" Set or reset indicator color """
self.indicator_label.config(bg=color if color else self.no_color)
self.update_idletasks() | [
"def",
"indicator",
"(",
"self",
",",
"color",
")",
":",
"self",
".",
"indicator_label",
".",
"config",
"(",
"bg",
"=",
"color",
"if",
"color",
"else",
"self",
".",
"no_color",
")",
"self",
".",
"update_idletasks",
"(",
")"
] | [
135,
4
] | [
138,
31
] | python | en | ['en', 'en', 'en'] | True |
LabelVarGrid.text | (self, text) | Set textvariable of label | Set textvariable of label | def text(self, text):
""" Set textvariable of label """
self.value.set(text) | [
"def",
"text",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"value",
".",
"set",
"(",
"text",
")"
] | [
149,
4
] | [
151,
28
] | python | en | ['en', 'en', 'en'] | True |
Dashboard.update_widgets | (self) | Set values of dashboard widgets | Set values of dashboard widgets | def update_widgets(self):
""" Set values of dashboard widgets """
cl = app.vehicle['climate_state']
ve = app.vehicle['vehicle_state']
dr = app.vehicle['drive_state']
ch = app.vehicle['charge_state']
co = app.vehicle['vehicle_config']
# Climate state
... | [
"def",
"update_widgets",
"(",
"self",
")",
":",
"cl",
"=",
"app",
".",
"vehicle",
"[",
"'climate_state'",
"]",
"ve",
"=",
"app",
".",
"vehicle",
"[",
"'vehicle_state'",
"]",
"dr",
"=",
"app",
".",
"vehicle",
"[",
"'drive_state'",
"]",
"ch",
"=",
"app",... | [
282,
4
] | [
380,
58
] | python | en | ['en', 'so', 'en'] | True |
Dashboard._heading_to_str | (deg) | Convert heading in degrees to a direction string | Convert heading in degrees to a direction string | def _heading_to_str(deg):
""" Convert heading in degrees to a direction string """
lst = ['NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW',
'WSW', 'W', 'WNW', 'NW', 'NNW', 'N']
return lst[int(abs((deg - 11.25) % 360) / 22.5)] | [
"def",
"_heading_to_str",
"(",
"deg",
")",
":",
"lst",
"=",
"[",
"'NNE'",
",",
"'NE'",
",",
"'ENE'",
",",
"'E'",
",",
"'ESE'",
",",
"'SE'",
",",
"'SSE'",
",",
"'S'",
",",
"'SSW'",
",",
"'SW'",
",",
"'WSW'",
",",
"'W'",
",",
"'WNW'",
",",
"'NW'",
... | [
383,
4
] | [
387,
56
] | python | en | ['en', 'en', 'en'] | True |
App.add_cmd_args | (self, endpoint) | Return add_command arguments for given named endpoint | Return add_command arguments for given named endpoint | def add_cmd_args(self, endpoint):
""" Return add_command arguments for given named endpoint """
return {'label': endpoint.capitalize().replace('_', ' '),
'state': DISABLED, 'command': lambda: self.cmd(endpoint)} | [
"def",
"add_cmd_args",
"(",
"self",
",",
"endpoint",
")",
":",
"return",
"{",
"'label'",
":",
"endpoint",
".",
"capitalize",
"(",
")",
".",
"replace",
"(",
"'_'",
",",
"' '",
")",
",",
"'state'",
":",
"DISABLED",
",",
"'command'",
":",
"lambda",
":",
... | [
489,
4
] | [
492,
73
] | python | en | ['en', 'en', 'en'] | True |
App.get_passcode | (self) | Ask user for passcode string in new dialog | Ask user for passcode string in new dialog | def get_passcode(self):
""" Ask user for passcode string in new dialog """
result = ['not_set']
def show_dialog():
""" Inner function to show dialog """
result[0] = askstring('Login', 'Passcode:')
self.after_idle(show_dialog) # Start from main thread
... | [
"def",
"get_passcode",
"(",
"self",
")",
":",
"result",
"=",
"[",
"'not_set'",
"]",
"def",
"show_dialog",
"(",
")",
":",
"\"\"\" Inner function to show dialog \"\"\"",
"result",
"[",
"0",
"]",
"=",
"askstring",
"(",
"'Login'",
",",
"'Passcode:'",
")",
"self",
... | [
494,
4
] | [
503,
24
] | python | en | ['en', 'en', 'en'] | True |
App.select_factor | (self, factors) | Let user select authorization factor | Let user select authorization factor | def select_factor(self, factors):
""" Let user select authorization factor """
result = [{}]
def show_dialog():
""" Inner function to show dialog """
dlg = SelectFactorDialog(self, 'Select factor', factors)
result[0] = dlg.result
self.after_idle... | [
"def",
"select_factor",
"(",
"self",
",",
"factors",
")",
":",
"result",
"=",
"[",
"{",
"}",
"]",
"def",
"show_dialog",
"(",
")",
":",
"\"\"\" Inner function to show dialog \"\"\"",
"dlg",
"=",
"SelectFactorDialog",
"(",
"self",
",",
"'Select factor'",
",",
"f... | [
505,
4
] | [
515,
24
] | python | en | ['fr', 'en', 'en'] | True |
App.login | (self) | Display login dialog and start new thread to get vehicle list | Display login dialog and start new thread to get vehicle list | def login(self):
""" Display login dialog and start new thread to get vehicle list """
dlg = LoginDialog(self)
if dlg.result:
self.email, self.password = dlg.result
self.status.text('Logging in...')
retry = teslapy.Retry(total=2,
... | [
"def",
"login",
"(",
"self",
")",
":",
"dlg",
"=",
"LoginDialog",
"(",
"self",
")",
"if",
"dlg",
".",
"result",
":",
"self",
".",
"email",
",",
"self",
".",
"password",
"=",
"dlg",
".",
"result",
"self",
".",
"status",
".",
"text",
"(",
"'Logging i... | [
517,
4
] | [
530,
47
] | python | en | ['en', 'en', 'en'] | True |
App.process_login | (self) | Waits for thread to finish and updates vehicle menu | Waits for thread to finish and updates vehicle menu | def process_login(self):
""" Waits for thread to finish and updates vehicle menu """
if self.login_thread.is_alive():
# Check again after 100 ms
self.after(100, self.process_login)
elif self.login_thread.exception:
self.status.text(self.login_thread.exce... | [
"def",
"process_login",
"(",
"self",
")",
":",
"if",
"self",
".",
"login_thread",
".",
"is_alive",
"(",
")",
":",
"# Check again after 100 ms\r",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_login",
")",
"elif",
"self",
".",
"login_thread",
... | [
532,
4
] | [
556,
47
] | python | en | ['en', 'en', 'en'] | True |
App.select | (self) | Select vehicle and start new thread to get vehicle image | Select vehicle and start new thread to get vehicle image | def select(self):
""" Select vehicle and start new thread to get vehicle image """
self.vehicle = self.login_thread.vehicles[self.selected.get()]
# Create and start image thread. Check thread status after 100 ms
self.image_thread = ImageThread(self.vehicle)
self.image_thread... | [
"def",
"select",
"(",
"self",
")",
":",
"self",
".",
"vehicle",
"=",
"self",
".",
"login_thread",
".",
"vehicles",
"[",
"self",
".",
"selected",
".",
"get",
"(",
")",
"]",
"# Create and start image thread. Check thread status after 100 ms\r",
"self",
".",
"image... | [
558,
4
] | [
568,
31
] | python | en | ['en', 'en', 'en'] | True |
App.process_select | (self) | Waits for thread to finish and displays vehicle image | Waits for thread to finish and displays vehicle image | def process_select(self):
""" Waits for thread to finish and displays vehicle image """
if self.image_thread.is_alive():
# Check again after 100 ms
self.after(100, self.process_select)
elif self.image_thread.exception:
# Handle errors
self.s... | [
"def",
"process_select",
"(",
"self",
")",
":",
"if",
"self",
".",
"image_thread",
".",
"is_alive",
"(",
")",
":",
"# Check again after 100 ms\r",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_select",
")",
"elif",
"self",
".",
"image_thread",... | [
570,
4
] | [
580,
78
] | python | en | ['en', 'en', 'en'] | True |
App.show_status | (self) | Display vehicle state | Display vehicle state | def show_status(self):
""" Display vehicle state """
self.status.text('%s is %s' % (self.vehicle['display_name'],
self.vehicle['state']))
# Enable/disable commands
state = NORMAL if self.vehicle['state'] == 'online' else DISABLED
for i... | [
"def",
"show_status",
"(",
"self",
")",
":",
"self",
".",
"status",
".",
"text",
"(",
"'%s is %s'",
"%",
"(",
"self",
".",
"vehicle",
"[",
"'display_name'",
"]",
",",
"self",
".",
"vehicle",
"[",
"'state'",
"]",
")",
")",
"# Enable/disable commands\r",
"... | [
582,
4
] | [
593,
59
] | python | en | ['en', 'af', 'en'] | True |
App.update_status | (self) | Creates a new thread to get vehicle summary | Creates a new thread to get vehicle summary | def update_status(self):
""" Creates a new thread to get vehicle summary """
self.status_thread = StatusThread(self.vehicle)
# Don't start if auto refresh is enabled
if not self.auto_refresh.get() or self.vehicle['state'] != 'online':
self.status_thread.start()
... | [
"def",
"update_status",
"(",
"self",
")",
":",
"self",
".",
"status_thread",
"=",
"StatusThread",
"(",
"self",
".",
"vehicle",
")",
"# Don't start if auto refresh is enabled\r",
"if",
"not",
"self",
".",
"auto_refresh",
".",
"get",
"(",
")",
"or",
"self",
".",... | [
595,
4
] | [
601,
44
] | python | en | ['en', 'en', 'en'] | True |
App.process_status | (self) | Waits for thread to finish and updates status | Waits for thread to finish and updates status | def process_status(self):
""" Waits for thread to finish and updates status """
if self.status_thread.is_alive():
self.after(100, self.process_status)
else:
# Increase status polling rate if vehicle is online
delay = 60000 if self.vehicle['state'] == 'on... | [
"def",
"process_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"status_thread",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_status",
")",
"else",
":",
"# Increase status polling rate if vehicle is online\r",
... | [
603,
4
] | [
615,
34
] | python | en | ['en', 'en', 'en'] | True |
App.update_dashboard | (self, scheduled=False) | Create new thread to get vehicle data | Create new thread to get vehicle data | def update_dashboard(self, scheduled=False):
""" Create new thread to get vehicle data """
if scheduled:
self.update_scheduled = False
if hasattr(self, 'vehicle') and self.vehicle['state'] != 'online':
return
if hasattr(self, 'update_thread') and self.update... | [
"def",
"update_dashboard",
"(",
"self",
",",
"scheduled",
"=",
"False",
")",
":",
"if",
"scheduled",
":",
"self",
".",
"update_scheduled",
"=",
"False",
"if",
"hasattr",
"(",
"self",
",",
"'vehicle'",
")",
"and",
"self",
".",
"vehicle",
"[",
"'state'",
"... | [
617,
4
] | [
629,
58
] | python | en | ['en', 'en', 'en'] | True |
App.process_update_dashboard | (self) | Waits for thread to finish and updates dashboard data | Waits for thread to finish and updates dashboard data | def process_update_dashboard(self):
""" Waits for thread to finish and updates dashboard data """
if self.update_thread.is_alive():
self.after(100, self.process_update_dashboard)
return
try:
delay = 4000 # Default update polling rate
if sel... | [
"def",
"process_update_dashboard",
"(",
"self",
")",
":",
"if",
"self",
".",
"update_thread",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_update_dashboard",
")",
"return",
"try",
":",
"delay",
"=",
"4000",
... | [
631,
4
] | [
663,
17
] | python | en | ['en', 'en', 'en'] | True |
App.wake_up | (self) | Creates a new thread to wake up vehicle | Creates a new thread to wake up vehicle | def wake_up(self):
""" Creates a new thread to wake up vehicle """
self.status.text('Please wait...')
self.wake_up_thread = WakeUpThread(self.vehicle)
self.wake_up_thread.start()
self.after(100, self.process_wake_up)
# Disable wake up command
self.cmd_menu.... | [
"def",
"wake_up",
"(",
"self",
")",
":",
"self",
".",
"status",
".",
"text",
"(",
"'Please wait...'",
")",
"self",
".",
"wake_up_thread",
"=",
"WakeUpThread",
"(",
"self",
".",
"vehicle",
")",
"self",
".",
"wake_up_thread",
".",
"start",
"(",
")",
"self"... | [
665,
4
] | [
672,
52
] | python | en | ['en', 'en', 'en'] | True |
App.process_wake_up | (self) | Waits for thread to finish and updates widgets | Waits for thread to finish and updates widgets | def process_wake_up(self):
""" Waits for thread to finish and updates widgets """
if self.wake_up_thread.is_alive():
self.after(100, self.process_wake_up)
elif self.wake_up_thread.exception:
self.status.text(self.wake_up_thread.exception)
self.cmd_menu.e... | [
"def",
"process_wake_up",
"(",
"self",
")",
":",
"if",
"self",
".",
"wake_up_thread",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_wake_up",
")",
"elif",
"self",
".",
"wake_up_thread",
".",
"exception",
":"... | [
674,
4
] | [
684,
35
] | python | en | ['en', 'en', 'en'] | True |
App.about | (self) | Show about dialog | Show about dialog | def about(self):
""" Show about dialog """
LabelGridDialog(self, 'About',
[{'text': 'Tesla Owner API Python GUI by Tim Dorssers'},
{'text': 'Tcl/Tk toolkit version %s' % TkVersion}]) | [
"def",
"about",
"(",
"self",
")",
":",
"LabelGridDialog",
"(",
"self",
",",
"'About'",
",",
"[",
"{",
"'text'",
":",
"'Tesla Owner API Python GUI by Tim Dorssers'",
"}",
",",
"{",
"'text'",
":",
"'Tcl/Tk toolkit version %s'",
"%",
"TkVersion",
"}",
"]",
")"
] | [
686,
4
] | [
690,
76
] | python | en | ['en', 'en', 'en'] | True |
App.option_codes | (self) | Show vehicle option codes in a dialog | Show vehicle option codes in a dialog | def option_codes(self):
""" Show vehicle option codes in a dialog """
table = []
for i, item in enumerate(self.vehicle.option_code_list()):
table.append(dict(text=item, row=i // 2, column=i % 2, sticky=W))
LabelGridDialog(self, 'Option codes', table) | [
"def",
"option_codes",
"(",
"self",
")",
":",
"table",
"=",
"[",
"]",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"self",
".",
"vehicle",
".",
"option_code_list",
"(",
")",
")",
":",
"table",
".",
"append",
"(",
"dict",
"(",
"text",
"=",
"item... | [
692,
4
] | [
697,
52
] | python | en | ['en', 'en', 'en'] | True |
App.decode_vin | (self) | Show decoded vin in a dialog | Show decoded vin in a dialog | def decode_vin(self):
""" Show decoded vin in a dialog """
table = []
for i, item in enumerate(self.vehicle.decode_vin().items()):
table.append(dict(text=item[0] + ':', row=i, sticky=E))
table.append(dict(text=item[1], row=i, column=1, sticky=W))
LabelGridDi... | [
"def",
"decode_vin",
"(",
"self",
")",
":",
"table",
"=",
"[",
"]",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"self",
".",
"vehicle",
".",
"decode_vin",
"(",
")",
".",
"items",
"(",
")",
")",
":",
"table",
".",
"append",
"(",
"dict",
"(",
... | [
699,
4
] | [
705,
50
] | python | en | ['en', 'en', 'nl'] | True |
App.charging_sites | (self) | Creates a new thread to get nearby charging sites | Creates a new thread to get nearby charging sites | def charging_sites(self):
""" Creates a new thread to get nearby charging sites """
self.status.text('Please wait...')
self.nearby_sites_thread = NearbySitesThread(self.vehicle)
self.nearby_sites_thread.start()
self.after(100, self.process_charging_sites) | [
"def",
"charging_sites",
"(",
"self",
")",
":",
"self",
".",
"status",
".",
"text",
"(",
"'Please wait...'",
")",
"self",
".",
"nearby_sites_thread",
"=",
"NearbySitesThread",
"(",
"self",
".",
"vehicle",
")",
"self",
".",
"nearby_sites_thread",
".",
"start",
... | [
707,
4
] | [
712,
52
] | python | en | ['en', 'en', 'en'] | True |
App.process_charging_sites | (self) | Waits for thread to finish and displays sites in a dialog box | Waits for thread to finish and displays sites in a dialog box | def process_charging_sites(self):
""" Waits for thread to finish and displays sites in a dialog box """
if self.nearby_sites_thread.is_alive():
self.after(100, self.process_charging_sites)
elif self.nearby_sites_thread.exception:
self.status.text(self.nearby_sites_th... | [
"def",
"process_charging_sites",
"(",
"self",
")",
":",
"if",
"self",
".",
"nearby_sites_thread",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_charging_sites",
")",
"elif",
"self",
".",
"nearby_sites_thread",
"... | [
714,
4
] | [
740,
65
] | python | en | ['en', 'en', 'en'] | True |
App.cmd | (self, name, **kwargs) | Creates a new thread to command vehicle | Creates a new thread to command vehicle | def cmd(self, name, **kwargs):
""" Creates a new thread to command vehicle """
self.status.text('Please wait...')
self.command_thread = CommandThread(self.vehicle, name, **kwargs)
self.command_thread.start()
self.after(100, self.process_cmd) | [
"def",
"cmd",
"(",
"self",
",",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"status",
".",
"text",
"(",
"'Please wait...'",
")",
"self",
".",
"command_thread",
"=",
"CommandThread",
"(",
"self",
".",
"vehicle",
",",
"name",
",",
"*",
"*",... | [
742,
4
] | [
747,
41
] | python | en | ['en', 'en', 'en'] | True |
App.process_cmd | (self) | Waits for thread to finish and update widgets | Waits for thread to finish and update widgets | def process_cmd(self):
""" Waits for thread to finish and update widgets """
if self.command_thread.is_alive():
self.after(100, self.process_cmd)
elif self.command_thread.exception:
self.status.text(self.command_thread.exception)
else:
# Update ... | [
"def",
"process_cmd",
"(",
"self",
")",
":",
"if",
"self",
".",
"command_thread",
".",
"is_alive",
"(",
")",
":",
"self",
".",
"after",
"(",
"100",
",",
"self",
".",
"process_cmd",
")",
"elif",
"self",
".",
"command_thread",
".",
"exception",
":",
"sel... | [
749,
4
] | [
758,
55
] | python | en | ['en', 'en', 'en'] | True |
App.lock_unlock | (self) | Lock or unlock vehicle | Lock or unlock vehicle | def lock_unlock(self):
""" Lock or unlock vehicle """
if self.vehicle['vehicle_state']['locked']:
self.cmd('UNLOCK')
else:
self.cmd('LOCK') | [
"def",
"lock_unlock",
"(",
"self",
")",
":",
"if",
"self",
".",
"vehicle",
"[",
"'vehicle_state'",
"]",
"[",
"'locked'",
"]",
":",
"self",
".",
"cmd",
"(",
"'UNLOCK'",
")",
"else",
":",
"self",
".",
"cmd",
"(",
"'LOCK'",
")"
] | [
760,
4
] | [
765,
28
] | python | en | ['en', 'et', 'en'] | True |
App.climate_on_off | (self) | Turn climate control on or off | Turn climate control on or off | def climate_on_off(self):
""" Turn climate control on or off """
if self.vehicle['climate_state']['is_climate_on']:
self.cmd('CLIMATE_OFF')
else:
self.cmd('CLIMATE_ON') | [
"def",
"climate_on_off",
"(",
"self",
")",
":",
"if",
"self",
".",
"vehicle",
"[",
"'climate_state'",
"]",
"[",
"'is_climate_on'",
"]",
":",
"self",
".",
"cmd",
"(",
"'CLIMATE_OFF'",
")",
"else",
":",
"self",
".",
"cmd",
"(",
"'CLIMATE_ON'",
")"
] | [
767,
4
] | [
772,
34
] | python | en | ['en', 'en', 'en'] | True |
App.set_temperature | (self) | Set climate control temperature | Set climate control temperature | def set_temperature(self):
""" Set climate control temperature """
# Get user input using a simple dialog box
temp = askfloat('Set', 'Temperature')
if temp:
self.cmd('CHANGE_CLIMATE_TEMPERATURE_SETTING', driver_temp=temp,
passenger_temp=temp) | [
"def",
"set_temperature",
"(",
"self",
")",
":",
"# Get user input using a simple dialog box\r",
"temp",
"=",
"askfloat",
"(",
"'Set'",
",",
"'Temperature'",
")",
"if",
"temp",
":",
"self",
".",
"cmd",
"(",
"'CHANGE_CLIMATE_TEMPERATURE_SETTING'",
",",
"driver_temp",
... | [
774,
4
] | [
780,
41
] | python | en | ['en', 'la', 'en'] | True |
App.actuate_trunk | (self, which_trunk) | Actuate trunk or frunk | Actuate trunk or frunk | def actuate_trunk(self, which_trunk):
""" Actuate trunk or frunk """
self.cmd('ACTUATE_TRUNK', which_trunk=which_trunk) | [
"def",
"actuate_trunk",
"(",
"self",
",",
"which_trunk",
")",
":",
"self",
".",
"cmd",
"(",
"'ACTUATE_TRUNK'",
",",
"which_trunk",
"=",
"which_trunk",
")"
] | [
782,
4
] | [
784,
58
] | python | en | ['en', 'en', 'en'] | True |
App.remote_start_drive | (self) | Trigger remote start drive | Trigger remote start drive | def remote_start_drive(self):
""" Trigger remote start drive """
if self.password:
self.cmd('REMOTE_START', password=self.password)
else:
self.status.text('Password required') | [
"def",
"remote_start_drive",
"(",
"self",
")",
":",
"if",
"self",
".",
"password",
":",
"self",
".",
"cmd",
"(",
"'REMOTE_START'",
",",
"password",
"=",
"self",
".",
"password",
")",
"else",
":",
"self",
".",
"status",
".",
"text",
"(",
"'Password requir... | [
786,
4
] | [
791,
49
] | python | en | ['fr', 'it', 'en'] | False |
App.set_charge_limit | (self) | Set charging limit | Set charging limit | def set_charge_limit(self):
""" Set charging limit """
limit = askinteger('Set', 'Charge Limit')
if limit:
self.cmd('CHANGE_CHARGE_LIMIT', percent=limit) | [
"def",
"set_charge_limit",
"(",
"self",
")",
":",
"limit",
"=",
"askinteger",
"(",
"'Set'",
",",
"'Charge Limit'",
")",
"if",
"limit",
":",
"self",
".",
"cmd",
"(",
"'CHANGE_CHARGE_LIMIT'",
",",
"percent",
"=",
"limit",
")"
] | [
793,
4
] | [
797,
58
] | python | de | ['de', 'fr', 'en'] | False |
App.open_close_charge_port | (self) | Open, unlock or close charging port | Open, unlock or close charging port | def open_close_charge_port(self):
""" Open, unlock or close charging port """
if (self.vehicle['charge_state']['charge_port_door_open'] and
self.vehicle['charge_state']['charge_port_latch'] != 'Engaged'):
self.cmd('CHARGE_PORT_DOOR_CLOSE')
else:
self... | [
"def",
"open_close_charge_port",
"(",
"self",
")",
":",
"if",
"(",
"self",
".",
"vehicle",
"[",
"'charge_state'",
"]",
"[",
"'charge_port_door_open'",
"]",
"and",
"self",
".",
"vehicle",
"[",
"'charge_state'",
"]",
"[",
"'charge_port_latch'",
"]",
"!=",
"'Enga... | [
799,
4
] | [
805,
45
] | python | en | ['en', 'ca', 'en'] | True |
App.start_stop_charge | (self) | Start or stop vehicle charging | Start or stop vehicle charging | def start_stop_charge(self):
""" Start or stop vehicle charging """
if self.vehicle['charge_state']['charging_state'].lower() == 'charging':
self.cmd('STOP_CHARGE')
else:
self.cmd('START_CHARGE') | [
"def",
"start_stop_charge",
"(",
"self",
")",
":",
"if",
"self",
".",
"vehicle",
"[",
"'charge_state'",
"]",
"[",
"'charging_state'",
"]",
".",
"lower",
"(",
")",
"==",
"'charging'",
":",
"self",
".",
"cmd",
"(",
"'STOP_CHARGE'",
")",
"else",
":",
"self"... | [
807,
4
] | [
812,
36
] | python | en | ['en', 'en', 'en'] | True |
App.seat_heater | (self) | Ask user which seat to heat | Ask user which seat to heat | def seat_heater(self):
""" Ask user which seat to heat """
dlg = SeatHeaterDialog(self)
if dlg.result:
self.cmd('REMOTE_SEAT_HEATER_REQUEST', heater=dlg.result[0],
level=dlg.result[1]) | [
"def",
"seat_heater",
"(",
"self",
")",
":",
"dlg",
"=",
"SeatHeaterDialog",
"(",
"self",
")",
"if",
"dlg",
".",
"result",
":",
"self",
".",
"cmd",
"(",
"'REMOTE_SEAT_HEATER_REQUEST'",
",",
"heater",
"=",
"dlg",
".",
"result",
"[",
"0",
"]",
",",
"leve... | [
814,
4
] | [
819,
41
] | python | en | ['en', 'en', 'en'] | True |
App.vent_close_sun_roof | (self) | Ask user to vent or close the sun roof | Ask user to vent or close the sun roof | def vent_close_sun_roof(self):
""" Ask user to vent or close the sun roof """
dlg = ControlDialog(self, 'Sun Roof')
if dlg.result:
self.cmd('CHANGE_SUNROOF_STATE', state=dlg.result) | [
"def",
"vent_close_sun_roof",
"(",
"self",
")",
":",
"dlg",
"=",
"ControlDialog",
"(",
"self",
",",
"'Sun Roof'",
")",
"if",
"dlg",
".",
"result",
":",
"self",
".",
"cmd",
"(",
"'CHANGE_SUNROOF_STATE'",
",",
"state",
"=",
"dlg",
".",
"result",
")"
] | [
821,
4
] | [
825,
62
] | python | en | ['en', 'en', 'en'] | True |
App.schedule_sw_update | (self) | Start software upgrade in two minutes | Start software upgrade in two minutes | def schedule_sw_update(self):
""" Start software upgrade in two minutes """
self.cmd('SCHEDULE_SOFTWARE_UPDATE', offset_sec=120) | [
"def",
"schedule_sw_update",
"(",
"self",
")",
":",
"self",
".",
"cmd",
"(",
"'SCHEDULE_SOFTWARE_UPDATE'",
",",
"offset_sec",
"=",
"120",
")"
] | [
827,
4
] | [
829,
60
] | python | en | ['en', 'en', 'en'] | True |
App.window_control | (self) | Ask user to vent or close windows | Ask user to vent or close windows | def window_control(self):
""" Ask user to vent or close windows """
dlg = ControlDialog(self, 'Windows')
if dlg.result:
self.cmd('WINDOW_CONTROL', command=dlg.result, lat=0, lon=0) | [
"def",
"window_control",
"(",
"self",
")",
":",
"dlg",
"=",
"ControlDialog",
"(",
"self",
",",
"'Windows'",
")",
"if",
"dlg",
".",
"result",
":",
"self",
".",
"cmd",
"(",
"'WINDOW_CONTROL'",
",",
"command",
"=",
"dlg",
".",
"result",
",",
"lat",
"=",
... | [
831,
4
] | [
835,
72
] | python | en | ['en', 'en', 'en'] | True |
App.max_defrost | (self) | Set max defrost mode | Set max defrost mode | def max_defrost(self):
""" Set max defrost mode """
try:
if self.vehicle['climate_state']['defrost_mode']:
self.cmd('MAX_DEFROST', on=False)
else:
self.cmd('MAX_DEFROST', on=True)
except KeyError:
pass | [
"def",
"max_defrost",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"vehicle",
"[",
"'climate_state'",
"]",
"[",
"'defrost_mode'",
"]",
":",
"self",
".",
"cmd",
"(",
"'MAX_DEFROST'",
",",
"on",
"=",
"False",
")",
"else",
":",
"self",
".",
"cm... | [
837,
4
] | [
845,
16
] | python | ca | ['en', 'ca', 'nl'] | False |
App.set_log | (self) | Set logging level | Set logging level | def set_log(self):
""" Set logging level """
level = logging.DEBUG if self.debug.get() else logging.WARNING
logging.getLogger().setLevel(level) | [
"def",
"set_log",
"(",
"self",
")",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"if",
"self",
".",
"debug",
".",
"get",
"(",
")",
"else",
"logging",
".",
"WARNING",
"logging",
".",
"getLogger",
"(",
")",
".",
"setLevel",
"(",
"level",
")"
] | [
847,
4
] | [
850,
43
] | python | da | ['nl', 'da', 'en'] | False |
App.save_and_quit | (self) | Save settings to file and quit app | Save settings to file and quit app | def save_and_quit(self):
""" Save settings to file and quit app """
config = RawConfigParser()
config.add_section('app')
config.add_section('display')
if hasattr(self, 'email'):
config.set('app', 'email', self.email)
try:
config.set('displa... | [
"def",
"save_and_quit",
"(",
"self",
")",
":",
"config",
"=",
"RawConfigParser",
"(",
")",
"config",
".",
"add_section",
"(",
"'app'",
")",
"config",
".",
"add_section",
"(",
"'display'",
")",
"if",
"hasattr",
"(",
"self",
",",
"'email'",
")",
":",
"conf... | [
852,
4
] | [
867,
23
] | python | en | ['en', 'en', 'en'] | True |
App.changeFullscreenOption | (self, event=None) |
Método para colocar o jogo no modo "fullscreen" ou "window"
|
Método para colocar o jogo no modo "fullscreen" ou "window"
| def changeFullscreenOption(self, event=None):
"""
Método para colocar o jogo no modo "fullscreen" ou "window"
"""
self.window_fullscreen = not self.window_fullscreen
self.attributes("-fullscreen", self.window_fullscreen) | [
"def",
"changeFullscreenOption",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"self",
".",
"window_fullscreen",
"=",
"not",
"self",
".",
"window_fullscreen",
"self",
".",
"attributes",
"(",
"\"-fullscreen\"",
",",
"self",
".",
"window_fullscreen",
")"
] | [
95,
4
] | [
101,
62
] | python | en | ['en', 'error', 'th'] | False |
App.close | (self, event=None) |
Método para fechar o jogo
|
Método para fechar o jogo
| def close(self, event=None):
"""
Método para fechar o jogo
"""
# Salva a melhor pontuação do jogador antes de sair do jogo
self.saveScore()
# Tenta interromper os processos
try:
self.__background.stop()
self.__bird.kill()
self... | [
"def",
"close",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Salva a melhor pontuação do jogador antes de sair do jogo",
"self",
".",
"saveScore",
"(",
")",
"# Tenta interromper os processos",
"try",
":",
"self",
".",
"__background",
".",
"stop",
"(",
")",
... | [
103,
4
] | [
117,
18
] | python | en | ['en', 'error', 'th'] | False |
App.createMenuButtons | (self) |
Método para criar os botões de menu
|
Método para criar os botões de menu
| def createMenuButtons(self):
"""
Método para criar os botões de menu
"""
# Define o tamanho do botão em porcentagem com base no tamanho da janela
width = (self.__width // 100) * self.button_width
height = (self.__height // 100) * self.button_height
# Cria um bot... | [
"def",
"createMenuButtons",
"(",
"self",
")",
":",
"# Define o tamanho do botão em porcentagem com base no tamanho da janela",
"width",
"=",
"(",
"self",
".",
"__width",
"//",
"100",
")",
"*",
"self",
".",
"button_width",
"height",
"=",
"(",
"self",
".",
"__height",... | [
119,
4
] | [
149,
63
] | python | en | ['en', 'error', 'th'] | False |
App.createScoreBoard | (self) |
Método para criar a imagem do placar do jogo no background
junto com as informações do jogador.
|
Método para criar a imagem do placar do jogo no background
junto com as informações do jogador.
| def createScoreBoard(self):
"""
Método para criar a imagem do placar do jogo no background
junto com as informações do jogador.
"""
# Define a posição X e Y
x = self.__width // 2
y = (self.__height // 100) * self.scoreboard_position_y
# Calcula o tamanh... | [
"def",
"createScoreBoard",
"(",
"self",
")",
":",
"# Define a posição X e Y",
"x",
"=",
"self",
".",
"__width",
"//",
"2",
"y",
"=",
"(",
"self",
".",
"__height",
"//",
"100",
")",
"*",
"self",
".",
"scoreboard_position_y",
"# Calcula o tamanho da imagem do plac... | [
151,
4
] | [
199,
9
] | python | en | ['en', 'error', 'th'] | False |
App.createTitleImage | (self) |
Método para criar a imagem do título do jogo no background
|
Método para criar a imagem do título do jogo no background
| def createTitleImage(self):
"""
Método para criar a imagem do título do jogo no background
"""
self.__background.create_image(self.__width // 2, (self.__height // 100) * self.title_position_y,
image=self.__title_image) | [
"def",
"createTitleImage",
"(",
"self",
")",
":",
"self",
".",
"__background",
".",
"create_image",
"(",
"self",
".",
"__width",
"//",
"2",
",",
"(",
"self",
".",
"__height",
"//",
"100",
")",
"*",
"self",
".",
"title_position_y",
",",
"image",
"=",
"s... | [
201,
4
] | [
207,
64
] | python | en | ['en', 'error', 'th'] | False |
App.deleteMenuButtons | (self) |
Método para deletar os botões de menu
|
Método para deletar os botões de menu
| def deleteMenuButtons(self):
"""
Método para deletar os botões de menu
"""
# Deleta cada botão criado dentro do background
for item in self.__buttons:
self.__background.delete(item)
# Limpa a lista de botões
self.__buttons.clear() | [
"def",
"deleteMenuButtons",
"(",
"self",
")",
":",
"# Deleta cada botão criado dentro do background",
"for",
"item",
"in",
"self",
".",
"__buttons",
":",
"self",
".",
"__background",
".",
"delete",
"(",
"item",
")",
"# Limpa a lista de botões",
"self",
".",
"__butto... | [
209,
4
] | [
219,
30
] | python | en | ['en', 'error', 'th'] | False |
App.gameOver | (self) |
Método de fim de jogo
|
Método de fim de jogo
| def gameOver(self):
"""
Método de fim de jogo
"""
# Calcula o tempo jogado em segundos e depois o formata
self.__time = int(time() - self.__time)
self.__time = str(timedelta(seconds=self.__time))
# Interrompe a animação do plano de fundo e a animação dos tubos
... | [
"def",
"gameOver",
"(",
"self",
")",
":",
"# Calcula o tempo jogado em segundos e depois o formata",
"self",
".",
"__time",
"=",
"int",
"(",
"time",
"(",
")",
"-",
"self",
".",
"__time",
")",
"self",
".",
"__time",
"=",
"str",
"(",
"timedelta",
"(",
"seconds... | [
221,
4
] | [
244,
31
] | python | en | ['en', 'error', 'th'] | False |
App.increaseScore | (self) |
Método para aumentar a pontuação do jogo atual do jogador
|
Método para aumentar a pontuação do jogo atual do jogador
| def increaseScore(self):
"""
Método para aumentar a pontuação do jogo atual do jogador
"""
self.__score += 1
if self.__score > self.__bestScore:
self.__bestScore = self.__score | [
"def",
"increaseScore",
"(",
"self",
")",
":",
"self",
".",
"__score",
"+=",
"1",
"if",
"self",
".",
"__score",
">",
"self",
".",
"__bestScore",
":",
"self",
".",
"__bestScore",
"=",
"self",
".",
"__score"
] | [
246,
4
] | [
253,
43
] | python | en | ['en', 'error', 'th'] | False |
App.init | (self) |
Método para iniciar o programa em si, criando toda a parte gráfica inicial do jogo
|
Método para iniciar o programa em si, criando toda a parte gráfica inicial do jogo
| def init(self):
"""
Método para iniciar o programa em si, criando toda a parte gráfica inicial do jogo
"""
# self.createMenuButtons()
self.loadScore()
# Cria o plano de fundo do jogo
self.__background = Background(
self, self.__width, self.__height, ... | [
"def",
"init",
"(",
"self",
")",
":",
"# self.createMenuButtons()",
"self",
".",
"loadScore",
"(",
")",
"# Cria o plano de fundo do jogo",
"self",
".",
"__background",
"=",
"Background",
"(",
"self",
",",
"self",
".",
"__width",
",",
"self",
".",
"__height",
"... | [
255,
4
] | [
293,
9
] | python | en | ['en', 'error', 'th'] | False |
App.loadScore | (self) |
Método para carregar a pontuação do jogador
|
Método para carregar a pontuação do jogador
| def loadScore(self):
"""
Método para carregar a pontuação do jogador
"""
# Tenta carregar o placar do usuário
try:
file = open(self.score_fp)
self.__bestScore = int(file.read(), 2)
file.close()
# Se não for possível, será criado um ar... | [
"def",
"loadScore",
"(",
"self",
")",
":",
"# Tenta carregar o placar do usuário",
"try",
":",
"file",
"=",
"open",
"(",
"self",
".",
"score_fp",
")",
"self",
".",
"__bestScore",
"=",
"int",
"(",
"file",
".",
"read",
"(",
")",
",",
"2",
")",
"file",
".... | [
295,
4
] | [
310,
24
] | python | en | ['en', 'error', 'th'] | False |
App.saveScore | (self) |
Método para salvar a pontuação do jogador
|
Método para salvar a pontuação do jogador
| def saveScore(self):
"""
Método para salvar a pontuação do jogador
"""
with open(self.score_fp, 'w') as file:
file.write(bin(self.__bestScore)) | [
"def",
"saveScore",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"score_fp",
",",
"'w'",
")",
"as",
"file",
":",
"file",
".",
"write",
"(",
"bin",
"(",
"self",
".",
"__bestScore",
")",
")"
] | [
312,
4
] | [
318,
45
] | python | en | ['en', 'error', 'th'] | False |
App.start | (self, event=None) |
Método para inicializar o jogo
|
Método para inicializar o jogo
| def start(self, event=None):
"""
Método para inicializar o jogo
"""
# Este método é executado somente se o jogador não estiver já jogando
if self.__playing: return
# Reinicia o placar
self.__score = 0
self.__time = time()
# Remove os botões de m... | [
"def",
"start",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"# Este método é executado somente se o jogador não estiver já jogando",
"if",
"self",
".",
"__playing",
":",
"return",
"# Reinicia o placar",
"self",
".",
"__score",
"=",
"0",
"self",
".",
"__time",
... | [
320,
4
] | [
356,
28
] | python | en | ['en', 'error', 'th'] | False |
get_undocumented | (documented, module, module_name=None, skip=[]) |
Find out which items in NumPy are not documented.
Returns
-------
undocumented : dict of bool
Dictionary containing True for each documented item name
and False for each undocumented one.
|
Find out which items in NumPy are not documented. | def get_undocumented(documented, module, module_name=None, skip=[]):
"""
Find out which items in NumPy are not documented.
Returns
-------
undocumented : dict of bool
Dictionary containing True for each documented item name
and False for each undocumented one.
"""
undocumen... | [
"def",
"get_undocumented",
"(",
"documented",
",",
"module",
",",
"module_name",
"=",
"None",
",",
"skip",
"=",
"[",
"]",
")",
":",
"undocumented",
"=",
"{",
"}",
"if",
"module_name",
"is",
"None",
":",
"module_name",
"=",
"module",
".",
"__name__",
"for... | [
119,
0
] | [
149,
23
] | python | en | ['en', 'error', 'th'] | False |
format_in_columns | (lst, max_columns) |
Format a list containing strings to a string containing the items
in columns.
|
Format a list containing strings to a string containing the items
in columns.
| def format_in_columns(lst, max_columns):
"""
Format a list containing strings to a string containing the items
in columns.
"""
lst = [str(_m) for _m in lst]
col_len = max([len(_m) for _m in lst]) + 2
ncols = 80//col_len
if ncols > max_columns:
ncols = max_columns
if ncols <= ... | [
"def",
"format_in_columns",
"(",
"lst",
",",
"max_columns",
")",
":",
"lst",
"=",
"[",
"str",
"(",
"_m",
")",
"for",
"_m",
"in",
"lst",
"]",
"col_len",
"=",
"max",
"(",
"[",
"len",
"(",
"_m",
")",
"for",
"_m",
"in",
"lst",
"]",
")",
"+",
"2",
... | [
151,
0
] | [
174,
27
] | python | en | ['en', 'error', 'th'] | False |
collect_files | () | Collect all Python files in the tools directory.
Returns: A collection of python files in the tools directory excluding
any directories in the EXCLUDE_LIST constant.
| Collect all Python files in the tools directory. | def collect_files():
"""Collect all Python files in the tools directory.
Returns: A collection of python files in the tools directory excluding
any directories in the EXCLUDE_LIST constant.
"""
# TODO: Add ability to collect a specific file or files.
matches = []
path_parts = os.getcwd()... | [
"def",
"collect_files",
"(",
")",
":",
"# TODO: Add ability to collect a specific file or files.",
"matches",
"=",
"[",
"]",
"path_parts",
"=",
"os",
".",
"getcwd",
"(",
")",
".",
"split",
"(",
"'/'",
")",
"dirname",
"=",
"'.'",
"if",
"path_parts",
"[",
"-",
... | [
10,
0
] | [
30,
18
] | python | en | ['en', 'en', 'en'] | True |
validate_format | (fix=False) | Check the format of python files in the tools directory.
Arguments:
fix: a flag to indicate if fixes should be applied.
| Check the format of python files in the tools directory. | def validate_format(fix=False):
"""Check the format of python files in the tools directory.
Arguments:
fix: a flag to indicate if fixes should be applied.
"""
fixes_required = False
failed_update_files = set()
successful_update_files = set()
for python_file in collect_files():
... | [
"def",
"validate_format",
"(",
"fix",
"=",
"False",
")",
":",
"fixes_required",
"=",
"False",
"failed_update_files",
"=",
"set",
"(",
")",
"successful_update_files",
"=",
"set",
"(",
")",
"for",
"python_file",
"in",
"collect_files",
"(",
")",
":",
"reformatted... | [
33,
0
] | [
55,
29
] | python | en | ['en', 'en', 'en'] | True |
normalize_descr | (descr) | Normalize a description adding the platform byteorder. | Normalize a description adding the platform byteorder. | def normalize_descr(descr):
"Normalize a description adding the platform byteorder."
out = []
for item in descr:
dtype = item[1]
if isinstance(dtype, str):
if dtype[0] not in ['|', '<', '>']:
onebyte = dtype[1:] == "1"
if onebyte or dtype[0] in ['... | [
"def",
"normalize_descr",
"(",
"descr",
")",
":",
"out",
"=",
"[",
"]",
"for",
"item",
"in",
"descr",
":",
"dtype",
"=",
"item",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"dtype",
",",
"str",
")",
":",
"if",
"dtype",
"[",
"0",
"]",
"not",
"in",
"... | [
71,
0
] | [
95,
14
] | python | en | ['en', 'fr', 'en'] | True |
CreateZeros.test_zeros0D | (self) | Check creation of 0-dimensional objects | Check creation of 0-dimensional objects | def test_zeros0D(self):
"""Check creation of 0-dimensional objects"""
h = np.zeros((), dtype=self._descr)
assert_(normalize_descr(self._descr) == h.dtype.descr)
assert_(h.dtype.fields['x'][0].name[:4] == 'void')
assert_(h.dtype.fields['x'][0].char == 'V')
assert_(h.dtype.... | [
"def",
"test_zeros0D",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"zeros",
"(",
"(",
")",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"normalize_descr",
"(",
"self",
".",
"_descr",
")",
"==",
"h",
".",
"dtype",
".",
"descr",
"... | [
105,
4
] | [
113,
54
] | python | en | ['en', 'en', 'en'] | True |
CreateZeros.test_zerosSD | (self) | Check creation of single-dimensional objects | Check creation of single-dimensional objects | def test_zerosSD(self):
"""Check creation of single-dimensional objects"""
h = np.zeros((2,), dtype=self._descr)
assert_(normalize_descr(self._descr) == h.dtype.descr)
assert_(h.dtype['y'].name[:4] == 'void')
assert_(h.dtype['y'].char == 'V')
assert_(h.dtype['y'].type == ... | [
"def",
"test_zerosSD",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"zeros",
"(",
"(",
"2",
",",
")",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"normalize_descr",
"(",
"self",
".",
"_descr",
")",
"==",
"h",
".",
"dtype",
".",
... | [
115,
4
] | [
123,
56
] | python | en | ['en', 'en', 'en'] | True |
CreateZeros.test_zerosMD | (self) | Check creation of multi-dimensional objects | Check creation of multi-dimensional objects | def test_zerosMD(self):
"""Check creation of multi-dimensional objects"""
h = np.zeros((2, 3), dtype=self._descr)
assert_(normalize_descr(self._descr) == h.dtype.descr)
assert_(h.dtype['z'].name == 'uint8')
assert_(h.dtype['z'].char == 'B')
assert_(h.dtype['z'].type == np... | [
"def",
"test_zerosMD",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"zeros",
"(",
"(",
"2",
",",
"3",
")",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"normalize_descr",
"(",
"self",
".",
"_descr",
")",
"==",
"h",
".",
"dtype",
... | [
125,
4
] | [
133,
58
] | python | en | ['en', 'en', 'en'] | True |
CreateValues.test_tuple | (self) | Check creation from tuples | Check creation from tuples | def test_tuple(self):
"""Check creation from tuples"""
h = np.array(self._buffer, dtype=self._descr)
assert_(normalize_descr(self._descr) == h.dtype.descr)
if self.multiple_rows:
assert_(h.shape == (2,))
else:
assert_(h.shape == ()) | [
"def",
"test_tuple",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_buffer",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"normalize_descr",
"(",
"self",
".",
"_descr",
")",
"==",
"h",
".",
"dtype",
".",
... | [
148,
4
] | [
155,
34
] | python | en | ['en', 'en', 'en'] | True |
CreateValues.test_list_of_tuple | (self) | Check creation from list of tuples | Check creation from list of tuples | def test_list_of_tuple(self):
"""Check creation from list of tuples"""
h = np.array([self._buffer], dtype=self._descr)
assert_(normalize_descr(self._descr) == h.dtype.descr)
if self.multiple_rows:
assert_(h.shape == (1, 2))
else:
assert_(h.shape == (1,)) | [
"def",
"test_list_of_tuple",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"[",
"self",
".",
"_buffer",
"]",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"normalize_descr",
"(",
"self",
".",
"_descr",
")",
"==",
"h",
"... | [
157,
4
] | [
164,
36
] | python | en | ['en', 'en', 'en'] | True |
CreateValues.test_list_of_list_of_tuple | (self) | Check creation from list of list of tuples | Check creation from list of list of tuples | def test_list_of_list_of_tuple(self):
"""Check creation from list of list of tuples"""
h = np.array([[self._buffer]], dtype=self._descr)
assert_(normalize_descr(self._descr) == h.dtype.descr)
if self.multiple_rows:
assert_(h.shape == (1, 1, 2))
else:
asser... | [
"def",
"test_list_of_list_of_tuple",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"self",
".",
"_buffer",
"]",
"]",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"normalize_descr",
"(",
"self",
".",
"_descr",
"... | [
166,
4
] | [
173,
38
] | python | en | ['en', 'en', 'en'] | True |
ReadValuesNested.test_access_top_fields | (self) | Check reading the top fields of a nested array | Check reading the top fields of a nested array | def test_access_top_fields(self):
"""Check reading the top fields of a nested array"""
h = np.array(self._buffer, dtype=self._descr)
if not self.multiple_rows:
assert_(h.shape == ())
assert_equal(h['x'], np.array(self._buffer[0], dtype='i4'))
assert_equal(h['y... | [
"def",
"test_access_top_fields",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_buffer",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"if",
"not",
"self",
".",
"multiple_rows",
":",
"assert_",
"(",
"h",
".",
"shape",
"==",... | [
240,
4
] | [
255,
76
] | python | en | ['en', 'en', 'en'] | True |
ReadValuesNested.test_nested1_acessors | (self) | Check reading the nested fields of a nested array (1st level) | Check reading the nested fields of a nested array (1st level) | def test_nested1_acessors(self):
"""Check reading the nested fields of a nested array (1st level)"""
h = np.array(self._buffer, dtype=self._descr)
if not self.multiple_rows:
assert_equal(h['Info']['value'],
np.array(self._buffer[1][0], dtype='c16'))
... | [
"def",
"test_nested1_acessors",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_buffer",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"if",
"not",
"self",
".",
"multiple_rows",
":",
"assert_equal",
"(",
"h",
"[",
"'Info'",
... | [
257,
4
] | [
285,
44
] | python | en | ['en', 'en', 'en'] | True |
ReadValuesNested.test_nested2_acessors | (self) | Check reading the nested fields of a nested array (2nd level) | Check reading the nested fields of a nested array (2nd level) | def test_nested2_acessors(self):
"""Check reading the nested fields of a nested array (2nd level)"""
h = np.array(self._buffer, dtype=self._descr)
if not self.multiple_rows:
assert_equal(h['Info']['Info2']['value'],
np.array(self._buffer[1][2][1], dtype='c16'... | [
"def",
"test_nested2_acessors",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_buffer",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"if",
"not",
"self",
".",
"multiple_rows",
":",
"assert_equal",
"(",
"h",
"[",
"'Info'",
... | [
287,
4
] | [
303,
43
] | python | en | ['en', 'en', 'en'] | True |
ReadValuesNested.test_nested1_descriptor | (self) | Check access nested descriptors of a nested array (1st level) | Check access nested descriptors of a nested array (1st level) | def test_nested1_descriptor(self):
"""Check access nested descriptors of a nested array (1st level)"""
h = np.array(self._buffer, dtype=self._descr)
assert_(h.dtype['Info']['value'].name == 'complex128')
assert_(h.dtype['Info']['y2'].name == 'float64')
if sys.version_info[0] >= 3... | [
"def",
"test_nested1_descriptor",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_buffer",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"h",
".",
"dtype",
"[",
"'Info'",
"]",
"[",
"'value'",
"]",
".",
"nam... | [
305,
4
] | [
314,
62
] | python | en | ['en', 'en', 'en'] | True |
ReadValuesNested.test_nested2_descriptor | (self) | Check access nested descriptors of a nested array (2nd level) | Check access nested descriptors of a nested array (2nd level) | def test_nested2_descriptor(self):
"""Check access nested descriptors of a nested array (2nd level)"""
h = np.array(self._buffer, dtype=self._descr)
assert_(h.dtype['Info']['Info2']['value'].name == 'void256')
assert_(h.dtype['Info']['Info2']['z3'].name == 'void64') | [
"def",
"test_nested2_descriptor",
"(",
"self",
")",
":",
"h",
"=",
"np",
".",
"array",
"(",
"self",
".",
"_buffer",
",",
"dtype",
"=",
"self",
".",
"_descr",
")",
"assert_",
"(",
"h",
".",
"dtype",
"[",
"'Info'",
"]",
"[",
"'Info2'",
"]",
"[",
"'va... | [
316,
4
] | [
320,
64
] | python | en | ['en', 'en', 'en'] | True |
StyledObject.color | (self) | Convenience access to the color. | Convenience access to the color. | def color(self) -> str:
"""Convenience access to the color."""
return self.style["color"] | [
"def",
"color",
"(",
"self",
")",
"->",
"str",
":",
"return",
"self",
".",
"style",
"[",
"\"color\"",
"]"
] | [
38,
4
] | [
40,
34
] | python | en | ['en', 'en', 'en'] | True |
StyledObject.cmap | (self) | A linear colormap that matches self.color for values above 1 and
is transparent for 0. | A linear colormap that matches self.color for values above 1 and
is transparent for 0. | def cmap(self) -> mpl.colors.Colormap:
"""A linear colormap that matches self.color for values above 1 and
is transparent for 0."""
color = mpl.colors.to_rgba(self.color)
# cmap_mat = np.array([np.linspace(c, 0, 1) for c in color]).T
cmap_mat = np.array([[0, 0, 0, 0], color])
... | [
"def",
"cmap",
"(",
"self",
")",
"->",
"mpl",
".",
"colors",
".",
"Colormap",
":",
"color",
"=",
"mpl",
".",
"colors",
".",
"to_rgba",
"(",
"self",
".",
"color",
")",
"# cmap_mat = np.array([np.linspace(c, 0, 1) for c in color]).T",
"cmap_mat",
"=",
"np",
".",... | [
43,
4
] | [
51,
19
] | python | en | ['en', 'en', 'en'] | True |
StyledObject.plot | (self, ax: mpl.axes.Axes) | Plot this object onto matplotlib axes. | Plot this object onto matplotlib axes. | def plot(self, ax: mpl.axes.Axes) -> None:
"""Plot this object onto matplotlib axes."""
raise NotImplementedError | [
"def",
"plot",
"(",
"self",
",",
"ax",
":",
"mpl",
".",
"axes",
".",
"Axes",
")",
"->",
"None",
":",
"raise",
"NotImplementedError"
] | [
53,
4
] | [
55,
33
] | python | en | ['en', 'fi', 'en'] | True |
ROI._apply_params | (self, shape: Optional[str] = "circle", **kwargs) | Convert a geometric rectangular or elliptic description to polygon contour.
Arguments belonging to the shapes:
- circle: radius
- ellipse: width, height, rotation
- square: width, rotation
- rectangle: width, height, rotation
where radius, width and height... | Convert a geometric rectangular or elliptic description to polygon contour.
Arguments belonging to the shapes:
- circle: radius
- ellipse: width, height, rotation
- square: width, rotation
- rectangle: width, height, rotation
where radius, width and height... | def _apply_params(self, shape: Optional[str] = "circle", **kwargs):
"""Convert a geometric rectangular or elliptic description to polygon contour.
Arguments belonging to the shapes:
- circle: radius
- ellipse: width, height, rotation
- square: width, rotation
... | [
"def",
"_apply_params",
"(",
"self",
",",
"shape",
":",
"Optional",
"[",
"str",
"]",
"=",
"\"circle\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"shape",
"==",
"\"point\"",
":",
"self",
".",
"_ref_point",
"=",
"np",
".",
"array",
"(",
"[",
"0",
","... | [
84,
4
] | [
138,
20
] | python | en | ['en', 'fr', 'es'] | False |
ROI.point | (cls, x0: int, y0: int, **kwargs) | Construct a point ROI. | Construct a point ROI. | def point(cls, x0: int, y0: int, **kwargs) -> ROI:
"""Construct a point ROI."""
array = np.array([[True]])
return cls(x0, y0, source=array, **kwargs) | [
"def",
"point",
"(",
"cls",
",",
"x0",
":",
"int",
",",
"y0",
":",
"int",
",",
"*",
"*",
"kwargs",
")",
"->",
"ROI",
":",
"array",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"True",
"]",
"]",
")",
"return",
"cls",
"(",
"x0",
",",
"y0",
",",
... | [
141,
4
] | [
144,
50
] | python | en | ['en', 'en', 'en'] | True |
ROI.from_array | (cls, x0: int, y0: int, array: Iterable, **kwargs) | Construct a polygonic ROI from a list of corners. Seems Superfluous????? | Construct a polygonic ROI from a list of corners. Seems Superfluous????? | def from_array(cls, x0: int, y0: int, array: Iterable, **kwargs) -> ROI:
"""Construct a polygonic ROI from a list of corners. Seems Superfluous?????"""
return cls(x0, y0, source=array, **kwargs) | [
"def",
"from_array",
"(",
"cls",
",",
"x0",
":",
"int",
",",
"y0",
":",
"int",
",",
"array",
":",
"Iterable",
",",
"*",
"*",
"kwargs",
")",
"->",
"ROI",
":",
"return",
"cls",
"(",
"x0",
",",
"y0",
",",
"source",
"=",
"array",
",",
"*",
"*",
"... | [
147,
4
] | [
149,
50
] | python | en | ['en', 'en', 'en'] | True |
ROI.apply | (self, obj: do.Image, return_array: bool = False) | Apply the MaskLike to a Dataobject and either return the masked
DataObject or the raw masked data. | Apply the MaskLike to a Dataobject and either return the masked
DataObject or the raw masked data. | def apply(self, obj: do.Image, return_array: bool = False) -> Union[do.Image,np.ndarray]:
"""Apply the MaskLike to a Dataobject and either return the masked
DataObject or the raw masked data."""
full_mask = self.pad_to(*obj.image.shape).astype(bool)
if return_array:
return np... | [
"def",
"apply",
"(",
"self",
",",
"obj",
":",
"do",
".",
"Image",
",",
"return_array",
":",
"bool",
"=",
"False",
")",
"->",
"Union",
"[",
"do",
".",
"Image",
",",
"np",
".",
"ndarray",
"]",
":",
"full_mask",
"=",
"self",
".",
"pad_to",
"(",
"*",... | [
151,
4
] | [
159,
21
] | python | en | ['en', 'en', 'en'] | True |
ROI.pad_to | (self, width: int, height: int) | Return the the mask padded to a given extent. | Return the the mask padded to a given extent. | def pad_to(self, width: int, height: int) -> np.ndarray:
"""Return the the mask padded to a given extent."""
if self._mask_buffer.shape == (height, width):
return self._mask_buffer
# find sizes and corners. The low corner is the difference between the mask's
# reference point... | [
"def",
"pad_to",
"(",
"self",
",",
"width",
":",
"int",
",",
"height",
":",
"int",
")",
"->",
"np",
".",
"ndarray",
":",
"if",
"self",
".",
"_mask_buffer",
".",
"shape",
"==",
"(",
"height",
",",
"width",
")",
":",
"return",
"self",
".",
"_mask_buf... | [
161,
4
] | [
187,
21
] | python | en | ['en', 'en', 'en'] | True |
ROI.area | (self) | Total area in pixels. Is only valid when the mask is not cut off at the sides! | Total area in pixels. Is only valid when the mask is not cut off at the sides! | def area(self) -> int:
"""Total area in pixels. Is only valid when the mask is not cut off at the sides!"""
return self.array.astype(bool).sum() | [
"def",
"area",
"(",
"self",
")",
"->",
"int",
":",
"return",
"self",
".",
"array",
".",
"astype",
"(",
"bool",
")",
".",
"sum",
"(",
")"
] | [
190,
4
] | [
192,
44
] | python | en | ['en', 'en', 'en'] | True |
ROI.ref_point | (self) | Reference point for the mask. | Reference point for the mask. | def ref_point(self) -> np.ndarray:
"""Reference point for the mask."""
return self._ref_point | [
"def",
"ref_point",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"self",
".",
"_ref_point"
] | [
195,
4
] | [
197,
30
] | python | en | ['en', 'en', 'en'] | True |
ROI.origin | (self) | Lower left origin of the mask considering its position and ref_point. | Lower left origin of the mask considering its position and ref_point. | def origin(self) -> np.ndarray:
"""Lower left origin of the mask considering its position and ref_point."""
return self.position - self.ref_point | [
"def",
"origin",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"return",
"self",
".",
"position",
"-",
"self",
".",
"ref_point"
] | [
200,
4
] | [
202,
45
] | python | en | ['en', 'en', 'en'] | True |
ROI.center_of_mass | (self) | The center of mass position of the mask array. | The center of mass position of the mask array. | def center_of_mass(self) -> np.ndarray:
"""The center of mass position of the mask array."""
y_i, x_i = np.nonzero(self.array)
return np.array([x_i.mean(), y_i.mean()]) | [
"def",
"center_of_mass",
"(",
"self",
")",
"->",
"np",
".",
"ndarray",
":",
"y_i",
",",
"x_i",
"=",
"np",
".",
"nonzero",
"(",
"self",
".",
"array",
")",
"return",
"np",
".",
"array",
"(",
"[",
"x_i",
".",
"mean",
"(",
")",
",",
"y_i",
".",
"me... | [
205,
4
] | [
208,
49
] | python | en | ['en', 'en', 'en'] | True |
ROI.plot | (self, ax: mpl.axes.Axes) | Plot the styled object onto a matplotlib axes. | Plot the styled object onto a matplotlib axes. | def plot(self, ax: mpl.axes.Axes):
"""Plot the styled object onto a matplotlib axes."""
img_height = int(abs(ax.get_xlim()[1] - ax.get_xlim()[0]))
img_width = int(abs(ax.get_ylim()[1] - ax.get_ylim()[0]))
array = self.pad_to(img_width, img_height)
ax.imshow(array, cmap=self.cmap,... | [
"def",
"plot",
"(",
"self",
",",
"ax",
":",
"mpl",
".",
"axes",
".",
"Axes",
")",
":",
"img_height",
"=",
"int",
"(",
"abs",
"(",
"ax",
".",
"get_xlim",
"(",
")",
"[",
"1",
"]",
"-",
"ax",
".",
"get_xlim",
"(",
")",
"[",
"0",
"]",
")",
")",... | [
210,
4
] | [
215,
76
] | python | en | ['en', 'hu', 'en'] | True |
RSMCut.__call__ | (self, img_array, length=None) |
See also:
https://stackoverflow.com/questions/7878398/
how-to-extract-an-arbitrary-line-of-values-from-a-numpy-array
|
See also:
https://stackoverflow.com/questions/7878398/
how-to-extract-an-arbitrary-line-of-values-from-a-numpy-array
| def __call__(self, img_array, length=None):
"""
See also:
https://stackoverflow.com/questions/7878398/
how-to-extract-an-arbitrary-line-of-values-from-a-numpy-array
"""
if length is None:
length = int(self.length)
dx, dy = (self.start - self.end) / le... | [
"def",
"__call__",
"(",
"self",
",",
"img_array",
",",
"length",
"=",
"None",
")",
":",
"if",
"length",
"is",
"None",
":",
"length",
"=",
"int",
"(",
"self",
".",
"length",
")",
"dx",
",",
"dy",
"=",
"(",
"self",
".",
"start",
"-",
"self",
".",
... | [
60,
4
] | [
80,
16
] | python | en | ['en', 'error', 'th'] | False |
compile | (source,
modulename='untitled',
extra_args='',
verbose=True,
source_fn=None,
extension='.f'
) |
Build extension module from a Fortran 77 source string with f2py.
Parameters
----------
source : str or bytes
Fortran source of module / subroutine to compile
.. versionchanged:: 1.16.0
Accept str as well as bytes
modulename : str, optional
The name of the comp... |
Build extension module from a Fortran 77 source string with f2py. | def compile(source,
modulename='untitled',
extra_args='',
verbose=True,
source_fn=None,
extension='.f'
):
"""
Build extension module from a Fortran 77 source string with f2py.
Parameters
----------
source : str or bytes
... | [
"def",
"compile",
"(",
"source",
",",
"modulename",
"=",
"'untitled'",
",",
"extra_args",
"=",
"''",
",",
"verbose",
"=",
"True",
",",
"source_fn",
"=",
"None",
",",
"extension",
"=",
"'.f'",
")",
":",
"import",
"tempfile",
"import",
"shlex",
"if",
"sour... | [
22,
0
] | [
116,
17
] | python | en | ['en', 'error', 'th'] | False |
build_module | (source_files, options=[], skip=[], only=[], module_name=None) |
Compile and import a f2py module, built from the given files.
|
Compile and import a f2py module, built from the given files. | def build_module(source_files, options=[], skip=[], only=[], module_name=None):
"""
Compile and import a f2py module, built from the given files.
"""
code = ("import sys; sys.path = %s; import numpy.f2py as f2py2e; "
"f2py2e.main()" % repr(sys.path))
d = get_module_dir()
# Copy f... | [
"def",
"build_module",
"(",
"source_files",
",",
"options",
"=",
"[",
"]",
",",
"skip",
"=",
"[",
"]",
",",
"only",
"=",
"[",
"]",
",",
"module_name",
"=",
"None",
")",
":",
"code",
"=",
"(",
"\"import sys; sys.path = %s; import numpy.f2py as f2py2e; \"",
"\... | [
94,
0
] | [
148,
37
] | python | en | ['en', 'error', 'th'] | False |
build_code | (source_code, options=[], skip=[], only=[], suffix=None,
module_name=None) |
Compile and import Fortran code using f2py.
|
Compile and import Fortran code using f2py. | def build_code(source_code, options=[], skip=[], only=[], suffix=None,
module_name=None):
"""
Compile and import Fortran code using f2py.
"""
if suffix is None:
suffix = '.f'
with temppath(suffix=suffix) as path:
with open(path, 'w') as f:
f.write(source_c... | [
"def",
"build_code",
"(",
"source_code",
",",
"options",
"=",
"[",
"]",
",",
"skip",
"=",
"[",
"]",
",",
"only",
"=",
"[",
"]",
",",
"suffix",
"=",
"None",
",",
"module_name",
"=",
"None",
")",
":",
"if",
"suffix",
"is",
"None",
":",
"suffix",
"=... | [
152,
0
] | [
164,
52
] | python | en | ['en', 'error', 'th'] | False |
build_module_distutils | (source_files, config_code, module_name, **kw) |
Build a module via distutils and import it.
|
Build a module via distutils and import it. | def build_module_distutils(source_files, config_code, module_name, **kw):
"""
Build a module via distutils and import it.
"""
from numpy.distutils.misc_util import Configuration
from numpy.distutils.core import setup
d = get_module_dir()
# Copy files
dst_sources = []
for fn in sou... | [
"def",
"build_module_distutils",
"(",
"source_files",
",",
"config_code",
",",
"module_name",
",",
"*",
"*",
"kw",
")",
":",
"from",
"numpy",
".",
"distutils",
".",
"misc_util",
"import",
"Configuration",
"from",
"numpy",
".",
"distutils",
".",
"core",
"import... | [
239,
0
] | [
303,
35
] | python | en | ['en', 'error', 'th'] | False |
pl_multi_process_test | (func) | Wrapper for running multi-processing tests. | Wrapper for running multi-processing tests. | def pl_multi_process_test(func):
"""Wrapper for running multi-processing tests."""
@functools.wraps(func)
def wrapper(*args, **kwargs):
from multiprocessing import Process, Queue
queue = Queue()
def inner_f(queue, **kwargs):
try:
func(**kwargs)
... | [
"def",
"pl_multi_process_test",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"multiprocessing",
"import",
"Process",
",",
"Queue",
"queue",
"=",
... | [
82,
0
] | [
112,
18
] | python | en | ['nb', 'en', 'en'] | True |
AllocationTracker.__init__ | (self, threshold=0) | track numpy allocations of size threshold bytes or more. | track numpy allocations of size threshold bytes or more. | def __init__(self, threshold=0):
'''track numpy allocations of size threshold bytes or more.'''
self.threshold = threshold
# The total number of bytes currently allocated with size above
# threshold
self.total_bytes = 0
# We buffer requests line by line and move them i... | [
"def",
"__init__",
"(",
"self",
",",
"threshold",
"=",
"0",
")",
":",
"self",
".",
"threshold",
"=",
"threshold",
"# The total number of bytes currently allocated with size above",
"# threshold",
"self",
".",
"total_bytes",
"=",
"0",
"# We buffer requests line by line and... | [
8,
4
] | [
28,
51
] | python | en | ['en', 'en', 'en'] | True |
mock_mlflow_run_creation | (logger, experiment_name=None, experiment_id=None, run_id=None) | Helper function to simulate mlflow client creating a new (or existing) experiment. | Helper function to simulate mlflow client creating a new (or existing) experiment. | def mock_mlflow_run_creation(logger, experiment_name=None, experiment_id=None, run_id=None):
""" Helper function to simulate mlflow client creating a new (or existing) experiment. """
run = MagicMock()
run.info.run_id = run_id
logger._mlflow_client.get_experiment_by_name = MagicMock(return_value=experim... | [
"def",
"mock_mlflow_run_creation",
"(",
"logger",
",",
"experiment_name",
"=",
"None",
",",
"experiment_id",
"=",
"None",
",",
"run_id",
"=",
"None",
")",
":",
"run",
"=",
"MagicMock",
"(",
")",
"run",
".",
"info",
".",
"run_id",
"=",
"run_id",
"logger",
... | [
24,
0
] | [
31,
17
] | python | en | ['en', 'en', 'en'] | True |
test_mlflow_logger_exists | (client, mlflow, tmpdir) | Test launching three independent loggers with either same or different experiment name. | Test launching three independent loggers with either same or different experiment name. | def test_mlflow_logger_exists(client, mlflow, tmpdir):
""" Test launching three independent loggers with either same or different experiment name. """
run1 = MagicMock()
run1.info.run_id = "run-id-1"
run2 = MagicMock()
run2.info.run_id = "run-id-2"
run3 = MagicMock()
run3.info.run_id = "r... | [
"def",
"test_mlflow_logger_exists",
"(",
"client",
",",
"mlflow",
",",
"tmpdir",
")",
":",
"run1",
"=",
"MagicMock",
"(",
")",
"run1",
".",
"info",
".",
"run_id",
"=",
"\"run-id-1\"",
"run2",
"=",
"MagicMock",
"(",
")",
"run2",
".",
"info",
".",
"run_id"... | [
36,
0
] | [
84,
39
] | python | en | ['en', 'en', 'en'] | True |
test_mlflow_log_dir | (client, mlflow, tmpdir) | Test that the trainer saves checkpoints in the logger's save dir. | Test that the trainer saves checkpoints in the logger's save dir. | def test_mlflow_log_dir(client, mlflow, tmpdir):
""" Test that the trainer saves checkpoints in the logger's save dir. """
# simulate experiment creation with mlflow client mock
run = MagicMock()
run.info.run_id = "run-id"
client.return_value.get_experiment_by_name = MagicMock(return_value=None)
... | [
"def",
"test_mlflow_log_dir",
"(",
"client",
",",
"mlflow",
",",
"tmpdir",
")",
":",
"# simulate experiment creation with mlflow client mock",
"run",
"=",
"MagicMock",
"(",
")",
"run",
".",
"info",
".",
"run_id",
"=",
"\"run-id\"",
"client",
".",
"return_value",
"... | [
89,
0
] | [
117,
45
] | python | en | ['en', 'en', 'en'] | True |
test_mlflow_logger_dirs_creation | (tmpdir) | Test that the logger creates the folders and files in the right place. | Test that the logger creates the folders and files in the right place. | def test_mlflow_logger_dirs_creation(tmpdir):
""" Test that the logger creates the folders and files in the right place. """
if not _MLFLOW_AVAILABLE:
pytest.xfail("test for explicit file creation requires mlflow dependency to be installed.")
assert not os.listdir(tmpdir)
logger = MLFlowLogger(... | [
"def",
"test_mlflow_logger_dirs_creation",
"(",
"tmpdir",
")",
":",
"if",
"not",
"_MLFLOW_AVAILABLE",
":",
"pytest",
".",
"xfail",
"(",
"\"test for explicit file creation requires mlflow dependency to be installed.\"",
")",
"assert",
"not",
"os",
".",
"listdir",
"(",
"tmp... | [
120,
0
] | [
159,
104
] | python | en | ['en', 'en', 'en'] | True |
test_mlflow_experiment_id_retrieved_once | (client, mlflow, tmpdir) |
Test that the logger experiment_id retrieved only once.
|
Test that the logger experiment_id retrieved only once.
| def test_mlflow_experiment_id_retrieved_once(client, mlflow, tmpdir):
"""
Test that the logger experiment_id retrieved only once.
"""
logger = MLFlowLogger('test', save_dir=tmpdir)
_ = logger.experiment
_ = logger.experiment
_ = logger.experiment
assert logger.experiment.get_experiment_b... | [
"def",
"test_mlflow_experiment_id_retrieved_once",
"(",
"client",
",",
"mlflow",
",",
"tmpdir",
")",
":",
"logger",
"=",
"MLFlowLogger",
"(",
"'test'",
",",
"save_dir",
"=",
"tmpdir",
")",
"_",
"=",
"logger",
".",
"experiment",
"_",
"=",
"logger",
".",
"expe... | [
164,
0
] | [
172,
67
] | python | en | ['en', 'error', 'th'] | False |
test_mlflow_logger_with_unexpected_characters | (client, mlflow, tmpdir) |
Test that the logger raises warning with special characters not accepted by MLFlow.
|
Test that the logger raises warning with special characters not accepted by MLFlow.
| def test_mlflow_logger_with_unexpected_characters(client, mlflow, tmpdir):
"""
Test that the logger raises warning with special characters not accepted by MLFlow.
"""
logger = MLFlowLogger('test', save_dir=tmpdir)
metrics = {'[some_metric]': 10}
with pytest.warns(RuntimeWarning, match='special ... | [
"def",
"test_mlflow_logger_with_unexpected_characters",
"(",
"client",
",",
"mlflow",
",",
"tmpdir",
")",
":",
"logger",
"=",
"MLFlowLogger",
"(",
"'test'",
",",
"save_dir",
"=",
"tmpdir",
")",
"metrics",
"=",
"{",
"'[some_metric]'",
":",
"10",
"}",
"with",
"p... | [
177,
0
] | [
185,
35
] | python | en | ['en', 'error', 'th'] | False |
test_mlflow_logger_with_long_param_value | (client, mlflow, tmpdir) |
Test that the logger raises warning with special characters not accepted by MLFlow.
|
Test that the logger raises warning with special characters not accepted by MLFlow.
| def test_mlflow_logger_with_long_param_value(client, mlflow, tmpdir):
"""
Test that the logger raises warning with special characters not accepted by MLFlow.
"""
logger = MLFlowLogger('test', save_dir=tmpdir)
value = 'test' * 100
key = 'test_param'
params = {key: value}
with pytest.warn... | [
"def",
"test_mlflow_logger_with_long_param_value",
"(",
"client",
",",
"mlflow",
",",
"tmpdir",
")",
":",
"logger",
"=",
"MLFlowLogger",
"(",
"'test'",
",",
"save_dir",
"=",
"tmpdir",
")",
"value",
"=",
"'test'",
"*",
"100",
"key",
"=",
"'test_param'",
"params... | [
190,
0
] | [
200,
38
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.