repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
lago-project/lago | lago/prefix.py | Prefix._create_ssh_keys | def _create_ssh_keys(self):
"""
Generate a pair of ssh keys for this prefix
Returns:
None
Raises:
RuntimeError: if it fails to create the keys
"""
ret, _, _ = utils.run_command(
[
'ssh-keygen',
'-t',
... | python | def _create_ssh_keys(self):
"""
Generate a pair of ssh keys for this prefix
Returns:
None
Raises:
RuntimeError: if it fails to create the keys
"""
ret, _, _ = utils.run_command(
[
'ssh-keygen',
'-t',
... | [
"def",
"_create_ssh_keys",
"(",
"self",
")",
":",
"ret",
",",
"_",
",",
"_",
"=",
"utils",
".",
"run_command",
"(",
"[",
"'ssh-keygen'",
",",
"'-t'",
",",
"'rsa'",
",",
"'-m'",
",",
"'PEM'",
",",
"'-N'",
",",
"''",
",",
"'-f'",
",",
"self",
".",
... | Generate a pair of ssh keys for this prefix
Returns:
None
Raises:
RuntimeError: if it fails to create the keys | [
"Generate",
"a",
"pair",
"of",
"ssh",
"keys",
"for",
"this",
"prefix"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L156-L183 | train |
lago-project/lago | lago/prefix.py | Prefix.cleanup | def cleanup(self):
"""
Stops any running entities in the prefix and uninitializes it, usually
you want to do this if you are going to remove the prefix afterwards
Returns:
None
"""
with LogTask('Stop prefix'):
self.stop()
with LogTask("Tag... | python | def cleanup(self):
"""
Stops any running entities in the prefix and uninitializes it, usually
you want to do this if you are going to remove the prefix afterwards
Returns:
None
"""
with LogTask('Stop prefix'):
self.stop()
with LogTask("Tag... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"with",
"LogTask",
"(",
"'Stop prefix'",
")",
":",
"self",
".",
"stop",
"(",
")",
"with",
"LogTask",
"(",
"\"Tag prefix as uninitialized\"",
")",
":",
"os",
".",
"unlink",
"(",
"self",
".",
"paths",
".",
"prefix_l... | Stops any running entities in the prefix and uninitializes it, usually
you want to do this if you are going to remove the prefix afterwards
Returns:
None | [
"Stops",
"any",
"running",
"entities",
"in",
"the",
"prefix",
"and",
"uninitializes",
"it",
"usually",
"you",
"want",
"to",
"do",
"this",
"if",
"you",
"are",
"going",
"to",
"remove",
"the",
"prefix",
"afterwards"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L228-L239 | train |
lago-project/lago | lago/prefix.py | Prefix._init_net_specs | def _init_net_specs(conf):
"""
Given a configuration specification, initializes all the net
definitions in it so they can be used comfortably
Args:
conf (dict): Configuration specification
Returns:
dict: the adapted new conf
"""
for net_n... | python | def _init_net_specs(conf):
"""
Given a configuration specification, initializes all the net
definitions in it so they can be used comfortably
Args:
conf (dict): Configuration specification
Returns:
dict: the adapted new conf
"""
for net_n... | [
"def",
"_init_net_specs",
"(",
"conf",
")",
":",
"for",
"net_name",
",",
"net_spec",
"in",
"conf",
".",
"get",
"(",
"'nets'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":",
"net_spec",
"[",
"'name'",
"]",
"=",
"net_name",
"net_spec",
"[",
"'mapping... | Given a configuration specification, initializes all the net
definitions in it so they can be used comfortably
Args:
conf (dict): Configuration specification
Returns:
dict: the adapted new conf | [
"Given",
"a",
"configuration",
"specification",
"initializes",
"all",
"the",
"net",
"definitions",
"in",
"it",
"so",
"they",
"can",
"be",
"used",
"comfortably"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L242-L258 | train |
lago-project/lago | lago/prefix.py | Prefix._allocate_subnets | def _allocate_subnets(self, conf):
"""
Allocate all the subnets needed by the given configuration spec
Args:
conf (dict): Configuration spec where to get the nets definitions
from
Returns:
tuple(list, dict): allocated subnets and modified conf
... | python | def _allocate_subnets(self, conf):
"""
Allocate all the subnets needed by the given configuration spec
Args:
conf (dict): Configuration spec where to get the nets definitions
from
Returns:
tuple(list, dict): allocated subnets and modified conf
... | [
"def",
"_allocate_subnets",
"(",
"self",
",",
"conf",
")",
":",
"allocated_subnets",
"=",
"[",
"]",
"try",
":",
"for",
"net_spec",
"in",
"conf",
".",
"get",
"(",
"'nets'",
",",
"{",
"}",
")",
".",
"itervalues",
"(",
")",
":",
"if",
"net_spec",
"[",
... | Allocate all the subnets needed by the given configuration spec
Args:
conf (dict): Configuration spec where to get the nets definitions
from
Returns:
tuple(list, dict): allocated subnets and modified conf | [
"Allocate",
"all",
"the",
"subnets",
"needed",
"by",
"the",
"given",
"configuration",
"spec"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L260-L292 | train |
lago-project/lago | lago/prefix.py | Prefix._select_mgmt_networks | def _select_mgmt_networks(self, conf):
"""
Select management networks. If no management network is found, it will
mark the first network found by sorted the network lists. Also adding
default DNS domain, if none is set.
Args:
conf(spec): spec
"""
ne... | python | def _select_mgmt_networks(self, conf):
"""
Select management networks. If no management network is found, it will
mark the first network found by sorted the network lists. Also adding
default DNS domain, if none is set.
Args:
conf(spec): spec
"""
ne... | [
"def",
"_select_mgmt_networks",
"(",
"self",
",",
"conf",
")",
":",
"nets",
"=",
"conf",
"[",
"'nets'",
"]",
"mgmts",
"=",
"sorted",
"(",
"[",
"name",
"for",
"name",
",",
"net",
"in",
"nets",
".",
"iteritems",
"(",
")",
"if",
"net",
".",
"get",
"("... | Select management networks. If no management network is found, it will
mark the first network found by sorted the network lists. Also adding
default DNS domain, if none is set.
Args:
conf(spec): spec | [
"Select",
"management",
"networks",
".",
"If",
"no",
"management",
"network",
"is",
"found",
"it",
"will",
"mark",
"the",
"first",
"network",
"found",
"by",
"sorted",
"the",
"network",
"lists",
".",
"Also",
"adding",
"default",
"DNS",
"domain",
"if",
"none",... | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L341-L373 | train |
lago-project/lago | lago/prefix.py | Prefix._register_preallocated_ips | def _register_preallocated_ips(self, conf):
"""
Parse all the domains in the given conf and preallocate all their ips
into the networks mappings, raising exception on duplicated ips or ips
out of the allowed ranges
See Also:
:mod:`lago.subnet_lease`
Args:
... | python | def _register_preallocated_ips(self, conf):
"""
Parse all the domains in the given conf and preallocate all their ips
into the networks mappings, raising exception on duplicated ips or ips
out of the allowed ranges
See Also:
:mod:`lago.subnet_lease`
Args:
... | [
"def",
"_register_preallocated_ips",
"(",
"self",
",",
"conf",
")",
":",
"for",
"dom_name",
",",
"dom_spec",
"in",
"conf",
".",
"get",
"(",
"'domains'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":",
"for",
"idx",
",",
"nic",
"in",
"enumerate",
"("... | Parse all the domains in the given conf and preallocate all their ips
into the networks mappings, raising exception on duplicated ips or ips
out of the allowed ranges
See Also:
:mod:`lago.subnet_lease`
Args:
conf (dict): Configuration spec to parse
Retu... | [
"Parse",
"all",
"the",
"domains",
"in",
"the",
"given",
"conf",
"and",
"preallocate",
"all",
"their",
"ips",
"into",
"the",
"networks",
"mappings",
"raising",
"exception",
"on",
"duplicated",
"ips",
"or",
"ips",
"out",
"of",
"the",
"allowed",
"ranges"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L406-L460 | train |
lago-project/lago | lago/prefix.py | Prefix._allocate_ips_to_nics | def _allocate_ips_to_nics(self, conf):
"""
For all the nics of all the domains in the conf that have dynamic ip,
allocate one and addit to the network mapping
Args:
conf (dict): Configuration spec to extract the domains from
Returns:
None
"""
... | python | def _allocate_ips_to_nics(self, conf):
"""
For all the nics of all the domains in the conf that have dynamic ip,
allocate one and addit to the network mapping
Args:
conf (dict): Configuration spec to extract the domains from
Returns:
None
"""
... | [
"def",
"_allocate_ips_to_nics",
"(",
"self",
",",
"conf",
")",
":",
"for",
"dom_name",
",",
"dom_spec",
"in",
"conf",
".",
"get",
"(",
"'domains'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":",
"for",
"idx",
",",
"nic",
"in",
"enumerate",
"(",
"... | For all the nics of all the domains in the conf that have dynamic ip,
allocate one and addit to the network mapping
Args:
conf (dict): Configuration spec to extract the domains from
Returns:
None | [
"For",
"all",
"the",
"nics",
"of",
"all",
"the",
"domains",
"in",
"the",
"conf",
"that",
"have",
"dynamic",
"ip",
"allocate",
"one",
"and",
"addit",
"to",
"the",
"network",
"mapping"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L481-L508 | train |
lago-project/lago | lago/prefix.py | Prefix._set_mtu_to_nics | def _set_mtu_to_nics(self, conf):
"""
For all the nics of all the domains in the conf that have MTU set,
save the MTU on the NIC definition.
Args:
conf (dict): Configuration spec to extract the domains from
Returns:
None
"""
for dom_name,... | python | def _set_mtu_to_nics(self, conf):
"""
For all the nics of all the domains in the conf that have MTU set,
save the MTU on the NIC definition.
Args:
conf (dict): Configuration spec to extract the domains from
Returns:
None
"""
for dom_name,... | [
"def",
"_set_mtu_to_nics",
"(",
"self",
",",
"conf",
")",
":",
"for",
"dom_name",
",",
"dom_spec",
"in",
"conf",
".",
"get",
"(",
"'domains'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":",
"for",
"idx",
",",
"nic",
"in",
"enumerate",
"(",
"dom_s... | For all the nics of all the domains in the conf that have MTU set,
save the MTU on the NIC definition.
Args:
conf (dict): Configuration spec to extract the domains from
Returns:
None | [
"For",
"all",
"the",
"nics",
"of",
"all",
"the",
"domains",
"in",
"the",
"conf",
"that",
"have",
"MTU",
"set",
"save",
"the",
"MTU",
"on",
"the",
"NIC",
"definition",
"."
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L510-L526 | train |
lago-project/lago | lago/prefix.py | Prefix._config_net_topology | def _config_net_topology(self, conf):
"""
Initialize and populate all the network related elements, like
reserving ips and populating network specs of the given confiiguration
spec
Args:
conf (dict): Configuration spec to initalize
Returns:
None
... | python | def _config_net_topology(self, conf):
"""
Initialize and populate all the network related elements, like
reserving ips and populating network specs of the given confiiguration
spec
Args:
conf (dict): Configuration spec to initalize
Returns:
None
... | [
"def",
"_config_net_topology",
"(",
"self",
",",
"conf",
")",
":",
"conf",
"=",
"self",
".",
"_init_net_specs",
"(",
"conf",
")",
"mgmts",
"=",
"self",
".",
"_select_mgmt_networks",
"(",
"conf",
")",
"self",
".",
"_validate_netconfig",
"(",
"conf",
")",
"a... | Initialize and populate all the network related elements, like
reserving ips and populating network specs of the given confiiguration
spec
Args:
conf (dict): Configuration spec to initalize
Returns:
None | [
"Initialize",
"and",
"populate",
"all",
"the",
"network",
"related",
"elements",
"like",
"reserving",
"ips",
"and",
"populating",
"network",
"specs",
"of",
"the",
"given",
"confiiguration",
"spec"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L528-L553 | train |
lago-project/lago | lago/prefix.py | Prefix._validate_netconfig | def _validate_netconfig(self, conf):
"""
Validate network configuration
Args:
conf(dict): spec
Returns:
None
Raises:
:exc:`~lago.utils.LagoInitException`: If a VM has more than
one management network configured, or a network whi... | python | def _validate_netconfig(self, conf):
"""
Validate network configuration
Args:
conf(dict): spec
Returns:
None
Raises:
:exc:`~lago.utils.LagoInitException`: If a VM has more than
one management network configured, or a network whi... | [
"def",
"_validate_netconfig",
"(",
"self",
",",
"conf",
")",
":",
"nets",
"=",
"conf",
".",
"get",
"(",
"'nets'",
",",
"{",
"}",
")",
"if",
"len",
"(",
"nets",
")",
"==",
"0",
":",
"raise",
"LagoInitException",
"(",
"'No networks configured.'",
")",
"n... | Validate network configuration
Args:
conf(dict): spec
Returns:
None
Raises:
:exc:`~lago.utils.LagoInitException`: If a VM has more than
one management network configured, or a network which is not
management has DNS attributes, or a... | [
"Validate",
"network",
"configuration"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L573-L633 | train |
lago-project/lago | lago/prefix.py | Prefix._create_disk | def _create_disk(
self,
name,
spec,
template_repo=None,
template_store=None,
):
"""
Creates a disc with the given name from the given repo or store
Args:
name (str): Name of the domain to create the disk for
spec (dict): Specif... | python | def _create_disk(
self,
name,
spec,
template_repo=None,
template_store=None,
):
"""
Creates a disc with the given name from the given repo or store
Args:
name (str): Name of the domain to create the disk for
spec (dict): Specif... | [
"def",
"_create_disk",
"(",
"self",
",",
"name",
",",
"spec",
",",
"template_repo",
"=",
"None",
",",
"template_store",
"=",
"None",
",",
")",
":",
"LOGGER",
".",
"debug",
"(",
"\"Spec: %s\"",
"%",
"spec",
")",
"with",
"LogTask",
"(",
"\"Create disk %s\"",... | Creates a disc with the given name from the given repo or store
Args:
name (str): Name of the domain to create the disk for
spec (dict): Specification of the disk to create
template_repo (TemplateRepository or None): template repo instance
to use
... | [
"Creates",
"a",
"disc",
"with",
"the",
"given",
"name",
"from",
"the",
"given",
"repo",
"or",
"store"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L635-L683 | train |
lago-project/lago | lago/prefix.py | Prefix._ova_to_spec | def _ova_to_spec(self, filename):
"""
Retrieve the given ova and makes a template of it.
Creates a disk from network provided ova.
Calculates the needed memory from the ovf.
The disk will be cached in the template repo
Args:
filename(str): the url to retrive ... | python | def _ova_to_spec(self, filename):
"""
Retrieve the given ova and makes a template of it.
Creates a disk from network provided ova.
Calculates the needed memory from the ovf.
The disk will be cached in the template repo
Args:
filename(str): the url to retrive ... | [
"def",
"_ova_to_spec",
"(",
"self",
",",
"filename",
")",
":",
"ova_extracted_dir",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"[",
"0",
"]",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"ova_extracted_dir",
")",
":",
"os",
... | Retrieve the given ova and makes a template of it.
Creates a disk from network provided ova.
Calculates the needed memory from the ovf.
The disk will be cached in the template repo
Args:
filename(str): the url to retrive the data from
TODO:
* Add hash ch... | [
"Retrieve",
"the",
"given",
"ova",
"and",
"makes",
"a",
"template",
"of",
"it",
".",
"Creates",
"a",
"disk",
"from",
"network",
"provided",
"ova",
".",
"Calculates",
"the",
"needed",
"memory",
"from",
"the",
"ovf",
".",
"The",
"disk",
"will",
"be",
"cach... | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L949-L1046 | train |
lago-project/lago | lago/prefix.py | Prefix._use_prototype | def _use_prototype(self, spec, prototypes):
"""
Populates the given spec with the values of it's declared prototype
Args:
spec (dict): spec to update
prototypes (dict): Configuration spec containing the prototypes
Returns:
dict: updated spec
... | python | def _use_prototype(self, spec, prototypes):
"""
Populates the given spec with the values of it's declared prototype
Args:
spec (dict): spec to update
prototypes (dict): Configuration spec containing the prototypes
Returns:
dict: updated spec
... | [
"def",
"_use_prototype",
"(",
"self",
",",
"spec",
",",
"prototypes",
")",
":",
"prototype",
"=",
"spec",
"[",
"'based-on'",
"]",
"del",
"spec",
"[",
"'based-on'",
"]",
"for",
"attr",
"in",
"prototype",
":",
"if",
"attr",
"not",
"in",
"spec",
":",
"spe... | Populates the given spec with the values of it's declared prototype
Args:
spec (dict): spec to update
prototypes (dict): Configuration spec containing the prototypes
Returns:
dict: updated spec | [
"Populates",
"the",
"given",
"spec",
"with",
"the",
"values",
"of",
"it",
"s",
"declared",
"prototype"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1048-L1065 | train |
lago-project/lago | lago/prefix.py | Prefix.fetch_url | def fetch_url(self, url):
"""
Retrieves the given url to the prefix
Args:
url(str): Url to retrieve
Returns:
str: path to the downloaded file
"""
url_path = urlparse.urlsplit(url).path
dst_path = os.path.basename(url_path)
dst_pat... | python | def fetch_url(self, url):
"""
Retrieves the given url to the prefix
Args:
url(str): Url to retrieve
Returns:
str: path to the downloaded file
"""
url_path = urlparse.urlsplit(url).path
dst_path = os.path.basename(url_path)
dst_pat... | [
"def",
"fetch_url",
"(",
"self",
",",
"url",
")",
":",
"url_path",
"=",
"urlparse",
".",
"urlsplit",
"(",
"url",
")",
".",
"path",
"dst_path",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"url_path",
")",
"dst_path",
"=",
"self",
".",
"paths",
".",
... | Retrieves the given url to the prefix
Args:
url(str): Url to retrieve
Returns:
str: path to the downloaded file | [
"Retrieves",
"the",
"given",
"url",
"to",
"the",
"prefix"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1067-L1083 | train |
lago-project/lago | lago/prefix.py | Prefix.export_vms | def export_vms(
self,
vms_names=None,
standalone=False,
export_dir='.',
compress=False,
init_file_name='LagoInitFile',
out_format=YAMLOutFormatPlugin(),
collect_only=False,
with_threads=True,
):
"""
Export vm images disks and in... | python | def export_vms(
self,
vms_names=None,
standalone=False,
export_dir='.',
compress=False,
init_file_name='LagoInitFile',
out_format=YAMLOutFormatPlugin(),
collect_only=False,
with_threads=True,
):
"""
Export vm images disks and in... | [
"def",
"export_vms",
"(",
"self",
",",
"vms_names",
"=",
"None",
",",
"standalone",
"=",
"False",
",",
"export_dir",
"=",
"'.'",
",",
"compress",
"=",
"False",
",",
"init_file_name",
"=",
"'LagoInitFile'",
",",
"out_format",
"=",
"YAMLOutFormatPlugin",
"(",
... | Export vm images disks and init file.
The exported images and init file can be used to recreate
the environment.
Args:
vms_names(list of str): Names of the vms to export, if None
export all the vms in the env (default=None)
standalone(bool): If false, exp... | [
"Export",
"vm",
"images",
"disks",
"and",
"init",
"file",
".",
"The",
"exported",
"images",
"and",
"init",
"file",
"can",
"be",
"used",
"to",
"recreate",
"the",
"environment",
"."
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1270-L1310 | train |
lago-project/lago | lago/prefix.py | Prefix.shutdown | def shutdown(self, vm_names=None, reboot=False):
"""
Shutdown this prefix
Args:
vm_names(list of str): List of the vms to shutdown
reboot(bool): If true, reboot the requested vms
Returns:
None
"""
self.virt_env.shutdown(vm_names, rebo... | python | def shutdown(self, vm_names=None, reboot=False):
"""
Shutdown this prefix
Args:
vm_names(list of str): List of the vms to shutdown
reboot(bool): If true, reboot the requested vms
Returns:
None
"""
self.virt_env.shutdown(vm_names, rebo... | [
"def",
"shutdown",
"(",
"self",
",",
"vm_names",
"=",
"None",
",",
"reboot",
"=",
"False",
")",
":",
"self",
".",
"virt_env",
".",
"shutdown",
"(",
"vm_names",
",",
"reboot",
")"
] | Shutdown this prefix
Args:
vm_names(list of str): List of the vms to shutdown
reboot(bool): If true, reboot the requested vms
Returns:
None | [
"Shutdown",
"this",
"prefix"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1339-L1350 | train |
lago-project/lago | lago/prefix.py | Prefix.virt_env | def virt_env(self):
"""
Getter for this instance's virt env, creates it if needed
Returns:
lago.virt.VirtEnv: virt env instance used by this prefix
"""
if self._virt_env is None:
self._virt_env = self._create_virt_env()
return self._virt_env | python | def virt_env(self):
"""
Getter for this instance's virt env, creates it if needed
Returns:
lago.virt.VirtEnv: virt env instance used by this prefix
"""
if self._virt_env is None:
self._virt_env = self._create_virt_env()
return self._virt_env | [
"def",
"virt_env",
"(",
"self",
")",
":",
"if",
"self",
".",
"_virt_env",
"is",
"None",
":",
"self",
".",
"_virt_env",
"=",
"self",
".",
"_create_virt_env",
"(",
")",
"return",
"self",
".",
"_virt_env"
] | Getter for this instance's virt env, creates it if needed
Returns:
lago.virt.VirtEnv: virt env instance used by this prefix | [
"Getter",
"for",
"this",
"instance",
"s",
"virt",
"env",
"creates",
"it",
"if",
"needed"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1395-L1404 | train |
lago-project/lago | lago/prefix.py | Prefix.destroy | def destroy(self):
"""
Destroy this prefix, running any cleanups and removing any files
inside it.
"""
subnets = (
str(net.gw()) for net in self.virt_env.get_nets().itervalues()
)
self._subnet_store.release(subnets)
self.cleanup()
shu... | python | def destroy(self):
"""
Destroy this prefix, running any cleanups and removing any files
inside it.
"""
subnets = (
str(net.gw()) for net in self.virt_env.get_nets().itervalues()
)
self._subnet_store.release(subnets)
self.cleanup()
shu... | [
"def",
"destroy",
"(",
"self",
")",
":",
"subnets",
"=",
"(",
"str",
"(",
"net",
".",
"gw",
"(",
")",
")",
"for",
"net",
"in",
"self",
".",
"virt_env",
".",
"get_nets",
"(",
")",
".",
"itervalues",
"(",
")",
")",
"self",
".",
"_subnet_store",
"."... | Destroy this prefix, running any cleanups and removing any files
inside it. | [
"Destroy",
"this",
"prefix",
"running",
"any",
"cleanups",
"and",
"removing",
"any",
"files",
"inside",
"it",
"."
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1414-L1426 | train |
lago-project/lago | lago/prefix.py | Prefix.is_prefix | def is_prefix(cls, path):
"""
Check if a path is a valid prefix
Args:
path(str): path to be checked
Returns:
bool: True if the given path is a prefix
"""
lagofile = paths.Paths(path).prefix_lagofile()
return os.path.isfile(lagofile) | python | def is_prefix(cls, path):
"""
Check if a path is a valid prefix
Args:
path(str): path to be checked
Returns:
bool: True if the given path is a prefix
"""
lagofile = paths.Paths(path).prefix_lagofile()
return os.path.isfile(lagofile) | [
"def",
"is_prefix",
"(",
"cls",
",",
"path",
")",
":",
"lagofile",
"=",
"paths",
".",
"Paths",
"(",
"path",
")",
".",
"prefix_lagofile",
"(",
")",
"return",
"os",
".",
"path",
".",
"isfile",
"(",
"lagofile",
")"
] | Check if a path is a valid prefix
Args:
path(str): path to be checked
Returns:
bool: True if the given path is a prefix | [
"Check",
"if",
"a",
"path",
"is",
"a",
"valid",
"prefix"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1501-L1512 | train |
lago-project/lago | lago/prefix.py | Prefix._get_scripts | def _get_scripts(self, host_metadata):
"""
Temporary method to retrieve the host scripts
TODO:
remove once the "ovirt-scripts" option gets deprecated
Args:
host_metadata(dict): host metadata to retrieve the scripts for
Returns:
list: deploy ... | python | def _get_scripts(self, host_metadata):
"""
Temporary method to retrieve the host scripts
TODO:
remove once the "ovirt-scripts" option gets deprecated
Args:
host_metadata(dict): host metadata to retrieve the scripts for
Returns:
list: deploy ... | [
"def",
"_get_scripts",
"(",
"self",
",",
"host_metadata",
")",
":",
"deploy_scripts",
"=",
"host_metadata",
".",
"get",
"(",
"'deploy-scripts'",
",",
"[",
"]",
")",
"if",
"deploy_scripts",
":",
"return",
"deploy_scripts",
"ovirt_scripts",
"=",
"host_metadata",
"... | Temporary method to retrieve the host scripts
TODO:
remove once the "ovirt-scripts" option gets deprecated
Args:
host_metadata(dict): host metadata to retrieve the scripts for
Returns:
list: deploy scripts for the host, empty if none found | [
"Temporary",
"method",
"to",
"retrieve",
"the",
"host",
"scripts"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1533-L1557 | train |
lago-project/lago | lago/prefix.py | Prefix._set_scripts | def _set_scripts(self, host_metadata, scripts):
"""
Temporary method to set the host scripts
TODO:
remove once the "ovirt-scripts" option gets deprecated
Args:
host_metadata(dict): host metadata to set scripts in
Returns:
dict: the updated m... | python | def _set_scripts(self, host_metadata, scripts):
"""
Temporary method to set the host scripts
TODO:
remove once the "ovirt-scripts" option gets deprecated
Args:
host_metadata(dict): host metadata to set scripts in
Returns:
dict: the updated m... | [
"def",
"_set_scripts",
"(",
"self",
",",
"host_metadata",
",",
"scripts",
")",
":",
"scripts_key",
"=",
"'deploy-scripts'",
"if",
"'ovirt-scritps'",
"in",
"host_metadata",
":",
"scripts_key",
"=",
"'ovirt-scripts'",
"host_metadata",
"[",
"scripts_key",
"]",
"=",
"... | Temporary method to set the host scripts
TODO:
remove once the "ovirt-scripts" option gets deprecated
Args:
host_metadata(dict): host metadata to set scripts in
Returns:
dict: the updated metadata | [
"Temporary",
"method",
"to",
"set",
"the",
"host",
"scripts"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1559-L1577 | train |
lago-project/lago | lago/prefix.py | Prefix._copy_deploy_scripts_for_hosts | def _copy_deploy_scripts_for_hosts(self, domains):
"""
Copy the deploy scripts for all the domains into the prefix scripts dir
Args:
domains(dict): spec with the domains info as when loaded from the
initfile
Returns:
None
"""
with... | python | def _copy_deploy_scripts_for_hosts(self, domains):
"""
Copy the deploy scripts for all the domains into the prefix scripts dir
Args:
domains(dict): spec with the domains info as when loaded from the
initfile
Returns:
None
"""
with... | [
"def",
"_copy_deploy_scripts_for_hosts",
"(",
"self",
",",
"domains",
")",
":",
"with",
"LogTask",
"(",
"'Copying any deploy scripts'",
")",
":",
"for",
"host_name",
",",
"host_spec",
"in",
"domains",
".",
"iteritems",
"(",
")",
":",
"host_metadata",
"=",
"host_... | Copy the deploy scripts for all the domains into the prefix scripts dir
Args:
domains(dict): spec with the domains info as when loaded from the
initfile
Returns:
None | [
"Copy",
"the",
"deploy",
"scripts",
"for",
"all",
"the",
"domains",
"into",
"the",
"prefix",
"scripts",
"dir"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1579-L1600 | train |
lago-project/lago | lago/prefix.py | Prefix._copy_delpoy_scripts | def _copy_delpoy_scripts(self, scripts):
"""
Copy the given deploy scripts to the scripts dir in the prefix
Args:
scripts(list of str): list of paths of the scripts to copy to the
prefix
Returns:
list of str: list with the paths to the copied scr... | python | def _copy_delpoy_scripts(self, scripts):
"""
Copy the given deploy scripts to the scripts dir in the prefix
Args:
scripts(list of str): list of paths of the scripts to copy to the
prefix
Returns:
list of str: list with the paths to the copied scr... | [
"def",
"_copy_delpoy_scripts",
"(",
"self",
",",
"scripts",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"paths",
".",
"scripts",
"(",
")",
")",
":",
"os",
".",
"makedirs",
"(",
"self",
".",
"paths",
".",
"scripts",
"(... | Copy the given deploy scripts to the scripts dir in the prefix
Args:
scripts(list of str): list of paths of the scripts to copy to the
prefix
Returns:
list of str: list with the paths to the copied scripts, with a
prefixed with $LAGO_PREFIX_PATH ... | [
"Copy",
"the",
"given",
"deploy",
"scripts",
"to",
"the",
"scripts",
"dir",
"in",
"the",
"prefix"
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/prefix.py#L1602-L1637 | train |
lago-project/lago | lago/config.py | ConfigLoad.update_args | def update_args(self, args):
"""Update config dictionary with parsed args, as resolved by argparse.
Only root positional arguments that already exist will overridden.
Args:
args (namespace): args parsed by argparse
"""
for arg in vars(args):
if self.get... | python | def update_args(self, args):
"""Update config dictionary with parsed args, as resolved by argparse.
Only root positional arguments that already exist will overridden.
Args:
args (namespace): args parsed by argparse
"""
for arg in vars(args):
if self.get... | [
"def",
"update_args",
"(",
"self",
",",
"args",
")",
":",
"for",
"arg",
"in",
"vars",
"(",
"args",
")",
":",
"if",
"self",
".",
"get",
"(",
"arg",
")",
"and",
"getattr",
"(",
"args",
",",
"arg",
")",
"is",
"not",
"None",
":",
"self",
".",
"_con... | Update config dictionary with parsed args, as resolved by argparse.
Only root positional arguments that already exist will overridden.
Args:
args (namespace): args parsed by argparse | [
"Update",
"config",
"dictionary",
"with",
"parsed",
"args",
"as",
"resolved",
"by",
"argparse",
".",
"Only",
"root",
"positional",
"arguments",
"that",
"already",
"exist",
"will",
"overridden",
"."
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/config.py#L148-L159 | train |
lago-project/lago | lago/config.py | ConfigLoad.update_parser | def update_parser(self, parser):
"""Update config dictionary with declared arguments in an argparse.parser
New variables will be created, and existing ones overridden.
Args:
parser (argparse.ArgumentParser): parser to read variables from
"""
self._parser = parser
... | python | def update_parser(self, parser):
"""Update config dictionary with declared arguments in an argparse.parser
New variables will be created, and existing ones overridden.
Args:
parser (argparse.ArgumentParser): parser to read variables from
"""
self._parser = parser
... | [
"def",
"update_parser",
"(",
"self",
",",
"parser",
")",
":",
"self",
".",
"_parser",
"=",
"parser",
"ini_str",
"=",
"argparse_to_ini",
"(",
"parser",
")",
"configp",
"=",
"configparser",
".",
"ConfigParser",
"(",
"allow_no_value",
"=",
"True",
")",
"configp... | Update config dictionary with declared arguments in an argparse.parser
New variables will be created, and existing ones overridden.
Args:
parser (argparse.ArgumentParser): parser to read variables from | [
"Update",
"config",
"dictionary",
"with",
"declared",
"arguments",
"in",
"an",
"argparse",
".",
"parser",
"New",
"variables",
"will",
"be",
"created",
"and",
"existing",
"ones",
"overridden",
"."
] | 5b8970f7687e063e4619066d5b8093ca997678c9 | https://github.com/lago-project/lago/blob/5b8970f7687e063e4619066d5b8093ca997678c9/lago/config.py#L161-L178 | train |
eXamadeus/godaddypy | godaddypy/client.py | Client._request_submit | def _request_submit(self, func, **kwargs):
"""A helper function that will wrap any requests we make.
:param func: a function reference to the requests method to invoke
:param kwargs: any extra arguments that requests.request takes
:type func: (url: Any, data: Any, json: Any, kwargs: Di... | python | def _request_submit(self, func, **kwargs):
"""A helper function that will wrap any requests we make.
:param func: a function reference to the requests method to invoke
:param kwargs: any extra arguments that requests.request takes
:type func: (url: Any, data: Any, json: Any, kwargs: Di... | [
"def",
"_request_submit",
"(",
"self",
",",
"func",
",",
"**",
"kwargs",
")",
":",
"resp",
"=",
"func",
"(",
"headers",
"=",
"self",
".",
"_get_headers",
"(",
")",
",",
"**",
"kwargs",
")",
"self",
".",
"_log_response_from_method",
"(",
"func",
".",
"_... | A helper function that will wrap any requests we make.
:param func: a function reference to the requests method to invoke
:param kwargs: any extra arguments that requests.request takes
:type func: (url: Any, data: Any, json: Any, kwargs: Dict) | [
"A",
"helper",
"function",
"that",
"will",
"wrap",
"any",
"requests",
"we",
"make",
"."
] | 67820604ffe233a67ef9f6b3a59ab85b02653e57 | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L80-L91 | train |
eXamadeus/godaddypy | godaddypy/client.py | Client.add_records | def add_records(self, domain, records):
"""Adds the specified DNS records to a domain.
:param domain: the domain to add the records to
:param records: the records to add
"""
url = self.API_TEMPLATE + self.RECORDS.format(domain=domain)
self._patch(url, json=records)
... | python | def add_records(self, domain, records):
"""Adds the specified DNS records to a domain.
:param domain: the domain to add the records to
:param records: the records to add
"""
url = self.API_TEMPLATE + self.RECORDS.format(domain=domain)
self._patch(url, json=records)
... | [
"def",
"add_records",
"(",
"self",
",",
"domain",
",",
"records",
")",
":",
"url",
"=",
"self",
".",
"API_TEMPLATE",
"+",
"self",
".",
"RECORDS",
".",
"format",
"(",
"domain",
"=",
"domain",
")",
"self",
".",
"_patch",
"(",
"url",
",",
"json",
"=",
... | Adds the specified DNS records to a domain.
:param domain: the domain to add the records to
:param records: the records to add | [
"Adds",
"the",
"specified",
"DNS",
"records",
"to",
"a",
"domain",
"."
] | 67820604ffe233a67ef9f6b3a59ab85b02653e57 | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L113-L124 | train |
eXamadeus/godaddypy | godaddypy/client.py | Client.get_domain_info | def get_domain_info(self, domain):
"""Get the GoDaddy supplied information about a specific domain.
:param domain: The domain to obtain info about.
:type domain: str
:return A JSON string representing the domain information
"""
url = self.API_TEMPLATE + self.DOMAIN_INFO... | python | def get_domain_info(self, domain):
"""Get the GoDaddy supplied information about a specific domain.
:param domain: The domain to obtain info about.
:type domain: str
:return A JSON string representing the domain information
"""
url = self.API_TEMPLATE + self.DOMAIN_INFO... | [
"def",
"get_domain_info",
"(",
"self",
",",
"domain",
")",
":",
"url",
"=",
"self",
".",
"API_TEMPLATE",
"+",
"self",
".",
"DOMAIN_INFO",
".",
"format",
"(",
"domain",
"=",
"domain",
")",
"return",
"self",
".",
"_get_json_from_response",
"(",
"url",
")"
] | Get the GoDaddy supplied information about a specific domain.
:param domain: The domain to obtain info about.
:type domain: str
:return A JSON string representing the domain information | [
"Get",
"the",
"GoDaddy",
"supplied",
"information",
"about",
"a",
"specific",
"domain",
"."
] | 67820604ffe233a67ef9f6b3a59ab85b02653e57 | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L126-L135 | train |
eXamadeus/godaddypy | godaddypy/client.py | Client.get_domains | def get_domains(self):
"""Returns a list of domains for the authenticated user.
"""
url = self.API_TEMPLATE + self.DOMAINS
data = self._get_json_from_response(url)
domains = list()
for item in data:
domain = item['domain']
domains.append(domain)
... | python | def get_domains(self):
"""Returns a list of domains for the authenticated user.
"""
url = self.API_TEMPLATE + self.DOMAINS
data = self._get_json_from_response(url)
domains = list()
for item in data:
domain = item['domain']
domains.append(domain)
... | [
"def",
"get_domains",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"API_TEMPLATE",
"+",
"self",
".",
"DOMAINS",
"data",
"=",
"self",
".",
"_get_json_from_response",
"(",
"url",
")",
"domains",
"=",
"list",
"(",
")",
"for",
"item",
"in",
"data",
":",... | Returns a list of domains for the authenticated user. | [
"Returns",
"a",
"list",
"of",
"domains",
"for",
"the",
"authenticated",
"user",
"."
] | 67820604ffe233a67ef9f6b3a59ab85b02653e57 | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L137-L149 | train |
eXamadeus/godaddypy | godaddypy/client.py | Client.replace_records | def replace_records(self, domain, records, record_type=None, name=None):
"""This will replace all records at the domain. Record type and record name can be provided to filter
which records to replace.
:param domain: the domain to replace records at
:param records: the records you will ... | python | def replace_records(self, domain, records, record_type=None, name=None):
"""This will replace all records at the domain. Record type and record name can be provided to filter
which records to replace.
:param domain: the domain to replace records at
:param records: the records you will ... | [
"def",
"replace_records",
"(",
"self",
",",
"domain",
",",
"records",
",",
"record_type",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_build_record_url",
"(",
"domain",
",",
"name",
"=",
"name",
",",
"record_type",
"=",
"... | This will replace all records at the domain. Record type and record name can be provided to filter
which records to replace.
:param domain: the domain to replace records at
:param records: the records you will be saving
:param record_type: the type of records you want to replace (eg. o... | [
"This",
"will",
"replace",
"all",
"records",
"at",
"the",
"domain",
".",
"Record",
"type",
"and",
"record",
"name",
"can",
"be",
"provided",
"to",
"filter",
"which",
"records",
"to",
"replace",
"."
] | 67820604ffe233a67ef9f6b3a59ab85b02653e57 | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L187-L203 | train |
eXamadeus/godaddypy | godaddypy/client.py | Client.update_record | def update_record(self, domain, record, record_type=None, name=None):
"""Call to GoDaddy API to update a single DNS record
:param name: only required if the record is None (deletion)
:param record_type: only required if the record is None (deletion)
:param domain: the domain where the D... | python | def update_record(self, domain, record, record_type=None, name=None):
"""Call to GoDaddy API to update a single DNS record
:param name: only required if the record is None (deletion)
:param record_type: only required if the record is None (deletion)
:param domain: the domain where the D... | [
"def",
"update_record",
"(",
"self",
",",
"domain",
",",
"record",
",",
"record_type",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"if",
"record_type",
"is",
"None",
":",
"record_type",
"=",
"record",
"[",
"'type'",
"]",
"if",
"name",
"is",
"None"... | Call to GoDaddy API to update a single DNS record
:param name: only required if the record is None (deletion)
:param record_type: only required if the record is None (deletion)
:param domain: the domain where the DNS belongs to (eg. 'example.com')
:param record: dict with record info (e... | [
"Call",
"to",
"GoDaddy",
"API",
"to",
"update",
"a",
"single",
"DNS",
"record"
] | 67820604ffe233a67ef9f6b3a59ab85b02653e57 | https://github.com/eXamadeus/godaddypy/blob/67820604ffe233a67ef9f6b3a59ab85b02653e57/godaddypy/client.py#L284-L305 | train |
tokibito/django-ftpserver | django_ftpserver/utils.py | parse_ports | def parse_ports(ports_text):
"""Parse ports text
e.g. ports_text = "12345,13000-15000,20000-30000"
"""
ports_set = set()
for bit in ports_text.split(','):
if '-' in bit:
low, high = bit.split('-', 1)
ports_set = ports_set.union(range(int(low), int(high) + 1))
... | python | def parse_ports(ports_text):
"""Parse ports text
e.g. ports_text = "12345,13000-15000,20000-30000"
"""
ports_set = set()
for bit in ports_text.split(','):
if '-' in bit:
low, high = bit.split('-', 1)
ports_set = ports_set.union(range(int(low), int(high) + 1))
... | [
"def",
"parse_ports",
"(",
"ports_text",
")",
":",
"ports_set",
"=",
"set",
"(",
")",
"for",
"bit",
"in",
"ports_text",
".",
"split",
"(",
"','",
")",
":",
"if",
"'-'",
"in",
"bit",
":",
"low",
",",
"high",
"=",
"bit",
".",
"split",
"(",
"'-'",
"... | Parse ports text
e.g. ports_text = "12345,13000-15000,20000-30000" | [
"Parse",
"ports",
"text"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/utils.py#L10-L22 | train |
tokibito/django-ftpserver | django_ftpserver/utils.py | make_server | def make_server(
server_class, handler_class, authorizer_class, filesystem_class,
host_port, file_access_user=None, **handler_options):
"""make server instance
:host_port: (host, port)
:file_access_user: 'spam'
handler_options:
* timeout
* passive_ports
* masquerade_... | python | def make_server(
server_class, handler_class, authorizer_class, filesystem_class,
host_port, file_access_user=None, **handler_options):
"""make server instance
:host_port: (host, port)
:file_access_user: 'spam'
handler_options:
* timeout
* passive_ports
* masquerade_... | [
"def",
"make_server",
"(",
"server_class",
",",
"handler_class",
",",
"authorizer_class",
",",
"filesystem_class",
",",
"host_port",
",",
"file_access_user",
"=",
"None",
",",
"**",
"handler_options",
")",
":",
"from",
".",
"import",
"compat",
"if",
"isinstance",
... | make server instance
:host_port: (host, port)
:file_access_user: 'spam'
handler_options:
* timeout
* passive_ports
* masquerade_address
* certfile
* keyfile | [
"make",
"server",
"instance"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/utils.py#L34-L67 | train |
tokibito/django-ftpserver | django_ftpserver/filesystems.py | StoragePatch.apply | def apply(cls, fs):
"""replace bound methods of fs.
"""
logger.debug(
'Patching %s with %s.', fs.__class__.__name__, cls.__name__)
fs._patch = cls
for method_name in cls.patch_methods:
# if fs hasn't method, raise AttributeError.
origin = getat... | python | def apply(cls, fs):
"""replace bound methods of fs.
"""
logger.debug(
'Patching %s with %s.', fs.__class__.__name__, cls.__name__)
fs._patch = cls
for method_name in cls.patch_methods:
# if fs hasn't method, raise AttributeError.
origin = getat... | [
"def",
"apply",
"(",
"cls",
",",
"fs",
")",
":",
"logger",
".",
"debug",
"(",
"'Patching %s with %s.'",
",",
"fs",
".",
"__class__",
".",
"__name__",
",",
"cls",
".",
"__name__",
")",
"fs",
".",
"_patch",
"=",
"cls",
"for",
"method_name",
"in",
"cls",
... | replace bound methods of fs. | [
"replace",
"bound",
"methods",
"of",
"fs",
"."
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/filesystems.py#L29-L41 | train |
tokibito/django-ftpserver | django_ftpserver/filesystems.py | S3Boto3StoragePatch._exists | def _exists(self, path):
"""S3 directory is not S3Ojbect.
"""
if path.endswith('/'):
return True
return self.storage.exists(path) | python | def _exists(self, path):
"""S3 directory is not S3Ojbect.
"""
if path.endswith('/'):
return True
return self.storage.exists(path) | [
"def",
"_exists",
"(",
"self",
",",
"path",
")",
":",
"if",
"path",
".",
"endswith",
"(",
"'/'",
")",
":",
"return",
"True",
"return",
"self",
".",
"storage",
".",
"exists",
"(",
"path",
")"
] | S3 directory is not S3Ojbect. | [
"S3",
"directory",
"is",
"not",
"S3Ojbect",
"."
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/filesystems.py#L68-L73 | train |
tokibito/django-ftpserver | django_ftpserver/filesystems.py | StorageFS.apply_patch | def apply_patch(self):
"""apply adjustment patch for storage
"""
patch = self.patches.get(self.storage.__class__.__name__)
if patch:
patch.apply(self) | python | def apply_patch(self):
"""apply adjustment patch for storage
"""
patch = self.patches.get(self.storage.__class__.__name__)
if patch:
patch.apply(self) | [
"def",
"apply_patch",
"(",
"self",
")",
":",
"patch",
"=",
"self",
".",
"patches",
".",
"get",
"(",
"self",
".",
"storage",
".",
"__class__",
".",
"__name__",
")",
"if",
"patch",
":",
"patch",
".",
"apply",
"(",
"self",
")"
] | apply adjustment patch for storage | [
"apply",
"adjustment",
"patch",
"for",
"storage"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/filesystems.py#L122-L127 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.has_user | def has_user(self, username):
"""return True if exists user.
"""
return self.model.objects.filter(
**self._filter_user_by(username)
).exists() | python | def has_user(self, username):
"""return True if exists user.
"""
return self.model.objects.filter(
**self._filter_user_by(username)
).exists() | [
"def",
"has_user",
"(",
"self",
",",
"username",
")",
":",
"return",
"self",
".",
"model",
".",
"objects",
".",
"filter",
"(",
"**",
"self",
".",
"_filter_user_by",
"(",
"username",
")",
")",
".",
"exists",
"(",
")"
] | return True if exists user. | [
"return",
"True",
"if",
"exists",
"user",
"."
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L39-L44 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.get_account | def get_account(self, username):
"""return user by username.
"""
try:
account = self.model.objects.get(
**self._filter_user_by(username)
)
except self.model.DoesNotExist:
return None
return account | python | def get_account(self, username):
"""return user by username.
"""
try:
account = self.model.objects.get(
**self._filter_user_by(username)
)
except self.model.DoesNotExist:
return None
return account | [
"def",
"get_account",
"(",
"self",
",",
"username",
")",
":",
"try",
":",
"account",
"=",
"self",
".",
"model",
".",
"objects",
".",
"get",
"(",
"**",
"self",
".",
"_filter_user_by",
"(",
"username",
")",
")",
"except",
"self",
".",
"model",
".",
"Do... | return user by username. | [
"return",
"user",
"by",
"username",
"."
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L46-L55 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.validate_authentication | def validate_authentication(self, username, password, handler):
"""authenticate user with password
"""
user = authenticate(
**{self.username_field: username, 'password': password}
)
account = self.get_account(username)
if not (user and account):
ra... | python | def validate_authentication(self, username, password, handler):
"""authenticate user with password
"""
user = authenticate(
**{self.username_field: username, 'password': password}
)
account = self.get_account(username)
if not (user and account):
ra... | [
"def",
"validate_authentication",
"(",
"self",
",",
"username",
",",
"password",
",",
"handler",
")",
":",
"user",
"=",
"authenticate",
"(",
"**",
"{",
"self",
".",
"username_field",
":",
"username",
",",
"'password'",
":",
"password",
"}",
")",
"account",
... | authenticate user with password | [
"authenticate",
"user",
"with",
"password"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L57-L65 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.get_msg_login | def get_msg_login(self, username):
"""message for welcome.
"""
account = self.get_account(username)
if account:
account.update_last_login()
account.save()
return 'welcome.' | python | def get_msg_login(self, username):
"""message for welcome.
"""
account = self.get_account(username)
if account:
account.update_last_login()
account.save()
return 'welcome.' | [
"def",
"get_msg_login",
"(",
"self",
",",
"username",
")",
":",
"account",
"=",
"self",
".",
"get_account",
"(",
"username",
")",
"if",
"account",
":",
"account",
".",
"update_last_login",
"(",
")",
"account",
".",
"save",
"(",
")",
"return",
"'welcome.'"
... | message for welcome. | [
"message",
"for",
"welcome",
"."
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L73-L80 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.has_perm | def has_perm(self, username, perm, path=None):
"""check user permission
"""
account = self.get_account(username)
return account and account.has_perm(perm, path) | python | def has_perm(self, username, perm, path=None):
"""check user permission
"""
account = self.get_account(username)
return account and account.has_perm(perm, path) | [
"def",
"has_perm",
"(",
"self",
",",
"username",
",",
"perm",
",",
"path",
"=",
"None",
")",
":",
"account",
"=",
"self",
".",
"get_account",
"(",
"username",
")",
"return",
"account",
"and",
"account",
".",
"has_perm",
"(",
"perm",
",",
"path",
")"
] | check user permission | [
"check",
"user",
"permission"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L85-L89 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.get_perms | def get_perms(self, username):
"""return user permissions
"""
account = self.get_account(username)
return account and account.get_perms() | python | def get_perms(self, username):
"""return user permissions
"""
account = self.get_account(username)
return account and account.get_perms() | [
"def",
"get_perms",
"(",
"self",
",",
"username",
")",
":",
"account",
"=",
"self",
".",
"get_account",
"(",
"username",
")",
"return",
"account",
"and",
"account",
".",
"get_perms",
"(",
")"
] | return user permissions | [
"return",
"user",
"permissions"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L91-L95 | train |
tokibito/django-ftpserver | django_ftpserver/authorizers.py | FTPAccountAuthorizer.impersonate_user | def impersonate_user(self, username, password):
"""delegate to personate_user method
"""
if self.personate_user:
self.personate_user.impersonate_user(username, password) | python | def impersonate_user(self, username, password):
"""delegate to personate_user method
"""
if self.personate_user:
self.personate_user.impersonate_user(username, password) | [
"def",
"impersonate_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"if",
"self",
".",
"personate_user",
":",
"self",
".",
"personate_user",
".",
"impersonate_user",
"(",
"username",
",",
"password",
")"
] | delegate to personate_user method | [
"delegate",
"to",
"personate_user",
"method"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/authorizers.py#L97-L101 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | ColorHelper.hex_to_rgb | def hex_to_rgb(self, h):
"""Converts a valid hex color string to an RGB array."""
rgb = (self.hex_to_red(h), self.hex_to_green(h), self.hex_to_blue(h))
return rgb | python | def hex_to_rgb(self, h):
"""Converts a valid hex color string to an RGB array."""
rgb = (self.hex_to_red(h), self.hex_to_green(h), self.hex_to_blue(h))
return rgb | [
"def",
"hex_to_rgb",
"(",
"self",
",",
"h",
")",
":",
"rgb",
"=",
"(",
"self",
".",
"hex_to_red",
"(",
"h",
")",
",",
"self",
".",
"hex_to_green",
"(",
"h",
")",
",",
"self",
".",
"hex_to_blue",
"(",
"h",
")",
")",
"return",
"rgb"
] | Converts a valid hex color string to an RGB array. | [
"Converts",
"a",
"valid",
"hex",
"color",
"string",
"to",
"an",
"RGB",
"array",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L73-L76 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | ColorHelper.cross_product | def cross_product(self, p1, p2):
"""Returns the cross product of two XYPoints."""
return (p1.x * p2.y - p1.y * p2.x) | python | def cross_product(self, p1, p2):
"""Returns the cross product of two XYPoints."""
return (p1.x * p2.y - p1.y * p2.x) | [
"def",
"cross_product",
"(",
"self",
",",
"p1",
",",
"p2",
")",
":",
"return",
"(",
"p1",
".",
"x",
"*",
"p2",
".",
"y",
"-",
"p1",
".",
"y",
"*",
"p2",
".",
"x",
")"
] | Returns the cross product of two XYPoints. | [
"Returns",
"the",
"cross",
"product",
"of",
"two",
"XYPoints",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L86-L88 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | ColorHelper.get_distance_between_two_points | def get_distance_between_two_points(self, one, two):
"""Returns the distance between two XYPoints."""
dx = one.x - two.x
dy = one.y - two.y
return math.sqrt(dx * dx + dy * dy) | python | def get_distance_between_two_points(self, one, two):
"""Returns the distance between two XYPoints."""
dx = one.x - two.x
dy = one.y - two.y
return math.sqrt(dx * dx + dy * dy) | [
"def",
"get_distance_between_two_points",
"(",
"self",
",",
"one",
",",
"two",
")",
":",
"dx",
"=",
"one",
".",
"x",
"-",
"two",
".",
"x",
"dy",
"=",
"one",
".",
"y",
"-",
"two",
".",
"y",
"return",
"math",
".",
"sqrt",
"(",
"dx",
"*",
"dx",
"+... | Returns the distance between two XYPoints. | [
"Returns",
"the",
"distance",
"between",
"two",
"XYPoints",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L144-L148 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | ColorHelper.get_xy_point_from_rgb | def get_xy_point_from_rgb(self, red_i, green_i, blue_i):
"""Returns an XYPoint object containing the closest available CIE 1931 x, y coordinates
based on the RGB input values."""
red = red_i / 255.0
green = green_i / 255.0
blue = blue_i / 255.0
r = ((red + 0.055) / (1.0... | python | def get_xy_point_from_rgb(self, red_i, green_i, blue_i):
"""Returns an XYPoint object containing the closest available CIE 1931 x, y coordinates
based on the RGB input values."""
red = red_i / 255.0
green = green_i / 255.0
blue = blue_i / 255.0
r = ((red + 0.055) / (1.0... | [
"def",
"get_xy_point_from_rgb",
"(",
"self",
",",
"red_i",
",",
"green_i",
",",
"blue_i",
")",
":",
"red",
"=",
"red_i",
"/",
"255.0",
"green",
"=",
"green_i",
"/",
"255.0",
"blue",
"=",
"blue_i",
"/",
"255.0",
"r",
"=",
"(",
"(",
"red",
"+",
"0.055"... | Returns an XYPoint object containing the closest available CIE 1931 x, y coordinates
based on the RGB input values. | [
"Returns",
"an",
"XYPoint",
"object",
"containing",
"the",
"closest",
"available",
"CIE",
"1931",
"x",
"y",
"coordinates",
"based",
"on",
"the",
"RGB",
"input",
"values",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L150-L176 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | Converter.hex_to_xy | def hex_to_xy(self, h):
"""Converts hexadecimal colors represented as a String to approximate CIE
1931 x and y coordinates.
"""
rgb = self.color.hex_to_rgb(h)
return self.rgb_to_xy(rgb[0], rgb[1], rgb[2]) | python | def hex_to_xy(self, h):
"""Converts hexadecimal colors represented as a String to approximate CIE
1931 x and y coordinates.
"""
rgb = self.color.hex_to_rgb(h)
return self.rgb_to_xy(rgb[0], rgb[1], rgb[2]) | [
"def",
"hex_to_xy",
"(",
"self",
",",
"h",
")",
":",
"rgb",
"=",
"self",
".",
"color",
".",
"hex_to_rgb",
"(",
"h",
")",
"return",
"self",
".",
"rgb_to_xy",
"(",
"rgb",
"[",
"0",
"]",
",",
"rgb",
"[",
"1",
"]",
",",
"rgb",
"[",
"2",
"]",
")"
... | Converts hexadecimal colors represented as a String to approximate CIE
1931 x and y coordinates. | [
"Converts",
"hexadecimal",
"colors",
"represented",
"as",
"a",
"String",
"to",
"approximate",
"CIE",
"1931",
"x",
"and",
"y",
"coordinates",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L228-L233 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | Converter.rgb_to_xy | def rgb_to_xy(self, red, green, blue):
"""Converts red, green and blue integer values to approximate CIE 1931
x and y coordinates.
"""
point = self.color.get_xy_point_from_rgb(red, green, blue)
return (point.x, point.y) | python | def rgb_to_xy(self, red, green, blue):
"""Converts red, green and blue integer values to approximate CIE 1931
x and y coordinates.
"""
point = self.color.get_xy_point_from_rgb(red, green, blue)
return (point.x, point.y) | [
"def",
"rgb_to_xy",
"(",
"self",
",",
"red",
",",
"green",
",",
"blue",
")",
":",
"point",
"=",
"self",
".",
"color",
".",
"get_xy_point_from_rgb",
"(",
"red",
",",
"green",
",",
"blue",
")",
"return",
"(",
"point",
".",
"x",
",",
"point",
".",
"y"... | Converts red, green and blue integer values to approximate CIE 1931
x and y coordinates. | [
"Converts",
"red",
"green",
"and",
"blue",
"integer",
"values",
"to",
"approximate",
"CIE",
"1931",
"x",
"and",
"y",
"coordinates",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L235-L240 | train |
benknight/hue-python-rgb-converter | rgbxy/__init__.py | Converter.get_random_xy_color | def get_random_xy_color(self):
"""Returns the approximate CIE 1931 x,y coordinates represented by the
supplied hexColor parameter, or of a random color if the parameter
is not passed."""
r = self.color.random_rgb_value()
g = self.color.random_rgb_value()
b = self.color.ra... | python | def get_random_xy_color(self):
"""Returns the approximate CIE 1931 x,y coordinates represented by the
supplied hexColor parameter, or of a random color if the parameter
is not passed."""
r = self.color.random_rgb_value()
g = self.color.random_rgb_value()
b = self.color.ra... | [
"def",
"get_random_xy_color",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"color",
".",
"random_rgb_value",
"(",
")",
"g",
"=",
"self",
".",
"color",
".",
"random_rgb_value",
"(",
")",
"b",
"=",
"self",
".",
"color",
".",
"random_rgb_value",
"(",
")"... | Returns the approximate CIE 1931 x,y coordinates represented by the
supplied hexColor parameter, or of a random color if the parameter
is not passed. | [
"Returns",
"the",
"approximate",
"CIE",
"1931",
"x",
"y",
"coordinates",
"represented",
"by",
"the",
"supplied",
"hexColor",
"parameter",
"or",
"of",
"a",
"random",
"color",
"if",
"the",
"parameter",
"is",
"not",
"passed",
"."
] | 76dd70eac7a56a1260fd94a52cca3991cd57dff0 | https://github.com/benknight/hue-python-rgb-converter/blob/76dd70eac7a56a1260fd94a52cca3991cd57dff0/rgbxy/__init__.py#L254-L261 | train |
tokibito/django-ftpserver | django_ftpserver/compat.py | become_daemon | def become_daemon(*args, **kwargs):
"""become_daemon function wrapper
In Django 1.9, 'become_daemon' is removed.
It means compatibility.
"""
if django.VERSION >= (1, 9):
from .daemonize import become_daemon
else:
from django.utils.daemonize import become_daemon
return become... | python | def become_daemon(*args, **kwargs):
"""become_daemon function wrapper
In Django 1.9, 'become_daemon' is removed.
It means compatibility.
"""
if django.VERSION >= (1, 9):
from .daemonize import become_daemon
else:
from django.utils.daemonize import become_daemon
return become... | [
"def",
"become_daemon",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"django",
".",
"VERSION",
">=",
"(",
"1",
",",
"9",
")",
":",
"from",
".",
"daemonize",
"import",
"become_daemon",
"else",
":",
"from",
"django",
".",
"utils",
".",
"daemo... | become_daemon function wrapper
In Django 1.9, 'become_daemon' is removed.
It means compatibility. | [
"become_daemon",
"function",
"wrapper"
] | 18cf9f6645df9c2d9c5188bf21e74c188d55de47 | https://github.com/tokibito/django-ftpserver/blob/18cf9f6645df9c2d9c5188bf21e74c188d55de47/django_ftpserver/compat.py#L15-L25 | train |
spacetelescope/pysynphot | commissioning/convert/conv_base.py | SpecCase.setUpClass | def setUpClass(cls):
"""Always overridden by the child cases, but let's put some
real values in here to test with"""
self.obsmode=None
self.spectrum=None
self.bp=None
self.sp=None
self.obs=None
self.setup2() | python | def setUpClass(cls):
"""Always overridden by the child cases, but let's put some
real values in here to test with"""
self.obsmode=None
self.spectrum=None
self.bp=None
self.sp=None
self.obs=None
self.setup2() | [
"def",
"setUpClass",
"(",
"cls",
")",
":",
"self",
".",
"obsmode",
"=",
"None",
"self",
".",
"spectrum",
"=",
"None",
"self",
".",
"bp",
"=",
"None",
"self",
".",
"sp",
"=",
"None",
"self",
".",
"obs",
"=",
"None",
"self",
".",
"setup2",
"(",
")"... | Always overridden by the child cases, but let's put some
real values in here to test with | [
"Always",
"overridden",
"by",
"the",
"child",
"cases",
"but",
"let",
"s",
"put",
"some",
"real",
"values",
"in",
"here",
"to",
"test",
"with"
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/convert/conv_base.py#L22-L30 | train |
spacetelescope/pysynphot | pysynphot/graphtab.py | GraphTable.validate | def validate(self):
""" Simulataneously checks for loops and unreachable nodes
"""
msg = list()
previously_seen = set()
currently_seen = set([1])
problemset = set()
while currently_seen:
node = currently_seen.pop()
if node in previously_see... | python | def validate(self):
""" Simulataneously checks for loops and unreachable nodes
"""
msg = list()
previously_seen = set()
currently_seen = set([1])
problemset = set()
while currently_seen:
node = currently_seen.pop()
if node in previously_see... | [
"def",
"validate",
"(",
"self",
")",
":",
"msg",
"=",
"list",
"(",
")",
"previously_seen",
"=",
"set",
"(",
")",
"currently_seen",
"=",
"set",
"(",
"[",
"1",
"]",
")",
"problemset",
"=",
"set",
"(",
")",
"while",
"currently_seen",
":",
"node",
"=",
... | Simulataneously checks for loops and unreachable nodes | [
"Simulataneously",
"checks",
"for",
"loops",
"and",
"unreachable",
"nodes"
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/graphtab.py#L242-L271 | train |
spacetelescope/pysynphot | pysynphot/refs.py | set_default_waveset | def set_default_waveset(minwave=500, maxwave=26000, num=10000,
delta=None, log=True):
"""Set the default wavelength set, ``pysynphot.refs._default_waveset``.
Parameters
----------
minwave, maxwave : float, optional
The start (inclusive) and end (exclusive) points of the ... | python | def set_default_waveset(minwave=500, maxwave=26000, num=10000,
delta=None, log=True):
"""Set the default wavelength set, ``pysynphot.refs._default_waveset``.
Parameters
----------
minwave, maxwave : float, optional
The start (inclusive) and end (exclusive) points of the ... | [
"def",
"set_default_waveset",
"(",
"minwave",
"=",
"500",
",",
"maxwave",
"=",
"26000",
",",
"num",
"=",
"10000",
",",
"delta",
"=",
"None",
",",
"log",
"=",
"True",
")",
":",
"global",
"_default_waveset",
"global",
"_default_waveset_str",
"num",
"=",
"int... | Set the default wavelength set, ``pysynphot.refs._default_waveset``.
Parameters
----------
minwave, maxwave : float, optional
The start (inclusive) and end (exclusive) points of the wavelength set.
Values should be given in linear space regardless of ``log``.
num : int, optional
... | [
"Set",
"the",
"default",
"wavelength",
"set",
"pysynphot",
".",
"refs",
".",
"_default_waveset",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/refs.py#L46-L103 | train |
spacetelescope/pysynphot | pysynphot/refs.py | _set_default_refdata | def _set_default_refdata():
"""Default refdata set on import."""
global GRAPHTABLE, COMPTABLE, THERMTABLE, PRIMARY_AREA
# Component tables are defined here.
try:
GRAPHTABLE = _refTable(os.path.join('mtab','*_tmg.fits'))
COMPTABLE = _refTable(os.path.join('mtab','*_tmc.fits'))
excep... | python | def _set_default_refdata():
"""Default refdata set on import."""
global GRAPHTABLE, COMPTABLE, THERMTABLE, PRIMARY_AREA
# Component tables are defined here.
try:
GRAPHTABLE = _refTable(os.path.join('mtab','*_tmg.fits'))
COMPTABLE = _refTable(os.path.join('mtab','*_tmc.fits'))
excep... | [
"def",
"_set_default_refdata",
"(",
")",
":",
"global",
"GRAPHTABLE",
",",
"COMPTABLE",
",",
"THERMTABLE",
",",
"PRIMARY_AREA",
"try",
":",
"GRAPHTABLE",
"=",
"_refTable",
"(",
"os",
".",
"path",
".",
"join",
"(",
"'mtab'",
",",
"'*_tmg.fits'",
")",
")",
"... | Default refdata set on import. | [
"Default",
"refdata",
"set",
"on",
"import",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/refs.py#L106-L129 | train |
spacetelescope/pysynphot | pysynphot/refs.py | setref | def setref(graphtable=None, comptable=None, thermtable=None,
area=None, waveset=None):
"""Set default graph and component tables, primary area, and
wavelength set.
This is similar to setting ``refdata`` in IRAF STSDAS SYNPHOT.
If all parameters set to `None`, they are reverted to software de... | python | def setref(graphtable=None, comptable=None, thermtable=None,
area=None, waveset=None):
"""Set default graph and component tables, primary area, and
wavelength set.
This is similar to setting ``refdata`` in IRAF STSDAS SYNPHOT.
If all parameters set to `None`, they are reverted to software de... | [
"def",
"setref",
"(",
"graphtable",
"=",
"None",
",",
"comptable",
"=",
"None",
",",
"thermtable",
"=",
"None",
",",
"area",
"=",
"None",
",",
"waveset",
"=",
"None",
")",
":",
"global",
"GRAPHTABLE",
",",
"COMPTABLE",
",",
"THERMTABLE",
",",
"PRIMARY_AR... | Set default graph and component tables, primary area, and
wavelength set.
This is similar to setting ``refdata`` in IRAF STSDAS SYNPHOT.
If all parameters set to `None`, they are reverted to software default.
If any of the parameters are not `None`, they are set to desired
values while the rest (if... | [
"Set",
"default",
"graph",
"and",
"component",
"tables",
"primary",
"area",
"and",
"wavelength",
"set",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/refs.py#L135-L216 | train |
spacetelescope/pysynphot | pysynphot/refs.py | getref | def getref():
"""Current default values for graph and component tables, primary area,
and wavelength set.
.. note::
Also see :func:`setref`.
Returns
-------
ans : dict
Mapping of parameter names to their current values.
"""
ans=dict(graphtable=GRAPHTABLE,
... | python | def getref():
"""Current default values for graph and component tables, primary area,
and wavelength set.
.. note::
Also see :func:`setref`.
Returns
-------
ans : dict
Mapping of parameter names to their current values.
"""
ans=dict(graphtable=GRAPHTABLE,
... | [
"def",
"getref",
"(",
")",
":",
"ans",
"=",
"dict",
"(",
"graphtable",
"=",
"GRAPHTABLE",
",",
"comptable",
"=",
"COMPTABLE",
",",
"thermtable",
"=",
"THERMTABLE",
",",
"area",
"=",
"PRIMARY_AREA",
",",
"waveset",
"=",
"_default_waveset_str",
")",
"return",
... | Current default values for graph and component tables, primary area,
and wavelength set.
.. note::
Also see :func:`setref`.
Returns
-------
ans : dict
Mapping of parameter names to their current values. | [
"Current",
"default",
"values",
"for",
"graph",
"and",
"component",
"tables",
"primary",
"area",
"and",
"wavelength",
"set",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/refs.py#L219-L238 | train |
spacetelescope/pysynphot | commissioning/kwfile_dict.py | read_kwfile | def read_kwfile(fname):
"""Syntax used as of r452 in commissioning tests"""
d={}
f=open(fname)
for line in f:
try:
kvpair=re.findall("(.*):: (.*)=(.*)$",line)[0]
d['name']=os.path.basename(kvpair[0])
key,val=kvpair[1:]
d[key.lower()]=val
ex... | python | def read_kwfile(fname):
"""Syntax used as of r452 in commissioning tests"""
d={}
f=open(fname)
for line in f:
try:
kvpair=re.findall("(.*):: (.*)=(.*)$",line)[0]
d['name']=os.path.basename(kvpair[0])
key,val=kvpair[1:]
d[key.lower()]=val
ex... | [
"def",
"read_kwfile",
"(",
"fname",
")",
":",
"d",
"=",
"{",
"}",
"f",
"=",
"open",
"(",
"fname",
")",
"for",
"line",
"in",
"f",
":",
"try",
":",
"kvpair",
"=",
"re",
".",
"findall",
"(",
"\"(.*):: (.*)=(.*)$\"",
",",
"line",
")",
"[",
"0",
"]",
... | Syntax used as of r452 in commissioning tests | [
"Syntax",
"used",
"as",
"of",
"r452",
"in",
"commissioning",
"tests"
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/kwfile_dict.py#L5-L19 | train |
spacetelescope/pysynphot | pysynphot/obsbandpass.py | ObsBandpass | def ObsBandpass(obstring, graphtable=None, comptable=None, component_dict={}):
"""Generate a bandpass object from observation mode.
If the bandpass consists of multiple throughput files
(e.g., "acs,hrc,f555w"), then `ObsModeBandpass` is returned.
Otherwise, if it consists of a single throughput file
... | python | def ObsBandpass(obstring, graphtable=None, comptable=None, component_dict={}):
"""Generate a bandpass object from observation mode.
If the bandpass consists of multiple throughput files
(e.g., "acs,hrc,f555w"), then `ObsModeBandpass` is returned.
Otherwise, if it consists of a single throughput file
... | [
"def",
"ObsBandpass",
"(",
"obstring",
",",
"graphtable",
"=",
"None",
",",
"comptable",
"=",
"None",
",",
"component_dict",
"=",
"{",
"}",
")",
":",
"ob",
"=",
"ObservationMode",
"(",
"obstring",
",",
"graphtable",
"=",
"graphtable",
",",
"comptable",
"="... | Generate a bandpass object from observation mode.
If the bandpass consists of multiple throughput files
(e.g., "acs,hrc,f555w"), then `ObsModeBandpass` is returned.
Otherwise, if it consists of a single throughput file
(e.g., "johnson,v"), then `~pysynphot.spectrum.TabularSpectralElement`
is return... | [
"Generate",
"a",
"bandpass",
"object",
"from",
"observation",
"mode",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/obsbandpass.py#L11-L48 | train |
spacetelescope/pysynphot | pysynphot/obsbandpass.py | ObsModeBandpass.thermback | def thermback(self):
"""Calculate thermal background count rate for ``self.obsmode``.
Calculation uses
:func:`~pysynphot.observationmode.ObservationMode.ThermalSpectrum`
to extract thermal component source spectrum in
``photlam`` per square arcsec. Then this spectrum is
... | python | def thermback(self):
"""Calculate thermal background count rate for ``self.obsmode``.
Calculation uses
:func:`~pysynphot.observationmode.ObservationMode.ThermalSpectrum`
to extract thermal component source spectrum in
``photlam`` per square arcsec. Then this spectrum is
... | [
"def",
"thermback",
"(",
"self",
")",
":",
"sp",
"=",
"self",
".",
"obsmode",
".",
"ThermalSpectrum",
"(",
")",
"ans",
"=",
"sp",
".",
"integrate",
"(",
")",
"*",
"(",
"self",
".",
"obsmode",
".",
"pixscale",
"**",
"2",
"*",
"self",
".",
"obsmode",... | Calculate thermal background count rate for ``self.obsmode``.
Calculation uses
:func:`~pysynphot.observationmode.ObservationMode.ThermalSpectrum`
to extract thermal component source spectrum in
``photlam`` per square arcsec. Then this spectrum is
integrated and multiplied by det... | [
"Calculate",
"thermal",
"background",
"count",
"rate",
"for",
"self",
".",
"obsmode",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/obsbandpass.py#L151-L186 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | MergeWaveSets | def MergeWaveSets(waveset1, waveset2):
"""Return the union of the two wavelength sets.
The union is computed using `numpy.union1d`, unless one or
both of them is `None`.
The merged result may sometimes contain numbers which are nearly
equal but differ at levels as small as 1E-14. Having values thi... | python | def MergeWaveSets(waveset1, waveset2):
"""Return the union of the two wavelength sets.
The union is computed using `numpy.union1d`, unless one or
both of them is `None`.
The merged result may sometimes contain numbers which are nearly
equal but differ at levels as small as 1E-14. Having values thi... | [
"def",
"MergeWaveSets",
"(",
"waveset1",
",",
"waveset2",
")",
":",
"if",
"waveset1",
"is",
"None",
"and",
"waveset2",
"is",
"not",
"None",
":",
"MergedWaveSet",
"=",
"waveset2",
"elif",
"waveset2",
"is",
"None",
"and",
"waveset1",
"is",
"not",
"None",
":"... | Return the union of the two wavelength sets.
The union is computed using `numpy.union1d`, unless one or
both of them is `None`.
The merged result may sometimes contain numbers which are nearly
equal but differ at levels as small as 1E-14. Having values this
close together can cause problems due to... | [
"Return",
"the",
"union",
"of",
"the",
"two",
"wavelength",
"sets",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L51-L102 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | trimSpectrum | def trimSpectrum(sp, minw, maxw):
"""Create a new spectrum with trimmed upper and lower ranges.
Parameters
----------
sp : `SourceSpectrum`
Spectrum to trim.
minw, maxw : number
Lower and upper limits (inclusive) for the wavelength set
in the trimmed spectrum.
Returns
... | python | def trimSpectrum(sp, minw, maxw):
"""Create a new spectrum with trimmed upper and lower ranges.
Parameters
----------
sp : `SourceSpectrum`
Spectrum to trim.
minw, maxw : number
Lower and upper limits (inclusive) for the wavelength set
in the trimmed spectrum.
Returns
... | [
"def",
"trimSpectrum",
"(",
"sp",
",",
"minw",
",",
"maxw",
")",
":",
"wave",
"=",
"sp",
".",
"GetWaveSet",
"(",
")",
"flux",
"=",
"sp",
"(",
"wave",
")",
"new_wave",
"=",
"N",
".",
"compress",
"(",
"wave",
">=",
"minw",
",",
"wave",
")",
"new_fl... | Create a new spectrum with trimmed upper and lower ranges.
Parameters
----------
sp : `SourceSpectrum`
Spectrum to trim.
minw, maxw : number
Lower and upper limits (inclusive) for the wavelength set
in the trimmed spectrum.
Returns
-------
result : `TabularSourceSp... | [
"Create",
"a",
"new",
"spectrum",
"with",
"trimmed",
"upper",
"and",
"lower",
"ranges",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L105-L140 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | Integrator.trapezoidIntegration | def trapezoidIntegration(self, x, y):
"""Perform trapezoid integration.
Parameters
----------
x : array_like
Wavelength set.
y : array_like
Integrand. For example, throughput or throughput
multiplied by wavelength.
Returns
--... | python | def trapezoidIntegration(self, x, y):
"""Perform trapezoid integration.
Parameters
----------
x : array_like
Wavelength set.
y : array_like
Integrand. For example, throughput or throughput
multiplied by wavelength.
Returns
--... | [
"def",
"trapezoidIntegration",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"npoints",
"=",
"x",
".",
"size",
"if",
"npoints",
">",
"0",
":",
"indices",
"=",
"N",
".",
"arange",
"(",
"npoints",
")",
"[",
":",
"-",
"1",
"]",
"deltas",
"=",
"x",
"[... | Perform trapezoid integration.
Parameters
----------
x : array_like
Wavelength set.
y : array_like
Integrand. For example, throughput or throughput
multiplied by wavelength.
Returns
-------
sum : float
Integrated ... | [
"Perform",
"trapezoid",
"integration",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L148-L176 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | Integrator.validate_wavetable | def validate_wavetable(self):
"""Enforce monotonic, ascending wavelength array with no zero or
negative values.
Raises
------
pysynphot.exceptions.DuplicateWavelength
Wavelength array contains duplicate entries.
pysynphot.exceptions.UnsortedWavelength
... | python | def validate_wavetable(self):
"""Enforce monotonic, ascending wavelength array with no zero or
negative values.
Raises
------
pysynphot.exceptions.DuplicateWavelength
Wavelength array contains duplicate entries.
pysynphot.exceptions.UnsortedWavelength
... | [
"def",
"validate_wavetable",
"(",
"self",
")",
":",
"wave",
"=",
"self",
".",
"_wavetable",
"if",
"N",
".",
"any",
"(",
"wave",
"<=",
"0",
")",
":",
"wrong",
"=",
"N",
".",
"where",
"(",
"wave",
"<=",
"0",
")",
"[",
"0",
"]",
"raise",
"exceptions... | Enforce monotonic, ascending wavelength array with no zero or
negative values.
Raises
------
pysynphot.exceptions.DuplicateWavelength
Wavelength array contains duplicate entries.
pysynphot.exceptions.UnsortedWavelength
Wavelength array is not monotonic a... | [
"Enforce",
"monotonic",
"ascending",
"wavelength",
"array",
"with",
"no",
"zero",
"or",
"negative",
"values",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L207-L247 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | Integrator.validate_fluxtable | def validate_fluxtable(self):
"""Check for non-negative fluxes.
If found, the negative flux values are set to zero, and
a warning is printed to screen. This check is not done
if flux unit is a magnitude because negative magnitude
values are legal.
"""
# neg. magn... | python | def validate_fluxtable(self):
"""Check for non-negative fluxes.
If found, the negative flux values are set to zero, and
a warning is printed to screen. This check is not done
if flux unit is a magnitude because negative magnitude
values are legal.
"""
# neg. magn... | [
"def",
"validate_fluxtable",
"(",
"self",
")",
":",
"if",
"(",
"(",
"not",
"self",
".",
"fluxunits",
".",
"isMag",
")",
"and",
"(",
"self",
".",
"_fluxtable",
".",
"min",
"(",
")",
"<",
"0",
")",
")",
":",
"idx",
"=",
"N",
".",
"where",
"(",
"s... | Check for non-negative fluxes.
If found, the negative flux values are set to zero, and
a warning is printed to screen. This check is not done
if flux unit is a magnitude because negative magnitude
values are legal. | [
"Check",
"for",
"non",
"-",
"negative",
"fluxes",
".",
"If",
"found",
"the",
"negative",
"flux",
"values",
"are",
"set",
"to",
"zero",
"and",
"a",
"warning",
"is",
"printed",
"to",
"screen",
".",
"This",
"check",
"is",
"not",
"done",
"if",
"flux",
"uni... | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L249-L263 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.addmag | def addmag(self, magval):
"""Add a scalar magnitude to existing flux values.
.. math::
\\textnormal{flux}_{\\textnormal{new}} = 10^{-0.4 \\; \\textnormal{magval}} \\; \\textnormal{flux}
Parameters
----------
magval : number
Magnitude value.
Ret... | python | def addmag(self, magval):
"""Add a scalar magnitude to existing flux values.
.. math::
\\textnormal{flux}_{\\textnormal{new}} = 10^{-0.4 \\; \\textnormal{magval}} \\; \\textnormal{flux}
Parameters
----------
magval : number
Magnitude value.
Ret... | [
"def",
"addmag",
"(",
"self",
",",
"magval",
")",
":",
"if",
"N",
".",
"isscalar",
"(",
"magval",
")",
":",
"factor",
"=",
"10",
"**",
"(",
"-",
"0.4",
"*",
"magval",
")",
"return",
"self",
"*",
"factor",
"else",
":",
"raise",
"TypeError",
"(",
"... | Add a scalar magnitude to existing flux values.
.. math::
\\textnormal{flux}_{\\textnormal{new}} = 10^{-0.4 \\; \\textnormal{magval}} \\; \\textnormal{flux}
Parameters
----------
magval : number
Magnitude value.
Returns
-------
sp : `Co... | [
"Add",
"a",
"scalar",
"magnitude",
"to",
"existing",
"flux",
"values",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L305-L332 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.getArrays | def getArrays(self):
"""Return wavelength and flux arrays in user units.
Returns
-------
wave : array_like
Wavelength array in ``self.waveunits``.
flux : array_like
Flux array in ``self.fluxunits``.
When necessary, ``self.primary_area`` is us... | python | def getArrays(self):
"""Return wavelength and flux arrays in user units.
Returns
-------
wave : array_like
Wavelength array in ``self.waveunits``.
flux : array_like
Flux array in ``self.fluxunits``.
When necessary, ``self.primary_area`` is us... | [
"def",
"getArrays",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'primary_area'",
")",
":",
"area",
"=",
"self",
".",
"primary_area",
"else",
":",
"area",
"=",
"None",
"wave",
"=",
"self",
".",
"GetWaveSet",
"(",
")",
"flux",
"=",
"self... | Return wavelength and flux arrays in user units.
Returns
-------
wave : array_like
Wavelength array in ``self.waveunits``.
flux : array_like
Flux array in ``self.fluxunits``.
When necessary, ``self.primary_area`` is used for unit conversion. | [
"Return",
"wavelength",
"and",
"flux",
"arrays",
"in",
"user",
"units",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L334-L359 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.validate_units | def validate_units(self):
"""Ensure that wavelenth and flux units belong to the
correct classes.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits` or
flux unit is not `~pysynphot.units.FluxUnits`.
"""
if (not isi... | python | def validate_units(self):
"""Ensure that wavelenth and flux units belong to the
correct classes.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits` or
flux unit is not `~pysynphot.units.FluxUnits`.
"""
if (not isi... | [
"def",
"validate_units",
"(",
"self",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"self",
".",
"waveunits",
",",
"units",
".",
"WaveUnits",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"%s is not a valid WaveUnit\"",
"%",
"self",
".",
"waveunits",
")",
"... | Ensure that wavelenth and flux units belong to the
correct classes.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits` or
flux unit is not `~pysynphot.units.FluxUnits`. | [
"Ensure",
"that",
"wavelenth",
"and",
"flux",
"units",
"belong",
"to",
"the",
"correct",
"classes",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L373-L387 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.writefits | def writefits(self, filename, clobber=True, trimzero=True,
binned=False, precision=None, hkeys=None):
"""Write the spectrum to a FITS table.
Primary header in EXT 0. ``FILENAME``, ``ORIGIN``, and any
extra keyword(s) from ``hkeys`` will also be added.
Table header an... | python | def writefits(self, filename, clobber=True, trimzero=True,
binned=False, precision=None, hkeys=None):
"""Write the spectrum to a FITS table.
Primary header in EXT 0. ``FILENAME``, ``ORIGIN``, and any
extra keyword(s) from ``hkeys`` will also be added.
Table header an... | [
"def",
"writefits",
"(",
"self",
",",
"filename",
",",
"clobber",
"=",
"True",
",",
"trimzero",
"=",
"True",
",",
"binned",
"=",
"False",
",",
"precision",
"=",
"None",
",",
"hkeys",
"=",
"None",
")",
":",
"pcodes",
"=",
"{",
"'d'",
":",
"'D'",
","... | Write the spectrum to a FITS table.
Primary header in EXT 0. ``FILENAME``, ``ORIGIN``, and any
extra keyword(s) from ``hkeys`` will also be added.
Table header and data are in EXT 1. The table has 2 columns,
i.e., ``WAVELENGTH`` and ``FLUX``. Data are stored in user units.
Its... | [
"Write",
"the",
"spectrum",
"to",
"a",
"FITS",
"table",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L389-L541 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.integrate | def integrate(self, fluxunits='photlam'):
"""Integrate the flux in given unit.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=flux``, where flux has been
convert to given unit first.
.. math::
\\textnormal{result} = \\int... | python | def integrate(self, fluxunits='photlam'):
"""Integrate the flux in given unit.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=flux``, where flux has been
convert to given unit first.
.. math::
\\textnormal{result} = \\int... | [
"def",
"integrate",
"(",
"self",
",",
"fluxunits",
"=",
"'photlam'",
")",
":",
"u",
"=",
"self",
".",
"fluxunits",
"self",
".",
"convert",
"(",
"fluxunits",
")",
"wave",
",",
"flux",
"=",
"self",
".",
"getArrays",
"(",
")",
"self",
".",
"convert",
"(... | Integrate the flux in given unit.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=flux``, where flux has been
convert to given unit first.
.. math::
\\textnormal{result} = \\int F_{\\lambda} d\\lambda
Parameters
-... | [
"Integrate",
"the",
"flux",
"in",
"given",
"unit",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L543-L574 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.convert | def convert(self, targetunits):
"""Set new user unit, for either wavelength or flux.
This effectively converts the spectrum wavelength or flux
to given unit. Note that actual data are always kept in
internal units (Angstrom and ``photlam``), and only converted
to user units by :... | python | def convert(self, targetunits):
"""Set new user unit, for either wavelength or flux.
This effectively converts the spectrum wavelength or flux
to given unit. Note that actual data are always kept in
internal units (Angstrom and ``photlam``), and only converted
to user units by :... | [
"def",
"convert",
"(",
"self",
",",
"targetunits",
")",
":",
"nunits",
"=",
"units",
".",
"Units",
"(",
"targetunits",
")",
"if",
"nunits",
".",
"isFlux",
":",
"self",
".",
"fluxunits",
"=",
"nunits",
"else",
":",
"self",
".",
"waveunits",
"=",
"nunits... | Set new user unit, for either wavelength or flux.
This effectively converts the spectrum wavelength or flux
to given unit. Note that actual data are always kept in
internal units (Angstrom and ``photlam``), and only converted
to user units by :meth:`getArrays` during actual computation.... | [
"Set",
"new",
"user",
"unit",
"for",
"either",
"wavelength",
"or",
"flux",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L642-L662 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SourceSpectrum.setMagnitude | def setMagnitude(self, band, value):
"""Makes the magnitude of the source in the band equal to value.
band is a SpectralElement.
This method is marked for deletion once the .renorm method is
well tested.
Object returned is a CompositeSourceSpectrum.
.. warning:: DO NOT ... | python | def setMagnitude(self, band, value):
"""Makes the magnitude of the source in the band equal to value.
band is a SpectralElement.
This method is marked for deletion once the .renorm method is
well tested.
Object returned is a CompositeSourceSpectrum.
.. warning:: DO NOT ... | [
"def",
"setMagnitude",
"(",
"self",
",",
"band",
",",
"value",
")",
":",
"objectFlux",
"=",
"band",
".",
"calcTotalFlux",
"(",
"self",
")",
"vegaFlux",
"=",
"band",
".",
"calcVegaFlux",
"(",
")",
"magDiff",
"=",
"-",
"2.5",
"*",
"math",
".",
"log10",
... | Makes the magnitude of the source in the band equal to value.
band is a SpectralElement.
This method is marked for deletion once the .renorm method is
well tested.
Object returned is a CompositeSourceSpectrum.
.. warning:: DO NOT USED | [
"Makes",
"the",
"magnitude",
"of",
"the",
"source",
"in",
"the",
"band",
"equal",
"to",
"value",
".",
"band",
"is",
"a",
"SpectralElement",
".",
"This",
"method",
"is",
"marked",
"for",
"deletion",
"once",
"the",
".",
"renorm",
"method",
"is",
"well",
"t... | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L699-L714 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | CompositeSourceSpectrum.tabulate | def tabulate(self):
"""Return a simplified version of the spectrum.
Composite spectrum can be overly complicated when it
has too many components and sub-components. This method
copies the following into a simple (tabulated) source spectrum:
* Name
* Wavelength array and... | python | def tabulate(self):
"""Return a simplified version of the spectrum.
Composite spectrum can be overly complicated when it
has too many components and sub-components. This method
copies the following into a simple (tabulated) source spectrum:
* Name
* Wavelength array and... | [
"def",
"tabulate",
"(",
"self",
")",
":",
"sp",
"=",
"ArraySourceSpectrum",
"(",
"wave",
"=",
"self",
".",
"wave",
",",
"flux",
"=",
"self",
".",
"flux",
",",
"waveunits",
"=",
"self",
".",
"waveunits",
",",
"fluxunits",
"=",
"self",
".",
"fluxunits",
... | Return a simplified version of the spectrum.
Composite spectrum can be overly complicated when it
has too many components and sub-components. This method
copies the following into a simple (tabulated) source spectrum:
* Name
* Wavelength array and unit
* Flux array and ... | [
"Return",
"a",
"simplified",
"version",
"of",
"the",
"spectrum",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L921-L943 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | TabularSourceSpectrum._readASCII | def _readASCII(self, filename):
"""ASCII files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is flux in Flam.
"""
self.waveunits = units.Units('angstrom')
self.fluxunits = units.Units('flam... | python | def _readASCII(self, filename):
"""ASCII files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is flux in Flam.
"""
self.waveunits = units.Units('angstrom')
self.fluxunits = units.Units('flam... | [
"def",
"_readASCII",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"waveunits",
"=",
"units",
".",
"Units",
"(",
"'angstrom'",
")",
"self",
".",
"fluxunits",
"=",
"units",
".",
"Units",
"(",
"'flam'",
")",
"wlist",
",",
"flist",
"=",
"self",
"... | ASCII files have no headers. Following synphot, this
routine will assume the first column is wavelength in Angstroms,
and the second column is flux in Flam. | [
"ASCII",
"files",
"have",
"no",
"headers",
".",
"Following",
"synphot",
"this",
"routine",
"will",
"assume",
"the",
"first",
"column",
"is",
"wavelength",
"in",
"Angstroms",
"and",
"the",
"second",
"column",
"is",
"flux",
"in",
"Flam",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L1029-L1039 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | FlatSpectrum.redshift | def redshift(self, z):
"""Apply redshift to the flat spectrum.
Unlike :meth:`SourceSpectrum.redshift`, the redshifted spectrum
remains an analytic flat source.
Parameters
----------
z : number
Redshift value.
Returns
-------
ans : `F... | python | def redshift(self, z):
"""Apply redshift to the flat spectrum.
Unlike :meth:`SourceSpectrum.redshift`, the redshifted spectrum
remains an analytic flat source.
Parameters
----------
z : number
Redshift value.
Returns
-------
ans : `F... | [
"def",
"redshift",
"(",
"self",
",",
"z",
")",
":",
"tmp",
"=",
"SourceSpectrum",
".",
"redshift",
"(",
"self",
",",
"z",
")",
"ans",
"=",
"FlatSpectrum",
"(",
"tmp",
".",
"flux",
".",
"max",
"(",
")",
",",
"fluxunits",
"=",
"tmp",
".",
"fluxunits"... | Apply redshift to the flat spectrum.
Unlike :meth:`SourceSpectrum.redshift`, the redshifted spectrum
remains an analytic flat source.
Parameters
----------
z : number
Redshift value.
Returns
-------
ans : `FlatSpectrum` | [
"Apply",
"redshift",
"to",
"the",
"flat",
"spectrum",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L1566-L1584 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SpectralElement.validate_units | def validate_units(self):
"""Ensure that wavelenth unit belongs to the correct class.
There is no check for throughput because it is unitless.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits`.
"""
if (not isinstance(self.wa... | python | def validate_units(self):
"""Ensure that wavelenth unit belongs to the correct class.
There is no check for throughput because it is unitless.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits`.
"""
if (not isinstance(self.wa... | [
"def",
"validate_units",
"(",
"self",
")",
":",
"if",
"(",
"not",
"isinstance",
"(",
"self",
".",
"waveunits",
",",
"units",
".",
"WaveUnits",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"%s is not a valid WaveUnit\"",
"%",
"self",
".",
"waveunits",
")"
] | Ensure that wavelenth unit belongs to the correct class.
There is no check for throughput because it is unitless.
Raises
------
TypeError
Wavelength unit is not `~pysynphot.units.WaveUnits`. | [
"Ensure",
"that",
"wavelenth",
"unit",
"belongs",
"to",
"the",
"correct",
"class",
".",
"There",
"is",
"no",
"check",
"for",
"throughput",
"because",
"it",
"is",
"unitless",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L1726-L1737 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SpectralElement.integrate | def integrate(self, wave=None):
"""Integrate the throughput over the specified wavelength set.
If no wavelength set is specified, the built-in one is used.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=throughput``.
Also see :ref:`pys... | python | def integrate(self, wave=None):
"""Integrate the throughput over the specified wavelength set.
If no wavelength set is specified, the built-in one is used.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=throughput``.
Also see :ref:`pys... | [
"def",
"integrate",
"(",
"self",
",",
"wave",
"=",
"None",
")",
":",
"if",
"wave",
"is",
"None",
":",
"wave",
"=",
"self",
".",
"wave",
"ans",
"=",
"self",
".",
"trapezoidIntegration",
"(",
"wave",
",",
"self",
"(",
"wave",
")",
")",
"return",
"ans... | Integrate the throughput over the specified wavelength set.
If no wavelength set is specified, the built-in one is used.
Integration is done using :meth:`~Integrator.trapezoidIntegration`
with ``x=wave`` and ``y=throughput``.
Also see :ref:`pysynphot-formula-equvw`.
Parameters
... | [
"Integrate",
"the",
"throughput",
"over",
"the",
"specified",
"wavelength",
"set",
".",
"If",
"no",
"wavelength",
"set",
"is",
"specified",
"the",
"built",
"-",
"in",
"one",
"is",
"used",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L1763-L1786 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SpectralElement.convert | def convert(self, targetunits):
"""Set new user unit, for wavelength only.
This effectively converts the spectrum wavelength
to given unit. Note that actual data are always kept in
internal unit (Angstrom), and only converted
to user unit by :meth:`GetWaveSet` during actual comp... | python | def convert(self, targetunits):
"""Set new user unit, for wavelength only.
This effectively converts the spectrum wavelength
to given unit. Note that actual data are always kept in
internal unit (Angstrom), and only converted
to user unit by :meth:`GetWaveSet` during actual comp... | [
"def",
"convert",
"(",
"self",
",",
"targetunits",
")",
":",
"nunits",
"=",
"units",
".",
"Units",
"(",
"targetunits",
")",
"self",
".",
"waveunits",
"=",
"nunits"
] | Set new user unit, for wavelength only.
This effectively converts the spectrum wavelength
to given unit. Note that actual data are always kept in
internal unit (Angstrom), and only converted
to user unit by :meth:`GetWaveSet` during actual computation.
User unit is stored in ``s... | [
"Set",
"new",
"user",
"unit",
"for",
"wavelength",
"only",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L2117-L2134 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | SpectralElement.sample | def sample(self, wave):
"""Sample the spectrum.
This uses :meth:`resample` to do the actual computation.
Parameters
----------
wave : number or array_like
Wavelength set for sampling, given in user unit.
Returns
-------
throughput : number o... | python | def sample(self, wave):
"""Sample the spectrum.
This uses :meth:`resample` to do the actual computation.
Parameters
----------
wave : number or array_like
Wavelength set for sampling, given in user unit.
Returns
-------
throughput : number o... | [
"def",
"sample",
"(",
"self",
",",
"wave",
")",
":",
"angwave",
"=",
"self",
".",
"waveunits",
".",
"ToAngstrom",
"(",
"wave",
")",
"return",
"self",
".",
"__call__",
"(",
"angwave",
")"
] | Sample the spectrum.
This uses :meth:`resample` to do the actual computation.
Parameters
----------
wave : number or array_like
Wavelength set for sampling, given in user unit.
Returns
-------
throughput : number or array_like
Sampled th... | [
"Sample",
"the",
"spectrum",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L2171-L2188 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | UniformTransmission.writefits | def writefits(self, *args, **kwargs):
"""Write to file using default waveset."""
old_wave = self.wave
self.wave = self._wavetable
try:
super(UniformTransmission, self).writefits(*args, **kwargs)
finally:
self.wave = old_wave | python | def writefits(self, *args, **kwargs):
"""Write to file using default waveset."""
old_wave = self.wave
self.wave = self._wavetable
try:
super(UniformTransmission, self).writefits(*args, **kwargs)
finally:
self.wave = old_wave | [
"def",
"writefits",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"old_wave",
"=",
"self",
".",
"wave",
"self",
".",
"wave",
"=",
"self",
".",
"_wavetable",
"try",
":",
"super",
"(",
"UniformTransmission",
",",
"self",
")",
".",
"writ... | Write to file using default waveset. | [
"Write",
"to",
"file",
"using",
"default",
"waveset",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L2687-L2695 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | TabularSpectralElement.ToInternal | def ToInternal(self):
"""Convert wavelengths to the internal representation of angstroms.
For internal use only."""
self.validate_units()
savewunits = self.waveunits
angwave = self.waveunits.Convert(self._wavetable, 'angstrom')
self._wavetable = angwave.copy()
sel... | python | def ToInternal(self):
"""Convert wavelengths to the internal representation of angstroms.
For internal use only."""
self.validate_units()
savewunits = self.waveunits
angwave = self.waveunits.Convert(self._wavetable, 'angstrom')
self._wavetable = angwave.copy()
sel... | [
"def",
"ToInternal",
"(",
"self",
")",
":",
"self",
".",
"validate_units",
"(",
")",
"savewunits",
"=",
"self",
".",
"waveunits",
"angwave",
"=",
"self",
".",
"waveunits",
".",
"Convert",
"(",
"self",
".",
"_wavetable",
",",
"'angstrom'",
")",
"self",
".... | Convert wavelengths to the internal representation of angstroms.
For internal use only. | [
"Convert",
"wavelengths",
"to",
"the",
"internal",
"representation",
"of",
"angstroms",
".",
"For",
"internal",
"use",
"only",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L2812-L2819 | train |
spacetelescope/pysynphot | pysynphot/spectrum.py | Box.sample | def sample(self, wavelength):
"""Input wavelengths assumed to be in user unit."""
wave = self.waveunits.Convert(wavelength, 'angstrom')
return self(wave) | python | def sample(self, wavelength):
"""Input wavelengths assumed to be in user unit."""
wave = self.waveunits.Convert(wavelength, 'angstrom')
return self(wave) | [
"def",
"sample",
"(",
"self",
",",
"wavelength",
")",
":",
"wave",
"=",
"self",
".",
"waveunits",
".",
"Convert",
"(",
"wavelength",
",",
"'angstrom'",
")",
"return",
"self",
"(",
"wave",
")"
] | Input wavelengths assumed to be in user unit. | [
"Input",
"wavelengths",
"assumed",
"to",
"be",
"in",
"user",
"unit",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/spectrum.py#L3317-L3320 | train |
spacetelescope/pysynphot | pysynphot/observationmode.py | ObservationMode.Throughput | def Throughput(self):
"""Combined throughput from multiplying all the components together.
Returns
-------
throughput : `~pysynphot.spectrum.TabularSpectralElement` or `None`
Combined throughput.
"""
try:
throughput = spectrum.TabularSpectralElem... | python | def Throughput(self):
"""Combined throughput from multiplying all the components together.
Returns
-------
throughput : `~pysynphot.spectrum.TabularSpectralElement` or `None`
Combined throughput.
"""
try:
throughput = spectrum.TabularSpectralElem... | [
"def",
"Throughput",
"(",
"self",
")",
":",
"try",
":",
"throughput",
"=",
"spectrum",
".",
"TabularSpectralElement",
"(",
")",
"product",
"=",
"self",
".",
"_multiplyThroughputs",
"(",
"0",
")",
"throughput",
".",
"_wavetable",
"=",
"product",
".",
"GetWave... | Combined throughput from multiplying all the components together.
Returns
-------
throughput : `~pysynphot.spectrum.TabularSpectralElement` or `None`
Combined throughput. | [
"Combined",
"throughput",
"from",
"multiplying",
"all",
"the",
"components",
"together",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observationmode.py#L368-L392 | train |
spacetelescope/pysynphot | pysynphot/observationmode.py | ObservationMode.ThermalSpectrum | def ThermalSpectrum(self):
"""Calculate thermal spectrum.
Returns
-------
sp : `~pysynphot.spectrum.CompositeSourceSpectrum`
Thermal spectrum in ``photlam``.
Raises
------
IndexError
Calculation failed.
"""
try:
... | python | def ThermalSpectrum(self):
"""Calculate thermal spectrum.
Returns
-------
sp : `~pysynphot.spectrum.CompositeSourceSpectrum`
Thermal spectrum in ``photlam``.
Raises
------
IndexError
Calculation failed.
"""
try:
... | [
"def",
"ThermalSpectrum",
"(",
"self",
")",
":",
"try",
":",
"thom",
"=",
"_ThermalObservationMode",
"(",
"self",
".",
"_obsmode",
")",
"self",
".",
"pixscale",
"=",
"thom",
".",
"pixscale",
"return",
"thom",
".",
"_getSpectrum",
"(",
")",
"except",
"Index... | Calculate thermal spectrum.
Returns
-------
sp : `~pysynphot.spectrum.CompositeSourceSpectrum`
Thermal spectrum in ``photlam``.
Raises
------
IndexError
Calculation failed. | [
"Calculate",
"thermal",
"spectrum",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observationmode.py#L404-L424 | train |
spacetelescope/pysynphot | pysynphot/observationmode.py | _ThermalObservationMode._multiplyThroughputs | def _multiplyThroughputs(self):
''' Overrides base class in order to deal with opaque components.
'''
index = 0
for component in self.components:
if component.throughput != None:
break
index += 1
return BaseObservationMode._multiplyThrough... | python | def _multiplyThroughputs(self):
''' Overrides base class in order to deal with opaque components.
'''
index = 0
for component in self.components:
if component.throughput != None:
break
index += 1
return BaseObservationMode._multiplyThrough... | [
"def",
"_multiplyThroughputs",
"(",
"self",
")",
":",
"index",
"=",
"0",
"for",
"component",
"in",
"self",
".",
"components",
":",
"if",
"component",
".",
"throughput",
"!=",
"None",
":",
"break",
"index",
"+=",
"1",
"return",
"BaseObservationMode",
".",
"... | Overrides base class in order to deal with opaque components. | [
"Overrides",
"base",
"class",
"in",
"order",
"to",
"deal",
"with",
"opaque",
"components",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observationmode.py#L515-L524 | train |
spacetelescope/pysynphot | commissioning/doscalars.py | reverse | def reverse(d):
"""Return a reverse lookup dictionary for the input dictionary"""
r={}
for k in d:
r[d[k]]=k
return r | python | def reverse(d):
"""Return a reverse lookup dictionary for the input dictionary"""
r={}
for k in d:
r[d[k]]=k
return r | [
"def",
"reverse",
"(",
"d",
")",
":",
"r",
"=",
"{",
"}",
"for",
"k",
"in",
"d",
":",
"r",
"[",
"d",
"[",
"k",
"]",
"]",
"=",
"k",
"return",
"r"
] | Return a reverse lookup dictionary for the input dictionary | [
"Return",
"a",
"reverse",
"lookup",
"dictionary",
"for",
"the",
"input",
"dictionary"
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/doscalars.py#L85-L90 | train |
spacetelescope/pysynphot | pysynphot/reddening.py | print_red_laws | def print_red_laws():
"""Print available extinction laws to screen.
Available extinction laws are extracted from ``pysynphot.locations.EXTDIR``.
The printed names may be used with :func:`Extinction`
to retrieve available reddening laws.
Examples
--------
>>> S.reddening.print_red_laws()
... | python | def print_red_laws():
"""Print available extinction laws to screen.
Available extinction laws are extracted from ``pysynphot.locations.EXTDIR``.
The printed names may be used with :func:`Extinction`
to retrieve available reddening laws.
Examples
--------
>>> S.reddening.print_red_laws()
... | [
"def",
"print_red_laws",
"(",
")",
":",
"laws",
"=",
"{",
"}",
"for",
"k",
"in",
"Cache",
".",
"RedLaws",
":",
"if",
"isinstance",
"(",
"Cache",
".",
"RedLaws",
"[",
"k",
"]",
",",
"str",
")",
":",
"Cache",
".",
"RedLaws",
"[",
"k",
"]",
"=",
"... | Print available extinction laws to screen.
Available extinction laws are extracted from ``pysynphot.locations.EXTDIR``.
The printed names may be used with :func:`Extinction`
to retrieve available reddening laws.
Examples
--------
>>> S.reddening.print_red_laws()
name reference
--... | [
"Print",
"available",
"extinction",
"laws",
"to",
"screen",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/reddening.py#L158-L202 | train |
spacetelescope/pysynphot | pysynphot/reddening.py | Extinction | def Extinction(extval,name=None):
"""Generate extinction curve to be used with spectra.
By default, :meth:`~CustomRedLaw.reddening` is used to
generate the extinction curve. If a deprecated
reddening law is given, then
`~pysynphot.extinction.DeprecatedExtinction` is used
instead.
.. note::
... | python | def Extinction(extval,name=None):
"""Generate extinction curve to be used with spectra.
By default, :meth:`~CustomRedLaw.reddening` is used to
generate the extinction curve. If a deprecated
reddening law is given, then
`~pysynphot.extinction.DeprecatedExtinction` is used
instead.
.. note::
... | [
"def",
"Extinction",
"(",
"extval",
",",
"name",
"=",
"None",
")",
":",
"try",
":",
"ext",
"=",
"Cache",
".",
"RedLaws",
"[",
"name",
"]",
".",
"reddening",
"(",
"extval",
")",
"except",
"AttributeError",
":",
"Cache",
".",
"RedLaws",
"[",
"name",
"]... | Generate extinction curve to be used with spectra.
By default, :meth:`~CustomRedLaw.reddening` is used to
generate the extinction curve. If a deprecated
reddening law is given, then
`~pysynphot.extinction.DeprecatedExtinction` is used
instead.
.. note::
Reddening laws are cached in ``py... | [
"Generate",
"extinction",
"curve",
"to",
"be",
"used",
"with",
"spectra",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/reddening.py#L205-L263 | train |
spacetelescope/pysynphot | pysynphot/reddening.py | ExtinctionSpectralElement._getWaveProp | def _getWaveProp(self):
"""Return wavelength in user units."""
wave = units.Angstrom().Convert(self._wavetable, self.waveunits.name)
return wave | python | def _getWaveProp(self):
"""Return wavelength in user units."""
wave = units.Angstrom().Convert(self._wavetable, self.waveunits.name)
return wave | [
"def",
"_getWaveProp",
"(",
"self",
")",
":",
"wave",
"=",
"units",
".",
"Angstrom",
"(",
")",
".",
"Convert",
"(",
"self",
".",
"_wavetable",
",",
"self",
".",
"waveunits",
".",
"name",
")",
"return",
"wave"
] | Return wavelength in user units. | [
"Return",
"wavelength",
"in",
"user",
"units",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/reddening.py#L23-L26 | train |
spacetelescope/pysynphot | pysynphot/reddening.py | CustomRedLaw.reddening | def reddening(self,extval):
"""Compute the reddening for the given extinction.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
\\textnormal{THRU} = 10^{-0.4 \\; A(V)}
.. note::
``self.litref`` is passed into ``ans.citation``.
Parameters
----... | python | def reddening(self,extval):
"""Compute the reddening for the given extinction.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
\\textnormal{THRU} = 10^{-0.4 \\; A(V)}
.. note::
``self.litref`` is passed into ``ans.citation``.
Parameters
----... | [
"def",
"reddening",
"(",
"self",
",",
"extval",
")",
":",
"T",
"=",
"10.0",
"**",
"(",
"-",
"0.4",
"*",
"extval",
"*",
"self",
".",
"obscuration",
")",
"ans",
"=",
"ExtinctionSpectralElement",
"(",
"wave",
"=",
"self",
".",
"wave",
",",
"waveunits",
... | Compute the reddening for the given extinction.
.. math::
A(V) = R(V) \\; \\times \\; E(B-V)
\\textnormal{THRU} = 10^{-0.4 \\; A(V)}
.. note::
``self.litref`` is passed into ``ans.citation``.
Parameters
----------
extval : float
... | [
"Compute",
"the",
"reddening",
"for",
"the",
"given",
"extinction",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/reddening.py#L79-L109 | train |
spacetelescope/pysynphot | pysynphot/tables.py | GraphTable.GetNextNode | def GetNextNode(self, modes, innode):
"""GetNextNode returns the outnode that matches an element from
the modes list, starting at the given innode.
This method isnt actually used, its just a helper method for
debugging purposes.
"""
nodes = N.where(self.innodes == innode... | python | def GetNextNode(self, modes, innode):
"""GetNextNode returns the outnode that matches an element from
the modes list, starting at the given innode.
This method isnt actually used, its just a helper method for
debugging purposes.
"""
nodes = N.where(self.innodes == innode... | [
"def",
"GetNextNode",
"(",
"self",
",",
"modes",
",",
"innode",
")",
":",
"nodes",
"=",
"N",
".",
"where",
"(",
"self",
".",
"innodes",
"==",
"innode",
")",
"if",
"nodes",
"[",
"0",
"]",
".",
"size",
"==",
"0",
":",
"return",
"-",
"1",
"defaultin... | GetNextNode returns the outnode that matches an element from
the modes list, starting at the given innode.
This method isnt actually used, its just a helper method for
debugging purposes. | [
"GetNextNode",
"returns",
"the",
"outnode",
"that",
"matches",
"an",
"element",
"from",
"the",
"modes",
"list",
"starting",
"at",
"the",
"given",
"innode",
".",
"This",
"method",
"isnt",
"actually",
"used",
"its",
"just",
"a",
"helper",
"method",
"for",
"deb... | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/tables.py#L120-L152 | train |
spacetelescope/pysynphot | pysynphot/tables.py | GraphTable.GetComponentsFromGT | def GetComponentsFromGT(self, modes, innode):
"""Obtain components from graph table for the given
observation mode keywords and starting node.
.. note::
This prints extra information to screen if
``pysynphot.tables.DEBUG`` is set to `True`.
Parameters
-... | python | def GetComponentsFromGT(self, modes, innode):
"""Obtain components from graph table for the given
observation mode keywords and starting node.
.. note::
This prints extra information to screen if
``pysynphot.tables.DEBUG`` is set to `True`.
Parameters
-... | [
"def",
"GetComponentsFromGT",
"(",
"self",
",",
"modes",
",",
"innode",
")",
":",
"components",
"=",
"[",
"]",
"thcomponents",
"=",
"[",
"]",
"outnode",
"=",
"0",
"inmodes",
"=",
"set",
"(",
"modes",
")",
"used_modes",
"=",
"set",
"(",
")",
"count",
... | Obtain components from graph table for the given
observation mode keywords and starting node.
.. note::
This prints extra information to screen if
``pysynphot.tables.DEBUG`` is set to `True`.
Parameters
----------
modes : list of str
List of... | [
"Obtain",
"components",
"from",
"graph",
"table",
"for",
"the",
"given",
"observation",
"mode",
"keywords",
"and",
"starting",
"node",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/tables.py#L154-L265 | train |
spacetelescope/pysynphot | commissioning/extrap/extrap.py | fincre | def fincre(oldname):
"""Increment the synphot version number from a filename"""
x=re.search('_(?P<version>[0-9][0-9][0-9])_syn',oldname)
version=x.group('version')
newversion="%03d"%(int(version)+1)
ans=oldname.replace(version,newversion)
return ans | python | def fincre(oldname):
"""Increment the synphot version number from a filename"""
x=re.search('_(?P<version>[0-9][0-9][0-9])_syn',oldname)
version=x.group('version')
newversion="%03d"%(int(version)+1)
ans=oldname.replace(version,newversion)
return ans | [
"def",
"fincre",
"(",
"oldname",
")",
":",
"x",
"=",
"re",
".",
"search",
"(",
"'_(?P<version>[0-9][0-9][0-9])_syn'",
",",
"oldname",
")",
"version",
"=",
"x",
".",
"group",
"(",
"'version'",
")",
"newversion",
"=",
"\"%03d\"",
"%",
"(",
"int",
"(",
"ver... | Increment the synphot version number from a filename | [
"Increment",
"the",
"synphot",
"version",
"number",
"from",
"a",
"filename"
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/extrap/extrap.py#L207-L213 | train |
spacetelescope/pysynphot | commissioning/basecase.py | calcspecCase.run_crbox | def run_crbox(self,spstring,form,output="",wavecat="INDEF",
lowave=0,hiwave=30000):
"""Calcspec has a bug. We will use countrate instead, and force it
to use a box function of uniform transmission as the obsmode."""
range=hiwave-lowave
midwave=range/2.0
iraf.co... | python | def run_crbox(self,spstring,form,output="",wavecat="INDEF",
lowave=0,hiwave=30000):
"""Calcspec has a bug. We will use countrate instead, and force it
to use a box function of uniform transmission as the obsmode."""
range=hiwave-lowave
midwave=range/2.0
iraf.co... | [
"def",
"run_crbox",
"(",
"self",
",",
"spstring",
",",
"form",
",",
"output",
"=",
"\"\"",
",",
"wavecat",
"=",
"\"INDEF\"",
",",
"lowave",
"=",
"0",
",",
"hiwave",
"=",
"30000",
")",
":",
"range",
"=",
"hiwave",
"-",
"lowave",
"midwave",
"=",
"range... | Calcspec has a bug. We will use countrate instead, and force it
to use a box function of uniform transmission as the obsmode. | [
"Calcspec",
"has",
"a",
"bug",
".",
"We",
"will",
"use",
"countrate",
"instead",
"and",
"force",
"it",
"to",
"use",
"a",
"box",
"function",
"of",
"uniform",
"transmission",
"as",
"the",
"obsmode",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/commissioning/basecase.py#L70-L81 | train |
spacetelescope/pysynphot | pysynphot/observation.py | validate_overlap | def validate_overlap(comp1, comp2, force):
"""Validate the overlap between the wavelength sets
of the two given components.
Parameters
----------
comp1, comp2 : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement`
Source spectrum and bandpass of an observation.
... | python | def validate_overlap(comp1, comp2, force):
"""Validate the overlap between the wavelength sets
of the two given components.
Parameters
----------
comp1, comp2 : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement`
Source spectrum and bandpass of an observation.
... | [
"def",
"validate_overlap",
"(",
"comp1",
",",
"comp2",
",",
"force",
")",
":",
"warnings",
"=",
"dict",
"(",
")",
"if",
"force",
"is",
"None",
":",
"stat",
"=",
"comp2",
".",
"check_overlap",
"(",
"comp1",
")",
"if",
"stat",
"==",
"'full'",
":",
"pas... | Validate the overlap between the wavelength sets
of the two given components.
Parameters
----------
comp1, comp2 : `~pysynphot.spectrum.SourceSpectrum` or `~pysynphot.spectrum.SpectralElement`
Source spectrum and bandpass of an observation.
force : {'extrap', 'taper', `None`}
If no... | [
"Validate",
"the",
"overlap",
"between",
"the",
"wavelength",
"sets",
"of",
"the",
"two",
"given",
"components",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L81-L140 | train |
spacetelescope/pysynphot | pysynphot/observation.py | Observation.validate_overlap | def validate_overlap(self,force):
"""Validate that spectrum and bandpass overlap.
Warnings are stored in ``self.warnings``.
Parameters
----------
force : {'extrap', 'taper', `None`}
If `None`, it is required that the spectrum and bandpass fully
overlap. P... | python | def validate_overlap(self,force):
"""Validate that spectrum and bandpass overlap.
Warnings are stored in ``self.warnings``.
Parameters
----------
force : {'extrap', 'taper', `None`}
If `None`, it is required that the spectrum and bandpass fully
overlap. P... | [
"def",
"validate_overlap",
"(",
"self",
",",
"force",
")",
":",
"self",
".",
"spectrum",
",",
"self",
".",
"bandpass",
",",
"warn",
"=",
"validate_overlap",
"(",
"self",
".",
"spectrum",
",",
"self",
".",
"bandpass",
",",
"force",
")",
"self",
".",
"wa... | Validate that spectrum and bandpass overlap.
Warnings are stored in ``self.warnings``.
Parameters
----------
force : {'extrap', 'taper', `None`}
If `None`, it is required that the spectrum and bandpass fully
overlap. Partial overlap is allowed if this is set to
... | [
"Validate",
"that",
"spectrum",
"and",
"bandpass",
"overlap",
".",
"Warnings",
"are",
"stored",
"in",
"self",
".",
"warnings",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L236-L252 | train |
spacetelescope/pysynphot | pysynphot/observation.py | Observation.initbinset | def initbinset(self,binset=None):
"""Set ``self.binwave``.
By default, wavelength values for binning are inherited
from bandpass. If the bandpass has no binning information,
then source spectrum wavelengths are used. However, if
user provides values, then those are used without ... | python | def initbinset(self,binset=None):
"""Set ``self.binwave``.
By default, wavelength values for binning are inherited
from bandpass. If the bandpass has no binning information,
then source spectrum wavelengths are used. However, if
user provides values, then those are used without ... | [
"def",
"initbinset",
"(",
"self",
",",
"binset",
"=",
"None",
")",
":",
"if",
"binset",
"is",
"None",
":",
"msg",
"=",
"\"(%s) does not have a defined binset in the wavecat table. The waveset of the spectrum will be used instead.\"",
"%",
"str",
"(",
"self",
".",
"bandp... | Set ``self.binwave``.
By default, wavelength values for binning are inherited
from bandpass. If the bandpass has no binning information,
then source spectrum wavelengths are used. However, if
user provides values, then those are used without question.
Parameters
-------... | [
"Set",
"self",
".",
"binwave",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L254-L281 | train |
spacetelescope/pysynphot | pysynphot/observation.py | Observation.initbinflux | def initbinflux(self):
"""Calculate binned flux and edges.
Flux is computed by integrating the spectrum
on the specified binned wavelength set, using
information from the natural wavelength set.
Native wave/flux arrays should be considered samples
of a continuous functi... | python | def initbinflux(self):
"""Calculate binned flux and edges.
Flux is computed by integrating the spectrum
on the specified binned wavelength set, using
information from the natural wavelength set.
Native wave/flux arrays should be considered samples
of a continuous functi... | [
"def",
"initbinflux",
"(",
"self",
")",
":",
"endpoints",
"=",
"binning",
".",
"calculate_bin_edges",
"(",
"self",
".",
"binwave",
")",
"spwave",
"=",
"spectrum",
".",
"MergeWaveSets",
"(",
"self",
".",
"wave",
",",
"endpoints",
")",
"spwave",
"=",
"spectr... | Calculate binned flux and edges.
Flux is computed by integrating the spectrum
on the specified binned wavelength set, using
information from the natural wavelength set.
Native wave/flux arrays should be considered samples
of a continuous function, but not their binned counterpa... | [
"Calculate",
"binned",
"flux",
"and",
"edges",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L283-L340 | train |
spacetelescope/pysynphot | pysynphot/observation.py | Observation.as_spectrum | def as_spectrum(self, binned=True):
"""Reduce the observation to a simple spectrum object.
An observation is a complex object with some restrictions on its
capabilities. At times, it would be useful to work with the
simulated observation as a simple object that is easier to
mani... | python | def as_spectrum(self, binned=True):
"""Reduce the observation to a simple spectrum object.
An observation is a complex object with some restrictions on its
capabilities. At times, it would be useful to work with the
simulated observation as a simple object that is easier to
mani... | [
"def",
"as_spectrum",
"(",
"self",
",",
"binned",
"=",
"True",
")",
":",
"if",
"binned",
":",
"wave",
",",
"flux",
"=",
"self",
".",
"binwave",
",",
"self",
".",
"binflux",
"else",
":",
"wave",
",",
"flux",
"=",
"self",
".",
"wave",
",",
"self",
... | Reduce the observation to a simple spectrum object.
An observation is a complex object with some restrictions on its
capabilities. At times, it would be useful to work with the
simulated observation as a simple object that is easier to
manipulate and takes up less memory.
Param... | [
"Reduce",
"the",
"observation",
"to",
"a",
"simple",
"spectrum",
"object",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/observation.py#L833-L863 | train |
spacetelescope/pysynphot | pysynphot/locations.py | irafconvert | def irafconvert(iraffilename):
"""Convert the IRAF file name to its Unix equivalent.
Input can be in ``directory$file`` or ``$directory/file`` format.
If ``'$'`` is not found in the input string, it is returned as-is.
Parameters
----------
iraffilename : str
Filename in IRAF format.
... | python | def irafconvert(iraffilename):
"""Convert the IRAF file name to its Unix equivalent.
Input can be in ``directory$file`` or ``$directory/file`` format.
If ``'$'`` is not found in the input string, it is returned as-is.
Parameters
----------
iraffilename : str
Filename in IRAF format.
... | [
"def",
"irafconvert",
"(",
"iraffilename",
")",
":",
"convertdict",
"=",
"CONVERTDICT",
"if",
"not",
"iraffilename",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"(",
"'http'",
",",
"'ftp'",
")",
")",
":",
"iraffilename",
"=",
"os",
".",
"path",
".",
... | Convert the IRAF file name to its Unix equivalent.
Input can be in ``directory$file`` or ``$directory/file`` format.
If ``'$'`` is not found in the input string, it is returned as-is.
Parameters
----------
iraffilename : str
Filename in IRAF format.
Returns
-------
unixfilenam... | [
"Convert",
"the",
"IRAF",
"file",
"name",
"to",
"its",
"Unix",
"equivalent",
"."
] | a125ff956f4d94beb157bd51899747a13234bb97 | https://github.com/spacetelescope/pysynphot/blob/a125ff956f4d94beb157bd51899747a13234bb97/pysynphot/locations.py#L137-L187 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.