repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
spacetelescope/synphot_refactor
synphot/observation.py
Observation.plot
def plot(self, binned=True, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs): # pragma: no cover """Plot the observation. .. note:: Uses ``matplotlib``. Parameters ---------- binned : bool Plot data in native wavelengths if `False`...
python
def plot(self, binned=True, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs): # pragma: no cover """Plot the observation. .. note:: Uses ``matplotlib``. Parameters ---------- binned : bool Plot data in native wavelengths if `False`...
[ "def", "plot", "(", "self", ",", "binned", "=", "True", ",", "wavelengths", "=", "None", ",", "flux_unit", "=", "None", ",", "area", "=", "None", ",", "vegaspec", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pragma: no cover", "if", "binned", "...
Plot the observation. .. note:: Uses ``matplotlib``. Parameters ---------- binned : bool Plot data in native wavelengths if `False`. Else, plot binned data (default). wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wa...
[ "Plot", "the", "observation", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L616-L656
spacetelescope/synphot_refactor
synphot/observation.py
Observation.as_spectrum
def as_spectrum(self, binned=True, wavelengths=None): """Reduce the observation to an empirical source spectrum. An observation is a complex object with some restrictions on its capabilities. At times, it would be useful to work with the observation as a simple object that is easier to ...
python
def as_spectrum(self, binned=True, wavelengths=None): """Reduce the observation to an empirical source spectrum. An observation is a complex object with some restrictions on its capabilities. At times, it would be useful to work with the observation as a simple object that is easier to ...
[ "def", "as_spectrum", "(", "self", ",", "binned", "=", "True", ",", "wavelengths", "=", "None", ")", ":", "if", "binned", ":", "w", ",", "y", "=", "self", ".", "_get_binned_arrays", "(", "wavelengths", ",", "self", ".", "_internal_flux_unit", ")", "else"...
Reduce the observation to an empirical source spectrum. An observation is a complex object with some restrictions on its capabilities. At times, it would be useful to work with the observation as a simple object that is easier to manipulate and takes up less memory. This is als...
[ "Reduce", "the", "observation", "to", "an", "empirical", "source", "spectrum", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L658-L696
Julius2342/pyvlx
pyvlx/set_node_name.py
SetNodeName.handle_frame
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameSetNodeNameConfirmation): return False self.success = frame.status == SetNodeNameConfirmationStatus.OK return True
python
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameSetNodeNameConfirmation): return False self.success = frame.status == SetNodeNameConfirmationStatus.OK return True
[ "async", "def", "handle_frame", "(", "self", ",", "frame", ")", ":", "if", "not", "isinstance", "(", "frame", ",", "FrameSetNodeNameConfirmation", ")", ":", "return", "False", "self", ".", "success", "=", "frame", ".", "status", "==", "SetNodeNameConfirmationS...
Handle incoming API frame, return True if this was the expected frame.
[ "Handle", "incoming", "API", "frame", "return", "True", "if", "this", "was", "the", "expected", "frame", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_node_name.py#L18-L23
Julius2342/pyvlx
pyvlx/api_event.py
ApiEvent.do_api_call
async def do_api_call(self): """Start. Sending and waiting for answer.""" self.pyvlx.connection.register_frame_received_cb( self.response_rec_callback) await self.send_frame() await self.start_timeout() await self.response_received_or_timeout.wait() await self...
python
async def do_api_call(self): """Start. Sending and waiting for answer.""" self.pyvlx.connection.register_frame_received_cb( self.response_rec_callback) await self.send_frame() await self.start_timeout() await self.response_received_or_timeout.wait() await self...
[ "async", "def", "do_api_call", "(", "self", ")", ":", "self", ".", "pyvlx", ".", "connection", ".", "register_frame_received_cb", "(", "self", ".", "response_rec_callback", ")", "await", "self", ".", "send_frame", "(", ")", "await", "self", ".", "start_timeout...
Start. Sending and waiting for answer.
[ "Start", ".", "Sending", "and", "waiting", "for", "answer", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/api_event.py#L18-L26
Julius2342/pyvlx
pyvlx/api_event.py
ApiEvent.start_timeout
async def start_timeout(self): """Start timeout.""" self.timeout_handle = self.pyvlx.connection.loop.call_later( self.timeout_in_seconds, self.timeout)
python
async def start_timeout(self): """Start timeout.""" self.timeout_handle = self.pyvlx.connection.loop.call_later( self.timeout_in_seconds, self.timeout)
[ "async", "def", "start_timeout", "(", "self", ")", ":", "self", ".", "timeout_handle", "=", "self", ".", "pyvlx", ".", "connection", ".", "loop", ".", "call_later", "(", "self", ".", "timeout_in_seconds", ",", "self", ".", "timeout", ")" ]
Start timeout.
[ "Start", "timeout", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/api_event.py#L49-L52
Julius2342/pyvlx
old_api/examples/example.py
main
async def main(): """Load devices and scenes, run first scene.""" pyvlx = PyVLX('pyvlx.yaml') # Alternative: # pyvlx = PyVLX(host="192.168.2.127", password="velux123", timeout=60) await pyvlx.load_devices() print(pyvlx.devices[1]) print(pyvlx.devices['Fenster 4']) await pyvlx.load_scen...
python
async def main(): """Load devices and scenes, run first scene.""" pyvlx = PyVLX('pyvlx.yaml') # Alternative: # pyvlx = PyVLX(host="192.168.2.127", password="velux123", timeout=60) await pyvlx.load_devices() print(pyvlx.devices[1]) print(pyvlx.devices['Fenster 4']) await pyvlx.load_scen...
[ "async", "def", "main", "(", ")", ":", "pyvlx", "=", "PyVLX", "(", "'pyvlx.yaml'", ")", "# Alternative:", "# pyvlx = PyVLX(host=\"192.168.2.127\", password=\"velux123\", timeout=60)", "await", "pyvlx", ".", "load_devices", "(", ")", "print", "(", "pyvlx", ".", "device...
Load devices and scenes, run first scene.
[ "Load", "devices", "and", "scenes", "run", "first", "scene", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/examples/example.py#L6-L23
Julius2342/pyvlx
pyvlx/on_off_switch.py
OnOffSwitch.set_state
async def set_state(self, parameter): """Set switch to desired state.""" command_send = CommandSend(pyvlx=self.pyvlx, node_id=self.node_id, parameter=parameter) await command_send.do_api_call() if not command_send.success: raise PyVLXException("Unable to send command") ...
python
async def set_state(self, parameter): """Set switch to desired state.""" command_send = CommandSend(pyvlx=self.pyvlx, node_id=self.node_id, parameter=parameter) await command_send.do_api_call() if not command_send.success: raise PyVLXException("Unable to send command") ...
[ "async", "def", "set_state", "(", "self", ",", "parameter", ")", ":", "command_send", "=", "CommandSend", "(", "pyvlx", "=", "self", ".", "pyvlx", ",", "node_id", "=", "self", ".", "node_id", ",", "parameter", "=", "parameter", ")", "await", "command_send"...
Set switch to desired state.
[ "Set", "switch", "to", "desired", "state", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/on_off_switch.py#L16-L23
spacetelescope/synphot_refactor
synphot/reddening.py
etau_madau
def etau_madau(wave, z, **kwargs): """Madau 1995 extinction for a galaxy at given redshift. This is the Lyman-alpha prescription from the photo-z code BPZ. The Lyman-alpha forest approximately has an effective "throughput" which is a function of redshift and rest-frame wavelength. One would mul...
python
def etau_madau(wave, z, **kwargs): """Madau 1995 extinction for a galaxy at given redshift. This is the Lyman-alpha prescription from the photo-z code BPZ. The Lyman-alpha forest approximately has an effective "throughput" which is a function of redshift and rest-frame wavelength. One would mul...
[ "def", "etau_madau", "(", "wave", ",", "z", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "z", ",", "numbers", ".", "Real", ")", ":", "raise", "exceptions", ".", "SynphotError", "(", "'Redshift must be a real scalar number.'", ")", "if...
Madau 1995 extinction for a galaxy at given redshift. This is the Lyman-alpha prescription from the photo-z code BPZ. The Lyman-alpha forest approximately has an effective "throughput" which is a function of redshift and rest-frame wavelength. One would multiply the SEDs by this factor before p...
[ "Madau", "1995", "extinction", "for", "a", "galaxy", "at", "given", "redshift", ".", "This", "is", "the", "Lyman", "-", "alpha", "prescription", "from", "the", "photo", "-", "z", "code", "BPZ", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L244-L315
spacetelescope/synphot_refactor
synphot/reddening.py
ReddeningLaw.extinction_curve
def extinction_curve(self, ebv, wavelengths=None): """Generate extinction curve. .. math:: A(V) = R(V) \\; \\times \\; E(B-V) THRU = 10^{-0.4 \\; A(V)} Parameters ---------- ebv : float or `~astropy.units.quantity.Quantity` :math:`E(B-V)` v...
python
def extinction_curve(self, ebv, wavelengths=None): """Generate extinction curve. .. math:: A(V) = R(V) \\; \\times \\; E(B-V) THRU = 10^{-0.4 \\; A(V)} Parameters ---------- ebv : float or `~astropy.units.quantity.Quantity` :math:`E(B-V)` v...
[ "def", "extinction_curve", "(", "self", ",", "ebv", ",", "wavelengths", "=", "None", ")", ":", "if", "isinstance", "(", "ebv", ",", "u", ".", "Quantity", ")", "and", "ebv", ".", "unit", ".", "decompose", "(", ")", "==", "u", ".", "mag", ":", "ebv",...
Generate extinction curve. .. math:: A(V) = R(V) \\; \\times \\; E(B-V) THRU = 10^{-0.4 \\; A(V)} Parameters ---------- ebv : float or `~astropy.units.quantity.Quantity` :math:`E(B-V)` value in magnitude. wavelengths : array-like, `~astrop...
[ "Generate", "extinction", "curve", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L42-L84
spacetelescope/synphot_refactor
synphot/reddening.py
ReddeningLaw.to_fits
def to_fits(self, filename, wavelengths=None, **kwargs): """Write the reddening law to a FITS file. :math:`R(V)` column is automatically named 'Av/E(B-V)'. Parameters ---------- filename : str Output filename. wavelengths : array-like, `~astropy.units.quant...
python
def to_fits(self, filename, wavelengths=None, **kwargs): """Write the reddening law to a FITS file. :math:`R(V)` column is automatically named 'Av/E(B-V)'. Parameters ---------- filename : str Output filename. wavelengths : array-like, `~astropy.units.quant...
[ "def", "to_fits", "(", "self", ",", "filename", ",", "wavelengths", "=", "None", ",", "*", "*", "kwargs", ")", ":", "w", ",", "y", "=", "self", ".", "_get_arrays", "(", "wavelengths", ")", "kwargs", "[", "'flux_col'", "]", "=", "'Av/E(B-V)'", "kwargs",...
Write the reddening law to a FITS file. :math:`R(V)` column is automatically named 'Av/E(B-V)'. Parameters ---------- filename : str Output filename. wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling....
[ "Write", "the", "reddening", "law", "to", "a", "FITS", "file", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L86-L128
spacetelescope/synphot_refactor
synphot/reddening.py
ReddeningLaw.from_file
def from_file(cls, filename, **kwargs): """Create a reddening law from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Reddening law filename. kwargs : dict ...
python
def from_file(cls, filename, **kwargs): """Create a reddening law from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Reddening law filename. kwargs : dict ...
[ "def", "from_file", "(", "cls", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "if", "'flux_unit'", "not", "in", "kwargs", ":", "kwargs", "[", "'flux_unit'", "]", "=", "cls", ".", "_internal_flux_unit", "if", "(", "(", "filename", ".", "endswith", ...
Create a reddening law from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Reddening law filename. kwargs : dict Keywords acceptable by :func:`~s...
[ "Create", "a", "reddening", "law", "from", "file", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L131-L163
spacetelescope/synphot_refactor
synphot/reddening.py
ReddeningLaw.from_extinction_model
def from_extinction_model(cls, modelname, **kwargs): """Load :ref:`pre-defined extinction model <synphot_reddening>`. Parameters ---------- modelname : str Extinction model name. Choose from 'lmc30dor', 'lmcavg', 'mwavg', 'mwdense', 'mwrv21', 'mwrv40', 'smcbar', ...
python
def from_extinction_model(cls, modelname, **kwargs): """Load :ref:`pre-defined extinction model <synphot_reddening>`. Parameters ---------- modelname : str Extinction model name. Choose from 'lmc30dor', 'lmcavg', 'mwavg', 'mwdense', 'mwrv21', 'mwrv40', 'smcbar', ...
[ "def", "from_extinction_model", "(", "cls", ",", "modelname", ",", "*", "*", "kwargs", ")", ":", "modelname", "=", "modelname", ".", "lower", "(", ")", "# Select filename based on model name", "if", "modelname", "==", "'lmc30dor'", ":", "cfgitem", "=", "Conf", ...
Load :ref:`pre-defined extinction model <synphot_reddening>`. Parameters ---------- modelname : str Extinction model name. Choose from 'lmc30dor', 'lmcavg', 'mwavg', 'mwdense', 'mwrv21', 'mwrv40', 'smcbar', or 'xgalsb'. kwargs : dict Keywords accepta...
[ "Load", ":", "ref", ":", "pre", "-", "defined", "extinction", "model", "<synphot_reddening", ">", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L166-L227
Julius2342/pyvlx
pyvlx/get_version.py
GetVersion.handle_frame
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameGetVersionConfirmation): return False self.version = frame.version self.success = True return True
python
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameGetVersionConfirmation): return False self.version = frame.version self.success = True return True
[ "async", "def", "handle_frame", "(", "self", ",", "frame", ")", ":", "if", "not", "isinstance", "(", "frame", ",", "FrameGetVersionConfirmation", ")", ":", "return", "False", "self", ".", "version", "=", "frame", ".", "version", "self", ".", "success", "="...
Handle incoming API frame, return True if this was the expected frame.
[ "Handle", "incoming", "API", "frame", "return", "True", "if", "this", "was", "the", "expected", "frame", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_version.py#L15-L21
Julius2342/pyvlx
pyvlx/frames/frame.py
FrameBase.validate_payload_len
def validate_payload_len(self, payload): """Validate payload len.""" if not hasattr(self, "PAYLOAD_LEN"): # No fixed payload len, e.g. within FrameGetSceneListNotification return # pylint: disable=no-member if len(payload) != self.PAYLOAD_LEN: raise Py...
python
def validate_payload_len(self, payload): """Validate payload len.""" if not hasattr(self, "PAYLOAD_LEN"): # No fixed payload len, e.g. within FrameGetSceneListNotification return # pylint: disable=no-member if len(payload) != self.PAYLOAD_LEN: raise Py...
[ "def", "validate_payload_len", "(", "self", ",", "payload", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"PAYLOAD_LEN\"", ")", ":", "# No fixed payload len, e.g. within FrameGetSceneListNotification", "return", "# pylint: disable=no-member", "if", "len", "(", "...
Validate payload len.
[ "Validate", "payload", "len", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame.py#L22-L29
Julius2342/pyvlx
pyvlx/frames/frame.py
FrameBase.build_frame
def build_frame(command, payload): """Build raw bytes from command and payload.""" packet_length = 2 + len(payload) + 1 ret = struct.pack("BB", 0, packet_length) ret += struct.pack(">H", command.value) ret += payload ret += struct.pack("B", calc_crc(ret)) return r...
python
def build_frame(command, payload): """Build raw bytes from command and payload.""" packet_length = 2 + len(payload) + 1 ret = struct.pack("BB", 0, packet_length) ret += struct.pack(">H", command.value) ret += payload ret += struct.pack("B", calc_crc(ret)) return r...
[ "def", "build_frame", "(", "command", ",", "payload", ")", ":", "packet_length", "=", "2", "+", "len", "(", "payload", ")", "+", "1", "ret", "=", "struct", ".", "pack", "(", "\"BB\"", ",", "0", ",", "packet_length", ")", "ret", "+=", "struct", ".", ...
Build raw bytes from command and payload.
[ "Build", "raw", "bytes", "from", "command", "and", "payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame.py#L45-L52
Julius2342/pyvlx
pyvlx/scene.py
Scene.run
async def run(self, wait_for_completion=True): """Run scene. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ activate_scene = ActivateScene( pyvlx=self.pyvlx, wait_for_comp...
python
async def run(self, wait_for_completion=True): """Run scene. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ activate_scene = ActivateScene( pyvlx=self.pyvlx, wait_for_comp...
[ "async", "def", "run", "(", "self", ",", "wait_for_completion", "=", "True", ")", ":", "activate_scene", "=", "ActivateScene", "(", "pyvlx", "=", "self", ".", "pyvlx", ",", "wait_for_completion", "=", "wait_for_completion", ",", "scene_id", "=", "self", ".", ...
Run scene. Parameters: * wait_for_completion: If set, function will return after device has reached target position.
[ "Run", "scene", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/scene.py#L23-L37
Julius2342/pyvlx
old_api/pyvlx/scenes.py
Scenes.add
def add(self, scene): """Add scene.""" if not isinstance(scene, Scene): raise TypeError() self.__scenes.append(scene)
python
def add(self, scene): """Add scene.""" if not isinstance(scene, Scene): raise TypeError() self.__scenes.append(scene)
[ "def", "add", "(", "self", ",", "scene", ")", ":", "if", "not", "isinstance", "(", "scene", ",", "Scene", ")", ":", "raise", "TypeError", "(", ")", "self", ".", "__scenes", ".", "append", "(", "scene", ")" ]
Add scene.
[ "Add", "scene", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L33-L37
Julius2342/pyvlx
old_api/pyvlx/scenes.py
Scenes.load
async def load(self): """Load scenes from KLF 200.""" json_response = await self.pyvlx.interface.api_call('scenes', 'get') self.data_import(json_response)
python
async def load(self): """Load scenes from KLF 200.""" json_response = await self.pyvlx.interface.api_call('scenes', 'get') self.data_import(json_response)
[ "async", "def", "load", "(", "self", ")", ":", "json_response", "=", "await", "self", ".", "pyvlx", ".", "interface", ".", "api_call", "(", "'scenes'", ",", "'get'", ")", "self", ".", "data_import", "(", "json_response", ")" ]
Load scenes from KLF 200.
[ "Load", "scenes", "from", "KLF", "200", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L39-L42
Julius2342/pyvlx
old_api/pyvlx/scenes.py
Scenes.data_import
def data_import(self, json_response): """Import scenes from JSON response.""" if 'data' not in json_response: raise PyVLXException('no element data found: {0}'.format( json.dumps(json_response))) data = json_response['data'] for item in data: self....
python
def data_import(self, json_response): """Import scenes from JSON response.""" if 'data' not in json_response: raise PyVLXException('no element data found: {0}'.format( json.dumps(json_response))) data = json_response['data'] for item in data: self....
[ "def", "data_import", "(", "self", ",", "json_response", ")", ":", "if", "'data'", "not", "in", "json_response", ":", "raise", "PyVLXException", "(", "'no element data found: {0}'", ".", "format", "(", "json", ".", "dumps", "(", "json_response", ")", ")", ")",...
Import scenes from JSON response.
[ "Import", "scenes", "from", "JSON", "response", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L44-L51
Julius2342/pyvlx
old_api/pyvlx/scenes.py
Scenes.load_scene
def load_scene(self, item): """Load scene from json.""" scene = Scene.from_config(self.pyvlx, item) self.add(scene)
python
def load_scene(self, item): """Load scene from json.""" scene = Scene.from_config(self.pyvlx, item) self.add(scene)
[ "def", "load_scene", "(", "self", ",", "item", ")", ":", "scene", "=", "Scene", ".", "from_config", "(", "self", ".", "pyvlx", ",", "item", ")", "self", ".", "add", "(", "scene", ")" ]
Load scene from json.
[ "Load", "scene", "from", "json", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L53-L56
Julius2342/pyvlx
pyvlx/get_state.py
GetState.handle_frame
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameGetStateConfirmation): return False self.success = True self.gateway_state = frame.gateway_state self.gateway_sub_state = fr...
python
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameGetStateConfirmation): return False self.success = True self.gateway_state = frame.gateway_state self.gateway_sub_state = fr...
[ "async", "def", "handle_frame", "(", "self", ",", "frame", ")", ":", "if", "not", "isinstance", "(", "frame", ",", "FrameGetStateConfirmation", ")", ":", "return", "False", "self", ".", "success", "=", "True", "self", ".", "gateway_state", "=", "frame", "....
Handle incoming API frame, return True if this was the expected frame.
[ "Handle", "incoming", "API", "frame", "return", "True", "if", "this", "was", "the", "expected", "frame", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_state.py#L16-L23
Julius2342/pyvlx
pyvlx/alias_array.py
AliasArray.parse_raw
def parse_raw(self, raw): """Parse alias array from raw bytes.""" if not isinstance(raw, bytes): raise PyVLXException("AliasArray::invalid_type_if_raw", type_raw=type(raw)) if len(raw) != 21: raise PyVLXException("AliasArray::invalid_size", size=len(raw)) nbr_of_a...
python
def parse_raw(self, raw): """Parse alias array from raw bytes.""" if not isinstance(raw, bytes): raise PyVLXException("AliasArray::invalid_type_if_raw", type_raw=type(raw)) if len(raw) != 21: raise PyVLXException("AliasArray::invalid_size", size=len(raw)) nbr_of_a...
[ "def", "parse_raw", "(", "self", ",", "raw", ")", ":", "if", "not", "isinstance", "(", "raw", ",", "bytes", ")", ":", "raise", "PyVLXException", "(", "\"AliasArray::invalid_type_if_raw\"", ",", "type_raw", "=", "type", "(", "raw", ")", ")", "if", "len", ...
Parse alias array from raw bytes.
[ "Parse", "alias", "array", "from", "raw", "bytes", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/alias_array.py#L26-L36
Julius2342/pyvlx
pyvlx/slip.py
decode
def decode(raw): """Decode SLIP message.""" return raw \ .replace(bytes([SLIP_ESC, SLIP_ESC_END]), bytes([SLIP_END])) \ .replace(bytes([SLIP_ESC, SLIP_ESC_ESC]), bytes([SLIP_ESC]))
python
def decode(raw): """Decode SLIP message.""" return raw \ .replace(bytes([SLIP_ESC, SLIP_ESC_END]), bytes([SLIP_END])) \ .replace(bytes([SLIP_ESC, SLIP_ESC_ESC]), bytes([SLIP_ESC]))
[ "def", "decode", "(", "raw", ")", ":", "return", "raw", ".", "replace", "(", "bytes", "(", "[", "SLIP_ESC", ",", "SLIP_ESC_END", "]", ")", ",", "bytes", "(", "[", "SLIP_END", "]", ")", ")", ".", "replace", "(", "bytes", "(", "[", "SLIP_ESC", ",", ...
Decode SLIP message.
[ "Decode", "SLIP", "message", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/slip.py#L16-L20
Julius2342/pyvlx
pyvlx/slip.py
encode
def encode(raw): """Encode SLIP message.""" return raw \ .replace(bytes([SLIP_ESC]), bytes([SLIP_ESC, SLIP_ESC_ESC])) \ .replace(bytes([SLIP_END]), bytes([SLIP_ESC, SLIP_ESC_END]))
python
def encode(raw): """Encode SLIP message.""" return raw \ .replace(bytes([SLIP_ESC]), bytes([SLIP_ESC, SLIP_ESC_ESC])) \ .replace(bytes([SLIP_END]), bytes([SLIP_ESC, SLIP_ESC_END]))
[ "def", "encode", "(", "raw", ")", ":", "return", "raw", ".", "replace", "(", "bytes", "(", "[", "SLIP_ESC", "]", ")", ",", "bytes", "(", "[", "SLIP_ESC", ",", "SLIP_ESC_ESC", "]", ")", ")", ".", "replace", "(", "bytes", "(", "[", "SLIP_END", "]", ...
Encode SLIP message.
[ "Encode", "SLIP", "message", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/slip.py#L23-L27
Julius2342/pyvlx
pyvlx/slip.py
get_next_slip
def get_next_slip(raw): """ Get the next slip packet from raw data. Returns the extracted packet plus the raw data with the remaining data stream. """ if not is_slip(raw): return None, raw length = raw[1:].index(SLIP_END) slip_packet = decode(raw[1:length+1]) new_raw = raw[lengt...
python
def get_next_slip(raw): """ Get the next slip packet from raw data. Returns the extracted packet plus the raw data with the remaining data stream. """ if not is_slip(raw): return None, raw length = raw[1:].index(SLIP_END) slip_packet = decode(raw[1:length+1]) new_raw = raw[lengt...
[ "def", "get_next_slip", "(", "raw", ")", ":", "if", "not", "is_slip", "(", "raw", ")", ":", "return", "None", ",", "raw", "length", "=", "raw", "[", "1", ":", "]", ".", "index", "(", "SLIP_END", ")", "slip_packet", "=", "decode", "(", "raw", "[", ...
Get the next slip packet from raw data. Returns the extracted packet plus the raw data with the remaining data stream.
[ "Get", "the", "next", "slip", "packet", "from", "raw", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/slip.py#L30-L41
Julius2342/pyvlx
pyvlx/set_utc.py
set_utc
async def set_utc(pyvlx): """Enable house status monitor.""" setutc = SetUTC(pyvlx=pyvlx) await setutc.do_api_call() if not setutc.success: raise PyVLXException("Unable to set utc.")
python
async def set_utc(pyvlx): """Enable house status monitor.""" setutc = SetUTC(pyvlx=pyvlx) await setutc.do_api_call() if not setutc.success: raise PyVLXException("Unable to set utc.")
[ "async", "def", "set_utc", "(", "pyvlx", ")", ":", "setutc", "=", "SetUTC", "(", "pyvlx", "=", "pyvlx", ")", "await", "setutc", ".", "do_api_call", "(", ")", "if", "not", "setutc", ".", "success", ":", "raise", "PyVLXException", "(", "\"Unable to set utc.\...
Enable house status monitor.
[ "Enable", "house", "status", "monitor", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_utc.py#L30-L35
Julius2342/pyvlx
pyvlx/set_utc.py
SetUTC.handle_frame
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameSetUTCConfirmation): return False self.success = True return True
python
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if not isinstance(frame, FrameSetUTCConfirmation): return False self.success = True return True
[ "async", "def", "handle_frame", "(", "self", ",", "frame", ")", ":", "if", "not", "isinstance", "(", "frame", ",", "FrameSetUTCConfirmation", ")", ":", "return", "False", "self", ".", "success", "=", "True", "return", "True" ]
Handle incoming API frame, return True if this was the expected frame.
[ "Handle", "incoming", "API", "frame", "return", "True", "if", "this", "was", "the", "expected", "frame", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_utc.py#L17-L22
spacetelescope/synphot_refactor
synphot/binning.py
_slow_calcbinflux
def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw): """Python implementation of ``calcbinflux``. This is only used if ``synphot.synphot_utils`` C-extension import fails. See docstrings.py """ binflux = np.empty(shape=(len_binwave, ), dtype=np.float64) intwave = np.empty(shap...
python
def _slow_calcbinflux(len_binwave, i_beg, i_end, avflux, deltaw): """Python implementation of ``calcbinflux``. This is only used if ``synphot.synphot_utils`` C-extension import fails. See docstrings.py """ binflux = np.empty(shape=(len_binwave, ), dtype=np.float64) intwave = np.empty(shap...
[ "def", "_slow_calcbinflux", "(", "len_binwave", ",", "i_beg", ",", "i_end", ",", "avflux", ",", "deltaw", ")", ":", "binflux", "=", "np", ".", "empty", "(", "shape", "=", "(", "len_binwave", ",", ")", ",", "dtype", "=", "np", ".", "float64", ")", "in...
Python implementation of ``calcbinflux``. This is only used if ``synphot.synphot_utils`` C-extension import fails. See docstrings.py
[ "Python", "implementation", "of", "calcbinflux", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L17-L38
spacetelescope/synphot_refactor
synphot/binning.py
calculate_bin_edges
def calculate_bin_edges(centers): """Calculate the edges of wavelength bins given the centers. The algorithm calculates bin edges as the midpoints between bin centers and treats the first and last bins as symmetric about their centers. Parameters ---------- centers : array-like or `~astropy.un...
python
def calculate_bin_edges(centers): """Calculate the edges of wavelength bins given the centers. The algorithm calculates bin edges as the midpoints between bin centers and treats the first and last bins as symmetric about their centers. Parameters ---------- centers : array-like or `~astropy.un...
[ "def", "calculate_bin_edges", "(", "centers", ")", ":", "if", "not", "isinstance", "(", "centers", ",", "u", ".", "Quantity", ")", ":", "centers", "=", "centers", "*", "u", ".", "AA", "if", "centers", ".", "ndim", "!=", "1", ":", "raise", "exceptions",...
Calculate the edges of wavelength bins given the centers. The algorithm calculates bin edges as the midpoints between bin centers and treats the first and last bins as symmetric about their centers. Parameters ---------- centers : array-like or `~astropy.units.quantity.Quantity` Sequence o...
[ "Calculate", "the", "edges", "of", "wavelength", "bins", "given", "the", "centers", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L51-L92
spacetelescope/synphot_refactor
synphot/binning.py
calculate_bin_widths
def calculate_bin_widths(edges): """Calculate the widths of wavelengths bins given their edges. Parameters ---------- edges : array-like or `~astropy.units.quantity.Quantity` Sequence of bin edges. Must be 1D and have at least two values. If not a Quantity, assumed to be in Angstrom. ...
python
def calculate_bin_widths(edges): """Calculate the widths of wavelengths bins given their edges. Parameters ---------- edges : array-like or `~astropy.units.quantity.Quantity` Sequence of bin edges. Must be 1D and have at least two values. If not a Quantity, assumed to be in Angstrom. ...
[ "def", "calculate_bin_widths", "(", "edges", ")", ":", "if", "not", "isinstance", "(", "edges", ",", "u", ".", "Quantity", ")", ":", "edges", "=", "edges", "*", "u", ".", "AA", "if", "edges", ".", "ndim", "!=", "1", ":", "raise", "exceptions", ".", ...
Calculate the widths of wavelengths bins given their edges. Parameters ---------- edges : array-like or `~astropy.units.quantity.Quantity` Sequence of bin edges. Must be 1D and have at least two values. If not a Quantity, assumed to be in Angstrom. Returns ------- widths : `~as...
[ "Calculate", "the", "widths", "of", "wavelengths", "bins", "given", "their", "edges", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L95-L126
spacetelescope/synphot_refactor
synphot/binning.py
calculate_bin_centers
def calculate_bin_centers(edges): """Calculate the centers of wavelengths bins given their edges. Parameters ---------- edges : array-like or `~astropy.units.quantity.Quantity` Sequence of bin edges. Must be 1D and have at least two values. If not a Quantity, assumed to be in Angstrom. ...
python
def calculate_bin_centers(edges): """Calculate the centers of wavelengths bins given their edges. Parameters ---------- edges : array-like or `~astropy.units.quantity.Quantity` Sequence of bin edges. Must be 1D and have at least two values. If not a Quantity, assumed to be in Angstrom. ...
[ "def", "calculate_bin_centers", "(", "edges", ")", ":", "if", "not", "isinstance", "(", "edges", ",", "u", ".", "Quantity", ")", ":", "edges", "=", "edges", "*", "u", ".", "AA", "if", "edges", ".", "ndim", "!=", "1", ":", "raise", "exceptions", ".", ...
Calculate the centers of wavelengths bins given their edges. Parameters ---------- edges : array-like or `~astropy.units.quantity.Quantity` Sequence of bin edges. Must be 1D and have at least two values. If not a Quantity, assumed to be in Angstrom. Returns ------- centers : `~...
[ "Calculate", "the", "centers", "of", "wavelengths", "bins", "given", "their", "edges", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L129-L166
spacetelescope/synphot_refactor
synphot/binning.py
wave_range
def wave_range(bins, cenwave, npix, mode='round'): """Calculate the wavelength range covered by the given number of pixels centered on the given central wavelength of the given bins. Parameters ---------- bins : array-like Wavelengths at bin centers, each centered on a pixel. Must b...
python
def wave_range(bins, cenwave, npix, mode='round'): """Calculate the wavelength range covered by the given number of pixels centered on the given central wavelength of the given bins. Parameters ---------- bins : array-like Wavelengths at bin centers, each centered on a pixel. Must b...
[ "def", "wave_range", "(", "bins", ",", "cenwave", ",", "npix", ",", "mode", "=", "'round'", ")", ":", "mode", "=", "mode", ".", "lower", "(", ")", "if", "mode", "not", "in", "(", "'round'", ",", "'min'", ",", "'max'", ",", "'none'", ")", ":", "ra...
Calculate the wavelength range covered by the given number of pixels centered on the given central wavelength of the given bins. Parameters ---------- bins : array-like Wavelengths at bin centers, each centered on a pixel. Must be 1D array. cenwave : float Desired central w...
[ "Calculate", "the", "wavelength", "range", "covered", "by", "the", "given", "number", "of", "pixels", "centered", "on", "the", "given", "central", "wavelength", "of", "the", "given", "bins", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L169-L358
spacetelescope/synphot_refactor
synphot/binning.py
pixel_range
def pixel_range(bins, waverange, mode='round'): """Calculate the number of pixels within the given wavelength range and the given bins. Parameters ---------- bins : array-like Wavelengths at bin centers, each centered on a pixel. Must be 1D array. waverange : tuple of float ...
python
def pixel_range(bins, waverange, mode='round'): """Calculate the number of pixels within the given wavelength range and the given bins. Parameters ---------- bins : array-like Wavelengths at bin centers, each centered on a pixel. Must be 1D array. waverange : tuple of float ...
[ "def", "pixel_range", "(", "bins", ",", "waverange", ",", "mode", "=", "'round'", ")", ":", "mode", "=", "mode", ".", "lower", "(", ")", "if", "mode", "not", "in", "(", "'round'", ",", "'min'", ",", "'max'", ",", "'none'", ")", ":", "raise", "excep...
Calculate the number of pixels within the given wavelength range and the given bins. Parameters ---------- bins : array-like Wavelengths at bin centers, each centered on a pixel. Must be 1D array. waverange : tuple of float Lower and upper limits of the desired wavelength r...
[ "Calculate", "the", "number", "of", "pixels", "within", "the", "given", "wavelength", "range", "and", "the", "given", "bins", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/binning.py#L361-L486
Julius2342/pyvlx
pyvlx/pyvlx.py
PyVLX.connect
async def connect(self): """Connect to KLF 200.""" PYVLXLOG.warning("Connecting to KLF 200.") await self.connection.connect() login = Login(pyvlx=self, password=self.config.password) await login.do_api_call() if not login.success: raise PyVLXException("Login t...
python
async def connect(self): """Connect to KLF 200.""" PYVLXLOG.warning("Connecting to KLF 200.") await self.connection.connect() login = Login(pyvlx=self, password=self.config.password) await login.do_api_call() if not login.success: raise PyVLXException("Login t...
[ "async", "def", "connect", "(", "self", ")", ":", "PYVLXLOG", ".", "warning", "(", "\"Connecting to KLF 200.\"", ")", "await", "self", ".", "connection", ".", "connect", "(", ")", "login", "=", "Login", "(", "pyvlx", "=", "self", ",", "password", "=", "s...
Connect to KLF 200.
[ "Connect", "to", "KLF", "200", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/pyvlx.py#L42-L49
Julius2342/pyvlx
pyvlx/pyvlx.py
PyVLX.update_version
async def update_version(self): """Retrieve version and protocol version from API.""" get_version = GetVersion(pyvlx=self) await get_version.do_api_call() if not get_version.success: raise PyVLXException("Unable to retrieve version") self.version = get_version.version...
python
async def update_version(self): """Retrieve version and protocol version from API.""" get_version = GetVersion(pyvlx=self) await get_version.do_api_call() if not get_version.success: raise PyVLXException("Unable to retrieve version") self.version = get_version.version...
[ "async", "def", "update_version", "(", "self", ")", ":", "get_version", "=", "GetVersion", "(", "pyvlx", "=", "self", ")", "await", "get_version", ".", "do_api_call", "(", ")", "if", "not", "get_version", ".", "success", ":", "raise", "PyVLXException", "(", ...
Retrieve version and protocol version from API.
[ "Retrieve", "version", "and", "protocol", "version", "from", "API", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/pyvlx.py#L51-L65
Julius2342/pyvlx
pyvlx/pyvlx.py
PyVLX.send_frame
async def send_frame(self, frame): """Send frame to API via connection.""" if not self.connection.connected: await self.connect() await self.update_version() await set_utc(pyvlx=self) await house_status_monitor_enable(pyvlx=self) self.connection.wr...
python
async def send_frame(self, frame): """Send frame to API via connection.""" if not self.connection.connected: await self.connect() await self.update_version() await set_utc(pyvlx=self) await house_status_monitor_enable(pyvlx=self) self.connection.wr...
[ "async", "def", "send_frame", "(", "self", ",", "frame", ")", ":", "if", "not", "self", ".", "connection", ".", "connected", ":", "await", "self", ".", "connect", "(", ")", "await", "self", ".", "update_version", "(", ")", "await", "set_utc", "(", "pyv...
Send frame to API via connection.
[ "Send", "frame", "to", "API", "via", "connection", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/pyvlx.py#L67-L74
Julius2342/pyvlx
old_api/pyvlx/scene.py
Scene.from_config
def from_config(cls, pyvlx, item): """Read scene from configuration.""" name = item['name'] ident = item['id'] return cls(pyvlx, ident, name)
python
def from_config(cls, pyvlx, item): """Read scene from configuration.""" name = item['name'] ident = item['id'] return cls(pyvlx, ident, name)
[ "def", "from_config", "(", "cls", ",", "pyvlx", ",", "item", ")", ":", "name", "=", "item", "[", "'name'", "]", "ident", "=", "item", "[", "'id'", "]", "return", "cls", "(", "pyvlx", ",", "ident", ",", "name", ")" ]
Read scene from configuration.
[ "Read", "scene", "from", "configuration", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scene.py#L14-L18
Julius2342/pyvlx
old_api/pyvlx/interface.py
Interface.api_call
async def api_call(self, verb, action, params=None, add_authorization_token=True, retry=False): """Send api call.""" if add_authorization_token and not self.token: await self.refresh_token() try: return await self._api_call_impl(verb, action, params, add_authorization_to...
python
async def api_call(self, verb, action, params=None, add_authorization_token=True, retry=False): """Send api call.""" if add_authorization_token and not self.token: await self.refresh_token() try: return await self._api_call_impl(verb, action, params, add_authorization_to...
[ "async", "def", "api_call", "(", "self", ",", "verb", ",", "action", ",", "params", "=", "None", ",", "add_authorization_token", "=", "True", ",", "retry", "=", "False", ")", ":", "if", "add_authorization_token", "and", "not", "self", ".", "token", ":", ...
Send api call.
[ "Send", "api", "call", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L19-L31
Julius2342/pyvlx
old_api/pyvlx/interface.py
Interface.refresh_token
async def refresh_token(self): """Refresh API token from KLF 200.""" json_response = await self.api_call('auth', 'login', {'password': self.config.password}, add_authorization_token=False) if 'token' not in json_response: raise PyVLXException('no element token found in response: {0}'...
python
async def refresh_token(self): """Refresh API token from KLF 200.""" json_response = await self.api_call('auth', 'login', {'password': self.config.password}, add_authorization_token=False) if 'token' not in json_response: raise PyVLXException('no element token found in response: {0}'...
[ "async", "def", "refresh_token", "(", "self", ")", ":", "json_response", "=", "await", "self", ".", "api_call", "(", "'auth'", ",", "'login'", ",", "{", "'password'", ":", "self", ".", "config", ".", "password", "}", ",", "add_authorization_token", "=", "F...
Refresh API token from KLF 200.
[ "Refresh", "API", "token", "from", "KLF", "200", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L62-L67
Julius2342/pyvlx
old_api/pyvlx/interface.py
Interface.create_body
def create_body(action, params): """Create http body for rest request.""" body = {} body['action'] = action if params is not None: body['params'] = params return body
python
def create_body(action, params): """Create http body for rest request.""" body = {} body['action'] = action if params is not None: body['params'] = params return body
[ "def", "create_body", "(", "action", ",", "params", ")", ":", "body", "=", "{", "}", "body", "[", "'action'", "]", "=", "action", "if", "params", "is", "not", "None", ":", "body", "[", "'params'", "]", "=", "params", "return", "body" ]
Create http body for rest request.
[ "Create", "http", "body", "for", "rest", "request", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L89-L95
Julius2342/pyvlx
old_api/pyvlx/interface.py
Interface.evaluate_response
def evaluate_response(json_response): """Evaluate rest response.""" if 'errors' in json_response and json_response['errors']: Interface.evaluate_errors(json_response) elif 'result' not in json_response: raise PyVLXException('no element result found in response: {0}'.form...
python
def evaluate_response(json_response): """Evaluate rest response.""" if 'errors' in json_response and json_response['errors']: Interface.evaluate_errors(json_response) elif 'result' not in json_response: raise PyVLXException('no element result found in response: {0}'.form...
[ "def", "evaluate_response", "(", "json_response", ")", ":", "if", "'errors'", "in", "json_response", "and", "json_response", "[", "'errors'", "]", ":", "Interface", ".", "evaluate_errors", "(", "json_response", ")", "elif", "'result'", "not", "in", "json_response"...
Evaluate rest response.
[ "Evaluate", "rest", "response", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L98-L105
Julius2342/pyvlx
old_api/pyvlx/interface.py
Interface.evaluate_errors
def evaluate_errors(json_response): """Evaluate rest errors.""" if 'errors' not in json_response or \ not isinstance(json_response['errors'], list) or \ not json_response['errors'] or \ not isinstance(json_response['errors'][0], int): raise PyVLXException('Co...
python
def evaluate_errors(json_response): """Evaluate rest errors.""" if 'errors' not in json_response or \ not isinstance(json_response['errors'], list) or \ not json_response['errors'] or \ not isinstance(json_response['errors'][0], int): raise PyVLXException('Co...
[ "def", "evaluate_errors", "(", "json_response", ")", ":", "if", "'errors'", "not", "in", "json_response", "or", "not", "isinstance", "(", "json_response", "[", "'errors'", "]", ",", "list", ")", "or", "not", "json_response", "[", "'errors'", "]", "or", "not"...
Evaluate rest errors.
[ "Evaluate", "rest", "errors", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/interface.py#L108-L122
Julius2342/pyvlx
pyvlx/frames/frame_set_node_name.py
FrameSetNodeNameRequest.get_payload
def get_payload(self): """Return Payload.""" ret = bytes([self.node_id]) ret += string_to_bytes(self.name, 64) return ret
python
def get_payload(self): """Return Payload.""" ret = bytes([self.node_id]) ret += string_to_bytes(self.name, 64) return ret
[ "def", "get_payload", "(", "self", ")", ":", "ret", "=", "bytes", "(", "[", "self", ".", "node_id", "]", ")", "ret", "+=", "string_to_bytes", "(", "self", ".", "name", ",", "64", ")", "return", "ret" ]
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_set_node_name.py#L21-L25
Julius2342/pyvlx
pyvlx/frames/frame_set_node_name.py
FrameSetNodeNameRequest.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.node_id = payload[0] self.name = bytes_to_string(payload[1:65])
python
def from_payload(self, payload): """Init frame from binary data.""" self.node_id = payload[0] self.name = bytes_to_string(payload[1:65])
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "node_id", "=", "payload", "[", "0", "]", "self", ".", "name", "=", "bytes_to_string", "(", "payload", "[", "1", ":", "65", "]", ")" ]
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_set_node_name.py#L27-L30
Julius2342/pyvlx
pyvlx/frames/frame_set_node_name.py
FrameSetNodeNameConfirmation.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.status = SetNodeNameConfirmationStatus(payload[0]) self.node_id = payload[1]
python
def from_payload(self, payload): """Init frame from binary data.""" self.status = SetNodeNameConfirmationStatus(payload[0]) self.node_id = payload[1]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "status", "=", "SetNodeNameConfirmationStatus", "(", "payload", "[", "0", "]", ")", "self", ".", "node_id", "=", "payload", "[", "1", "]" ]
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_set_node_name.py#L60-L63
Julius2342/pyvlx
pyvlx/node_helper.py
convert_frame_to_node
def convert_frame_to_node(pyvlx, frame): """Convert FrameGet[All]Node[s]InformationNotification into Node object.""" # pylint: disable=too-many-return-statements if frame.node_type == NodeTypeWithSubtype.WINDOW_OPENER: return Window(pyvlx=pyvlx, node_id=frame.node_id, name=frame.name, rain_sensor=Fa...
python
def convert_frame_to_node(pyvlx, frame): """Convert FrameGet[All]Node[s]InformationNotification into Node object.""" # pylint: disable=too-many-return-statements if frame.node_type == NodeTypeWithSubtype.WINDOW_OPENER: return Window(pyvlx=pyvlx, node_id=frame.node_id, name=frame.name, rain_sensor=Fa...
[ "def", "convert_frame_to_node", "(", "pyvlx", ",", "frame", ")", ":", "# pylint: disable=too-many-return-statements", "if", "frame", ".", "node_type", "==", "NodeTypeWithSubtype", ".", "WINDOW_OPENER", ":", "return", "Window", "(", "pyvlx", "=", "pyvlx", ",", "node_...
Convert FrameGet[All]Node[s]InformationNotification into Node object.
[ "Convert", "FrameGet", "[", "All", "]", "Node", "[", "s", "]", "InformationNotification", "into", "Node", "object", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/node_helper.py#L8-L30
spacetelescope/synphot_refactor
synphot/thermal.py
ThermalSpectralElement.temperature
def temperature(self, what): """Set temperature.""" self._temperature = units.validate_quantity(what, u.K)
python
def temperature(self, what): """Set temperature.""" self._temperature = units.validate_quantity(what, u.K)
[ "def", "temperature", "(", "self", ",", "what", ")", ":", "self", ".", "_temperature", "=", "units", ".", "validate_quantity", "(", "what", ",", "u", ".", "K", ")" ]
Set temperature.
[ "Set", "temperature", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/thermal.py#L53-L55
spacetelescope/synphot_refactor
synphot/thermal.py
ThermalSpectralElement.thermal_source
def thermal_source(self): """Apply emissivity to an existing beam to produce a thermal source spectrum (without optical counterpart). Thermal source spectrum is calculated as follow: #. Create a blackbody spectrum in PHOTLAM per square arcsec with `temperature`. ...
python
def thermal_source(self): """Apply emissivity to an existing beam to produce a thermal source spectrum (without optical counterpart). Thermal source spectrum is calculated as follow: #. Create a blackbody spectrum in PHOTLAM per square arcsec with `temperature`. ...
[ "def", "thermal_source", "(", "self", ")", ":", "sp", "=", "(", "SourceSpectrum", "(", "BlackBody1D", ",", "temperature", "=", "self", ".", "temperature", ")", "*", "units", ".", "SR_PER_ARCSEC2", "*", "self", ".", "beam_fill_factor", "*", "self", ")", "sp...
Apply emissivity to an existing beam to produce a thermal source spectrum (without optical counterpart). Thermal source spectrum is calculated as follow: #. Create a blackbody spectrum in PHOTLAM per square arcsec with `temperature`. #. Multiply the blackbody wit...
[ "Apply", "emissivity", "to", "an", "existing", "beam", "to", "produce", "a", "thermal", "source", "spectrum", "(", "without", "optical", "counterpart", ")", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/thermal.py#L72-L92
spacetelescope/synphot_refactor
synphot/thermal.py
ThermalSpectralElement.from_file
def from_file(cls, filename, temperature_key='DEFT', beamfill_key='BEAMFILL', **kwargs): """Creates a thermal spectral element from file. .. note:: Only FITS format is supported. Parameters ---------- filename : str Thermal spectral el...
python
def from_file(cls, filename, temperature_key='DEFT', beamfill_key='BEAMFILL', **kwargs): """Creates a thermal spectral element from file. .. note:: Only FITS format is supported. Parameters ---------- filename : str Thermal spectral el...
[ "def", "from_file", "(", "cls", ",", "filename", ",", "temperature_key", "=", "'DEFT'", ",", "beamfill_key", "=", "'BEAMFILL'", ",", "*", "*", "kwargs", ")", ":", "if", "not", "(", "filename", ".", "endswith", "(", "'fits'", ")", "or", "filename", ".", ...
Creates a thermal spectral element from file. .. note:: Only FITS format is supported. Parameters ---------- filename : str Thermal spectral element filename. temperature_key, beamfill_key : str Keywords in FITS *table extension* that store...
[ "Creates", "a", "thermal", "spectral", "element", "from", "file", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/thermal.py#L95-L150
Julius2342/pyvlx
pyvlx/frames/frame_get_all_nodes_information.py
FrameGetAllNodesInformationConfirmation.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.status = AllNodesInformationStatus(payload[0]) self.number_of_nodes = payload[1]
python
def from_payload(self, payload): """Init frame from binary data.""" self.status = AllNodesInformationStatus(payload[0]) self.number_of_nodes = payload[1]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "status", "=", "AllNodesInformationStatus", "(", "payload", "[", "0", "]", ")", "self", ".", "number_of_nodes", "=", "payload", "[", "1", "]" ]
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_all_nodes_information.py#L46-L49
Julius2342/pyvlx
pyvlx/frames/frame_get_all_nodes_information.py
FrameGetAllNodesInformationNotification.get_payload
def get_payload(self): """Return Payload.""" payload = bytes() payload += bytes([self.node_id]) payload += bytes([self.order >> 8 & 255, self.order & 255]) payload += bytes([self.placement]) payload += bytes(string_to_bytes(self.name, 64)) payload += bytes([self.v...
python
def get_payload(self): """Return Payload.""" payload = bytes() payload += bytes([self.node_id]) payload += bytes([self.order >> 8 & 255, self.order & 255]) payload += bytes([self.placement]) payload += bytes(string_to_bytes(self.name, 64)) payload += bytes([self.v...
[ "def", "get_payload", "(", "self", ")", ":", "payload", "=", "bytes", "(", ")", "payload", "+=", "bytes", "(", "[", "self", ".", "node_id", "]", ")", "payload", "+=", "bytes", "(", "[", "self", ".", "order", ">>", "8", "&", "255", ",", "self", "....
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_all_nodes_information.py#L92-L118
Julius2342/pyvlx
pyvlx/frames/frame_get_all_nodes_information.py
FrameGetAllNodesInformationNotification.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.node_id = payload[0] self.order = payload[1] * 256 + payload[2] self.placement = payload[3] self.name = bytes_to_string(payload[4:68]) self.velocity = Velocity(payload[68]) self.node_type = N...
python
def from_payload(self, payload): """Init frame from binary data.""" self.node_id = payload[0] self.order = payload[1] * 256 + payload[2] self.placement = payload[3] self.name = bytes_to_string(payload[4:68]) self.velocity = Velocity(payload[68]) self.node_type = N...
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "node_id", "=", "payload", "[", "0", "]", "self", ".", "order", "=", "payload", "[", "1", "]", "*", "256", "+", "payload", "[", "2", "]", "self", ".", "placement", "=", "p...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_all_nodes_information.py#L120-L143
Julius2342/pyvlx
pyvlx/parameter.py
Parameter.from_parameter
def from_parameter(self, parameter): """Set internal raw state from parameter.""" if not isinstance(parameter, Parameter): raise Exception("parameter::from_parameter_wrong_object") self.raw = parameter.raw
python
def from_parameter(self, parameter): """Set internal raw state from parameter.""" if not isinstance(parameter, Parameter): raise Exception("parameter::from_parameter_wrong_object") self.raw = parameter.raw
[ "def", "from_parameter", "(", "self", ",", "parameter", ")", ":", "if", "not", "isinstance", "(", "parameter", ",", "Parameter", ")", ":", "raise", "Exception", "(", "\"parameter::from_parameter_wrong_object\"", ")", "self", ".", "raw", "=", "parameter", ".", ...
Set internal raw state from parameter.
[ "Set", "internal", "raw", "state", "from", "parameter", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L21-L25
Julius2342/pyvlx
pyvlx/parameter.py
Parameter.from_int
def from_int(value): """Create raw out of position vlaue.""" if not isinstance(value, int): raise PyVLXException("value_has_to_be_int") if not Parameter.is_valid_int(value): raise PyVLXException("value_out_of_range") return bytes([value >> 8 & 255, value & 255])
python
def from_int(value): """Create raw out of position vlaue.""" if not isinstance(value, int): raise PyVLXException("value_has_to_be_int") if not Parameter.is_valid_int(value): raise PyVLXException("value_out_of_range") return bytes([value >> 8 & 255, value & 255])
[ "def", "from_int", "(", "value", ")", ":", "if", "not", "isinstance", "(", "value", ",", "int", ")", ":", "raise", "PyVLXException", "(", "\"value_has_to_be_int\"", ")", "if", "not", "Parameter", ".", "is_valid_int", "(", "value", ")", ":", "raise", "PyVLX...
Create raw out of position vlaue.
[ "Create", "raw", "out", "of", "position", "vlaue", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L28-L34
Julius2342/pyvlx
pyvlx/parameter.py
Parameter.is_valid_int
def is_valid_int(value): """Test if value can be rendered out of int.""" if 0 <= value <= Parameter.MAX: # This includes ON and OFF return True if value == Parameter.UNKNOWN_VALUE: return True if value == Parameter.CURRENT_POSITION: return True ...
python
def is_valid_int(value): """Test if value can be rendered out of int.""" if 0 <= value <= Parameter.MAX: # This includes ON and OFF return True if value == Parameter.UNKNOWN_VALUE: return True if value == Parameter.CURRENT_POSITION: return True ...
[ "def", "is_valid_int", "(", "value", ")", ":", "if", "0", "<=", "value", "<=", "Parameter", ".", "MAX", ":", "# This includes ON and OFF", "return", "True", "if", "value", "==", "Parameter", ".", "UNKNOWN_VALUE", ":", "return", "True", "if", "value", "==", ...
Test if value can be rendered out of int.
[ "Test", "if", "value", "can", "be", "rendered", "out", "of", "int", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L37-L45
Julius2342/pyvlx
pyvlx/parameter.py
Parameter.from_raw
def from_raw(raw): """Test if raw packets are valid for initialization of Position.""" if not isinstance(raw, bytes): raise PyVLXException("Position::raw_must_be_bytes") if len(raw) != 2: raise PyVLXException("Position::raw_must_be_two_bytes") if raw != Position.f...
python
def from_raw(raw): """Test if raw packets are valid for initialization of Position.""" if not isinstance(raw, bytes): raise PyVLXException("Position::raw_must_be_bytes") if len(raw) != 2: raise PyVLXException("Position::raw_must_be_two_bytes") if raw != Position.f...
[ "def", "from_raw", "(", "raw", ")", ":", "if", "not", "isinstance", "(", "raw", ",", "bytes", ")", ":", "raise", "PyVLXException", "(", "\"Position::raw_must_be_bytes\"", ")", "if", "len", "(", "raw", ")", "!=", "2", ":", "raise", "PyVLXException", "(", ...
Test if raw packets are valid for initialization of Position.
[ "Test", "if", "raw", "packets", "are", "valid", "for", "initialization", "of", "Position", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L48-L58
Julius2342/pyvlx
pyvlx/parameter.py
Position.from_percent
def from_percent(position_percent): """Create raw value out of percent position.""" if not isinstance(position_percent, int): raise PyVLXException("Position::position_percent_has_to_be_int") if position_percent < 0: raise PyVLXException("Position::position_percent_has_to_...
python
def from_percent(position_percent): """Create raw value out of percent position.""" if not isinstance(position_percent, int): raise PyVLXException("Position::position_percent_has_to_be_int") if position_percent < 0: raise PyVLXException("Position::position_percent_has_to_...
[ "def", "from_percent", "(", "position_percent", ")", ":", "if", "not", "isinstance", "(", "position_percent", ",", "int", ")", ":", "raise", "PyVLXException", "(", "\"Position::position_percent_has_to_be_int\"", ")", "if", "position_percent", "<", "0", ":", "raise",...
Create raw value out of percent position.
[ "Create", "raw", "value", "out", "of", "percent", "position", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/parameter.py#L172-L180
Julius2342/pyvlx
pyvlx/frames/frame_get_version.py
FrameGetVersionConfirmation.product
def product(self): """Return product as human readable string.""" if self.product_group == 14 and self.product_type == 3: return "KLF 200" return "Unknown Product: {}:{}".format(self.product_group, self.product_type)
python
def product(self): """Return product as human readable string.""" if self.product_group == 14 and self.product_type == 3: return "KLF 200" return "Unknown Product: {}:{}".format(self.product_group, self.product_type)
[ "def", "product", "(", "self", ")", ":", "if", "self", ".", "product_group", "==", "14", "and", "self", ".", "product_type", "==", "3", ":", "return", "\"KLF 200\"", "return", "\"Unknown Product: {}:{}\"", ".", "format", "(", "self", ".", "product_group", ",...
Return product as human readable string.
[ "Return", "product", "as", "human", "readable", "string", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_version.py#L44-L48
Julius2342/pyvlx
pyvlx/frames/frame_get_version.py
FrameGetVersionConfirmation.get_payload
def get_payload(self): """Return Payload.""" ret = self._software_version ret += bytes([self.hardware_version, self.product_group, self.product_type]) return ret
python
def get_payload(self): """Return Payload.""" ret = self._software_version ret += bytes([self.hardware_version, self.product_group, self.product_type]) return ret
[ "def", "get_payload", "(", "self", ")", ":", "ret", "=", "self", ".", "_software_version", "ret", "+=", "bytes", "(", "[", "self", ".", "hardware_version", ",", "self", ".", "product_group", ",", "self", ".", "product_type", "]", ")", "return", "ret" ]
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_version.py#L50-L54
Julius2342/pyvlx
pyvlx/frames/frame_get_version.py
FrameGetVersionConfirmation.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self._software_version = payload[0:6] self.hardware_version = payload[6] self.product_group = payload[7] self.product_type = payload[8]
python
def from_payload(self, payload): """Init frame from binary data.""" self._software_version = payload[0:6] self.hardware_version = payload[6] self.product_group = payload[7] self.product_type = payload[8]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "_software_version", "=", "payload", "[", "0", ":", "6", "]", "self", ".", "hardware_version", "=", "payload", "[", "6", "]", "self", ".", "product_group", "=", "payload", "[", ...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_version.py#L56-L61
Julius2342/pyvlx
pyvlx/frames/frame_activate_scene.py
FrameActivateSceneRequest.get_payload
def get_payload(self): """Return Payload.""" ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.originator.value]) ret += bytes([self.priority.value]) ret += bytes([self.scene_id]) ret += bytes([self.velocity.value]) return ret
python
def get_payload(self): """Return Payload.""" ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.originator.value]) ret += bytes([self.priority.value]) ret += bytes([self.scene_id]) ret += bytes([self.velocity.value]) return ret
[ "def", "get_payload", "(", "self", ")", ":", "ret", "=", "bytes", "(", "[", "self", ".", "session_id", ">>", "8", "&", "255", ",", "self", ".", "session_id", "&", "255", "]", ")", "ret", "+=", "bytes", "(", "[", "self", ".", "originator", ".", "v...
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L23-L30
Julius2342/pyvlx
pyvlx/frames/frame_activate_scene.py
FrameActivateSceneRequest.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.originator = Originator(payload[2]) self.priority = Priority(payload[3]) self.scene_id = payload[4] self.velocity = Velocity(payload[5])
python
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.originator = Originator(payload[2]) self.priority = Priority(payload[3]) self.scene_id = payload[4] self.velocity = Velocity(payload[5])
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "session_id", "=", "payload", "[", "0", "]", "*", "256", "+", "payload", "[", "1", "]", "self", ".", "originator", "=", "Originator", "(", "payload", "[", "2", "]", ")", "se...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L32-L38
Julius2342/pyvlx
pyvlx/frames/frame_activate_scene.py
FrameActivateSceneConfirmation.get_payload
def get_payload(self): """Return Payload.""" ret = bytes([self.status.value]) ret += bytes([self.session_id >> 8 & 255, self.session_id & 255]) return ret
python
def get_payload(self): """Return Payload.""" ret = bytes([self.status.value]) ret += bytes([self.session_id >> 8 & 255, self.session_id & 255]) return ret
[ "def", "get_payload", "(", "self", ")", ":", "ret", "=", "bytes", "(", "[", "self", ".", "status", ".", "value", "]", ")", "ret", "+=", "bytes", "(", "[", "self", ".", "session_id", ">>", "8", "&", "255", ",", "self", ".", "session_id", "&", "255...
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L65-L69
Julius2342/pyvlx
pyvlx/frames/frame_activate_scene.py
FrameActivateSceneConfirmation.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.status = ActivateSceneConfirmationStatus(payload[0]) self.session_id = payload[1]*256 + payload[2]
python
def from_payload(self, payload): """Init frame from binary data.""" self.status = ActivateSceneConfirmationStatus(payload[0]) self.session_id = payload[1]*256 + payload[2]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "status", "=", "ActivateSceneConfirmationStatus", "(", "payload", "[", "0", "]", ")", "self", ".", "session_id", "=", "payload", "[", "1", "]", "*", "256", "+", "payload", "[", ...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_activate_scene.py#L71-L74
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandSendRequest.get_payload
def get_payload(self): """Return Payload.""" # Session id ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.originator.value]) ret += bytes([self.priority.value]) ret += bytes([0]) # ParameterActive pointing to main parameter (MP) ...
python
def get_payload(self): """Return Payload.""" # Session id ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.originator.value]) ret += bytes([self.priority.value]) ret += bytes([0]) # ParameterActive pointing to main parameter (MP) ...
[ "def", "get_payload", "(", "self", ")", ":", "# Session id", "ret", "=", "bytes", "(", "[", "self", ".", "session_id", ">>", "8", "&", "255", ",", "self", ".", "session_id", "&", "255", "]", ")", "ret", "+=", "bytes", "(", "[", "self", ".", "origin...
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L25-L50
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandSendRequest.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.originator = Originator(payload[2]) self.priority = Priority(payload[3]) len_node_ids = payload[41] if len_node_ids > 20: raise PyVLXExcepti...
python
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.originator = Originator(payload[2]) self.priority = Priority(payload[3]) len_node_ids = payload[41] if len_node_ids > 20: raise PyVLXExcepti...
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "session_id", "=", "payload", "[", "0", "]", "*", "256", "+", "payload", "[", "1", "]", "self", ".", "originator", "=", "Originator", "(", "payload", "[", "2", "]", ")", "se...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L52-L65
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandSendConfirmation.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.status = CommandSendConfirmationStatus(payload[2])
python
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.status = CommandSendConfirmationStatus(payload[2])
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "session_id", "=", "payload", "[", "0", "]", "*", "256", "+", "payload", "[", "1", "]", "self", ".", "status", "=", "CommandSendConfirmationStatus", "(", "payload", "[", "2", "]...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L98-L101
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandRunStatusNotification.get_payload
def get_payload(self): """Return Payload.""" ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.status_id]) ret += bytes([self.index_id]) ret += bytes([self.node_parameter]) ret += bytes([self.parameter_value >> 8 & 255, self.parameter_val...
python
def get_payload(self): """Return Payload.""" ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.status_id]) ret += bytes([self.index_id]) ret += bytes([self.node_parameter]) ret += bytes([self.parameter_value >> 8 & 255, self.parameter_val...
[ "def", "get_payload", "(", "self", ")", ":", "ret", "=", "bytes", "(", "[", "self", ".", "session_id", ">>", "8", "&", "255", ",", "self", ".", "session_id", "&", "255", "]", ")", "ret", "+=", "bytes", "(", "[", "self", ".", "status_id", "]", ")"...
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L122-L132
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandRunStatusNotification.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.status_id = payload[2] self.index_id = payload[3] self.node_parameter = payload[4] self.parameter_value = payload[5]*256 + payload[6]
python
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.status_id = payload[2] self.index_id = payload[3] self.node_parameter = payload[4] self.parameter_value = payload[5]*256 + payload[6]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "session_id", "=", "payload", "[", "0", "]", "*", "256", "+", "payload", "[", "1", "]", "self", ".", "status_id", "=", "payload", "[", "2", "]", "self", ".", "index_id", "="...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L134-L140
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandRemainingTimeNotification.get_payload
def get_payload(self): """Return Payload.""" ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.index_id]) ret += bytes([self.node_parameter]) ret += bytes([self.seconds >> 8 & 255, self.seconds & 255]) return ret
python
def get_payload(self): """Return Payload.""" ret = bytes([self.session_id >> 8 & 255, self.session_id & 255]) ret += bytes([self.index_id]) ret += bytes([self.node_parameter]) ret += bytes([self.seconds >> 8 & 255, self.seconds & 255]) return ret
[ "def", "get_payload", "(", "self", ")", ":", "ret", "=", "bytes", "(", "[", "self", ".", "session_id", ">>", "8", "&", "255", ",", "self", ".", "session_id", "&", "255", "]", ")", "ret", "+=", "bytes", "(", "[", "self", ".", "index_id", "]", ")",...
Return Payload.
[ "Return", "Payload", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L164-L170
Julius2342/pyvlx
pyvlx/frames/frame_command_send.py
FrameCommandRemainingTimeNotification.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.index_id = payload[2] self.node_parameter = payload[3] self.seconds = payload[4]*256 + payload[5]
python
def from_payload(self, payload): """Init frame from binary data.""" self.session_id = payload[0]*256 + payload[1] self.index_id = payload[2] self.node_parameter = payload[3] self.seconds = payload[4]*256 + payload[5]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "session_id", "=", "payload", "[", "0", "]", "*", "256", "+", "payload", "[", "1", "]", "self", ".", "index_id", "=", "payload", "[", "2", "]", "self", ".", "node_parameter", ...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_command_send.py#L172-L177
Julius2342/pyvlx
examples/monitor.py
main
async def main(loop): """Log packets from Bus.""" # Setting debug PYVLXLOG.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) PYVLXLOG.addHandler(stream_handler) # Connecting to KLF 200 pyvlx = PyVLX('pyvlx.yaml', loop=loop) await...
python
async def main(loop): """Log packets from Bus.""" # Setting debug PYVLXLOG.setLevel(logging.DEBUG) stream_handler = logging.StreamHandler() stream_handler.setLevel(logging.DEBUG) PYVLXLOG.addHandler(stream_handler) # Connecting to KLF 200 pyvlx = PyVLX('pyvlx.yaml', loop=loop) await...
[ "async", "def", "main", "(", "loop", ")", ":", "# Setting debug", "PYVLXLOG", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "stream_handler", "=", "logging", ".", "StreamHandler", "(", ")", "stream_handler", ".", "setLevel", "(", "logging", ".", "DEBUG...
Log packets from Bus.
[ "Log", "packets", "from", "Bus", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/examples/monitor.py#L9-L27
Julius2342/pyvlx
pyvlx/node.py
Node.rename
async def rename(self, name): """Change name of node.""" set_node_name = SetNodeName(pyvlx=self.pyvlx, node_id=self.node_id, name=name) await set_node_name.do_api_call() if not set_node_name.success: raise PyVLXException("Unable to rename node") self.name = name
python
async def rename(self, name): """Change name of node.""" set_node_name = SetNodeName(pyvlx=self.pyvlx, node_id=self.node_id, name=name) await set_node_name.do_api_call() if not set_node_name.success: raise PyVLXException("Unable to rename node") self.name = name
[ "async", "def", "rename", "(", "self", ",", "name", ")", ":", "set_node_name", "=", "SetNodeName", "(", "pyvlx", "=", "self", ".", "pyvlx", ",", "node_id", "=", "self", ".", "node_id", ",", "name", "=", "name", ")", "await", "set_node_name", ".", "do_a...
Change name of node.
[ "Change", "name", "of", "node", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/node.py#L36-L42
Julius2342/pyvlx
pyvlx/opening_device.py
OpeningDevice.set_position
async def set_position(self, position, wait_for_completion=True): """Set window to desired position. Parameters: * position: Position object containing the target position. * wait_for_completion: If set, function will return after device has reached target positi...
python
async def set_position(self, position, wait_for_completion=True): """Set window to desired position. Parameters: * position: Position object containing the target position. * wait_for_completion: If set, function will return after device has reached target positi...
[ "async", "def", "set_position", "(", "self", ",", "position", ",", "wait_for_completion", "=", "True", ")", ":", "command_send", "=", "CommandSend", "(", "pyvlx", "=", "self", ".", "pyvlx", ",", "wait_for_completion", "=", "wait_for_completion", ",", "node_id", ...
Set window to desired position. Parameters: * position: Position object containing the target position. * wait_for_completion: If set, function will return after device has reached target position.
[ "Set", "window", "to", "desired", "position", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L24-L41
Julius2342/pyvlx
pyvlx/opening_device.py
OpeningDevice.open
async def open(self, wait_for_completion=True): """Open window. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ await self.set_position( position=Position(position_percent=0), ...
python
async def open(self, wait_for_completion=True): """Open window. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ await self.set_position( position=Position(position_percent=0), ...
[ "async", "def", "open", "(", "self", ",", "wait_for_completion", "=", "True", ")", ":", "await", "self", ".", "set_position", "(", "position", "=", "Position", "(", "position_percent", "=", "0", ")", ",", "wait_for_completion", "=", "wait_for_completion", ")" ...
Open window. Parameters: * wait_for_completion: If set, function will return after device has reached target position.
[ "Open", "window", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L43-L53
Julius2342/pyvlx
pyvlx/opening_device.py
OpeningDevice.close
async def close(self, wait_for_completion=True): """Close window. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ await self.set_position( position=Position(position_percent=100), ...
python
async def close(self, wait_for_completion=True): """Close window. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ await self.set_position( position=Position(position_percent=100), ...
[ "async", "def", "close", "(", "self", ",", "wait_for_completion", "=", "True", ")", ":", "await", "self", ".", "set_position", "(", "position", "=", "Position", "(", "position_percent", "=", "100", ")", ",", "wait_for_completion", "=", "wait_for_completion", "...
Close window. Parameters: * wait_for_completion: If set, function will return after device has reached target position.
[ "Close", "window", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L55-L65
Julius2342/pyvlx
pyvlx/opening_device.py
OpeningDevice.stop
async def stop(self, wait_for_completion=True): """Stop window. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ await self.set_position( position=CurrentPosition(), wait_fo...
python
async def stop(self, wait_for_completion=True): """Stop window. Parameters: * wait_for_completion: If set, function will return after device has reached target position. """ await self.set_position( position=CurrentPosition(), wait_fo...
[ "async", "def", "stop", "(", "self", ",", "wait_for_completion", "=", "True", ")", ":", "await", "self", ".", "set_position", "(", "position", "=", "CurrentPosition", "(", ")", ",", "wait_for_completion", "=", "wait_for_completion", ")" ]
Stop window. Parameters: * wait_for_completion: If set, function will return after device has reached target position.
[ "Stop", "window", "." ]
train
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/opening_device.py#L67-L77
spacetelescope/synphot_refactor
synphot/models.py
_get_sampleset
def _get_sampleset(model): """Return sampleset of a model or `None` if undefined. Model could be a real model or evaluated sampleset.""" if isinstance(model, Model): if hasattr(model, 'sampleset'): w = model.sampleset() else: w = None else: w = model # Al...
python
def _get_sampleset(model): """Return sampleset of a model or `None` if undefined. Model could be a real model or evaluated sampleset.""" if isinstance(model, Model): if hasattr(model, 'sampleset'): w = model.sampleset() else: w = None else: w = model # Al...
[ "def", "_get_sampleset", "(", "model", ")", ":", "if", "isinstance", "(", "model", ",", "Model", ")", ":", "if", "hasattr", "(", "model", ",", "'sampleset'", ")", ":", "w", "=", "model", ".", "sampleset", "(", ")", "else", ":", "w", "=", "None", "e...
Return sampleset of a model or `None` if undefined. Model could be a real model or evaluated sampleset.
[ "Return", "sampleset", "of", "a", "model", "or", "None", "if", "undefined", ".", "Model", "could", "be", "a", "real", "model", "or", "evaluated", "sampleset", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L654-L664
spacetelescope/synphot_refactor
synphot/models.py
_merge_sampleset
def _merge_sampleset(model1, model2): """Simple merge of samplesets.""" w1 = _get_sampleset(model1) w2 = _get_sampleset(model2) return merge_wavelengths(w1, w2)
python
def _merge_sampleset(model1, model2): """Simple merge of samplesets.""" w1 = _get_sampleset(model1) w2 = _get_sampleset(model2) return merge_wavelengths(w1, w2)
[ "def", "_merge_sampleset", "(", "model1", ",", "model2", ")", ":", "w1", "=", "_get_sampleset", "(", "model1", ")", "w2", "=", "_get_sampleset", "(", "model2", ")", "return", "merge_wavelengths", "(", "w1", ",", "w2", ")" ]
Simple merge of samplesets.
[ "Simple", "merge", "of", "samplesets", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L667-L671
spacetelescope/synphot_refactor
synphot/models.py
_shift_wavelengths
def _shift_wavelengths(model1, model2): """One of the models is either ``RedshiftScaleFactor`` or ``Scale``. Possible combos:: RedshiftScaleFactor | Model Scale | Model Model | Scale """ if isinstance(model1, _models.RedshiftScaleFactor): val = _get_sampleset(model2) ...
python
def _shift_wavelengths(model1, model2): """One of the models is either ``RedshiftScaleFactor`` or ``Scale``. Possible combos:: RedshiftScaleFactor | Model Scale | Model Model | Scale """ if isinstance(model1, _models.RedshiftScaleFactor): val = _get_sampleset(model2) ...
[ "def", "_shift_wavelengths", "(", "model1", ",", "model2", ")", ":", "if", "isinstance", "(", "model1", ",", "_models", ".", "RedshiftScaleFactor", ")", ":", "val", "=", "_get_sampleset", "(", "model2", ")", "if", "val", "is", "None", ":", "w", "=", "val...
One of the models is either ``RedshiftScaleFactor`` or ``Scale``. Possible combos:: RedshiftScaleFactor | Model Scale | Model Model | Scale
[ "One", "of", "the", "models", "is", "either", "RedshiftScaleFactor", "or", "Scale", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L674-L694
spacetelescope/synphot_refactor
synphot/models.py
get_waveset
def get_waveset(model): """Get optimal wavelengths for sampling a given model. Parameters ---------- model : `~astropy.modeling.Model` Model. Returns ------- waveset : array-like or `None` Optimal wavelengths. `None` if undefined. Raises ------ synphot.exceptio...
python
def get_waveset(model): """Get optimal wavelengths for sampling a given model. Parameters ---------- model : `~astropy.modeling.Model` Model. Returns ------- waveset : array-like or `None` Optimal wavelengths. `None` if undefined. Raises ------ synphot.exceptio...
[ "def", "get_waveset", "(", "model", ")", ":", "if", "not", "isinstance", "(", "model", ",", "Model", ")", ":", "raise", "SynphotError", "(", "'{0} is not a model.'", ".", "format", "(", "model", ")", ")", "if", "isinstance", "(", "model", ",", "_CompoundMo...
Get optimal wavelengths for sampling a given model. Parameters ---------- model : `~astropy.modeling.Model` Model. Returns ------- waveset : array-like or `None` Optimal wavelengths. `None` if undefined. Raises ------ synphot.exceptions.SynphotError Invalid...
[ "Get", "optimal", "wavelengths", "for", "sampling", "a", "given", "model", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L708-L735
spacetelescope/synphot_refactor
synphot/models.py
_get_meta
def _get_meta(model): """Return metadata of a model. Model could be a real model or evaluated metadata.""" if isinstance(model, Model): w = model.meta else: w = model # Already metadata return w
python
def _get_meta(model): """Return metadata of a model. Model could be a real model or evaluated metadata.""" if isinstance(model, Model): w = model.meta else: w = model # Already metadata return w
[ "def", "_get_meta", "(", "model", ")", ":", "if", "isinstance", "(", "model", ",", "Model", ")", ":", "w", "=", "model", ".", "meta", "else", ":", "w", "=", "model", "# Already metadata", "return", "w" ]
Return metadata of a model. Model could be a real model or evaluated metadata.
[ "Return", "metadata", "of", "a", "model", ".", "Model", "could", "be", "a", "real", "model", "or", "evaluated", "metadata", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L744-L751
spacetelescope/synphot_refactor
synphot/models.py
_merge_meta
def _merge_meta(model1, model2): """Simple merge of samplesets.""" w1 = _get_meta(model1) w2 = _get_meta(model2) return metadata.merge(w1, w2, metadata_conflicts='silent')
python
def _merge_meta(model1, model2): """Simple merge of samplesets.""" w1 = _get_meta(model1) w2 = _get_meta(model2) return metadata.merge(w1, w2, metadata_conflicts='silent')
[ "def", "_merge_meta", "(", "model1", ",", "model2", ")", ":", "w1", "=", "_get_meta", "(", "model1", ")", "w2", "=", "_get_meta", "(", "model2", ")", "return", "metadata", ".", "merge", "(", "w1", ",", "w2", ",", "metadata_conflicts", "=", "'silent'", ...
Simple merge of samplesets.
[ "Simple", "merge", "of", "samplesets", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L754-L758
spacetelescope/synphot_refactor
synphot/models.py
get_metadata
def get_metadata(model): """Get metadata for a given model. Parameters ---------- model : `~astropy.modeling.Model` Model. Returns ------- metadata : dict Metadata for the model. Raises ------ synphot.exceptions.SynphotError Invalid model. """ ...
python
def get_metadata(model): """Get metadata for a given model. Parameters ---------- model : `~astropy.modeling.Model` Model. Returns ------- metadata : dict Metadata for the model. Raises ------ synphot.exceptions.SynphotError Invalid model. """ ...
[ "def", "get_metadata", "(", "model", ")", ":", "if", "not", "isinstance", "(", "model", ",", "Model", ")", ":", "raise", "SynphotError", "(", "'{0} is not a model.'", ".", "format", "(", "model", ")", ")", "if", "isinstance", "(", "model", ",", "_CompoundM...
Get metadata for a given model. Parameters ---------- model : `~astropy.modeling.Model` Model. Returns ------- metadata : dict Metadata for the model. Raises ------ synphot.exceptions.SynphotError Invalid model.
[ "Get", "metadata", "for", "a", "given", "model", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L761-L788
spacetelescope/synphot_refactor
synphot/models.py
BlackBody1D.lambda_max
def lambda_max(self): """Peak wavelength in Angstrom when the curve is expressed as power density.""" return ((const.b_wien.value / self.temperature) * u.m).to(u.AA).value
python
def lambda_max(self): """Peak wavelength in Angstrom when the curve is expressed as power density.""" return ((const.b_wien.value / self.temperature) * u.m).to(u.AA).value
[ "def", "lambda_max", "(", "self", ")", ":", "return", "(", "(", "const", ".", "b_wien", ".", "value", "/", "self", ".", "temperature", ")", "*", "u", ".", "m", ")", ".", "to", "(", "u", ".", "AA", ")", ".", "value" ]
Peak wavelength in Angstrom when the curve is expressed as power density.
[ "Peak", "wavelength", "in", "Angstrom", "when", "the", "curve", "is", "expressed", "as", "power", "density", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L53-L56
spacetelescope/synphot_refactor
synphot/models.py
BlackBody1D.bounding_box
def bounding_box(self, factor=10.0): """Tuple defining the default ``bounding_box`` limits, ``(x_low, x_high)``. .. math:: x_{\\textnormal{low}} = 0 x_{\\textnormal{high}} = \\log(\\lambda_{\\textnormal{max}} \\;\ (1 + \\textnormal{factor})) Parame...
python
def bounding_box(self, factor=10.0): """Tuple defining the default ``bounding_box`` limits, ``(x_low, x_high)``. .. math:: x_{\\textnormal{low}} = 0 x_{\\textnormal{high}} = \\log(\\lambda_{\\textnormal{max}} \\;\ (1 + \\textnormal{factor})) Parame...
[ "def", "bounding_box", "(", "self", ",", "factor", "=", "10.0", ")", ":", "w0", "=", "self", ".", "lambda_max", "return", "(", "w0", "*", "0", ",", "np", ".", "log10", "(", "w0", "+", "factor", "*", "w0", ")", ")" ]
Tuple defining the default ``bounding_box`` limits, ``(x_low, x_high)``. .. math:: x_{\\textnormal{low}} = 0 x_{\\textnormal{high}} = \\log(\\lambda_{\\textnormal{max}} \\;\ (1 + \\textnormal{factor})) Parameters ---------- factor : float ...
[ "Tuple", "defining", "the", "default", "bounding_box", "limits", "(", "x_low", "x_high", ")", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L58-L76
spacetelescope/synphot_refactor
synphot/models.py
BlackBody1D.sampleset
def sampleset(self, factor_bbox=10.0, num=1000): """Return ``x`` array that samples the feature. Parameters ---------- factor_bbox : float Factor for ``bounding_box`` calculations. num : int Number of points to generate. """ w1, w2 = sel...
python
def sampleset(self, factor_bbox=10.0, num=1000): """Return ``x`` array that samples the feature. Parameters ---------- factor_bbox : float Factor for ``bounding_box`` calculations. num : int Number of points to generate. """ w1, w2 = sel...
[ "def", "sampleset", "(", "self", ",", "factor_bbox", "=", "10.0", ",", "num", "=", "1000", ")", ":", "w1", ",", "w2", "=", "self", ".", "bounding_box", "(", "factor", "=", "factor_bbox", ")", "if", "self", ".", "_n_models", "==", "1", ":", "w", "="...
Return ``x`` array that samples the feature. Parameters ---------- factor_bbox : float Factor for ``bounding_box`` calculations. num : int Number of points to generate.
[ "Return", "x", "array", "that", "samples", "the", "feature", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L78-L97
spacetelescope/synphot_refactor
synphot/models.py
BlackBody1D.evaluate
def evaluate(x, temperature): """Evaluate the model. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. temperature : number Temperature in Kelvin. Returns ------- y : number or ndarray Blackbody rad...
python
def evaluate(x, temperature): """Evaluate the model. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. temperature : number Temperature in Kelvin. Returns ------- y : number or ndarray Blackbody rad...
[ "def", "evaluate", "(", "x", ",", "temperature", ")", ":", "if", "ASTROPY_LT_2_0", ":", "from", "astropy", ".", "analytic_functions", ".", "blackbody", "import", "blackbody_nu", "else", ":", "from", "astropy", ".", "modeling", ".", "blackbody", "import", "blac...
Evaluate the model. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. temperature : number Temperature in Kelvin. Returns ------- y : number or ndarray Blackbody radiation in PHOTLAM per steradian.
[ "Evaluate", "the", "model", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L100-L133
spacetelescope/synphot_refactor
synphot/models.py
BlackBodyNorm1D.evaluate
def evaluate(self, x, temperature): """Evaluate the model. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. temperature : number Temperature in Kelvin. Returns ------- y : number or ndarray Blackbo...
python
def evaluate(self, x, temperature): """Evaluate the model. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. temperature : number Temperature in Kelvin. Returns ------- y : number or ndarray Blackbo...
[ "def", "evaluate", "(", "self", ",", "x", ",", "temperature", ")", ":", "bbflux", "=", "super", "(", "BlackBodyNorm1D", ",", "self", ")", ".", "evaluate", "(", "x", ",", "temperature", ")", "return", "bbflux", "*", "self", ".", "_omega" ]
Evaluate the model. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. temperature : number Temperature in Kelvin. Returns ------- y : number or ndarray Blackbody radiation in PHOTLAM.
[ "Evaluate", "the", "model", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L157-L175
spacetelescope/synphot_refactor
synphot/models.py
Box1D._calc_sampleset
def _calc_sampleset(w1, w2, step, minimal): """Calculate sampleset for each model.""" if minimal: arr = [w1 - step, w1, w2, w2 + step] else: arr = np.arange(w1 - step, w2 + step + step, step) return arr
python
def _calc_sampleset(w1, w2, step, minimal): """Calculate sampleset for each model.""" if minimal: arr = [w1 - step, w1, w2, w2 + step] else: arr = np.arange(w1 - step, w2 + step + step, step) return arr
[ "def", "_calc_sampleset", "(", "w1", ",", "w2", ",", "step", ",", "minimal", ")", ":", "if", "minimal", ":", "arr", "=", "[", "w1", "-", "step", ",", "w1", ",", "w2", ",", "w2", "+", "step", "]", "else", ":", "arr", "=", "np", ".", "arange", ...
Calculate sampleset for each model.
[ "Calculate", "sampleset", "for", "each", "model", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L184-L191
spacetelescope/synphot_refactor
synphot/models.py
Box1D.sampleset
def sampleset(self, step=0.01, minimal=False): """Return ``x`` array that samples the feature. Parameters ---------- step : float Distance of first and last points w.r.t. bounding box. minimal : bool Only return the minimal points needed to define the bo...
python
def sampleset(self, step=0.01, minimal=False): """Return ``x`` array that samples the feature. Parameters ---------- step : float Distance of first and last points w.r.t. bounding box. minimal : bool Only return the minimal points needed to define the bo...
[ "def", "sampleset", "(", "self", ",", "step", "=", "0.01", ",", "minimal", "=", "False", ")", ":", "w1", ",", "w2", "=", "self", ".", "bounding_box", "if", "self", ".", "_n_models", "==", "1", ":", "w", "=", "self", ".", "_calc_sampleset", "(", "w1...
Return ``x`` array that samples the feature. Parameters ---------- step : float Distance of first and last points w.r.t. bounding box. minimal : bool Only return the minimal points needed to define the box; i.e., box edges and a point outside on each...
[ "Return", "x", "array", "that", "samples", "the", "feature", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L193-L214
spacetelescope/synphot_refactor
synphot/models.py
ConstFlux1D.evaluate
def evaluate(self, x, *args): """One dimensional constant flux model function. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. Returns ------- y : number or ndarray Flux in PHOTLAM. """ a = (self.ampl...
python
def evaluate(self, x, *args): """One dimensional constant flux model function. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. Returns ------- y : number or ndarray Flux in PHOTLAM. """ a = (self.ampl...
[ "def", "evaluate", "(", "self", ",", "x", ",", "*", "args", ")", ":", "a", "=", "(", "self", ".", "amplitude", "*", "np", ".", "ones_like", "(", "x", ")", ")", "*", "self", ".", "_flux_unit", "y", "=", "units", ".", "convert_flux", "(", "x", ",...
One dimensional constant flux model function. Parameters ---------- x : number or ndarray Wavelengths in Angstrom. Returns ------- y : number or ndarray Flux in PHOTLAM.
[ "One", "dimensional", "constant", "flux", "model", "function", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L252-L268
spacetelescope/synphot_refactor
synphot/models.py
Empirical1D._process_neg_flux
def _process_neg_flux(self, x, y): """Remove negative flux.""" if self._keep_neg: # Nothing to do return y old_y = None if np.isscalar(y): # pragma: no cover if y < 0: n_neg = 1 old_x = x old_y = y ...
python
def _process_neg_flux(self, x, y): """Remove negative flux.""" if self._keep_neg: # Nothing to do return y old_y = None if np.isscalar(y): # pragma: no cover if y < 0: n_neg = 1 old_x = x old_y = y ...
[ "def", "_process_neg_flux", "(", "self", ",", "x", ",", "y", ")", ":", "if", "self", ".", "_keep_neg", ":", "# Nothing to do", "return", "y", "old_y", "=", "None", "if", "np", ".", "isscalar", "(", "y", ")", ":", "# pragma: no cover", "if", "y", "<", ...
Remove negative flux.
[ "Remove", "negative", "flux", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L328-L360
spacetelescope/synphot_refactor
synphot/models.py
Empirical1D.evaluate
def evaluate(self, inputs): """Evaluate the model. Parameters ---------- inputs : number or ndarray Wavelengths in same unit as ``points``. Returns ------- y : number or ndarray Flux or throughput in same unit as ``lookup_table``. ...
python
def evaluate(self, inputs): """Evaluate the model. Parameters ---------- inputs : number or ndarray Wavelengths in same unit as ``points``. Returns ------- y : number or ndarray Flux or throughput in same unit as ``lookup_table``. ...
[ "def", "evaluate", "(", "self", ",", "inputs", ")", ":", "y", "=", "super", "(", "Empirical1D", ",", "self", ")", ".", "evaluate", "(", "inputs", ")", "# Assume NaN at both ends need to be extrapolated based on", "# nearest end point.", "if", "self", ".", "fill_va...
Evaluate the model. Parameters ---------- inputs : number or ndarray Wavelengths in same unit as ``points``. Returns ------- y : number or ndarray Flux or throughput in same unit as ``lookup_table``.
[ "Evaluate", "the", "model", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L370-L401
spacetelescope/synphot_refactor
synphot/models.py
GaussianAbsorption1D.evaluate
def evaluate(x, amplitude, mean, stddev): """ GaussianAbsorption1D model function. """ return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev)
python
def evaluate(x, amplitude, mean, stddev): """ GaussianAbsorption1D model function. """ return 1.0 - Gaussian1D.evaluate(x, amplitude, mean, stddev)
[ "def", "evaluate", "(", "x", ",", "amplitude", ",", "mean", ",", "stddev", ")", ":", "return", "1.0", "-", "Gaussian1D", ".", "evaluate", "(", "x", ",", "amplitude", ",", "mean", ",", "stddev", ")" ]
GaussianAbsorption1D model function.
[ "GaussianAbsorption1D", "model", "function", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L452-L456
spacetelescope/synphot_refactor
synphot/models.py
GaussianAbsorption1D.fit_deriv
def fit_deriv(x, amplitude, mean, stddev): """ GaussianAbsorption1D model function derivatives. """ import operator return list(map( operator.neg, Gaussian1D.fit_deriv(x, amplitude, mean, stddev)))
python
def fit_deriv(x, amplitude, mean, stddev): """ GaussianAbsorption1D model function derivatives. """ import operator return list(map( operator.neg, Gaussian1D.fit_deriv(x, amplitude, mean, stddev)))
[ "def", "fit_deriv", "(", "x", ",", "amplitude", ",", "mean", ",", "stddev", ")", ":", "import", "operator", "return", "list", "(", "map", "(", "operator", ".", "neg", ",", "Gaussian1D", ".", "fit_deriv", "(", "x", ",", "amplitude", ",", "mean", ",", ...
GaussianAbsorption1D model function derivatives.
[ "GaussianAbsorption1D", "model", "function", "derivatives", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L459-L465
spacetelescope/synphot_refactor
synphot/models.py
Lorentz1D.sampleset
def sampleset(self, factor_step=0.05, **kwargs): """Return ``x`` array that samples the feature. Parameters ---------- factor_step : float Factor for sample step calculation. The step is calculated using ``factor_step * self.fwhm``. kwargs : dict ...
python
def sampleset(self, factor_step=0.05, **kwargs): """Return ``x`` array that samples the feature. Parameters ---------- factor_step : float Factor for sample step calculation. The step is calculated using ``factor_step * self.fwhm``. kwargs : dict ...
[ "def", "sampleset", "(", "self", ",", "factor_step", "=", "0.05", ",", "*", "*", "kwargs", ")", ":", "w1", ",", "w2", "=", "self", ".", "bounding_box", "(", "*", "*", "kwargs", ")", "dw", "=", "factor_step", "*", "self", ".", "fwhm", "if", "self", ...
Return ``x`` array that samples the feature. Parameters ---------- factor_step : float Factor for sample step calculation. The step is calculated using ``factor_step * self.fwhm``. kwargs : dict Keyword(s) for ``bounding_box`` calculation.
[ "Return", "x", "array", "that", "samples", "the", "feature", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L530-L551
spacetelescope/synphot_refactor
synphot/models.py
PowerLawFlux1D.evaluate
def evaluate(self, x, *args): """Return flux in PHOTLAM. Assume input wavelength is in Angstrom.""" xx = x / self.x_0 y = (self.amplitude * xx ** (-self.alpha)) * self._flux_unit flux = units.convert_flux(x, y, units.PHOTLAM) return flux.value
python
def evaluate(self, x, *args): """Return flux in PHOTLAM. Assume input wavelength is in Angstrom.""" xx = x / self.x_0 y = (self.amplitude * xx ** (-self.alpha)) * self._flux_unit flux = units.convert_flux(x, y, units.PHOTLAM) return flux.value
[ "def", "evaluate", "(", "self", ",", "x", ",", "*", "args", ")", ":", "xx", "=", "x", "/", "self", ".", "x_0", "y", "=", "(", "self", ".", "amplitude", "*", "xx", "**", "(", "-", "self", ".", "alpha", ")", ")", "*", "self", ".", "_flux_unit",...
Return flux in PHOTLAM. Assume input wavelength is in Angstrom.
[ "Return", "flux", "in", "PHOTLAM", ".", "Assume", "input", "wavelength", "is", "in", "Angstrom", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L624-L629
spacetelescope/synphot_refactor
synphot/models.py
Trapezoid1D.sampleset
def sampleset(self): """Return ``x`` array that samples the feature.""" x1, x4 = self.bounding_box dw = self.width * 0.5 x2 = self.x_0 - dw x3 = self.x_0 + dw if self._n_models == 1: w = [x1, x2, x3, x4] else: w = list(zip(x1, x2, x3, x4))...
python
def sampleset(self): """Return ``x`` array that samples the feature.""" x1, x4 = self.bounding_box dw = self.width * 0.5 x2 = self.x_0 - dw x3 = self.x_0 + dw if self._n_models == 1: w = [x1, x2, x3, x4] else: w = list(zip(x1, x2, x3, x4))...
[ "def", "sampleset", "(", "self", ")", ":", "x1", ",", "x4", "=", "self", ".", "bounding_box", "dw", "=", "self", ".", "width", "*", "0.5", "x2", "=", "self", ".", "x_0", "-", "dw", "x3", "=", "self", ".", "x_0", "+", "dw", "if", "self", ".", ...
Return ``x`` array that samples the feature.
[ "Return", "x", "array", "that", "samples", "the", "feature", "." ]
train
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/models.py#L637-L649
awesto/djangoshop-stripe
shop_stripe/payment.py
StripePayment.get_payment_request
def get_payment_request(self, cart, request): """ From the given request, add a snippet to the page. """ try: self.charge(cart, request) thank_you_url = OrderModel.objects.get_latest_url() js_expression = 'window.location.href="{}";'.format(thank_you_u...
python
def get_payment_request(self, cart, request): """ From the given request, add a snippet to the page. """ try: self.charge(cart, request) thank_you_url = OrderModel.objects.get_latest_url() js_expression = 'window.location.href="{}";'.format(thank_you_u...
[ "def", "get_payment_request", "(", "self", ",", "cart", ",", "request", ")", ":", "try", ":", "self", ".", "charge", "(", "cart", ",", "request", ")", "thank_you_url", "=", "OrderModel", ".", "objects", ".", "get_latest_url", "(", ")", "js_expression", "="...
From the given request, add a snippet to the page.
[ "From", "the", "given", "request", "add", "a", "snippet", "to", "the", "page", "." ]
train
https://github.com/awesto/djangoshop-stripe/blob/010d4642f971961cfeb415520ad819b3751281cb/shop_stripe/payment.py#L28-L38