repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
twitterdev/search-tweets-python | searchtweets/utils.py | partition | def partition(iterable, chunk_size, pad_none=False):
"""adapted from Toolz. Breaks an iterable into n iterables up to the
certain chunk size, padding with Nones if availble.
Example:
>>> from searchtweets.utils import partition
>>> iter_ = range(10)
>>> list(partition(iter_, 3))
... | python | def partition(iterable, chunk_size, pad_none=False):
"""adapted from Toolz. Breaks an iterable into n iterables up to the
certain chunk size, padding with Nones if availble.
Example:
>>> from searchtweets.utils import partition
>>> iter_ = range(10)
>>> list(partition(iter_, 3))
... | [
"def",
"partition",
"(",
"iterable",
",",
"chunk_size",
",",
"pad_none",
"=",
"False",
")",
":",
"args",
"=",
"[",
"iter",
"(",
"iterable",
")",
"]",
"*",
"chunk_size",
"if",
"not",
"pad_none",
":",
"return",
"zip",
"(",
"*",
"args",
")",
"else",
":"... | adapted from Toolz. Breaks an iterable into n iterables up to the
certain chunk size, padding with Nones if availble.
Example:
>>> from searchtweets.utils import partition
>>> iter_ = range(10)
>>> list(partition(iter_, 3))
[(0, 1, 2), (3, 4, 5), (6, 7, 8)]
>>> list(part... | [
"adapted",
"from",
"Toolz",
".",
"Breaks",
"an",
"iterable",
"into",
"n",
"iterables",
"up",
"to",
"the",
"certain",
"chunk",
"size",
"padding",
"with",
"Nones",
"if",
"availble",
"."
] | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L41-L57 |
twitterdev/search-tweets-python | searchtweets/utils.py | merge_dicts | def merge_dicts(*dicts):
"""
Helpful function to merge / combine dictionaries and return a new
dictionary.
Args:
dicts (list or Iterable): iterable set of dictionaries for merging.
Returns:
dict: dict with all keys from the passed list. Later dictionaries in
the sequence wi... | python | def merge_dicts(*dicts):
"""
Helpful function to merge / combine dictionaries and return a new
dictionary.
Args:
dicts (list or Iterable): iterable set of dictionaries for merging.
Returns:
dict: dict with all keys from the passed list. Later dictionaries in
the sequence wi... | [
"def",
"merge_dicts",
"(",
"*",
"dicts",
")",
":",
"def",
"_merge_dicts",
"(",
"dict1",
",",
"dict2",
")",
":",
"merged",
"=",
"dict1",
".",
"copy",
"(",
")",
"merged",
".",
"update",
"(",
"dict2",
")",
"return",
"merged",
"return",
"reduce",
"(",
"_... | Helpful function to merge / combine dictionaries and return a new
dictionary.
Args:
dicts (list or Iterable): iterable set of dictionaries for merging.
Returns:
dict: dict with all keys from the passed list. Later dictionaries in
the sequence will override duplicate keys from previ... | [
"Helpful",
"function",
"to",
"merge",
"/",
"combine",
"dictionaries",
"and",
"return",
"a",
"new",
"dictionary",
"."
] | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L60-L84 |
twitterdev/search-tweets-python | searchtweets/utils.py | write_ndjson | def write_ndjson(filename, data_iterable, append=False, **kwargs):
"""
Generator that writes newline-delimited json to a file and returns items
from an iterable.
"""
write_mode = "ab" if append else "wb"
logger.info("writing to file {}".format(filename))
with codecs.open(filename, write_mode... | python | def write_ndjson(filename, data_iterable, append=False, **kwargs):
"""
Generator that writes newline-delimited json to a file and returns items
from an iterable.
"""
write_mode = "ab" if append else "wb"
logger.info("writing to file {}".format(filename))
with codecs.open(filename, write_mode... | [
"def",
"write_ndjson",
"(",
"filename",
",",
"data_iterable",
",",
"append",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"write_mode",
"=",
"\"ab\"",
"if",
"append",
"else",
"\"wb\"",
"logger",
".",
"info",
"(",
"\"writing to file {}\"",
".",
"format",
... | Generator that writes newline-delimited json to a file and returns items
from an iterable. | [
"Generator",
"that",
"writes",
"newline",
"-",
"delimited",
"json",
"to",
"a",
"file",
"and",
"returns",
"items",
"from",
"an",
"iterable",
"."
] | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L87-L97 |
twitterdev/search-tweets-python | searchtweets/utils.py | write_result_stream | def write_result_stream(result_stream, filename_prefix=None,
results_per_file=None, **kwargs):
"""
Wraps a ``ResultStream`` object to save it to a file. This function will still
return all data from the result stream as a generator that wraps the
``write_ndjson`` method.
Arg... | python | def write_result_stream(result_stream, filename_prefix=None,
results_per_file=None, **kwargs):
"""
Wraps a ``ResultStream`` object to save it to a file. This function will still
return all data from the result stream as a generator that wraps the
``write_ndjson`` method.
Arg... | [
"def",
"write_result_stream",
"(",
"result_stream",
",",
"filename_prefix",
"=",
"None",
",",
"results_per_file",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"result_stream",
",",
"types",
".",
"GeneratorType",
")",
":",
"stream",
... | Wraps a ``ResultStream`` object to save it to a file. This function will still
return all data from the result stream as a generator that wraps the
``write_ndjson`` method.
Args:
result_stream (ResultStream): the unstarted ResultStream object
filename_prefix (str or None): the base name for... | [
"Wraps",
"a",
"ResultStream",
"object",
"to",
"save",
"it",
"to",
"a",
"file",
".",
"This",
"function",
"will",
"still",
"return",
"all",
"data",
"from",
"the",
"result",
"stream",
"as",
"a",
"generator",
"that",
"wraps",
"the",
"write_ndjson",
"method",
"... | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L100-L140 |
twitterdev/search-tweets-python | searchtweets/utils.py | read_config | def read_config(filename):
"""Reads and flattens a configuration file into a single
dictionary for ease of use. Works with both ``.config`` and
``.yaml`` files. Files should look like this::
search_rules:
from-date: 2017-06-01
to-date: 2017-09-01 01:01
pt-rule: k... | python | def read_config(filename):
"""Reads and flattens a configuration file into a single
dictionary for ease of use. Works with both ``.config`` and
``.yaml`` files. Files should look like this::
search_rules:
from-date: 2017-06-01
to-date: 2017-09-01 01:01
pt-rule: k... | [
"def",
"read_config",
"(",
"filename",
")",
":",
"file_type",
"=",
"\"yaml\"",
"if",
"filename",
".",
"endswith",
"(",
"\".yaml\"",
")",
"else",
"\"config\"",
"config",
"=",
"configparser",
".",
"ConfigParser",
"(",
")",
"if",
"file_type",
"==",
"\"yaml\"",
... | Reads and flattens a configuration file into a single
dictionary for ease of use. Works with both ``.config`` and
``.yaml`` files. Files should look like this::
search_rules:
from-date: 2017-06-01
to-date: 2017-09-01 01:01
pt-rule: kanye
search_params:
... | [
"Reads",
"and",
"flattens",
"a",
"configuration",
"file",
"into",
"a",
"single",
"dictionary",
"for",
"ease",
"of",
"use",
".",
"Works",
"with",
"both",
".",
"config",
"and",
".",
"yaml",
"files",
".",
"Files",
"should",
"look",
"like",
"this",
"::"
] | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/utils.py#L143-L212 |
twitterdev/search-tweets-python | searchtweets/credentials.py | _load_yaml_credentials | def _load_yaml_credentials(filename=None, yaml_key=None):
"""Loads and parses credentials in a YAML file. Catches common exceptions
and returns an empty dict on error, which will be handled downstream.
Returns:
dict: parsed credentials or {}
"""
try:
with open(os.path.expanduser(fil... | python | def _load_yaml_credentials(filename=None, yaml_key=None):
"""Loads and parses credentials in a YAML file. Catches common exceptions
and returns an empty dict on error, which will be handled downstream.
Returns:
dict: parsed credentials or {}
"""
try:
with open(os.path.expanduser(fil... | [
"def",
"_load_yaml_credentials",
"(",
"filename",
"=",
"None",
",",
"yaml_key",
"=",
"None",
")",
":",
"try",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"filename",
")",
")",
"as",
"f",
":",
"search_creds",
"=",
"yaml",
".",
... | Loads and parses credentials in a YAML file. Catches common exceptions
and returns an empty dict on error, which will be handled downstream.
Returns:
dict: parsed credentials or {} | [
"Loads",
"and",
"parses",
"credentials",
"in",
"a",
"YAML",
"file",
".",
"Catches",
"common",
"exceptions",
"and",
"returns",
"an",
"empty",
"dict",
"on",
"error",
"which",
"will",
"be",
"handled",
"downstream",
"."
] | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/credentials.py#L25-L43 |
twitterdev/search-tweets-python | searchtweets/credentials.py | load_credentials | def load_credentials(filename=None, account_type=None,
yaml_key=None, env_overwrite=True):
"""
Handles credential management. Supports both YAML files and environment
variables. A YAML file is preferred for simplicity and configureability.
A YAML credential file should look somethin... | python | def load_credentials(filename=None, account_type=None,
yaml_key=None, env_overwrite=True):
"""
Handles credential management. Supports both YAML files and environment
variables. A YAML file is preferred for simplicity and configureability.
A YAML credential file should look somethin... | [
"def",
"load_credentials",
"(",
"filename",
"=",
"None",
",",
"account_type",
"=",
"None",
",",
"yaml_key",
"=",
"None",
",",
"env_overwrite",
"=",
"True",
")",
":",
"yaml_key",
"=",
"yaml_key",
"if",
"yaml_key",
"is",
"not",
"None",
"else",
"\"search_tweets... | Handles credential management. Supports both YAML files and environment
variables. A YAML file is preferred for simplicity and configureability.
A YAML credential file should look something like this:
.. code:: yaml
<KEY>:
endpoint: <FULL_URL_OF_ENDPOINT>
username: <USERNAME>
... | [
"Handles",
"credential",
"management",
".",
"Supports",
"both",
"YAML",
"files",
"and",
"environment",
"variables",
".",
"A",
"YAML",
"file",
"is",
"preferred",
"for",
"simplicity",
"and",
"configureability",
".",
"A",
"YAML",
"credential",
"file",
"should",
"lo... | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/credentials.py#L110-L190 |
twitterdev/search-tweets-python | searchtweets/credentials.py | _generate_bearer_token | def _generate_bearer_token(consumer_key, consumer_secret):
"""
Return the bearer token for a given pair of consumer key and secret values.
"""
data = [('grant_type', 'client_credentials')]
resp = requests.post(OAUTH_ENDPOINT,
data=data,
auth=(consume... | python | def _generate_bearer_token(consumer_key, consumer_secret):
"""
Return the bearer token for a given pair of consumer key and secret values.
"""
data = [('grant_type', 'client_credentials')]
resp = requests.post(OAUTH_ENDPOINT,
data=data,
auth=(consume... | [
"def",
"_generate_bearer_token",
"(",
"consumer_key",
",",
"consumer_secret",
")",
":",
"data",
"=",
"[",
"(",
"'grant_type'",
",",
"'client_credentials'",
")",
"]",
"resp",
"=",
"requests",
".",
"post",
"(",
"OAUTH_ENDPOINT",
",",
"data",
"=",
"data",
",",
... | Return the bearer token for a given pair of consumer key and secret values. | [
"Return",
"the",
"bearer",
"token",
"for",
"a",
"given",
"pair",
"of",
"consumer",
"key",
"and",
"secret",
"values",
"."
] | train | https://github.com/twitterdev/search-tweets-python/blob/7875afb4f3ee125a9fdcf2e50b5ae761da5f46b5/searchtweets/credentials.py#L193-L206 |
kvesteri/validators | validators/email.py | email | def email(value, whitelist=None):
"""
Validate an email address.
This validator is based on `Django's email validator`_. Returns
``True`` on success and :class:`~validators.utils.ValidationFailure`
when validation fails.
Examples::
>>> email('someone@example.com')
True
... | python | def email(value, whitelist=None):
"""
Validate an email address.
This validator is based on `Django's email validator`_. Returns
``True`` on success and :class:`~validators.utils.ValidationFailure`
when validation fails.
Examples::
>>> email('someone@example.com')
True
... | [
"def",
"email",
"(",
"value",
",",
"whitelist",
"=",
"None",
")",
":",
"if",
"whitelist",
"is",
"None",
":",
"whitelist",
"=",
"domain_whitelist",
"if",
"not",
"value",
"or",
"'@'",
"not",
"in",
"value",
":",
"return",
"False",
"user_part",
",",
"domain_... | Validate an email address.
This validator is based on `Django's email validator`_. Returns
``True`` on success and :class:`~validators.utils.ValidationFailure`
when validation fails.
Examples::
>>> email('someone@example.com')
True
>>> email('bogus@@')
ValidationFailu... | [
"Validate",
"an",
"email",
"address",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/email.py#L26-L72 |
kvesteri/validators | validators/i18n/fi.py | fi_business_id | def fi_business_id(business_id):
"""
Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more
information see `Finnish Trade Register`_
.. _Finnish Trade Register:
http://en.wikipedia.org/wiki/Finnish_Trade_Register
Examples::
>>> fi_busine... | python | def fi_business_id(business_id):
"""
Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more
information see `Finnish Trade Register`_
.. _Finnish Trade Register:
http://en.wikipedia.org/wiki/Finnish_Trade_Register
Examples::
>>> fi_busine... | [
"def",
"fi_business_id",
"(",
"business_id",
")",
":",
"if",
"not",
"business_id",
"or",
"not",
"re",
".",
"match",
"(",
"business_id_pattern",
",",
"business_id",
")",
":",
"return",
"False",
"factors",
"=",
"[",
"7",
",",
"9",
",",
"10",
",",
"5",
",... | Validate a Finnish Business ID.
Each company in Finland has a distinct business id. For more
information see `Finnish Trade Register`_
.. _Finnish Trade Register:
http://en.wikipedia.org/wiki/Finnish_Trade_Register
Examples::
>>> fi_business_id('0112038-9') # Fast Monkeys Ltd
... | [
"Validate",
"a",
"Finnish",
"Business",
"ID",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/i18n/fi.py#L20-L51 |
kvesteri/validators | validators/i18n/fi.py | fi_ssn | def fi_ssn(ssn, allow_temporal_ssn=True):
"""
Validate a Finnish Social Security Number.
This validator is based on `django-localflavor-fi`_.
.. _django-localflavor-fi:
https://github.com/django/django-localflavor-fi/
Examples::
>>> fi_ssn('010101-0101')
True
>>>... | python | def fi_ssn(ssn, allow_temporal_ssn=True):
"""
Validate a Finnish Social Security Number.
This validator is based on `django-localflavor-fi`_.
.. _django-localflavor-fi:
https://github.com/django/django-localflavor-fi/
Examples::
>>> fi_ssn('010101-0101')
True
>>>... | [
"def",
"fi_ssn",
"(",
"ssn",
",",
"allow_temporal_ssn",
"=",
"True",
")",
":",
"if",
"not",
"ssn",
":",
"return",
"False",
"result",
"=",
"re",
".",
"match",
"(",
"ssn_pattern",
",",
"ssn",
")",
"if",
"not",
"result",
":",
"return",
"False",
"gd",
"=... | Validate a Finnish Social Security Number.
This validator is based on `django-localflavor-fi`_.
.. _django-localflavor-fi:
https://github.com/django/django-localflavor-fi/
Examples::
>>> fi_ssn('010101-0101')
True
>>> fi_ssn('101010-0102')
ValidationFailure(func=... | [
"Validate",
"a",
"Finnish",
"Social",
"Security",
"Number",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/i18n/fi.py#L55-L94 |
kvesteri/validators | validators/iban.py | modcheck | def modcheck(value):
"""Check if the value string passes the mod97-test.
"""
# move country code and check numbers to end
rearranged = value[4:] + value[:4]
# convert letters to numbers
converted = [char_value(char) for char in rearranged]
# interpret as integer
integerized = int(''.join... | python | def modcheck(value):
"""Check if the value string passes the mod97-test.
"""
# move country code and check numbers to end
rearranged = value[4:] + value[:4]
# convert letters to numbers
converted = [char_value(char) for char in rearranged]
# interpret as integer
integerized = int(''.join... | [
"def",
"modcheck",
"(",
"value",
")",
":",
"# move country code and check numbers to end",
"rearranged",
"=",
"value",
"[",
"4",
":",
"]",
"+",
"value",
"[",
":",
"4",
"]",
"# convert letters to numbers",
"converted",
"=",
"[",
"char_value",
"(",
"char",
")",
... | Check if the value string passes the mod97-test. | [
"Check",
"if",
"the",
"value",
"string",
"passes",
"the",
"mod97",
"-",
"test",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/iban.py#L20-L29 |
kvesteri/validators | validators/utils.py | func_args_as_dict | def func_args_as_dict(func, args, kwargs):
"""
Return given function's positional and key value arguments as an ordered
dictionary.
"""
if six.PY2:
_getargspec = inspect.getargspec
else:
_getargspec = inspect.getfullargspec
arg_names = list(
OrderedDict.fromkeys(
... | python | def func_args_as_dict(func, args, kwargs):
"""
Return given function's positional and key value arguments as an ordered
dictionary.
"""
if six.PY2:
_getargspec = inspect.getargspec
else:
_getargspec = inspect.getfullargspec
arg_names = list(
OrderedDict.fromkeys(
... | [
"def",
"func_args_as_dict",
"(",
"func",
",",
"args",
",",
"kwargs",
")",
":",
"if",
"six",
".",
"PY2",
":",
"_getargspec",
"=",
"inspect",
".",
"getargspec",
"else",
":",
"_getargspec",
"=",
"inspect",
".",
"getfullargspec",
"arg_names",
"=",
"list",
"(",... | Return given function's positional and key value arguments as an ordered
dictionary. | [
"Return",
"given",
"function",
"s",
"positional",
"and",
"key",
"value",
"arguments",
"as",
"an",
"ordered",
"dictionary",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/utils.py#L35-L56 |
kvesteri/validators | validators/utils.py | validator | def validator(func, *args, **kwargs):
"""
A decorator that makes given function validator.
Whenever the given function is called and returns ``False`` value
this decorator returns :class:`ValidationFailure` object.
Example::
>>> @validator
... def even(value):
... retu... | python | def validator(func, *args, **kwargs):
"""
A decorator that makes given function validator.
Whenever the given function is called and returns ``False`` value
this decorator returns :class:`ValidationFailure` object.
Example::
>>> @validator
... def even(value):
... retu... | [
"def",
"validator",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrapper",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"value",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"i... | A decorator that makes given function validator.
Whenever the given function is called and returns ``False`` value
this decorator returns :class:`ValidationFailure` object.
Example::
>>> @validator
... def even(value):
... return not (value % 2)
>>> even(4)
Tr... | [
"A",
"decorator",
"that",
"makes",
"given",
"function",
"validator",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/utils.py#L59-L89 |
kvesteri/validators | validators/length.py | length | def length(value, min=None, max=None):
"""
Return whether or not the length of given string is within a specified
range.
Examples::
>>> length('something', min=2)
True
>>> length('something', min=9, max=9)
True
>>> length('something', max=5)
Validation... | python | def length(value, min=None, max=None):
"""
Return whether or not the length of given string is within a specified
range.
Examples::
>>> length('something', min=2)
True
>>> length('something', min=9, max=9)
True
>>> length('something', max=5)
Validation... | [
"def",
"length",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"if",
"(",
"min",
"is",
"not",
"None",
"and",
"min",
"<",
"0",
")",
"or",
"(",
"max",
"is",
"not",
"None",
"and",
"max",
"<",
"0",
")",
":",
"raise",
... | Return whether or not the length of given string is within a specified
range.
Examples::
>>> length('something', min=2)
True
>>> length('something', min=9, max=9)
True
>>> length('something', max=5)
ValidationFailure(func=length, ...)
:param value:
... | [
"Return",
"whether",
"or",
"not",
"the",
"length",
"of",
"given",
"string",
"is",
"within",
"a",
"specified",
"range",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/length.py#L6-L37 |
kvesteri/validators | validators/url.py | url | def url(value, public=False):
"""
Return whether or not given value is a valid URL.
If the value is valid URL this function returns ``True``, otherwise
:class:`~validators.utils.ValidationFailure`.
This validator is based on the wonderful `URL validator of dperini`_.
.. _URL validator of dper... | python | def url(value, public=False):
"""
Return whether or not given value is a valid URL.
If the value is valid URL this function returns ``True``, otherwise
:class:`~validators.utils.ValidationFailure`.
This validator is based on the wonderful `URL validator of dperini`_.
.. _URL validator of dper... | [
"def",
"url",
"(",
"value",
",",
"public",
"=",
"False",
")",
":",
"result",
"=",
"pattern",
".",
"match",
"(",
"value",
")",
"if",
"not",
"public",
":",
"return",
"result",
"return",
"result",
"and",
"not",
"any",
"(",
"(",
"result",
".",
"groupdict... | Return whether or not given value is a valid URL.
If the value is valid URL this function returns ``True``, otherwise
:class:`~validators.utils.ValidationFailure`.
This validator is based on the wonderful `URL validator of dperini`_.
.. _URL validator of dperini:
https://gist.github.com/dperi... | [
"Return",
"whether",
"or",
"not",
"given",
"value",
"is",
"a",
"valid",
"URL",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/url.py#L94-L151 |
kvesteri/validators | validators/between.py | between | def between(value, min=None, max=None):
"""
Validate that a number is between minimum and/or maximum value.
This will work with any comparable type, such as floats, decimals and dates
not just integers.
This validator is originally based on `WTForms NumberRange validator`_.
.. _WTForms Number... | python | def between(value, min=None, max=None):
"""
Validate that a number is between minimum and/or maximum value.
This will work with any comparable type, such as floats, decimals and dates
not just integers.
This validator is originally based on `WTForms NumberRange validator`_.
.. _WTForms Number... | [
"def",
"between",
"(",
"value",
",",
"min",
"=",
"None",
",",
"max",
"=",
"None",
")",
":",
"if",
"min",
"is",
"None",
"and",
"max",
"is",
"None",
":",
"raise",
"AssertionError",
"(",
"'At least one of `min` or `max` must be specified.'",
")",
"if",
"min",
... | Validate that a number is between minimum and/or maximum value.
This will work with any comparable type, such as floats, decimals and dates
not just integers.
This validator is originally based on `WTForms NumberRange validator`_.
.. _WTForms NumberRange validator:
https://github.com/wtforms/w... | [
"Validate",
"that",
"a",
"number",
"is",
"between",
"minimum",
"and",
"/",
"or",
"maximum",
"value",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/between.py#L6-L61 |
kvesteri/validators | validators/ip_address.py | ipv4 | def ipv4(value):
"""
Return whether or not given value is a valid IP version 4 address.
This validator is based on `WTForms IPAddress validator`_
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv4('123.0.0.7')
... | python | def ipv4(value):
"""
Return whether or not given value is a valid IP version 4 address.
This validator is based on `WTForms IPAddress validator`_
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv4('123.0.0.7')
... | [
"def",
"ipv4",
"(",
"value",
")",
":",
"groups",
"=",
"value",
".",
"split",
"(",
"'.'",
")",
"if",
"len",
"(",
"groups",
")",
"!=",
"4",
"or",
"any",
"(",
"not",
"x",
".",
"isdigit",
"(",
")",
"for",
"x",
"in",
"groups",
")",
":",
"return",
... | Return whether or not given value is a valid IP version 4 address.
This validator is based on `WTForms IPAddress validator`_
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv4('123.0.0.7')
True
>>> ipv... | [
"Return",
"whether",
"or",
"not",
"given",
"value",
"is",
"a",
"valid",
"IP",
"version",
"4",
"address",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/ip_address.py#L5-L29 |
kvesteri/validators | validators/ip_address.py | ipv6 | def ipv6(value):
"""
Return whether or not given value is a valid IP version 6 address
(including IPv4-mapped IPv6 addresses).
This validator is based on `WTForms IPAddress validator`_.
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
... | python | def ipv6(value):
"""
Return whether or not given value is a valid IP version 6 address
(including IPv4-mapped IPv6 addresses).
This validator is based on `WTForms IPAddress validator`_.
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
... | [
"def",
"ipv6",
"(",
"value",
")",
":",
"ipv6_groups",
"=",
"value",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"ipv6_groups",
")",
"==",
"1",
":",
"return",
"False",
"ipv4_groups",
"=",
"ipv6_groups",
"[",
"-",
"1",
"]",
".",
"split",
"(",
"'... | Return whether or not given value is a valid IP version 6 address
(including IPv4-mapped IPv6 addresses).
This validator is based on `WTForms IPAddress validator`_.
.. _WTForms IPAddress validator:
https://github.com/wtforms/wtforms/blob/master/wtforms/validators.py
Examples::
>>> ipv... | [
"Return",
"whether",
"or",
"not",
"given",
"value",
"is",
"a",
"valid",
"IP",
"version",
"6",
"address",
"(",
"including",
"IPv4",
"-",
"mapped",
"IPv6",
"addresses",
")",
"."
] | train | https://github.com/kvesteri/validators/blob/34d355e87168241e872b25811d245810df2bd430/validators/ip_address.py#L33-L94 |
Yubico/python-u2flib-server | release.py | get_version | def get_version(module_name_or_file=None):
"""Return the current version as defined by the given module/file."""
if module_name_or_file is None:
parts = base_module.split('.')
module_name_or_file = parts[0] if len(parts) > 1 else \
find_packages(exclude=['test', 'test.*'])[0]
i... | python | def get_version(module_name_or_file=None):
"""Return the current version as defined by the given module/file."""
if module_name_or_file is None:
parts = base_module.split('.')
module_name_or_file = parts[0] if len(parts) > 1 else \
find_packages(exclude=['test', 'test.*'])[0]
i... | [
"def",
"get_version",
"(",
"module_name_or_file",
"=",
"None",
")",
":",
"if",
"module_name_or_file",
"is",
"None",
":",
"parts",
"=",
"base_module",
".",
"split",
"(",
"'.'",
")",
"module_name_or_file",
"=",
"parts",
"[",
"0",
"]",
"if",
"len",
"(",
"part... | Return the current version as defined by the given module/file. | [
"Return",
"the",
"current",
"version",
"as",
"defined",
"by",
"the",
"given",
"module",
"/",
"file",
"."
] | train | https://github.com/Yubico/python-u2flib-server/blob/4b9d353a3ba82be40c6cf9bab39d34ea7e07cb5a/release.py#L45-L58 |
eddyxu/cpp-coveralls | cpp_coveralls/report.py | post_report | def post_report(coverage, args):
"""Post coverage report to coveralls.io."""
response = requests.post(URL, files={'json_file': json.dumps(coverage)},
verify=(not args.skip_ssl_verify))
try:
result = response.json()
except ValueError:
result = {'error': 'Failu... | python | def post_report(coverage, args):
"""Post coverage report to coveralls.io."""
response = requests.post(URL, files={'json_file': json.dumps(coverage)},
verify=(not args.skip_ssl_verify))
try:
result = response.json()
except ValueError:
result = {'error': 'Failu... | [
"def",
"post_report",
"(",
"coverage",
",",
"args",
")",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"URL",
",",
"files",
"=",
"{",
"'json_file'",
":",
"json",
".",
"dumps",
"(",
"coverage",
")",
"}",
",",
"verify",
"=",
"(",
"not",
"args",
... | Post coverage report to coveralls.io. | [
"Post",
"coverage",
"report",
"to",
"coveralls",
".",
"io",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/report.py#L10-L24 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | is_source_file | def is_source_file(args, filepath):
"""Returns true if it is a C++ source file."""
if args.extension:
return os.path.splitext(filepath)[1] in args.extension
else:
return os.path.splitext(filepath)[1] in _CPP_EXTENSIONS | python | def is_source_file(args, filepath):
"""Returns true if it is a C++ source file."""
if args.extension:
return os.path.splitext(filepath)[1] in args.extension
else:
return os.path.splitext(filepath)[1] in _CPP_EXTENSIONS | [
"def",
"is_source_file",
"(",
"args",
",",
"filepath",
")",
":",
"if",
"args",
".",
"extension",
":",
"return",
"os",
".",
"path",
".",
"splitext",
"(",
"filepath",
")",
"[",
"1",
"]",
"in",
"args",
".",
"extension",
"else",
":",
"return",
"os",
".",... | Returns true if it is a C++ source file. | [
"Returns",
"true",
"if",
"it",
"is",
"a",
"C",
"++",
"source",
"file",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L93-L98 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | exclude_paths | def exclude_paths(args):
"""Returns the absolute paths for excluded path."""
results = []
if args.exclude:
for excl_path in args.exclude:
results.append(os.path.abspath(os.path.join(args.root, excl_path)))
return results | python | def exclude_paths(args):
"""Returns the absolute paths for excluded path."""
results = []
if args.exclude:
for excl_path in args.exclude:
results.append(os.path.abspath(os.path.join(args.root, excl_path)))
return results | [
"def",
"exclude_paths",
"(",
"args",
")",
":",
"results",
"=",
"[",
"]",
"if",
"args",
".",
"exclude",
":",
"for",
"excl_path",
"in",
"args",
".",
"exclude",
":",
"results",
".",
"append",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"pa... | Returns the absolute paths for excluded path. | [
"Returns",
"the",
"absolute",
"paths",
"for",
"excluded",
"path",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L101-L107 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | create_exclude_rules | def create_exclude_rules(args):
"""Creates the exlude rules
"""
global _cached_exclude_rules
if _cached_exclude_rules is not None:
return _cached_exclude_rules
rules = []
for excl_path in args.exclude:
abspath = os.path.abspath(os.path.join(args.root, excl_path))
rules.ap... | python | def create_exclude_rules(args):
"""Creates the exlude rules
"""
global _cached_exclude_rules
if _cached_exclude_rules is not None:
return _cached_exclude_rules
rules = []
for excl_path in args.exclude:
abspath = os.path.abspath(os.path.join(args.root, excl_path))
rules.ap... | [
"def",
"create_exclude_rules",
"(",
"args",
")",
":",
"global",
"_cached_exclude_rules",
"if",
"_cached_exclude_rules",
"is",
"not",
"None",
":",
"return",
"_cached_exclude_rules",
"rules",
"=",
"[",
"]",
"for",
"excl_path",
"in",
"args",
".",
"exclude",
":",
"a... | Creates the exlude rules | [
"Creates",
"the",
"exlude",
"rules"
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L113-L127 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | is_excluded_path | def is_excluded_path(args, filepath):
"""Returns true if the filepath is under the one of the exclude path."""
# Try regular expressions first.
for regexp_exclude_path in args.regexp:
if re.match(regexp_exclude_path, filepath):
return True
abspath = os.path.abspath(filepath)
if a... | python | def is_excluded_path(args, filepath):
"""Returns true if the filepath is under the one of the exclude path."""
# Try regular expressions first.
for regexp_exclude_path in args.regexp:
if re.match(regexp_exclude_path, filepath):
return True
abspath = os.path.abspath(filepath)
if a... | [
"def",
"is_excluded_path",
"(",
"args",
",",
"filepath",
")",
":",
"# Try regular expressions first.",
"for",
"regexp_exclude_path",
"in",
"args",
".",
"regexp",
":",
"if",
"re",
".",
"match",
"(",
"regexp_exclude_path",
",",
"filepath",
")",
":",
"return",
"Tru... | Returns true if the filepath is under the one of the exclude path. | [
"Returns",
"true",
"if",
"the",
"filepath",
"is",
"under",
"the",
"one",
"of",
"the",
"exclude",
"path",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L135-L166 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | filter_dirs | def filter_dirs(root, dirs, excl_paths):
"""Filter directory paths based on the exclusion rules defined in
'excl_paths'.
"""
filtered_dirs = []
for dirpath in dirs:
abspath = os.path.abspath(os.path.join(root, dirpath))
if os.path.basename(abspath) in _SKIP_DIRS:
continue... | python | def filter_dirs(root, dirs, excl_paths):
"""Filter directory paths based on the exclusion rules defined in
'excl_paths'.
"""
filtered_dirs = []
for dirpath in dirs:
abspath = os.path.abspath(os.path.join(root, dirpath))
if os.path.basename(abspath) in _SKIP_DIRS:
continue... | [
"def",
"filter_dirs",
"(",
"root",
",",
"dirs",
",",
"excl_paths",
")",
":",
"filtered_dirs",
"=",
"[",
"]",
"for",
"dirpath",
"in",
"dirs",
":",
"abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
"... | Filter directory paths based on the exclusion rules defined in
'excl_paths'. | [
"Filter",
"directory",
"paths",
"based",
"on",
"the",
"exclusion",
"rules",
"defined",
"in",
"excl_paths",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L186-L197 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | parse_gcov_file | def parse_gcov_file(args, fobj, filename):
"""Parses the content of .gcov file
"""
coverage = []
ignoring = False
for line in fobj:
report_fields = line.decode('utf-8', 'replace').split(':', 2)
if len(report_fields) == 1:
continue
line_num = report_fields[1].strip... | python | def parse_gcov_file(args, fobj, filename):
"""Parses the content of .gcov file
"""
coverage = []
ignoring = False
for line in fobj:
report_fields = line.decode('utf-8', 'replace').split(':', 2)
if len(report_fields) == 1:
continue
line_num = report_fields[1].strip... | [
"def",
"parse_gcov_file",
"(",
"args",
",",
"fobj",
",",
"filename",
")",
":",
"coverage",
"=",
"[",
"]",
"ignoring",
"=",
"False",
"for",
"line",
"in",
"fobj",
":",
"report_fields",
"=",
"line",
".",
"decode",
"(",
"'utf-8'",
",",
"'replace'",
")",
".... | Parses the content of .gcov file | [
"Parses",
"the",
"content",
"of",
".",
"gcov",
"file"
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L247-L296 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | parse_lcov_file_info | def parse_lcov_file_info(args, filepath, line_iter, line_coverage_re, file_end_string):
""" Parse the file content in lcov info file
"""
coverage = []
lines_covered = []
for line in line_iter:
if line != "end_of_record":
line_coverage_match = line_coverage_re.match(line)
... | python | def parse_lcov_file_info(args, filepath, line_iter, line_coverage_re, file_end_string):
""" Parse the file content in lcov info file
"""
coverage = []
lines_covered = []
for line in line_iter:
if line != "end_of_record":
line_coverage_match = line_coverage_re.match(line)
... | [
"def",
"parse_lcov_file_info",
"(",
"args",
",",
"filepath",
",",
"line_iter",
",",
"line_coverage_re",
",",
"file_end_string",
")",
":",
"coverage",
"=",
"[",
"]",
"lines_covered",
"=",
"[",
"]",
"for",
"line",
"in",
"line_iter",
":",
"if",
"line",
"!=",
... | Parse the file content in lcov info file | [
"Parse",
"the",
"file",
"content",
"in",
"lcov",
"info",
"file"
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L299-L322 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | combine_reports | def combine_reports(original, new):
"""Combines two gcov reports for a file into one by adding the number of hits on each line
"""
if original is None:
return new
report = {}
report['name'] = original['name']
report['source_digest'] = original['source_digest']
coverage = []
for o... | python | def combine_reports(original, new):
"""Combines two gcov reports for a file into one by adding the number of hits on each line
"""
if original is None:
return new
report = {}
report['name'] = original['name']
report['source_digest'] = original['source_digest']
coverage = []
for o... | [
"def",
"combine_reports",
"(",
"original",
",",
"new",
")",
":",
"if",
"original",
"is",
"None",
":",
"return",
"new",
"report",
"=",
"{",
"}",
"report",
"[",
"'name'",
"]",
"=",
"original",
"[",
"'name'",
"]",
"report",
"[",
"'source_digest'",
"]",
"=... | Combines two gcov reports for a file into one by adding the number of hits on each line | [
"Combines",
"two",
"gcov",
"reports",
"for",
"a",
"file",
"into",
"one",
"by",
"adding",
"the",
"number",
"of",
"hits",
"on",
"each",
"line"
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L324-L342 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | collect_non_report_files | def collect_non_report_files(args, discovered_files):
"""Collects the source files that have no coverage reports.
"""
excl_paths = exclude_paths(args)
abs_root = os.path.abspath(args.root)
non_report_files = []
for root, dirs, files in os.walk(args.root, followlinks=args.follow_symlinks):
... | python | def collect_non_report_files(args, discovered_files):
"""Collects the source files that have no coverage reports.
"""
excl_paths = exclude_paths(args)
abs_root = os.path.abspath(args.root)
non_report_files = []
for root, dirs, files in os.walk(args.root, followlinks=args.follow_symlinks):
... | [
"def",
"collect_non_report_files",
"(",
"args",
",",
"discovered_files",
")",
":",
"excl_paths",
"=",
"exclude_paths",
"(",
"args",
")",
"abs_root",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"args",
".",
"root",
")",
"non_report_files",
"=",
"[",
"]",
"... | Collects the source files that have no coverage reports. | [
"Collects",
"the",
"source",
"files",
"that",
"have",
"no",
"coverage",
"reports",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L344-L371 |
eddyxu/cpp-coveralls | cpp_coveralls/coverage.py | collect | def collect(args):
"""Collect coverage reports."""
excl_paths = exclude_paths(args)
report = {}
if args.repo_token:
report['repo_token'] = args.repo_token
report['service_name'] = args.service_name
report['service_job_id'] = args.service_job_id
if os.getenv('COVERALLS_PARALLEL', F... | python | def collect(args):
"""Collect coverage reports."""
excl_paths = exclude_paths(args)
report = {}
if args.repo_token:
report['repo_token'] = args.repo_token
report['service_name'] = args.service_name
report['service_job_id'] = args.service_job_id
if os.getenv('COVERALLS_PARALLEL', F... | [
"def",
"collect",
"(",
"args",
")",
":",
"excl_paths",
"=",
"exclude_paths",
"(",
"args",
")",
"report",
"=",
"{",
"}",
"if",
"args",
".",
"repo_token",
":",
"report",
"[",
"'repo_token'",
"]",
"=",
"args",
".",
"repo_token",
"report",
"[",
"'service_nam... | Collect coverage reports. | [
"Collect",
"coverage",
"reports",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/coverage.py#L374-L472 |
eddyxu/cpp-coveralls | cpp_coveralls/__init__.py | parse_yaml_config | def parse_yaml_config(args):
"""Parse yaml config"""
try:
import yaml
except ImportError:
yaml = None
yml = {}
try:
with open(args.coveralls_yaml, 'r') as fp:
if not yaml:
raise SystemExit('PyYAML is required for parsing configuration')
... | python | def parse_yaml_config(args):
"""Parse yaml config"""
try:
import yaml
except ImportError:
yaml = None
yml = {}
try:
with open(args.coveralls_yaml, 'r') as fp:
if not yaml:
raise SystemExit('PyYAML is required for parsing configuration')
... | [
"def",
"parse_yaml_config",
"(",
"args",
")",
":",
"try",
":",
"import",
"yaml",
"except",
"ImportError",
":",
"yaml",
"=",
"None",
"yml",
"=",
"{",
"}",
"try",
":",
"with",
"open",
"(",
"args",
".",
"coveralls_yaml",
",",
"'r'",
")",
"as",
"fp",
":"... | Parse yaml config | [
"Parse",
"yaml",
"config"
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/__init__.py#L37-L53 |
eddyxu/cpp-coveralls | cpp_coveralls/__init__.py | run | def run():
"""Run cpp coverage."""
import json
import os
import sys
from . import coverage, report
args = coverage.create_args(sys.argv[1:])
if args.verbose:
print('encodings: {}'.format(args.encodings))
yml = parse_yaml_config(args)
if not args.repo_token:
# try ... | python | def run():
"""Run cpp coverage."""
import json
import os
import sys
from . import coverage, report
args = coverage.create_args(sys.argv[1:])
if args.verbose:
print('encodings: {}'.format(args.encodings))
yml = parse_yaml_config(args)
if not args.repo_token:
# try ... | [
"def",
"run",
"(",
")",
":",
"import",
"json",
"import",
"os",
"import",
"sys",
"from",
".",
"import",
"coverage",
",",
"report",
"args",
"=",
"coverage",
".",
"create_args",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"if",
"args",
".",
"ver... | Run cpp coverage. | [
"Run",
"cpp",
"coverage",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/__init__.py#L55-L106 |
eddyxu/cpp-coveralls | cpp_coveralls/gitrepo.py | gitrepo | def gitrepo(cwd):
"""Return hash of Git data that can be used to display more information to
users.
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
"author_name": "Wil Gieseler",
"author_email": "wil@example.c... | python | def gitrepo(cwd):
"""Return hash of Git data that can be used to display more information to
users.
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
"author_name": "Wil Gieseler",
"author_email": "wil@example.c... | [
"def",
"gitrepo",
"(",
"cwd",
")",
":",
"repo",
"=",
"Repository",
"(",
"cwd",
")",
"if",
"not",
"repo",
".",
"valid",
"(",
")",
":",
"return",
"{",
"}",
"return",
"{",
"'head'",
":",
"{",
"'id'",
":",
"repo",
".",
"gitlog",
"(",
"'%H'",
")",
"... | Return hash of Git data that can be used to display more information to
users.
Example:
"git": {
"head": {
"id": "5e837ce92220be64821128a70f6093f836dd2c05",
"author_name": "Wil Gieseler",
"author_email": "wil@example.com",
"com... | [
"Return",
"hash",
"of",
"Git",
"data",
"that",
"can",
"be",
"used",
"to",
"display",
"more",
"information",
"to",
"users",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/gitrepo.py#L7-L49 |
eddyxu/cpp-coveralls | cpp_coveralls/gitrepo.py | Repository.git | def git(self, *arguments):
"""
Return (exit code, output) from git.
"""
process = subprocess.Popen(['git'] + list(arguments),
stdout=subprocess.PIPE,
cwd=self.cwd)
out = process.communicate()[0].decode('UTF-8')... | python | def git(self, *arguments):
"""
Return (exit code, output) from git.
"""
process = subprocess.Popen(['git'] + list(arguments),
stdout=subprocess.PIPE,
cwd=self.cwd)
out = process.communicate()[0].decode('UTF-8')... | [
"def",
"git",
"(",
"self",
",",
"*",
"arguments",
")",
":",
"process",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'git'",
"]",
"+",
"list",
"(",
"arguments",
")",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"cwd",
"=",
"self",
".",
"cwd",
... | Return (exit code, output) from git. | [
"Return",
"(",
"exit",
"code",
"output",
")",
"from",
"git",
"."
] | train | https://github.com/eddyxu/cpp-coveralls/blob/ff7af7eea2a23828f6ab2541667ea04f94344dce/cpp_coveralls/gitrepo.py#L66-L75 |
vitiral/gpio | gpio.py | _verify | def _verify(function):
"""decorator to ensure pin is properly set up"""
# @functools.wraps
def wrapped(pin, *args, **kwargs):
pin = int(pin)
if pin not in _open:
ppath = gpiopath(pin)
if not os.path.exists(ppath):
log.debug("Creating Pin {0}".f... | python | def _verify(function):
"""decorator to ensure pin is properly set up"""
# @functools.wraps
def wrapped(pin, *args, **kwargs):
pin = int(pin)
if pin not in _open:
ppath = gpiopath(pin)
if not os.path.exists(ppath):
log.debug("Creating Pin {0}".f... | [
"def",
"_verify",
"(",
"function",
")",
":",
"# @functools.wraps\r",
"def",
"wrapped",
"(",
"pin",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"pin",
"=",
"int",
"(",
"pin",
")",
"if",
"pin",
"not",
"in",
"_open",
":",
"ppath",
"=",
"gpiop... | decorator to ensure pin is properly set up | [
"decorator",
"to",
"ensure",
"pin",
"is",
"properly",
"set",
"up"
] | train | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L54-L70 |
vitiral/gpio | gpio.py | cleanup | def cleanup(pin=None, assert_exists=False):
"""Cleanup the pin by closing and unexporting it.
Args:
pin (int, optional): either the pin to clean up or None (default).
If None, clean up all pins.
assert_exists: if True, raise a ValueError if the pin was not
setup. ... | python | def cleanup(pin=None, assert_exists=False):
"""Cleanup the pin by closing and unexporting it.
Args:
pin (int, optional): either the pin to clean up or None (default).
If None, clean up all pins.
assert_exists: if True, raise a ValueError if the pin was not
setup. ... | [
"def",
"cleanup",
"(",
"pin",
"=",
"None",
",",
"assert_exists",
"=",
"False",
")",
":",
"if",
"pin",
"is",
"None",
":",
"# Take a list of keys because we will be deleting from _open\r",
"for",
"pin",
"in",
"list",
"(",
"_open",
")",
":",
"cleanup",
"(",
"pin"... | Cleanup the pin by closing and unexporting it.
Args:
pin (int, optional): either the pin to clean up or None (default).
If None, clean up all pins.
assert_exists: if True, raise a ValueError if the pin was not
setup. Otherwise, this function is a NOOP. | [
"Cleanup",
"the",
"pin",
"by",
"closing",
"and",
"unexporting",
"it",
".",
"Args",
":",
"pin",
"(",
"int",
"optional",
")",
":",
"either",
"the",
"pin",
"to",
"clean",
"up",
"or",
"None",
"(",
"default",
")",
".",
"If",
"None",
"clean",
"up",
"all",
... | train | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L73-L103 |
vitiral/gpio | gpio.py | setup | def setup(pin, mode, pullup=None, initial=False):
'''Setup pin with mode IN or OUT.
Args:
pin (int):
mode (str): use either gpio.OUT or gpio.IN
pullup (None): rpio compatibility. If anything but None, raises
value Error
pullup (bool, optional): Initial pin va... | python | def setup(pin, mode, pullup=None, initial=False):
'''Setup pin with mode IN or OUT.
Args:
pin (int):
mode (str): use either gpio.OUT or gpio.IN
pullup (None): rpio compatibility. If anything but None, raises
value Error
pullup (bool, optional): Initial pin va... | [
"def",
"setup",
"(",
"pin",
",",
"mode",
",",
"pullup",
"=",
"None",
",",
"initial",
"=",
"False",
")",
":",
"if",
"pullup",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"\"sysfs does not support pullups\"",
")",
"if",
"mode",
"not",
"in",
"(",
... | Setup pin with mode IN or OUT.
Args:
pin (int):
mode (str): use either gpio.OUT or gpio.IN
pullup (None): rpio compatibility. If anything but None, raises
value Error
pullup (bool, optional): Initial pin value. Default is False | [
"Setup",
"pin",
"with",
"mode",
"IN",
"or",
"OUT",
".",
"Args",
":",
"pin",
"(",
"int",
")",
":",
"mode",
"(",
"str",
")",
":",
"use",
"either",
"gpio",
".",
"OUT",
"or",
"gpio",
".",
"IN",
"pullup",
"(",
"None",
")",
":",
"rpio",
"compatibility"... | train | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L107-L130 |
vitiral/gpio | gpio.py | read | def read(pin):
'''read the pin value
Returns:
bool: 0 or 1
'''
f = _open[pin].value
out = int(_read(f))
log.debug("Read {0}: {1}".format(pin, out))
return out | python | def read(pin):
'''read the pin value
Returns:
bool: 0 or 1
'''
f = _open[pin].value
out = int(_read(f))
log.debug("Read {0}: {1}".format(pin, out))
return out | [
"def",
"read",
"(",
"pin",
")",
":",
"f",
"=",
"_open",
"[",
"pin",
"]",
".",
"value",
"out",
"=",
"int",
"(",
"_read",
"(",
"f",
")",
")",
"log",
".",
"debug",
"(",
"\"Read {0}: {1}\"",
".",
"format",
"(",
"pin",
",",
"out",
")",
")",
"return"... | read the pin value
Returns:
bool: 0 or 1 | [
"read",
"the",
"pin",
"value",
"Returns",
":",
"bool",
":",
"0",
"or",
"1"
] | train | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L145-L154 |
vitiral/gpio | gpio.py | set | def set(pin, value):
'''set the pin value to 0 or 1'''
if value is LOW:
value = 0
value = int(bool(value))
log.debug("Write {0}: {1}".format(pin, value))
f = _open[pin].value
_write(f, value) | python | def set(pin, value):
'''set the pin value to 0 or 1'''
if value is LOW:
value = 0
value = int(bool(value))
log.debug("Write {0}: {1}".format(pin, value))
f = _open[pin].value
_write(f, value) | [
"def",
"set",
"(",
"pin",
",",
"value",
")",
":",
"if",
"value",
"is",
"LOW",
":",
"value",
"=",
"0",
"value",
"=",
"int",
"(",
"bool",
"(",
"value",
")",
")",
"log",
".",
"debug",
"(",
"\"Write {0}: {1}\"",
".",
"format",
"(",
"pin",
",",
"value... | set the pin value to 0 or 1 | [
"set",
"the",
"pin",
"value",
"to",
"0",
"or",
"1"
] | train | https://github.com/vitiral/gpio/blob/d4d8bdc6965295b978eca882e2e2e5a1b35e047b/gpio.py#L158-L165 |
bstriner/keras-tqdm | keras_tqdm/tqdm_callback.py | TQDMCallback.tqdm | def tqdm(self, desc, total, leave, initial=0):
"""
Extension point. Override to provide custom options to tqdm initializer.
:param desc: Description string
:param total: Total number of updates
:param leave: Leave progress bar when done
:param initial: Initial counter sta... | python | def tqdm(self, desc, total, leave, initial=0):
"""
Extension point. Override to provide custom options to tqdm initializer.
:param desc: Description string
:param total: Total number of updates
:param leave: Leave progress bar when done
:param initial: Initial counter sta... | [
"def",
"tqdm",
"(",
"self",
",",
"desc",
",",
"total",
",",
"leave",
",",
"initial",
"=",
"0",
")",
":",
"return",
"tqdm",
"(",
"desc",
"=",
"desc",
",",
"total",
"=",
"total",
",",
"leave",
"=",
"leave",
",",
"file",
"=",
"self",
".",
"output_fi... | Extension point. Override to provide custom options to tqdm initializer.
:param desc: Description string
:param total: Total number of updates
:param leave: Leave progress bar when done
:param initial: Initial counter state
:return: new progress bar | [
"Extension",
"point",
".",
"Override",
"to",
"provide",
"custom",
"options",
"to",
"tqdm",
"initializer",
".",
":",
"param",
"desc",
":",
"Description",
"string",
":",
"param",
"total",
":",
"Total",
"number",
"of",
"updates",
":",
"param",
"leave",
":",
"... | train | https://github.com/bstriner/keras-tqdm/blob/9696a8d6602d098364314f33b746fb868e225c95/keras_tqdm/tqdm_callback.py#L53-L62 |
bstriner/keras-tqdm | keras_tqdm/tqdm_callback.py | TQDMCallback.build_tqdm_outer | def build_tqdm_outer(self, desc, total):
"""
Extension point. Override to provide custom options to outer progress bars (Epoch loop)
:param desc: Description
:param total: Number of epochs
:return: new progress bar
"""
return self.tqdm(desc=desc, total=total, leav... | python | def build_tqdm_outer(self, desc, total):
"""
Extension point. Override to provide custom options to outer progress bars (Epoch loop)
:param desc: Description
:param total: Number of epochs
:return: new progress bar
"""
return self.tqdm(desc=desc, total=total, leav... | [
"def",
"build_tqdm_outer",
"(",
"self",
",",
"desc",
",",
"total",
")",
":",
"return",
"self",
".",
"tqdm",
"(",
"desc",
"=",
"desc",
",",
"total",
"=",
"total",
",",
"leave",
"=",
"self",
".",
"leave_outer",
",",
"initial",
"=",
"self",
".",
"initia... | Extension point. Override to provide custom options to outer progress bars (Epoch loop)
:param desc: Description
:param total: Number of epochs
:return: new progress bar | [
"Extension",
"point",
".",
"Override",
"to",
"provide",
"custom",
"options",
"to",
"outer",
"progress",
"bars",
"(",
"Epoch",
"loop",
")",
":",
"param",
"desc",
":",
"Description",
":",
"param",
"total",
":",
"Number",
"of",
"epochs",
":",
"return",
":",
... | train | https://github.com/bstriner/keras-tqdm/blob/9696a8d6602d098364314f33b746fb868e225c95/keras_tqdm/tqdm_callback.py#L64-L71 |
bstriner/keras-tqdm | keras_tqdm/tqdm_callback.py | TQDMCallback.build_tqdm_inner | def build_tqdm_inner(self, desc, total):
"""
Extension point. Override to provide custom options to inner progress bars (Batch loop)
:param desc: Description
:param total: Number of batches
:return: new progress bar
"""
return self.tqdm(desc=desc, total=total, lea... | python | def build_tqdm_inner(self, desc, total):
"""
Extension point. Override to provide custom options to inner progress bars (Batch loop)
:param desc: Description
:param total: Number of batches
:return: new progress bar
"""
return self.tqdm(desc=desc, total=total, lea... | [
"def",
"build_tqdm_inner",
"(",
"self",
",",
"desc",
",",
"total",
")",
":",
"return",
"self",
".",
"tqdm",
"(",
"desc",
"=",
"desc",
",",
"total",
"=",
"total",
",",
"leave",
"=",
"self",
".",
"leave_inner",
")"
] | Extension point. Override to provide custom options to inner progress bars (Batch loop)
:param desc: Description
:param total: Number of batches
:return: new progress bar | [
"Extension",
"point",
".",
"Override",
"to",
"provide",
"custom",
"options",
"to",
"inner",
"progress",
"bars",
"(",
"Batch",
"loop",
")",
":",
"param",
"desc",
":",
"Description",
":",
"param",
"total",
":",
"Number",
"of",
"batches",
":",
"return",
":",
... | train | https://github.com/bstriner/keras-tqdm/blob/9696a8d6602d098364314f33b746fb868e225c95/keras_tqdm/tqdm_callback.py#L73-L80 |
bstriner/keras-tqdm | keras_tqdm/tqdm_notebook_callback.py | TQDMNotebookCallback.tqdm | def tqdm(self, desc, total, leave, initial=0):
"""
Extension point. Override to provide custom options to tqdm_notebook initializer.
:param desc: Description string
:param total: Total number of updates
:param leave: Leave progress bar when done
:return: new progress bar
... | python | def tqdm(self, desc, total, leave, initial=0):
"""
Extension point. Override to provide custom options to tqdm_notebook initializer.
:param desc: Description string
:param total: Total number of updates
:param leave: Leave progress bar when done
:return: new progress bar
... | [
"def",
"tqdm",
"(",
"self",
",",
"desc",
",",
"total",
",",
"leave",
",",
"initial",
"=",
"0",
")",
":",
"return",
"tqdm_notebook",
"(",
"desc",
"=",
"desc",
",",
"total",
"=",
"total",
",",
"leave",
"=",
"leave",
",",
"initial",
"=",
"initial",
")... | Extension point. Override to provide custom options to tqdm_notebook initializer.
:param desc: Description string
:param total: Total number of updates
:param leave: Leave progress bar when done
:return: new progress bar
:param initial: Initial counter state | [
"Extension",
"point",
".",
"Override",
"to",
"provide",
"custom",
"options",
"to",
"tqdm_notebook",
"initializer",
".",
":",
"param",
"desc",
":",
"Description",
"string",
":",
"param",
"total",
":",
"Total",
"number",
"of",
"updates",
":",
"param",
"leave",
... | train | https://github.com/bstriner/keras-tqdm/blob/9696a8d6602d098364314f33b746fb868e225c95/keras_tqdm/tqdm_notebook_callback.py#L29-L38 |
fhs/pyhdf | pyhdf/V.py | V.end | def end(self):
"""Close the V interface.
Args::
No argument
Returns::
None
C library equivalent : Vend
"""
# Note: Vend is just a macro; use 'Vfinish' instead
# Note also the the same C function is ... | python | def end(self):
"""Close the V interface.
Args::
No argument
Returns::
None
C library equivalent : Vend
"""
# Note: Vend is just a macro; use 'Vfinish' instead
# Note also the the same C function is ... | [
"def",
"end",
"(",
"self",
")",
":",
"# Note: Vend is just a macro; use 'Vfinish' instead",
"# Note also the the same C function is used to end",
"# the VS interface",
"_checkErr",
"(",
"'vend'",
",",
"_C",
".",
"Vfinish",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
")",
... | Close the V interface.
Args::
No argument
Returns::
None
C library equivalent : Vend | [
"Close",
"the",
"V",
"interface",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L704-L723 |
fhs/pyhdf | pyhdf/V.py | V.attach | def attach(self, num_name, write=0):
"""Open an existing vgroup given its name or its reference
number, or create a new vgroup, returning a VG instance for
that vgroup.
Args::
num_name reference number or name of the vgroup to open,
or -1 to creat... | python | def attach(self, num_name, write=0):
"""Open an existing vgroup given its name or its reference
number, or create a new vgroup, returning a VG instance for
that vgroup.
Args::
num_name reference number or name of the vgroup to open,
or -1 to creat... | [
"def",
"attach",
"(",
"self",
",",
"num_name",
",",
"write",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"num_name",
",",
"bytes",
")",
":",
"num",
"=",
"self",
".",
"find",
"(",
"num_name",
")",
"else",
":",
"num",
"=",
"num_name",
"vg_id",
"=",
... | Open an existing vgroup given its name or its reference
number, or create a new vgroup, returning a VG instance for
that vgroup.
Args::
num_name reference number or name of the vgroup to open,
or -1 to create a new vgroup; vcreate() can also
... | [
"Open",
"an",
"existing",
"vgroup",
"given",
"its",
"name",
"or",
"its",
"reference",
"number",
"or",
"create",
"a",
"new",
"vgroup",
"returning",
"a",
"VG",
"instance",
"for",
"that",
"vgroup",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L725-L755 |
fhs/pyhdf | pyhdf/V.py | V.create | def create(self, name):
"""Create a new vgroup, and assign it a name.
Args::
name name to assign to the new vgroup
Returns::
VG instance for the new vgroup
A create(name) call is equivalent to an attach(-1, 1) call,
followed by a call to the setname(nam... | python | def create(self, name):
"""Create a new vgroup, and assign it a name.
Args::
name name to assign to the new vgroup
Returns::
VG instance for the new vgroup
A create(name) call is equivalent to an attach(-1, 1) call,
followed by a call to the setname(nam... | [
"def",
"create",
"(",
"self",
",",
"name",
")",
":",
"vg",
"=",
"self",
".",
"attach",
"(",
"-",
"1",
",",
"1",
")",
"vg",
".",
"_name",
"=",
"name",
"return",
"vg"
] | Create a new vgroup, and assign it a name.
Args::
name name to assign to the new vgroup
Returns::
VG instance for the new vgroup
A create(name) call is equivalent to an attach(-1, 1) call,
followed by a call to the setname(name) method of the instance.
... | [
"Create",
"a",
"new",
"vgroup",
"and",
"assign",
"it",
"a",
"name",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L757-L776 |
fhs/pyhdf | pyhdf/V.py | V.find | def find(self, name):
"""Find a vgroup given its name, returning its reference
number if found.
Args::
name name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: ... | python | def find(self, name):
"""Find a vgroup given its name, returning its reference
number if found.
Args::
name name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: ... | [
"def",
"find",
"(",
"self",
",",
"name",
")",
":",
"refnum",
"=",
"_C",
".",
"Vfind",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"name",
")",
"if",
"not",
"refnum",
":",
"raise",
"HDF4Error",
"(",
"\"vgroup not found\"",
")",
"return",
"refnum"
] | Find a vgroup given its name, returning its reference
number if found.
Args::
name name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: Vfind | [
"Find",
"a",
"vgroup",
"given",
"its",
"name",
"returning",
"its",
"reference",
"number",
"if",
"found",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L778-L798 |
fhs/pyhdf | pyhdf/V.py | V.findclass | def findclass(self, name):
"""Find a vgroup given its class name, returning its reference
number if found.
Args::
name class name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C lib... | python | def findclass(self, name):
"""Find a vgroup given its class name, returning its reference
number if found.
Args::
name class name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C lib... | [
"def",
"findclass",
"(",
"self",
",",
"name",
")",
":",
"refnum",
"=",
"_C",
".",
"Vfindclass",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"name",
")",
"if",
"not",
"refnum",
":",
"raise",
"HDF4Error",
"(",
"\"vgroup not found\"",
")",
"return",
"... | Find a vgroup given its class name, returning its reference
number if found.
Args::
name class name of the vgroup to find
Returns::
vgroup reference number
An exception is raised if the vgroup is not found.
C library equivalent: Vfind | [
"Find",
"a",
"vgroup",
"given",
"its",
"class",
"name",
"returning",
"its",
"reference",
"number",
"if",
"found",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L800-L820 |
fhs/pyhdf | pyhdf/V.py | V.delete | def delete(self, num_name):
"""Delete from the HDF file the vgroup identified by its
reference number or its name.
Args::
num_name either the reference number or the name of
the vgroup to delete
Returns::
None
C library equivalent... | python | def delete(self, num_name):
"""Delete from the HDF file the vgroup identified by its
reference number or its name.
Args::
num_name either the reference number or the name of
the vgroup to delete
Returns::
None
C library equivalent... | [
"def",
"delete",
"(",
"self",
",",
"num_name",
")",
":",
"try",
":",
"vg",
"=",
"self",
".",
"attach",
"(",
"num_name",
",",
"1",
")",
"except",
"HDF4Error",
"as",
"msg",
":",
"raise",
"HDF4Error",
"(",
"\"delete: no such vgroup\"",
")",
"# ATTENTION: The ... | Delete from the HDF file the vgroup identified by its
reference number or its name.
Args::
num_name either the reference number or the name of
the vgroup to delete
Returns::
None
C library equivalent : Vdelete | [
"Delete",
"from",
"the",
"HDF",
"file",
"the",
"vgroup",
"identified",
"by",
"its",
"reference",
"number",
"or",
"its",
"name",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L822-L849 |
fhs/pyhdf | pyhdf/V.py | V.getid | def getid(self, ref):
"""Obtain the reference number of the vgroup following the
vgroup with the given reference number .
Args::
ref reference number of the vgroup after which to search;
set to -1 to start the search at the start of
the HDF file
... | python | def getid(self, ref):
"""Obtain the reference number of the vgroup following the
vgroup with the given reference number .
Args::
ref reference number of the vgroup after which to search;
set to -1 to start the search at the start of
the HDF file
... | [
"def",
"getid",
"(",
"self",
",",
"ref",
")",
":",
"num",
"=",
"_C",
".",
"Vgetid",
"(",
"self",
".",
"_hdf_inst",
".",
"_id",
",",
"ref",
")",
"_checkErr",
"(",
"'getid'",
",",
"num",
",",
"\"bad arguments or last vgroup reached\"",
")",
"return",
"num"... | Obtain the reference number of the vgroup following the
vgroup with the given reference number .
Args::
ref reference number of the vgroup after which to search;
set to -1 to start the search at the start of
the HDF file
Returns::
refe... | [
"Obtain",
"the",
"reference",
"number",
"of",
"the",
"vgroup",
"following",
"the",
"vgroup",
"with",
"the",
"given",
"reference",
"number",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L851-L872 |
fhs/pyhdf | pyhdf/V.py | VG.insert | def insert(self, inst):
"""Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert
"""
... | python | def insert(self, inst):
"""Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert
"""
... | [
"def",
"insert",
"(",
"self",
",",
"inst",
")",
":",
"if",
"isinstance",
"(",
"inst",
",",
"VD",
")",
":",
"id",
"=",
"inst",
".",
"_id",
"elif",
"isinstance",
"(",
"inst",
",",
"VG",
")",
":",
"id",
"=",
"inst",
".",
"_id",
"else",
":",
"raise... | Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert | [
"Insert",
"a",
"vdata",
"or",
"a",
"vgroup",
"in",
"the",
"vgroup",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L994-L1017 |
fhs/pyhdf | pyhdf/V.py | VG.add | def add(self, tag, ref):
"""Add to the vgroup an object identified by its tag and
reference number.
Args::
tag tag of the object to add
ref reference number of the object to add
Returns::
total number of objects in the vgroup after the additi... | python | def add(self, tag, ref):
"""Add to the vgroup an object identified by its tag and
reference number.
Args::
tag tag of the object to add
ref reference number of the object to add
Returns::
total number of objects in the vgroup after the additi... | [
"def",
"add",
"(",
"self",
",",
"tag",
",",
"ref",
")",
":",
"n",
"=",
"_C",
".",
"Vaddtagref",
"(",
"self",
".",
"_id",
",",
"tag",
",",
"ref",
")",
"_checkErr",
"(",
"'addtagref'",
",",
"n",
",",
"'invalid arguments'",
")",
"return",
"n"
] | Add to the vgroup an object identified by its tag and
reference number.
Args::
tag tag of the object to add
ref reference number of the object to add
Returns::
total number of objects in the vgroup after the addition
C library equivalent : V... | [
"Add",
"to",
"the",
"vgroup",
"an",
"object",
"identified",
"by",
"its",
"tag",
"and",
"reference",
"number",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1019-L1037 |
fhs/pyhdf | pyhdf/V.py | VG.delete | def delete(self, tag, ref):
"""Delete from the vgroup the member identified by its tag
and reference number.
Args::
tag tag of the member to delete
ref reference number of the member to delete
Returns::
None
Only the link of the member wit... | python | def delete(self, tag, ref):
"""Delete from the vgroup the member identified by its tag
and reference number.
Args::
tag tag of the member to delete
ref reference number of the member to delete
Returns::
None
Only the link of the member wit... | [
"def",
"delete",
"(",
"self",
",",
"tag",
",",
"ref",
")",
":",
"_checkErr",
"(",
"'delete'",
",",
"_C",
".",
"Vdeletetagref",
"(",
"self",
".",
"_id",
",",
"tag",
",",
"ref",
")",
",",
"\"error deleting member\"",
")"
] | Delete from the vgroup the member identified by its tag
and reference number.
Args::
tag tag of the member to delete
ref reference number of the member to delete
Returns::
None
Only the link of the member with the vgroup is deleted.
The me... | [
"Delete",
"from",
"the",
"vgroup",
"the",
"member",
"identified",
"by",
"its",
"tag",
"and",
"reference",
"number",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1039-L1059 |
fhs/pyhdf | pyhdf/V.py | VG.tagref | def tagref(self, index):
"""Get the tag and reference number of a vgroup member,
given the index number of that member.
Args::
index member index (0 based)
Returns::
2-element tuple:
- member tag
- member reference number
C libra... | python | def tagref(self, index):
"""Get the tag and reference number of a vgroup member,
given the index number of that member.
Args::
index member index (0 based)
Returns::
2-element tuple:
- member tag
- member reference number
C libra... | [
"def",
"tagref",
"(",
"self",
",",
"index",
")",
":",
"status",
",",
"tag",
",",
"ref",
"=",
"_C",
".",
"Vgettagref",
"(",
"self",
".",
"_id",
",",
"index",
")",
"_checkErr",
"(",
"'tagref'",
",",
"status",
",",
"\"illegal arguments\"",
")",
"return",
... | Get the tag and reference number of a vgroup member,
given the index number of that member.
Args::
index member index (0 based)
Returns::
2-element tuple:
- member tag
- member reference number
C library equivalent : Vgettagref | [
"Get",
"the",
"tag",
"and",
"reference",
"number",
"of",
"a",
"vgroup",
"member",
"given",
"the",
"index",
"number",
"of",
"that",
"member",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1079-L1098 |
fhs/pyhdf | pyhdf/V.py | VG.tagrefs | def tagrefs(self):
"""Get the tags and reference numbers of all the vgroup
members.
Args::
no argument
Returns::
list of (tag,ref) tuples, one for each vgroup member
C library equivalent : Vgettagrefs
... | python | def tagrefs(self):
"""Get the tags and reference numbers of all the vgroup
members.
Args::
no argument
Returns::
list of (tag,ref) tuples, one for each vgroup member
C library equivalent : Vgettagrefs
... | [
"def",
"tagrefs",
"(",
"self",
")",
":",
"n",
"=",
"self",
".",
"_nmembers",
"ret",
"=",
"[",
"]",
"if",
"n",
":",
"tags",
"=",
"_C",
".",
"array_int32",
"(",
"n",
")",
"refs",
"=",
"_C",
".",
"array_int32",
"(",
"n",
")",
"k",
"=",
"_C",
"."... | Get the tags and reference numbers of all the vgroup
members.
Args::
no argument
Returns::
list of (tag,ref) tuples, one for each vgroup member
C library equivalent : Vgettagrefs | [
"Get",
"the",
"tags",
"and",
"reference",
"numbers",
"of",
"all",
"the",
"vgroup",
"members",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1100-L1124 |
fhs/pyhdf | pyhdf/V.py | VG.inqtagref | def inqtagref(self, tag, ref):
"""Determines if an object identified by its tag and reference
number belongs to the vgroup.
Args::
tag tag of the object to check
ref reference number of the object to check
Returns::
False (0) if the object does... | python | def inqtagref(self, tag, ref):
"""Determines if an object identified by its tag and reference
number belongs to the vgroup.
Args::
tag tag of the object to check
ref reference number of the object to check
Returns::
False (0) if the object does... | [
"def",
"inqtagref",
"(",
"self",
",",
"tag",
",",
"ref",
")",
":",
"return",
"_C",
".",
"Vinqtagref",
"(",
"self",
".",
"_id",
",",
"tag",
",",
"ref",
")"
] | Determines if an object identified by its tag and reference
number belongs to the vgroup.
Args::
tag tag of the object to check
ref reference number of the object to check
Returns::
False (0) if the object does not belong to the vgroup,
True ... | [
"Determines",
"if",
"an",
"object",
"identified",
"by",
"its",
"tag",
"and",
"reference",
"number",
"belongs",
"to",
"the",
"vgroup",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1126-L1143 |
fhs/pyhdf | pyhdf/V.py | VG.nrefs | def nrefs(self, tag):
"""Determine the number of tags of a given type in a vgroup.
Args::
tag tag type to look for in the vgroup
Returns::
number of members identified by this tag type
C library equivalent : Vnrefs
... | python | def nrefs(self, tag):
"""Determine the number of tags of a given type in a vgroup.
Args::
tag tag type to look for in the vgroup
Returns::
number of members identified by this tag type
C library equivalent : Vnrefs
... | [
"def",
"nrefs",
"(",
"self",
",",
"tag",
")",
":",
"n",
"=",
"_C",
".",
"Vnrefs",
"(",
"self",
".",
"_id",
",",
"tag",
")",
"_checkErr",
"(",
"'nrefs'",
",",
"n",
",",
"\"bad arguments\"",
")",
"return",
"n"
] | Determine the number of tags of a given type in a vgroup.
Args::
tag tag type to look for in the vgroup
Returns::
number of members identified by this tag type
C library equivalent : Vnrefs | [
"Determine",
"the",
"number",
"of",
"tags",
"of",
"a",
"given",
"type",
"in",
"a",
"vgroup",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1145-L1161 |
fhs/pyhdf | pyhdf/V.py | VG.attrinfo | def attrinfo(self):
"""Return info about all the vgroup attributes.
Args::
no argument
Returns::
dictionnary describing each vgroup attribute; for each attribute,
a (name,data) pair is added to the dictionary, where 'data' is
a tuple holding:
... | python | def attrinfo(self):
"""Return info about all the vgroup attributes.
Args::
no argument
Returns::
dictionnary describing each vgroup attribute; for each attribute,
a (name,data) pair is added to the dictionary, where 'data' is
a tuple holding:
... | [
"def",
"attrinfo",
"(",
"self",
")",
":",
"dic",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"self",
".",
"_nattrs",
")",
":",
"att",
"=",
"self",
".",
"attr",
"(",
"n",
")",
"name",
",",
"type",
",",
"order",
",",
"size",
"=",
"att",
".",... | Return info about all the vgroup attributes.
Args::
no argument
Returns::
dictionnary describing each vgroup attribute; for each attribute,
a (name,data) pair is added to the dictionary, where 'data' is
a tuple holding:
- attribute data type (one of... | [
"Return",
"info",
"about",
"all",
"the",
"vgroup",
"attributes",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1218-L1245 |
fhs/pyhdf | pyhdf/V.py | VG.findattr | def findattr(self, name):
"""Search the vgroup for a given attribute.
Args::
name attribute name
Returns::
if found, VGAttr instance describing the attribute
None otherwise
C library equivalent : Vfindattr
... | python | def findattr(self, name):
"""Search the vgroup for a given attribute.
Args::
name attribute name
Returns::
if found, VGAttr instance describing the attribute
None otherwise
C library equivalent : Vfindattr
... | [
"def",
"findattr",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"att",
"=",
"self",
".",
"attr",
"(",
"name",
")",
"if",
"att",
".",
"_index",
"is",
"None",
":",
"att",
"=",
"None",
"except",
"HDF4Error",
":",
"att",
"=",
"None",
"return",
"at... | Search the vgroup for a given attribute.
Args::
name attribute name
Returns::
if found, VGAttr instance describing the attribute
None otherwise
C library equivalent : Vfindattr | [
"Search",
"the",
"vgroup",
"for",
"a",
"given",
"attribute",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1248-L1269 |
fhs/pyhdf | pyhdf/V.py | VGAttr.get | def get(self):
"""Retrieve the attribute value.
Args::
no argument
Returns::
attribute value(s); a list is returned if the attribute
is made up of more than one value, except in the case of a
string-valued attribute (data type HC.CHAR8) where the
... | python | def get(self):
"""Retrieve the attribute value.
Args::
no argument
Returns::
attribute value(s); a list is returned if the attribute
is made up of more than one value, except in the case of a
string-valued attribute (data type HC.CHAR8) where the
... | [
"def",
"get",
"(",
"self",
")",
":",
"# Make sure the attribute exists.",
"if",
"self",
".",
"_index",
"is",
"None",
":",
"raise",
"HDF4Error",
"(",
"\"non existent attribute\"",
")",
"# Obtain attribute type and the number of values.",
"status",
",",
"aName",
",",
"d... | Retrieve the attribute value.
Args::
no argument
Returns::
attribute value(s); a list is returned if the attribute
is made up of more than one value, except in the case of a
string-valued attribute (data type HC.CHAR8) where the
values are returned a... | [
"Retrieve",
"the",
"attribute",
"value",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1308-L1374 |
fhs/pyhdf | pyhdf/V.py | VGAttr.info | def info(self):
"""Retrieve info about the attribute.
Args::
no argument
Returns::
4-element tuple with the following components:
-attribute name
-attribute data type (one of HC.xxx constants)
-attribute order (number of values)
... | python | def info(self):
"""Retrieve info about the attribute.
Args::
no argument
Returns::
4-element tuple with the following components:
-attribute name
-attribute data type (one of HC.xxx constants)
-attribute order (number of values)
... | [
"def",
"info",
"(",
"self",
")",
":",
"# Make sure the attribute exists.",
"if",
"self",
".",
"_index",
"is",
"None",
":",
"raise",
"HDF4Error",
"(",
"\"non existent attribute\"",
")",
"status",
",",
"name",
",",
"type",
",",
"order",
",",
"size",
"=",
"_C",... | Retrieve info about the attribute.
Args::
no argument
Returns::
4-element tuple with the following components:
-attribute name
-attribute data type (one of HC.xxx constants)
-attribute order (number of values)
-attribute size in byt... | [
"Retrieve",
"info",
"about",
"the",
"attribute",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L1467-L1492 |
fhs/pyhdf | pyhdf/SD.py | SDAttr.info | def info(self):
"""Retrieve info about the attribute : name, data type and
number of values.
Args::
no argument
Returns::
3-element tuple holding:
- attribute name
- attribute data type (see constants SDC.xxx)
- number of values in t... | python | def info(self):
"""Retrieve info about the attribute : name, data type and
number of values.
Args::
no argument
Returns::
3-element tuple holding:
- attribute name
- attribute data type (see constants SDC.xxx)
- number of values in t... | [
"def",
"info",
"(",
"self",
")",
":",
"if",
"self",
".",
"_index",
"is",
"None",
":",
"try",
":",
"self",
".",
"_index",
"=",
"self",
".",
"_obj",
".",
"findattr",
"(",
"self",
".",
"_name",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF4Error",
"(... | Retrieve info about the attribute : name, data type and
number of values.
Args::
no argument
Returns::
3-element tuple holding:
- attribute name
- attribute data type (see constants SDC.xxx)
- number of values in the attribute; for a string-... | [
"Retrieve",
"info",
"about",
"the",
"attribute",
":",
"name",
"data",
"type",
"and",
"number",
"of",
"values",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1147-L1176 |
fhs/pyhdf | pyhdf/SD.py | SDAttr.index | def index(self):
"""Retrieve the attribute index number.
Args::
no argument
Returns::
attribute index number (starting at 0)
C library equivalent : SDfindattr
"""
self._index = _C.SDfindattr(self._obj._id, sel... | python | def index(self):
"""Retrieve the attribute index number.
Args::
no argument
Returns::
attribute index number (starting at 0)
C library equivalent : SDfindattr
"""
self._index = _C.SDfindattr(self._obj._id, sel... | [
"def",
"index",
"(",
"self",
")",
":",
"self",
".",
"_index",
"=",
"_C",
".",
"SDfindattr",
"(",
"self",
".",
"_obj",
".",
"_id",
",",
"self",
".",
"_name",
")",
"_checkErr",
"(",
"'find'",
",",
"self",
".",
"_index",
",",
"'illegal attribute name'",
... | Retrieve the attribute index number.
Args::
no argument
Returns::
attribute index number (starting at 0)
C library equivalent : SDfindattr | [
"Retrieve",
"the",
"attribute",
"index",
"number",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1178-L1194 |
fhs/pyhdf | pyhdf/SD.py | SDAttr.get | def get(self):
"""Retrieve the attribute value.
Args::
no argument
Returns::
attribute value(s); a list is returned if the attribute
is made up of more than one value, except in the case of a
string-valued attribute (data type SDC.CHAR8) where the
... | python | def get(self):
"""Retrieve the attribute value.
Args::
no argument
Returns::
attribute value(s); a list is returned if the attribute
is made up of more than one value, except in the case of a
string-valued attribute (data type SDC.CHAR8) where the
... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"_index",
"is",
"None",
":",
"try",
":",
"self",
".",
"_index",
"=",
"self",
".",
"_obj",
".",
"findattr",
"(",
"self",
".",
"_name",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF4Error",
"("... | Retrieve the attribute value.
Args::
no argument
Returns::
attribute value(s); a list is returned if the attribute
is made up of more than one value, except in the case of a
string-valued attribute (data type SDC.CHAR8) where the
values are returned ... | [
"Retrieve",
"the",
"attribute",
"value",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1196-L1265 |
fhs/pyhdf | pyhdf/SD.py | SDAttr.set | def set(self, data_type, values):
"""Update/Create a new attribute and set its value(s).
Args::
data_type : attribute data type (see constants SDC.xxx)
values : attribute value(s); specify a list to create
a multi-valued attribute; a string valued
... | python | def set(self, data_type, values):
"""Update/Create a new attribute and set its value(s).
Args::
data_type : attribute data type (see constants SDC.xxx)
values : attribute value(s); specify a list to create
a multi-valued attribute; a string valued
... | [
"def",
"set",
"(",
"self",
",",
"data_type",
",",
"values",
")",
":",
"try",
":",
"n_values",
"=",
"len",
"(",
"values",
")",
"except",
":",
"n_values",
"=",
"1",
"values",
"=",
"[",
"values",
"]",
"if",
"data_type",
"==",
"SDC",
".",
"CHAR8",
":",... | Update/Create a new attribute and set its value(s).
Args::
data_type : attribute data type (see constants SDC.xxx)
values : attribute value(s); specify a list to create
a multi-valued attribute; a string valued
attribute can be cre... | [
"Update",
"/",
"Create",
"a",
"new",
"attribute",
"and",
"set",
"its",
"value",
"(",
"s",
")",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1267-L1336 |
fhs/pyhdf | pyhdf/SD.py | SD.end | def end(self):
"""End access to the SD interface and close the HDF file.
Args::
no argument
Returns::
None
The instance should not be used afterwards.
The 'end()' method is implicitly called when the
SD instance is deleted.
C library ... | python | def end(self):
"""End access to the SD interface and close the HDF file.
Args::
no argument
Returns::
None
The instance should not be used afterwards.
The 'end()' method is implicitly called when the
SD instance is deleted.
C library ... | [
"def",
"end",
"(",
"self",
")",
":",
"status",
"=",
"_C",
".",
"SDend",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'end'",
",",
"status",
",",
"\"cannot execute\"",
")",
"self",
".",
"_id",
"=",
"None"
] | End access to the SD interface and close the HDF file.
Args::
no argument
Returns::
None
The instance should not be used afterwards.
The 'end()' method is implicitly called when the
SD instance is deleted.
C library equivalent : SDend | [
"End",
"access",
"to",
"the",
"SD",
"interface",
"and",
"close",
"the",
"HDF",
"file",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1457-L1477 |
fhs/pyhdf | pyhdf/SD.py | SD.info | def info(self):
"""Retrieve information about the SD interface.
Args::
no argument
Returns::
2-element tuple holding:
number of datasets inside the file
number of file attributes
C library equivalent : SDfileinfo
... | python | def info(self):
"""Retrieve information about the SD interface.
Args::
no argument
Returns::
2-element tuple holding:
number of datasets inside the file
number of file attributes
C library equivalent : SDfileinfo
... | [
"def",
"info",
"(",
"self",
")",
":",
"status",
",",
"n_datasets",
",",
"n_file_attrs",
"=",
"_C",
".",
"SDfileinfo",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'info'",
",",
"status",
",",
"\"cannot execute\"",
")",
"return",
"n_datasets",
",",
"n... | Retrieve information about the SD interface.
Args::
no argument
Returns::
2-element tuple holding:
number of datasets inside the file
number of file attributes
C library equivalent : SDfileinfo | [
"Retrieve",
"information",
"about",
"the",
"SD",
"interface",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1479-L1497 |
fhs/pyhdf | pyhdf/SD.py | SD.nametoindex | def nametoindex(self, sds_name):
"""Return the index number of a dataset given the dataset name.
Args::
sds_name : dataset name
Returns::
index number of the dataset
C library equivalent : SDnametoindex
"""
... | python | def nametoindex(self, sds_name):
"""Return the index number of a dataset given the dataset name.
Args::
sds_name : dataset name
Returns::
index number of the dataset
C library equivalent : SDnametoindex
"""
... | [
"def",
"nametoindex",
"(",
"self",
",",
"sds_name",
")",
":",
"sds_idx",
"=",
"_C",
".",
"SDnametoindex",
"(",
"self",
".",
"_id",
",",
"sds_name",
")",
"_checkErr",
"(",
"'nametoindex'",
",",
"sds_idx",
",",
"'non existent SDS'",
")",
"return",
"sds_idx"
] | Return the index number of a dataset given the dataset name.
Args::
sds_name : dataset name
Returns::
index number of the dataset
C library equivalent : SDnametoindex | [
"Return",
"the",
"index",
"number",
"of",
"a",
"dataset",
"given",
"the",
"dataset",
"name",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1499-L1515 |
fhs/pyhdf | pyhdf/SD.py | SD.reftoindex | def reftoindex(self, sds_ref):
"""Returns the index number of a dataset given the dataset
reference number.
Args::
sds_ref : dataset reference number
Returns::
dataset index number
C library equivalent : SDreftoindex
... | python | def reftoindex(self, sds_ref):
"""Returns the index number of a dataset given the dataset
reference number.
Args::
sds_ref : dataset reference number
Returns::
dataset index number
C library equivalent : SDreftoindex
... | [
"def",
"reftoindex",
"(",
"self",
",",
"sds_ref",
")",
":",
"sds_idx",
"=",
"_C",
".",
"SDreftoindex",
"(",
"self",
".",
"_id",
",",
"sds_ref",
")",
"_checkErr",
"(",
"'reftoindex'",
",",
"sds_idx",
",",
"'illegal SDS ref number'",
")",
"return",
"sds_idx"
] | Returns the index number of a dataset given the dataset
reference number.
Args::
sds_ref : dataset reference number
Returns::
dataset index number
C library equivalent : SDreftoindex | [
"Returns",
"the",
"index",
"number",
"of",
"a",
"dataset",
"given",
"the",
"dataset",
"reference",
"number",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1517-L1534 |
fhs/pyhdf | pyhdf/SD.py | SD.setfillmode | def setfillmode(self, fill_mode):
"""Set the fill mode for all the datasets in the file.
Args::
fill_mode : fill mode; one of :
SDC.FILL write the fill value to all the datasets
of the file by default
SDC.NOF... | python | def setfillmode(self, fill_mode):
"""Set the fill mode for all the datasets in the file.
Args::
fill_mode : fill mode; one of :
SDC.FILL write the fill value to all the datasets
of the file by default
SDC.NOF... | [
"def",
"setfillmode",
"(",
"self",
",",
"fill_mode",
")",
":",
"if",
"not",
"fill_mode",
"in",
"[",
"SDC",
".",
"FILL",
",",
"SDC",
".",
"NOFILL",
"]",
":",
"raise",
"HDF4Error",
"(",
"\"bad fill mode\"",
")",
"old_mode",
"=",
"_C",
".",
"SDsetfillmode",... | Set the fill mode for all the datasets in the file.
Args::
fill_mode : fill mode; one of :
SDC.FILL write the fill value to all the datasets
of the file by default
SDC.NOFILL do not write fill values to all datasets
... | [
"Set",
"the",
"fill",
"mode",
"for",
"all",
"the",
"datasets",
"in",
"the",
"file",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1536-L1558 |
fhs/pyhdf | pyhdf/SD.py | SD.create | def create(self, name, data_type, dim_sizes):
"""Create a dataset.
Args::
name dataset name
data_type type of the data, set to one of the SDC.xxx
constants;
dim_sizes lengths of the dataset dimensions; a one-
... | python | def create(self, name, data_type, dim_sizes):
"""Create a dataset.
Args::
name dataset name
data_type type of the data, set to one of the SDC.xxx
constants;
dim_sizes lengths of the dataset dimensions; a one-
... | [
"def",
"create",
"(",
"self",
",",
"name",
",",
"data_type",
",",
"dim_sizes",
")",
":",
"# Validate args.",
"if",
"isinstance",
"(",
"dim_sizes",
",",
"type",
"(",
"1",
")",
")",
":",
"# allow k instead of [k]",
"# for a 1-dim arr",
"dim_sizes",
"=",
"[",
"... | Create a dataset.
Args::
name dataset name
data_type type of the data, set to one of the SDC.xxx
constants;
dim_sizes lengths of the dataset dimensions; a one-
dimensional array is specified with an integer,
... | [
"Create",
"a",
"dataset",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1560-L1601 |
fhs/pyhdf | pyhdf/SD.py | SD.select | def select(self, name_or_index):
"""Locate a dataset.
Args::
name_or_index dataset name or index number
Returns::
SDS instance for the dataset
C library equivalent : SDselect
"""
if isi... | python | def select(self, name_or_index):
"""Locate a dataset.
Args::
name_or_index dataset name or index number
Returns::
SDS instance for the dataset
C library equivalent : SDselect
"""
if isi... | [
"def",
"select",
"(",
"self",
",",
"name_or_index",
")",
":",
"if",
"isinstance",
"(",
"name_or_index",
",",
"type",
"(",
"1",
")",
")",
":",
"idx",
"=",
"name_or_index",
"else",
":",
"try",
":",
"idx",
"=",
"self",
".",
"nametoindex",
"(",
"name_or_in... | Locate a dataset.
Args::
name_or_index dataset name or index number
Returns::
SDS instance for the dataset
C library equivalent : SDselect | [
"Locate",
"a",
"dataset",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1603-L1626 |
fhs/pyhdf | pyhdf/SD.py | SD.attributes | def attributes(self, full=0):
"""Return a dictionnary describing every global
attribute attached to the SD interface.
Args::
full true to get complete info about each attribute
false to report only each attribute value
Returns::
Empty dict... | python | def attributes(self, full=0):
"""Return a dictionnary describing every global
attribute attached to the SD interface.
Args::
full true to get complete info about each attribute
false to report only each attribute value
Returns::
Empty dict... | [
"def",
"attributes",
"(",
"self",
",",
"full",
"=",
"0",
")",
":",
"# Get the number of global attributes.",
"nsds",
",",
"natts",
"=",
"self",
".",
"info",
"(",
")",
"# Inquire each attribute",
"res",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"natts"... | Return a dictionnary describing every global
attribute attached to the SD interface.
Args::
full true to get complete info about each attribute
false to report only each attribute value
Returns::
Empty dictionnary if no global attribute defined
... | [
"Return",
"a",
"dictionnary",
"describing",
"every",
"global",
"attribute",
"attached",
"to",
"the",
"SD",
"interface",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1651-L1689 |
fhs/pyhdf | pyhdf/SD.py | SD.datasets | def datasets(self):
"""Return a dictionnary describing all the file datasets.
Args::
no argument
Returns::
Empty dictionnary if no dataset is defined.
Otherwise, dictionnary whose keys are the file dataset names,
and values are tuples describing the co... | python | def datasets(self):
"""Return a dictionnary describing all the file datasets.
Args::
no argument
Returns::
Empty dictionnary if no dataset is defined.
Otherwise, dictionnary whose keys are the file dataset names,
and values are tuples describing the co... | [
"def",
"datasets",
"(",
"self",
")",
":",
"# Get number of datasets",
"nDs",
"=",
"self",
".",
"info",
"(",
")",
"[",
"0",
"]",
"# Inquire each var",
"res",
"=",
"{",
"}",
"for",
"n",
"in",
"range",
"(",
"nDs",
")",
":",
"# Get dataset info.",
"v",
"="... | Return a dictionnary describing all the file datasets.
Args::
no argument
Returns::
Empty dictionnary if no dataset is defined.
Otherwise, dictionnary whose keys are the file dataset names,
and values are tuples describing the corresponding datasets.
... | [
"Return",
"a",
"dictionnary",
"describing",
"all",
"the",
"file",
"datasets",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1691-L1736 |
fhs/pyhdf | pyhdf/SD.py | SDS.endaccess | def endaccess(self):
"""Terminates access to the SDS.
Args::
no argument
Returns::
None.
The SDS instance should not be used afterwards.
The 'endaccess()' method is implicitly called when
the SDS instance is deleted.
C library equivalent ... | python | def endaccess(self):
"""Terminates access to the SDS.
Args::
no argument
Returns::
None.
The SDS instance should not be used afterwards.
The 'endaccess()' method is implicitly called when
the SDS instance is deleted.
C library equivalent ... | [
"def",
"endaccess",
"(",
"self",
")",
":",
"status",
"=",
"_C",
".",
"SDendaccess",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'endaccess'",
",",
"status",
",",
"\"cannot execute\"",
")",
"self",
".",
"_id",
"=",
"None"
] | Terminates access to the SDS.
Args::
no argument
Returns::
None.
The SDS instance should not be used afterwards.
The 'endaccess()' method is implicitly called when
the SDS instance is deleted.
C library equivalent : SDendaccess | [
"Terminates",
"access",
"to",
"the",
"SDS",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1817-L1837 |
fhs/pyhdf | pyhdf/SD.py | SDS.dim | def dim(self, dim_index):
"""Get an SDim instance given a dimension index number.
Args::
dim_index index number of the dimension (numbering starts at 0)
C library equivalent : SDgetdimid
"""
id = _C.SDgetdimid(self._id, dim... | python | def dim(self, dim_index):
"""Get an SDim instance given a dimension index number.
Args::
dim_index index number of the dimension (numbering starts at 0)
C library equivalent : SDgetdimid
"""
id = _C.SDgetdimid(self._id, dim... | [
"def",
"dim",
"(",
"self",
",",
"dim_index",
")",
":",
"id",
"=",
"_C",
".",
"SDgetdimid",
"(",
"self",
".",
"_id",
",",
"dim_index",
")",
"_checkErr",
"(",
"'dim'",
",",
"id",
",",
"'invalid SDS identifier or dimension index'",
")",
"return",
"SDim",
"(",... | Get an SDim instance given a dimension index number.
Args::
dim_index index number of the dimension (numbering starts at 0)
C library equivalent : SDgetdimid | [
"Get",
"an",
"SDim",
"instance",
"given",
"a",
"dimension",
"index",
"number",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1840-L1851 |
fhs/pyhdf | pyhdf/SD.py | SDS.get | def get(self, start=None, count=None, stride=None):
"""Read data from the dataset.
Args::
start : indices where to start reading in the data array;
default to 0 on all dimensions
count : number of values to read along each dimension;
defa... | python | def get(self, start=None, count=None, stride=None):
"""Read data from the dataset.
Args::
start : indices where to start reading in the data array;
default to 0 on all dimensions
count : number of values to read along each dimension;
defa... | [
"def",
"get",
"(",
"self",
",",
"start",
"=",
"None",
",",
"count",
"=",
"None",
",",
"stride",
"=",
"None",
")",
":",
"# Obtain SDS info.",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"i... | Read data from the dataset.
Args::
start : indices where to start reading in the data array;
default to 0 on all dimensions
count : number of values to read along each dimension;
default to the current length of all dimensions
stride :... | [
"Read",
"data",
"from",
"the",
"dataset",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1853-L1920 |
fhs/pyhdf | pyhdf/SD.py | SDS.set | def set(self, data, start=None, count=None, stride=None):
"""Write data to the dataset.
Args::
data : array of data to write; can be given as a numpy
array, or as Python sequence (whose elements can be
imbricated sequences)
start : indic... | python | def set(self, data, start=None, count=None, stride=None):
"""Write data to the dataset.
Args::
data : array of data to write; can be given as a numpy
array, or as Python sequence (whose elements can be
imbricated sequences)
start : indic... | [
"def",
"set",
"(",
"self",
",",
"data",
",",
"start",
"=",
"None",
",",
"count",
"=",
"None",
",",
"stride",
"=",
"None",
")",
":",
"# Obtain SDS info.",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"s... | Write data to the dataset.
Args::
data : array of data to write; can be given as a numpy
array, or as Python sequence (whose elements can be
imbricated sequences)
start : indices where to start writing in the dataset;
default... | [
"Write",
"data",
"to",
"the",
"dataset",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L1922-L2001 |
fhs/pyhdf | pyhdf/SD.py | SDS.info | def info(self):
"""Retrieves information about the dataset.
Args::
no argument
Returns::
5-element tuple holding:
- dataset name
- dataset rank (number of dimensions)
- dataset shape, that is a list giving the length of each
data... | python | def info(self):
"""Retrieves information about the dataset.
Args::
no argument
Returns::
5-element tuple holding:
- dataset name
- dataset rank (number of dimensions)
- dataset shape, that is a list giving the length of each
data... | [
"def",
"info",
"(",
"self",
")",
":",
"buf",
"=",
"_C",
".",
"array_int32",
"(",
"_C",
".",
"H4_MAX_VAR_DIMS",
")",
"status",
",",
"sds_name",
",",
"rank",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDgetinfo",
"(",
"self",
".",
"_id",
",",
... | Retrieves information about the dataset.
Args::
no argument
Returns::
5-element tuple holding:
- dataset name
- dataset rank (number of dimensions)
- dataset shape, that is a list giving the length of each
dataset dimension; if the first... | [
"Retrieves",
"information",
"about",
"the",
"dataset",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2102-L2130 |
fhs/pyhdf | pyhdf/SD.py | SDS.checkempty | def checkempty(self):
"""Determine whether the dataset is empty.
Args::
no argument
Returns::
True(1) if dataset is empty, False(0) if not
C library equivalent : SDcheckempty
"""
status, emptySDS = _C.SDch... | python | def checkempty(self):
"""Determine whether the dataset is empty.
Args::
no argument
Returns::
True(1) if dataset is empty, False(0) if not
C library equivalent : SDcheckempty
"""
status, emptySDS = _C.SDch... | [
"def",
"checkempty",
"(",
"self",
")",
":",
"status",
",",
"emptySDS",
"=",
"_C",
".",
"SDcheckempty",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'checkempty'",
",",
"status",
",",
"'invalid SDS identifier'",
")",
"return",
"emptySDS"
] | Determine whether the dataset is empty.
Args::
no argument
Returns::
True(1) if dataset is empty, False(0) if not
C library equivalent : SDcheckempty | [
"Determine",
"whether",
"the",
"dataset",
"is",
"empty",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2132-L2148 |
fhs/pyhdf | pyhdf/SD.py | SDS.ref | def ref(self):
"""Get the reference number of the dataset.
Args::
no argument
Returns::
dataset reference number
C library equivalent : SDidtoref
"""
sds_ref = _C.SDidtoref(self._id)
_checkErr('idtore... | python | def ref(self):
"""Get the reference number of the dataset.
Args::
no argument
Returns::
dataset reference number
C library equivalent : SDidtoref
"""
sds_ref = _C.SDidtoref(self._id)
_checkErr('idtore... | [
"def",
"ref",
"(",
"self",
")",
":",
"sds_ref",
"=",
"_C",
".",
"SDidtoref",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'idtoref'",
",",
"sds_ref",
",",
"'illegal SDS identifier'",
")",
"return",
"sds_ref"
] | Get the reference number of the dataset.
Args::
no argument
Returns::
dataset reference number
C library equivalent : SDidtoref | [
"Get",
"the",
"reference",
"number",
"of",
"the",
"dataset",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2150-L2166 |
fhs/pyhdf | pyhdf/SD.py | SDS.getcal | def getcal(self):
"""Retrieve the SDS calibration coefficients.
Args::
no argument
Returns::
5-element tuple holding:
- cal: calibration factor (attribute 'scale_factor')
- cal_error : calibration factor error
(attribute 'scale... | python | def getcal(self):
"""Retrieve the SDS calibration coefficients.
Args::
no argument
Returns::
5-element tuple holding:
- cal: calibration factor (attribute 'scale_factor')
- cal_error : calibration factor error
(attribute 'scale... | [
"def",
"getcal",
"(",
"self",
")",
":",
"status",
",",
"cal",
",",
"cal_error",
",",
"offset",
",",
"offset_err",
",",
"data_type",
"=",
"_C",
".",
"SDgetcal",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'getcal'",
",",
"status",
",",
"'no calibra... | Retrieve the SDS calibration coefficients.
Args::
no argument
Returns::
5-element tuple holding:
- cal: calibration factor (attribute 'scale_factor')
- cal_error : calibration factor error
(attribute 'scale_factor_err')
- off... | [
"Retrieve",
"the",
"SDS",
"calibration",
"coefficients",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2206-L2246 |
fhs/pyhdf | pyhdf/SD.py | SDS.getdatastrs | def getdatastrs(self):
"""Retrieve the dataset standard string attributes.
Args::
no argument
Returns::
4-element tuple holding:
- dataset label string (attribute 'long_name')
- dataset unit (attribute 'units')
- dataset output format (attri... | python | def getdatastrs(self):
"""Retrieve the dataset standard string attributes.
Args::
no argument
Returns::
4-element tuple holding:
- dataset label string (attribute 'long_name')
- dataset unit (attribute 'units')
- dataset output format (attri... | [
"def",
"getdatastrs",
"(",
"self",
")",
":",
"status",
",",
"label",
",",
"unit",
",",
"format",
",",
"coord_system",
"=",
"_C",
".",
"SDgetdatastrs",
"(",
"self",
".",
"_id",
",",
"128",
")",
"_checkErr",
"(",
"'getdatastrs'",
",",
"status",
",",
"'ca... | Retrieve the dataset standard string attributes.
Args::
no argument
Returns::
4-element tuple holding:
- dataset label string (attribute 'long_name')
- dataset unit (attribute 'units')
- dataset output format (attribute 'format')
- dataset... | [
"Retrieve",
"the",
"dataset",
"standard",
"string",
"attributes",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2248-L2276 |
fhs/pyhdf | pyhdf/SD.py | SDS.getrange | def getrange(self):
"""Retrieve the dataset min and max values.
Args::
no argument
Returns::
(min, max) tuple (attribute 'valid_range')
Note that those are the values as stored
by the 'setrange' method. 'getrange' does *NOT* compute the
min ... | python | def getrange(self):
"""Retrieve the dataset min and max values.
Args::
no argument
Returns::
(min, max) tuple (attribute 'valid_range')
Note that those are the values as stored
by the 'setrange' method. 'getrange' does *NOT* compute the
min ... | [
"def",
"getrange",
"(",
"self",
")",
":",
"# Obtain SDS data type.",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF4Error",
"(",
"'getra... | Retrieve the dataset min and max values.
Args::
no argument
Returns::
(min, max) tuple (attribute 'valid_range')
Note that those are the values as stored
by the 'setrange' method. 'getrange' does *NOT* compute the
min and max from the current datase... | [
"Retrieve",
"the",
"dataset",
"min",
"and",
"max",
"values",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2344-L2426 |
fhs/pyhdf | pyhdf/SD.py | SDS.setcal | def setcal(self, cal, cal_error, offset, offset_err, data_type):
"""Set the dataset calibration coefficients.
Args::
cal the calibraton factor (attribute 'scale_factor')
cal_error calibration factor error
(attribute 'scale_factor_err')
offs... | python | def setcal(self, cal, cal_error, offset, offset_err, data_type):
"""Set the dataset calibration coefficients.
Args::
cal the calibraton factor (attribute 'scale_factor')
cal_error calibration factor error
(attribute 'scale_factor_err')
offs... | [
"def",
"setcal",
"(",
"self",
",",
"cal",
",",
"cal_error",
",",
"offset",
",",
"offset_err",
",",
"data_type",
")",
":",
"status",
"=",
"_C",
".",
"SDsetcal",
"(",
"self",
".",
"_id",
",",
"cal",
",",
"cal_error",
",",
"offset",
",",
"offset_err",
"... | Set the dataset calibration coefficients.
Args::
cal the calibraton factor (attribute 'scale_factor')
cal_error calibration factor error
(attribute 'scale_factor_err')
offset offset value (attribute 'add_offset')
offset_err offset e... | [
"Set",
"the",
"dataset",
"calibration",
"coefficients",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2428-L2463 |
fhs/pyhdf | pyhdf/SD.py | SDS.setdatastrs | def setdatastrs(self, label, unit, format, coord_sys):
"""Set the dataset standard string type attributes.
Args::
label dataset label (attribute 'long_name')
unit dataset unit (attribute 'units')
format dataset format (attribute 'format')
... | python | def setdatastrs(self, label, unit, format, coord_sys):
"""Set the dataset standard string type attributes.
Args::
label dataset label (attribute 'long_name')
unit dataset unit (attribute 'units')
format dataset format (attribute 'format')
... | [
"def",
"setdatastrs",
"(",
"self",
",",
"label",
",",
"unit",
",",
"format",
",",
"coord_sys",
")",
":",
"status",
"=",
"_C",
".",
"SDsetdatastrs",
"(",
"self",
".",
"_id",
",",
"label",
",",
"unit",
",",
"format",
",",
"coord_sys",
")",
"_checkErr",
... | Set the dataset standard string type attributes.
Args::
label dataset label (attribute 'long_name')
unit dataset unit (attribute 'units')
format dataset format (attribute 'format')
coord_sys dataset coordinate system (attribute 'coordsys')
... | [
"Set",
"the",
"dataset",
"standard",
"string",
"type",
"attributes",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2465-L2490 |
fhs/pyhdf | pyhdf/SD.py | SDS.setfillvalue | def setfillvalue(self, fill_val):
"""Set the dataset fill value.
Args::
fill_val dataset fill value (attribute '_FillValue')
Returns::
None
The fill value is part of the so-called "standard" SDS
attributes. Calling 'setfillvalue' is equivalent to settin... | python | def setfillvalue(self, fill_val):
"""Set the dataset fill value.
Args::
fill_val dataset fill value (attribute '_FillValue')
Returns::
None
The fill value is part of the so-called "standard" SDS
attributes. Calling 'setfillvalue' is equivalent to settin... | [
"def",
"setfillvalue",
"(",
"self",
",",
"fill_val",
")",
":",
"# Obtain SDS data type.",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"except",
"HDF4Error",
":",
"raise",
"HDF... | Set the dataset fill value.
Args::
fill_val dataset fill value (attribute '_FillValue')
Returns::
None
The fill value is part of the so-called "standard" SDS
attributes. Calling 'setfillvalue' is equivalent to setting
the following attribute::
... | [
"Set",
"the",
"dataset",
"fill",
"value",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2492-L2552 |
fhs/pyhdf | pyhdf/SD.py | SDS.setrange | def setrange(self, min, max):
"""Set the dataset min and max values.
Args::
min dataset minimum value (attribute 'valid_range')
max dataset maximum value (attribute 'valid_range')
Returns::
None
The data range is part of the so-called "st... | python | def setrange(self, min, max):
"""Set the dataset min and max values.
Args::
min dataset minimum value (attribute 'valid_range')
max dataset maximum value (attribute 'valid_range')
Returns::
None
The data range is part of the so-called "st... | [
"def",
"setrange",
"(",
"self",
",",
"min",
",",
"max",
")",
":",
"# Obtain SDS data type.",
"try",
":",
"sds_name",
",",
"rank",
",",
"dim_sizes",
",",
"data_type",
",",
"n_attrs",
"=",
"self",
".",
"info",
"(",
")",
"except",
"HDF4Error",
":",
"raise",... | Set the dataset min and max values.
Args::
min dataset minimum value (attribute 'valid_range')
max dataset maximum value (attribute 'valid_range')
Returns::
None
The data range is part of the so-called "standard" SDS
attributes. Calling m... | [
"Set",
"the",
"dataset",
"min",
"and",
"max",
"values",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2555-L2629 |
fhs/pyhdf | pyhdf/SD.py | SDS.getcompress | def getcompress(self):
"""Retrieves info about dataset compression type and mode.
Args::
no argument
Returns::
tuple holding:
- compression type (one of the SDC.COMP_xxx constants)
- optional values, depending on the compression type
COM... | python | def getcompress(self):
"""Retrieves info about dataset compression type and mode.
Args::
no argument
Returns::
tuple holding:
- compression type (one of the SDC.COMP_xxx constants)
- optional values, depending on the compression type
COM... | [
"def",
"getcompress",
"(",
"self",
")",
":",
"status",
",",
"comp_type",
",",
"value",
",",
"v2",
",",
"v3",
",",
"v4",
",",
"v5",
"=",
"_C",
".",
"_SDgetcompress",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'getcompress'",
",",
"status",
",",
... | Retrieves info about dataset compression type and mode.
Args::
no argument
Returns::
tuple holding:
- compression type (one of the SDC.COMP_xxx constants)
- optional values, depending on the compression type
COMP_NONE 0 value no additio... | [
"Retrieves",
"info",
"about",
"dataset",
"compression",
"type",
"and",
"mode",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2631-L2677 |
fhs/pyhdf | pyhdf/SD.py | SDS.setcompress | def setcompress(self, comp_type, value=0, v2=0):
"""Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression t... | python | def setcompress(self, comp_type, value=0, v2=0):
"""Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression t... | [
"def",
"setcompress",
"(",
"self",
",",
"comp_type",
",",
"value",
"=",
"0",
",",
"v2",
"=",
"0",
")",
":",
"status",
"=",
"_C",
".",
"_SDsetcompress",
"(",
"self",
".",
"_id",
",",
"comp_type",
",",
"value",
",",
"v2",
")",
"_checkErr",
"(",
"'set... | Compresses the dataset using a specified compression method.
Args::
comp_type compression type, identified by one of the
SDC.COMP_xxx constants
value,v2 auxiliary value(s) needed by some compression types
SDC.COMP_SKPHUFF Skipping-Hu... | [
"Compresses",
"the",
"dataset",
"using",
"a",
"specified",
"compression",
"method",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2679-L2718 |
fhs/pyhdf | pyhdf/SD.py | SDS.setexternalfile | def setexternalfile(self, filename, offset=0):
"""Store the dataset data in an external file.
Args::
filename external file name
offset offset in bytes where to start writing in
the external file
Returns::
None
C library ... | python | def setexternalfile(self, filename, offset=0):
"""Store the dataset data in an external file.
Args::
filename external file name
offset offset in bytes where to start writing in
the external file
Returns::
None
C library ... | [
"def",
"setexternalfile",
"(",
"self",
",",
"filename",
",",
"offset",
"=",
"0",
")",
":",
"status",
"=",
"_C",
".",
"SDsetexternalfile",
"(",
"self",
".",
"_id",
",",
"filename",
",",
"offset",
")",
"_checkErr",
"(",
"'setexternalfile'",
",",
"status",
... | Store the dataset data in an external file.
Args::
filename external file name
offset offset in bytes where to start writing in
the external file
Returns::
None
C library equivalent : SDsetexternalfile | [
"Store",
"the",
"dataset",
"data",
"in",
"an",
"external",
"file",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2721-L2738 |
fhs/pyhdf | pyhdf/SD.py | SDS.dimensions | def dimensions(self, full=0):
"""Return a dictionnary describing every dataset dimension.
Args::
full true to get complete info about each dimension
false to report only each dimension length
Returns::
Dictionnary where each key is a dimension nam... | python | def dimensions(self, full=0):
"""Return a dictionnary describing every dataset dimension.
Args::
full true to get complete info about each dimension
false to report only each dimension length
Returns::
Dictionnary where each key is a dimension nam... | [
"def",
"dimensions",
"(",
"self",
",",
"full",
"=",
"0",
")",
":",
"# Get the number of dimensions and their lengths.",
"nDims",
",",
"dimLen",
"=",
"self",
".",
"info",
"(",
")",
"[",
"1",
":",
"3",
"]",
"if",
"isinstance",
"(",
"dimLen",
",",
"int",
")... | Return a dictionnary describing every dataset dimension.
Args::
full true to get complete info about each dimension
false to report only each dimension length
Returns::
Dictionnary where each key is a dimension name. If no name
has been given to... | [
"Return",
"a",
"dictionnary",
"describing",
"every",
"dataset",
"dimension",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2800-L2849 |
fhs/pyhdf | pyhdf/SD.py | SDim.info | def info(self):
"""Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
... | python | def info(self):
"""Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
... | [
"def",
"info",
"(",
"self",
")",
":",
"status",
",",
"dim_name",
",",
"dim_size",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDdiminfo",
"(",
"self",
".",
"_id",
")",
"_checkErr",
"(",
"'info'",
",",
"status",
",",
"'cannot execute'",
")",
"ret... | Return info about the dimension instance.
Args::
no argument
Returns::
4-element tuple holding:
- dimension name; 'fakeDimx' is returned if the dimension
has not been named yet, where 'x' is the dimension
index number
- dimension lengt... | [
"Return",
"info",
"about",
"the",
"dimension",
"instance",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2892-L2918 |
fhs/pyhdf | pyhdf/SD.py | SDim.setname | def setname(self, dim_name):
"""Set the dimension name.
Args::
dim_name dimension name; setting 2 dimensions to the same
name make the dimensions "shared"; in order to be
shared, the dimesions must be deined similarly.
Returns::
... | python | def setname(self, dim_name):
"""Set the dimension name.
Args::
dim_name dimension name; setting 2 dimensions to the same
name make the dimensions "shared"; in order to be
shared, the dimesions must be deined similarly.
Returns::
... | [
"def",
"setname",
"(",
"self",
",",
"dim_name",
")",
":",
"status",
"=",
"_C",
".",
"SDsetdimname",
"(",
"self",
".",
"_id",
",",
"dim_name",
")",
"_checkErr",
"(",
"'setname'",
",",
"status",
",",
"'cannot execute'",
")"
] | Set the dimension name.
Args::
dim_name dimension name; setting 2 dimensions to the same
name make the dimensions "shared"; in order to be
shared, the dimesions must be deined similarly.
Returns::
None
C library equivalent :... | [
"Set",
"the",
"dimension",
"name",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2939-L2956 |
fhs/pyhdf | pyhdf/SD.py | SDim.getscale | def getscale(self):
"""Obtain the scale values along a dimension.
Args::
no argument
Returns::
list with the scale values; the list length is equal to the
dimension length; the element type is equal to the dimension
data type, as set when the 'setdimsc... | python | def getscale(self):
"""Obtain the scale values along a dimension.
Args::
no argument
Returns::
list with the scale values; the list length is equal to the
dimension length; the element type is equal to the dimension
data type, as set when the 'setdimsc... | [
"def",
"getscale",
"(",
"self",
")",
":",
"# Get dimension info. If data_type is 0, no scale have been set",
"# on the dimension.",
"status",
",",
"dim_name",
",",
"dim_size",
",",
"data_type",
",",
"n_attrs",
"=",
"_C",
".",
"SDdiminfo",
"(",
"self",
".",
"_id",
")... | Obtain the scale values along a dimension.
Args::
no argument
Returns::
list with the scale values; the list length is equal to the
dimension length; the element type is equal to the dimension
data type, as set when the 'setdimscale()' method was called.
... | [
"Obtain",
"the",
"scale",
"values",
"along",
"a",
"dimension",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L2959-L3018 |
fhs/pyhdf | pyhdf/SD.py | SDim.setscale | def setscale(self, data_type, scale):
"""Initialize the scale values along the dimension.
Args::
data_type data type code (one of the SDC.xxx constants)
scale sequence holding the scale values; the number of
values must match the current length of t... | python | def setscale(self, data_type, scale):
"""Initialize the scale values along the dimension.
Args::
data_type data type code (one of the SDC.xxx constants)
scale sequence holding the scale values; the number of
values must match the current length of t... | [
"def",
"setscale",
"(",
"self",
",",
"data_type",
",",
"scale",
")",
":",
"try",
":",
"n_values",
"=",
"len",
"(",
"scale",
")",
"except",
":",
"n_values",
"=",
"1",
"# Validate args",
"info",
"=",
"self",
".",
"_sds",
".",
"info",
"(",
")",
"if",
... | Initialize the scale values along the dimension.
Args::
data_type data type code (one of the SDC.xxx constants)
scale sequence holding the scale values; the number of
values must match the current length of the dataset
along that dime... | [
"Initialize",
"the",
"scale",
"values",
"along",
"the",
"dimension",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L3020-L3098 |
fhs/pyhdf | pyhdf/SD.py | SDim.getstrs | def getstrs(self):
"""Retrieve the dimension standard string attributes.
Args::
no argument
Returns::
3-element tuple holding:
-dimension label (attribute 'long_name')
-dimension unit (attribute 'units')
-dimension format (attribute ... | python | def getstrs(self):
"""Retrieve the dimension standard string attributes.
Args::
no argument
Returns::
3-element tuple holding:
-dimension label (attribute 'long_name')
-dimension unit (attribute 'units')
-dimension format (attribute ... | [
"def",
"getstrs",
"(",
"self",
")",
":",
"status",
",",
"label",
",",
"unit",
",",
"format",
"=",
"_C",
".",
"SDgetdimstrs",
"(",
"self",
".",
"_id",
",",
"128",
")",
"_checkErr",
"(",
"'getstrs'",
",",
"status",
",",
"'cannot execute'",
")",
"return",... | Retrieve the dimension standard string attributes.
Args::
no argument
Returns::
3-element tuple holding:
-dimension label (attribute 'long_name')
-dimension unit (attribute 'units')
-dimension format (attribute 'format')
An exceptio... | [
"Retrieve",
"the",
"dimension",
"standard",
"string",
"attributes",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L3100-L3122 |
fhs/pyhdf | pyhdf/SD.py | SDim.setstrs | def setstrs(self, label, unit, format):
"""Set the dimension standard string attributes.
Args::
label dimension label (attribute 'long_name')
unit dimension unit (attribute 'units')
format dimension format (attribute 'format')
Returns::
None
... | python | def setstrs(self, label, unit, format):
"""Set the dimension standard string attributes.
Args::
label dimension label (attribute 'long_name')
unit dimension unit (attribute 'units')
format dimension format (attribute 'format')
Returns::
None
... | [
"def",
"setstrs",
"(",
"self",
",",
"label",
",",
"unit",
",",
"format",
")",
":",
"status",
"=",
"_C",
".",
"SDsetdimstrs",
"(",
"self",
".",
"_id",
",",
"label",
",",
"unit",
",",
"format",
")",
"_checkErr",
"(",
"'setstrs'",
",",
"status",
",",
... | Set the dimension standard string attributes.
Args::
label dimension label (attribute 'long_name')
unit dimension unit (attribute 'units')
format dimension format (attribute 'format')
Returns::
None
C library equivalent: SDsetdimstrs | [
"Set",
"the",
"dimension",
"standard",
"string",
"attributes",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/SD.py#L3124-L3141 |
fhs/pyhdf | pyhdf/VS.py | VS.attach | def attach(self, num_name, write=0):
"""Locate an existing vdata or create a new vdata in the HDF file,
returning a VD instance.
Args::
num_name Name or reference number of the vdata. An existing vdata
can be specified either through its reference number or
... | python | def attach(self, num_name, write=0):
"""Locate an existing vdata or create a new vdata in the HDF file,
returning a VD instance.
Args::
num_name Name or reference number of the vdata. An existing vdata
can be specified either through its reference number or
... | [
"def",
"attach",
"(",
"self",
",",
"num_name",
",",
"write",
"=",
"0",
")",
":",
"mode",
"=",
"write",
"and",
"'w'",
"or",
"'r'",
"if",
"isinstance",
"(",
"num_name",
",",
"str",
")",
":",
"num",
"=",
"self",
".",
"find",
"(",
"num_name",
")",
"e... | Locate an existing vdata or create a new vdata in the HDF file,
returning a VD instance.
Args::
num_name Name or reference number of the vdata. An existing vdata
can be specified either through its reference number or
its name. Use -1 to create a new ... | [
"Locate",
"an",
"existing",
"vdata",
"or",
"create",
"a",
"new",
"vdata",
"in",
"the",
"HDF",
"file",
"returning",
"a",
"VD",
"instance",
"."
] | train | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/VS.py#L872-L911 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.