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
MisterWil/abodepy
abodepy/socketio.py
SocketIO.set_cookie
def set_cookie(self, cookie=None): """Set the Cookie header.""" if cookie: self._cookie = cookie.encode() else: self._cookie = None
python
def set_cookie(self, cookie=None): """Set the Cookie header.""" if cookie: self._cookie = cookie.encode() else: self._cookie = None
[ "def", "set_cookie", "(", "self", ",", "cookie", "=", "None", ")", ":", "if", "cookie", ":", "self", ".", "_cookie", "=", "cookie", ".", "encode", "(", ")", "else", ":", "self", ".", "_cookie", "=", "None" ]
Set the Cookie header.
[ "Set", "the", "Cookie", "header", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/socketio.py#L91-L96
train
MisterWil/abodepy
abodepy/socketio.py
SocketIO.on
def on(self, event_name, callback): """Register callback for a SocketIO event.""" if not event_name: return False _LOGGER.debug("Adding callback for event name: %s", event_name) self._callbacks[event_name].append((callback)) return True
python
def on(self, event_name, callback): """Register callback for a SocketIO event.""" if not event_name: return False _LOGGER.debug("Adding callback for event name: %s", event_name) self._callbacks[event_name].append((callback)) return True
[ "def", "on", "(", "self", ",", "event_name", ",", "callback", ")", ":", "if", "not", "event_name", ":", "return", "False", "_LOGGER", ".", "debug", "(", "\"Adding callback for event name: %s\"", ",", "event_name", ")", "self", ".", "_callbacks", "[", "event_na...
Register callback for a SocketIO event.
[ "Register", "callback", "for", "a", "SocketIO", "event", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/socketio.py#L99-L108
train
MisterWil/abodepy
abodepy/socketio.py
SocketIO.start
def start(self): """Start a thread to handle SocketIO notifications.""" if not self._thread: _LOGGER.info("Starting SocketIO thread...") self._thread = threading.Thread(target=self._run_socketio_thread, name='SocketIOThread') ...
python
def start(self): """Start a thread to handle SocketIO notifications.""" if not self._thread: _LOGGER.info("Starting SocketIO thread...") self._thread = threading.Thread(target=self._run_socketio_thread, name='SocketIOThread') ...
[ "def", "start", "(", "self", ")", ":", "if", "not", "self", ".", "_thread", ":", "_LOGGER", ".", "info", "(", "\"Starting SocketIO thread...\"", ")", "self", ".", "_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_run_socketio_t...
Start a thread to handle SocketIO notifications.
[ "Start", "a", "thread", "to", "handle", "SocketIO", "notifications", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/socketio.py#L110-L118
train
MisterWil/abodepy
abodepy/socketio.py
SocketIO.stop
def stop(self): """Tell the SocketIO thread to terminate.""" if self._thread: _LOGGER.info("Stopping SocketIO thread...") # pylint: disable=W0212 self._running = False if self._exit_event: self._exit_event.set() se...
python
def stop(self): """Tell the SocketIO thread to terminate.""" if self._thread: _LOGGER.info("Stopping SocketIO thread...") # pylint: disable=W0212 self._running = False if self._exit_event: self._exit_event.set() se...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "_thread", ":", "_LOGGER", ".", "info", "(", "\"Stopping SocketIO thread...\"", ")", "self", ".", "_running", "=", "False", "if", "self", ".", "_exit_event", ":", "self", ".", "_exit_event", ".", "...
Tell the SocketIO thread to terminate.
[ "Tell", "the", "SocketIO", "thread", "to", "terminate", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/socketio.py#L120-L131
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController.add_device_callback
def add_device_callback(self, devices, callback): """Register a device callback.""" if not devices: return False if not isinstance(devices, (tuple, list)): devices = [devices] for device in devices: # Device may be a device_id device_id =...
python
def add_device_callback(self, devices, callback): """Register a device callback.""" if not devices: return False if not isinstance(devices, (tuple, list)): devices = [devices] for device in devices: # Device may be a device_id device_id =...
[ "def", "add_device_callback", "(", "self", ",", "devices", ",", "callback", ")", ":", "if", "not", "devices", ":", "return", "False", "if", "not", "isinstance", "(", "devices", ",", "(", "tuple", ",", "list", ")", ")", ":", "devices", "=", "[", "device...
Register a device callback.
[ "Register", "a", "device", "callback", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L49-L74
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController.add_event_callback
def add_event_callback(self, event_groups, callback): """Register callback for a group of timeline events.""" if not event_groups: return False if not isinstance(event_groups, (tuple, list)): event_groups = [event_groups] for event_group in event_groups: ...
python
def add_event_callback(self, event_groups, callback): """Register callback for a group of timeline events.""" if not event_groups: return False if not isinstance(event_groups, (tuple, list)): event_groups = [event_groups] for event_group in event_groups: ...
[ "def", "add_event_callback", "(", "self", ",", "event_groups", ",", "callback", ")", ":", "if", "not", "event_groups", ":", "return", "False", "if", "not", "isinstance", "(", "event_groups", ",", "(", "tuple", ",", "list", ")", ")", ":", "event_groups", "=...
Register callback for a group of timeline events.
[ "Register", "callback", "for", "a", "group", "of", "timeline", "events", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L76-L93
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController.add_timeline_callback
def add_timeline_callback(self, timeline_events, callback): """Register a callback for a specific timeline event.""" if not timeline_events: return False if not isinstance(timeline_events, (tuple, list)): timeline_events = [timeline_events] for timeline_event in...
python
def add_timeline_callback(self, timeline_events, callback): """Register a callback for a specific timeline event.""" if not timeline_events: return False if not isinstance(timeline_events, (tuple, list)): timeline_events = [timeline_events] for timeline_event in...
[ "def", "add_timeline_callback", "(", "self", ",", "timeline_events", ",", "callback", ")", ":", "if", "not", "timeline_events", ":", "return", "False", "if", "not", "isinstance", "(", "timeline_events", ",", "(", "tuple", ",", "list", ")", ")", ":", "timelin...
Register a callback for a specific timeline event.
[ "Register", "a", "callback", "for", "a", "specific", "timeline", "event", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L95-L116
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController._on_socket_started
def _on_socket_started(self): """Socket IO startup callback.""" # pylint: disable=W0212 cookies = self._abode._get_session().cookies.get_dict() cookie_string = "; ".join( [str(x) + "=" + str(y) for x, y in cookies.items()]) self._socketio.set_cookie(cookie_string)
python
def _on_socket_started(self): """Socket IO startup callback.""" # pylint: disable=W0212 cookies = self._abode._get_session().cookies.get_dict() cookie_string = "; ".join( [str(x) + "=" + str(y) for x, y in cookies.items()]) self._socketio.set_cookie(cookie_string)
[ "def", "_on_socket_started", "(", "self", ")", ":", "cookies", "=", "self", ".", "_abode", ".", "_get_session", "(", ")", ".", "cookies", ".", "get_dict", "(", ")", "cookie_string", "=", "\"; \"", ".", "join", "(", "[", "str", "(", "x", ")", "+", "\"...
Socket IO startup callback.
[ "Socket", "IO", "startup", "callback", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L123-L130
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController._on_device_update
def _on_device_update(self, devid): """Device callback from Abode SocketIO server.""" if isinstance(devid, (tuple, list)): devid = devid[0] if devid is None: _LOGGER.warning("Device update with no device id.") return _LOGGER.debug("Device update even...
python
def _on_device_update(self, devid): """Device callback from Abode SocketIO server.""" if isinstance(devid, (tuple, list)): devid = devid[0] if devid is None: _LOGGER.warning("Device update with no device id.") return _LOGGER.debug("Device update even...
[ "def", "_on_device_update", "(", "self", ",", "devid", ")", ":", "if", "isinstance", "(", "devid", ",", "(", "tuple", ",", "list", ")", ")", ":", "devid", "=", "devid", "[", "0", "]", "if", "devid", "is", "None", ":", "_LOGGER", ".", "warning", "("...
Device callback from Abode SocketIO server.
[ "Device", "callback", "from", "Abode", "SocketIO", "server", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L136-L154
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController._on_mode_change
def _on_mode_change(self, mode): """Mode change broadcast from Abode SocketIO server.""" if isinstance(mode, (tuple, list)): mode = mode[0] if mode is None: _LOGGER.warning("Mode change event with no mode.") return if not mode or mode.lower() not in ...
python
def _on_mode_change(self, mode): """Mode change broadcast from Abode SocketIO server.""" if isinstance(mode, (tuple, list)): mode = mode[0] if mode is None: _LOGGER.warning("Mode change event with no mode.") return if not mode or mode.lower() not in ...
[ "def", "_on_mode_change", "(", "self", ",", "mode", ")", ":", "if", "isinstance", "(", "mode", ",", "(", "tuple", ",", "list", ")", ")", ":", "mode", "=", "mode", "[", "0", "]", "if", "mode", "is", "None", ":", "_LOGGER", ".", "warning", "(", "\"...
Mode change broadcast from Abode SocketIO server.
[ "Mode", "change", "broadcast", "from", "Abode", "SocketIO", "server", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L156-L181
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController._on_timeline_update
def _on_timeline_update(self, event): """Timeline update broadcast from Abode SocketIO server.""" if isinstance(event, (tuple, list)): event = event[0] event_type = event.get('event_type') event_code = event.get('event_code') if not event_type or not event_code: ...
python
def _on_timeline_update(self, event): """Timeline update broadcast from Abode SocketIO server.""" if isinstance(event, (tuple, list)): event = event[0] event_type = event.get('event_type') event_code = event.get('event_code') if not event_type or not event_code: ...
[ "def", "_on_timeline_update", "(", "self", ",", "event", ")", ":", "if", "isinstance", "(", "event", ",", "(", "tuple", ",", "list", ")", ")", ":", "event", "=", "event", "[", "0", "]", "event_type", "=", "event", ".", "get", "(", "'event_type'", ")"...
Timeline update broadcast from Abode SocketIO server.
[ "Timeline", "update", "broadcast", "from", "Abode", "SocketIO", "server", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L183-L212
train
MisterWil/abodepy
abodepy/event_controller.py
AbodeEventController._on_automation_update
def _on_automation_update(self, event): """Automation update broadcast from Abode SocketIO server.""" event_group = TIMELINE.AUTOMATION_EDIT_GROUP if isinstance(event, (tuple, list)): event = event[0] for callback in self._event_callbacks.get(event_group, ()): _...
python
def _on_automation_update(self, event): """Automation update broadcast from Abode SocketIO server.""" event_group = TIMELINE.AUTOMATION_EDIT_GROUP if isinstance(event, (tuple, list)): event = event[0] for callback in self._event_callbacks.get(event_group, ()): _...
[ "def", "_on_automation_update", "(", "self", ",", "event", ")", ":", "event_group", "=", "TIMELINE", ".", "AUTOMATION_EDIT_GROUP", "if", "isinstance", "(", "event", ",", "(", "tuple", ",", "list", ")", ")", ":", "event", "=", "event", "[", "0", "]", "for...
Automation update broadcast from Abode SocketIO server.
[ "Automation", "update", "broadcast", "from", "Abode", "SocketIO", "server", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/event_controller.py#L214-L222
train
MisterWil/abodepy
abodepy/__init__.py
Abode.login
def login(self, username=None, password=None): """Explicit Abode login.""" if username is not None: self._cache[CONST.ID] = username if password is not None: self._cache[CONST.PASSWORD] = password if (self._cache[CONST.ID] is None or not isinstanc...
python
def login(self, username=None, password=None): """Explicit Abode login.""" if username is not None: self._cache[CONST.ID] = username if password is not None: self._cache[CONST.PASSWORD] = password if (self._cache[CONST.ID] is None or not isinstanc...
[ "def", "login", "(", "self", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "if", "username", "is", "not", "None", ":", "self", ".", "_cache", "[", "CONST", ".", "ID", "]", "=", "username", "if", "password", "is", "not", "Non...
Explicit Abode login.
[ "Explicit", "Abode", "login", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L107-L151
train
MisterWil/abodepy
abodepy/__init__.py
Abode.logout
def logout(self): """Explicit Abode logout.""" if self._token: header_data = { 'ABODE-API-KEY': self._token } self._session = requests.session() self._token = None self._panel = None self._user = None se...
python
def logout(self): """Explicit Abode logout.""" if self._token: header_data = { 'ABODE-API-KEY': self._token } self._session = requests.session() self._token = None self._panel = None self._user = None se...
[ "def", "logout", "(", "self", ")", ":", "if", "self", ".", "_token", ":", "header_data", "=", "{", "'ABODE-API-KEY'", ":", "self", ".", "_token", "}", "self", ".", "_session", "=", "requests", ".", "session", "(", ")", "self", ".", "_token", "=", "No...
Explicit Abode logout.
[ "Explicit", "Abode", "logout", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L153-L183
train
MisterWil/abodepy
abodepy/__init__.py
Abode.refresh
def refresh(self): """Do a full refresh of all devices and automations.""" self.get_devices(refresh=True) self.get_automations(refresh=True)
python
def refresh(self): """Do a full refresh of all devices and automations.""" self.get_devices(refresh=True) self.get_automations(refresh=True)
[ "def", "refresh", "(", "self", ")", ":", "self", ".", "get_devices", "(", "refresh", "=", "True", ")", "self", ".", "get_automations", "(", "refresh", "=", "True", ")" ]
Do a full refresh of all devices and automations.
[ "Do", "a", "full", "refresh", "of", "all", "devices", "and", "automations", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L185-L188
train
MisterWil/abodepy
abodepy/__init__.py
Abode.get_device
def get_device(self, device_id, refresh=False): """Get a single device.""" if self._devices is None: self.get_devices() refresh = False device = self._devices.get(device_id) if device and refresh: device.refresh() return device
python
def get_device(self, device_id, refresh=False): """Get a single device.""" if self._devices is None: self.get_devices() refresh = False device = self._devices.get(device_id) if device and refresh: device.refresh() return device
[ "def", "get_device", "(", "self", ",", "device_id", ",", "refresh", "=", "False", ")", ":", "if", "self", ".", "_devices", "is", "None", ":", "self", ".", "get_devices", "(", ")", "refresh", "=", "False", "device", "=", "self", ".", "_devices", ".", ...
Get a single device.
[ "Get", "a", "single", "device", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L251-L262
train
MisterWil/abodepy
abodepy/__init__.py
Abode.get_automations
def get_automations(self, refresh=False, generic_type=None): """Get all automations.""" if refresh or self._automations is None: if self._automations is None: # Set up the device libraries self._automations = {} _LOGGER.info("Updating all automati...
python
def get_automations(self, refresh=False, generic_type=None): """Get all automations.""" if refresh or self._automations is None: if self._automations is None: # Set up the device libraries self._automations = {} _LOGGER.info("Updating all automati...
[ "def", "get_automations", "(", "self", ",", "refresh", "=", "False", ",", "generic_type", "=", "None", ")", ":", "if", "refresh", "or", "self", ".", "_automations", "is", "None", ":", "if", "self", ".", "_automations", "is", "None", ":", "self", ".", "...
Get all automations.
[ "Get", "all", "automations", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L264-L300
train
MisterWil/abodepy
abodepy/__init__.py
Abode.get_automation
def get_automation(self, automation_id, refresh=False): """Get a single automation.""" if self._automations is None: self.get_automations() refresh = False automation = self._automations.get(str(automation_id)) if automation and refresh: automation.r...
python
def get_automation(self, automation_id, refresh=False): """Get a single automation.""" if self._automations is None: self.get_automations() refresh = False automation = self._automations.get(str(automation_id)) if automation and refresh: automation.r...
[ "def", "get_automation", "(", "self", ",", "automation_id", ",", "refresh", "=", "False", ")", ":", "if", "self", ".", "_automations", "is", "None", ":", "self", ".", "get_automations", "(", ")", "refresh", "=", "False", "automation", "=", "self", ".", "...
Get a single automation.
[ "Get", "a", "single", "automation", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L302-L313
train
MisterWil/abodepy
abodepy/__init__.py
Abode.get_alarm
def get_alarm(self, area='1', refresh=False): """Shortcut method to get the alarm device.""" if self._devices is None: self.get_devices() refresh = False return self.get_device(CONST.ALARM_DEVICE_ID + area, refresh)
python
def get_alarm(self, area='1', refresh=False): """Shortcut method to get the alarm device.""" if self._devices is None: self.get_devices() refresh = False return self.get_device(CONST.ALARM_DEVICE_ID + area, refresh)
[ "def", "get_alarm", "(", "self", ",", "area", "=", "'1'", ",", "refresh", "=", "False", ")", ":", "if", "self", ".", "_devices", "is", "None", ":", "self", ".", "get_devices", "(", ")", "refresh", "=", "False", "return", "self", ".", "get_device", "(...
Shortcut method to get the alarm device.
[ "Shortcut", "method", "to", "get", "the", "alarm", "device", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L315-L321
train
MisterWil/abodepy
abodepy/__init__.py
Abode.set_default_mode
def set_default_mode(self, default_mode): """Set the default mode when alarms are turned 'on'.""" if default_mode.lower() not in (CONST.MODE_AWAY, CONST.MODE_HOME): raise AbodeException(ERROR.INVALID_DEFAULT_ALARM_MODE) self._default_alarm_mode = default_mode.lower()
python
def set_default_mode(self, default_mode): """Set the default mode when alarms are turned 'on'.""" if default_mode.lower() not in (CONST.MODE_AWAY, CONST.MODE_HOME): raise AbodeException(ERROR.INVALID_DEFAULT_ALARM_MODE) self._default_alarm_mode = default_mode.lower()
[ "def", "set_default_mode", "(", "self", ",", "default_mode", ")", ":", "if", "default_mode", ".", "lower", "(", ")", "not", "in", "(", "CONST", ".", "MODE_AWAY", ",", "CONST", ".", "MODE_HOME", ")", ":", "raise", "AbodeException", "(", "ERROR", ".", "INV...
Set the default mode when alarms are turned 'on'.
[ "Set", "the", "default", "mode", "when", "alarms", "are", "turned", "on", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L323-L328
train
MisterWil/abodepy
abodepy/__init__.py
Abode.set_setting
def set_setting(self, setting, value, area='1', validate_value=True): """Set an abode system setting to a given value.""" setting = setting.lower() if setting not in CONST.ALL_SETTINGS: raise AbodeException(ERROR.INVALID_SETTING, CONST.ALL_SETTINGS) if setting in CONST.PANE...
python
def set_setting(self, setting, value, area='1', validate_value=True): """Set an abode system setting to a given value.""" setting = setting.lower() if setting not in CONST.ALL_SETTINGS: raise AbodeException(ERROR.INVALID_SETTING, CONST.ALL_SETTINGS) if setting in CONST.PANE...
[ "def", "set_setting", "(", "self", ",", "setting", ",", "value", ",", "area", "=", "'1'", ",", "validate_value", "=", "True", ")", ":", "setting", "=", "setting", ".", "lower", "(", ")", "if", "setting", "not", "in", "CONST", ".", "ALL_SETTINGS", ":", ...
Set an abode system setting to a given value.
[ "Set", "an", "abode", "system", "setting", "to", "a", "given", "value", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L330-L350
train
MisterWil/abodepy
abodepy/__init__.py
Abode._panel_settings
def _panel_settings(setting, value, validate_value): """Will validate panel settings and values, returns data packet.""" if validate_value: if (setting == CONST.SETTING_CAMERA_RESOLUTION and value not in CONST.SETTING_ALL_CAMERA_RES): raise AbodeException(...
python
def _panel_settings(setting, value, validate_value): """Will validate panel settings and values, returns data packet.""" if validate_value: if (setting == CONST.SETTING_CAMERA_RESOLUTION and value not in CONST.SETTING_ALL_CAMERA_RES): raise AbodeException(...
[ "def", "_panel_settings", "(", "setting", ",", "value", ",", "validate_value", ")", ":", "if", "validate_value", ":", "if", "(", "setting", "==", "CONST", ".", "SETTING_CAMERA_RESOLUTION", "and", "value", "not", "in", "CONST", ".", "SETTING_ALL_CAMERA_RES", ")",...
Will validate panel settings and values, returns data packet.
[ "Will", "validate", "panel", "settings", "and", "values", "returns", "data", "packet", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L353-L368
train
MisterWil/abodepy
abodepy/__init__.py
Abode._area_settings
def _area_settings(area, setting, value, validate_value): """Will validate area settings and values, returns data packet.""" if validate_value: # Exit delay has some specific limitations apparently if (setting == CONST.SETTING_EXIT_DELAY_AWAY and value not in ...
python
def _area_settings(area, setting, value, validate_value): """Will validate area settings and values, returns data packet.""" if validate_value: # Exit delay has some specific limitations apparently if (setting == CONST.SETTING_EXIT_DELAY_AWAY and value not in ...
[ "def", "_area_settings", "(", "area", ",", "setting", ",", "value", ",", "validate_value", ")", ":", "if", "validate_value", ":", "if", "(", "setting", "==", "CONST", ".", "SETTING_EXIT_DELAY_AWAY", "and", "value", "not", "in", "CONST", ".", "VALID_SETTING_EXI...
Will validate area settings and values, returns data packet.
[ "Will", "validate", "area", "settings", "and", "values", "returns", "data", "packet", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L371-L383
train
MisterWil/abodepy
abodepy/__init__.py
Abode._sound_settings
def _sound_settings(area, setting, value, validate_value): """Will validate sound settings and values, returns data packet.""" if validate_value: if (setting in CONST.VALID_SOUND_SETTINGS and value not in CONST.ALL_SETTING_SOUND): raise AbodeException(ERRO...
python
def _sound_settings(area, setting, value, validate_value): """Will validate sound settings and values, returns data packet.""" if validate_value: if (setting in CONST.VALID_SOUND_SETTINGS and value not in CONST.ALL_SETTING_SOUND): raise AbodeException(ERRO...
[ "def", "_sound_settings", "(", "area", ",", "setting", ",", "value", ",", "validate_value", ")", ":", "if", "validate_value", ":", "if", "(", "setting", "in", "CONST", ".", "VALID_SOUND_SETTINGS", "and", "value", "not", "in", "CONST", ".", "ALL_SETTING_SOUND",...
Will validate sound settings and values, returns data packet.
[ "Will", "validate", "sound", "settings", "and", "values", "returns", "data", "packet", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L386-L402
train
MisterWil/abodepy
abodepy/__init__.py
Abode._siren_settings
def _siren_settings(setting, value, validate_value): """Will validate siren settings and values, returns data packet.""" if validate_value: if value not in CONST.SETTING_DISABLE_ENABLE: raise AbodeException(ERROR.INVALID_SETTING_VALUE, CON...
python
def _siren_settings(setting, value, validate_value): """Will validate siren settings and values, returns data packet.""" if validate_value: if value not in CONST.SETTING_DISABLE_ENABLE: raise AbodeException(ERROR.INVALID_SETTING_VALUE, CON...
[ "def", "_siren_settings", "(", "setting", ",", "value", ",", "validate_value", ")", ":", "if", "validate_value", ":", "if", "value", "not", "in", "CONST", ".", "SETTING_DISABLE_ENABLE", ":", "raise", "AbodeException", "(", "ERROR", ".", "INVALID_SETTING_VALUE", ...
Will validate siren settings and values, returns data packet.
[ "Will", "validate", "siren", "settings", "and", "values", "returns", "data", "packet", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L405-L412
train
MisterWil/abodepy
abodepy/__init__.py
Abode.send_request
def send_request(self, method, url, headers=None, data=None, is_retry=False): """Send requests to Abode.""" if not self._token: self.login() if not headers: headers = {} headers['Authorization'] = 'Bearer ' + self._oauth_token header...
python
def send_request(self, method, url, headers=None, data=None, is_retry=False): """Send requests to Abode.""" if not self._token: self.login() if not headers: headers = {} headers['Authorization'] = 'Bearer ' + self._oauth_token header...
[ "def", "send_request", "(", "self", ",", "method", ",", "url", ",", "headers", "=", "None", ",", "data", "=", "None", ",", "is_retry", "=", "False", ")", ":", "if", "not", "self", ".", "_token", ":", "self", ".", "login", "(", ")", "if", "not", "...
Send requests to Abode.
[ "Send", "requests", "to", "Abode", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L414-L442
train
MisterWil/abodepy
abodepy/__init__.py
Abode._save_cache
def _save_cache(self): """Trigger a cache save.""" if not self._disable_cache: UTILS.save_cache(self._cache, self._cache_path)
python
def _save_cache(self): """Trigger a cache save.""" if not self._disable_cache: UTILS.save_cache(self._cache, self._cache_path)
[ "def", "_save_cache", "(", "self", ")", ":", "if", "not", "self", ".", "_disable_cache", ":", "UTILS", ".", "save_cache", "(", "self", ".", "_cache", ",", "self", ".", "_cache_path", ")" ]
Trigger a cache save.
[ "Trigger", "a", "cache", "save", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/__init__.py#L475-L478
train
MisterWil/abodepy
abodepy/helpers/constants.py
get_generic_type
def get_generic_type(type_tag): """Map type tag to generic type.""" return { # Alarm DEVICE_ALARM: TYPE_ALARM, # Binary Sensors - Connectivity DEVICE_GLASS_BREAK: TYPE_CONNECTIVITY, DEVICE_KEYPAD: TYPE_CONNECTIVITY, DEVICE_REMOTE_CONTROLLER: TYPE_CONNECTIVITY, ...
python
def get_generic_type(type_tag): """Map type tag to generic type.""" return { # Alarm DEVICE_ALARM: TYPE_ALARM, # Binary Sensors - Connectivity DEVICE_GLASS_BREAK: TYPE_CONNECTIVITY, DEVICE_KEYPAD: TYPE_CONNECTIVITY, DEVICE_REMOTE_CONTROLLER: TYPE_CONNECTIVITY, ...
[ "def", "get_generic_type", "(", "type_tag", ")", ":", "return", "{", "DEVICE_ALARM", ":", "TYPE_ALARM", ",", "DEVICE_GLASS_BREAK", ":", "TYPE_CONNECTIVITY", ",", "DEVICE_KEYPAD", ":", "TYPE_CONNECTIVITY", ",", "DEVICE_REMOTE_CONTROLLER", ":", "TYPE_CONNECTIVITY", ",", ...
Map type tag to generic type.
[ "Map", "type", "tag", "to", "generic", "type", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/helpers/constants.py#L228-L280
train
MisterWil/abodepy
abodepy/devices/lock.py
AbodeLock.lock
def lock(self): """Lock the device.""" success = self.set_status(CONST.STATUS_LOCKCLOSED_INT) if success: self._json_state['status'] = CONST.STATUS_LOCKCLOSED return success
python
def lock(self): """Lock the device.""" success = self.set_status(CONST.STATUS_LOCKCLOSED_INT) if success: self._json_state['status'] = CONST.STATUS_LOCKCLOSED return success
[ "def", "lock", "(", "self", ")", ":", "success", "=", "self", ".", "set_status", "(", "CONST", ".", "STATUS_LOCKCLOSED_INT", ")", "if", "success", ":", "self", ".", "_json_state", "[", "'status'", "]", "=", "CONST", ".", "STATUS_LOCKCLOSED", "return", "suc...
Lock the device.
[ "Lock", "the", "device", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/lock.py#L10-L17
train
MisterWil/abodepy
abodepy/devices/lock.py
AbodeLock.unlock
def unlock(self): """Unlock the device.""" success = self.set_status(CONST.STATUS_LOCKOPEN_INT) if success: self._json_state['status'] = CONST.STATUS_LOCKOPEN return success
python
def unlock(self): """Unlock the device.""" success = self.set_status(CONST.STATUS_LOCKOPEN_INT) if success: self._json_state['status'] = CONST.STATUS_LOCKOPEN return success
[ "def", "unlock", "(", "self", ")", ":", "success", "=", "self", ".", "set_status", "(", "CONST", ".", "STATUS_LOCKOPEN_INT", ")", "if", "success", ":", "self", ".", "_json_state", "[", "'status'", "]", "=", "CONST", ".", "STATUS_LOCKOPEN", "return", "succe...
Unlock the device.
[ "Unlock", "the", "device", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/lock.py#L19-L26
train
MisterWil/abodepy
abodepy/devices/__init__.py
AbodeDevice.set_status
def set_status(self, status): """Set device status.""" if self._json_state['control_url']: url = CONST.BASE_URL + self._json_state['control_url'] status_data = { 'status': str(status) } response = self._abode.send_request( ...
python
def set_status(self, status): """Set device status.""" if self._json_state['control_url']: url = CONST.BASE_URL + self._json_state['control_url'] status_data = { 'status': str(status) } response = self._abode.send_request( ...
[ "def", "set_status", "(", "self", ",", "status", ")", ":", "if", "self", ".", "_json_state", "[", "'control_url'", "]", ":", "url", "=", "CONST", ".", "BASE_URL", "+", "self", ".", "_json_state", "[", "'control_url'", "]", "status_data", "=", "{", "'stat...
Set device status.
[ "Set", "device", "status", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/__init__.py#L30-L59
train
MisterWil/abodepy
abodepy/devices/__init__.py
AbodeDevice.set_level
def set_level(self, level): """Set device level.""" if self._json_state['control_url']: url = CONST.BASE_URL + self._json_state['control_url'] level_data = { 'level': str(level) } response = self._abode.send_request( "put"...
python
def set_level(self, level): """Set device level.""" if self._json_state['control_url']: url = CONST.BASE_URL + self._json_state['control_url'] level_data = { 'level': str(level) } response = self._abode.send_request( "put"...
[ "def", "set_level", "(", "self", ",", "level", ")", ":", "if", "self", ".", "_json_state", "[", "'control_url'", "]", ":", "url", "=", "CONST", ".", "BASE_URL", "+", "self", ".", "_json_state", "[", "'control_url'", "]", "level_data", "=", "{", "'level'"...
Set device level.
[ "Set", "device", "level", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/__init__.py#L61-L88
train
MisterWil/abodepy
abodepy/devices/__init__.py
AbodeDevice._update_name
def _update_name(self): """Set the device name from _json_state, with a sensible default.""" self._name = self._json_state.get('name') if not self._name: self._name = self.type + ' ' + self.device_id
python
def _update_name(self): """Set the device name from _json_state, with a sensible default.""" self._name = self._json_state.get('name') if not self._name: self._name = self.type + ' ' + self.device_id
[ "def", "_update_name", "(", "self", ")", ":", "self", ".", "_name", "=", "self", ".", "_json_state", ".", "get", "(", "'name'", ")", "if", "not", "self", ".", "_name", ":", "self", ".", "_name", "=", "self", ".", "type", "+", "' '", "+", "self", ...
Set the device name from _json_state, with a sensible default.
[ "Set", "the", "device", "name", "from", "_json_state", "with", "a", "sensible", "default", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/__init__.py#L189-L193
train
MisterWil/abodepy
abodepy/devices/light.py
AbodeLight.set_color_temp
def set_color_temp(self, color_temp): """Set device color.""" if self._json_state['control_url']: url = CONST.INTEGRATIONS_URL + self._device_uuid color_data = { 'action': 'setcolortemperature', 'colorTemperature': int(color_temp) } ...
python
def set_color_temp(self, color_temp): """Set device color.""" if self._json_state['control_url']: url = CONST.INTEGRATIONS_URL + self._device_uuid color_data = { 'action': 'setcolortemperature', 'colorTemperature': int(color_temp) } ...
[ "def", "set_color_temp", "(", "self", ",", "color_temp", ")", ":", "if", "self", ".", "_json_state", "[", "'control_url'", "]", ":", "url", "=", "CONST", ".", "INTEGRATIONS_URL", "+", "self", ".", "_device_uuid", "color_data", "=", "{", "'action'", ":", "'...
Set device color.
[ "Set", "device", "color", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/light.py#L18-L49
train
MisterWil/abodepy
abodepy/devices/light.py
AbodeLight.color
def color(self): """Get light color.""" return (self.get_value(CONST.STATUSES_KEY).get('hue'), self.get_value(CONST.STATUSES_KEY).get('saturation'))
python
def color(self): """Get light color.""" return (self.get_value(CONST.STATUSES_KEY).get('hue'), self.get_value(CONST.STATUSES_KEY).get('saturation'))
[ "def", "color", "(", "self", ")", ":", "return", "(", "self", ".", "get_value", "(", "CONST", ".", "STATUSES_KEY", ")", ".", "get", "(", "'hue'", ")", ",", "self", ".", "get_value", "(", "CONST", ".", "STATUSES_KEY", ")", ".", "get", "(", "'saturatio...
Get light color.
[ "Get", "light", "color", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/light.py#L97-L100
train
MisterWil/abodepy
abodepy/devices/light.py
AbodeLight.has_color
def has_color(self): """Device is using color mode.""" if (self.get_value(CONST.STATUSES_KEY).get('color_mode') == str(CONST.COLOR_MODE_ON)): return True return False
python
def has_color(self): """Device is using color mode.""" if (self.get_value(CONST.STATUSES_KEY).get('color_mode') == str(CONST.COLOR_MODE_ON)): return True return False
[ "def", "has_color", "(", "self", ")", ":", "if", "(", "self", ".", "get_value", "(", "CONST", ".", "STATUSES_KEY", ")", ".", "get", "(", "'color_mode'", ")", "==", "str", "(", "CONST", ".", "COLOR_MODE_ON", ")", ")", ":", "return", "True", "return", ...
Device is using color mode.
[ "Device", "is", "using", "color", "mode", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/light.py#L108-L113
train
MisterWil/abodepy
abodepy/devices/camera.py
AbodeCamera.capture
def capture(self): """Request a new camera image.""" url = str.replace(CONST.CAMS_ID_CAPTURE_URL, '$DEVID$', self.device_id) try: response = self._abode.send_request("put", url) _LOGGER.debug("Capture image response: %s", response.text) ...
python
def capture(self): """Request a new camera image.""" url = str.replace(CONST.CAMS_ID_CAPTURE_URL, '$DEVID$', self.device_id) try: response = self._abode.send_request("put", url) _LOGGER.debug("Capture image response: %s", response.text) ...
[ "def", "capture", "(", "self", ")", ":", "url", "=", "str", ".", "replace", "(", "CONST", ".", "CAMS_ID_CAPTURE_URL", ",", "'$DEVID$'", ",", "self", ".", "device_id", ")", "try", ":", "response", "=", "self", ".", "_abode", ".", "send_request", "(", "\...
Request a new camera image.
[ "Request", "a", "new", "camera", "image", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/camera.py#L24-L38
train
MisterWil/abodepy
abodepy/devices/camera.py
AbodeCamera.refresh_image
def refresh_image(self): """Get the most recent camera image.""" url = str.replace(CONST.TIMELINE_IMAGES_ID_URL, '$DEVID$', self.device_id) response = self._abode.send_request("get", url) _LOGGER.debug("Get image response: %s", response.text) return se...
python
def refresh_image(self): """Get the most recent camera image.""" url = str.replace(CONST.TIMELINE_IMAGES_ID_URL, '$DEVID$', self.device_id) response = self._abode.send_request("get", url) _LOGGER.debug("Get image response: %s", response.text) return se...
[ "def", "refresh_image", "(", "self", ")", ":", "url", "=", "str", ".", "replace", "(", "CONST", ".", "TIMELINE_IMAGES_ID_URL", ",", "'$DEVID$'", ",", "self", ".", "device_id", ")", "response", "=", "self", ".", "_abode", ".", "send_request", "(", "\"get\""...
Get the most recent camera image.
[ "Get", "the", "most", "recent", "camera", "image", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/camera.py#L40-L48
train
MisterWil/abodepy
abodepy/devices/camera.py
AbodeCamera.update_image_location
def update_image_location(self, timeline_json): """Update the image location.""" if not timeline_json: return False # If we get a list of objects back (likely) # then we just want the first one as it should be the "newest" if isinstance(timeline_json, (tuple, list)):...
python
def update_image_location(self, timeline_json): """Update the image location.""" if not timeline_json: return False # If we get a list of objects back (likely) # then we just want the first one as it should be the "newest" if isinstance(timeline_json, (tuple, list)):...
[ "def", "update_image_location", "(", "self", ",", "timeline_json", ")", ":", "if", "not", "timeline_json", ":", "return", "False", "if", "isinstance", "(", "timeline_json", ",", "(", "tuple", ",", "list", ")", ")", ":", "timeline_json", "=", "timeline_json", ...
Update the image location.
[ "Update", "the", "image", "location", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/camera.py#L50-L89
train
MisterWil/abodepy
abodepy/devices/camera.py
AbodeCamera.image_to_file
def image_to_file(self, path, get_image=True): """Write the image to a file.""" if not self.image_url or get_image: if not self.refresh_image(): return False response = requests.get(self.image_url, stream=True) if response.status_code != 200: _LO...
python
def image_to_file(self, path, get_image=True): """Write the image to a file.""" if not self.image_url or get_image: if not self.refresh_image(): return False response = requests.get(self.image_url, stream=True) if response.status_code != 200: _LO...
[ "def", "image_to_file", "(", "self", ",", "path", ",", "get_image", "=", "True", ")", ":", "if", "not", "self", ".", "image_url", "or", "get_image", ":", "if", "not", "self", ".", "refresh_image", "(", ")", ":", "return", "False", "response", "=", "req...
Write the image to a file.
[ "Write", "the", "image", "to", "a", "file", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/camera.py#L91-L108
train
MisterWil/abodepy
abodepy/devices/alarm.py
create_alarm
def create_alarm(panel_json, abode, area='1'): """Create a new alarm device from a panel response.""" panel_json['name'] = CONST.ALARM_NAME panel_json['id'] = CONST.ALARM_DEVICE_ID + area panel_json['type'] = CONST.ALARM_TYPE panel_json['type_tag'] = CONST.DEVICE_ALARM panel_json['generic_type']...
python
def create_alarm(panel_json, abode, area='1'): """Create a new alarm device from a panel response.""" panel_json['name'] = CONST.ALARM_NAME panel_json['id'] = CONST.ALARM_DEVICE_ID + area panel_json['type'] = CONST.ALARM_TYPE panel_json['type_tag'] = CONST.DEVICE_ALARM panel_json['generic_type']...
[ "def", "create_alarm", "(", "panel_json", ",", "abode", ",", "area", "=", "'1'", ")", ":", "panel_json", "[", "'name'", "]", "=", "CONST", ".", "ALARM_NAME", "panel_json", "[", "'id'", "]", "=", "CONST", ".", "ALARM_DEVICE_ID", "+", "area", "panel_json", ...
Create a new alarm device from a panel response.
[ "Create", "a", "new", "alarm", "device", "from", "a", "panel", "response", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/alarm.py#L14-L22
train
MisterWil/abodepy
abodepy/devices/alarm.py
AbodeAlarm.set_mode
def set_mode(self, mode): """Set Abode alarm mode.""" if not mode: raise AbodeException(ERROR.MISSING_ALARM_MODE) elif mode.lower() not in CONST.ALL_MODES: raise AbodeException(ERROR.INVALID_ALARM_MODE, CONST.ALL_MODES) mode = mode.lower() response = sel...
python
def set_mode(self, mode): """Set Abode alarm mode.""" if not mode: raise AbodeException(ERROR.MISSING_ALARM_MODE) elif mode.lower() not in CONST.ALL_MODES: raise AbodeException(ERROR.INVALID_ALARM_MODE, CONST.ALL_MODES) mode = mode.lower() response = sel...
[ "def", "set_mode", "(", "self", ",", "mode", ")", ":", "if", "not", "mode", ":", "raise", "AbodeException", "(", "ERROR", ".", "MISSING_ALARM_MODE", ")", "elif", "mode", ".", "lower", "(", ")", "not", "in", "CONST", ".", "ALL_MODES", ":", "raise", "Abo...
Set Abode alarm mode.
[ "Set", "Abode", "alarm", "mode", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/alarm.py#L33-L60
train
MisterWil/abodepy
abodepy/devices/alarm.py
AbodeAlarm.refresh
def refresh(self, url=CONST.PANEL_URL): """Refresh the alarm device.""" response_object = AbodeDevice.refresh(self, url) # pylint: disable=W0212 self._abode._panel.update(response_object[0]) return response_object
python
def refresh(self, url=CONST.PANEL_URL): """Refresh the alarm device.""" response_object = AbodeDevice.refresh(self, url) # pylint: disable=W0212 self._abode._panel.update(response_object[0]) return response_object
[ "def", "refresh", "(", "self", ",", "url", "=", "CONST", ".", "PANEL_URL", ")", ":", "response_object", "=", "AbodeDevice", ".", "refresh", "(", "self", ",", "url", ")", "self", ".", "_abode", ".", "_panel", ".", "update", "(", "response_object", "[", ...
Refresh the alarm device.
[ "Refresh", "the", "alarm", "device", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/alarm.py#L82-L88
train
MisterWil/abodepy
abodepy/devices/alarm.py
AbodeAlarm.mode
def mode(self): """Get alarm mode.""" mode = self.get_value('mode').get(self.device_id, None) return mode.lower()
python
def mode(self): """Get alarm mode.""" mode = self.get_value('mode').get(self.device_id, None) return mode.lower()
[ "def", "mode", "(", "self", ")", ":", "mode", "=", "self", ".", "get_value", "(", "'mode'", ")", ".", "get", "(", "self", ".", "device_id", ",", "None", ")", "return", "mode", ".", "lower", "(", ")" ]
Get alarm mode.
[ "Get", "alarm", "mode", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/alarm.py#L111-L115
train
MisterWil/abodepy
abodepy/utils.py
update
def update(dct, dct_merge): """Recursively merge dicts.""" for key, value in dct_merge.items(): if key in dct and isinstance(dct[key], dict): dct[key] = update(dct[key], value) else: dct[key] = value return dct
python
def update(dct, dct_merge): """Recursively merge dicts.""" for key, value in dct_merge.items(): if key in dct and isinstance(dct[key], dict): dct[key] = update(dct[key], value) else: dct[key] = value return dct
[ "def", "update", "(", "dct", ",", "dct_merge", ")", ":", "for", "key", ",", "value", "in", "dct_merge", ".", "items", "(", ")", ":", "if", "key", "in", "dct", "and", "isinstance", "(", "dct", "[", "key", "]", ",", "dict", ")", ":", "dct", "[", ...
Recursively merge dicts.
[ "Recursively", "merge", "dicts", "." ]
6f84bb428fd1da98855f55083cd427bebbcc57ae
https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/utils.py#L23-L30
train
Akrog/cinderlib
cinderlib/nos_brick.py
RBDConnector.check_valid_device
def check_valid_device(self, path, run_as_root=True): """Verify an existing RBD handle is connected and valid.""" if self.im_root: try: with open(path, 'r') as f: f.read(4096) except Exception: return False return Tr...
python
def check_valid_device(self, path, run_as_root=True): """Verify an existing RBD handle is connected and valid.""" if self.im_root: try: with open(path, 'r') as f: f.read(4096) except Exception: return False return Tr...
[ "def", "check_valid_device", "(", "self", ",", "path", ",", "run_as_root", "=", "True", ")", ":", "if", "self", ".", "im_root", ":", "try", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "f", ":", "f", ".", "read", "(", "4096", ")", "ex...
Verify an existing RBD handle is connected and valid.
[ "Verify", "an", "existing", "RBD", "handle", "is", "connected", "and", "valid", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/nos_brick.py#L114-L130
train
Akrog/cinderlib
cinderlib/persistence/__init__.py
setup
def setup(config): """Setup persistence to be used in cinderlib. By default memory persistance will be used, but there are other mechanisms available and other ways to use custom mechanisms: - Persistence plugins: Plugin mechanism uses Python entrypoints under namespace cinderlib.persistence.sto...
python
def setup(config): """Setup persistence to be used in cinderlib. By default memory persistance will be used, but there are other mechanisms available and other ways to use custom mechanisms: - Persistence plugins: Plugin mechanism uses Python entrypoints under namespace cinderlib.persistence.sto...
[ "def", "setup", "(", "config", ")", ":", "if", "config", "is", "None", ":", "config", "=", "{", "}", "else", ":", "config", "=", "config", ".", "copy", "(", ")", "volume_cmd", ".", "CONF", ".", "_ConfigOpts__cache", "=", "MyDict", "(", ")", "storage"...
Setup persistence to be used in cinderlib. By default memory persistance will be used, but there are other mechanisms available and other ways to use custom mechanisms: - Persistence plugins: Plugin mechanism uses Python entrypoints under namespace cinderlib.persistence.storage, and cinderlib comes ...
[ "Setup", "persistence", "to", "be", "used", "in", "cinderlib", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/persistence/__init__.py#L43-L85
train
Akrog/cinderlib
cinderlib/cinderlib.py
Backend._transform_legacy_stats
def _transform_legacy_stats(self, stats): """Convert legacy stats to new stats with pools key.""" # Fill pools for legacy driver reports if stats and 'pools' not in stats: pool = stats.copy() pool['pool_name'] = self.id for key in ('driver_version', 'shared_ta...
python
def _transform_legacy_stats(self, stats): """Convert legacy stats to new stats with pools key.""" # Fill pools for legacy driver reports if stats and 'pools' not in stats: pool = stats.copy() pool['pool_name'] = self.id for key in ('driver_version', 'shared_ta...
[ "def", "_transform_legacy_stats", "(", "self", ",", "stats", ")", ":", "if", "stats", "and", "'pools'", "not", "in", "stats", ":", "pool", "=", "stats", ".", "copy", "(", ")", "pool", "[", "'pool_name'", "]", "=", "self", ".", "id", "for", "key", "in...
Convert legacy stats to new stats with pools key.
[ "Convert", "legacy", "stats", "to", "new", "stats", "with", "pools", "key", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/cinderlib.py#L130-L141
train
Akrog/cinderlib
cinderlib/cinderlib.py
Backend._config_parse
def _config_parse(self): """Replacer oslo_config.cfg.ConfigParser.parse for in-memory cfg.""" res = super(cfg.ConfigParser, self).parse(Backend._config_string_io) return res
python
def _config_parse(self): """Replacer oslo_config.cfg.ConfigParser.parse for in-memory cfg.""" res = super(cfg.ConfigParser, self).parse(Backend._config_string_io) return res
[ "def", "_config_parse", "(", "self", ")", ":", "res", "=", "super", "(", "cfg", ".", "ConfigParser", ",", "self", ")", ".", "parse", "(", "Backend", ".", "_config_string_io", ")", "return", "res" ]
Replacer oslo_config.cfg.ConfigParser.parse for in-memory cfg.
[ "Replacer", "oslo_config", ".", "cfg", ".", "ConfigParser", ".", "parse", "for", "in", "-", "memory", "cfg", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/cinderlib.py#L196-L199
train
Akrog/cinderlib
cinderlib/cinderlib.py
Backend._update_cinder_config
def _update_cinder_config(cls): """Parse in-memory file to update OSLO configuration used by Cinder.""" cls._config_string_io.seek(0) cls._parser.write(cls._config_string_io) # Check if we have any multiopt cls._config_string_io.seek(0) current_cfg = cls._config_string_i...
python
def _update_cinder_config(cls): """Parse in-memory file to update OSLO configuration used by Cinder.""" cls._config_string_io.seek(0) cls._parser.write(cls._config_string_io) # Check if we have any multiopt cls._config_string_io.seek(0) current_cfg = cls._config_string_i...
[ "def", "_update_cinder_config", "(", "cls", ")", ":", "cls", ".", "_config_string_io", ".", "seek", "(", "0", ")", "cls", ".", "_parser", ".", "write", "(", "cls", ".", "_config_string_io", ")", "cls", ".", "_config_string_io", ".", "seek", "(", "0", ")"...
Parse in-memory file to update OSLO configuration used by Cinder.
[ "Parse", "in", "-", "memory", "file", "to", "update", "OSLO", "configuration", "used", "by", "Cinder", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/cinderlib.py#L202-L215
train
Akrog/cinderlib
cinderlib/cinderlib.py
Backend._set_cinder_config
def _set_cinder_config(cls, host, locks_path, cinder_config_params): """Setup the parser with all the known Cinder configuration.""" cfg.CONF.set_default('state_path', os.getcwd()) cfg.CONF.set_default('lock_path', '$state_path', 'oslo_concurrency') cls._parser = six.moves.configparser....
python
def _set_cinder_config(cls, host, locks_path, cinder_config_params): """Setup the parser with all the known Cinder configuration.""" cfg.CONF.set_default('state_path', os.getcwd()) cfg.CONF.set_default('lock_path', '$state_path', 'oslo_concurrency') cls._parser = six.moves.configparser....
[ "def", "_set_cinder_config", "(", "cls", ",", "host", ",", "locks_path", ",", "cinder_config_params", ")", ":", "cfg", ".", "CONF", ".", "set_default", "(", "'state_path'", ",", "os", ".", "getcwd", "(", ")", ")", "cfg", ".", "CONF", ".", "set_default", ...
Setup the parser with all the known Cinder configuration.
[ "Setup", "the", "parser", "with", "all", "the", "known", "Cinder", "configuration", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/cinderlib.py#L218-L251
train
Akrog/cinderlib
cinderlib/cinderlib.py
Backend.list_supported_drivers
def list_supported_drivers(): """Returns dictionary with driver classes names as keys.""" def convert_oslo_config(oslo_options): options = [] for opt in oslo_options: tmp_dict = {k: str(v) for k, v in vars(opt).items() if not k.startsw...
python
def list_supported_drivers(): """Returns dictionary with driver classes names as keys.""" def convert_oslo_config(oslo_options): options = [] for opt in oslo_options: tmp_dict = {k: str(v) for k, v in vars(opt).items() if not k.startsw...
[ "def", "list_supported_drivers", "(", ")", ":", "def", "convert_oslo_config", "(", "oslo_options", ")", ":", "options", "=", "[", "]", "for", "opt", "in", "oslo_options", ":", "tmp_dict", "=", "{", "k", ":", "str", "(", "v", ")", "for", "k", ",", "v", ...
Returns dictionary with driver classes names as keys.
[ "Returns", "dictionary", "with", "driver", "classes", "names", "as", "keys", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/cinderlib.py#L393-L428
train
Akrog/cinderlib
cinderlib/serialization.py
load
def load(json_src, save=False): """Load any json serialized cinderlib object.""" if isinstance(json_src, six.string_types): json_src = json_lib.loads(json_src) if isinstance(json_src, list): return [getattr(objects, obj['class']).load(obj, save) for obj in json_src] ret...
python
def load(json_src, save=False): """Load any json serialized cinderlib object.""" if isinstance(json_src, six.string_types): json_src = json_lib.loads(json_src) if isinstance(json_src, list): return [getattr(objects, obj['class']).load(obj, save) for obj in json_src] ret...
[ "def", "load", "(", "json_src", ",", "save", "=", "False", ")", ":", "if", "isinstance", "(", "json_src", ",", "six", ".", "string_types", ")", ":", "json_src", "=", "json_lib", ".", "loads", "(", "json_src", ")", "if", "isinstance", "(", "json_src", "...
Load any json serialized cinderlib object.
[ "Load", "any", "json", "serialized", "cinderlib", "object", "." ]
6481cd9a34744f80bdba130fe9089f1b8b7cb327
https://github.com/Akrog/cinderlib/blob/6481cd9a34744f80bdba130fe9089f1b8b7cb327/cinderlib/serialization.py#L157-L166
train
zblz/naima
naima/model_utils.py
memoize
def memoize(func): """ Cache decorator for functions inside model classes """ def model(cls, energy, *args, **kwargs): try: memoize = cls._memoize cache = cls._cache queue = cls._queue except AttributeError: memoize = False if memoize: ...
python
def memoize(func): """ Cache decorator for functions inside model classes """ def model(cls, energy, *args, **kwargs): try: memoize = cls._memoize cache = cls._cache queue = cls._queue except AttributeError: memoize = False if memoize: ...
[ "def", "memoize", "(", "func", ")", ":", "def", "model", "(", "cls", ",", "energy", ",", "*", "args", ",", "**", "kwargs", ")", ":", "try", ":", "memoize", "=", "cls", ".", "_memoize", "cache", "=", "cls", ".", "_cache", "queue", "=", "cls", ".",...
Cache decorator for functions inside model classes
[ "Cache", "decorator", "for", "functions", "inside", "model", "classes" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/model_utils.py#L15-L84
train
zblz/naima
examples/RXJ1713_SynIC.py
lnprior
def lnprior(pars): """ Return probability of parameter values according to prior knowledge. Parameter limits should be done here through uniform prior ditributions """ # Limit norm and B to be positive logprob = ( naima.uniform_prior(pars[0], 0.0, np.inf) + naima.uniform_prior(pa...
python
def lnprior(pars): """ Return probability of parameter values according to prior knowledge. Parameter limits should be done here through uniform prior ditributions """ # Limit norm and B to be positive logprob = ( naima.uniform_prior(pars[0], 0.0, np.inf) + naima.uniform_prior(pa...
[ "def", "lnprior", "(", "pars", ")", ":", "logprob", "=", "(", "naima", ".", "uniform_prior", "(", "pars", "[", "0", "]", ",", "0.0", ",", "np", ".", "inf", ")", "+", "naima", ".", "uniform_prior", "(", "pars", "[", "1", "]", ",", "-", "1", ",",...
Return probability of parameter values according to prior knowledge. Parameter limits should be done here through uniform prior ditributions
[ "Return", "probability", "of", "parameter", "values", "according", "to", "prior", "knowledge", ".", "Parameter", "limits", "should", "be", "done", "here", "through", "uniform", "prior", "ditributions" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/examples/RXJ1713_SynIC.py#L56-L68
train
zblz/naima
naima/core.py
normal_prior
def normal_prior(value, mean, sigma): """Normal prior distribution. """ return -0.5 * (2 * np.pi * sigma) - (value - mean) ** 2 / (2.0 * sigma)
python
def normal_prior(value, mean, sigma): """Normal prior distribution. """ return -0.5 * (2 * np.pi * sigma) - (value - mean) ** 2 / (2.0 * sigma)
[ "def", "normal_prior", "(", "value", ",", "mean", ",", "sigma", ")", ":", "return", "-", "0.5", "*", "(", "2", "*", "np", ".", "pi", "*", "sigma", ")", "-", "(", "value", "-", "mean", ")", "**", "2", "/", "(", "2.0", "*", "sigma", ")" ]
Normal prior distribution.
[ "Normal", "prior", "distribution", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/core.py#L44-L47
train
zblz/naima
naima/core.py
log_uniform_prior
def log_uniform_prior(value, umin=0, umax=None): """Log-uniform prior distribution. """ if value > 0 and value >= umin: if umax is not None: if value <= umax: return 1 / value else: return -np.inf else: return 1 / value ...
python
def log_uniform_prior(value, umin=0, umax=None): """Log-uniform prior distribution. """ if value > 0 and value >= umin: if umax is not None: if value <= umax: return 1 / value else: return -np.inf else: return 1 / value ...
[ "def", "log_uniform_prior", "(", "value", ",", "umin", "=", "0", ",", "umax", "=", "None", ")", ":", "if", "value", ">", "0", "and", "value", ">=", "umin", ":", "if", "umax", "is", "not", "None", ":", "if", "value", "<=", "umax", ":", "return", "...
Log-uniform prior distribution.
[ "Log", "-", "uniform", "prior", "distribution", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/core.py#L50-L62
train
zblz/naima
naima/core.py
run_sampler
def run_sampler(nrun=100, sampler=None, pos=None, **kwargs): """Run an MCMC sampler. If no sampler or initial position vector is provided, extra ``kwargs`` are passed to `get_sampler` to generate a new sampler. Parameters ---------- nrun : int, optional Number of steps to run sampl...
python
def run_sampler(nrun=100, sampler=None, pos=None, **kwargs): """Run an MCMC sampler. If no sampler or initial position vector is provided, extra ``kwargs`` are passed to `get_sampler` to generate a new sampler. Parameters ---------- nrun : int, optional Number of steps to run sampl...
[ "def", "run_sampler", "(", "nrun", "=", "100", ",", "sampler", "=", "None", ",", "pos", "=", "None", ",", "**", "kwargs", ")", ":", "if", "sampler", "is", "None", "or", "pos", "is", "None", ":", "sampler", ",", "pos", "=", "get_sampler", "(", "**",...
Run an MCMC sampler. If no sampler or initial position vector is provided, extra ``kwargs`` are passed to `get_sampler` to generate a new sampler. Parameters ---------- nrun : int, optional Number of steps to run sampler : :class:`~emcee.EnsembleSampler` instance, optional Samp...
[ "Run", "an", "MCMC", "sampler", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/core.py#L527-L563
train
projecthamster/hamster-lib
hamster_lib/reports.py
XMLWriter._fact_to_tuple
def _fact_to_tuple(self, fact): """ Convert a ``Fact`` to its normalized tuple. This is where all type conversion for ``Fact`` attributes to strings as well as any normalization happens. Note: Because different writers may require different types, we need to ...
python
def _fact_to_tuple(self, fact): """ Convert a ``Fact`` to its normalized tuple. This is where all type conversion for ``Fact`` attributes to strings as well as any normalization happens. Note: Because different writers may require different types, we need to ...
[ "def", "_fact_to_tuple", "(", "self", ",", "fact", ")", ":", "if", "fact", ".", "category", ":", "category", "=", "fact", ".", "category", ".", "name", "else", ":", "category", "=", "''", "description", "=", "fact", ".", "description", "or", "''", "ret...
Convert a ``Fact`` to its normalized tuple. This is where all type conversion for ``Fact`` attributes to strings as well as any normalization happens. Note: Because different writers may require different types, we need to do this individually. Args: ...
[ "Convert", "a", "Fact", "to", "its", "normalized", "tuple", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/reports.py#L294-L326
train
projecthamster/hamster-lib
hamster_lib/reports.py
XMLWriter._write_fact
def _write_fact(self, fact_tuple): """ Create new fact element and populate attributes. Once the child is prepared append it to ``fact_list``. """ fact = self.document.createElement("fact") fact.setAttribute('start', fact_tuple.start) fact.setAttribute('end', fac...
python
def _write_fact(self, fact_tuple): """ Create new fact element and populate attributes. Once the child is prepared append it to ``fact_list``. """ fact = self.document.createElement("fact") fact.setAttribute('start', fact_tuple.start) fact.setAttribute('end', fac...
[ "def", "_write_fact", "(", "self", ",", "fact_tuple", ")", ":", "fact", "=", "self", ".", "document", ".", "createElement", "(", "\"fact\"", ")", "fact", ".", "setAttribute", "(", "'start'", ",", "fact_tuple", ".", "start", ")", "fact", ".", "setAttribute"...
Create new fact element and populate attributes. Once the child is prepared append it to ``fact_list``.
[ "Create", "new", "fact", "element", "and", "populate", "attributes", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/reports.py#L328-L341
train
projecthamster/hamster-lib
hamster_lib/reports.py
XMLWriter._close
def _close(self): """ Append the xml fact list to the main document write file and cleanup. ``toxml`` should take care of encoding everything with UTF-8. """ self.document.appendChild(self.fact_list) self.file.write(self.document.toxml(encoding='utf-8')) return ...
python
def _close(self): """ Append the xml fact list to the main document write file and cleanup. ``toxml`` should take care of encoding everything with UTF-8. """ self.document.appendChild(self.fact_list) self.file.write(self.document.toxml(encoding='utf-8')) return ...
[ "def", "_close", "(", "self", ")", ":", "self", ".", "document", ".", "appendChild", "(", "self", ".", "fact_list", ")", "self", ".", "file", ".", "write", "(", "self", ".", "document", ".", "toxml", "(", "encoding", "=", "'utf-8'", ")", ")", "return...
Append the xml fact list to the main document write file and cleanup. ``toxml`` should take care of encoding everything with UTF-8.
[ "Append", "the", "xml", "fact", "list", "to", "the", "main", "document", "write", "file", "and", "cleanup", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/reports.py#L343-L352
train
LabKey/labkey-api-python
labkey/query.py
execute_sql
def execute_sql(server_context, schema_name, sql, container_path=None, max_rows=None, sort=None, offset=None, container_filter=None, save_in_session=None, parameters=None, required_version=None, ...
python
def execute_sql(server_context, schema_name, sql, container_path=None, max_rows=None, sort=None, offset=None, container_filter=None, save_in_session=None, parameters=None, required_version=None, ...
[ "def", "execute_sql", "(", "server_context", ",", "schema_name", ",", "sql", ",", "container_path", "=", "None", ",", "max_rows", "=", "None", ",", "sort", "=", "None", ",", "offset", "=", "None", ",", "container_filter", "=", "None", ",", "save_in_session",...
Execute sql query against a LabKey server. :param server_context: A LabKey server context. See utils.create_server_context. :param schema_name: schema of table :param sql: String of labkey sql to execute :param container_path: labkey container path if not already set in context :param max_rows: max...
[ "Execute", "sql", "query", "against", "a", "LabKey", "server", "." ]
3c8d393384d7cbb2785f8a7f5fe34007b17a76b8
https://github.com/LabKey/labkey-api-python/blob/3c8d393384d7cbb2785f8a7f5fe34007b17a76b8/labkey/query.py#L87-L143
train
LabKey/labkey-api-python
labkey/query.py
update_rows
def update_rows(server_context, schema_name, query_name, rows, container_path=None, timeout=_default_timeout): """ Update a set of rows :param server_context: A LabKey server context. See utils.create_server_context. :param schema_name: schema of table :param query_name: table name to update :p...
python
def update_rows(server_context, schema_name, query_name, rows, container_path=None, timeout=_default_timeout): """ Update a set of rows :param server_context: A LabKey server context. See utils.create_server_context. :param schema_name: schema of table :param query_name: table name to update :p...
[ "def", "update_rows", "(", "server_context", ",", "schema_name", ",", "query_name", ",", "rows", ",", "container_path", "=", "None", ",", "timeout", "=", "_default_timeout", ")", ":", "url", "=", "server_context", ".", "build_url", "(", "'query'", ",", "'updat...
Update a set of rows :param server_context: A LabKey server context. See utils.create_server_context. :param schema_name: schema of table :param query_name: table name to update :param rows: Set of rows to update :param container_path: labkey container path if not already set in context :param ...
[ "Update", "a", "set", "of", "rows" ]
3c8d393384d7cbb2785f8a7f5fe34007b17a76b8
https://github.com/LabKey/labkey-api-python/blob/3c8d393384d7cbb2785f8a7f5fe34007b17a76b8/labkey/query.py#L265-L286
train
projecthamster/hamster-lib
hamster_lib/helpers/time.py
get_day_end
def get_day_end(config): """ Get the day end time given the day start. This assumes full 24h day. Args: config (dict): Configdict. Needed to extract ``day_start``. Note: This is merely a convinience funtion so we do not have to deduct this from ``day_start`` by hand all the tim...
python
def get_day_end(config): """ Get the day end time given the day start. This assumes full 24h day. Args: config (dict): Configdict. Needed to extract ``day_start``. Note: This is merely a convinience funtion so we do not have to deduct this from ``day_start`` by hand all the tim...
[ "def", "get_day_end", "(", "config", ")", ":", "day_start_datetime", "=", "datetime", ".", "datetime", ".", "combine", "(", "datetime", ".", "date", ".", "today", "(", ")", ",", "config", "[", "'day_start'", "]", ")", "day_end_datetime", "=", "day_start_date...
Get the day end time given the day start. This assumes full 24h day. Args: config (dict): Configdict. Needed to extract ``day_start``. Note: This is merely a convinience funtion so we do not have to deduct this from ``day_start`` by hand all the time.
[ "Get", "the", "day", "end", "time", "given", "the", "day", "start", ".", "This", "assumes", "full", "24h", "day", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/helpers/time.py#L33-L46
train
projecthamster/hamster-lib
hamster_lib/helpers/time.py
end_day_to_datetime
def end_day_to_datetime(end_day, config): """ Convert a given end day to its proper datetime. This is non trivial because of variable ``day_start``. We want to make sure that even if an 'end day' is specified the actual point in time may reach into the following day. Args: end (datetim...
python
def end_day_to_datetime(end_day, config): """ Convert a given end day to its proper datetime. This is non trivial because of variable ``day_start``. We want to make sure that even if an 'end day' is specified the actual point in time may reach into the following day. Args: end (datetim...
[ "def", "end_day_to_datetime", "(", "end_day", ",", "config", ")", ":", "day_start_time", "=", "config", "[", "'day_start'", "]", "day_end_time", "=", "get_day_end", "(", "config", ")", "if", "day_start_time", "==", "datetime", ".", "time", "(", "0", ",", "0"...
Convert a given end day to its proper datetime. This is non trivial because of variable ``day_start``. We want to make sure that even if an 'end day' is specified the actual point in time may reach into the following day. Args: end (datetime.date): Raw end date that is to be adjusted. ...
[ "Convert", "a", "given", "end", "day", "to", "its", "proper", "datetime", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/helpers/time.py#L49-L82
train
projecthamster/hamster-lib
hamster_lib/helpers/time.py
complete_timeframe
def complete_timeframe(timeframe, config, partial=False): """ Apply fallback strategy to incomplete timeframes. Our fallback strategy is as follows: * Missing start-date: Fallback to ``today``. * Missing start-time: Fallback to ``store.config['day_start']``. * Missing end-date: Fall...
python
def complete_timeframe(timeframe, config, partial=False): """ Apply fallback strategy to incomplete timeframes. Our fallback strategy is as follows: * Missing start-date: Fallback to ``today``. * Missing start-time: Fallback to ``store.config['day_start']``. * Missing end-date: Fall...
[ "def", "complete_timeframe", "(", "timeframe", ",", "config", ",", "partial", "=", "False", ")", ":", "def", "complete_start_date", "(", "date", ")", ":", "if", "not", "date", ":", "date", "=", "datetime", ".", "date", ".", "today", "(", ")", "else", "...
Apply fallback strategy to incomplete timeframes. Our fallback strategy is as follows: * Missing start-date: Fallback to ``today``. * Missing start-time: Fallback to ``store.config['day_start']``. * Missing end-date: Fallback to ``today`` for ``day_start='00:00`, ``tomorrow`` othe...
[ "Apply", "fallback", "strategy", "to", "incomplete", "timeframes", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/helpers/time.py#L189-L297
train
projecthamster/hamster-lib
hamster_lib/helpers/time.py
validate_start_end_range
def validate_start_end_range(range_tuple): """ Perform basic sanity checks on a timeframe. Args: range_tuple (tuple): ``(start, end)`` tuple as returned by ``complete_timeframe``. Raises: ValueError: If start > end. Returns: tuple: ``(start, end)`` tuple that p...
python
def validate_start_end_range(range_tuple): """ Perform basic sanity checks on a timeframe. Args: range_tuple (tuple): ``(start, end)`` tuple as returned by ``complete_timeframe``. Raises: ValueError: If start > end. Returns: tuple: ``(start, end)`` tuple that p...
[ "def", "validate_start_end_range", "(", "range_tuple", ")", ":", "start", ",", "end", "=", "range_tuple", "if", "(", "start", "and", "end", ")", "and", "(", "start", ">", "end", ")", ":", "raise", "ValueError", "(", "_", "(", "\"Start after end!\"", ")", ...
Perform basic sanity checks on a timeframe. Args: range_tuple (tuple): ``(start, end)`` tuple as returned by ``complete_timeframe``. Raises: ValueError: If start > end. Returns: tuple: ``(start, end)`` tuple that passed validation. Note: ``timeframes`` may...
[ "Perform", "basic", "sanity", "checks", "on", "a", "timeframe", "." ]
bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f
https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/helpers/time.py#L340-L364
train
zblz/naima
naima/utils.py
validate_data_table
def validate_data_table(data_table, sed=None): """ Validate all columns of a data table. If a list of tables is passed, all tables will be validated and then concatenated Parameters ---------- data_table : `astropy.table.Table` or list of `astropy.table.Table`. sed : bool, optional ...
python
def validate_data_table(data_table, sed=None): """ Validate all columns of a data table. If a list of tables is passed, all tables will be validated and then concatenated Parameters ---------- data_table : `astropy.table.Table` or list of `astropy.table.Table`. sed : bool, optional ...
[ "def", "validate_data_table", "(", "data_table", ",", "sed", "=", "None", ")", ":", "if", "isinstance", "(", "data_table", ",", "Table", ")", "or", "isinstance", "(", "data_table", ",", "QTable", ")", ":", "data_table", "=", "[", "data_table", "]", "try", ...
Validate all columns of a data table. If a list of tables is passed, all tables will be validated and then concatenated Parameters ---------- data_table : `astropy.table.Table` or list of `astropy.table.Table`. sed : bool, optional Whether to convert the fluxes to SED. If unset, all data ...
[ "Validate", "all", "columns", "of", "a", "data", "table", ".", "If", "a", "list", "of", "tables", "is", "passed", "all", "tables", "will", "be", "validated", "and", "then", "concatenated" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L44-L115
train
zblz/naima
naima/utils.py
sed_conversion
def sed_conversion(energy, model_unit, sed): """ Manage conversion between differential spectrum and SED """ model_pt = model_unit.physical_type ones = np.ones(energy.shape) if sed: # SED f_unit = u.Unit("erg/s") if model_pt == "power" or model_pt == "flux" or model_pt...
python
def sed_conversion(energy, model_unit, sed): """ Manage conversion between differential spectrum and SED """ model_pt = model_unit.physical_type ones = np.ones(energy.shape) if sed: # SED f_unit = u.Unit("erg/s") if model_pt == "power" or model_pt == "flux" or model_pt...
[ "def", "sed_conversion", "(", "energy", ",", "model_unit", ",", "sed", ")", ":", "model_pt", "=", "model_unit", ".", "physical_type", "ones", "=", "np", ".", "ones", "(", "energy", ".", "shape", ")", "if", "sed", ":", "f_unit", "=", "u", ".", "Unit", ...
Manage conversion between differential spectrum and SED
[ "Manage", "conversion", "between", "differential", "spectrum", "and", "SED" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L237-L292
train
zblz/naima
naima/utils.py
trapz_loglog
def trapz_loglog(y, x, axis=-1, intervals=False): """ Integrate along the given axis using the composite trapezoidal rule in loglog space. Integrate `y` (`x`) along given axis in loglog space. Parameters ---------- y : array_like Input array to integrate. x : array_like, option...
python
def trapz_loglog(y, x, axis=-1, intervals=False): """ Integrate along the given axis using the composite trapezoidal rule in loglog space. Integrate `y` (`x`) along given axis in loglog space. Parameters ---------- y : array_like Input array to integrate. x : array_like, option...
[ "def", "trapz_loglog", "(", "y", ",", "x", ",", "axis", "=", "-", "1", ",", "intervals", "=", "False", ")", ":", "try", ":", "y_unit", "=", "y", ".", "unit", "y", "=", "y", ".", "value", "except", "AttributeError", ":", "y_unit", "=", "1.0", "try...
Integrate along the given axis using the composite trapezoidal rule in loglog space. Integrate `y` (`x`) along given axis in loglog space. Parameters ---------- y : array_like Input array to integrate. x : array_like, optional Independent variable to integrate over. axis : ...
[ "Integrate", "along", "the", "given", "axis", "using", "the", "composite", "trapezoidal", "rule", "in", "loglog", "space", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L295-L368
train
zblz/naima
naima/utils.py
_generate_energy_edges_single
def _generate_energy_edges_single(ene): """Generate energy edges for single group""" midene = np.sqrt((ene[1:] * ene[:-1])) elo, ehi = np.zeros(len(ene)) * ene.unit, np.zeros(len(ene)) * ene.unit elo[1:] = ene[1:] - midene ehi[:-1] = midene - ene[:-1] elo[0] = ene[0] * (1 - ene[0] / (ene[0] + eh...
python
def _generate_energy_edges_single(ene): """Generate energy edges for single group""" midene = np.sqrt((ene[1:] * ene[:-1])) elo, ehi = np.zeros(len(ene)) * ene.unit, np.zeros(len(ene)) * ene.unit elo[1:] = ene[1:] - midene ehi[:-1] = midene - ene[:-1] elo[0] = ene[0] * (1 - ene[0] / (ene[0] + eh...
[ "def", "_generate_energy_edges_single", "(", "ene", ")", ":", "midene", "=", "np", ".", "sqrt", "(", "(", "ene", "[", "1", ":", "]", "*", "ene", "[", ":", "-", "1", "]", ")", ")", "elo", ",", "ehi", "=", "np", ".", "zeros", "(", "len", "(", "...
Generate energy edges for single group
[ "Generate", "energy", "edges", "for", "single", "group" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L371-L379
train
zblz/naima
naima/utils.py
generate_energy_edges
def generate_energy_edges(ene, groups=None): """Generate energy bin edges from given energy array. Generate an array of energy edges from given energy array to be used as abcissa error bar limits when no energy uncertainty or energy band is provided. Parameters ---------- ene : `astropy.un...
python
def generate_energy_edges(ene, groups=None): """Generate energy bin edges from given energy array. Generate an array of energy edges from given energy array to be used as abcissa error bar limits when no energy uncertainty or energy band is provided. Parameters ---------- ene : `astropy.un...
[ "def", "generate_energy_edges", "(", "ene", ",", "groups", "=", "None", ")", ":", "if", "groups", "is", "None", "or", "len", "(", "ene", ")", "!=", "len", "(", "groups", ")", ":", "return", "_generate_energy_edges_single", "(", "ene", ")", "else", ":", ...
Generate energy bin edges from given energy array. Generate an array of energy edges from given energy array to be used as abcissa error bar limits when no energy uncertainty or energy band is provided. Parameters ---------- ene : `astropy.units.Quantity` array instance 1-D array of en...
[ "Generate", "energy", "bin", "edges", "from", "given", "energy", "array", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L382-L408
train
zblz/naima
naima/utils.py
build_data_table
def build_data_table( energy, flux, flux_error=None, flux_error_lo=None, flux_error_hi=None, energy_width=None, energy_lo=None, energy_hi=None, ul=None, cl=None, ): """ Read data into data dict. Parameters ---------- energy : :class:`~astropy.units.Quantity`...
python
def build_data_table( energy, flux, flux_error=None, flux_error_lo=None, flux_error_hi=None, energy_width=None, energy_lo=None, energy_hi=None, ul=None, cl=None, ): """ Read data into data dict. Parameters ---------- energy : :class:`~astropy.units.Quantity`...
[ "def", "build_data_table", "(", "energy", ",", "flux", ",", "flux_error", "=", "None", ",", "flux_error_lo", "=", "None", ",", "flux_error_hi", "=", "None", ",", "energy_width", "=", "None", ",", "energy_lo", "=", "None", ",", "energy_hi", "=", "None", ","...
Read data into data dict. Parameters ---------- energy : :class:`~astropy.units.Quantity` array instance Observed photon energy array [physical type ``energy``] flux : :class:`~astropy.units.Quantity` array instance Observed flux array [physical type ``flux`` or ``differential flux``]...
[ "Read", "data", "into", "data", "dict", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L411-L492
train
zblz/naima
naima/utils.py
estimate_B
def estimate_B( xray_table, vhe_table, photon_energy_density=0.261 * u.eV / u.cm ** 3 ): """ Estimate magnetic field from synchrotron to Inverse Compton luminosity ratio Estimate the magnetic field from the ratio of X-ray to gamma-ray emission according to: .. math:: \\frac{L_\mathrm{...
python
def estimate_B( xray_table, vhe_table, photon_energy_density=0.261 * u.eV / u.cm ** 3 ): """ Estimate magnetic field from synchrotron to Inverse Compton luminosity ratio Estimate the magnetic field from the ratio of X-ray to gamma-ray emission according to: .. math:: \\frac{L_\mathrm{...
[ "def", "estimate_B", "(", "xray_table", ",", "vhe_table", ",", "photon_energy_density", "=", "0.261", "*", "u", ".", "eV", "/", "u", ".", "cm", "**", "3", ")", ":", "xray", "=", "validate_data_table", "(", "xray_table", ",", "sed", "=", "False", ")", "...
Estimate magnetic field from synchrotron to Inverse Compton luminosity ratio Estimate the magnetic field from the ratio of X-ray to gamma-ray emission according to: .. math:: \\frac{L_\mathrm{xray}}{L_\gamma} = \\frac{u_\mathrm{B}}{u_\mathrm{ph}} = \\frac{B^2}{ 8 \pi u_\mathrm...
[ "Estimate", "magnetic", "field", "from", "synchrotron", "to", "Inverse", "Compton", "luminosity", "ratio" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/utils.py#L495-L555
train
zblz/naima
naima/extern/interruptible_pool.py
_initializer_wrapper
def _initializer_wrapper(actual_initializer, *rest): """ We ignore SIGINT. It's up to our parent to kill us in the typical condition of this arising from ``^C`` on a terminal. If someone is manually killing us with that signal, well... nothing will happen. """ signal.signal(signal.SIGINT, signa...
python
def _initializer_wrapper(actual_initializer, *rest): """ We ignore SIGINT. It's up to our parent to kill us in the typical condition of this arising from ``^C`` on a terminal. If someone is manually killing us with that signal, well... nothing will happen. """ signal.signal(signal.SIGINT, signa...
[ "def", "_initializer_wrapper", "(", "actual_initializer", ",", "*", "rest", ")", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "signal", ".", "SIG_IGN", ")", "if", "actual_initializer", "is", "not", "None", ":", "actual_initializer", "(", ...
We ignore SIGINT. It's up to our parent to kill us in the typical condition of this arising from ``^C`` on a terminal. If someone is manually killing us with that signal, well... nothing will happen.
[ "We", "ignore", "SIGINT", ".", "It", "s", "up", "to", "our", "parent", "to", "kill", "us", "in", "the", "typical", "condition", "of", "this", "arising", "from", "^C", "on", "a", "terminal", ".", "If", "someone", "is", "manually", "killing", "us", "with...
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/extern/interruptible_pool.py#L40-L49
train
zblz/naima
naima/models.py
PowerLaw.eval
def eval(e, amplitude, e_0, alpha): """One dimensional power law model function""" xx = e / e_0 return amplitude * xx ** (-alpha)
python
def eval(e, amplitude, e_0, alpha): """One dimensional power law model function""" xx = e / e_0 return amplitude * xx ** (-alpha)
[ "def", "eval", "(", "e", ",", "amplitude", ",", "e_0", ",", "alpha", ")", ":", "xx", "=", "e", "/", "e_0", "return", "amplitude", "*", "xx", "**", "(", "-", "alpha", ")" ]
One dimensional power law model function
[ "One", "dimensional", "power", "law", "model", "function" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/models.py#L92-L96
train
zblz/naima
naima/models.py
ExponentialCutoffPowerLaw.eval
def eval(e, amplitude, e_0, alpha, e_cutoff, beta): """One dimensional power law with an exponential cutoff model function """ xx = e / e_0 return amplitude * xx ** (-alpha) * np.exp(-(e / e_cutoff) ** beta)
python
def eval(e, amplitude, e_0, alpha, e_cutoff, beta): """One dimensional power law with an exponential cutoff model function """ xx = e / e_0 return amplitude * xx ** (-alpha) * np.exp(-(e / e_cutoff) ** beta)
[ "def", "eval", "(", "e", ",", "amplitude", ",", "e_0", ",", "alpha", ",", "e_cutoff", ",", "beta", ")", ":", "xx", "=", "e", "/", "e_0", "return", "amplitude", "*", "xx", "**", "(", "-", "alpha", ")", "*", "np", ".", "exp", "(", "-", "(", "e"...
One dimensional power law with an exponential cutoff model function
[ "One", "dimensional", "power", "law", "with", "an", "exponential", "cutoff", "model", "function" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/models.py#L161-L166
train
zblz/naima
naima/models.py
LogParabola.eval
def eval(e, amplitude, e_0, alpha, beta): """One dimenional log parabola model function""" ee = e / e_0 eeponent = -alpha - beta * np.log(ee) return amplitude * ee ** eeponent
python
def eval(e, amplitude, e_0, alpha, beta): """One dimenional log parabola model function""" ee = e / e_0 eeponent = -alpha - beta * np.log(ee) return amplitude * ee ** eeponent
[ "def", "eval", "(", "e", ",", "amplitude", ",", "e_0", ",", "alpha", ",", "beta", ")", ":", "ee", "=", "e", "/", "e_0", "eeponent", "=", "-", "alpha", "-", "beta", "*", "np", ".", "log", "(", "ee", ")", "return", "amplitude", "*", "ee", "**", ...
One dimenional log parabola model function
[ "One", "dimenional", "log", "parabola", "model", "function" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/models.py#L410-L415
train
zblz/naima
naima/radiative.py
BaseRadiative.flux
def flux(self, photon_energy, distance=1 * u.kpc): """Differential flux at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float,...
python
def flux(self, photon_energy, distance=1 * u.kpc): """Differential flux at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float,...
[ "def", "flux", "(", "self", ",", "photon_energy", ",", "distance", "=", "1", "*", "u", ".", "kpc", ")", ":", "spec", "=", "self", ".", "_spectrum", "(", "photon_energy", ")", "if", "distance", "!=", "0", ":", "distance", "=", "validate_scalar", "(", ...
Differential flux at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float, optional Distance to the source. If set to 0, the...
[ "Differential", "flux", "at", "a", "given", "distance", "from", "the", "source", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L99-L123
train
zblz/naima
naima/radiative.py
BaseRadiative.sed
def sed(self, photon_energy, distance=1 * u.kpc): """Spectral energy distribution at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quanti...
python
def sed(self, photon_energy, distance=1 * u.kpc): """Spectral energy distribution at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quanti...
[ "def", "sed", "(", "self", ",", "photon_energy", ",", "distance", "=", "1", "*", "u", ".", "kpc", ")", ":", "if", "distance", "!=", "0", ":", "out_unit", "=", "\"erg/(cm2 s)\"", "else", ":", "out_unit", "=", "\"erg/s\"", "photon_energy", "=", "_validate_...
Spectral energy distribution at a given distance from the source. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float, optional Distance to the source. If se...
[ "Spectral", "energy", "distribution", "at", "a", "given", "distance", "from", "the", "source", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L125-L148
train
zblz/naima
naima/radiative.py
BaseElectron._gam
def _gam(self): """ Lorentz factor array """ log10gmin = np.log10(self.Eemin / mec2).value log10gmax = np.log10(self.Eemax / mec2).value return np.logspace( log10gmin, log10gmax, int(self.nEed * (log10gmax - log10gmin)) )
python
def _gam(self): """ Lorentz factor array """ log10gmin = np.log10(self.Eemin / mec2).value log10gmax = np.log10(self.Eemax / mec2).value return np.logspace( log10gmin, log10gmax, int(self.nEed * (log10gmax - log10gmin)) )
[ "def", "_gam", "(", "self", ")", ":", "log10gmin", "=", "np", ".", "log10", "(", "self", ".", "Eemin", "/", "mec2", ")", ".", "value", "log10gmax", "=", "np", ".", "log10", "(", "self", ".", "Eemax", "/", "mec2", ")", ".", "value", "return", "np"...
Lorentz factor array
[ "Lorentz", "factor", "array" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L163-L170
train
zblz/naima
naima/radiative.py
BaseElectron._nelec
def _nelec(self): """ Particles per unit lorentz factor """ pd = self.particle_distribution(self._gam * mec2) return pd.to(1 / mec2_unit).value
python
def _nelec(self): """ Particles per unit lorentz factor """ pd = self.particle_distribution(self._gam * mec2) return pd.to(1 / mec2_unit).value
[ "def", "_nelec", "(", "self", ")", ":", "pd", "=", "self", ".", "particle_distribution", "(", "self", ".", "_gam", "*", "mec2", ")", "return", "pd", ".", "to", "(", "1", "/", "mec2_unit", ")", ".", "value" ]
Particles per unit lorentz factor
[ "Particles", "per", "unit", "lorentz", "factor" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L173-L177
train
zblz/naima
naima/radiative.py
BaseElectron.We
def We(self): """ Total energy in electrons used for the radiative calculation """ We = trapz_loglog(self._gam * self._nelec, self._gam * mec2) return We
python
def We(self): """ Total energy in electrons used for the radiative calculation """ We = trapz_loglog(self._gam * self._nelec, self._gam * mec2) return We
[ "def", "We", "(", "self", ")", ":", "We", "=", "trapz_loglog", "(", "self", ".", "_gam", "*", "self", ".", "_nelec", ",", "self", ".", "_gam", "*", "mec2", ")", "return", "We" ]
Total energy in electrons used for the radiative calculation
[ "Total", "energy", "in", "electrons", "used", "for", "the", "radiative", "calculation" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L180-L184
train
zblz/naima
naima/radiative.py
BaseElectron.compute_We
def compute_We(self, Eemin=None, Eemax=None): """ Total energy in electrons between energies Eemin and Eemax Parameters ---------- Eemin : :class:`~astropy.units.Quantity` float, optional Minimum electron energy for energy content calculation. Eemax : :class:`~astro...
python
def compute_We(self, Eemin=None, Eemax=None): """ Total energy in electrons between energies Eemin and Eemax Parameters ---------- Eemin : :class:`~astropy.units.Quantity` float, optional Minimum electron energy for energy content calculation. Eemax : :class:`~astro...
[ "def", "compute_We", "(", "self", ",", "Eemin", "=", "None", ",", "Eemax", "=", "None", ")", ":", "if", "Eemin", "is", "None", "and", "Eemax", "is", "None", ":", "We", "=", "self", ".", "We", "else", ":", "if", "Eemax", "is", "None", ":", "Eemax"...
Total energy in electrons between energies Eemin and Eemax Parameters ---------- Eemin : :class:`~astropy.units.Quantity` float, optional Minimum electron energy for energy content calculation. Eemax : :class:`~astropy.units.Quantity` float, optional Maximum ele...
[ "Total", "energy", "in", "electrons", "between", "energies", "Eemin", "and", "Eemax" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L186-L215
train
zblz/naima
naima/radiative.py
BaseElectron.set_We
def set_We(self, We, Eemin=None, Eemax=None, amplitude_name=None): """ Normalize particle distribution so that the total energy in electrons between Eemin and Eemax is We Parameters ---------- We : :class:`~astropy.units.Quantity` float Desired energy in electrons. ...
python
def set_We(self, We, Eemin=None, Eemax=None, amplitude_name=None): """ Normalize particle distribution so that the total energy in electrons between Eemin and Eemax is We Parameters ---------- We : :class:`~astropy.units.Quantity` float Desired energy in electrons. ...
[ "def", "set_We", "(", "self", ",", "We", ",", "Eemin", "=", "None", ",", "Eemax", "=", "None", ",", "amplitude_name", "=", "None", ")", ":", "We", "=", "validate_scalar", "(", "\"We\"", ",", "We", ",", "physical_type", "=", "\"energy\"", ")", "oldWe", ...
Normalize particle distribution so that the total energy in electrons between Eemin and Eemax is We Parameters ---------- We : :class:`~astropy.units.Quantity` float Desired energy in electrons. Eemin : :class:`~astropy.units.Quantity` float, optional Mi...
[ "Normalize", "particle", "distribution", "so", "that", "the", "total", "energy", "in", "electrons", "between", "Eemin", "and", "Eemax", "is", "We" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L217-L258
train
zblz/naima
naima/radiative.py
Synchrotron._spectrum
def _spectrum(self, photon_energy): """Compute intrinsic synchrotron differential spectrum for energies in ``photon_energy`` Compute synchrotron for random magnetic field according to approximation of Aharonian, Kelner, and Prosekin 2010, PhysRev D 82, 3002 (`arXiv:1006.1045 <ht...
python
def _spectrum(self, photon_energy): """Compute intrinsic synchrotron differential spectrum for energies in ``photon_energy`` Compute synchrotron for random magnetic field according to approximation of Aharonian, Kelner, and Prosekin 2010, PhysRev D 82, 3002 (`arXiv:1006.1045 <ht...
[ "def", "_spectrum", "(", "self", ",", "photon_energy", ")", ":", "outspecene", "=", "_validate_ene", "(", "photon_energy", ")", "from", "scipy", ".", "special", "import", "cbrt", "def", "Gtilde", "(", "x", ")", ":", "cb", "=", "cbrt", "(", "x", ")", "g...
Compute intrinsic synchrotron differential spectrum for energies in ``photon_energy`` Compute synchrotron for random magnetic field according to approximation of Aharonian, Kelner, and Prosekin 2010, PhysRev D 82, 3002 (`arXiv:1006.1045 <http://arxiv.org/abs/1006.1045>`_). Para...
[ "Compute", "intrinsic", "synchrotron", "differential", "spectrum", "for", "energies", "in", "photon_energy" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L304-L372
train
zblz/naima
naima/radiative.py
InverseCompton._spectrum
def _spectrum(self, photon_energy): """Compute differential IC spectrum for energies in ``photon_energy``. Compute IC spectrum using IC cross-section for isotropic interaction with a blackbody photon spectrum following Khangulyan, Aharonian, and Kelner 2014, ApJ 783, 100 (`arXiv:1310.79...
python
def _spectrum(self, photon_energy): """Compute differential IC spectrum for energies in ``photon_energy``. Compute IC spectrum using IC cross-section for isotropic interaction with a blackbody photon spectrum following Khangulyan, Aharonian, and Kelner 2014, ApJ 783, 100 (`arXiv:1310.79...
[ "def", "_spectrum", "(", "self", ",", "photon_energy", ")", ":", "outspecene", "=", "_validate_ene", "(", "photon_energy", ")", "self", ".", "specic", "=", "[", "]", "for", "seed", "in", "self", ".", "seed_photon_fields", ":", "self", ".", "specic", ".", ...
Compute differential IC spectrum for energies in ``photon_energy``. Compute IC spectrum using IC cross-section for isotropic interaction with a blackbody photon spectrum following Khangulyan, Aharonian, and Kelner 2014, ApJ 783, 100 (`arXiv:1310.7971 <http://www.arxiv.org/abs/1310.7971>...
[ "Compute", "differential", "IC", "spectrum", "for", "energies", "in", "photon_energy", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L743-L766
train
zblz/naima
naima/radiative.py
InverseCompton.flux
def flux(self, photon_energy, distance=1 * u.kpc, seed=None): """Differential flux at a given distance from the source from a single seed photon field Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. ...
python
def flux(self, photon_energy, distance=1 * u.kpc, seed=None): """Differential flux at a given distance from the source from a single seed photon field Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. ...
[ "def", "flux", "(", "self", ",", "photon_energy", ",", "distance", "=", "1", "*", "u", ".", "kpc", ",", "seed", "=", "None", ")", ":", "model", "=", "super", "(", "InverseCompton", ",", "self", ")", ".", "flux", "(", "photon_energy", ",", "distance",...
Differential flux at a given distance from the source from a single seed photon field Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float, optional D...
[ "Differential", "flux", "at", "a", "given", "distance", "from", "the", "source", "from", "a", "single", "seed", "photon", "field" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L768-L819
train
zblz/naima
naima/radiative.py
InverseCompton.sed
def sed(self, photon_energy, distance=1 * u.kpc, seed=None): """Spectral energy distribution at a given distance from the source Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.un...
python
def sed(self, photon_energy, distance=1 * u.kpc, seed=None): """Spectral energy distribution at a given distance from the source Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.un...
[ "def", "sed", "(", "self", ",", "photon_energy", ",", "distance", "=", "1", "*", "u", ".", "kpc", ",", "seed", "=", "None", ")", ":", "sed", "=", "super", "(", "InverseCompton", ",", "self", ")", ".", "sed", "(", "photon_energy", ",", "distance", "...
Spectral energy distribution at a given distance from the source Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` float or array Photon energy array. distance : :class:`~astropy.units.Quantity` float, optional Distance to the source. If set...
[ "Spectral", "energy", "distribution", "at", "a", "given", "distance", "from", "the", "source" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L821-L851
train
zblz/naima
naima/radiative.py
Bremsstrahlung._emiss_ee
def _emiss_ee(self, Eph): """ Electron-electron bremsstrahlung emissivity per unit photon energy """ if self.weight_ee == 0.0: return np.zeros_like(Eph) gam = np.vstack(self._gam) # compute integral with electron distribution emiss = c.cgs * trapz_log...
python
def _emiss_ee(self, Eph): """ Electron-electron bremsstrahlung emissivity per unit photon energy """ if self.weight_ee == 0.0: return np.zeros_like(Eph) gam = np.vstack(self._gam) # compute integral with electron distribution emiss = c.cgs * trapz_log...
[ "def", "_emiss_ee", "(", "self", ",", "Eph", ")", ":", "if", "self", ".", "weight_ee", "==", "0.0", ":", "return", "np", ".", "zeros_like", "(", "Eph", ")", "gam", "=", "np", ".", "vstack", "(", "self", ".", "_gam", ")", "emiss", "=", "c", ".", ...
Electron-electron bremsstrahlung emissivity per unit photon energy
[ "Electron", "-", "electron", "bremsstrahlung", "emissivity", "per", "unit", "photon", "energy" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1002-L1016
train
zblz/naima
naima/radiative.py
Bremsstrahlung._emiss_ep
def _emiss_ep(self, Eph): """ Electron-proton bremsstrahlung emissivity per unit photon energy """ if self.weight_ep == 0.0: return np.zeros_like(Eph) gam = np.vstack(self._gam) eps = (Eph / mec2).decompose().value # compute integral with electron dis...
python
def _emiss_ep(self, Eph): """ Electron-proton bremsstrahlung emissivity per unit photon energy """ if self.weight_ep == 0.0: return np.zeros_like(Eph) gam = np.vstack(self._gam) eps = (Eph / mec2).decompose().value # compute integral with electron dis...
[ "def", "_emiss_ep", "(", "self", ",", "Eph", ")", ":", "if", "self", ".", "weight_ep", "==", "0.0", ":", "return", "np", ".", "zeros_like", "(", "Eph", ")", "gam", "=", "np", ".", "vstack", "(", "self", ".", "_gam", ")", "eps", "=", "(", "Eph", ...
Electron-proton bremsstrahlung emissivity per unit photon energy
[ "Electron", "-", "proton", "bremsstrahlung", "emissivity", "per", "unit", "photon", "energy" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1018-L1033
train
zblz/naima
naima/radiative.py
Bremsstrahlung._spectrum
def _spectrum(self, photon_energy): """Compute differential bremsstrahlung spectrum for energies in ``photon_energy``. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` instance Photon energy array. """ Eph = _validate_ene(photon...
python
def _spectrum(self, photon_energy): """Compute differential bremsstrahlung spectrum for energies in ``photon_energy``. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` instance Photon energy array. """ Eph = _validate_ene(photon...
[ "def", "_spectrum", "(", "self", ",", "photon_energy", ")", ":", "Eph", "=", "_validate_ene", "(", "photon_energy", ")", "spec", "=", "self", ".", "n0", "*", "(", "self", ".", "weight_ee", "*", "self", ".", "_emiss_ee", "(", "Eph", ")", "+", "self", ...
Compute differential bremsstrahlung spectrum for energies in ``photon_energy``. Parameters ---------- photon_energy : :class:`~astropy.units.Quantity` instance Photon energy array.
[ "Compute", "differential", "bremsstrahlung", "spectrum", "for", "energies", "in", "photon_energy", "." ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1035-L1052
train
zblz/naima
naima/radiative.py
BaseProton._Ep
def _Ep(self): """ Proton energy array in GeV """ return np.logspace( np.log10(self.Epmin.to("GeV").value), np.log10(self.Epmax.to("GeV").value), int(self.nEpd * (np.log10(self.Epmax / self.Epmin))), )
python
def _Ep(self): """ Proton energy array in GeV """ return np.logspace( np.log10(self.Epmin.to("GeV").value), np.log10(self.Epmax.to("GeV").value), int(self.nEpd * (np.log10(self.Epmax / self.Epmin))), )
[ "def", "_Ep", "(", "self", ")", ":", "return", "np", ".", "logspace", "(", "np", ".", "log10", "(", "self", ".", "Epmin", ".", "to", "(", "\"GeV\"", ")", ".", "value", ")", ",", "np", ".", "log10", "(", "self", ".", "Epmax", ".", "to", "(", "...
Proton energy array in GeV
[ "Proton", "energy", "array", "in", "GeV" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1067-L1074
train
zblz/naima
naima/radiative.py
BaseProton._J
def _J(self): """ Particles per unit proton energy in particles per GeV """ pd = self.particle_distribution(self._Ep * u.GeV) return pd.to("1/GeV").value
python
def _J(self): """ Particles per unit proton energy in particles per GeV """ pd = self.particle_distribution(self._Ep * u.GeV) return pd.to("1/GeV").value
[ "def", "_J", "(", "self", ")", ":", "pd", "=", "self", ".", "particle_distribution", "(", "self", ".", "_Ep", "*", "u", ".", "GeV", ")", "return", "pd", ".", "to", "(", "\"1/GeV\"", ")", ".", "value" ]
Particles per unit proton energy in particles per GeV
[ "Particles", "per", "unit", "proton", "energy", "in", "particles", "per", "GeV" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1077-L1081
train
zblz/naima
naima/radiative.py
BaseProton.Wp
def Wp(self): """Total energy in protons """ Wp = trapz_loglog(self._Ep * self._J, self._Ep) * u.GeV return Wp.to("erg")
python
def Wp(self): """Total energy in protons """ Wp = trapz_loglog(self._Ep * self._J, self._Ep) * u.GeV return Wp.to("erg")
[ "def", "Wp", "(", "self", ")", ":", "Wp", "=", "trapz_loglog", "(", "self", ".", "_Ep", "*", "self", ".", "_J", ",", "self", ".", "_Ep", ")", "*", "u", ".", "GeV", "return", "Wp", ".", "to", "(", "\"erg\"", ")" ]
Total energy in protons
[ "Total", "energy", "in", "protons" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1084-L1088
train
zblz/naima
naima/radiative.py
BaseProton.compute_Wp
def compute_Wp(self, Epmin=None, Epmax=None): """ Total energy in protons between energies Epmin and Epmax Parameters ---------- Epmin : :class:`~astropy.units.Quantity` float, optional Minimum proton energy for energy content calculation. Epmax : :class:`~astropy.u...
python
def compute_Wp(self, Epmin=None, Epmax=None): """ Total energy in protons between energies Epmin and Epmax Parameters ---------- Epmin : :class:`~astropy.units.Quantity` float, optional Minimum proton energy for energy content calculation. Epmax : :class:`~astropy.u...
[ "def", "compute_Wp", "(", "self", ",", "Epmin", "=", "None", ",", "Epmax", "=", "None", ")", ":", "if", "Epmin", "is", "None", "and", "Epmax", "is", "None", ":", "Wp", "=", "self", ".", "Wp", "else", ":", "if", "Epmax", "is", "None", ":", "Epmax"...
Total energy in protons between energies Epmin and Epmax Parameters ---------- Epmin : :class:`~astropy.units.Quantity` float, optional Minimum proton energy for energy content calculation. Epmax : :class:`~astropy.units.Quantity` float, optional Maximum proton ...
[ "Total", "energy", "in", "protons", "between", "energies", "Epmin", "and", "Epmax" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1090-L1122
train
zblz/naima
naima/radiative.py
BaseProton.set_Wp
def set_Wp(self, Wp, Epmin=None, Epmax=None, amplitude_name=None): """ Normalize particle distribution so that the total energy in protons between Epmin and Epmax is Wp Parameters ---------- Wp : :class:`~astropy.units.Quantity` float Desired energy in protons. ...
python
def set_Wp(self, Wp, Epmin=None, Epmax=None, amplitude_name=None): """ Normalize particle distribution so that the total energy in protons between Epmin and Epmax is Wp Parameters ---------- Wp : :class:`~astropy.units.Quantity` float Desired energy in protons. ...
[ "def", "set_Wp", "(", "self", ",", "Wp", ",", "Epmin", "=", "None", ",", "Epmax", "=", "None", ",", "amplitude_name", "=", "None", ")", ":", "Wp", "=", "validate_scalar", "(", "\"Wp\"", ",", "Wp", ",", "physical_type", "=", "\"energy\"", ")", "oldWp", ...
Normalize particle distribution so that the total energy in protons between Epmin and Epmax is Wp Parameters ---------- Wp : :class:`~astropy.units.Quantity` float Desired energy in protons. Epmin : :class:`~astropy.units.Quantity` float, optional Minimu...
[ "Normalize", "particle", "distribution", "so", "that", "the", "total", "energy", "in", "protons", "between", "Epmin", "and", "Epmax", "is", "Wp" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1124-L1165
train
zblz/naima
naima/radiative.py
PionDecay._sigma_inel
def _sigma_inel(self, Tp): """ Inelastic cross-section for p-p interaction. KATV14 Eq. 1 Parameters ---------- Tp : float Kinetic energy of proton (i.e. Ep - m_p*c**2) [GeV] Returns ------- sigma_inel : float Inelastic cross-secti...
python
def _sigma_inel(self, Tp): """ Inelastic cross-section for p-p interaction. KATV14 Eq. 1 Parameters ---------- Tp : float Kinetic energy of proton (i.e. Ep - m_p*c**2) [GeV] Returns ------- sigma_inel : float Inelastic cross-secti...
[ "def", "_sigma_inel", "(", "self", ",", "Tp", ")", ":", "L", "=", "np", ".", "log", "(", "Tp", "/", "self", ".", "_Tth", ")", "sigma", "=", "30.7", "-", "0.96", "*", "L", "+", "0.18", "*", "L", "**", "2", "sigma", "*=", "(", "1", "-", "(", ...
Inelastic cross-section for p-p interaction. KATV14 Eq. 1 Parameters ---------- Tp : float Kinetic energy of proton (i.e. Ep - m_p*c**2) [GeV] Returns ------- sigma_inel : float Inelastic cross-section for p-p interaction [1/cm2].
[ "Inelastic", "cross", "-", "section", "for", "p", "-", "p", "interaction", ".", "KATV14", "Eq", ".", "1" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1284-L1302
train
zblz/naima
naima/radiative.py
PionDecay._sigma_pi_loE
def _sigma_pi_loE(self, Tp): """ inclusive cross section for Tth < Tp < 2 GeV Fit from experimental data """ m_p = self._m_p m_pi = self._m_pi Mres = 1.1883 # GeV Gres = 0.2264 # GeV s = 2 * m_p * (Tp + 2 * m_p) # center of mass energy g...
python
def _sigma_pi_loE(self, Tp): """ inclusive cross section for Tth < Tp < 2 GeV Fit from experimental data """ m_p = self._m_p m_pi = self._m_pi Mres = 1.1883 # GeV Gres = 0.2264 # GeV s = 2 * m_p * (Tp + 2 * m_p) # center of mass energy g...
[ "def", "_sigma_pi_loE", "(", "self", ",", "Tp", ")", ":", "m_p", "=", "self", ".", "_m_p", "m_pi", "=", "self", ".", "_m_pi", "Mres", "=", "1.1883", "Gres", "=", "0.2264", "s", "=", "2", "*", "m_p", "*", "(", "Tp", "+", "2", "*", "m_p", ")", ...
inclusive cross section for Tth < Tp < 2 GeV Fit from experimental data
[ "inclusive", "cross", "section", "for", "Tth", "<", "Tp", "<", "2", "GeV", "Fit", "from", "experimental", "data" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1304-L1339
train
zblz/naima
naima/radiative.py
PionDecay._sigma_pi_midE
def _sigma_pi_midE(self, Tp): """ Geant 4.10.0 model for 2 GeV < Tp < 5 GeV """ m_p = self._m_p Qp = (Tp - self._Tth) / m_p multip = -6e-3 + 0.237 * Qp - 0.023 * Qp ** 2 return self._sigma_inel(Tp) * multip
python
def _sigma_pi_midE(self, Tp): """ Geant 4.10.0 model for 2 GeV < Tp < 5 GeV """ m_p = self._m_p Qp = (Tp - self._Tth) / m_p multip = -6e-3 + 0.237 * Qp - 0.023 * Qp ** 2 return self._sigma_inel(Tp) * multip
[ "def", "_sigma_pi_midE", "(", "self", ",", "Tp", ")", ":", "m_p", "=", "self", ".", "_m_p", "Qp", "=", "(", "Tp", "-", "self", ".", "_Tth", ")", "/", "m_p", "multip", "=", "-", "6e-3", "+", "0.237", "*", "Qp", "-", "0.023", "*", "Qp", "**", "...
Geant 4.10.0 model for 2 GeV < Tp < 5 GeV
[ "Geant", "4", ".", "10", ".", "0", "model", "for", "2", "GeV", "<", "Tp", "<", "5", "GeV" ]
d6a6781d73bf58fd8269e8b0e3b70be22723cd5b
https://github.com/zblz/naima/blob/d6a6781d73bf58fd8269e8b0e3b70be22723cd5b/naima/radiative.py#L1341-L1348
train