repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
fronzbot/blinkpy
blinkpy/sync_module.py
BlinkSyncModule.arm
def arm(self, value): """Arm or disarm system.""" if value: return api.request_system_arm(self.blink, self.network_id) return api.request_system_disarm(self.blink, self.network_id)
python
def arm(self, value): """Arm or disarm system.""" if value: return api.request_system_arm(self.blink, self.network_id) return api.request_system_disarm(self.blink, self.network_id)
[ "def", "arm", "(", "self", ",", "value", ")", ":", "if", "value", ":", "return", "api", ".", "request_system_arm", "(", "self", ".", "blink", ",", "self", ".", "network_id", ")", "return", "api", ".", "request_system_disarm", "(", "self", ".", "blink", ...
Arm or disarm system.
[ "Arm", "or", "disarm", "system", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L73-L78
train
fronzbot/blinkpy
blinkpy/sync_module.py
BlinkSyncModule.start
def start(self): """Initialize the system.""" response = api.request_syncmodule(self.blink, self.network_id, force=True) try: self.summary = response['syncmodule'] self.network_id = self.s...
python
def start(self): """Initialize the system.""" response = api.request_syncmodule(self.blink, self.network_id, force=True) try: self.summary = response['syncmodule'] self.network_id = self.s...
[ "def", "start", "(", "self", ")", ":", "response", "=", "api", ".", "request_syncmodule", "(", "self", ".", "blink", ",", "self", ".", "network_id", ",", "force", "=", "True", ")", "try", ":", "self", ".", "summary", "=", "response", "[", "'syncmodule'...
Initialize the system.
[ "Initialize", "the", "system", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L80-L123
train
fronzbot/blinkpy
blinkpy/sync_module.py
BlinkSyncModule.get_events
def get_events(self, **kwargs): """Retrieve events from server.""" force = kwargs.pop('force', False) response = api.request_sync_events(self.blink, self.network_id, force=force) try: return...
python
def get_events(self, **kwargs): """Retrieve events from server.""" force = kwargs.pop('force', False) response = api.request_sync_events(self.blink, self.network_id, force=force) try: return...
[ "def", "get_events", "(", "self", ",", "**", "kwargs", ")", ":", "force", "=", "kwargs", ".", "pop", "(", "'force'", ",", "False", ")", "response", "=", "api", ".", "request_sync_events", "(", "self", ".", "blink", ",", "self", ".", "network_id", ",", ...
Retrieve events from server.
[ "Retrieve", "events", "from", "server", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L125-L137
train
fronzbot/blinkpy
blinkpy/sync_module.py
BlinkSyncModule.get_camera_info
def get_camera_info(self, camera_id): """Retrieve camera information.""" response = api.request_camera_info(self.blink, self.network_id, camera_id) try: return response['camera'][0] except (...
python
def get_camera_info(self, camera_id): """Retrieve camera information.""" response = api.request_camera_info(self.blink, self.network_id, camera_id) try: return response['camera'][0] except (...
[ "def", "get_camera_info", "(", "self", ",", "camera_id", ")", ":", "response", "=", "api", ".", "request_camera_info", "(", "self", ".", "blink", ",", "self", ".", "network_id", ",", "camera_id", ")", "try", ":", "return", "response", "[", "'camera'", "]",...
Retrieve camera information.
[ "Retrieve", "camera", "information", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L139-L150
train
fronzbot/blinkpy
blinkpy/sync_module.py
BlinkSyncModule.refresh
def refresh(self, force_cache=False): """Get all blink cameras and pulls their most recent status.""" self.network_info = api.request_network_status(self.blink, self.network_id) self.check_new_videos() for camera_name in self.cameras...
python
def refresh(self, force_cache=False): """Get all blink cameras and pulls their most recent status.""" self.network_info = api.request_network_status(self.blink, self.network_id) self.check_new_videos() for camera_name in self.cameras...
[ "def", "refresh", "(", "self", ",", "force_cache", "=", "False", ")", ":", "self", ".", "network_info", "=", "api", ".", "request_network_status", "(", "self", ".", "blink", ",", "self", ".", "network_id", ")", "self", ".", "check_new_videos", "(", ")", ...
Get all blink cameras and pulls their most recent status.
[ "Get", "all", "blink", "cameras", "and", "pulls", "their", "most", "recent", "status", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L152-L161
train
fronzbot/blinkpy
blinkpy/sync_module.py
BlinkSyncModule.check_new_videos
def check_new_videos(self): """Check if new videos since last refresh.""" resp = api.request_videos(self.blink, time=self.blink.last_refresh, page=0) for camera in self.cameras.keys(): self.motion[camera] = False ...
python
def check_new_videos(self): """Check if new videos since last refresh.""" resp = api.request_videos(self.blink, time=self.blink.last_refresh, page=0) for camera in self.cameras.keys(): self.motion[camera] = False ...
[ "def", "check_new_videos", "(", "self", ")", ":", "resp", "=", "api", ".", "request_videos", "(", "self", ".", "blink", ",", "time", "=", "self", ".", "blink", ".", "last_refresh", ",", "page", "=", "0", ")", "for", "camera", "in", "self", ".", "came...
Check if new videos since last refresh.
[ "Check", "if", "new", "videos", "since", "last", "refresh", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/sync_module.py#L163-L188
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.attributes
def attributes(self): """Return dictionary of all camera attributes.""" attributes = { 'name': self.name, 'camera_id': self.camera_id, 'serial': self.serial, 'temperature': self.temperature, 'temperature_c': self.temperature_c, 'tem...
python
def attributes(self): """Return dictionary of all camera attributes.""" attributes = { 'name': self.name, 'camera_id': self.camera_id, 'serial': self.serial, 'temperature': self.temperature, 'temperature_c': self.temperature_c, 'tem...
[ "def", "attributes", "(", "self", ")", ":", "attributes", "=", "{", "'name'", ":", "self", ".", "name", ",", "'camera_id'", ":", "self", ".", "camera_id", ",", "'serial'", ":", "self", ".", "serial", ",", "'temperature'", ":", "self", ".", "temperature",...
Return dictionary of all camera attributes.
[ "Return", "dictionary", "of", "all", "camera", "attributes", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L34-L53
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.snap_picture
def snap_picture(self): """Take a picture with camera to create a new thumbnail.""" return api.request_new_image(self.sync.blink, self.network_id, self.camera_id)
python
def snap_picture(self): """Take a picture with camera to create a new thumbnail.""" return api.request_new_image(self.sync.blink, self.network_id, self.camera_id)
[ "def", "snap_picture", "(", "self", ")", ":", "return", "api", ".", "request_new_image", "(", "self", ".", "sync", ".", "blink", ",", "self", ".", "network_id", ",", "self", ".", "camera_id", ")" ]
Take a picture with camera to create a new thumbnail.
[ "Take", "a", "picture", "with", "camera", "to", "create", "a", "new", "thumbnail", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L79-L83
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.set_motion_detect
def set_motion_detect(self, enable): """Set motion detection.""" if enable: return api.request_motion_detection_enable(self.sync.blink, self.network_id, self.camera_id) retur...
python
def set_motion_detect(self, enable): """Set motion detection.""" if enable: return api.request_motion_detection_enable(self.sync.blink, self.network_id, self.camera_id) retur...
[ "def", "set_motion_detect", "(", "self", ",", "enable", ")", ":", "if", "enable", ":", "return", "api", ".", "request_motion_detection_enable", "(", "self", ".", "sync", ".", "blink", ",", "self", ".", "network_id", ",", "self", ".", "camera_id", ")", "ret...
Set motion detection.
[ "Set", "motion", "detection", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L85-L93
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.update
def update(self, config, force_cache=False, **kwargs): """Update camera info.""" # force = kwargs.pop('force', False) self.name = config['name'] self.camera_id = str(config['id']) self.network_id = str(config['network_id']) self.serial = config['serial'] self.moti...
python
def update(self, config, force_cache=False, **kwargs): """Update camera info.""" # force = kwargs.pop('force', False) self.name = config['name'] self.camera_id = str(config['id']) self.network_id = str(config['network_id']) self.serial = config['serial'] self.moti...
[ "def", "update", "(", "self", ",", "config", ",", "force_cache", "=", "False", ",", "**", "kwargs", ")", ":", "self", ".", "name", "=", "config", "[", "'name'", "]", "self", ".", "camera_id", "=", "str", "(", "config", "[", "'id'", "]", ")", "self"...
Update camera info.
[ "Update", "camera", "info", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L95-L162
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.image_to_file
def image_to_file(self, path): """ Write image to file. :param path: Path to write file """ _LOGGER.debug("Writing image from %s to %s", self.name, path) response = self._cached_image if response.status_code == 200: with open(path, 'wb') as imgfile: ...
python
def image_to_file(self, path): """ Write image to file. :param path: Path to write file """ _LOGGER.debug("Writing image from %s to %s", self.name, path) response = self._cached_image if response.status_code == 200: with open(path, 'wb') as imgfile: ...
[ "def", "image_to_file", "(", "self", ",", "path", ")", ":", "_LOGGER", ".", "debug", "(", "\"Writing image from %s to %s\"", ",", "self", ".", "name", ",", "path", ")", "response", "=", "self", ".", "_cached_image", "if", "response", ".", "status_code", "=="...
Write image to file. :param path: Path to write file
[ "Write", "image", "to", "file", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L164-L178
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.video_to_file
def video_to_file(self, path): """Write video to file. :param path: Path to write file """ _LOGGER.debug("Writing video from %s to %s", self.name, path) response = self._cached_video if response is None: _LOGGER.error("No saved video exist for %s.", ...
python
def video_to_file(self, path): """Write video to file. :param path: Path to write file """ _LOGGER.debug("Writing video from %s to %s", self.name, path) response = self._cached_video if response is None: _LOGGER.error("No saved video exist for %s.", ...
[ "def", "video_to_file", "(", "self", ",", "path", ")", ":", "_LOGGER", ".", "debug", "(", "\"Writing video from %s to %s\"", ",", "self", ".", "name", ",", "path", ")", "response", "=", "self", ".", "_cached_video", "if", "response", "is", "None", ":", "_L...
Write video to file. :param path: Path to write file
[ "Write", "video", "to", "file", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L180-L193
train
fronzbot/blinkpy
blinkpy/camera.py
BlinkCamera.get_thumb_from_homescreen
def get_thumb_from_homescreen(self): """Retrieve thumbnail from homescreen.""" for device in self.sync.homescreen['devices']: try: device_type = device['device_type'] device_name = device['name'] device_thumb = device['thumbnail'] ...
python
def get_thumb_from_homescreen(self): """Retrieve thumbnail from homescreen.""" for device in self.sync.homescreen['devices']: try: device_type = device['device_type'] device_name = device['name'] device_thumb = device['thumbnail'] ...
[ "def", "get_thumb_from_homescreen", "(", "self", ")", ":", "for", "device", "in", "self", ".", "sync", ".", "homescreen", "[", "'devices'", "]", ":", "try", ":", "device_type", "=", "device", "[", "'device_type'", "]", "device_name", "=", "device", "[", "'...
Retrieve thumbnail from homescreen.
[ "Retrieve", "thumbnail", "from", "homescreen", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/camera.py#L195-L209
train
fronzbot/blinkpy
blinkpy/helpers/util.py
get_time
def get_time(time_to_convert=None): """Create blink-compatible timestamp.""" if time_to_convert is None: time_to_convert = time.time() return time.strftime(TIMESTAMP_FORMAT, time.localtime(time_to_convert))
python
def get_time(time_to_convert=None): """Create blink-compatible timestamp.""" if time_to_convert is None: time_to_convert = time.time() return time.strftime(TIMESTAMP_FORMAT, time.localtime(time_to_convert))
[ "def", "get_time", "(", "time_to_convert", "=", "None", ")", ":", "if", "time_to_convert", "is", "None", ":", "time_to_convert", "=", "time", ".", "time", "(", ")", "return", "time", ".", "strftime", "(", "TIMESTAMP_FORMAT", ",", "time", ".", "localtime", ...
Create blink-compatible timestamp.
[ "Create", "blink", "-", "compatible", "timestamp", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L14-L18
train
fronzbot/blinkpy
blinkpy/helpers/util.py
merge_dicts
def merge_dicts(dict_a, dict_b): """Merge two dictionaries into one.""" duplicates = [val for val in dict_a if val in dict_b] if duplicates: _LOGGER.warning(("Duplicates found during merge: %s. " "Renaming is recommended."), duplicates) return {**dict_a, **dict_b}
python
def merge_dicts(dict_a, dict_b): """Merge two dictionaries into one.""" duplicates = [val for val in dict_a if val in dict_b] if duplicates: _LOGGER.warning(("Duplicates found during merge: %s. " "Renaming is recommended."), duplicates) return {**dict_a, **dict_b}
[ "def", "merge_dicts", "(", "dict_a", ",", "dict_b", ")", ":", "duplicates", "=", "[", "val", "for", "val", "in", "dict_a", "if", "val", "in", "dict_b", "]", "if", "duplicates", ":", "_LOGGER", ".", "warning", "(", "(", "\"Duplicates found during merge: %s. \...
Merge two dictionaries into one.
[ "Merge", "two", "dictionaries", "into", "one", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L21-L27
train
fronzbot/blinkpy
blinkpy/helpers/util.py
attempt_reauthorization
def attempt_reauthorization(blink): """Attempt to refresh auth token and links.""" _LOGGER.info("Auth token expired, attempting reauthorization.") headers = blink.get_auth_token(is_retry=True) return headers
python
def attempt_reauthorization(blink): """Attempt to refresh auth token and links.""" _LOGGER.info("Auth token expired, attempting reauthorization.") headers = blink.get_auth_token(is_retry=True) return headers
[ "def", "attempt_reauthorization", "(", "blink", ")", ":", "_LOGGER", ".", "info", "(", "\"Auth token expired, attempting reauthorization.\"", ")", "headers", "=", "blink", ".", "get_auth_token", "(", "is_retry", "=", "True", ")", "return", "headers" ]
Attempt to refresh auth token and links.
[ "Attempt", "to", "refresh", "auth", "token", "and", "links", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L36-L40
train
fronzbot/blinkpy
blinkpy/helpers/util.py
http_req
def http_req(blink, url='http://example.com', data=None, headers=None, reqtype='get', stream=False, json_resp=True, is_retry=False): """ Perform server requests and check if reauthorization neccessary. :param blink: Blink instance :param url: URL to perform request :param data: Data to...
python
def http_req(blink, url='http://example.com', data=None, headers=None, reqtype='get', stream=False, json_resp=True, is_retry=False): """ Perform server requests and check if reauthorization neccessary. :param blink: Blink instance :param url: URL to perform request :param data: Data to...
[ "def", "http_req", "(", "blink", ",", "url", "=", "'http://example.com'", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "reqtype", "=", "'get'", ",", "stream", "=", "False", ",", "json_resp", "=", "True", ",", "is_retry", "=", "False", ")...
Perform server requests and check if reauthorization neccessary. :param blink: Blink instance :param url: URL to perform request :param data: Data to send (default: None) :param headers: Headers to send (default: None) :param reqtype: Can be 'get' or 'post' (default: 'get') :param stream: Strea...
[ "Perform", "server", "requests", "and", "check", "if", "reauthorization", "neccessary", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/helpers/util.py#L43-L94
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.start
def start(self): """ Perform full system setup. Method logs in and sets auth token, urls, and ids for future requests. Essentially this is just a wrapper function for ease of use. """ if self._username is None or self._password is None: if not self.login(): ...
python
def start(self): """ Perform full system setup. Method logs in and sets auth token, urls, and ids for future requests. Essentially this is just a wrapper function for ease of use. """ if self._username is None or self._password is None: if not self.login(): ...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "_username", "is", "None", "or", "self", ".", "_password", "is", "None", ":", "if", "not", "self", ".", "login", "(", ")", ":", "return", "elif", "not", "self", ".", "get_auth_token", "(", "...
Perform full system setup. Method logs in and sets auth token, urls, and ids for future requests. Essentially this is just a wrapper function for ease of use.
[ "Perform", "full", "system", "setup", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L82-L107
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.login
def login(self): """Prompt user for username and password.""" self._username = input("Username:") self._password = getpass.getpass("Password:") if self.get_auth_token(): _LOGGER.debug("Login successful!") return True _LOGGER.warning("Unable to login with %...
python
def login(self): """Prompt user for username and password.""" self._username = input("Username:") self._password = getpass.getpass("Password:") if self.get_auth_token(): _LOGGER.debug("Login successful!") return True _LOGGER.warning("Unable to login with %...
[ "def", "login", "(", "self", ")", ":", "self", ".", "_username", "=", "input", "(", "\"Username:\"", ")", "self", ".", "_password", "=", "getpass", ".", "getpass", "(", "\"Password:\"", ")", "if", "self", ".", "get_auth_token", "(", ")", ":", "_LOGGER", ...
Prompt user for username and password.
[ "Prompt", "user", "for", "username", "and", "password", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L109-L117
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.get_auth_token
def get_auth_token(self, is_retry=False): """Retrieve the authentication token from Blink.""" if not isinstance(self._username, str): raise BlinkAuthenticationException(ERROR.USERNAME) if not isinstance(self._password, str): raise BlinkAuthenticationException(ERROR.PASSWO...
python
def get_auth_token(self, is_retry=False): """Retrieve the authentication token from Blink.""" if not isinstance(self._username, str): raise BlinkAuthenticationException(ERROR.USERNAME) if not isinstance(self._password, str): raise BlinkAuthenticationException(ERROR.PASSWO...
[ "def", "get_auth_token", "(", "self", ",", "is_retry", "=", "False", ")", ":", "if", "not", "isinstance", "(", "self", ".", "_username", ",", "str", ")", ":", "raise", "BlinkAuthenticationException", "(", "ERROR", ".", "USERNAME", ")", "if", "not", "isinst...
Retrieve the authentication token from Blink.
[ "Retrieve", "the", "authentication", "token", "from", "Blink", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L119-L141
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.login_request
def login_request(self, login_urls, is_retry=False): """Make a login request.""" try: login_url = login_urls.pop(0) except IndexError: _LOGGER.error("Could not login to blink servers.") return False _LOGGER.info("Attempting login with %s", login_url) ...
python
def login_request(self, login_urls, is_retry=False): """Make a login request.""" try: login_url = login_urls.pop(0) except IndexError: _LOGGER.error("Could not login to blink servers.") return False _LOGGER.info("Attempting login with %s", login_url) ...
[ "def", "login_request", "(", "self", ",", "login_urls", ",", "is_retry", "=", "False", ")", ":", "try", ":", "login_url", "=", "login_urls", ".", "pop", "(", "0", ")", "except", "IndexError", ":", "_LOGGER", ".", "error", "(", "\"Could not login to blink ser...
Make a login request.
[ "Make", "a", "login", "request", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L143-L176
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.get_ids
def get_ids(self): """Set the network ID and Account ID.""" response = api.request_networks(self) all_networks = [] network_dict = {} for network, status in self.networks.items(): if status['onboarded']: all_networks.append('{}'.format(network)) ...
python
def get_ids(self): """Set the network ID and Account ID.""" response = api.request_networks(self) all_networks = [] network_dict = {} for network, status in self.networks.items(): if status['onboarded']: all_networks.append('{}'.format(network)) ...
[ "def", "get_ids", "(", "self", ")", ":", "response", "=", "api", ".", "request_networks", "(", "self", ")", "all_networks", "=", "[", "]", "network_dict", "=", "{", "}", "for", "network", ",", "status", "in", "self", ".", "networks", ".", "items", "(",...
Set the network ID and Account ID.
[ "Set", "the", "network", "ID", "and", "Account", "ID", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L178-L195
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.get_cameras
def get_cameras(self): """Retrieve a camera list for each onboarded network.""" response = api.request_homescreen(self) try: all_cameras = {} for camera in response['cameras']: camera_network = str(camera['network_id']) camera_name = camera...
python
def get_cameras(self): """Retrieve a camera list for each onboarded network.""" response = api.request_homescreen(self) try: all_cameras = {} for camera in response['cameras']: camera_network = str(camera['network_id']) camera_name = camera...
[ "def", "get_cameras", "(", "self", ")", ":", "response", "=", "api", ".", "request_homescreen", "(", "self", ")", "try", ":", "all_cameras", "=", "{", "}", "for", "camera", "in", "response", "[", "'cameras'", "]", ":", "camera_network", "=", "str", "(", ...
Retrieve a camera list for each onboarded network.
[ "Retrieve", "a", "camera", "list", "for", "each", "onboarded", "network", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L197-L214
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.refresh
def refresh(self, force_cache=False): """ Perform a system refresh. :param force_cache: Force an update of the camera cache """ if self.check_if_ok_to_update() or force_cache: for sync_name, sync_module in self.sync.items(): _LOGGER.debug("Attempting ...
python
def refresh(self, force_cache=False): """ Perform a system refresh. :param force_cache: Force an update of the camera cache """ if self.check_if_ok_to_update() or force_cache: for sync_name, sync_module in self.sync.items(): _LOGGER.debug("Attempting ...
[ "def", "refresh", "(", "self", ",", "force_cache", "=", "False", ")", ":", "if", "self", ".", "check_if_ok_to_update", "(", ")", "or", "force_cache", ":", "for", "sync_name", ",", "sync_module", "in", "self", ".", "sync", ".", "items", "(", ")", ":", "...
Perform a system refresh. :param force_cache: Force an update of the camera cache
[ "Perform", "a", "system", "refresh", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L217-L231
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.check_if_ok_to_update
def check_if_ok_to_update(self): """Check if it is ok to perform an http request.""" current_time = int(time.time()) last_refresh = self.last_refresh if last_refresh is None: last_refresh = 0 if current_time >= (last_refresh + self.refresh_rate): return Tr...
python
def check_if_ok_to_update(self): """Check if it is ok to perform an http request.""" current_time = int(time.time()) last_refresh = self.last_refresh if last_refresh is None: last_refresh = 0 if current_time >= (last_refresh + self.refresh_rate): return Tr...
[ "def", "check_if_ok_to_update", "(", "self", ")", ":", "current_time", "=", "int", "(", "time", ".", "time", "(", ")", ")", "last_refresh", "=", "self", ".", "last_refresh", "if", "last_refresh", "is", "None", ":", "last_refresh", "=", "0", "if", "current_...
Check if it is ok to perform an http request.
[ "Check", "if", "it", "is", "ok", "to", "perform", "an", "http", "request", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L233-L241
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.merge_cameras
def merge_cameras(self): """Merge all sync camera dicts into one.""" combined = CaseInsensitiveDict({}) for sync in self.sync: combined = merge_dicts(combined, self.sync[sync].cameras) return combined
python
def merge_cameras(self): """Merge all sync camera dicts into one.""" combined = CaseInsensitiveDict({}) for sync in self.sync: combined = merge_dicts(combined, self.sync[sync].cameras) return combined
[ "def", "merge_cameras", "(", "self", ")", ":", "combined", "=", "CaseInsensitiveDict", "(", "{", "}", ")", "for", "sync", "in", "self", ".", "sync", ":", "combined", "=", "merge_dicts", "(", "combined", ",", "self", ".", "sync", "[", "sync", "]", ".", ...
Merge all sync camera dicts into one.
[ "Merge", "all", "sync", "camera", "dicts", "into", "one", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L243-L248
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink.download_videos
def download_videos(self, path, since=None, camera='all', stop=10): """ Download all videos from server since specified time. :param path: Path to write files. /path/<cameraname>_<recorddate>.mp4 :param since: Date and time to get videos from. Ex: "2018/07/28 12:3...
python
def download_videos(self, path, since=None, camera='all', stop=10): """ Download all videos from server since specified time. :param path: Path to write files. /path/<cameraname>_<recorddate>.mp4 :param since: Date and time to get videos from. Ex: "2018/07/28 12:3...
[ "def", "download_videos", "(", "self", ",", "path", ",", "since", "=", "None", ",", "camera", "=", "'all'", ",", "stop", "=", "10", ")", ":", "if", "since", "is", "None", ":", "since_epochs", "=", "self", ".", "last_refresh", "else", ":", "parsed_datet...
Download all videos from server since specified time. :param path: Path to write files. /path/<cameraname>_<recorddate>.mp4 :param since: Date and time to get videos from. Ex: "2018/07/28 12:33:00" to retrieve videos since July 28th 2018 at 12:33:00 ...
[ "Download", "all", "videos", "from", "server", "since", "specified", "time", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L250-L285
train
fronzbot/blinkpy
blinkpy/blinkpy.py
Blink._parse_downloaded_items
def _parse_downloaded_items(self, result, camera, path): """Parse downloaded videos.""" for item in result: try: created_at = item['created_at'] camera_name = item['camera_name'] is_deleted = item['deleted'] address = item['addr...
python
def _parse_downloaded_items(self, result, camera, path): """Parse downloaded videos.""" for item in result: try: created_at = item['created_at'] camera_name = item['camera_name'] is_deleted = item['deleted'] address = item['addr...
[ "def", "_parse_downloaded_items", "(", "self", ",", "result", ",", "camera", ",", "path", ")", ":", "for", "item", "in", "result", ":", "try", ":", "created_at", "=", "item", "[", "'created_at'", "]", "camera_name", "=", "item", "[", "'camera_name'", "]", ...
Parse downloaded videos.
[ "Parse", "downloaded", "videos", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/blinkpy.py#L287-L322
train
fronzbot/blinkpy
blinkpy/api.py
request_login
def request_login(blink, url, username, password, is_retry=False): """ Login request. :param blink: Blink instance. :param url: Login url. :param username: Blink username. :param password: Blink password. :param is_retry: Is this part of a re-authorization attempt? """ headers = { ...
python
def request_login(blink, url, username, password, is_retry=False): """ Login request. :param blink: Blink instance. :param url: Login url. :param username: Blink username. :param password: Blink password. :param is_retry: Is this part of a re-authorization attempt? """ headers = { ...
[ "def", "request_login", "(", "blink", ",", "url", ",", "username", ",", "password", ",", "is_retry", "=", "False", ")", ":", "headers", "=", "{", "'Host'", ":", "DEFAULT_URL", ",", "'Content-Type'", ":", "'application/json'", "}", "data", "=", "dumps", "("...
Login request. :param blink: Blink instance. :param url: Login url. :param username: Blink username. :param password: Blink password. :param is_retry: Is this part of a re-authorization attempt?
[ "Login", "request", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L14-L34
train
fronzbot/blinkpy
blinkpy/api.py
request_networks
def request_networks(blink): """Request all networks information.""" url = "{}/networks".format(blink.urls.base_url) return http_get(blink, url)
python
def request_networks(blink): """Request all networks information.""" url = "{}/networks".format(blink.urls.base_url) return http_get(blink, url)
[ "def", "request_networks", "(", "blink", ")", ":", "url", "=", "\"{}/networks\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request all networks information.
[ "Request", "all", "networks", "information", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L37-L40
train
fronzbot/blinkpy
blinkpy/api.py
request_network_status
def request_network_status(blink, network): """ Request network information. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}".format(blink.urls.base_url, network) return http_get(blink, url)
python
def request_network_status(blink, network): """ Request network information. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}".format(blink.urls.base_url, network) return http_get(blink, url)
[ "def", "request_network_status", "(", "blink", ",", "network", ")", ":", "url", "=", "\"{}/network/{}\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request network information. :param blink: Blink instance. :param network: Sync module network id.
[ "Request", "network", "information", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L44-L52
train
fronzbot/blinkpy
blinkpy/api.py
request_syncmodule
def request_syncmodule(blink, network): """ Request sync module info. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/syncmodules".format(blink.urls.base_url, network) return http_get(blink, url)
python
def request_syncmodule(blink, network): """ Request sync module info. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/syncmodules".format(blink.urls.base_url, network) return http_get(blink, url)
[ "def", "request_syncmodule", "(", "blink", ",", "network", ")", ":", "url", "=", "\"{}/network/{}/syncmodules\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request sync module info. :param blink: Blink instance. :param network: Sync module network id.
[ "Request", "sync", "module", "info", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L56-L64
train
fronzbot/blinkpy
blinkpy/api.py
request_system_arm
def request_system_arm(blink, network): """ Arm system. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/arm".format(blink.urls.base_url, network) return http_post(blink, url)
python
def request_system_arm(blink, network): """ Arm system. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/arm".format(blink.urls.base_url, network) return http_post(blink, url)
[ "def", "request_system_arm", "(", "blink", ",", "network", ")", ":", "url", "=", "\"{}/network/{}/arm\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ")", "return", "http_post", "(", "blink", ",", "url", ")" ]
Arm system. :param blink: Blink instance. :param network: Sync module network id.
[ "Arm", "system", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L68-L76
train
fronzbot/blinkpy
blinkpy/api.py
request_system_disarm
def request_system_disarm(blink, network): """ Disarm system. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/disarm".format(blink.urls.base_url, network) return http_post(blink, url)
python
def request_system_disarm(blink, network): """ Disarm system. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/disarm".format(blink.urls.base_url, network) return http_post(blink, url)
[ "def", "request_system_disarm", "(", "blink", ",", "network", ")", ":", "url", "=", "\"{}/network/{}/disarm\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ")", "return", "http_post", "(", "blink", ",", "url", ")" ]
Disarm system. :param blink: Blink instance. :param network: Sync module network id.
[ "Disarm", "system", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L80-L88
train
fronzbot/blinkpy
blinkpy/api.py
request_command_status
def request_command_status(blink, network, command_id): """ Request command status. :param blink: Blink instance. :param network: Sync module network id. :param command_id: Command id to check. """ url = "{}/network/{}/command/{}".format(blink.urls.base_url, ...
python
def request_command_status(blink, network, command_id): """ Request command status. :param blink: Blink instance. :param network: Sync module network id. :param command_id: Command id to check. """ url = "{}/network/{}/command/{}".format(blink.urls.base_url, ...
[ "def", "request_command_status", "(", "blink", ",", "network", ",", "command_id", ")", ":", "url", "=", "\"{}/network/{}/command/{}\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ",", "command_id", ")", "return", "http_get", "("...
Request command status. :param blink: Blink instance. :param network: Sync module network id. :param command_id: Command id to check.
[ "Request", "command", "status", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L91-L102
train
fronzbot/blinkpy
blinkpy/api.py
request_homescreen
def request_homescreen(blink): """Request homescreen info.""" url = "{}/api/v3/accounts/{}/homescreen".format(blink.urls.base_url, blink.account_id) return http_get(blink, url)
python
def request_homescreen(blink): """Request homescreen info.""" url = "{}/api/v3/accounts/{}/homescreen".format(blink.urls.base_url, blink.account_id) return http_get(blink, url)
[ "def", "request_homescreen", "(", "blink", ")", ":", "url", "=", "\"{}/api/v3/accounts/{}/homescreen\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "blink", ".", "account_id", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request homescreen info.
[ "Request", "homescreen", "info", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L106-L110
train
fronzbot/blinkpy
blinkpy/api.py
request_sync_events
def request_sync_events(blink, network): """ Request events from sync module. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/events/network/{}".format(blink.urls.base_url, network) return http_get(blink, url)
python
def request_sync_events(blink, network): """ Request events from sync module. :param blink: Blink instance. :param network: Sync module network id. """ url = "{}/events/network/{}".format(blink.urls.base_url, network) return http_get(blink, url)
[ "def", "request_sync_events", "(", "blink", ",", "network", ")", ":", "url", "=", "\"{}/events/network/{}\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request events from sync module. :param blink: Blink instance. :param network: Sync module network id.
[ "Request", "events", "from", "sync", "module", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L114-L122
train
fronzbot/blinkpy
blinkpy/api.py
request_video_count
def request_video_count(blink): """Request total video count.""" url = "{}/api/v2/videos/count".format(blink.urls.base_url) return http_get(blink, url)
python
def request_video_count(blink): """Request total video count.""" url = "{}/api/v2/videos/count".format(blink.urls.base_url) return http_get(blink, url)
[ "def", "request_video_count", "(", "blink", ")", ":", "url", "=", "\"{}/api/v2/videos/count\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request total video count.
[ "Request", "total", "video", "count", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L156-L159
train
fronzbot/blinkpy
blinkpy/api.py
request_videos
def request_videos(blink, time=None, page=0): """ Perform a request for videos. :param blink: Blink instance. :param time: Get videos since this time. In epoch seconds. :param page: Page number to get videos from. """ timestamp = get_time(time) url = "{}/api/v2/videos/changed?since={}&...
python
def request_videos(blink, time=None, page=0): """ Perform a request for videos. :param blink: Blink instance. :param time: Get videos since this time. In epoch seconds. :param page: Page number to get videos from. """ timestamp = get_time(time) url = "{}/api/v2/videos/changed?since={}&...
[ "def", "request_videos", "(", "blink", ",", "time", "=", "None", ",", "page", "=", "0", ")", ":", "timestamp", "=", "get_time", "(", "time", ")", "url", "=", "\"{}/api/v2/videos/changed?since={}&page={}\"", ".", "format", "(", "blink", ".", "urls", ".", "b...
Perform a request for videos. :param blink: Blink instance. :param time: Get videos since this time. In epoch seconds. :param page: Page number to get videos from.
[ "Perform", "a", "request", "for", "videos", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L162-L173
train
fronzbot/blinkpy
blinkpy/api.py
request_cameras
def request_cameras(blink, network): """ Request all camera information. :param Blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/cameras".format(blink.urls.base_url, network) return http_get(blink, url)
python
def request_cameras(blink, network): """ Request all camera information. :param Blink: Blink instance. :param network: Sync module network id. """ url = "{}/network/{}/cameras".format(blink.urls.base_url, network) return http_get(blink, url)
[ "def", "request_cameras", "(", "blink", ",", "network", ")", ":", "url", "=", "\"{}/network/{}/cameras\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ")", "return", "http_get", "(", "blink", ",", "url", ")" ]
Request all camera information. :param Blink: Blink instance. :param network: Sync module network id.
[ "Request", "all", "camera", "information", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L177-L185
train
fronzbot/blinkpy
blinkpy/api.py
request_camera_sensors
def request_camera_sensors(blink, network, camera_id): """ Request camera sensor info for one camera. :param blink: Blink instance. :param network: Sync module network id. :param camera_id: Camera ID of camera to request sesnor info from. """ url = "{}/network/{}/camera/{}/signals".format(b...
python
def request_camera_sensors(blink, network, camera_id): """ Request camera sensor info for one camera. :param blink: Blink instance. :param network: Sync module network id. :param camera_id: Camera ID of camera to request sesnor info from. """ url = "{}/network/{}/camera/{}/signals".format(b...
[ "def", "request_camera_sensors", "(", "blink", ",", "network", ",", "camera_id", ")", ":", "url", "=", "\"{}/network/{}/camera/{}/signals\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ",", "camera_id", ")", "return", "http_get", ...
Request camera sensor info for one camera. :param blink: Blink instance. :param network: Sync module network id. :param camera_id: Camera ID of camera to request sesnor info from.
[ "Request", "camera", "sensor", "info", "for", "one", "camera", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L202-L213
train
fronzbot/blinkpy
blinkpy/api.py
request_motion_detection_enable
def request_motion_detection_enable(blink, network, camera_id): """ Enable motion detection for a camera. :param blink: Blink instance. :param network: Sync module network id. :param camera_id: Camera ID of camera to enable. """ url = "{}/network/{}/camera/{}/enable".format(blink.urls.base_...
python
def request_motion_detection_enable(blink, network, camera_id): """ Enable motion detection for a camera. :param blink: Blink instance. :param network: Sync module network id. :param camera_id: Camera ID of camera to enable. """ url = "{}/network/{}/camera/{}/enable".format(blink.urls.base_...
[ "def", "request_motion_detection_enable", "(", "blink", ",", "network", ",", "camera_id", ")", ":", "url", "=", "\"{}/network/{}/camera/{}/enable\"", ".", "format", "(", "blink", ".", "urls", ".", "base_url", ",", "network", ",", "camera_id", ")", "return", "htt...
Enable motion detection for a camera. :param blink: Blink instance. :param network: Sync module network id. :param camera_id: Camera ID of camera to enable.
[ "Enable", "motion", "detection", "for", "a", "camera", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L217-L228
train
fronzbot/blinkpy
blinkpy/api.py
http_get
def http_get(blink, url, stream=False, json=True, is_retry=False): """ Perform an http get request. :param url: URL to perform get request. :param stream: Stream response? True/FALSE :param json: Return json response? TRUE/False :param is_retry: Is this part of a re-auth attempt? """ if...
python
def http_get(blink, url, stream=False, json=True, is_retry=False): """ Perform an http get request. :param url: URL to perform get request. :param stream: Stream response? True/FALSE :param json: Return json response? TRUE/False :param is_retry: Is this part of a re-auth attempt? """ if...
[ "def", "http_get", "(", "blink", ",", "url", ",", "stream", "=", "False", ",", "json", "=", "True", ",", "is_retry", "=", "False", ")", ":", "if", "blink", ".", "auth_header", "is", "None", ":", "raise", "BlinkException", "(", "ERROR", ".", "AUTH_TOKEN...
Perform an http get request. :param url: URL to perform get request. :param stream: Stream response? True/FALSE :param json: Return json response? TRUE/False :param is_retry: Is this part of a re-auth attempt?
[ "Perform", "an", "http", "get", "request", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L245-L259
train
fronzbot/blinkpy
blinkpy/api.py
http_post
def http_post(blink, url, is_retry=False): """ Perform an http post request. :param url: URL to perfom post request. :param is_retry: Is this part of a re-auth attempt? """ if blink.auth_header is None: raise BlinkException(ERROR.AUTH_TOKEN) _LOGGER.debug("Making POST request to %s"...
python
def http_post(blink, url, is_retry=False): """ Perform an http post request. :param url: URL to perfom post request. :param is_retry: Is this part of a re-auth attempt? """ if blink.auth_header is None: raise BlinkException(ERROR.AUTH_TOKEN) _LOGGER.debug("Making POST request to %s"...
[ "def", "http_post", "(", "blink", ",", "url", ",", "is_retry", "=", "False", ")", ":", "if", "blink", ".", "auth_header", "is", "None", ":", "raise", "BlinkException", "(", "ERROR", ".", "AUTH_TOKEN", ")", "_LOGGER", ".", "debug", "(", "\"Making POST reque...
Perform an http post request. :param url: URL to perfom post request. :param is_retry: Is this part of a re-auth attempt?
[ "Perform", "an", "http", "post", "request", "." ]
bfdc1e47bdd84903f1aca653605846f3c99bcfac
https://github.com/fronzbot/blinkpy/blob/bfdc1e47bdd84903f1aca653605846f3c99bcfac/blinkpy/api.py#L262-L273
train
loli/medpy
medpy/filter/image.py
sls
def sls(minuend, subtrahend, metric = "ssd", noise = "global", signed = True, sn_size = None, sn_footprint = None, sn_mode = "reflect", sn_cval = 0.0, pn_size = None, pn_footprint = None, pn_mode = "reflect", pn_cval = 0.0): r""" Computes the signed local similarity between two images. Comp...
python
def sls(minuend, subtrahend, metric = "ssd", noise = "global", signed = True, sn_size = None, sn_footprint = None, sn_mode = "reflect", sn_cval = 0.0, pn_size = None, pn_footprint = None, pn_mode = "reflect", pn_cval = 0.0): r""" Computes the signed local similarity between two images. Comp...
[ "def", "sls", "(", "minuend", ",", "subtrahend", ",", "metric", "=", "\"ssd\"", ",", "noise", "=", "\"global\"", ",", "signed", "=", "True", ",", "sn_size", "=", "None", ",", "sn_footprint", "=", "None", ",", "sn_mode", "=", "\"reflect\"", ",", "sn_cval"...
r""" Computes the signed local similarity between two images. Compares a patch around each voxel of the minuend array to a number of patches centered at the points of a search neighbourhood in the subtrahend. Thus, creates a multi-dimensional measure of patch similarity between the minuend and a co...
[ "r", "Computes", "the", "signed", "local", "similarity", "between", "two", "images", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L37-L170
train
loli/medpy
medpy/filter/image.py
average_filter
def average_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0): r""" Calculates a multi-dimensional average filter. Parameters ---------- input : array-like input array to filter size : scalar or tuple, optional See footprint, below foo...
python
def average_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0): r""" Calculates a multi-dimensional average filter. Parameters ---------- input : array-like input array to filter size : scalar or tuple, optional See footprint, below foo...
[ "def", "average_filter", "(", "input", ",", "size", "=", "None", ",", "footprint", "=", "None", ",", "output", "=", "None", ",", "mode", "=", "\"reflect\"", ",", "cval", "=", "0.0", ",", "origin", "=", "0", ")", ":", "r", "footprint", "=", "__make_fo...
r""" Calculates a multi-dimensional average filter. Parameters ---------- input : array-like input array to filter size : scalar or tuple, optional See footprint, below footprint : array, optional Either `size` or `footprint` must be defined. `size` gives the sha...
[ "r", "Calculates", "a", "multi", "-", "dimensional", "average", "filter", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L230-L284
train
loli/medpy
medpy/filter/image.py
sum_filter
def sum_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0): r""" Calculates a multi-dimensional sum filter. Parameters ---------- input : array-like input array to filter size : scalar or tuple, optional See footprint, below footprint :...
python
def sum_filter(input, size=None, footprint=None, output=None, mode="reflect", cval=0.0, origin=0): r""" Calculates a multi-dimensional sum filter. Parameters ---------- input : array-like input array to filter size : scalar or tuple, optional See footprint, below footprint :...
[ "def", "sum_filter", "(", "input", ",", "size", "=", "None", ",", "footprint", "=", "None", ",", "output", "=", "None", ",", "mode", "=", "\"reflect\"", ",", "cval", "=", "0.0", ",", "origin", "=", "0", ")", ":", "r", "footprint", "=", "__make_footpr...
r""" Calculates a multi-dimensional sum filter. Parameters ---------- input : array-like input array to filter size : scalar or tuple, optional See footprint, below footprint : array, optional Either `size` or `footprint` must be defined. `size` gives the shape t...
[ "r", "Calculates", "a", "multi", "-", "dimensional", "sum", "filter", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/image.py#L287-L337
train
loli/medpy
medpy/features/histogram.py
_gaussian_membership_sigma
def _gaussian_membership_sigma(smoothness, eps = 0.0005): # 275us @ smothness=10 r"""Compute the sigma required for a gaussian, such that in a neighbourhood of smoothness the maximum error is 'eps'. The error is here the difference between the clipped integral and one. """ error = 0 deltas = [0....
python
def _gaussian_membership_sigma(smoothness, eps = 0.0005): # 275us @ smothness=10 r"""Compute the sigma required for a gaussian, such that in a neighbourhood of smoothness the maximum error is 'eps'. The error is here the difference between the clipped integral and one. """ error = 0 deltas = [0....
[ "def", "_gaussian_membership_sigma", "(", "smoothness", ",", "eps", "=", "0.0005", ")", ":", "r", "error", "=", "0", "deltas", "=", "[", "0.1", ",", "0.01", ",", "0.001", ",", "0.0001", "]", "sigma", "=", "smoothness", "*", "0.3", "point", "=", "-", ...
r"""Compute the sigma required for a gaussian, such that in a neighbourhood of smoothness the maximum error is 'eps'. The error is here the difference between the clipped integral and one.
[ "r", "Compute", "the", "sigma", "required", "for", "a", "gaussian", "such", "that", "in", "a", "neighbourhood", "of", "smoothness", "the", "maximum", "error", "is", "eps", ".", "The", "error", "is", "here", "the", "difference", "between", "the", "clipped", ...
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/histogram.py#L361-L375
train
loli/medpy
doc/numpydoc/numpydoc/plot_directive.py
out_of_date
def out_of_date(original, derived): """ Returns True if derivative is out-of-date wrt original, both of which are full file paths. """ return (not os.path.exists(derived) or os.stat(derived).st_mtime < os.stat(original).st_mtime)
python
def out_of_date(original, derived): """ Returns True if derivative is out-of-date wrt original, both of which are full file paths. """ return (not os.path.exists(derived) or os.stat(derived).st_mtime < os.stat(original).st_mtime)
[ "def", "out_of_date", "(", "original", ",", "derived", ")", ":", "return", "(", "not", "os", ".", "path", ".", "exists", "(", "derived", ")", "or", "os", ".", "stat", "(", "derived", ")", ".", "st_mtime", "<", "os", ".", "stat", "(", "original", ")...
Returns True if derivative is out-of-date wrt original, both of which are full file paths.
[ "Returns", "True", "if", "derivative", "is", "out", "-", "of", "-", "date", "wrt", "original", "both", "of", "which", "are", "full", "file", "paths", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/plot_directive.py#L481-L487
train
loli/medpy
medpy/features/texture.py
local_maxima
def local_maxima(vector,min_distance = 4, brd_mode = "wrap"): """ Internal finder for local maxima . Returns UNSORTED indices of maxima in input vector. """ fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode) for ii in range(len(fits)): if fits[ii] == fits...
python
def local_maxima(vector,min_distance = 4, brd_mode = "wrap"): """ Internal finder for local maxima . Returns UNSORTED indices of maxima in input vector. """ fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode) for ii in range(len(fits)): if fits[ii] == fits...
[ "def", "local_maxima", "(", "vector", ",", "min_distance", "=", "4", ",", "brd_mode", "=", "\"wrap\"", ")", ":", "fits", "=", "gaussian_filter", "(", "numpy", ".", "asarray", "(", "vector", ",", "dtype", "=", "numpy", ".", "float32", ")", ",", "1.", ",...
Internal finder for local maxima . Returns UNSORTED indices of maxima in input vector.
[ "Internal", "finder", "for", "local", "maxima", ".", "Returns", "UNSORTED", "indices", "of", "maxima", "in", "input", "vector", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L268-L280
train
loli/medpy
medpy/features/texture.py
local_minima
def local_minima(vector,min_distance = 4, brd_mode = "wrap"): """ Internal finder for local minima . Returns UNSORTED indices of minima in input vector. """ fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode) for ii in range(len(fits)): if fits[ii] == fits...
python
def local_minima(vector,min_distance = 4, brd_mode = "wrap"): """ Internal finder for local minima . Returns UNSORTED indices of minima in input vector. """ fits = gaussian_filter(numpy.asarray(vector,dtype=numpy.float32),1., mode=brd_mode) for ii in range(len(fits)): if fits[ii] == fits...
[ "def", "local_minima", "(", "vector", ",", "min_distance", "=", "4", ",", "brd_mode", "=", "\"wrap\"", ")", ":", "fits", "=", "gaussian_filter", "(", "numpy", ".", "asarray", "(", "vector", ",", "dtype", "=", "numpy", ".", "float32", ")", ",", "1.", ",...
Internal finder for local minima . Returns UNSORTED indices of minima in input vector.
[ "Internal", "finder", "for", "local", "minima", ".", "Returns", "UNSORTED", "indices", "of", "minima", "in", "input", "vector", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L282-L294
train
loli/medpy
medpy/features/texture.py
find_valley_range
def find_valley_range(vector, min_distance = 4): """ Internal finder peaks and valley ranges. Returns UNSORTED indices of maxima in input vector. Returns range of valleys before and after maximum """ # http://users.monash.edu.au/~dengs/resource/papers/icme08.pdf # find min and max with ...
python
def find_valley_range(vector, min_distance = 4): """ Internal finder peaks and valley ranges. Returns UNSORTED indices of maxima in input vector. Returns range of valleys before and after maximum """ # http://users.monash.edu.au/~dengs/resource/papers/icme08.pdf # find min and max with ...
[ "def", "find_valley_range", "(", "vector", ",", "min_distance", "=", "4", ")", ":", "mode", "=", "\"wrap\"", "minima", "=", "local_minima", "(", "vector", ",", "min_distance", ",", "mode", ")", "maxima", "=", "local_maxima", "(", "vector", ",", "min_distance...
Internal finder peaks and valley ranges. Returns UNSORTED indices of maxima in input vector. Returns range of valleys before and after maximum
[ "Internal", "finder", "peaks", "and", "valley", "ranges", ".", "Returns", "UNSORTED", "indices", "of", "maxima", "in", "input", "vector", ".", "Returns", "range", "of", "valleys", "before", "and", "after", "maximum" ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/texture.py#L296-L324
train
loli/medpy
medpy/filter/smoothing.py
gauss_xminus1d
def gauss_xminus1d(img, sigma, dim=2): r""" Applies a X-1D gauss to a copy of a XD image, slicing it along dim. Essentially uses `scipy.ndimage.filters.gaussian_filter`, but applies it to a dimension less than the image has. Parameters ---------- img : array_like The image to smoot...
python
def gauss_xminus1d(img, sigma, dim=2): r""" Applies a X-1D gauss to a copy of a XD image, slicing it along dim. Essentially uses `scipy.ndimage.filters.gaussian_filter`, but applies it to a dimension less than the image has. Parameters ---------- img : array_like The image to smoot...
[ "def", "gauss_xminus1d", "(", "img", ",", "sigma", ",", "dim", "=", "2", ")", ":", "r", "img", "=", "numpy", ".", "array", "(", "img", ",", "copy", "=", "False", ")", "return", "xminus1d", "(", "img", ",", "gaussian_filter", ",", "dim", ",", "sigma...
r""" Applies a X-1D gauss to a copy of a XD image, slicing it along dim. Essentially uses `scipy.ndimage.filters.gaussian_filter`, but applies it to a dimension less than the image has. Parameters ---------- img : array_like The image to smooth. sigma : integer The sigma i....
[ "r", "Applies", "a", "X", "-", "1D", "gauss", "to", "a", "copy", "of", "a", "XD", "image", "slicing", "it", "along", "dim", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/smoothing.py#L34-L56
train
loli/medpy
medpy/filter/smoothing.py
anisotropic_diffusion
def anisotropic_diffusion(img, niter=1, kappa=50, gamma=0.1, voxelspacing=None, option=1): r""" Edge-preserving, XD Anisotropic diffusion. Parameters ---------- img : array_like Input image (will be cast to numpy.float). niter : integer Number of iterations. kappa : integer...
python
def anisotropic_diffusion(img, niter=1, kappa=50, gamma=0.1, voxelspacing=None, option=1): r""" Edge-preserving, XD Anisotropic diffusion. Parameters ---------- img : array_like Input image (will be cast to numpy.float). niter : integer Number of iterations. kappa : integer...
[ "def", "anisotropic_diffusion", "(", "img", ",", "niter", "=", "1", ",", "kappa", "=", "50", ",", "gamma", "=", "0.1", ",", "voxelspacing", "=", "None", ",", "option", "=", "1", ")", ":", "r", "if", "option", "==", "1", ":", "def", "condgradient", ...
r""" Edge-preserving, XD Anisotropic diffusion. Parameters ---------- img : array_like Input image (will be cast to numpy.float). niter : integer Number of iterations. kappa : integer Conduction coefficient, e.g. 20-100. ``kappa`` controls conduction as a functi...
[ "r", "Edge", "-", "preserving", "XD", "Anisotropic", "diffusion", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/smoothing.py#L58-L169
train
loli/medpy
medpy/graphcut/generate.py
__voxel_4conectedness
def __voxel_4conectedness(shape): """ Returns the number of edges for the supplied image shape assuming 4-connectedness. The name of the function has historical reasons. Essentially it returns the number of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness, etc. ...
python
def __voxel_4conectedness(shape): """ Returns the number of edges for the supplied image shape assuming 4-connectedness. The name of the function has historical reasons. Essentially it returns the number of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness, etc. ...
[ "def", "__voxel_4conectedness", "(", "shape", ")", ":", "shape", "=", "list", "(", "shape", ")", "while", "1", "in", "shape", ":", "shape", ".", "remove", "(", "1", ")", "return", "int", "(", "round", "(", "sum", "(", "[", "(", "dim", "-", "1", "...
Returns the number of edges for the supplied image shape assuming 4-connectedness. The name of the function has historical reasons. Essentially it returns the number of edges assuming 4-connectedness only for 2D. For 3D it assumes 6-connectedness, etc. @param shape the shape of the image @...
[ "Returns", "the", "number", "of", "edges", "for", "the", "supplied", "image", "shape", "assuming", "4", "-", "connectedness", ".", "The", "name", "of", "the", "function", "has", "historical", "reasons", ".", "Essentially", "it", "returns", "the", "number", "...
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/generate.py#L316-L331
train
loli/medpy
medpy/graphcut/energy_voxel.py
__skeleton_base
def __skeleton_base(graph, image, boundary_term, neighbourhood_function, spacing): """ Base of the skeleton for voxel based boundary term calculation. This function holds the low level procedures shared by nearly all boundary terms. @param graph An initialized graph.GCGraph object @type gr...
python
def __skeleton_base(graph, image, boundary_term, neighbourhood_function, spacing): """ Base of the skeleton for voxel based boundary term calculation. This function holds the low level procedures shared by nearly all boundary terms. @param graph An initialized graph.GCGraph object @type gr...
[ "def", "__skeleton_base", "(", "graph", ",", "image", ",", "boundary_term", ",", "neighbourhood_function", ",", "spacing", ")", ":", "image", "=", "scipy", ".", "asarray", "(", "image", ")", "image", "=", "image", ".", "astype", "(", "scipy", ".", "float_"...
Base of the skeleton for voxel based boundary term calculation. This function holds the low level procedures shared by nearly all boundary terms. @param graph An initialized graph.GCGraph object @type graph.GCGraph @param image The image containing the voxel intensity values @type image nu...
[ "Base", "of", "the", "skeleton", "for", "voxel", "based", "boundary", "term", "calculation", ".", "This", "function", "holds", "the", "low", "level", "procedures", "shared", "by", "nearly", "all", "boundary", "terms", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L590-L640
train
loli/medpy
medpy/metric/image.py
__range
def __range(a, bins): '''Compute the histogram range of the values in the array a according to scipy.stats.histogram.''' a = numpy.asarray(a) a_max = a.max() a_min = a.min() s = 0.5 * (a_max - a_min) / float(bins - 1) return (a_min - s, a_max + s)
python
def __range(a, bins): '''Compute the histogram range of the values in the array a according to scipy.stats.histogram.''' a = numpy.asarray(a) a_max = a.max() a_min = a.min() s = 0.5 * (a_max - a_min) / float(bins - 1) return (a_min - s, a_max + s)
[ "def", "__range", "(", "a", ",", "bins", ")", ":", "a", "=", "numpy", ".", "asarray", "(", "a", ")", "a_max", "=", "a", ".", "max", "(", ")", "a_min", "=", "a", ".", "min", "(", ")", "s", "=", "0.5", "*", "(", "a_max", "-", "a_min", ")", ...
Compute the histogram range of the values in the array a according to scipy.stats.histogram.
[ "Compute", "the", "histogram", "range", "of", "the", "values", "in", "the", "array", "a", "according", "to", "scipy", ".", "stats", ".", "histogram", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/image.py#L103-L110
train
loli/medpy
medpy/features/intensity.py
centerdistance
def centerdistance(image, voxelspacing = None, mask = slice(None)): r""" Takes a simple or multi-spectral image and returns its voxel-wise center distance in mm. A multi-spectral image must be supplied as a list or tuple of its spectra. Optionally a binary mask can be supplied to select the voxels ...
python
def centerdistance(image, voxelspacing = None, mask = slice(None)): r""" Takes a simple or multi-spectral image and returns its voxel-wise center distance in mm. A multi-spectral image must be supplied as a list or tuple of its spectra. Optionally a binary mask can be supplied to select the voxels ...
[ "def", "centerdistance", "(", "image", ",", "voxelspacing", "=", "None", ",", "mask", "=", "slice", "(", "None", ")", ")", ":", "r", "if", "type", "(", "image", ")", "==", "tuple", "or", "type", "(", "image", ")", "==", "list", ":", "image", "=", ...
r""" Takes a simple or multi-spectral image and returns its voxel-wise center distance in mm. A multi-spectral image must be supplied as a list or tuple of its spectra. Optionally a binary mask can be supplied to select the voxels for which the feature should be extracted. The center dista...
[ "r", "Takes", "a", "simple", "or", "multi", "-", "spectral", "image", "and", "returns", "its", "voxel", "-", "wise", "center", "distance", "in", "mm", ".", "A", "multi", "-", "spectral", "image", "must", "be", "supplied", "as", "a", "list", "or", "tupl...
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L59-L96
train
loli/medpy
medpy/features/intensity.py
mask_distance
def mask_distance(image, voxelspacing = None, mask = slice(None)): r""" Computes the distance of each point under the mask to the mask border taking the voxel-spacing into account. Note that this feature is independent of the actual image content, but depends solely the mask image. Therefore al...
python
def mask_distance(image, voxelspacing = None, mask = slice(None)): r""" Computes the distance of each point under the mask to the mask border taking the voxel-spacing into account. Note that this feature is independent of the actual image content, but depends solely the mask image. Therefore al...
[ "def", "mask_distance", "(", "image", ",", "voxelspacing", "=", "None", ",", "mask", "=", "slice", "(", "None", ")", ")", ":", "r", "if", "type", "(", "image", ")", "==", "tuple", "or", "type", "(", "image", ")", "==", "list", ":", "image", "=", ...
r""" Computes the distance of each point under the mask to the mask border taking the voxel-spacing into account. Note that this feature is independent of the actual image content, but depends solely the mask image. Therefore always a one-dimensional feature is returned, even if a multi-spectra...
[ "r", "Computes", "the", "distance", "of", "each", "point", "under", "the", "mask", "to", "the", "mask", "border", "taking", "the", "voxel", "-", "spacing", "into", "account", ".", "Note", "that", "this", "feature", "is", "independent", "of", "the", "actual...
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L246-L275
train
loli/medpy
medpy/features/intensity.py
_extract_hemispheric_difference
def _extract_hemispheric_difference(image, mask = slice(None), sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None): """ Internal, single-image version of `hemispheric_difference`. """ # constants INTERPOLATION_RANGE = int(10) # how many neighbouring values to take into account...
python
def _extract_hemispheric_difference(image, mask = slice(None), sigma_active = 7, sigma_reference = 7, cut_plane = 0, voxelspacing = None): """ Internal, single-image version of `hemispheric_difference`. """ # constants INTERPOLATION_RANGE = int(10) # how many neighbouring values to take into account...
[ "def", "_extract_hemispheric_difference", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "sigma_active", "=", "7", ",", "sigma_reference", "=", "7", ",", "cut_plane", "=", "0", ",", "voxelspacing", "=", "None", ")", ":", "INTERPOLATION_RANGE...
Internal, single-image version of `hemispheric_difference`.
[ "Internal", "single", "-", "image", "version", "of", "hemispheric_difference", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L522-L585
train
loli/medpy
medpy/features/intensity.py
_extract_local_histogram
def _extract_local_histogram(image, mask=slice(None), bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0): """ Internal, single-image version of @see local_histogram Note: Values outside of the histograms range are not considered. Note: Mode...
python
def _extract_local_histogram(image, mask=slice(None), bins=19, rang="image", cutoffp=(0.0, 100.0), size=None, footprint=None, output=None, mode="ignore", origin=0): """ Internal, single-image version of @see local_histogram Note: Values outside of the histograms range are not considered. Note: Mode...
[ "def", "_extract_local_histogram", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "bins", "=", "19", ",", "rang", "=", "\"image\"", ",", "cutoffp", "=", "(", "0.0", ",", "100.0", ")", ",", "size", "=", "None", ",", "footprint", "=", ...
Internal, single-image version of @see local_histogram Note: Values outside of the histograms range are not considered. Note: Mode constant is not available, instead a mode "ignore" is provided. Note: Default dtype of returned values is float.
[ "Internal", "single", "-", "image", "version", "of" ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L587-L625
train
loli/medpy
medpy/features/intensity.py
_extract_median
def _extract_median(image, mask = slice(None), size = 1, voxelspacing = None): """ Internal, single-image version of `median`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # determine structure element size in voxel units size = _create_s...
python
def _extract_median(image, mask = slice(None), size = 1, voxelspacing = None): """ Internal, single-image version of `median`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # determine structure element size in voxel units size = _create_s...
[ "def", "_extract_median", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "size", "=", "1", ",", "voxelspacing", "=", "None", ")", ":", "if", "voxelspacing", "is", "None", ":", "voxelspacing", "=", "[", "1.", "]", "*", "image", ".", ...
Internal, single-image version of `median`.
[ "Internal", "single", "-", "image", "version", "of", "median", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L627-L638
train
loli/medpy
medpy/features/intensity.py
_extract_gaussian_gradient_magnitude
def _extract_gaussian_gradient_magnitude(image, mask = slice(None), sigma = 1, voxelspacing = None): """ Internal, single-image version of `gaussian_gradient_magnitude`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # determine gaussian kernel...
python
def _extract_gaussian_gradient_magnitude(image, mask = slice(None), sigma = 1, voxelspacing = None): """ Internal, single-image version of `gaussian_gradient_magnitude`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # determine gaussian kernel...
[ "def", "_extract_gaussian_gradient_magnitude", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "sigma", "=", "1", ",", "voxelspacing", "=", "None", ")", ":", "if", "voxelspacing", "is", "None", ":", "voxelspacing", "=", "[", "1.", "]", "*...
Internal, single-image version of `gaussian_gradient_magnitude`.
[ "Internal", "single", "-", "image", "version", "of", "gaussian_gradient_magnitude", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L640-L651
train
loli/medpy
medpy/features/intensity.py
_extract_shifted_mean_gauss
def _extract_shifted_mean_gauss(image, mask = slice(None), offset = None, sigma = 1, voxelspacing = None): """ Internal, single-image version of `shifted_mean_gauss`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # set offset if offset is None:...
python
def _extract_shifted_mean_gauss(image, mask = slice(None), offset = None, sigma = 1, voxelspacing = None): """ Internal, single-image version of `shifted_mean_gauss`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # set offset if offset is None:...
[ "def", "_extract_shifted_mean_gauss", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "offset", "=", "None", ",", "sigma", "=", "1", ",", "voxelspacing", "=", "None", ")", ":", "if", "voxelspacing", "is", "None", ":", "voxelspacing", "=",...
Internal, single-image version of `shifted_mean_gauss`.
[ "Internal", "single", "-", "image", "version", "of", "shifted_mean_gauss", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L653-L678
train
loli/medpy
medpy/features/intensity.py
_extract_mask_distance
def _extract_mask_distance(image, mask = slice(None), voxelspacing = None): """ Internal, single-image version of `mask_distance`. """ if isinstance(mask, slice): mask = numpy.ones(image.shape, numpy.bool) distance_map = distance_transform_edt(mask, sampling=voxelspacing) retur...
python
def _extract_mask_distance(image, mask = slice(None), voxelspacing = None): """ Internal, single-image version of `mask_distance`. """ if isinstance(mask, slice): mask = numpy.ones(image.shape, numpy.bool) distance_map = distance_transform_edt(mask, sampling=voxelspacing) retur...
[ "def", "_extract_mask_distance", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "voxelspacing", "=", "None", ")", ":", "if", "isinstance", "(", "mask", ",", "slice", ")", ":", "mask", "=", "numpy", ".", "ones", "(", "image", ".", "sh...
Internal, single-image version of `mask_distance`.
[ "Internal", "single", "-", "image", "version", "of", "mask_distance", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L680-L689
train
loli/medpy
medpy/features/intensity.py
_extract_local_mean_gauss
def _extract_local_mean_gauss(image, mask = slice(None), sigma = 1, voxelspacing = None): """ Internal, single-image version of `local_mean_gauss`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # determine gaussian kernel size in voxel units ...
python
def _extract_local_mean_gauss(image, mask = slice(None), sigma = 1, voxelspacing = None): """ Internal, single-image version of `local_mean_gauss`. """ # set voxel spacing if voxelspacing is None: voxelspacing = [1.] * image.ndim # determine gaussian kernel size in voxel units ...
[ "def", "_extract_local_mean_gauss", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "sigma", "=", "1", ",", "voxelspacing", "=", "None", ")", ":", "if", "voxelspacing", "is", "None", ":", "voxelspacing", "=", "[", "1.", "]", "*", "image...
Internal, single-image version of `local_mean_gauss`.
[ "Internal", "single", "-", "image", "version", "of", "local_mean_gauss", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L691-L702
train
loli/medpy
medpy/features/intensity.py
_extract_centerdistance
def _extract_centerdistance(image, mask = slice(None), voxelspacing = None): """ Internal, single-image version of `centerdistance`. """ image = numpy.array(image, copy=False) if None == voxelspacing: voxelspacing = [1.] * image.ndim # get image center and an array holding ...
python
def _extract_centerdistance(image, mask = slice(None), voxelspacing = None): """ Internal, single-image version of `centerdistance`. """ image = numpy.array(image, copy=False) if None == voxelspacing: voxelspacing = [1.] * image.ndim # get image center and an array holding ...
[ "def", "_extract_centerdistance", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ",", "voxelspacing", "=", "None", ")", ":", "image", "=", "numpy", ".", "array", "(", "image", ",", "copy", "=", "False", ")", "if", "None", "==", "voxelspacin...
Internal, single-image version of `centerdistance`.
[ "Internal", "single", "-", "image", "version", "of", "centerdistance", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L705-L724
train
loli/medpy
medpy/features/intensity.py
_extract_intensities
def _extract_intensities(image, mask = slice(None)): """ Internal, single-image version of `intensities`. """ return numpy.array(image, copy=True)[mask].ravel()
python
def _extract_intensities(image, mask = slice(None)): """ Internal, single-image version of `intensities`. """ return numpy.array(image, copy=True)[mask].ravel()
[ "def", "_extract_intensities", "(", "image", ",", "mask", "=", "slice", "(", "None", ")", ")", ":", "return", "numpy", ".", "array", "(", "image", ",", "copy", "=", "True", ")", "[", "mask", "]", ".", "ravel", "(", ")" ]
Internal, single-image version of `intensities`.
[ "Internal", "single", "-", "image", "version", "of", "intensities", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L727-L731
train
loli/medpy
medpy/features/intensity.py
_substract_hemispheres
def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing): """ Helper function for `_extract_hemispheric_difference`. Smoothes both images and then substracts the reference from the active image. """ active_kernel = _create_structure_array(active_sigma, voxel_spacin...
python
def _substract_hemispheres(active, reference, active_sigma, reference_sigma, voxel_spacing): """ Helper function for `_extract_hemispheric_difference`. Smoothes both images and then substracts the reference from the active image. """ active_kernel = _create_structure_array(active_sigma, voxel_spacin...
[ "def", "_substract_hemispheres", "(", "active", ",", "reference", ",", "active_sigma", ",", "reference_sigma", ",", "voxel_spacing", ")", ":", "active_kernel", "=", "_create_structure_array", "(", "active_sigma", ",", "voxel_spacing", ")", "active_smoothed", "=", "gau...
Helper function for `_extract_hemispheric_difference`. Smoothes both images and then substracts the reference from the active image.
[ "Helper", "function", "for", "_extract_hemispheric_difference", ".", "Smoothes", "both", "images", "and", "then", "substracts", "the", "reference", "from", "the", "active", "image", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/features/intensity.py#L733-L744
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._dispatch
def _dispatch(self, tree): "_dispatcher function, _dispatching tree type T to method _T." if isinstance(tree, list): for t in tree: self._dispatch(t) return meth = getattr(self, "_"+tree.__class__.__name__) if tree.__class__.__name__ == 'NoneType' ...
python
def _dispatch(self, tree): "_dispatcher function, _dispatching tree type T to method _T." if isinstance(tree, list): for t in tree: self._dispatch(t) return meth = getattr(self, "_"+tree.__class__.__name__) if tree.__class__.__name__ == 'NoneType' ...
[ "def", "_dispatch", "(", "self", ",", "tree", ")", ":", "\"_dispatcher function, _dispatching tree type T to method _T.\"", "if", "isinstance", "(", "tree", ",", "list", ")", ":", "for", "t", "in", "tree", ":", "self", ".", "_dispatch", "(", "t", ")", "return"...
_dispatcher function, _dispatching tree type T to method _T.
[ "_dispatcher", "function", "_dispatching", "tree", "type", "T", "to", "method", "_T", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L80-L89
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._AssAttr
def _AssAttr(self, t): """ Handle assigning an attribute of an object """ self._dispatch(t.expr) self._write('.'+t.attrname)
python
def _AssAttr(self, t): """ Handle assigning an attribute of an object """ self._dispatch(t.expr) self._write('.'+t.attrname)
[ "def", "_AssAttr", "(", "self", ",", "t", ")", ":", "self", ".", "_dispatch", "(", "t", ".", "expr", ")", "self", ".", "_write", "(", "'.'", "+", "t", ".", "attrname", ")" ]
Handle assigning an attribute of an object
[ "Handle", "assigning", "an", "attribute", "of", "an", "object" ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L110-L114
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._Assign
def _Assign(self, t): """ Expression Assignment such as "a = 1". This only handles assignment in expressions. Keyword assignment is handled separately. """ self._fill() for target in t.nodes: self._dispatch(target) self._write(" = ") ...
python
def _Assign(self, t): """ Expression Assignment such as "a = 1". This only handles assignment in expressions. Keyword assignment is handled separately. """ self._fill() for target in t.nodes: self._dispatch(target) self._write(" = ") ...
[ "def", "_Assign", "(", "self", ",", "t", ")", ":", "self", ".", "_fill", "(", ")", "for", "target", "in", "t", ".", "nodes", ":", "self", ".", "_dispatch", "(", "target", ")", "self", ".", "_write", "(", "\" = \"", ")", "self", ".", "_dispatch", ...
Expression Assignment such as "a = 1". This only handles assignment in expressions. Keyword assignment is handled separately.
[ "Expression", "Assignment", "such", "as", "a", "=", "1", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L116-L128
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._AssTuple
def _AssTuple(self, t): """ Tuple on left hand side of an expression. """ # _write each elements, separated by a comma. for element in t.nodes[:-1]: self._dispatch(element) self._write(", ") # Handle the last one without writing comma last_elemen...
python
def _AssTuple(self, t): """ Tuple on left hand side of an expression. """ # _write each elements, separated by a comma. for element in t.nodes[:-1]: self._dispatch(element) self._write(", ") # Handle the last one without writing comma last_elemen...
[ "def", "_AssTuple", "(", "self", ",", "t", ")", ":", "for", "element", "in", "t", ".", "nodes", "[", ":", "-", "1", "]", ":", "self", ".", "_dispatch", "(", "element", ")", "self", ".", "_write", "(", "\", \"", ")", "last_element", "=", "t", ".",...
Tuple on left hand side of an expression.
[ "Tuple", "on", "left", "hand", "side", "of", "an", "expression", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L137-L148
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._CallFunc
def _CallFunc(self, t): """ Function call. """ self._dispatch(t.node) self._write("(") comma = False for e in t.args: if comma: self._write(", ") else: comma = True self._dispatch(e) if t.star_args: if comma: self._w...
python
def _CallFunc(self, t): """ Function call. """ self._dispatch(t.node) self._write("(") comma = False for e in t.args: if comma: self._write(", ") else: comma = True self._dispatch(e) if t.star_args: if comma: self._w...
[ "def", "_CallFunc", "(", "self", ",", "t", ")", ":", "self", ".", "_dispatch", "(", "t", ".", "node", ")", "self", ".", "_write", "(", "\"(\"", ")", "comma", "=", "False", "for", "e", "in", "t", ".", "args", ":", "if", "comma", ":", "self", "."...
Function call.
[ "Function", "call", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L183-L203
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._From
def _From(self, t): """ Handle "from xyz import foo, bar as baz". """ # fixme: Are From and ImportFrom handled differently? self._fill("from ") self._write(t.modname) self._write(" import ") for i, (name,asname) in enumerate(t.names): if i != 0: ...
python
def _From(self, t): """ Handle "from xyz import foo, bar as baz". """ # fixme: Are From and ImportFrom handled differently? self._fill("from ") self._write(t.modname) self._write(" import ") for i, (name,asname) in enumerate(t.names): if i != 0: ...
[ "def", "_From", "(", "self", ",", "t", ")", ":", "self", ".", "_fill", "(", "\"from \"", ")", "self", ".", "_write", "(", "t", ".", "modname", ")", "self", ".", "_write", "(", "\" import \"", ")", "for", "i", ",", "(", "name", ",", "asname", ")",...
Handle "from xyz import foo, bar as baz".
[ "Handle", "from", "xyz", "import", "foo", "bar", "as", "baz", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L244-L256
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._Function
def _Function(self, t): """ Handle function definitions """ if t.decorators is not None: self._fill("@") self._dispatch(t.decorators) self._fill("def "+t.name + "(") defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults) for i, ...
python
def _Function(self, t): """ Handle function definitions """ if t.decorators is not None: self._fill("@") self._dispatch(t.decorators) self._fill("def "+t.name + "(") defaults = [None] * (len(t.argnames) - len(t.defaults)) + list(t.defaults) for i, ...
[ "def", "_Function", "(", "self", ",", "t", ")", ":", "if", "t", ".", "decorators", "is", "not", "None", ":", "self", ".", "_fill", "(", "\"@\"", ")", "self", ".", "_dispatch", "(", "t", ".", "decorators", ")", "self", ".", "_fill", "(", "\"def \"",...
Handle function definitions
[ "Handle", "function", "definitions" ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L258-L279
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._Getattr
def _Getattr(self, t): """ Handle getting an attribute of an object """ if isinstance(t.expr, (Div, Mul, Sub, Add)): self._write('(') self._dispatch(t.expr) self._write(')') else: self._dispatch(t.expr) self._write('.'+...
python
def _Getattr(self, t): """ Handle getting an attribute of an object """ if isinstance(t.expr, (Div, Mul, Sub, Add)): self._write('(') self._dispatch(t.expr) self._write(')') else: self._dispatch(t.expr) self._write('.'+...
[ "def", "_Getattr", "(", "self", ",", "t", ")", ":", "if", "isinstance", "(", "t", ".", "expr", ",", "(", "Div", ",", "Mul", ",", "Sub", ",", "Add", ")", ")", ":", "self", ".", "_write", "(", "'('", ")", "self", ".", "_dispatch", "(", "t", "."...
Handle getting an attribute of an object
[ "Handle", "getting", "an", "attribute", "of", "an", "object" ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L281-L291
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._Import
def _Import(self, t): """ Handle "import xyz.foo". """ self._fill("import ") for i, (name,asname) in enumerate(t.names): if i != 0: self._write(", ") self._write(name) if asname is not None: self._write(" as "+a...
python
def _Import(self, t): """ Handle "import xyz.foo". """ self._fill("import ") for i, (name,asname) in enumerate(t.names): if i != 0: self._write(", ") self._write(name) if asname is not None: self._write(" as "+a...
[ "def", "_Import", "(", "self", ",", "t", ")", ":", "self", ".", "_fill", "(", "\"import \"", ")", "for", "i", ",", "(", "name", ",", "asname", ")", "in", "enumerate", "(", "t", ".", "names", ")", ":", "if", "i", "!=", "0", ":", "self", ".", "...
Handle "import xyz.foo".
[ "Handle", "import", "xyz", ".", "foo", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L326-L336
train
loli/medpy
doc/numpydoc/numpydoc/compiler_unparse.py
UnparseCompilerAst._Keyword
def _Keyword(self, t): """ Keyword value assignment within function calls and definitions. """ self._write(t.name) self._write("=") self._dispatch(t.expr)
python
def _Keyword(self, t): """ Keyword value assignment within function calls and definitions. """ self._write(t.name) self._write("=") self._dispatch(t.expr)
[ "def", "_Keyword", "(", "self", ",", "t", ")", ":", "self", ".", "_write", "(", "t", ".", "name", ")", "self", ".", "_write", "(", "\"=\"", ")", "self", ".", "_dispatch", "(", "t", ".", "expr", ")" ]
Keyword value assignment within function calls and definitions.
[ "Keyword", "value", "assignment", "within", "function", "calls", "and", "definitions", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/compiler_unparse.py#L338-L343
train
loli/medpy
medpy/utilities/argparseu.py
__sequenceAscendingStrict
def __sequenceAscendingStrict(l): "Test a sequences values to be in strictly ascending order." it = iter(l) next(it) if not all(b > a for a, b in zip(l, it)): raise argparse.ArgumentTypeError('All values must be given in strictly ascending order.') return l
python
def __sequenceAscendingStrict(l): "Test a sequences values to be in strictly ascending order." it = iter(l) next(it) if not all(b > a for a, b in zip(l, it)): raise argparse.ArgumentTypeError('All values must be given in strictly ascending order.') return l
[ "def", "__sequenceAscendingStrict", "(", "l", ")", ":", "\"Test a sequences values to be in strictly ascending order.\"", "it", "=", "iter", "(", "l", ")", "next", "(", "it", ")", "if", "not", "all", "(", "b", ">", "a", "for", "a", ",", "b", "in", "zip", "...
Test a sequences values to be in strictly ascending order.
[ "Test", "a", "sequences", "values", "to", "be", "in", "strictly", "ascending", "order", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/utilities/argparseu.py#L238-L244
train
loli/medpy
medpy/filter/IntensityRangeStandardization.py
IntensityRangeStandardization.__check_mapping
def __check_mapping(self, landmarks): """ Checks whether the image, from which the supplied landmarks were extracted, can be transformed to the learned standard intensity space without loss of information. """ sc_udiff = numpy.asarray(self.__sc_umaxs)[1:] - numpy.asarray(...
python
def __check_mapping(self, landmarks): """ Checks whether the image, from which the supplied landmarks were extracted, can be transformed to the learned standard intensity space without loss of information. """ sc_udiff = numpy.asarray(self.__sc_umaxs)[1:] - numpy.asarray(...
[ "def", "__check_mapping", "(", "self", ",", "landmarks", ")", ":", "sc_udiff", "=", "numpy", ".", "asarray", "(", "self", ".", "__sc_umaxs", ")", "[", "1", ":", "]", "-", "numpy", ".", "asarray", "(", "self", ".", "__sc_umins", ")", "[", ":", "-", ...
Checks whether the image, from which the supplied landmarks were extracted, can be transformed to the learned standard intensity space without loss of information.
[ "Checks", "whether", "the", "image", "from", "which", "the", "supplied", "landmarks", "were", "extracted", "can", "be", "transformed", "to", "the", "learned", "standard", "intensity", "space", "without", "loss", "of", "information", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L459-L467
train
loli/medpy
medpy/filter/IntensityRangeStandardization.py
IntensityRangeStandardization.is_in_interval
def is_in_interval(n, l, r, border = 'included'): """ Checks whether a number is inside the interval l, r. """ if 'included' == border: return (n >= l) and (n <= r) elif 'excluded' == border: return (n > l) and (n < r) else: raise Value...
python
def is_in_interval(n, l, r, border = 'included'): """ Checks whether a number is inside the interval l, r. """ if 'included' == border: return (n >= l) and (n <= r) elif 'excluded' == border: return (n > l) and (n < r) else: raise Value...
[ "def", "is_in_interval", "(", "n", ",", "l", ",", "r", ",", "border", "=", "'included'", ")", ":", "if", "'included'", "==", "border", ":", "return", "(", "n", ">=", "l", ")", "and", "(", "n", "<=", "r", ")", "elif", "'excluded'", "==", "border", ...
Checks whether a number is inside the interval l, r.
[ "Checks", "whether", "a", "number", "is", "inside", "the", "interval", "l", "r", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L497-L506
train
loli/medpy
medpy/filter/IntensityRangeStandardization.py
IntensityRangeStandardization.are_in_interval
def are_in_interval(s, l, r, border = 'included'): """ Checks whether all number in the sequence s lie inside the interval formed by l and r. """ return numpy.all([IntensityRangeStandardization.is_in_interval(x, l, r, border) for x in s])
python
def are_in_interval(s, l, r, border = 'included'): """ Checks whether all number in the sequence s lie inside the interval formed by l and r. """ return numpy.all([IntensityRangeStandardization.is_in_interval(x, l, r, border) for x in s])
[ "def", "are_in_interval", "(", "s", ",", "l", ",", "r", ",", "border", "=", "'included'", ")", ":", "return", "numpy", ".", "all", "(", "[", "IntensityRangeStandardization", ".", "is_in_interval", "(", "x", ",", "l", ",", "r", ",", "border", ")", "for"...
Checks whether all number in the sequence s lie inside the interval formed by l and r.
[ "Checks", "whether", "all", "number", "in", "the", "sequence", "s", "lie", "inside", "the", "interval", "formed", "by", "l", "and", "r", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/IntensityRangeStandardization.py#L509-L514
train
loli/medpy
medpy/filter/houghtransform.py
template_sphere
def template_sphere (radius, dimensions): r""" Returns a spherical binary structure of a of the supplied radius that can be used as template input to the generalized hough transform. Parameters ---------- radius : integer The circles radius in voxels. dimensions : integer Th...
python
def template_sphere (radius, dimensions): r""" Returns a spherical binary structure of a of the supplied radius that can be used as template input to the generalized hough transform. Parameters ---------- radius : integer The circles radius in voxels. dimensions : integer Th...
[ "def", "template_sphere", "(", "radius", ",", "dimensions", ")", ":", "r", "if", "int", "(", "dimensions", ")", "!=", "dimensions", ":", "raise", "TypeError", "(", "'The supplied dimension parameter must be of type integer.'", ")", "dimensions", "=", "int", "(", "...
r""" Returns a spherical binary structure of a of the supplied radius that can be used as template input to the generalized hough transform. Parameters ---------- radius : integer The circles radius in voxels. dimensions : integer The dimensionality of the circle Returns ...
[ "r", "Returns", "a", "spherical", "binary", "structure", "of", "a", "of", "the", "supplied", "radius", "that", "can", "be", "used", "as", "template", "input", "to", "the", "generalized", "hough", "transform", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/houghtransform.py#L156-L177
train
loli/medpy
doc/numpydoc/numpydoc/traitsdoc.py
looks_like_issubclass
def looks_like_issubclass(obj, classname): """ Return True if the object has a class or superclass with the given class name. Ignores old-style classes. """ t = obj if t.__name__ == classname: return True for klass in t.__mro__: if klass.__name__ == classname: re...
python
def looks_like_issubclass(obj, classname): """ Return True if the object has a class or superclass with the given class name. Ignores old-style classes. """ t = obj if t.__name__ == classname: return True for klass in t.__mro__: if klass.__name__ == classname: re...
[ "def", "looks_like_issubclass", "(", "obj", ",", "classname", ")", ":", "t", "=", "obj", "if", "t", ".", "__name__", "==", "classname", ":", "return", "True", "for", "klass", "in", "t", ".", "__mro__", ":", "if", "klass", ".", "__name__", "==", "classn...
Return True if the object has a class or superclass with the given class name. Ignores old-style classes.
[ "Return", "True", "if", "the", "object", "has", "a", "class", "or", "superclass", "with", "the", "given", "class", "name", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/doc/numpydoc/numpydoc/traitsdoc.py#L102-L114
train
loli/medpy
medpy/filter/utilities.py
__make_footprint
def __make_footprint(input, size, footprint): "Creates a standard footprint element ala scipy.ndimage." if footprint is None: if size is None: raise RuntimeError("no footprint or filter size provided") sizes = _ni_support._normalize_sequence(size, input.ndim) footprint = nump...
python
def __make_footprint(input, size, footprint): "Creates a standard footprint element ala scipy.ndimage." if footprint is None: if size is None: raise RuntimeError("no footprint or filter size provided") sizes = _ni_support._normalize_sequence(size, input.ndim) footprint = nump...
[ "def", "__make_footprint", "(", "input", ",", "size", ",", "footprint", ")", ":", "\"Creates a standard footprint element ala scipy.ndimage.\"", "if", "footprint", "is", "None", ":", "if", "size", "is", "None", ":", "raise", "RuntimeError", "(", "\"no footprint or fil...
Creates a standard footprint element ala scipy.ndimage.
[ "Creates", "a", "standard", "footprint", "element", "ala", "scipy", ".", "ndimage", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/filter/utilities.py#L246-L255
train
loli/medpy
medpy/graphcut/energy_label.py
__check_label_image
def __check_label_image(label_image): """Check the label image for consistent labelling starting from 1.""" encountered_indices = scipy.unique(label_image) expected_indices = scipy.arange(1, label_image.max() + 1) if not encountered_indices.size == expected_indices.size or \ not (encountered_indi...
python
def __check_label_image(label_image): """Check the label image for consistent labelling starting from 1.""" encountered_indices = scipy.unique(label_image) expected_indices = scipy.arange(1, label_image.max() + 1) if not encountered_indices.size == expected_indices.size or \ not (encountered_indi...
[ "def", "__check_label_image", "(", "label_image", ")", ":", "encountered_indices", "=", "scipy", ".", "unique", "(", "label_image", ")", "expected_indices", "=", "scipy", ".", "arange", "(", "1", ",", "label_image", ".", "max", "(", ")", "+", "1", ")", "if...
Check the label image for consistent labelling starting from 1.
[ "Check", "the", "label", "image", "for", "consistent", "labelling", "starting", "from", "1", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_label.py#L407-L413
train
loli/medpy
bin/medpy_graphcut_label_bgreduced.py
__xd_iterator_pass_on
def __xd_iterator_pass_on(arr, view, fun): """ Like xd_iterator, but the fun return values are always passed on to the next and only the last returned. """ # create list of iterations iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)] # iterate...
python
def __xd_iterator_pass_on(arr, view, fun): """ Like xd_iterator, but the fun return values are always passed on to the next and only the last returned. """ # create list of iterations iterations = [[None] if dim in view else list(range(arr.shape[dim])) for dim in range(arr.ndim)] # iterate...
[ "def", "__xd_iterator_pass_on", "(", "arr", ",", "view", ",", "fun", ")", ":", "iterations", "=", "[", "[", "None", "]", "if", "dim", "in", "view", "else", "list", "(", "range", "(", "arr", ".", "shape", "[", "dim", "]", ")", ")", "for", "dim", "...
Like xd_iterator, but the fun return values are always passed on to the next and only the last returned.
[ "Like", "xd_iterator", "but", "the", "fun", "return", "values", "are", "always", "passed", "on", "to", "the", "next", "and", "only", "the", "last", "returned", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/bin/medpy_graphcut_label_bgreduced.py#L176-L189
train
loli/medpy
medpy/io/header.py
set_pixel_spacing
def set_pixel_spacing(hdr, spacing): r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`.""" warnings.warn('get_pixel_spacing() is depreciated, use set_voxel_spacing() instead', category=DeprecationWarning) set_voxel_spacing(hdr, spacing)
python
def set_pixel_spacing(hdr, spacing): r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`.""" warnings.warn('get_pixel_spacing() is depreciated, use set_voxel_spacing() instead', category=DeprecationWarning) set_voxel_spacing(hdr, spacing)
[ "def", "set_pixel_spacing", "(", "hdr", ",", "spacing", ")", ":", "r", "warnings", ".", "warn", "(", "'get_pixel_spacing() is depreciated, use set_voxel_spacing() instead'", ",", "category", "=", "DeprecationWarning", ")", "set_voxel_spacing", "(", "hdr", ",", "spacing"...
r"""Depreciated synonym of `~medpy.io.header.set_voxel_spacing`.
[ "r", "Depreciated", "synonym", "of", "~medpy", ".", "io", ".", "header", ".", "set_voxel_spacing", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L100-L103
train
loli/medpy
medpy/io/header.py
Header.copy_to
def copy_to(self, sitkimage): """ Copy all stored meta information info to an sitk Image. Note that only the spacing and the offset/origin information are guaranteed to be preserved, although the method also tries to copy other meta information such as DICOM tags. Param...
python
def copy_to(self, sitkimage): """ Copy all stored meta information info to an sitk Image. Note that only the spacing and the offset/origin information are guaranteed to be preserved, although the method also tries to copy other meta information such as DICOM tags. Param...
[ "def", "copy_to", "(", "self", ",", "sitkimage", ")", ":", "if", "self", ".", "sitkimage", "is", "not", "None", ":", "for", "k", "in", "self", ".", "sitkimage", ".", "GetMetaDataKeys", "(", ")", ":", "sitkimage", ".", "SetMetaData", "(", "k", ",", "s...
Copy all stored meta information info to an sitk Image. Note that only the spacing and the offset/origin information are guaranteed to be preserved, although the method also tries to copy other meta information such as DICOM tags. Parameters ---------- sitkimage : sitk....
[ "Copy", "all", "stored", "meta", "information", "info", "to", "an", "sitk", "Image", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L213-L242
train
loli/medpy
medpy/io/header.py
Header.get_info_consistent
def get_info_consistent(self, ndim): """ Returns the main meta-data information adapted to the supplied image dimensionality. It will try to resolve inconsistencies and other conflicts, altering the information avilable int he most plausible way. Parameters ----...
python
def get_info_consistent(self, ndim): """ Returns the main meta-data information adapted to the supplied image dimensionality. It will try to resolve inconsistencies and other conflicts, altering the information avilable int he most plausible way. Parameters ----...
[ "def", "get_info_consistent", "(", "self", ",", "ndim", ")", ":", "if", "ndim", ">", "len", "(", "self", ".", "spacing", ")", ":", "spacing", "=", "self", ".", "spacing", "+", "(", "1.0", ",", ")", "*", "(", "ndim", "-", "len", "(", "self", ".", ...
Returns the main meta-data information adapted to the supplied image dimensionality. It will try to resolve inconsistencies and other conflicts, altering the information avilable int he most plausible way. Parameters ---------- ndim : int image's dimensional...
[ "Returns", "the", "main", "meta", "-", "data", "information", "adapted", "to", "the", "supplied", "image", "dimensionality", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/io/header.py#L244-L279
train
loli/medpy
medpy/metric/binary.py
hd95
def hd95(result, reference, voxelspacing=None, connectivity=1): """ 95th percentile of the Hausdorff Distance. Computes the 95th percentile of the (symmetric) Hausdorff Distance (HD) between the binary objects in two images. Compared to the Hausdorff Distance, this metric is slightly more stable to sma...
python
def hd95(result, reference, voxelspacing=None, connectivity=1): """ 95th percentile of the Hausdorff Distance. Computes the 95th percentile of the (symmetric) Hausdorff Distance (HD) between the binary objects in two images. Compared to the Hausdorff Distance, this metric is slightly more stable to sma...
[ "def", "hd95", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "hd1", "=", "__surface_distances", "(", "result", ",", "reference", ",", "voxelspacing", ",", "connectivity", ")", "hd2", "=", "__sur...
95th percentile of the Hausdorff Distance. Computes the 95th percentile of the (symmetric) Hausdorff Distance (HD) between the binary objects in two images. Compared to the Hausdorff Distance, this metric is slightly more stable to small outliers and is commonly used in Biomedical Segmentation challenges. ...
[ "95th", "percentile", "of", "the", "Hausdorff", "Distance", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/binary.py#L354-L399
train
loli/medpy
medpy/metric/binary.py
__surface_distances
def __surface_distances(result, reference, voxelspacing=None, connectivity=1): """ The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference. """ result = numpy.atleast_1d(result.astype(numpy.bool)) reference = num...
python
def __surface_distances(result, reference, voxelspacing=None, connectivity=1): """ The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference. """ result = numpy.atleast_1d(result.astype(numpy.bool)) reference = num...
[ "def", "__surface_distances", "(", "result", ",", "reference", ",", "voxelspacing", "=", "None", ",", "connectivity", "=", "1", ")", ":", "result", "=", "numpy", ".", "atleast_1d", "(", "result", ".", "astype", "(", "numpy", ".", "bool", ")", ")", "refer...
The distances between the surface voxel of binary objects in result and their nearest partner surface voxel of a binary object in reference.
[ "The", "distances", "between", "the", "surface", "voxel", "of", "binary", "objects", "in", "result", "and", "their", "nearest", "partner", "surface", "voxel", "of", "a", "binary", "object", "in", "reference", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/binary.py#L1195-L1227
train
loli/medpy
medpy/metric/histogram.py
__minowski_low_positive_integer_p
def __minowski_low_positive_integer_p(h1, h2, p = 2): # 11..43 us for p = 1..24 \w 100 bins """ A faster implementation of the Minowski distance for positive integer < 25. @note do not use this function directly, but the general @link minowski() method. @note the passed histograms must be scipy arrays. ...
python
def __minowski_low_positive_integer_p(h1, h2, p = 2): # 11..43 us for p = 1..24 \w 100 bins """ A faster implementation of the Minowski distance for positive integer < 25. @note do not use this function directly, but the general @link minowski() method. @note the passed histograms must be scipy arrays. ...
[ "def", "__minowski_low_positive_integer_p", "(", "h1", ",", "h2", ",", "p", "=", "2", ")", ":", "mult", "=", "scipy", ".", "absolute", "(", "h1", "-", "h2", ")", "dif", "=", "mult", "for", "_", "in", "range", "(", "p", "-", "1", ")", ":", "dif", ...
A faster implementation of the Minowski distance for positive integer < 25. @note do not use this function directly, but the general @link minowski() method. @note the passed histograms must be scipy arrays.
[ "A", "faster", "implementation", "of", "the", "Minowski", "distance", "for", "positive", "integer", "<", "25", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L95-L104
train
loli/medpy
medpy/metric/histogram.py
__kullback_leibler
def __kullback_leibler(h1, h2): # 36.3 us """ The actual KL implementation. @see kullback_leibler() for details. Expects the histograms to be of type scipy.ndarray. """ result = h1.astype(scipy.float_) mask = h1 != 0 result[mask] = scipy.multiply(h1[mask], scipy.log(h1[mask] / h2[mask])) ...
python
def __kullback_leibler(h1, h2): # 36.3 us """ The actual KL implementation. @see kullback_leibler() for details. Expects the histograms to be of type scipy.ndarray. """ result = h1.astype(scipy.float_) mask = h1 != 0 result[mask] = scipy.multiply(h1[mask], scipy.log(h1[mask] / h2[mask])) ...
[ "def", "__kullback_leibler", "(", "h1", ",", "h2", ")", ":", "result", "=", "h1", ".", "astype", "(", "scipy", ".", "float_", ")", "mask", "=", "h1", "!=", "0", "result", "[", "mask", "]", "=", "scipy", ".", "multiply", "(", "h1", "[", "mask", "]...
The actual KL implementation. @see kullback_leibler() for details. Expects the histograms to be of type scipy.ndarray.
[ "The", "actual", "KL", "implementation", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L562-L570
train
loli/medpy
medpy/metric/histogram.py
__prepare_histogram
def __prepare_histogram(h1, h2): """Convert the histograms to scipy.ndarrays if required.""" h1 = h1 if scipy.ndarray == type(h1) else scipy.asarray(h1) h2 = h2 if scipy.ndarray == type(h2) else scipy.asarray(h2) if h1.shape != h2.shape or h1.size != h2.size: raise ValueError('h1 and h2 must be ...
python
def __prepare_histogram(h1, h2): """Convert the histograms to scipy.ndarrays if required.""" h1 = h1 if scipy.ndarray == type(h1) else scipy.asarray(h1) h2 = h2 if scipy.ndarray == type(h2) else scipy.asarray(h2) if h1.shape != h2.shape or h1.size != h2.size: raise ValueError('h1 and h2 must be ...
[ "def", "__prepare_histogram", "(", "h1", ",", "h2", ")", ":", "h1", "=", "h1", "if", "scipy", ".", "ndarray", "==", "type", "(", "h1", ")", "else", "scipy", ".", "asarray", "(", "h1", ")", "h2", "=", "h2", "if", "scipy", ".", "ndarray", "==", "ty...
Convert the histograms to scipy.ndarrays if required.
[ "Convert", "the", "histograms", "to", "scipy", ".", "ndarrays", "if", "required", "." ]
95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5
https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/metric/histogram.py#L1246-L1252
train
minrk/findspark
findspark.py
find
def find(): """Find a local spark installation. Will first check the SPARK_HOME env variable, and otherwise search common installation locations, e.g. from homebrew """ spark_home = os.environ.get('SPARK_HOME', None) if not spark_home: for path in [ '/usr/local/opt/apache-s...
python
def find(): """Find a local spark installation. Will first check the SPARK_HOME env variable, and otherwise search common installation locations, e.g. from homebrew """ spark_home = os.environ.get('SPARK_HOME', None) if not spark_home: for path in [ '/usr/local/opt/apache-s...
[ "def", "find", "(", ")", ":", "spark_home", "=", "os", ".", "environ", ".", "get", "(", "'SPARK_HOME'", ",", "None", ")", "if", "not", "spark_home", ":", "for", "path", "in", "[", "'/usr/local/opt/apache-spark/libexec'", ",", "'/usr/lib/spark/'", ",", "'/usr...
Find a local spark installation. Will first check the SPARK_HOME env variable, and otherwise search common installation locations, e.g. from homebrew
[ "Find", "a", "local", "spark", "installation", "." ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L14-L38
train
minrk/findspark
findspark.py
change_rc
def change_rc(spark_home, spark_python, py4j): """Persists changes to environment by changing shell config. Adds lines to .bashrc to set environment variables including the adding of dependencies to the system path. Will only edit this file if they already exist. Currently only works for bash. Par...
python
def change_rc(spark_home, spark_python, py4j): """Persists changes to environment by changing shell config. Adds lines to .bashrc to set environment variables including the adding of dependencies to the system path. Will only edit this file if they already exist. Currently only works for bash. Par...
[ "def", "change_rc", "(", "spark_home", ",", "spark_python", ",", "py4j", ")", ":", "bashrc_location", "=", "os", ".", "path", ".", "expanduser", "(", "\"~/.bashrc\"", ")", "if", "os", ".", "path", ".", "isfile", "(", "bashrc_location", ")", ":", "with", ...
Persists changes to environment by changing shell config. Adds lines to .bashrc to set environment variables including the adding of dependencies to the system path. Will only edit this file if they already exist. Currently only works for bash. Parameters ---------- spark_home : str Pa...
[ "Persists", "changes", "to", "environment", "by", "changing", "shell", "config", "." ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L41-L65
train
minrk/findspark
findspark.py
edit_ipython_profile
def edit_ipython_profile(spark_home, spark_python, py4j): """Adds a startup file to the current IPython profile to import pyspark. The startup file sets the required environment variables and imports pyspark. Parameters ---------- spark_home : str Path to Spark installation. spark_pyth...
python
def edit_ipython_profile(spark_home, spark_python, py4j): """Adds a startup file to the current IPython profile to import pyspark. The startup file sets the required environment variables and imports pyspark. Parameters ---------- spark_home : str Path to Spark installation. spark_pyth...
[ "def", "edit_ipython_profile", "(", "spark_home", ",", "spark_python", ",", "py4j", ")", ":", "from", "IPython", "import", "get_ipython", "ip", "=", "get_ipython", "(", ")", "if", "ip", ":", "profile_dir", "=", "ip", ".", "profile_dir", ".", "location", "els...
Adds a startup file to the current IPython profile to import pyspark. The startup file sets the required environment variables and imports pyspark. Parameters ---------- spark_home : str Path to Spark installation. spark_python : str Path to python subdirectory of Spark installatio...
[ "Adds", "a", "startup", "file", "to", "the", "current", "IPython", "profile", "to", "import", "pyspark", "." ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L68-L98
train
minrk/findspark
findspark.py
init
def init(spark_home=None, python_path=None, edit_rc=False, edit_profile=False): """Make pyspark importable. Sets environment variables and adds dependencies to sys.path. If no Spark location is provided, will try to find an installation. Parameters ---------- spark_home : str, optional, defaul...
python
def init(spark_home=None, python_path=None, edit_rc=False, edit_profile=False): """Make pyspark importable. Sets environment variables and adds dependencies to sys.path. If no Spark location is provided, will try to find an installation. Parameters ---------- spark_home : str, optional, defaul...
[ "def", "init", "(", "spark_home", "=", "None", ",", "python_path", "=", "None", ",", "edit_rc", "=", "False", ",", "edit_profile", "=", "False", ")", ":", "if", "not", "spark_home", ":", "spark_home", "=", "find", "(", ")", "if", "not", "python_path", ...
Make pyspark importable. Sets environment variables and adds dependencies to sys.path. If no Spark location is provided, will try to find an installation. Parameters ---------- spark_home : str, optional, default = None Path to Spark installation, will try to find automatically if ...
[ "Make", "pyspark", "importable", "." ]
20c945d5136269ca56b1341786c49087faa7c75e
https://github.com/minrk/findspark/blob/20c945d5136269ca56b1341786c49087faa7c75e/findspark.py#L101-L147
train