repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
Julius2342/pyvlx
pyvlx/connection.py
Connection.connect
async def connect(self): """Connect to gateway via SSL.""" tcp_client = TCPTransport(self.frame_received_cb, self.connection_closed_cb) self.transport, _ = await self.loop.create_connection( lambda: tcp_client, host=self.config.host, port=self.config.port, ...
python
async def connect(self): """Connect to gateway via SSL.""" tcp_client = TCPTransport(self.frame_received_cb, self.connection_closed_cb) self.transport, _ = await self.loop.create_connection( lambda: tcp_client, host=self.config.host, port=self.config.port, ...
[ "async", "def", "connect", "(", "self", ")", ":", "tcp_client", "=", "TCPTransport", "(", "self", ".", "frame_received_cb", ",", "self", ".", "connection_closed_cb", ")", "self", ".", "transport", ",", "_", "=", "await", "self", ".", "loop", ".", "create_c...
Connect to gateway via SSL.
[ "Connect", "to", "gateway", "via", "SSL", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/connection.py#L82-L90
train
Julius2342/pyvlx
pyvlx/connection.py
Connection.write
def write(self, frame): """Write frame to Bus.""" if not isinstance(frame, FrameBase): raise PyVLXException("Frame not of type FrameBase", frame_type=type(frame)) PYVLXLOG.debug("SEND: %s", frame) self.transport.write(slip_pack(bytes(frame)))
python
def write(self, frame): """Write frame to Bus.""" if not isinstance(frame, FrameBase): raise PyVLXException("Frame not of type FrameBase", frame_type=type(frame)) PYVLXLOG.debug("SEND: %s", frame) self.transport.write(slip_pack(bytes(frame)))
[ "def", "write", "(", "self", ",", "frame", ")", ":", "if", "not", "isinstance", "(", "frame", ",", "FrameBase", ")", ":", "raise", "PyVLXException", "(", "\"Frame not of type FrameBase\"", ",", "frame_type", "=", "type", "(", "frame", ")", ")", "PYVLXLOG", ...
Write frame to Bus.
[ "Write", "frame", "to", "Bus", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/connection.py#L100-L105
train
Julius2342/pyvlx
pyvlx/connection.py
Connection.create_ssl_context
def create_ssl_context(): """Create and return SSL Context.""" ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE return ssl_context
python
def create_ssl_context(): """Create and return SSL Context.""" ssl_context = ssl.create_default_context(ssl.Purpose.SERVER_AUTH) ssl_context.check_hostname = False ssl_context.verify_mode = ssl.CERT_NONE return ssl_context
[ "def", "create_ssl_context", "(", ")", ":", "ssl_context", "=", "ssl", ".", "create_default_context", "(", "ssl", ".", "Purpose", ".", "SERVER_AUTH", ")", "ssl_context", ".", "check_hostname", "=", "False", "ssl_context", ".", "verify_mode", "=", "ssl", ".", "...
Create and return SSL Context.
[ "Create", "and", "return", "SSL", "Context", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/connection.py#L108-L113
train
Julius2342/pyvlx
pyvlx/connection.py
Connection.frame_received_cb
def frame_received_cb(self, frame): """Received message.""" PYVLXLOG.debug("REC: %s", frame) for frame_received_cb in self.frame_received_cbs: # pylint: disable=not-callable self.loop.create_task(frame_received_cb(frame))
python
def frame_received_cb(self, frame): """Received message.""" PYVLXLOG.debug("REC: %s", frame) for frame_received_cb in self.frame_received_cbs: # pylint: disable=not-callable self.loop.create_task(frame_received_cb(frame))
[ "def", "frame_received_cb", "(", "self", ",", "frame", ")", ":", "PYVLXLOG", ".", "debug", "(", "\"REC: %s\"", ",", "frame", ")", "for", "frame_received_cb", "in", "self", ".", "frame_received_cbs", ":", "# pylint: disable=not-callable", "self", ".", "loop", "."...
Received message.
[ "Received", "message", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/connection.py#L115-L120
train
Julius2342/pyvlx
old_api/pyvlx/config.py
Config.read_config
def read_config(self, path): """Read configuration file.""" self.pyvlx.logger.info('Reading config file: ', path) try: with open(path, 'r') as filehandle: doc = yaml.load(filehandle) if 'config' not in doc: raise PyVLXException('no ...
python
def read_config(self, path): """Read configuration file.""" self.pyvlx.logger.info('Reading config file: ', path) try: with open(path, 'r') as filehandle: doc = yaml.load(filehandle) if 'config' not in doc: raise PyVLXException('no ...
[ "def", "read_config", "(", "self", ",", "path", ")", ":", "self", ".", "pyvlx", ".", "logger", ".", "info", "(", "'Reading config file: '", ",", "path", ")", "try", ":", "with", "open", "(", "path", ",", "'r'", ")", "as", "filehandle", ":", "doc", "=...
Read configuration file.
[ "Read", "configuration", "file", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/config.py#L19-L34
train
Julius2342/pyvlx
pyvlx/node_updater.py
NodeUpdater.process_frame
async def process_frame(self, frame): """Update nodes via frame, usually received by house monitor.""" if isinstance(frame, FrameNodeStatePositionChangedNotification): if frame.node_id not in self.pyvlx.nodes: return node = self.pyvlx.nodes[frame.node_id] ...
python
async def process_frame(self, frame): """Update nodes via frame, usually received by house monitor.""" if isinstance(frame, FrameNodeStatePositionChangedNotification): if frame.node_id not in self.pyvlx.nodes: return node = self.pyvlx.nodes[frame.node_id] ...
[ "async", "def", "process_frame", "(", "self", ",", "frame", ")", ":", "if", "isinstance", "(", "frame", ",", "FrameNodeStatePositionChangedNotification", ")", ":", "if", "frame", ".", "node_id", "not", "in", "self", ".", "pyvlx", ".", "nodes", ":", "return",...
Update nodes via frame, usually received by house monitor.
[ "Update", "nodes", "via", "frame", "usually", "received", "by", "house", "monitor", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/node_updater.py#L14-L29
train
Julius2342/pyvlx
pyvlx/scenes.py
Scenes.add
def add(self, scene): """Add scene, replace existing scene if scene with scene_id is present.""" if not isinstance(scene, Scene): raise TypeError() for i, j in enumerate(self.__scenes): if j.scene_id == scene.scene_id: self.__scenes[i] = scene ...
python
def add(self, scene): """Add scene, replace existing scene if scene with scene_id is present.""" if not isinstance(scene, Scene): raise TypeError() for i, j in enumerate(self.__scenes): if j.scene_id == scene.scene_id: self.__scenes[i] = scene ...
[ "def", "add", "(", "self", ",", "scene", ")", ":", "if", "not", "isinstance", "(", "scene", ",", "Scene", ")", ":", "raise", "TypeError", "(", ")", "for", "i", ",", "j", "in", "enumerate", "(", "self", ".", "__scenes", ")", ":", "if", "j", ".", ...
Add scene, replace existing scene if scene with scene_id is present.
[ "Add", "scene", "replace", "existing", "scene", "if", "scene", "with", "scene_id", "is", "present", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/scenes.py#L34-L42
train
Julius2342/pyvlx
pyvlx/scenes.py
Scenes.load
async def load(self): """Load scenes from KLF 200.""" get_scene_list = GetSceneList(pyvlx=self.pyvlx) await get_scene_list.do_api_call() if not get_scene_list.success: raise PyVLXException("Unable to retrieve scene information") for scene in get_scene_list.scenes: ...
python
async def load(self): """Load scenes from KLF 200.""" get_scene_list = GetSceneList(pyvlx=self.pyvlx) await get_scene_list.do_api_call() if not get_scene_list.success: raise PyVLXException("Unable to retrieve scene information") for scene in get_scene_list.scenes: ...
[ "async", "def", "load", "(", "self", ")", ":", "get_scene_list", "=", "GetSceneList", "(", "pyvlx", "=", "self", ".", "pyvlx", ")", "await", "get_scene_list", ".", "do_api_call", "(", ")", "if", "not", "get_scene_list", ".", "success", ":", "raise", "PyVLX...
Load scenes from KLF 200.
[ "Load", "scenes", "from", "KLF", "200", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/scenes.py#L48-L55
train
tbielawa/bitmath
bitmath/__init__.py
best_prefix
def best_prefix(bytes, system=NIST): """Return a bitmath instance representing the best human-readable representation of the number of bytes given by ``bytes``. In addition to a numeric type, the ``bytes`` parameter may also be a bitmath type. Optionally select a preferred unit system by specifying the ``system`` ...
python
def best_prefix(bytes, system=NIST): """Return a bitmath instance representing the best human-readable representation of the number of bytes given by ``bytes``. In addition to a numeric type, the ``bytes`` parameter may also be a bitmath type. Optionally select a preferred unit system by specifying the ``system`` ...
[ "def", "best_prefix", "(", "bytes", ",", "system", "=", "NIST", ")", ":", "if", "isinstance", "(", "bytes", ",", "Bitmath", ")", ":", "value", "=", "bytes", ".", "bytes", "else", ":", "value", "=", "bytes", "return", "Byte", "(", "value", ")", ".", ...
Return a bitmath instance representing the best human-readable representation of the number of bytes given by ``bytes``. In addition to a numeric type, the ``bytes`` parameter may also be a bitmath type. Optionally select a preferred unit system by specifying the ``system`` keyword. Choices for ``system`` are ``bitmat...
[ "Return", "a", "bitmath", "instance", "representing", "the", "best", "human", "-", "readable", "representation", "of", "the", "number", "of", "bytes", "given", "by", "bytes", ".", "In", "addition", "to", "a", "numeric", "type", "the", "bytes", "parameter", "...
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1174-L1198
train
tbielawa/bitmath
bitmath/__init__.py
query_device_capacity
def query_device_capacity(device_fd): """Create bitmath instances of the capacity of a system block device Make one or more ioctl request to query the capacity of a block device. Perform any processing required to compute the final capacity value. Return the device capacity in bytes as a :class:`bitmath.Byte` inst...
python
def query_device_capacity(device_fd): """Create bitmath instances of the capacity of a system block device Make one or more ioctl request to query the capacity of a block device. Perform any processing required to compute the final capacity value. Return the device capacity in bytes as a :class:`bitmath.Byte` inst...
[ "def", "query_device_capacity", "(", "device_fd", ")", ":", "if", "os_name", "(", ")", "!=", "'posix'", ":", "raise", "NotImplementedError", "(", "\"'bitmath.query_device_capacity' is not supported on this platform: %s\"", "%", "os_name", "(", ")", ")", "s", "=", "os"...
Create bitmath instances of the capacity of a system block device Make one or more ioctl request to query the capacity of a block device. Perform any processing required to compute the final capacity value. Return the device capacity in bytes as a :class:`bitmath.Byte` instance. Thanks to the following resources for ...
[ "Create", "bitmath", "instances", "of", "the", "capacity", "of", "a", "system", "block", "device" ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1201-L1331
train
tbielawa/bitmath
bitmath/__init__.py
getsize
def getsize(path, bestprefix=True, system=NIST): """Return a bitmath instance in the best human-readable representation of the file size at `path`. Optionally, provide a preferred unit system by setting `system` to either `bitmath.NIST` (default) or `bitmath.SI`. Optionally, set ``bestprefix`` to ``False`` to get ...
python
def getsize(path, bestprefix=True, system=NIST): """Return a bitmath instance in the best human-readable representation of the file size at `path`. Optionally, provide a preferred unit system by setting `system` to either `bitmath.NIST` (default) or `bitmath.SI`. Optionally, set ``bestprefix`` to ``False`` to get ...
[ "def", "getsize", "(", "path", ",", "bestprefix", "=", "True", ",", "system", "=", "NIST", ")", ":", "_path", "=", "os", ".", "path", ".", "realpath", "(", "path", ")", "size_bytes", "=", "os", ".", "path", ".", "getsize", "(", "_path", ")", "if", ...
Return a bitmath instance in the best human-readable representation of the file size at `path`. Optionally, provide a preferred unit system by setting `system` to either `bitmath.NIST` (default) or `bitmath.SI`. Optionally, set ``bestprefix`` to ``False`` to get ``bitmath.Byte`` instances back.
[ "Return", "a", "bitmath", "instance", "in", "the", "best", "human", "-", "readable", "representation", "of", "the", "file", "size", "at", "path", ".", "Optionally", "provide", "a", "preferred", "unit", "system", "by", "setting", "system", "to", "either", "bi...
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1334-L1348
train
tbielawa/bitmath
bitmath/__init__.py
listdir
def listdir(search_base, followlinks=False, filter='*', relpath=False, bestprefix=False, system=NIST): """This is a generator which recurses the directory tree `search_base`, yielding 2-tuples of: * The absolute/relative path to a discovered file * A bitmath instance representing the "apparent size" of...
python
def listdir(search_base, followlinks=False, filter='*', relpath=False, bestprefix=False, system=NIST): """This is a generator which recurses the directory tree `search_base`, yielding 2-tuples of: * The absolute/relative path to a discovered file * A bitmath instance representing the "apparent size" of...
[ "def", "listdir", "(", "search_base", ",", "followlinks", "=", "False", ",", "filter", "=", "'*'", ",", "relpath", "=", "False", ",", "bestprefix", "=", "False", ",", "system", "=", "NIST", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "o...
This is a generator which recurses the directory tree `search_base`, yielding 2-tuples of: * The absolute/relative path to a discovered file * A bitmath instance representing the "apparent size" of the file. - `search_base` - The directory to begin walking down. - `followlinks` - Whether or not to follow symb...
[ "This", "is", "a", "generator", "which", "recurses", "the", "directory", "tree", "search_base", "yielding", "2", "-", "tuples", "of", ":" ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1351-L1391
train
tbielawa/bitmath
bitmath/__init__.py
parse_string
def parse_string(s): """Parse a string with units and try to make a bitmath object out of it. String inputs may include whitespace characters between the value and the unit. """ # Strings only please if not isinstance(s, (str, unicode)): raise ValueError("parse_string only accepts string inputs...
python
def parse_string(s): """Parse a string with units and try to make a bitmath object out of it. String inputs may include whitespace characters between the value and the unit. """ # Strings only please if not isinstance(s, (str, unicode)): raise ValueError("parse_string only accepts string inputs...
[ "def", "parse_string", "(", "s", ")", ":", "# Strings only please", "if", "not", "isinstance", "(", "s", ",", "(", "str", ",", "unicode", ")", ")", ":", "raise", "ValueError", "(", "\"parse_string only accepts string inputs but a %s was given\"", "%", "type", "(",...
Parse a string with units and try to make a bitmath object out of it. String inputs may include whitespace characters between the value and the unit.
[ "Parse", "a", "string", "with", "units", "and", "try", "to", "make", "a", "bitmath", "object", "out", "of", "it", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1394-L1434
train
tbielawa/bitmath
bitmath/__init__.py
parse_string_unsafe
def parse_string_unsafe(s, system=SI): """Attempt to parse a string with ambiguous units and try to make a bitmath object out of it. This may produce inaccurate results if parsing shell output. For example `ls` may say a 2730 Byte file is '2.7K'. 2730 Bytes == 2.73 kB ~= 2.666 KiB. See the documentation for all of...
python
def parse_string_unsafe(s, system=SI): """Attempt to parse a string with ambiguous units and try to make a bitmath object out of it. This may produce inaccurate results if parsing shell output. For example `ls` may say a 2730 Byte file is '2.7K'. 2730 Bytes == 2.73 kB ~= 2.666 KiB. See the documentation for all of...
[ "def", "parse_string_unsafe", "(", "s", ",", "system", "=", "SI", ")", ":", "if", "not", "isinstance", "(", "s", ",", "(", "str", ",", "unicode", ")", ")", "and", "not", "isinstance", "(", "s", ",", "numbers", ".", "Number", ")", ":", "raise", "Val...
Attempt to parse a string with ambiguous units and try to make a bitmath object out of it. This may produce inaccurate results if parsing shell output. For example `ls` may say a 2730 Byte file is '2.7K'. 2730 Bytes == 2.73 kB ~= 2.666 KiB. See the documentation for all of the important details. Note the following ca...
[ "Attempt", "to", "parse", "a", "string", "with", "ambiguous", "units", "and", "try", "to", "make", "a", "bitmath", "object", "out", "of", "it", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1437-L1559
train
tbielawa/bitmath
bitmath/__init__.py
format
def format(fmt_str=None, plural=False, bestprefix=False): """Context manager for printing bitmath instances. ``fmt_str`` - a formatting mini-language compat formatting string. See the @properties (above) for a list of available items. ``plural`` - True enables printing instances with 's's if they're plural. False...
python
def format(fmt_str=None, plural=False, bestprefix=False): """Context manager for printing bitmath instances. ``fmt_str`` - a formatting mini-language compat formatting string. See the @properties (above) for a list of available items. ``plural`` - True enables printing instances with 's's if they're plural. False...
[ "def", "format", "(", "fmt_str", "=", "None", ",", "plural", "=", "False", ",", "bestprefix", "=", "False", ")", ":", "if", "'bitmath'", "not", "in", "globals", "(", ")", ":", "import", "bitmath", "if", "plural", ":", "orig_fmt_plural", "=", "bitmath", ...
Context manager for printing bitmath instances. ``fmt_str`` - a formatting mini-language compat formatting string. See the @properties (above) for a list of available items. ``plural`` - True enables printing instances with 's's if they're plural. False (default) prints them as singular (no trailing 's'). ``bestpref...
[ "Context", "manager", "for", "printing", "bitmath", "instances", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1565-L1595
train
tbielawa/bitmath
bitmath/__init__.py
cli_script_main
def cli_script_main(cli_args): """ A command line interface to basic bitmath operations. """ choices = ALL_UNIT_TYPES parser = argparse.ArgumentParser( description='Converts from one type of size to another.') parser.add_argument('--from-stdin', default=False, action='store_true', ...
python
def cli_script_main(cli_args): """ A command line interface to basic bitmath operations. """ choices = ALL_UNIT_TYPES parser = argparse.ArgumentParser( description='Converts from one type of size to another.') parser.add_argument('--from-stdin', default=False, action='store_true', ...
[ "def", "cli_script_main", "(", "cli_args", ")", ":", "choices", "=", "ALL_UNIT_TYPES", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Converts from one type of size to another.'", ")", "parser", ".", "add_argument", "(", "'--from-stdin'", ...
A command line interface to basic bitmath operations.
[ "A", "command", "line", "interface", "to", "basic", "bitmath", "operations", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1598-L1643
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath._do_setup
def _do_setup(self): """Setup basic parameters for this class. `base` is the numeric base which when raised to `power` is equivalent to 1 unit of the corresponding prefix. I.e., base=2, power=10 represents 2^10, which is the NIST Binary Prefix for 1 Kibibyte. Likewise, for the SI prefix classes `base` will be...
python
def _do_setup(self): """Setup basic parameters for this class. `base` is the numeric base which when raised to `power` is equivalent to 1 unit of the corresponding prefix. I.e., base=2, power=10 represents 2^10, which is the NIST Binary Prefix for 1 Kibibyte. Likewise, for the SI prefix classes `base` will be...
[ "def", "_do_setup", "(", "self", ")", ":", "(", "self", ".", "_base", ",", "self", ".", "_power", ",", "self", ".", "_name_singular", ",", "self", ".", "_name_plural", ")", "=", "self", ".", "_setup", "(", ")", "self", ".", "_unit_value", "=", "self"...
Setup basic parameters for this class. `base` is the numeric base which when raised to `power` is equivalent to 1 unit of the corresponding prefix. I.e., base=2, power=10 represents 2^10, which is the NIST Binary Prefix for 1 Kibibyte. Likewise, for the SI prefix classes `base` will be 10, and the `power` for the Kil...
[ "Setup", "basic", "parameters", "for", "this", "class", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L239-L250
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath._norm
def _norm(self, value): """Normalize the input value into the fundamental unit for this prefix type. :param number value: The input value to be normalized :raises ValueError: if the input value is not a type of real number """ if isinstance(value, self.valid_types): self._byte_value =...
python
def _norm(self, value): """Normalize the input value into the fundamental unit for this prefix type. :param number value: The input value to be normalized :raises ValueError: if the input value is not a type of real number """ if isinstance(value, self.valid_types): self._byte_value =...
[ "def", "_norm", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "self", ".", "valid_types", ")", ":", "self", ".", "_byte_value", "=", "value", "*", "self", ".", "_unit_value", "self", ".", "_bit_value", "=", "self", ".", ...
Normalize the input value into the fundamental unit for this prefix type. :param number value: The input value to be normalized :raises ValueError: if the input value is not a type of real number
[ "Normalize", "the", "input", "value", "into", "the", "fundamental", "unit", "for", "this", "prefix", "type", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L252-L267
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath.system
def system(self): """The system of units used to measure an instance""" if self._base == 2: return "NIST" elif self._base == 10: return "SI" else: # I don't expect to ever encounter this logic branch, but # hey, it's better to have extra te...
python
def system(self): """The system of units used to measure an instance""" if self._base == 2: return "NIST" elif self._base == 10: return "SI" else: # I don't expect to ever encounter this logic branch, but # hey, it's better to have extra te...
[ "def", "system", "(", "self", ")", ":", "if", "self", ".", "_base", "==", "2", ":", "return", "\"NIST\"", "elif", "self", ".", "_base", "==", "10", ":", "return", "\"SI\"", "else", ":", "# I don't expect to ever encounter this logic branch, but", "# hey, it's be...
The system of units used to measure an instance
[ "The", "system", "of", "units", "used", "to", "measure", "an", "instance" ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L299-L310
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath.unit
def unit(self): """The string that is this instances prefix unit name in agreement with this instance value (singular or plural). Following the convention that only 1 is singular. This will always be the singular form when :attr:`bitmath.format_plural` is ``False`` (default value). For example: >>> KiB(1)....
python
def unit(self): """The string that is this instances prefix unit name in agreement with this instance value (singular or plural). Following the convention that only 1 is singular. This will always be the singular form when :attr:`bitmath.format_plural` is ``False`` (default value). For example: >>> KiB(1)....
[ "def", "unit", "(", "self", ")", ":", "global", "format_plural", "if", "self", ".", "prefix_value", "==", "1", ":", "# If it's a '1', return it singular, no matter what", "return", "self", ".", "_name_singular", "elif", "format_plural", ":", "# Pluralization requested",...
The string that is this instances prefix unit name in agreement with this instance value (singular or plural). Following the convention that only 1 is singular. This will always be the singular form when :attr:`bitmath.format_plural` is ``False`` (default value). For example: >>> KiB(1).unit == 'KiB' >>> Byte(0...
[ "The", "string", "that", "is", "this", "instances", "prefix", "unit", "name", "in", "agreement", "with", "this", "instance", "value", "(", "singular", "or", "plural", ")", ".", "Following", "the", "convention", "that", "only", "1", "is", "singular", ".", "...
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L313-L338
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath.from_other
def from_other(cls, item): """Factory function to return instances of `item` converted into a new instance of ``cls``. Because this is a class method, it may be called from any bitmath class object without the need to explicitly instantiate the class ahead of time. *Implicit Parameter:* * ``cls`` A bitmath cl...
python
def from_other(cls, item): """Factory function to return instances of `item` converted into a new instance of ``cls``. Because this is a class method, it may be called from any bitmath class object without the need to explicitly instantiate the class ahead of time. *Implicit Parameter:* * ``cls`` A bitmath cl...
[ "def", "from_other", "(", "cls", ",", "item", ")", ":", "if", "isinstance", "(", "item", ",", "Bitmath", ")", ":", "return", "cls", "(", "bits", "=", "item", ".", "bits", ")", "else", ":", "raise", "ValueError", "(", "\"The provided items must be a valid b...
Factory function to return instances of `item` converted into a new instance of ``cls``. Because this is a class method, it may be called from any bitmath class object without the need to explicitly instantiate the class ahead of time. *Implicit Parameter:* * ``cls`` A bitmath class, implicitly set to the class of th...
[ "Factory", "function", "to", "return", "instances", "of", "item", "converted", "into", "a", "new", "instance", "of", "cls", ".", "Because", "this", "is", "a", "class", "method", "it", "may", "be", "called", "from", "any", "bitmath", "class", "object", "wit...
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L371-L398
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath.format
def format(self, fmt): """Return a representation of this instance formatted with user supplied syntax""" _fmt_params = { 'base': self.base, 'bin': self.bin, 'binary': self.binary, 'bits': self.bits, 'bytes': self.bytes, 'power': se...
python
def format(self, fmt): """Return a representation of this instance formatted with user supplied syntax""" _fmt_params = { 'base': self.base, 'bin': self.bin, 'binary': self.binary, 'bits': self.bits, 'bytes': self.bytes, 'power': se...
[ "def", "format", "(", "self", ",", "fmt", ")", ":", "_fmt_params", "=", "{", "'base'", ":", "self", ".", "base", ",", "'bin'", ":", "self", ".", "bin", ",", "'binary'", ":", "self", ".", "binary", ",", "'bits'", ":", "self", ".", "bits", ",", "'b...
Return a representation of this instance formatted with user supplied syntax
[ "Return", "a", "representation", "of", "this", "instance", "formatted", "with", "user", "supplied", "syntax" ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L416-L433
train
tbielawa/bitmath
bitmath/__init__.py
Bitmath.best_prefix
def best_prefix(self, system=None): """Optional parameter, `system`, allows you to prefer NIST or SI in the results. By default, the current system is used (Bit/Byte default to NIST). Logic discussion/notes: Base-case, does it need converting? If the instance is less than one Byte, return the instance as a B...
python
def best_prefix(self, system=None): """Optional parameter, `system`, allows you to prefer NIST or SI in the results. By default, the current system is used (Bit/Byte default to NIST). Logic discussion/notes: Base-case, does it need converting? If the instance is less than one Byte, return the instance as a B...
[ "def", "best_prefix", "(", "self", ",", "system", "=", "None", ")", ":", "# Use absolute value so we don't return Bit's for *everything*", "# less than Byte(1). From github issue #55", "if", "abs", "(", "self", ")", "<", "Byte", "(", "1", ")", ":", "return", "Bit", ...
Optional parameter, `system`, allows you to prefer NIST or SI in the results. By default, the current system is used (Bit/Byte default to NIST). Logic discussion/notes: Base-case, does it need converting? If the instance is less than one Byte, return the instance as a Bit instance. Else, begin by recording the unit...
[ "Optional", "parameter", "system", "allows", "you", "to", "prefer", "NIST", "or", "SI", "in", "the", "results", ".", "By", "default", "the", "current", "system", "is", "used", "(", "Bit", "/", "Byte", "default", "to", "NIST", ")", "." ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L439-L528
train
tbielawa/bitmath
bitmath/__init__.py
Bit._norm
def _norm(self, value): """Normalize the input value into the fundamental unit for this prefix type""" self._bit_value = value * self._unit_value self._byte_value = self._bit_value / 8.0
python
def _norm(self, value): """Normalize the input value into the fundamental unit for this prefix type""" self._bit_value = value * self._unit_value self._byte_value = self._bit_value / 8.0
[ "def", "_norm", "(", "self", ",", "value", ")", ":", "self", ".", "_bit_value", "=", "value", "*", "self", ".", "_unit_value", "self", ".", "_byte_value", "=", "self", ".", "_bit_value", "/", "8.0" ]
Normalize the input value into the fundamental unit for this prefix type
[ "Normalize", "the", "input", "value", "into", "the", "fundamental", "unit", "for", "this", "prefix", "type" ]
58ad3ac5f076cc6e53f36a91af055c6028c850a5
https://github.com/tbielawa/bitmath/blob/58ad3ac5f076cc6e53f36a91af055c6028c850a5/bitmath/__init__.py#L1091-L1095
train
Julius2342/pyvlx
pyvlx/frames/frame_helper.py
calc_crc
def calc_crc(raw): """Calculate cyclic redundancy check (CRC).""" crc = 0 for sym in raw: crc = crc ^ int(sym) return crc
python
def calc_crc(raw): """Calculate cyclic redundancy check (CRC).""" crc = 0 for sym in raw: crc = crc ^ int(sym) return crc
[ "def", "calc_crc", "(", "raw", ")", ":", "crc", "=", "0", "for", "sym", "in", "raw", ":", "crc", "=", "crc", "^", "int", "(", "sym", ")", "return", "crc" ]
Calculate cyclic redundancy check (CRC).
[ "Calculate", "cyclic", "redundancy", "check", "(", "CRC", ")", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_helper.py#L6-L11
train
Julius2342/pyvlx
pyvlx/frames/frame_helper.py
extract_from_frame
def extract_from_frame(data): """Extract payload and command from frame.""" if len(data) <= 4: raise PyVLXException("could_not_extract_from_frame_too_short", data=data) length = data[0] * 256 + data[1] - 1 if len(data) != length + 3: raise PyVLXException("could_not_extract_from_frame_inv...
python
def extract_from_frame(data): """Extract payload and command from frame.""" if len(data) <= 4: raise PyVLXException("could_not_extract_from_frame_too_short", data=data) length = data[0] * 256 + data[1] - 1 if len(data) != length + 3: raise PyVLXException("could_not_extract_from_frame_inv...
[ "def", "extract_from_frame", "(", "data", ")", ":", "if", "len", "(", "data", ")", "<=", "4", ":", "raise", "PyVLXException", "(", "\"could_not_extract_from_frame_too_short\"", ",", "data", "=", "data", ")", "length", "=", "data", "[", "0", "]", "*", "256"...
Extract payload and command from frame.
[ "Extract", "payload", "and", "command", "from", "frame", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_helper.py#L14-L28
train
Julius2342/pyvlx
pyvlx/frames/frame_node_information_changed.py
FrameNodeInformationChangedNotification.get_payload
def get_payload(self): """Return Payload.""" payload = bytes([self.node_id]) payload += string_to_bytes(self.name, 64) payload += bytes([self.order >> 8 & 255, self.order & 255]) payload += bytes([self.placement]) payload += bytes([self.node_variation.value]) retu...
python
def get_payload(self): """Return Payload.""" payload = bytes([self.node_id]) payload += string_to_bytes(self.name, 64) payload += bytes([self.order >> 8 & 255, self.order & 255]) payload += bytes([self.placement]) payload += bytes([self.node_variation.value]) retu...
[ "def", "get_payload", "(", "self", ")", ":", "payload", "=", "bytes", "(", "[", "self", ".", "node_id", "]", ")", "payload", "+=", "string_to_bytes", "(", "self", ".", "name", ",", "64", ")", "payload", "+=", "bytes", "(", "[", "self", ".", "order", ...
Return Payload.
[ "Return", "Payload", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_information_changed.py#L22-L29
train
Julius2342/pyvlx
pyvlx/frames/frame_node_information_changed.py
FrameNodeInformationChangedNotification.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]) self.order = payload[65] * 256 + payload[66] self.placement = payload[67] self.node_variation = NodeVariation(payload[68])
python
def from_payload(self, payload): """Init frame from binary data.""" self.node_id = payload[0] self.name = bytes_to_string(payload[1:65]) self.order = payload[65] * 256 + payload[66] self.placement = payload[67] self.node_variation = NodeVariation(payload[68])
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "node_id", "=", "payload", "[", "0", "]", "self", ".", "name", "=", "bytes_to_string", "(", "payload", "[", "1", ":", "65", "]", ")", "self", ".", "order", "=", "payload", "...
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_node_information_changed.py#L31-L37
train
Julius2342/pyvlx
pyvlx/frames/frame_get_node_information.py
FrameGetNodeInformationConfirmation.from_payload
def from_payload(self, payload): """Init frame from binary data.""" self.status = NodeInformationStatus(payload[0]) self.node_id = payload[1]
python
def from_payload(self, payload): """Init frame from binary data.""" self.status = NodeInformationStatus(payload[0]) self.node_id = payload[1]
[ "def", "from_payload", "(", "self", ",", "payload", ")", ":", "self", ".", "status", "=", "NodeInformationStatus", "(", "payload", "[", "0", "]", ")", "self", ".", "node_id", "=", "payload", "[", "1", "]" ]
Init frame from binary data.
[ "Init", "frame", "from", "binary", "data", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame_get_node_information.py#L60-L63
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._get_meta
def _get_meta(obj): """Extract metadata, if any, from given object.""" if hasattr(obj, 'meta'): # Spectrum or model meta = deepcopy(obj.meta) elif isinstance(obj, dict): # Metadata meta = deepcopy(obj) else: # Number meta = {} return meta
python
def _get_meta(obj): """Extract metadata, if any, from given object.""" if hasattr(obj, 'meta'): # Spectrum or model meta = deepcopy(obj.meta) elif isinstance(obj, dict): # Metadata meta = deepcopy(obj) else: # Number meta = {} return meta
[ "def", "_get_meta", "(", "obj", ")", ":", "if", "hasattr", "(", "obj", ",", "'meta'", ")", ":", "# Spectrum or model", "meta", "=", "deepcopy", "(", "obj", ".", "meta", ")", "elif", "isinstance", "(", "obj", ",", "dict", ")", ":", "# Metadata", "meta",...
Extract metadata, if any, from given object.
[ "Extract", "metadata", "if", "any", "from", "given", "object", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L193-L201
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._merge_meta
def _merge_meta(left, right, result, clean=True): """Merge metadata from left and right onto results. This is used during class initialization. This should also be used by operators to merge metadata after creating a new instance but before returning it. Result's metadata is mod...
python
def _merge_meta(left, right, result, clean=True): """Merge metadata from left and right onto results. This is used during class initialization. This should also be used by operators to merge metadata after creating a new instance but before returning it. Result's metadata is mod...
[ "def", "_merge_meta", "(", "left", ",", "right", ",", "result", ",", "clean", "=", "True", ")", ":", "# Copies are returned because they need some clean-up below.", "left", "=", "BaseSpectrum", ".", "_get_meta", "(", "left", ")", "right", "=", "BaseSpectrum", ".",...
Merge metadata from left and right onto results. This is used during class initialization. This should also be used by operators to merge metadata after creating a new instance but before returning it. Result's metadata is modified in-place. Parameters ---------- ...
[ "Merge", "metadata", "from", "left", "and", "right", "onto", "results", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L204-L239
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._process_generic_param
def _process_generic_param(pval, def_unit, equivalencies=[]): """Process generic model parameter.""" if isinstance(pval, u.Quantity): outval = pval.to(def_unit, equivalencies).value else: # Assume already in desired unit outval = pval return outval
python
def _process_generic_param(pval, def_unit, equivalencies=[]): """Process generic model parameter.""" if isinstance(pval, u.Quantity): outval = pval.to(def_unit, equivalencies).value else: # Assume already in desired unit outval = pval return outval
[ "def", "_process_generic_param", "(", "pval", ",", "def_unit", ",", "equivalencies", "=", "[", "]", ")", ":", "if", "isinstance", "(", "pval", ",", "u", ".", "Quantity", ")", ":", "outval", "=", "pval", ".", "to", "(", "def_unit", ",", "equivalencies", ...
Process generic model parameter.
[ "Process", "generic", "model", "parameter", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L242-L248
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._process_wave_param
def _process_wave_param(self, pval): """Process individual model parameter representing wavelength.""" return self._process_generic_param( pval, self._internal_wave_unit, equivalencies=u.spectral())
python
def _process_wave_param(self, pval): """Process individual model parameter representing wavelength.""" return self._process_generic_param( pval, self._internal_wave_unit, equivalencies=u.spectral())
[ "def", "_process_wave_param", "(", "self", ",", "pval", ")", ":", "return", "self", ".", "_process_generic_param", "(", "pval", ",", "self", ".", "_internal_wave_unit", ",", "equivalencies", "=", "u", ".", "spectral", "(", ")", ")" ]
Process individual model parameter representing wavelength.
[ "Process", "individual", "model", "parameter", "representing", "wavelength", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L250-L253
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.waveset
def waveset(self): """Optimal wavelengths for sampling the spectrum or bandpass.""" w = get_waveset(self.model) if w is not None: utils.validate_wavelengths(w) w = w * self._internal_wave_unit return w
python
def waveset(self): """Optimal wavelengths for sampling the spectrum or bandpass.""" w = get_waveset(self.model) if w is not None: utils.validate_wavelengths(w) w = w * self._internal_wave_unit return w
[ "def", "waveset", "(", "self", ")", ":", "w", "=", "get_waveset", "(", "self", ".", "model", ")", "if", "w", "is", "not", "None", ":", "utils", ".", "validate_wavelengths", "(", "w", ")", "w", "=", "w", "*", "self", ".", "_internal_wave_unit", "retur...
Optimal wavelengths for sampling the spectrum or bandpass.
[ "Optimal", "wavelengths", "for", "sampling", "the", "spectrum", "or", "bandpass", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L309-L315
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.waverange
def waverange(self): """Range of `waveset`.""" if self.waveset is None: x = [None, None] else: x = u.Quantity([self.waveset.min(), self.waveset.max()]) return x
python
def waverange(self): """Range of `waveset`.""" if self.waveset is None: x = [None, None] else: x = u.Quantity([self.waveset.min(), self.waveset.max()]) return x
[ "def", "waverange", "(", "self", ")", ":", "if", "self", ".", "waveset", "is", "None", ":", "x", "=", "[", "None", ",", "None", "]", "else", ":", "x", "=", "u", ".", "Quantity", "(", "[", "self", ".", "waveset", ".", "min", "(", ")", ",", "se...
Range of `waveset`.
[ "Range", "of", "waveset", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L318-L324
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._validate_wavelengths
def _validate_wavelengths(self, wave): """Validate wavelengths for sampling.""" if wave is None: if self.waveset is None: raise exceptions.SynphotError( 'self.waveset is undefined; ' 'Provide wavelengths for sampling.') wave...
python
def _validate_wavelengths(self, wave): """Validate wavelengths for sampling.""" if wave is None: if self.waveset is None: raise exceptions.SynphotError( 'self.waveset is undefined; ' 'Provide wavelengths for sampling.') wave...
[ "def", "_validate_wavelengths", "(", "self", ",", "wave", ")", ":", "if", "wave", "is", "None", ":", "if", "self", ".", "waveset", "is", "None", ":", "raise", "exceptions", ".", "SynphotError", "(", "'self.waveset is undefined; '", "'Provide wavelengths for sampli...
Validate wavelengths for sampling.
[ "Validate", "wavelengths", "for", "sampling", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L330-L343
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._validate_other_mul_div
def _validate_other_mul_div(other): """Conditions for other to satisfy before mul/div.""" if not isinstance(other, (u.Quantity, numbers.Number, BaseUnitlessSpectrum, SourceSpectrum)): raise exceptions.IncompatibleSources( 'Can only operate on...
python
def _validate_other_mul_div(other): """Conditions for other to satisfy before mul/div.""" if not isinstance(other, (u.Quantity, numbers.Number, BaseUnitlessSpectrum, SourceSpectrum)): raise exceptions.IncompatibleSources( 'Can only operate on...
[ "def", "_validate_other_mul_div", "(", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "(", "u", ".", "Quantity", ",", "numbers", ".", "Number", ",", "BaseUnitlessSpectrum", ",", "SourceSpectrum", ")", ")", ":", "raise", "exceptions", ".", ...
Conditions for other to satisfy before mul/div.
[ "Conditions", "for", "other", "to", "satisfy", "before", "mul", "/", "div", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L375-L390
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.integrate
def integrate(self, wavelengths=None, **kwargs): """Perform integration. This uses any analytical integral that the underlying model has (i.e., ``self.model.integral``). If unavailable, it uses the default fall-back integrator set in the ``default_integrator`` configuration item...
python
def integrate(self, wavelengths=None, **kwargs): """Perform integration. This uses any analytical integral that the underlying model has (i.e., ``self.model.integral``). If unavailable, it uses the default fall-back integrator set in the ``default_integrator`` configuration item...
[ "def", "integrate", "(", "self", ",", "wavelengths", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# Cannot integrate per Hz units natively across wavelength", "# without converting them to per Angstrom unit first, so", "# less misleading to just disallow that option for now.", ...
Perform integration. This uses any analytical integral that the underlying model has (i.e., ``self.model.integral``). If unavailable, it uses the default fall-back integrator set in the ``default_integrator`` configuration item. If wavelengths are provided, flux or throughput i...
[ "Perform", "integration", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L410-L493
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.avgwave
def avgwave(self, wavelengths=None): """Calculate the :ref:`average wavelength <synphot-formula-avgwv>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be...
python
def avgwave(self, wavelengths=None): """Calculate the :ref:`average wavelength <synphot-formula-avgwv>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be...
[ "def", "avgwave", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "y", "=", "self", "(", "x", ")", ".", "value", "num", "=", "np", ".", "trapz", "(", "y"...
Calculate the :ref:`average wavelength <synphot-formula-avgwv>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, `waveset` i...
[ "Calculate", "the", ":", "ref", ":", "average", "wavelength", "<synphot", "-", "formula", "-", "avgwv", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L495-L521
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.barlam
def barlam(self, wavelengths=None): """Calculate :ref:`mean log wavelength <synphot-formula-barlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in...
python
def barlam(self, wavelengths=None): """Calculate :ref:`mean log wavelength <synphot-formula-barlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in...
[ "def", "barlam", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "y", "=", "self", "(", "x", ")", ".", "value", "num", "=", "np", ".", "trapz", "(", "y",...
Calculate :ref:`mean log wavelength <synphot-formula-barlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, `waveset` is ...
[ "Calculate", ":", "ref", ":", "mean", "log", "wavelength", "<synphot", "-", "formula", "-", "barlam", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L523-L549
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.pivot
def pivot(self, wavelengths=None): """Calculate :ref:`pivot wavelength <synphot-formula-pivwv>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angs...
python
def pivot(self, wavelengths=None): """Calculate :ref:`pivot wavelength <synphot-formula-pivwv>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angs...
[ "def", "pivot", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "y", "=", "self", "(", "x", ")", ".", "value", "num", "=", "np", ".", "trapz", "(", "y", ...
Calculate :ref:`pivot wavelength <synphot-formula-pivwv>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, `waveset` is used...
[ "Calculate", ":", "ref", ":", "pivot", "wavelength", "<synphot", "-", "formula", "-", "pivwv", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L551-L577
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.force_extrapolation
def force_extrapolation(self): """Force the underlying model to extrapolate. An example where this is useful: You create a source spectrum with non-default extrapolation behavior and you wish to force the underlying empirical model to extrapolate based on nearest point. .. note...
python
def force_extrapolation(self): """Force the underlying model to extrapolate. An example where this is useful: You create a source spectrum with non-default extrapolation behavior and you wish to force the underlying empirical model to extrapolate based on nearest point. .. note...
[ "def", "force_extrapolation", "(", "self", ")", ":", "# We use _model here in case the spectrum is redshifted.", "if", "isinstance", "(", "self", ".", "_model", ",", "Empirical1D", ")", ":", "self", ".", "_model", ".", "fill_value", "=", "np", ".", "nan", "is_forc...
Force the underlying model to extrapolate. An example where this is useful: You create a source spectrum with non-default extrapolation behavior and you wish to force the underlying empirical model to extrapolate based on nearest point. .. note:: This is only applicable to...
[ "Force", "the", "underlying", "model", "to", "extrapolate", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L579-L606
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.taper
def taper(self, wavelengths=None): """Taper the spectrum or bandpass. The wavelengths to use for the first and last points are calculated by using the same ratio as for the 2 interior points. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quant...
python
def taper(self, wavelengths=None): """Taper the spectrum or bandpass. The wavelengths to use for the first and last points are calculated by using the same ratio as for the 2 interior points. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quant...
[ "def", "taper", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", "# Calculate new end points for tapering", "w1", "=", "x", "[", "0", "]", "**", "2", "/", "x", "[", "1", "]",...
Taper the spectrum or bandpass. The wavelengths to use for the first and last points are calculated by using the same ratio as for the 2 interior points. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values ...
[ "Taper", "the", "spectrum", "or", "bandpass", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L608-L657
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._get_arrays
def _get_arrays(self, wavelengths, **kwargs): """Get sampled spectrum or bandpass in user units.""" x = self._validate_wavelengths(wavelengths) y = self(x, **kwargs) if isinstance(wavelengths, u.Quantity): w = x.to(wavelengths.unit, u.spectral()) else: w ...
python
def _get_arrays(self, wavelengths, **kwargs): """Get sampled spectrum or bandpass in user units.""" x = self._validate_wavelengths(wavelengths) y = self(x, **kwargs) if isinstance(wavelengths, u.Quantity): w = x.to(wavelengths.unit, u.spectral()) else: w ...
[ "def", "_get_arrays", "(", "self", ",", "wavelengths", ",", "*", "*", "kwargs", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", "y", "=", "self", "(", "x", ",", "*", "*", "kwargs", ")", "if", "isinstance", "(", "wav...
Get sampled spectrum or bandpass in user units.
[ "Get", "sampled", "spectrum", "or", "bandpass", "in", "user", "units", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L659-L669
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum._do_plot
def _do_plot(x, y, title='', xlog=False, ylog=False, left=None, right=None, bottom=None, top=None, save_as=''): # pragma: no cover """Plot worker. Parameters ---------- x, y : `~astropy.units.quantity.Quantity` Wavelength and flux/throughpu...
python
def _do_plot(x, y, title='', xlog=False, ylog=False, left=None, right=None, bottom=None, top=None, save_as=''): # pragma: no cover """Plot worker. Parameters ---------- x, y : `~astropy.units.quantity.Quantity` Wavelength and flux/throughpu...
[ "def", "_do_plot", "(", "x", ",", "y", ",", "title", "=", "''", ",", "xlog", "=", "False", ",", "ylog", "=", "False", ",", "left", "=", "None", ",", "right", "=", "None", ",", "bottom", "=", "None", ",", "top", "=", "None", ",", "save_as", "=",...
Plot worker. Parameters ---------- x, y : `~astropy.units.quantity.Quantity` Wavelength and flux/throughput to plot. kwargs See :func:`plot`.
[ "Plot", "worker", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L672-L732
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSpectrum.plot
def plot(self, wavelengths=None, **kwargs): # pragma: no cover """Plot the spectrum. .. note:: Uses ``matplotlib``. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Qu...
python
def plot(self, wavelengths=None, **kwargs): # pragma: no cover """Plot the spectrum. .. note:: Uses ``matplotlib``. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Qu...
[ "def", "plot", "(", "self", ",", "wavelengths", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pragma: no cover", "w", ",", "y", "=", "self", ".", "_get_arrays", "(", "wavelengths", ")", "self", ".", "_do_plot", "(", "w", ",", "y", ",", "*", "*...
Plot the spectrum. .. note:: Uses ``matplotlib``. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, `waveset` is used...
[ "Plot", "the", "spectrum", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L734-L774
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSourceSpectrum._validate_flux_unit
def _validate_flux_unit(new_unit, wav_only=False): """Make sure flux unit is valid.""" new_unit = units.validate_unit(new_unit) acceptable_types = ['spectral flux density wav', 'photon flux density wav'] acceptable_names = ['PHOTLAM', 'FLAM'] if not w...
python
def _validate_flux_unit(new_unit, wav_only=False): """Make sure flux unit is valid.""" new_unit = units.validate_unit(new_unit) acceptable_types = ['spectral flux density wav', 'photon flux density wav'] acceptable_names = ['PHOTLAM', 'FLAM'] if not w...
[ "def", "_validate_flux_unit", "(", "new_unit", ",", "wav_only", "=", "False", ")", ":", "new_unit", "=", "units", ".", "validate_unit", "(", "new_unit", ")", "acceptable_types", "=", "[", "'spectral flux density wav'", ",", "'photon flux density wav'", "]", "accepta...
Make sure flux unit is valid.
[ "Make", "sure", "flux", "unit", "is", "valid", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L785-L802
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseSourceSpectrum.normalize
def normalize(self, renorm_val, band=None, wavelengths=None, force=False, area=None, vegaspec=None): """Renormalize the spectrum to the given Quantity and band. .. warning:: Redshift attribute (``z``) is reset to 0 in the normalized spectrum even if ``self.z``...
python
def normalize(self, renorm_val, band=None, wavelengths=None, force=False, area=None, vegaspec=None): """Renormalize the spectrum to the given Quantity and band. .. warning:: Redshift attribute (``z``) is reset to 0 in the normalized spectrum even if ``self.z``...
[ "def", "normalize", "(", "self", ",", "renorm_val", ",", "band", "=", "None", ",", "wavelengths", "=", "None", ",", "force", "=", "False", ",", "area", "=", "None", ",", "vegaspec", "=", "None", ")", ":", "warndict", "=", "{", "}", "if", "band", "i...
Renormalize the spectrum to the given Quantity and band. .. warning:: Redshift attribute (``z``) is reset to 0 in the normalized spectrum even if ``self.z`` is non-zero. This is because the normalization simply adds a scale factor to the existing composite model...
[ "Renormalize", "the", "spectrum", "to", "the", "given", "Quantity", "and", "band", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L837-L995
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum._process_flux_param
def _process_flux_param(self, pval, wave): """Process individual model parameter representing flux.""" if isinstance(pval, u.Quantity): self._validate_flux_unit(pval.unit) outval = units.convert_flux(self._redshift_model(wave), pval, self._...
python
def _process_flux_param(self, pval, wave): """Process individual model parameter representing flux.""" if isinstance(pval, u.Quantity): self._validate_flux_unit(pval.unit) outval = units.convert_flux(self._redshift_model(wave), pval, self._...
[ "def", "_process_flux_param", "(", "self", ",", "pval", ",", "wave", ")", ":", "if", "isinstance", "(", "pval", ",", "u", ".", "Quantity", ")", ":", "self", ".", "_validate_flux_unit", "(", "pval", ".", "unit", ")", "outval", "=", "units", ".", "conver...
Process individual model parameter representing flux.
[ "Process", "individual", "model", "parameter", "representing", "flux", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1024-L1032
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum.model
def model(self): """Model of the spectrum with given redshift.""" if self.z == 0: m = self._model else: # wavelength if self._internal_wave_unit.physical_type == 'length': rs = self._redshift_model.inverse # frequency or wavenumber ...
python
def model(self): """Model of the spectrum with given redshift.""" if self.z == 0: m = self._model else: # wavelength if self._internal_wave_unit.physical_type == 'length': rs = self._redshift_model.inverse # frequency or wavenumber ...
[ "def", "model", "(", "self", ")", ":", "if", "self", ".", "z", "==", "0", ":", "m", "=", "self", ".", "_model", "else", ":", "# wavelength", "if", "self", ".", "_internal_wave_unit", ".", "physical_type", "==", "'length'", ":", "rs", "=", "self", "."...
Model of the spectrum with given redshift.
[ "Model", "of", "the", "spectrum", "with", "given", "redshift", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1035-L1054
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum.z
def z(self, what): """Change redshift.""" if not isinstance(what, numbers.Real): raise exceptions.SynphotError( 'Redshift must be a real scalar number.') self._z = float(what) self._redshift_model = RedshiftScaleFactor(self._z) if self.z_type == 'wavel...
python
def z(self, what): """Change redshift.""" if not isinstance(what, numbers.Real): raise exceptions.SynphotError( 'Redshift must be a real scalar number.') self._z = float(what) self._redshift_model = RedshiftScaleFactor(self._z) if self.z_type == 'wavel...
[ "def", "z", "(", "self", ",", "what", ")", ":", "if", "not", "isinstance", "(", "what", ",", "numbers", ".", "Real", ")", ":", "raise", "exceptions", ".", "SynphotError", "(", "'Redshift must be a real scalar number.'", ")", "self", ".", "_z", "=", "float"...
Change redshift.
[ "Change", "redshift", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1062-L1072
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum._validate_other_add_sub
def _validate_other_add_sub(self, other): """Conditions for other to satisfy before add/sub.""" if not isinstance(other, self.__class__): raise exceptions.IncompatibleSources( 'Can only operate on {0}.'.format(self.__class__.__name__))
python
def _validate_other_add_sub(self, other): """Conditions for other to satisfy before add/sub.""" if not isinstance(other, self.__class__): raise exceptions.IncompatibleSources( 'Can only operate on {0}.'.format(self.__class__.__name__))
[ "def", "_validate_other_add_sub", "(", "self", ",", "other", ")", ":", "if", "not", "isinstance", "(", "other", ",", "self", ".", "__class__", ")", ":", "raise", "exceptions", ".", "IncompatibleSources", "(", "'Can only operate on {0}.'", ".", "format", "(", "...
Conditions for other to satisfy before add/sub.
[ "Conditions", "for", "other", "to", "satisfy", "before", "add", "/", "sub", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1092-L1096
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum.plot
def plot(self, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs): # pragma: no cover """Plot the spectrum. .. note:: Uses :mod:`matplotlib`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` ...
python
def plot(self, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs): # pragma: no cover """Plot the spectrum. .. note:: Uses :mod:`matplotlib`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` ...
[ "def", "plot", "(", "self", ",", "wavelengths", "=", "None", ",", "flux_unit", "=", "None", ",", "area", "=", "None", ",", "vegaspec", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# pragma: no cover", "w", ",", "y", "=", "self", ".", "_get_arrays...
Plot the spectrum. .. note:: Uses :mod:`matplotlib`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for integration. If not a Quantity, assumed to be in Angstrom. If `None`, ``self.wave...
[ "Plot", "the", "spectrum", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1141-L1172
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum.to_fits
def to_fits(self, filename, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs): """Write the spectrum to a FITS file. Parameters ---------- filename : str Output filename. wavelengths : array-like, `~astropy.units.quantity.Quantity...
python
def to_fits(self, filename, wavelengths=None, flux_unit=None, area=None, vegaspec=None, **kwargs): """Write the spectrum to a FITS file. Parameters ---------- filename : str Output filename. wavelengths : array-like, `~astropy.units.quantity.Quantity...
[ "def", "to_fits", "(", "self", ",", "filename", ",", "wavelengths", "=", "None", ",", "flux_unit", "=", "None", ",", "area", "=", "None", ",", "vegaspec", "=", "None", ",", "*", "*", "kwargs", ")", ":", "w", ",", "y", "=", "self", ".", "_get_arrays...
Write the spectrum to a FITS file. Parameters ---------- filename : str Output filename. wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. ...
[ "Write", "the", "spectrum", "to", "a", "FITS", "file", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1174-L1214
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum.from_file
def from_file(cls, filename, keep_neg=False, **kwargs): """Create a spectrum from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Spectrum filename. keep_neg : bo...
python
def from_file(cls, filename, keep_neg=False, **kwargs): """Create a spectrum from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Spectrum filename. keep_neg : bo...
[ "def", "from_file", "(", "cls", ",", "filename", ",", "keep_neg", "=", "False", ",", "*", "*", "kwargs", ")", ":", "header", ",", "wavelengths", ",", "fluxes", "=", "specio", ".", "read_spec", "(", "filename", ",", "*", "*", "kwargs", ")", "return", ...
Create a spectrum from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Spectrum filename. keep_neg : bool See `~synphot.models.Empirical1D`. kwargs :...
[ "Create", "a", "spectrum", "from", "file", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1217-L1244
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SourceSpectrum.from_vega
def from_vega(cls, **kwargs): """Load :ref:`Vega spectrum <synphot-vega-spec>`. Parameters ---------- kwargs : dict Keywords acceptable by :func:`~synphot.specio.read_remote_spec`. Returns ------- vegaspec : `SourceSpectrum` Empirical Veg...
python
def from_vega(cls, **kwargs): """Load :ref:`Vega spectrum <synphot-vega-spec>`. Parameters ---------- kwargs : dict Keywords acceptable by :func:`~synphot.specio.read_remote_spec`. Returns ------- vegaspec : `SourceSpectrum` Empirical Veg...
[ "def", "from_vega", "(", "cls", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "conf", ".", "vega_file", "header", ",", "wavelengths", ",", "fluxes", "=", "specio", ".", "read_remote_spec", "(", "filename", ",", "*", "*", "kwargs", ")", "header", ...
Load :ref:`Vega spectrum <synphot-vega-spec>`. Parameters ---------- kwargs : dict Keywords acceptable by :func:`~synphot.specio.read_remote_spec`. Returns ------- vegaspec : `SourceSpectrum` Empirical Vega spectrum.
[ "Load", ":", "ref", ":", "Vega", "spectrum", "<synphot", "-", "vega", "-", "spec", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1247-L1268
train
spacetelescope/synphot_refactor
synphot/spectrum.py
BaseUnitlessSpectrum._validate_flux_unit
def _validate_flux_unit(new_unit): # pragma: no cover """Make sure flux unit is valid.""" new_unit = units.validate_unit(new_unit) if new_unit.decompose() != u.dimensionless_unscaled: raise exceptions.SynphotError( 'Unit {0} is not dimensionless'.format(new_unit)) ...
python
def _validate_flux_unit(new_unit): # pragma: no cover """Make sure flux unit is valid.""" new_unit = units.validate_unit(new_unit) if new_unit.decompose() != u.dimensionless_unscaled: raise exceptions.SynphotError( 'Unit {0} is not dimensionless'.format(new_unit)) ...
[ "def", "_validate_flux_unit", "(", "new_unit", ")", ":", "# pragma: no cover", "new_unit", "=", "units", ".", "validate_unit", "(", "new_unit", ")", "if", "new_unit", ".", "decompose", "(", ")", "!=", "u", ".", "dimensionless_unscaled", ":", "raise", "exceptions...
Make sure flux unit is valid.
[ "Make", "sure", "flux", "unit", "is", "valid", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1280-L1288
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.check_overlap
def check_overlap(self, other, wavelengths=None, threshold=0.01): """Check for wavelength overlap between two spectra. Only wavelengths where ``self`` throughput is non-zero are considered. Example of full overlap:: |---------- other ----------| |------ self...
python
def check_overlap(self, other, wavelengths=None, threshold=0.01): """Check for wavelength overlap between two spectra. Only wavelengths where ``self`` throughput is non-zero are considered. Example of full overlap:: |---------- other ----------| |------ self...
[ "def", "check_overlap", "(", "self", ",", "other", ",", "wavelengths", "=", "None", ",", "threshold", "=", "0.01", ")", ":", "if", "not", "isinstance", "(", "other", ",", "BaseSpectrum", ")", ":", "raise", "exceptions", ".", "SynphotError", "(", "'other mu...
Check for wavelength overlap between two spectra. Only wavelengths where ``self`` throughput is non-zero are considered. Example of full overlap:: |---------- other ----------| |------ self ------| Examples of partial overlap:: |---------- self...
[ "Check", "for", "wavelength", "overlap", "between", "two", "spectra", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1333-L1448
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.unit_response
def unit_response(self, area, wavelengths=None): """Calculate :ref:`unit response <synphot-formula-uresp>` of this bandpass. Parameters ---------- area : float or `~astropy.units.quantity.Quantity` Area that flux covers. If not a Quantity, assumed to be in ...
python
def unit_response(self, area, wavelengths=None): """Calculate :ref:`unit response <synphot-formula-uresp>` of this bandpass. Parameters ---------- area : float or `~astropy.units.quantity.Quantity` Area that flux covers. If not a Quantity, assumed to be in ...
[ "def", "unit_response", "(", "self", ",", "area", ",", "wavelengths", "=", "None", ")", ":", "a", "=", "units", ".", "validate_quantity", "(", "area", ",", "units", ".", "AREA", ")", "# Only correct if wavelengths are in Angstrom.", "x", "=", "self", ".", "_...
Calculate :ref:`unit response <synphot-formula-uresp>` of this bandpass. Parameters ---------- area : float or `~astropy.units.quantity.Quantity` Area that flux covers. If not a Quantity, assumed to be in :math:`cm^{2}`. wavelengths : array-like, `~astro...
[ "Calculate", ":", "ref", ":", "unit", "response", "<synphot", "-", "formula", "-", "uresp", ">", "of", "this", "bandpass", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1450-L1481
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.rmswidth
def rmswidth(self, wavelengths=None, threshold=None): """Calculate the :ref:`bandpass RMS width <synphot-formula-rmswidth>`. Not to be confused with :func:`photbw`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Waveleng...
python
def rmswidth(self, wavelengths=None, threshold=None): """Calculate the :ref:`bandpass RMS width <synphot-formula-rmswidth>`. Not to be confused with :func:`photbw`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Waveleng...
[ "def", "rmswidth", "(", "self", ",", "wavelengths", "=", "None", ",", "threshold", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "y", "=", "self", "(", "x", ")", ".", "value", "if", "thr...
Calculate the :ref:`bandpass RMS width <synphot-formula-rmswidth>`. Not to be confused with :func:`photbw`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to...
[ "Calculate", "the", ":", "ref", ":", "bandpass", "RMS", "width", "<synphot", "-", "formula", "-", "rmswidth", ">", ".", "Not", "to", "be", "confused", "with", ":", "func", ":", "photbw", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1483-L1536
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.fwhm
def fwhm(self, **kwargs): """Calculate :ref:`synphot-formula-fwhm` of equivalent gaussian. Parameters ---------- kwargs : dict See :func:`photbw`. Returns ------- fwhm_val : `~astropy.units.quantity.Quantity` FWHM of equivalent gaussian. ...
python
def fwhm(self, **kwargs): """Calculate :ref:`synphot-formula-fwhm` of equivalent gaussian. Parameters ---------- kwargs : dict See :func:`photbw`. Returns ------- fwhm_val : `~astropy.units.quantity.Quantity` FWHM of equivalent gaussian. ...
[ "def", "fwhm", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "np", ".", "sqrt", "(", "8", "*", "np", ".", "log", "(", "2", ")", ")", "*", "self", ".", "photbw", "(", "*", "*", "kwargs", ")" ]
Calculate :ref:`synphot-formula-fwhm` of equivalent gaussian. Parameters ---------- kwargs : dict See :func:`photbw`. Returns ------- fwhm_val : `~astropy.units.quantity.Quantity` FWHM of equivalent gaussian.
[ "Calculate", ":", "ref", ":", "synphot", "-", "formula", "-", "fwhm", "of", "equivalent", "gaussian", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1600-L1614
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.tpeak
def tpeak(self, wavelengths=None): """Calculate :ref:`peak bandpass throughput <synphot-formula-tpeak>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be...
python
def tpeak(self, wavelengths=None): """Calculate :ref:`peak bandpass throughput <synphot-formula-tpeak>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be...
[ "def", "tpeak", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "return", "self", "(", "x", ")", ".", "max", "(", ")" ]
Calculate :ref:`peak bandpass throughput <synphot-formula-tpeak>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, ``self.wa...
[ "Calculate", ":", "ref", ":", "peak", "bandpass", "throughput", "<synphot", "-", "formula", "-", "tpeak", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1633-L1650
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.wpeak
def wpeak(self, wavelengths=None): """Calculate :ref:`wavelength at peak throughput <synphot-formula-tpeak>`. If there are multiple data points with peak throughput value, only the first match is returned. Parameters ---------- wavelengths : array-like, `~astrop...
python
def wpeak(self, wavelengths=None): """Calculate :ref:`wavelength at peak throughput <synphot-formula-tpeak>`. If there are multiple data points with peak throughput value, only the first match is returned. Parameters ---------- wavelengths : array-like, `~astrop...
[ "def", "wpeak", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", "return", "x", "[", "self", "(", "x", ")", "==", "self", ".", "tpeak", "(", "wavelengths", "=", "wavelength...
Calculate :ref:`wavelength at peak throughput <synphot-formula-tpeak>`. If there are multiple data points with peak throughput value, only the first match is returned. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` ...
[ "Calculate", ":", "ref", ":", "wavelength", "at", "peak", "throughput", "<synphot", "-", "formula", "-", "tpeak", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1652-L1673
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.rectwidth
def rectwidth(self, wavelengths=None): """Calculate :ref:`bandpass rectangular width <synphot-formula-rectw>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed...
python
def rectwidth(self, wavelengths=None): """Calculate :ref:`bandpass rectangular width <synphot-formula-rectw>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed...
[ "def", "rectwidth", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "equvw", "=", "self", ".", "equivwidth", "(", "wavelengths", "=", "wavelengths", ")", "tpeak", "=", "self", ".", "tpeak", "(", "wavelengths", "=", "wavelengths", ")", "if", "tpea...
Calculate :ref:`bandpass rectangular width <synphot-formula-rectw>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, ``self....
[ "Calculate", ":", "ref", ":", "bandpass", "rectangular", "width", "<synphot", "-", "formula", "-", "rectw", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1693-L1717
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.efficiency
def efficiency(self, wavelengths=None): """Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed ...
python
def efficiency(self, wavelengths=None): """Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed ...
[ "def", "efficiency", "(", "self", ",", "wavelengths", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_wavelengths", "(", "wavelengths", ")", ".", "value", "y", "=", "self", "(", "x", ")", ".", "value", "qtlam", "=", "abs", "(", "np", ".", ...
Calculate :ref:`dimensionless efficiency <synphot-formula-qtlam>`. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom. If `None`, ``self.wa...
[ "Calculate", ":", "ref", ":", "dimensionless", "efficiency", "<synphot", "-", "formula", "-", "qtlam", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1719-L1738
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.emflx
def emflx(self, area, wavelengths=None): """Calculate :ref:`equivalent monochromatic flux <synphot-formula-emflx>`. Parameters ---------- area, wavelengths See :func:`unit_response`. Returns ------- em_flux : `~astropy.units.quantity.Quantity...
python
def emflx(self, area, wavelengths=None): """Calculate :ref:`equivalent monochromatic flux <synphot-formula-emflx>`. Parameters ---------- area, wavelengths See :func:`unit_response`. Returns ------- em_flux : `~astropy.units.quantity.Quantity...
[ "def", "emflx", "(", "self", ",", "area", ",", "wavelengths", "=", "None", ")", ":", "t_lambda", "=", "self", ".", "tlambda", "(", "wavelengths", "=", "wavelengths", ")", "if", "t_lambda", "==", "0", ":", "# pragma: no cover", "em_flux", "=", "0.0", "*",...
Calculate :ref:`equivalent monochromatic flux <synphot-formula-emflx>`. Parameters ---------- area, wavelengths See :func:`unit_response`. Returns ------- em_flux : `~astropy.units.quantity.Quantity` Equivalent monochromatic flux.
[ "Calculate", ":", "ref", ":", "equivalent", "monochromatic", "flux", "<synphot", "-", "formula", "-", "emflx", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1740-L1764
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.from_file
def from_file(cls, filename, **kwargs): """Creates a bandpass from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Bandpass filename. kwargs : dict Ke...
python
def from_file(cls, filename, **kwargs): """Creates a bandpass from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Bandpass filename. kwargs : dict Ke...
[ "def", "from_file", "(", "cls", ",", "filename", ",", "*", "*", "kwargs", ")", ":", "if", "'flux_unit'", "not", "in", "kwargs", ":", "kwargs", "[", "'flux_unit'", "]", "=", "cls", ".", "_internal_flux_unit", "if", "(", "(", "filename", ".", "endswith", ...
Creates a bandpass from file. If filename has 'fits' or 'fit' suffix, it is read as FITS. Otherwise, it is read as ASCII. Parameters ---------- filename : str Bandpass filename. kwargs : dict Keywords acceptable by :func:`~synphot.sp...
[ "Creates", "a", "bandpass", "from", "file", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1805-L1836
train
spacetelescope/synphot_refactor
synphot/spectrum.py
SpectralElement.from_filter
def from_filter(cls, filtername, **kwargs): """Load :ref:`pre-defined filter bandpass <synphot-predefined-filter>`. Parameters ---------- filtername : str Filter name. Choose from 'bessel_j', 'bessel_h', 'bessel_k', 'cousins_r', 'cousins_i', 'johnson_u', 'johnson...
python
def from_filter(cls, filtername, **kwargs): """Load :ref:`pre-defined filter bandpass <synphot-predefined-filter>`. Parameters ---------- filtername : str Filter name. Choose from 'bessel_j', 'bessel_h', 'bessel_k', 'cousins_r', 'cousins_i', 'johnson_u', 'johnson...
[ "def", "from_filter", "(", "cls", ",", "filtername", ",", "*", "*", "kwargs", ")", ":", "filtername", "=", "filtername", ".", "lower", "(", ")", "# Select filename based on filter name", "if", "filtername", "==", "'bessel_j'", ":", "cfgitem", "=", "Conf", ".",...
Load :ref:`pre-defined filter bandpass <synphot-predefined-filter>`. Parameters ---------- filtername : str Filter name. Choose from 'bessel_j', 'bessel_h', 'bessel_k', 'cousins_r', 'cousins_i', 'johnson_u', 'johnson_b', 'johnson_v', 'johnson_r', 'johnson_i',...
[ "Load", ":", "ref", ":", "pre", "-", "defined", "filter", "bandpass", "<synphot", "-", "predefined", "-", "filter", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/spectrum.py#L1839-L1909
train
Julius2342/pyvlx
pyvlx/activate_scene.py
ActivateScene.handle_frame
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if isinstance(frame, FrameActivateSceneConfirmation) and frame.session_id == self.session_id: if frame.status == ActivateSceneConfirmationStatus.ACCEPTED: self.su...
python
async def handle_frame(self, frame): """Handle incoming API frame, return True if this was the expected frame.""" if isinstance(frame, FrameActivateSceneConfirmation) and frame.session_id == self.session_id: if frame.status == ActivateSceneConfirmationStatus.ACCEPTED: self.su...
[ "async", "def", "handle_frame", "(", "self", ",", "frame", ")", ":", "if", "isinstance", "(", "frame", ",", "FrameActivateSceneConfirmation", ")", "and", "frame", ".", "session_id", "==", "self", ".", "session_id", ":", "if", "frame", ".", "status", "==", ...
Handle incoming API frame, return True if this was the expected frame.
[ "Handle", "incoming", "API", "frame", "return", "True", "if", "this", "was", "the", "expected", "frame", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/activate_scene.py#L21-L36
train
Julius2342/pyvlx
pyvlx/activate_scene.py
ActivateScene.request_frame
def request_frame(self): """Construct initiating frame.""" self.session_id = get_new_session_id() return FrameActivateSceneRequest(scene_id=self.scene_id, session_id=self.session_id)
python
def request_frame(self): """Construct initiating frame.""" self.session_id = get_new_session_id() return FrameActivateSceneRequest(scene_id=self.scene_id, session_id=self.session_id)
[ "def", "request_frame", "(", "self", ")", ":", "self", ".", "session_id", "=", "get_new_session_id", "(", ")", "return", "FrameActivateSceneRequest", "(", "scene_id", "=", "self", ".", "scene_id", ",", "session_id", "=", "self", ".", "session_id", ")" ]
Construct initiating frame.
[ "Construct", "initiating", "frame", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/activate_scene.py#L38-L41
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation._init_bins
def _init_bins(self, binset): """Calculated binned wavelength centers, edges, and flux. By contrast, the native waveset and flux should be considered samples of a continuous function. Thus, it makes sense to interpolate ``self.waveset`` and ``self(self.waveset)``, but not `bins...
python
def _init_bins(self, binset): """Calculated binned wavelength centers, edges, and flux. By contrast, the native waveset and flux should be considered samples of a continuous function. Thus, it makes sense to interpolate ``self.waveset`` and ``self(self.waveset)``, but not `bins...
[ "def", "_init_bins", "(", "self", ",", "binset", ")", ":", "if", "binset", "is", "None", ":", "if", "self", ".", "bandpass", ".", "waveset", "is", "not", "None", ":", "self", ".", "_binset", "=", "self", ".", "bandpass", ".", "waveset", "elif", "self...
Calculated binned wavelength centers, edges, and flux. By contrast, the native waveset and flux should be considered samples of a continuous function. Thus, it makes sense to interpolate ``self.waveset`` and ``self(self.waveset)``, but not `binset` and `binflux`.
[ "Calculated", "binned", "wavelength", "centers", "edges", "and", "flux", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L142-L196
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation.sample_binned
def sample_binned(self, wavelengths=None, flux_unit=None, **kwargs): """Sample binned observation without interpolation. To sample unbinned data, use ``__call__``. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Waveleng...
python
def sample_binned(self, wavelengths=None, flux_unit=None, **kwargs): """Sample binned observation without interpolation. To sample unbinned data, use ``__call__``. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Waveleng...
[ "def", "sample_binned", "(", "self", ",", "wavelengths", "=", "None", ",", "flux_unit", "=", "None", ",", "*", "*", "kwargs", ")", ":", "x", "=", "self", ".", "_validate_binned_wavelengths", "(", "wavelengths", ")", "i", "=", "np", ".", "searchsorted", "...
Sample binned observation without interpolation. To sample unbinned data, use ``__call__``. Parameters ---------- wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` Wavelength values for sampling. If not a Quantity, assumed to be in Angstrom...
[ "Sample", "binned", "observation", "without", "interpolation", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L241-L283
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation._get_binned_arrays
def _get_binned_arrays(self, wavelengths, flux_unit, area=None, vegaspec=None): """Get binned observation in user units.""" x = self._validate_binned_wavelengths(wavelengths) y = self.sample_binned(wavelengths=x, flux_unit=flux_unit, area=area, ...
python
def _get_binned_arrays(self, wavelengths, flux_unit, area=None, vegaspec=None): """Get binned observation in user units.""" x = self._validate_binned_wavelengths(wavelengths) y = self.sample_binned(wavelengths=x, flux_unit=flux_unit, area=area, ...
[ "def", "_get_binned_arrays", "(", "self", ",", "wavelengths", ",", "flux_unit", ",", "area", "=", "None", ",", "vegaspec", "=", "None", ")", ":", "x", "=", "self", ".", "_validate_binned_wavelengths", "(", "wavelengths", ")", "y", "=", "self", ".", "sample...
Get binned observation in user units.
[ "Get", "binned", "observation", "in", "user", "units", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L285-L297
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation.binned_waverange
def binned_waverange(self, cenwave, npix, **kwargs): """Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of `binset`. Parameters ---------- cenwave : float or `~astropy.units.quantity.Quantity` Des...
python
def binned_waverange(self, cenwave, npix, **kwargs): """Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of `binset`. Parameters ---------- cenwave : float or `~astropy.units.quantity.Quantity` Des...
[ "def", "binned_waverange", "(", "self", ",", "cenwave", ",", "npix", ",", "*", "*", "kwargs", ")", ":", "# Calculation is done in the unit of cenwave.", "if", "not", "isinstance", "(", "cenwave", ",", "u", ".", "Quantity", ")", ":", "cenwave", "=", "cenwave", ...
Calculate the wavelength range covered by the given number of pixels centered on the given central wavelengths of `binset`. Parameters ---------- cenwave : float or `~astropy.units.quantity.Quantity` Desired central wavelength. If not a Quantity, assumed ...
[ "Calculate", "the", "wavelength", "range", "covered", "by", "the", "given", "number", "of", "pixels", "centered", "on", "the", "given", "central", "wavelengths", "of", "binset", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L299-L331
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation.binned_pixelrange
def binned_pixelrange(self, waverange, **kwargs): """Calculate the number of pixels within the given wavelength range and `binset`. Parameters ---------- waverange : tuple of float or `~astropy.units.quantity.Quantity` Lower and upper limits of the desired wavelength...
python
def binned_pixelrange(self, waverange, **kwargs): """Calculate the number of pixels within the given wavelength range and `binset`. Parameters ---------- waverange : tuple of float or `~astropy.units.quantity.Quantity` Lower and upper limits of the desired wavelength...
[ "def", "binned_pixelrange", "(", "self", ",", "waverange", ",", "*", "*", "kwargs", ")", ":", "x", "=", "units", ".", "validate_quantity", "(", "waverange", ",", "self", ".", "_internal_wave_unit", ",", "equivalencies", "=", "u", ".", "spectral", "(", ")",...
Calculate the number of pixels within the given wavelength range and `binset`. Parameters ---------- waverange : tuple of float or `~astropy.units.quantity.Quantity` Lower and upper limits of the desired wavelength range. If not a Quantity, assumed to be in Angst...
[ "Calculate", "the", "number", "of", "pixels", "within", "the", "given", "wavelength", "range", "and", "binset", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L333-L354
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation.effective_wavelength
def effective_wavelength(self, binned=True, wavelengths=None, mode='efflerg'): """Calculate :ref:`effective wavelength <synphot-formula-effwave>`. Parameters ---------- binned : bool Sample data in native wavelengths if `False`. Else,...
python
def effective_wavelength(self, binned=True, wavelengths=None, mode='efflerg'): """Calculate :ref:`effective wavelength <synphot-formula-effwave>`. Parameters ---------- binned : bool Sample data in native wavelengths if `False`. Else,...
[ "def", "effective_wavelength", "(", "self", ",", "binned", "=", "True", ",", "wavelengths", "=", "None", ",", "mode", "=", "'efflerg'", ")", ":", "mode", "=", "mode", ".", "lower", "(", ")", "if", "mode", "==", "'efflerg'", ":", "flux_unit", "=", "unit...
Calculate :ref:`effective wavelength <synphot-formula-effwave>`. Parameters ---------- binned : bool Sample data in native wavelengths if `False`. Else, sample binned data (default). wavelengths : array-like, `~astropy.units.quantity.Quantity`, or `None` ...
[ "Calculate", ":", "ref", ":", "effective", "wavelength", "<synphot", "-", "formula", "-", "effwave", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L356-L415
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation.effstim
def effstim(self, flux_unit=None, wavelengths=None, area=None, vegaspec=None): """Calculate :ref:`effective stimulus <synphot-formula-effstim>` for given flux unit. Parameters ---------- flux_unit : str or `~astropy.units.core.Unit` or `None` The unit...
python
def effstim(self, flux_unit=None, wavelengths=None, area=None, vegaspec=None): """Calculate :ref:`effective stimulus <synphot-formula-effstim>` for given flux unit. Parameters ---------- flux_unit : str or `~astropy.units.core.Unit` or `None` The unit...
[ "def", "effstim", "(", "self", ",", "flux_unit", "=", "None", ",", "wavelengths", "=", "None", ",", "area", "=", "None", ",", "vegaspec", "=", "None", ")", ":", "if", "flux_unit", "is", "None", ":", "flux_unit", "=", "self", ".", "_internal_flux_unit", ...
Calculate :ref:`effective stimulus <synphot-formula-effstim>` for given flux unit. Parameters ---------- flux_unit : str or `~astropy.units.core.Unit` or `None` The unit of effective stimulus. COUNT gives result in count/s (see :meth:`countrate` for more ...
[ "Calculate", ":", "ref", ":", "effective", "stimulus", "<synphot", "-", "formula", "-", "effstim", ">", "for", "given", "flux", "unit", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L418-L505
train
spacetelescope/synphot_refactor
synphot/observation.py
Observation.countrate
def countrate(self, area, binned=True, wavelengths=None, waverange=None, force=False): """Calculate :ref:`effective stimulus <synphot-formula-effstim>` in count/s. Parameters ---------- area : float or `~astropy.units.quantity.Quantity` Area that fl...
python
def countrate(self, area, binned=True, wavelengths=None, waverange=None, force=False): """Calculate :ref:`effective stimulus <synphot-formula-effstim>` in count/s. Parameters ---------- area : float or `~astropy.units.quantity.Quantity` Area that fl...
[ "def", "countrate", "(", "self", ",", "area", ",", "binned", "=", "True", ",", "wavelengths", "=", "None", ",", "waverange", "=", "None", ",", "force", "=", "False", ")", ":", "# Sample the observation", "if", "binned", ":", "x", "=", "self", ".", "_va...
Calculate :ref:`effective stimulus <synphot-formula-effstim>` in count/s. Parameters ---------- area : float or `~astropy.units.quantity.Quantity` Area that flux covers. If not a Quantity, assumed to be in :math:`cm^{2}`. binned : bool Sample...
[ "Calculate", ":", "ref", ":", "effective", "stimulus", "<synphot", "-", "formula", "-", "effstim", ">", "in", "count", "/", "s", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L507-L614
train
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", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L616-L656
train
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", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/observation.py#L658-L696
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/set_node_name.py#L18-L23
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/api_event.py#L18-L26
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/api_event.py#L49-L52
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/examples/example.py#L6-L23
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/on_off_switch.py#L16-L23
train
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", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L244-L315
train
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", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L42-L84
train
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", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L86-L128
train
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", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L131-L163
train
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", ">", "." ]
9c064f3cff0c41dd8acadc0f67c6350931275b9f
https://github.com/spacetelescope/synphot_refactor/blob/9c064f3cff0c41dd8acadc0f67c6350931275b9f/synphot/reddening.py#L166-L227
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_version.py#L15-L21
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame.py#L22-L29
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/frames/frame.py#L45-L52
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/scene.py#L23-L37
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L33-L37
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L39-L42
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L44-L51
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/old_api/pyvlx/scenes.py#L53-L56
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/get_state.py#L16-L23
train
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", "." ]
ee78e1324bcb1be5b8d1a9d05ab5496b72eae848
https://github.com/Julius2342/pyvlx/blob/ee78e1324bcb1be5b8d1a9d05ab5496b72eae848/pyvlx/alias_array.py#L26-L36
train