partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Experience.episode_info | Search for the episode with the requested experience Id
:return: | src/streamlink/plugins/funimationnow.py | def episode_info(self):
"""
Search for the episode with the requested experience Id
:return:
"""
if self.show_info:
for season in self.show_info["seasons"]:
for episode in season["episodes"]:
for lang in episode["languages"].values(... | def episode_info(self):
"""
Search for the episode with the requested experience Id
:return:
"""
if self.show_info:
for season in self.show_info["seasons"]:
for episode in season["episodes"]:
for lang in episode["languages"].values(... | [
"Search",
"for",
"the",
"episode",
"with",
"the",
"requested",
"experience",
"Id",
":",
"return",
":"
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/funimationnow.py#L87-L98 | [
"def",
"episode_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"show_info",
":",
"for",
"season",
"in",
"self",
".",
"show_info",
"[",
"\"seasons\"",
"]",
":",
"for",
"episode",
"in",
"season",
"[",
"\"episodes\"",
"]",
":",
"for",
"lang",
"in",
"epi... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | Experience.sources | Get the sources for a given experience_id, which is tied to a specific language
:param experience_id: int; video content id
:return: sources dict | src/streamlink/plugins/funimationnow.py | def sources(self):
"""
Get the sources for a given experience_id, which is tied to a specific language
:param experience_id: int; video content id
:return: sources dict
"""
api_url = self.sources_api_url.format(experience_id=self.experience_id)
res = self.get(api_... | def sources(self):
"""
Get the sources for a given experience_id, which is tied to a specific language
:param experience_id: int; video content id
:return: sources dict
"""
api_url = self.sources_api_url.format(experience_id=self.experience_id)
res = self.get(api_... | [
"Get",
"the",
"sources",
"for",
"a",
"given",
"experience_id",
"which",
"is",
"tied",
"to",
"a",
"specific",
"language",
":",
"param",
"experience_id",
":",
"int",
";",
"video",
"content",
"id",
":",
"return",
":",
"sources",
"dict"
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/funimationnow.py#L127-L135 | [
"def",
"sources",
"(",
"self",
")",
":",
"api_url",
"=",
"self",
".",
"sources_api_url",
".",
"format",
"(",
"experience_id",
"=",
"self",
".",
"experience_id",
")",
"res",
"=",
"self",
".",
"get",
"(",
"api_url",
",",
"params",
"=",
"{",
"\"pinst_id\"",... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | SteamBroadcastPlugin.encrypt_password | Get the RSA key for the user and encrypt the users password
:param email: steam account
:param password: password for account
:return: encrypted password | src/streamlink/plugins/steam.py | def encrypt_password(self, email, password):
"""
Get the RSA key for the user and encrypt the users password
:param email: steam account
:param password: password for account
:return: encrypted password
"""
res = self.session.http.get(self._get_rsa_key_url, params... | def encrypt_password(self, email, password):
"""
Get the RSA key for the user and encrypt the users password
:param email: steam account
:param password: password for account
:return: encrypted password
"""
res = self.session.http.get(self._get_rsa_key_url, params... | [
"Get",
"the",
"RSA",
"key",
"for",
"the",
"user",
"and",
"encrypt",
"the",
"users",
"password",
":",
"param",
"email",
":",
"steam",
"account",
":",
"param",
"password",
":",
"password",
"for",
"account",
":",
"return",
":",
"encrypted",
"password"
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/steam.py#L90-L102 | [
"def",
"encrypt_password",
"(",
"self",
",",
"email",
",",
"password",
")",
":",
"res",
"=",
"self",
".",
"session",
".",
"http",
".",
"get",
"(",
"self",
".",
"_get_rsa_key_url",
",",
"params",
"=",
"dict",
"(",
"username",
"=",
"email",
",",
"donotca... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | SteamBroadcastPlugin.dologin | Logs in to Steam | src/streamlink/plugins/steam.py | def dologin(self, email, password, emailauth="", emailsteamid="", captchagid="-1", captcha_text="", twofactorcode=""):
"""
Logs in to Steam
"""
epassword, rsatimestamp = self.encrypt_password(email, password)
login_data = {
'username': email,
"password":... | def dologin(self, email, password, emailauth="", emailsteamid="", captchagid="-1", captcha_text="", twofactorcode=""):
"""
Logs in to Steam
"""
epassword, rsatimestamp = self.encrypt_password(email, password)
login_data = {
'username': email,
"password":... | [
"Logs",
"in",
"to",
"Steam"
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/steam.py#L104-L176 | [
"def",
"dologin",
"(",
"self",
",",
"email",
",",
"password",
",",
"emailauth",
"=",
"\"\"",
",",
"emailsteamid",
"=",
"\"\"",
",",
"captchagid",
"=",
"\"-1\"",
",",
"captcha_text",
"=",
"\"\"",
",",
"twofactorcode",
"=",
"\"\"",
")",
":",
"epassword",
"... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | Huomao.get_stream_id | Returns the stream_id contained in the HTML. | src/streamlink/plugins/huomao.py | def get_stream_id(self, html):
"""Returns the stream_id contained in the HTML."""
stream_id = stream_id_pattern.search(html)
if not stream_id:
self.logger.error("Failed to extract stream_id.")
return stream_id.group("stream_id") | def get_stream_id(self, html):
"""Returns the stream_id contained in the HTML."""
stream_id = stream_id_pattern.search(html)
if not stream_id:
self.logger.error("Failed to extract stream_id.")
return stream_id.group("stream_id") | [
"Returns",
"the",
"stream_id",
"contained",
"in",
"the",
"HTML",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/huomao.py#L55-L62 | [
"def",
"get_stream_id",
"(",
"self",
",",
"html",
")",
":",
"stream_id",
"=",
"stream_id_pattern",
".",
"search",
"(",
"html",
")",
"if",
"not",
"stream_id",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Failed to extract stream_id.\"",
")",
"return",
"s... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | Huomao.get_stream_info | Returns a nested list of different stream options.
Each entry in the list will contain a stream_url and stream_quality_name
for each stream occurrence that was found in the JS. | src/streamlink/plugins/huomao.py | def get_stream_info(self, html):
"""
Returns a nested list of different stream options.
Each entry in the list will contain a stream_url and stream_quality_name
for each stream occurrence that was found in the JS.
"""
stream_info = stream_info_pattern.findall(html)
... | def get_stream_info(self, html):
"""
Returns a nested list of different stream options.
Each entry in the list will contain a stream_url and stream_quality_name
for each stream occurrence that was found in the JS.
"""
stream_info = stream_info_pattern.findall(html)
... | [
"Returns",
"a",
"nested",
"list",
"of",
"different",
"stream",
"options",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/huomao.py#L64-L85 | [
"def",
"get_stream_info",
"(",
"self",
",",
"html",
")",
":",
"stream_info",
"=",
"stream_info_pattern",
".",
"findall",
"(",
"html",
")",
"if",
"not",
"stream_info",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"Failed to extract stream_info.\"",
")",
"# ... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | ABweb._login | login and update cached cookies | src/streamlink/plugins/abweb.py | def _login(self, username, password):
'''login and update cached cookies'''
self.logger.debug('login ...')
res = self.session.http.get(self.login_url)
input_list = self._input_re.findall(res.text)
if not input_list:
raise PluginError('Missing input data on login webs... | def _login(self, username, password):
'''login and update cached cookies'''
self.logger.debug('login ...')
res = self.session.http.get(self.login_url)
input_list = self._input_re.findall(res.text)
if not input_list:
raise PluginError('Missing input data on login webs... | [
"login",
"and",
"update",
"cached",
"cookies"
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/abweb.py#L93-L135 | [
"def",
"_login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'login ...'",
")",
"res",
"=",
"self",
".",
"session",
".",
"http",
".",
"get",
"(",
"self",
".",
"login_url",
")",
"input_list",
"="... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | StreamMapper.map | Creates a key-function mapping.
The return value from the function should be either
- A tuple containing a name and stream
- A iterator of tuples containing a name and stream
Any extra arguments will be passed to the function. | src/streamlink/plugin/api/mapper.py | def map(self, key, func, *args, **kwargs):
"""Creates a key-function mapping.
The return value from the function should be either
- A tuple containing a name and stream
- A iterator of tuples containing a name and stream
Any extra arguments will be passed to the function.
... | def map(self, key, func, *args, **kwargs):
"""Creates a key-function mapping.
The return value from the function should be either
- A tuple containing a name and stream
- A iterator of tuples containing a name and stream
Any extra arguments will be passed to the function.
... | [
"Creates",
"a",
"key",
"-",
"function",
"mapping",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugin/api/mapper.py#L18-L27 | [
"def",
"map",
"(",
"self",
",",
"key",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_map",
".",
"append",
"(",
"(",
"key",
",",
"partial",
"(",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
")",
... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | parse_timestamp | Takes ISO 8601 format(string) and converts into a utc datetime(naive) | src/streamlink/plugins/crunchyroll.py | def parse_timestamp(ts):
"""Takes ISO 8601 format(string) and converts into a utc datetime(naive)"""
return (
datetime.datetime.strptime(ts[:-7], "%Y-%m-%dT%H:%M:%S") +
datetime.timedelta(hours=int(ts[-5:-3]), minutes=int(ts[-2:])) *
int(ts[-6:-5] + "1")
) | def parse_timestamp(ts):
"""Takes ISO 8601 format(string) and converts into a utc datetime(naive)"""
return (
datetime.datetime.strptime(ts[:-7], "%Y-%m-%dT%H:%M:%S") +
datetime.timedelta(hours=int(ts[-5:-3]), minutes=int(ts[-2:])) *
int(ts[-6:-5] + "1")
) | [
"Takes",
"ISO",
"8601",
"format",
"(",
"string",
")",
"and",
"converts",
"into",
"a",
"utc",
"datetime",
"(",
"naive",
")"
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/crunchyroll.py#L27-L33 | [
"def",
"parse_timestamp",
"(",
"ts",
")",
":",
"return",
"(",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"ts",
"[",
":",
"-",
"7",
"]",
",",
"\"%Y-%m-%dT%H:%M:%S\"",
")",
"+",
"datetime",
".",
"timedelta",
"(",
"hours",
"=",
"int",
"(",
"ts",
... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | CrunchyrollAPI._api_call | Makes a call against the api.
:param entrypoint: API method to call.
:param params: parameters to include in the request data.
:param schema: schema to use to validate the data | src/streamlink/plugins/crunchyroll.py | def _api_call(self, entrypoint, params=None, schema=None):
"""Makes a call against the api.
:param entrypoint: API method to call.
:param params: parameters to include in the request data.
:param schema: schema to use to validate the data
"""
url = self._api_url.format(e... | def _api_call(self, entrypoint, params=None, schema=None):
"""Makes a call against the api.
:param entrypoint: API method to call.
:param params: parameters to include in the request data.
:param schema: schema to use to validate the data
"""
url = self._api_url.format(e... | [
"Makes",
"a",
"call",
"against",
"the",
"api",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/crunchyroll.py#L137-L179 | [
"def",
"_api_call",
"(",
"self",
",",
"entrypoint",
",",
"params",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"url",
"=",
"self",
".",
"_api_url",
".",
"format",
"(",
"entrypoint",
")",
"# Default params",
"params",
"=",
"params",
"or",
"{",
"}... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | CrunchyrollAPI.start_session | Starts a session against Crunchyroll's server.
Is recommended that you call this method before making any other calls
to make sure you have a valid session against the server. | src/streamlink/plugins/crunchyroll.py | def start_session(self):
"""
Starts a session against Crunchyroll's server.
Is recommended that you call this method before making any other calls
to make sure you have a valid session against the server.
"""
params = {}
if self.auth:
param... | def start_session(self):
"""
Starts a session against Crunchyroll's server.
Is recommended that you call this method before making any other calls
to make sure you have a valid session against the server.
"""
params = {}
if self.auth:
param... | [
"Starts",
"a",
"session",
"against",
"Crunchyroll",
"s",
"server",
".",
"Is",
"recommended",
"that",
"you",
"call",
"this",
"method",
"before",
"making",
"any",
"other",
"calls",
"to",
"make",
"sure",
"you",
"have",
"a",
"valid",
"session",
"against",
"the",... | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/crunchyroll.py#L188-L199 | [
"def",
"start_session",
"(",
"self",
")",
":",
"params",
"=",
"{",
"}",
"if",
"self",
".",
"auth",
":",
"params",
"[",
"\"auth\"",
"]",
"=",
"self",
".",
"auth",
"self",
".",
"session_id",
"=",
"self",
".",
"_api_call",
"(",
"\"start_session\"",
",",
... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | CrunchyrollAPI.login | Authenticates the session to be able to access restricted data from
the server (e.g. premium restricted videos). | src/streamlink/plugins/crunchyroll.py | def login(self, username, password):
"""
Authenticates the session to be able to access restricted data from
the server (e.g. premium restricted videos).
"""
params = {
"account": username,
"password": password
}
login = self._api_... | def login(self, username, password):
"""
Authenticates the session to be able to access restricted data from
the server (e.g. premium restricted videos).
"""
params = {
"account": username,
"password": password
}
login = self._api_... | [
"Authenticates",
"the",
"session",
"to",
"be",
"able",
"to",
"access",
"restricted",
"data",
"from",
"the",
"server",
"(",
"e",
".",
"g",
".",
"premium",
"restricted",
"videos",
")",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/crunchyroll.py#L201-L214 | [
"def",
"login",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"params",
"=",
"{",
"\"account\"",
":",
"username",
",",
"\"password\"",
":",
"password",
"}",
"login",
"=",
"self",
".",
"_api_call",
"(",
"\"login\"",
",",
"params",
",",
"schema"... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | CrunchyrollAPI.get_info | Returns the data for a certain media item.
:param media_id: id that identifies the media item to be accessed.
:param fields: list of the media"s field to be returned. By default the
API returns some fields, but others are not returned unless they are
explicity asked for.... | src/streamlink/plugins/crunchyroll.py | def get_info(self, media_id, fields=None, schema=None):
"""
Returns the data for a certain media item.
:param media_id: id that identifies the media item to be accessed.
:param fields: list of the media"s field to be returned. By default the
API returns some fiel... | def get_info(self, media_id, fields=None, schema=None):
"""
Returns the data for a certain media item.
:param media_id: id that identifies the media item to be accessed.
:param fields: list of the media"s field to be returned. By default the
API returns some fiel... | [
"Returns",
"the",
"data",
"for",
"a",
"certain",
"media",
"item",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/crunchyroll.py#L222-L239 | [
"def",
"get_info",
"(",
"self",
",",
"media_id",
",",
"fields",
"=",
"None",
",",
"schema",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"media_id\"",
":",
"media_id",
"}",
"if",
"fields",
":",
"params",
"[",
"\"fields\"",
"]",
"=",
"\",\"",
".",
"jo... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | Crunchyroll._create_api | Creates a new CrunchyrollAPI object, initiates it's session and
tries to authenticate it either by using saved credentials or the
user's username and password. | src/streamlink/plugins/crunchyroll.py | def _create_api(self):
"""Creates a new CrunchyrollAPI object, initiates it's session and
tries to authenticate it either by using saved credentials or the
user's username and password.
"""
if self.options.get("purge_credentials"):
self.cache.set("session_id", None, 0... | def _create_api(self):
"""Creates a new CrunchyrollAPI object, initiates it's session and
tries to authenticate it either by using saved credentials or the
user's username and password.
"""
if self.options.get("purge_credentials"):
self.cache.set("session_id", None, 0... | [
"Creates",
"a",
"new",
"CrunchyrollAPI",
"object",
"initiates",
"it",
"s",
"session",
"and",
"tries",
"to",
"authenticate",
"it",
"either",
"by",
"using",
"saved",
"credentials",
"or",
"the",
"user",
"s",
"username",
"and",
"password",
"."
] | streamlink/streamlink | python | https://github.com/streamlink/streamlink/blob/c8ed1daff14ac03195870238b9b900c1109dd5c1/src/streamlink/plugins/crunchyroll.py#L346-L389 | [
"def",
"_create_api",
"(",
"self",
")",
":",
"if",
"self",
".",
"options",
".",
"get",
"(",
"\"purge_credentials\"",
")",
":",
"self",
".",
"cache",
".",
"set",
"(",
"\"session_id\"",
",",
"None",
",",
"0",
")",
"self",
".",
"cache",
".",
"set",
"(",... | c8ed1daff14ac03195870238b9b900c1109dd5c1 |
test | compress | Compress a byte string.
Args:
string (bytes): The input data.
mode (int, optional): The compression mode can be MODE_GENERIC (default),
MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0).
quality (int, optional): Controls the compression-speed vs compression-
dens... | python/brotli.py | def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0):
"""Compress a byte string.
Args:
string (bytes): The input data.
mode (int, optional): The compression mode can be MODE_GENERIC (default),
MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0).
qua... | def compress(string, mode=MODE_GENERIC, quality=11, lgwin=22, lgblock=0):
"""Compress a byte string.
Args:
string (bytes): The input data.
mode (int, optional): The compression mode can be MODE_GENERIC (default),
MODE_TEXT (for UTF-8 format text input) or MODE_FONT (for WOFF 2.0).
qua... | [
"Compress",
"a",
"byte",
"string",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/python/brotli.py#L26-L50 | [
"def",
"compress",
"(",
"string",
",",
"mode",
"=",
"MODE_GENERIC",
",",
"quality",
"=",
"11",
",",
"lgwin",
"=",
"22",
",",
"lgblock",
"=",
"0",
")",
":",
"compressor",
"=",
"Compressor",
"(",
"mode",
"=",
"mode",
",",
"quality",
"=",
"quality",
","... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | get_binary_stdio | Return the specified standard input, output or errors stream as a
'raw' buffer object suitable for reading/writing binary data from/to it. | python/bro.py | def get_binary_stdio(stream):
""" Return the specified standard input, output or errors stream as a
'raw' buffer object suitable for reading/writing binary data from/to it.
"""
assert stream in ['stdin', 'stdout', 'stderr'], 'invalid stream name'
stdio = getattr(sys, stream)
if sys.version_info[... | def get_binary_stdio(stream):
""" Return the specified standard input, output or errors stream as a
'raw' buffer object suitable for reading/writing binary data from/to it.
"""
assert stream in ['stdin', 'stdout', 'stderr'], 'invalid stream name'
stdio = getattr(sys, stream)
if sys.version_info[... | [
"Return",
"the",
"specified",
"standard",
"input",
"output",
"or",
"errors",
"stream",
"as",
"a",
"raw",
"buffer",
"object",
"suitable",
"for",
"reading",
"/",
"writing",
"binary",
"data",
"from",
"/",
"to",
"it",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/python/bro.py#L21-L46 | [
"def",
"get_binary_stdio",
"(",
"stream",
")",
":",
"assert",
"stream",
"in",
"[",
"'stdin'",
",",
"'stdout'",
",",
"'stderr'",
"]",
",",
"'invalid stream name'",
"stdio",
"=",
"getattr",
"(",
"sys",
",",
"stream",
")",
"if",
"sys",
".",
"version_info",
"[... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | outputCharFormatter | Show character in readable format | research/brotlidump.py | def outputCharFormatter(c):
"""Show character in readable format
"""
#TODO 2: allow hex only output
if 32<c<127: return chr(c)
elif c==10: return '\\n'
elif c==13: return '\\r'
elif c==32: return '" "'
else: return '\\x{:02x}'.format(c) | def outputCharFormatter(c):
"""Show character in readable format
"""
#TODO 2: allow hex only output
if 32<c<127: return chr(c)
elif c==10: return '\\n'
elif c==13: return '\\r'
elif c==32: return '" "'
else: return '\\x{:02x}'.format(c) | [
"Show",
"character",
"in",
"readable",
"format"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L22-L30 | [
"def",
"outputCharFormatter",
"(",
"c",
")",
":",
"#TODO 2: allow hex only output",
"if",
"32",
"<",
"c",
"<",
"127",
":",
"return",
"chr",
"(",
"c",
")",
"elif",
"c",
"==",
"10",
":",
"return",
"'\\\\n'",
"elif",
"c",
"==",
"13",
":",
"return",
"'\\\\... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | outputFormatter | Show string or char. | research/brotlidump.py | def outputFormatter(s):
"""Show string or char.
"""
result = ''
def formatSubString(s):
for c in s:
if c==32: yield ' '
else: yield outputCharFormatter(c)
if len(result)<200: return ''.join(formatSubString(s))
else:
return ''.join(formatSubString(s[:100]))... | def outputFormatter(s):
"""Show string or char.
"""
result = ''
def formatSubString(s):
for c in s:
if c==32: yield ' '
else: yield outputCharFormatter(c)
if len(result)<200: return ''.join(formatSubString(s))
else:
return ''.join(formatSubString(s[:100]))... | [
"Show",
"string",
"or",
"char",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L32-L43 | [
"def",
"outputFormatter",
"(",
"s",
")",
":",
"result",
"=",
"''",
"def",
"formatSubString",
"(",
"s",
")",
":",
"for",
"c",
"in",
"s",
":",
"if",
"c",
"==",
"32",
":",
"yield",
"' '",
"else",
":",
"yield",
"outputCharFormatter",
"(",
"c",
")",
"if... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | BitStream.read | Read n bits from the stream and return as an integer.
Produces zero bits beyond the stream.
>>> olleke.data[0]==27
True
>>> olleke.read(5)
27
>>> olleke
BitStream(pos=0:5) | research/brotlidump.py | def read(self, n):
"""Read n bits from the stream and return as an integer.
Produces zero bits beyond the stream.
>>> olleke.data[0]==27
True
>>> olleke.read(5)
27
>>> olleke
BitStream(pos=0:5)
"""
value = self.peek(n)
self.pos += ... | def read(self, n):
"""Read n bits from the stream and return as an integer.
Produces zero bits beyond the stream.
>>> olleke.data[0]==27
True
>>> olleke.read(5)
27
>>> olleke
BitStream(pos=0:5)
"""
value = self.peek(n)
self.pos += ... | [
"Read",
"n",
"bits",
"from",
"the",
"stream",
"and",
"return",
"as",
"an",
"integer",
".",
"Produces",
"zero",
"bits",
"beyond",
"the",
"stream",
".",
">>>",
"olleke",
".",
"data",
"[",
"0",
"]",
"==",
"27",
"True",
">>>",
"olleke",
".",
"read",
"(",... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L62-L77 | [
"def",
"read",
"(",
"self",
",",
"n",
")",
":",
"value",
"=",
"self",
".",
"peek",
"(",
"n",
")",
"self",
".",
"pos",
"+=",
"n",
"if",
"self",
".",
"pos",
">",
"len",
"(",
"self",
".",
"data",
")",
"*",
"8",
":",
"raise",
"ValueError",
"(",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | BitStream.peek | Peek an n bit integer from the stream without updating the pointer.
It is not an error to read beyond the end of the stream.
>>> olleke.data[:2]==b'\x1b\x2e' and 0x2e1b==11803
True
>>> olleke.peek(15)
11803
>>> hex(olleke.peek(32))
'0x2e1b' | research/brotlidump.py | def peek(self, n):
"""Peek an n bit integer from the stream without updating the pointer.
It is not an error to read beyond the end of the stream.
>>> olleke.data[:2]==b'\x1b\x2e' and 0x2e1b==11803
True
>>> olleke.peek(15)
11803
>>> hex(olleke.peek(32))
'0... | def peek(self, n):
"""Peek an n bit integer from the stream without updating the pointer.
It is not an error to read beyond the end of the stream.
>>> olleke.data[:2]==b'\x1b\x2e' and 0x2e1b==11803
True
>>> olleke.peek(15)
11803
>>> hex(olleke.peek(32))
'0... | [
"Peek",
"an",
"n",
"bit",
"integer",
"from",
"the",
"stream",
"without",
"updating",
"the",
"pointer",
".",
"It",
"is",
"not",
"an",
"error",
"to",
"read",
"beyond",
"the",
"end",
"of",
"the",
"stream",
".",
">>>",
"olleke",
".",
"data",
"[",
":",
"2... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L79-L95 | [
"def",
"peek",
"(",
"self",
",",
"n",
")",
":",
"#read bytes that contain the data: self.data[self.pos>>3:self.pos+n+7>>3]",
"#convert to int: int.from_bytes(..., 'little')",
"#shift out the bits from the first byte: >>(self.pos&7)",
"#mask unwanted bits: & (1<<n)-1",
"return",
"int",
".... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | BitStream.readBytes | Read n bytes from the stream on a byte boundary. | research/brotlidump.py | def readBytes(self, n):
"""Read n bytes from the stream on a byte boundary.
"""
if self.pos&7: raise ValueError('readBytes: need byte boundary')
result = self.data[self.pos>>3:(self.pos>>3)+n]
self.pos += 8*n
return result | def readBytes(self, n):
"""Read n bytes from the stream on a byte boundary.
"""
if self.pos&7: raise ValueError('readBytes: need byte boundary')
result = self.data[self.pos>>3:(self.pos>>3)+n]
self.pos += 8*n
return result | [
"Read",
"n",
"bytes",
"from",
"the",
"stream",
"on",
"a",
"byte",
"boundary",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L97-L103 | [
"def",
"readBytes",
"(",
"self",
",",
"n",
")",
":",
"if",
"self",
".",
"pos",
"&",
"7",
":",
"raise",
"ValueError",
"(",
"'readBytes: need byte boundary'",
")",
"result",
"=",
"self",
".",
"data",
"[",
"self",
".",
"pos",
">>",
"3",
":",
"(",
"self"... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Symbol.value | The value used for processing. Can be a tuple.
with optional extra bits | research/brotlidump.py | def value(self, extra=None):
"""The value used for processing. Can be a tuple.
with optional extra bits
"""
if isinstance(self.code, WithExtra):
if not 0<=extra<1<<self.extraBits():
raise ValueError("value: extra value doesn't fit in extraBits")
re... | def value(self, extra=None):
"""The value used for processing. Can be a tuple.
with optional extra bits
"""
if isinstance(self.code, WithExtra):
if not 0<=extra<1<<self.extraBits():
raise ValueError("value: extra value doesn't fit in extraBits")
re... | [
"The",
"value",
"used",
"for",
"processing",
".",
"Can",
"be",
"a",
"tuple",
".",
"with",
"optional",
"extra",
"bits"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L144-L154 | [
"def",
"value",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"code",
",",
"WithExtra",
")",
":",
"if",
"not",
"0",
"<=",
"extra",
"<",
"1",
"<<",
"self",
".",
"extraBits",
"(",
")",
":",
"raise",
"ValueE... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Symbol.explanation | Long explanation of the value from the numeric value
with optional extra bits
Used by Layout.verboseRead when printing the value | research/brotlidump.py | def explanation(self, extra=None):
"""Long explanation of the value from the numeric value
with optional extra bits
Used by Layout.verboseRead when printing the value
"""
if isinstance(self.code, WithExtra):
return self.code.callback(self, extra)
return self.c... | def explanation(self, extra=None):
"""Long explanation of the value from the numeric value
with optional extra bits
Used by Layout.verboseRead when printing the value
"""
if isinstance(self.code, WithExtra):
return self.code.callback(self, extra)
return self.c... | [
"Long",
"explanation",
"of",
"the",
"value",
"from",
"the",
"numeric",
"value",
"with",
"optional",
"extra",
"bits",
"Used",
"by",
"Layout",
".",
"verboseRead",
"when",
"printing",
"the",
"value"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L156-L163 | [
"def",
"explanation",
"(",
"self",
",",
"extra",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"code",
",",
"WithExtra",
")",
":",
"return",
"self",
".",
"code",
".",
"callback",
"(",
"self",
",",
"extra",
")",
"return",
"self",
".",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | RangeDecoder.decodePeek | Find which symbol index matches the given data (from peek, as a number)
and return the number of bits decoded.
Can also be used to figure out length of a symbol. | research/brotlidump.py | def decodePeek(self, data):
"""Find which symbol index matches the given data (from peek, as a number)
and return the number of bits decoded.
Can also be used to figure out length of a symbol.
"""
return self.maxLength, Symbol(self, data&(1<<self.maxLength)-1) | def decodePeek(self, data):
"""Find which symbol index matches the given data (from peek, as a number)
and return the number of bits decoded.
Can also be used to figure out length of a symbol.
"""
return self.maxLength, Symbol(self, data&(1<<self.maxLength)-1) | [
"Find",
"which",
"symbol",
"index",
"matches",
"the",
"given",
"data",
"(",
"from",
"peek",
"as",
"a",
"number",
")",
"and",
"return",
"the",
"number",
"of",
"bits",
"decoded",
".",
"Can",
"also",
"be",
"used",
"to",
"figure",
"out",
"length",
"of",
"a... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L200-L205 | [
"def",
"decodePeek",
"(",
"self",
",",
"data",
")",
":",
"return",
"self",
".",
"maxLength",
",",
"Symbol",
"(",
"self",
",",
"data",
"&",
"(",
"1",
"<<",
"self",
".",
"maxLength",
")",
"-",
"1",
")"
] | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | PrefixDecoder.decodePeek | Find which symbol index matches the given data (from peek, as a number)
and return the number of bits decoded.
Can also be used to figure out length of a symbol. | research/brotlidump.py | def decodePeek(self, data):
"""Find which symbol index matches the given data (from peek, as a number)
and return the number of bits decoded.
Can also be used to figure out length of a symbol.
"""
#do binary search for word length
#invariant: lo<=length<=hi
lo, hi... | def decodePeek(self, data):
"""Find which symbol index matches the given data (from peek, as a number)
and return the number of bits decoded.
Can also be used to figure out length of a symbol.
"""
#do binary search for word length
#invariant: lo<=length<=hi
lo, hi... | [
"Find",
"which",
"symbol",
"index",
"matches",
"the",
"given",
"data",
"(",
"from",
"peek",
"as",
"a",
"number",
")",
"and",
"return",
"the",
"number",
"of",
"bits",
"decoded",
".",
"Can",
"also",
"be",
"used",
"to",
"figure",
"out",
"length",
"of",
"a... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L246-L271 | [
"def",
"decodePeek",
"(",
"self",
",",
"data",
")",
":",
"#do binary search for word length",
"#invariant: lo<=length<=hi",
"lo",
",",
"hi",
"=",
"self",
".",
"minLength",
",",
"self",
".",
"maxLength",
"while",
"lo",
"<=",
"hi",
":",
"mid",
"=",
"lo",
"+",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | PrefixDecoder.setDecode | Store decodeTable,
and compute lengthTable, minLength, maxLength from encodings. | research/brotlidump.py | def setDecode(self, decodeTable):
"""Store decodeTable,
and compute lengthTable, minLength, maxLength from encodings.
"""
self.decodeTable = decodeTable
#set of symbols with unknown length
todo = set(decodeTable)
#bit size under investigation
maskLength = ... | def setDecode(self, decodeTable):
"""Store decodeTable,
and compute lengthTable, minLength, maxLength from encodings.
"""
self.decodeTable = decodeTable
#set of symbols with unknown length
todo = set(decodeTable)
#bit size under investigation
maskLength = ... | [
"Store",
"decodeTable",
"and",
"compute",
"lengthTable",
"minLength",
"maxLength",
"from",
"encodings",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L274-L301 | [
"def",
"setDecode",
"(",
"self",
",",
"decodeTable",
")",
":",
"self",
".",
"decodeTable",
"=",
"decodeTable",
"#set of symbols with unknown length",
"todo",
"=",
"set",
"(",
"decodeTable",
")",
"#bit size under investigation",
"maskLength",
"=",
"0",
"lengthTable",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | PrefixDecoder.setLength | Given the bit pattern lengths for symbols given in lengthTable,
set decodeTable, minLength, maxLength | research/brotlidump.py | def setLength(self, lengthTable):
"""Given the bit pattern lengths for symbols given in lengthTable,
set decodeTable, minLength, maxLength
"""
self.lengthTable = lengthTable
self.minLength = min(lengthTable.values())
self.maxLength = max(lengthTable.values())
#com... | def setLength(self, lengthTable):
"""Given the bit pattern lengths for symbols given in lengthTable,
set decodeTable, minLength, maxLength
"""
self.lengthTable = lengthTable
self.minLength = min(lengthTable.values())
self.maxLength = max(lengthTable.values())
#com... | [
"Given",
"the",
"bit",
"pattern",
"lengths",
"for",
"symbols",
"given",
"in",
"lengthTable",
"set",
"decodeTable",
"minLength",
"maxLength"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L303-L326 | [
"def",
"setLength",
"(",
"self",
",",
"lengthTable",
")",
":",
"self",
".",
"lengthTable",
"=",
"lengthTable",
"self",
".",
"minLength",
"=",
"min",
"(",
"lengthTable",
".",
"values",
"(",
")",
")",
"self",
".",
"maxLength",
"=",
"max",
"(",
"lengthTable... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Code.explanation | Long explanation of the value from the numeric value
This is a default routine.
You can customize in three ways:
- set description to add some text
- override to get more control
- set callback to make it dependent on you local variables | research/brotlidump.py | def explanation(self, index):
"""Long explanation of the value from the numeric value
This is a default routine.
You can customize in three ways:
- set description to add some text
- override to get more control
- set callback to make it dependent on you local variables
... | def explanation(self, index):
"""Long explanation of the value from the numeric value
This is a default routine.
You can customize in three ways:
- set description to add some text
- override to get more control
- set callback to make it dependent on you local variables
... | [
"Long",
"explanation",
"of",
"the",
"value",
"from",
"the",
"numeric",
"value",
"This",
"is",
"a",
"default",
"routine",
".",
"You",
"can",
"customize",
"in",
"three",
"ways",
":",
"-",
"set",
"description",
"to",
"add",
"some",
"text",
"-",
"override",
... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L393-L406 | [
"def",
"explanation",
"(",
"self",
",",
"index",
")",
":",
"value",
"=",
"self",
".",
"value",
"(",
"index",
")",
"return",
"'{0}{1}: {2}'",
".",
"format",
"(",
"self",
".",
"description",
"and",
"self",
".",
"description",
"+",
"': '",
",",
"self",
".... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Code.showCode | Show all words of the code in a nice format. | research/brotlidump.py | def showCode(self, width=80):
"""Show all words of the code in a nice format.
"""
#make table of all symbols with binary strings
symbolStrings = [
(self.bitPattern(s.index), self.mnemonic(s.index))
for s in self
]
#determine column widths the w... | def showCode(self, width=80):
"""Show all words of the code in a nice format.
"""
#make table of all symbols with binary strings
symbolStrings = [
(self.bitPattern(s.index), self.mnemonic(s.index))
for s in self
]
#determine column widths the w... | [
"Show",
"all",
"words",
"of",
"the",
"code",
"in",
"a",
"nice",
"format",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L412-L433 | [
"def",
"showCode",
"(",
"self",
",",
"width",
"=",
"80",
")",
":",
"#make table of all symbols with binary strings",
"symbolStrings",
"=",
"[",
"(",
"self",
".",
"bitPattern",
"(",
"s",
".",
"index",
")",
",",
"self",
".",
"mnemonic",
"(",
"s",
".",
"index... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Code.readTuple | Read symbol from stream. Returns symbol, length. | research/brotlidump.py | def readTuple(self, stream):
"""Read symbol from stream. Returns symbol, length.
"""
length, symbol = self.decodePeek(stream.peek(self.maxLength))
stream.pos += length
return length, symbol | def readTuple(self, stream):
"""Read symbol from stream. Returns symbol, length.
"""
length, symbol = self.decodePeek(stream.peek(self.maxLength))
stream.pos += length
return length, symbol | [
"Read",
"symbol",
"from",
"stream",
".",
"Returns",
"symbol",
"length",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L435-L440 | [
"def",
"readTuple",
"(",
"self",
",",
"stream",
")",
":",
"length",
",",
"symbol",
"=",
"self",
".",
"decodePeek",
"(",
"stream",
".",
"peek",
"(",
"self",
".",
"maxLength",
")",
")",
"stream",
".",
"pos",
"+=",
"length",
"return",
"length",
",",
"sy... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | WithExtra.readTupleAndExtra | Read symbol and extrabits from stream.
Returns symbol length, symbol, extraBits, extra
>>> olleke.pos = 6
>>> MetablockLengthAlphabet().readTupleAndExtra(olleke)
(2, Symbol(MLEN, 4), 16, 46) | research/brotlidump.py | def readTupleAndExtra(self, stream):
"""Read symbol and extrabits from stream.
Returns symbol length, symbol, extraBits, extra
>>> olleke.pos = 6
>>> MetablockLengthAlphabet().readTupleAndExtra(olleke)
(2, Symbol(MLEN, 4), 16, 46)
"""
length, symbol = self.decodeP... | def readTupleAndExtra(self, stream):
"""Read symbol and extrabits from stream.
Returns symbol length, symbol, extraBits, extra
>>> olleke.pos = 6
>>> MetablockLengthAlphabet().readTupleAndExtra(olleke)
(2, Symbol(MLEN, 4), 16, 46)
"""
length, symbol = self.decodeP... | [
"Read",
"symbol",
"and",
"extrabits",
"from",
"stream",
".",
"Returns",
"symbol",
"length",
"symbol",
"extraBits",
"extra",
">>>",
"olleke",
".",
"pos",
"=",
"6",
">>>",
"MetablockLengthAlphabet",
"()",
".",
"readTupleAndExtra",
"(",
"olleke",
")",
"(",
"2",
... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L466-L476 | [
"def",
"readTupleAndExtra",
"(",
"self",
",",
"stream",
")",
":",
"length",
",",
"symbol",
"=",
"self",
".",
"decodePeek",
"(",
"stream",
".",
"peek",
"(",
"self",
".",
"maxLength",
")",
")",
"stream",
".",
"pos",
"+=",
"length",
"extraBits",
"=",
"sel... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | WithExtra.explanation | Expanded version of Code.explanation supporting extra bits.
If you don't supply extra, it is not mentioned. | research/brotlidump.py | def explanation(self, index, extra=None):
"""Expanded version of Code.explanation supporting extra bits.
If you don't supply extra, it is not mentioned.
"""
extraBits = 0 if extra is None else self.extraBits(index)
if not hasattr(self, 'extraTable'):
formatString = '{... | def explanation(self, index, extra=None):
"""Expanded version of Code.explanation supporting extra bits.
If you don't supply extra, it is not mentioned.
"""
extraBits = 0 if extra is None else self.extraBits(index)
if not hasattr(self, 'extraTable'):
formatString = '{... | [
"Expanded",
"version",
"of",
"Code",
".",
"explanation",
"supporting",
"extra",
"bits",
".",
"If",
"you",
"don",
"t",
"supply",
"extra",
"it",
"is",
"not",
"mentioned",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L478-L501 | [
"def",
"explanation",
"(",
"self",
",",
"index",
",",
"extra",
"=",
"None",
")",
":",
"extraBits",
"=",
"0",
"if",
"extra",
"is",
"None",
"else",
"self",
".",
"extraBits",
"(",
"index",
")",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'extraTable'",
"... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Enumerator.value | Override if you don't define value0 and extraTable | research/brotlidump.py | def value(self, index, extra):
"""Override if you don't define value0 and extraTable
"""
lower, upper = self.span(index)
value = lower+(extra or 0)
if value>upper:
raise ValueError('value: extra out of range')
return value | def value(self, index, extra):
"""Override if you don't define value0 and extraTable
"""
lower, upper = self.span(index)
value = lower+(extra or 0)
if value>upper:
raise ValueError('value: extra out of range')
return value | [
"Override",
"if",
"you",
"don",
"t",
"define",
"value0",
"and",
"extraTable"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L540-L547 | [
"def",
"value",
"(",
"self",
",",
"index",
",",
"extra",
")",
":",
"lower",
",",
"upper",
"=",
"self",
".",
"span",
"(",
"index",
")",
"value",
"=",
"lower",
"+",
"(",
"extra",
"or",
"0",
")",
"if",
"value",
">",
"upper",
":",
"raise",
"ValueErro... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Enumerator.span | Give the range of possible values in a tuple
Useful for mnemonic and explanation | research/brotlidump.py | def span(self, index):
"""Give the range of possible values in a tuple
Useful for mnemonic and explanation
"""
lower = self.value0+sum(1<<x for x in self.extraTable[:index])
upper = lower+(1<<self.extraTable[index])
return lower, upper-1 | def span(self, index):
"""Give the range of possible values in a tuple
Useful for mnemonic and explanation
"""
lower = self.value0+sum(1<<x for x in self.extraTable[:index])
upper = lower+(1<<self.extraTable[index])
return lower, upper-1 | [
"Give",
"the",
"range",
"of",
"possible",
"values",
"in",
"a",
"tuple",
"Useful",
"for",
"mnemonic",
"and",
"explanation"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L549-L555 | [
"def",
"span",
"(",
"self",
",",
"index",
")",
":",
"lower",
"=",
"self",
".",
"value0",
"+",
"sum",
"(",
"1",
"<<",
"x",
"for",
"x",
"in",
"self",
".",
"extraTable",
"[",
":",
"index",
"]",
")",
"upper",
"=",
"lower",
"+",
"(",
"1",
"<<",
"s... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | PrefixCodeHeader.value | Returns ('Simple', #codewords) or ('Complex', HSKIP) | research/brotlidump.py | def value(self, index, extra):
"""Returns ('Simple', #codewords) or ('Complex', HSKIP)
"""
if index==1:
if extra>3:
raise ValueError('value: extra out of range')
return 'Simple', extra+1
if extra:
raise ValueError('value: extra out of r... | def value(self, index, extra):
"""Returns ('Simple', #codewords) or ('Complex', HSKIP)
"""
if index==1:
if extra>3:
raise ValueError('value: extra out of range')
return 'Simple', extra+1
if extra:
raise ValueError('value: extra out of r... | [
"Returns",
"(",
"Simple",
"#codewords",
")",
"or",
"(",
"Complex",
"HSKIP",
")"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L571-L580 | [
"def",
"value",
"(",
"self",
",",
"index",
",",
"extra",
")",
":",
"if",
"index",
"==",
"1",
":",
"if",
"extra",
">",
"3",
":",
"raise",
"ValueError",
"(",
"'value: extra out of range'",
")",
"return",
"'Simple'",
",",
"extra",
"+",
"1",
"if",
"extra",... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | TreeAlphabet.value | Give count and value. | research/brotlidump.py | def value(self, index, extra):
"""Give count and value."""
index = index
if index==0: return 1, 0
if index<=self.RLEMAX: return (1<<index)+extra, 0
return 1, index-self.RLEMAX | def value(self, index, extra):
"""Give count and value."""
index = index
if index==0: return 1, 0
if index<=self.RLEMAX: return (1<<index)+extra, 0
return 1, index-self.RLEMAX | [
"Give",
"count",
"and",
"value",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L978-L983 | [
"def",
"value",
"(",
"self",
",",
"index",
",",
"extra",
")",
":",
"index",
"=",
"index",
"if",
"index",
"==",
"0",
":",
"return",
"1",
",",
"0",
"if",
"index",
"<=",
"self",
".",
"RLEMAX",
":",
"return",
"(",
"1",
"<<",
"index",
")",
"+",
"ext... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | InsertAndCopyAlphabet.splitSymbol | Give relevant values for computations:
(insertSymbol, copySymbol, dist0flag) | research/brotlidump.py | def splitSymbol(self, index):
"""Give relevant values for computations:
(insertSymbol, copySymbol, dist0flag)
"""
#determine insert and copy upper bits from table
row = [0,0,1,1,2,2,1,3,2,3,3][index>>6]
col = [0,1,0,1,0,1,2,0,2,1,2][index>>6]
#determine inserts an... | def splitSymbol(self, index):
"""Give relevant values for computations:
(insertSymbol, copySymbol, dist0flag)
"""
#determine insert and copy upper bits from table
row = [0,0,1,1,2,2,1,3,2,3,3][index>>6]
col = [0,1,0,1,0,1,2,0,2,1,2][index>>6]
#determine inserts an... | [
"Give",
"relevant",
"values",
"for",
"computations",
":",
"(",
"insertSymbol",
"copySymbol",
"dist0flag",
")"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1057-L1072 | [
"def",
"splitSymbol",
"(",
"self",
",",
"index",
")",
":",
"#determine insert and copy upper bits from table",
"row",
"=",
"[",
"0",
",",
"0",
",",
"1",
",",
"1",
",",
"2",
",",
"2",
",",
"1",
",",
"3",
",",
"2",
",",
"3",
",",
"3",
"]",
"[",
"in... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | InsertAndCopyAlphabet.mnemonic | Make a nice mnemonic | research/brotlidump.py | def mnemonic(self, index):
"""Make a nice mnemonic
"""
i,c,d0 = self.splitSymbol(index)
iLower, _ = i.code.span(i.index)
iExtra = i.extraBits()
cLower, _ = c.code.span(c.index)
cExtra = c.extraBits()
return 'I{}{}{}C{}{}{}{}'.format(
iLower,
... | def mnemonic(self, index):
"""Make a nice mnemonic
"""
i,c,d0 = self.splitSymbol(index)
iLower, _ = i.code.span(i.index)
iExtra = i.extraBits()
cLower, _ = c.code.span(c.index)
cExtra = c.extraBits()
return 'I{}{}{}C{}{}{}{}'.format(
iLower,
... | [
"Make",
"a",
"nice",
"mnemonic"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1074-L1089 | [
"def",
"mnemonic",
"(",
"self",
",",
"index",
")",
":",
"i",
",",
"c",
",",
"d0",
"=",
"self",
".",
"splitSymbol",
"(",
"index",
")",
"iLower",
",",
"_",
"=",
"i",
".",
"code",
".",
"span",
"(",
"i",
".",
"index",
")",
"iExtra",
"=",
"i",
"."... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | DistanceAlphabet.extraBits | Indicate how many extra bits are needed to interpret symbol
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> [d[i].extraBits() for i in range(26)]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [d[i].extraBits() for i in range(26,36)]
... | research/brotlidump.py | def extraBits(self, index):
"""Indicate how many extra bits are needed to interpret symbol
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> [d[i].extraBits() for i in range(26)]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [d[i].extr... | def extraBits(self, index):
"""Indicate how many extra bits are needed to interpret symbol
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> [d[i].extraBits() for i in range(26)]
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> [d[i].extr... | [
"Indicate",
"how",
"many",
"extra",
"bits",
"are",
"needed",
"to",
"interpret",
"symbol",
">>>",
"d",
"=",
"DistanceAlphabet",
"(",
"D",
"NPOSTFIX",
"=",
"2",
"NDIRECT",
"=",
"10",
")",
">>>",
"[",
"d",
"[",
"i",
"]",
".",
"extraBits",
"()",
"for",
"... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1134-L1143 | [
"def",
"extraBits",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"<",
"16",
"+",
"self",
".",
"NDIRECT",
":",
"return",
"0",
"return",
"1",
"+",
"(",
"(",
"index",
"-",
"self",
".",
"NDIRECT",
"-",
"16",
")",
">>",
"(",
"self",
".",
"NPO... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | DistanceAlphabet.value | Decode value of symbol together with the extra bits.
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[34].value(2)
(0, 35) | research/brotlidump.py | def value(self, dcode, dextra):
"""Decode value of symbol together with the extra bits.
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[34].value(2)
(0, 35)
"""
if dcode<16:
return [(1,0),(2,0),(3,0),(4,0),
(1,-1),(1,+1),(1,-2),... | def value(self, dcode, dextra):
"""Decode value of symbol together with the extra bits.
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[34].value(2)
(0, 35)
"""
if dcode<16:
return [(1,0),(2,0),(3,0),(4,0),
(1,-1),(1,+1),(1,-2),... | [
"Decode",
"value",
"of",
"symbol",
"together",
"with",
"the",
"extra",
"bits",
".",
">>>",
"d",
"=",
"DistanceAlphabet",
"(",
"D",
"NPOSTFIX",
"=",
"2",
"NDIRECT",
"=",
"10",
")",
">>>",
"d",
"[",
"34",
"]",
".",
"value",
"(",
"2",
")",
"(",
"0",
... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1145-L1165 | [
"def",
"value",
"(",
"self",
",",
"dcode",
",",
"dextra",
")",
":",
"if",
"dcode",
"<",
"16",
":",
"return",
"[",
"(",
"1",
",",
"0",
")",
",",
"(",
"2",
",",
"0",
")",
",",
"(",
"3",
",",
"0",
")",
",",
"(",
"4",
",",
"0",
")",
",",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | DistanceAlphabet.mnemonic | Give mnemonic representation of meaning.
verbose compresses strings of x's | research/brotlidump.py | def mnemonic(self, index, verbose=False):
"""Give mnemonic representation of meaning.
verbose compresses strings of x's
"""
if index<16:
return ['last', '2last', '3last', '4last',
'last-1', 'last+1', 'last-2', 'last+2', 'last-3', 'last+3',
'2la... | def mnemonic(self, index, verbose=False):
"""Give mnemonic representation of meaning.
verbose compresses strings of x's
"""
if index<16:
return ['last', '2last', '3last', '4last',
'last-1', 'last+1', 'last-2', 'last+2', 'last-3', 'last+3',
'2la... | [
"Give",
"mnemonic",
"representation",
"of",
"meaning",
".",
"verbose",
"compresses",
"strings",
"of",
"x",
"s"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1167-L1188 | [
"def",
"mnemonic",
"(",
"self",
",",
"index",
",",
"verbose",
"=",
"False",
")",
":",
"if",
"index",
"<",
"16",
":",
"return",
"[",
"'last'",
",",
"'2last'",
",",
"'3last'",
",",
"'4last'",
",",
"'last-1'",
",",
"'last+1'",
",",
"'last-2'",
",",
"'la... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | DistanceAlphabet.explanation | >>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[55].explanation(13)
'11[1101]01-5: [0]+240' | research/brotlidump.py | def explanation(self, index, extra):
"""
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[55].explanation(13)
'11[1101]01-5: [0]+240'
"""
extraBits = self.extraBits(index)
extraString = '[{:0{}b}]'.format(extra, extraBits)
return '{0}: [{1[0]}]{... | def explanation(self, index, extra):
"""
>>> d = DistanceAlphabet('D', NPOSTFIX=2, NDIRECT=10)
>>> d[55].explanation(13)
'11[1101]01-5: [0]+240'
"""
extraBits = self.extraBits(index)
extraString = '[{:0{}b}]'.format(extra, extraBits)
return '{0}: [{1[0]}]{... | [
">>>",
"d",
"=",
"DistanceAlphabet",
"(",
"D",
"NPOSTFIX",
"=",
"2",
"NDIRECT",
"=",
"10",
")",
">>>",
"d",
"[",
"55",
"]",
".",
"explanation",
"(",
"13",
")",
"11",
"[",
"1101",
"]",
"01",
"-",
"5",
":",
"[",
"0",
"]",
"+",
"240"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1190-L1200 | [
"def",
"explanation",
"(",
"self",
",",
"index",
",",
"extra",
")",
":",
"extraBits",
"=",
"self",
".",
"extraBits",
"(",
"index",
")",
"extraString",
"=",
"'[{:0{}b}]'",
".",
"format",
"(",
"extra",
",",
"extraBits",
")",
"return",
"'{0}: [{1[0]}]{1[1]:+d}'... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | WordList.word | Get word | research/brotlidump.py | def word(self, size, dist):
"""Get word
"""
#split dist in index and action
ndbits = self.NDBITS[size]
index = dist&(1<<ndbits)-1
action = dist>>ndbits
#compute position in file
position = sum(n<<self.NDBITS[n] for n in range(4,size))+size*index
se... | def word(self, size, dist):
"""Get word
"""
#split dist in index and action
ndbits = self.NDBITS[size]
index = dist&(1<<ndbits)-1
action = dist>>ndbits
#compute position in file
position = sum(n<<self.NDBITS[n] for n in range(4,size))+size*index
se... | [
"Get",
"word"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1269-L1279 | [
"def",
"word",
"(",
"self",
",",
"size",
",",
"dist",
")",
":",
"#split dist in index and action",
"ndbits",
"=",
"self",
".",
"NDBITS",
"[",
"size",
"]",
"index",
"=",
"dist",
"&",
"(",
"1",
"<<",
"ndbits",
")",
"-",
"1",
"action",
"=",
"dist",
">>"... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | WordList.compileActions | Build the action table from the text above | research/brotlidump.py | def compileActions(self):
"""Build the action table from the text above
"""
import re
self.actionList = actions = [None]*121
#Action 73, which is too long, looks like this when expanded:
actions[73] = "b' the '+w+b' of the '"
#find out what the columns are
... | def compileActions(self):
"""Build the action table from the text above
"""
import re
self.actionList = actions = [None]*121
#Action 73, which is too long, looks like this when expanded:
actions[73] = "b' the '+w+b' of the '"
#find out what the columns are
... | [
"Build",
"the",
"action",
"table",
"from",
"the",
"text",
"above"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1317-L1357 | [
"def",
"compileActions",
"(",
"self",
")",
":",
"import",
"re",
"self",
".",
"actionList",
"=",
"actions",
"=",
"[",
"None",
"]",
"*",
"121",
"#Action 73, which is too long, looks like this when expanded:",
"actions",
"[",
"73",
"]",
"=",
"\"b' the '+w+b' of the '\"... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | WordList.doAction | Perform the proper action | research/brotlidump.py | def doAction(self, w, action):
"""Perform the proper action
"""
#set environment for the UpperCaseFirst
U = self.upperCase1
return eval(self.actionList[action], locals()) | def doAction(self, w, action):
"""Perform the proper action
"""
#set environment for the UpperCaseFirst
U = self.upperCase1
return eval(self.actionList[action], locals()) | [
"Perform",
"the",
"proper",
"action"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1359-L1364 | [
"def",
"doAction",
"(",
"self",
",",
"w",
",",
"action",
")",
":",
"#set environment for the UpperCaseFirst",
"U",
"=",
"self",
".",
"upperCase1",
"return",
"eval",
"(",
"self",
".",
"actionList",
"[",
"action",
"]",
",",
"locals",
"(",
")",
")"
] | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.makeHexData | Produce hex dump of all data containing the bits
from pos to stream.pos | research/brotlidump.py | def makeHexData(self, pos):
"""Produce hex dump of all data containing the bits
from pos to stream.pos
"""
firstAddress = pos+7>>3
lastAddress = self.stream.pos+7>>3
return ''.join(map('{:02x} '.format,
self.stream.data[firstAddress:lastAddress])) | def makeHexData(self, pos):
"""Produce hex dump of all data containing the bits
from pos to stream.pos
"""
firstAddress = pos+7>>3
lastAddress = self.stream.pos+7>>3
return ''.join(map('{:02x} '.format,
self.stream.data[firstAddress:lastAddress])) | [
"Produce",
"hex",
"dump",
"of",
"all",
"data",
"containing",
"the",
"bits",
"from",
"pos",
"to",
"stream",
".",
"pos"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1376-L1383 | [
"def",
"makeHexData",
"(",
"self",
",",
"pos",
")",
":",
"firstAddress",
"=",
"pos",
"+",
"7",
">>",
"3",
"lastAddress",
"=",
"self",
".",
"stream",
".",
"pos",
"+",
"7",
">>",
"3",
"return",
"''",
".",
"join",
"(",
"map",
"(",
"'{:02x} '",
".",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.formatBitData | Show formatted bit data:
Bytes are separated by commas
whole bytes are displayed in hex
>>> Layout(olleke).formatBitData(6, 2, 16)
'|00h|2Eh,|00'
>>> Layout(olleke).formatBitData(4, 1, 0)
'1' | research/brotlidump.py | def formatBitData(self, pos, width1, width2=0):
"""Show formatted bit data:
Bytes are separated by commas
whole bytes are displayed in hex
>>> Layout(olleke).formatBitData(6, 2, 16)
'|00h|2Eh,|00'
>>> Layout(olleke).formatBitData(4, 1, 0)
'1'
"""
r... | def formatBitData(self, pos, width1, width2=0):
"""Show formatted bit data:
Bytes are separated by commas
whole bytes are displayed in hex
>>> Layout(olleke).formatBitData(6, 2, 16)
'|00h|2Eh,|00'
>>> Layout(olleke).formatBitData(4, 1, 0)
'1'
"""
r... | [
"Show",
"formatted",
"bit",
"data",
":",
"Bytes",
"are",
"separated",
"by",
"commas",
"whole",
"bytes",
"are",
"displayed",
"in",
"hex",
">>>",
"Layout",
"(",
"olleke",
")",
".",
"formatBitData",
"(",
"6",
"2",
"16",
")",
"|00h|2Eh",
"|00",
">>>",
"Layou... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1385-L1422 | [
"def",
"formatBitData",
"(",
"self",
",",
"pos",
",",
"width1",
",",
"width2",
"=",
"0",
")",
":",
"result",
"=",
"[",
"]",
"#make empty prefix code explicit",
"if",
"width1",
"==",
"0",
":",
"result",
"=",
"[",
"'()'",
",",
"','",
"]",
"for",
"width",... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.readPrefixCode | give alphabet the prefix code that is read from the stream
Called for the following alphabets, in this order:
The alphabet in question must have a "logical" order,
otherwise the assignment of symbols doesn't work. | research/brotlidump.py | def readPrefixCode(self, alphabet):
"""give alphabet the prefix code that is read from the stream
Called for the following alphabets, in this order:
The alphabet in question must have a "logical" order,
otherwise the assignment of symbols doesn't work.
"""
mode, numberOfS... | def readPrefixCode(self, alphabet):
"""give alphabet the prefix code that is read from the stream
Called for the following alphabets, in this order:
The alphabet in question must have a "logical" order,
otherwise the assignment of symbols doesn't work.
"""
mode, numberOfS... | [
"give",
"alphabet",
"the",
"prefix",
"code",
"that",
"is",
"read",
"from",
"the",
"stream",
"Called",
"for",
"the",
"following",
"alphabets",
"in",
"this",
"order",
":",
"The",
"alphabet",
"in",
"question",
"must",
"have",
"a",
"logical",
"order",
"otherwise... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1424-L1456 | [
"def",
"readPrefixCode",
"(",
"self",
",",
"alphabet",
")",
":",
"mode",
",",
"numberOfSymbols",
"=",
"self",
".",
"verboseRead",
"(",
"PrefixCodeHeader",
"(",
"alphabet",
".",
"name",
")",
")",
"if",
"mode",
"==",
"'Complex'",
":",
"#for a complex code, numbe... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.readComplexCode | Read complex code | research/brotlidump.py | def readComplexCode(self, hskip, alphabet):
"""Read complex code"""
stream = self.stream
#read the lengths for the length code
lengths = [1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15][hskip:]
codeLengths = {}
total = 0
lol = LengthOfLengthAlphabet('##'+alphabet.nam... | def readComplexCode(self, hskip, alphabet):
"""Read complex code"""
stream = self.stream
#read the lengths for the length code
lengths = [1,2,3,4,0,5,17,6,16,7,8,9,10,11,12,13,14,15][hskip:]
codeLengths = {}
total = 0
lol = LengthOfLengthAlphabet('##'+alphabet.nam... | [
"Read",
"complex",
"code"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1458-L1575 | [
"def",
"readComplexCode",
"(",
"self",
",",
"hskip",
",",
"alphabet",
")",
":",
"stream",
"=",
"self",
".",
"stream",
"#read the lengths for the length code",
"lengths",
"=",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"0",
",",
"5",
",",
"17",
",",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.processStream | Process a brotli stream. | research/brotlidump.py | def processStream(self):
"""Process a brotli stream.
"""
print('addr hex{:{}s}binary context explanation'.format(
'', self.width-10))
print('Stream header'.center(60, '-'))
self.windowSize = self.verboseRead(WindowSizeAlphabet())
print('Metablock header'.cent... | def processStream(self):
"""Process a brotli stream.
"""
print('addr hex{:{}s}binary context explanation'.format(
'', self.width-10))
print('Stream header'.center(60, '-'))
self.windowSize = self.verboseRead(WindowSizeAlphabet())
print('Metablock header'.cent... | [
"Process",
"a",
"brotli",
"stream",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1578-L1615 | [
"def",
"processStream",
"(",
"self",
")",
":",
"print",
"(",
"'addr hex{:{}s}binary context explanation'",
".",
"format",
"(",
"''",
",",
"self",
".",
"width",
"-",
"10",
")",
")",
"print",
"(",
"'Stream header'",
".",
"center",
"(",
"60",
",",
"'-'",
")"... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.verboseRead | Read symbol and extra from stream and explain what happens.
Returns the value of the symbol
>>> olleke.pos = 0
>>> l = Layout(olleke)
>>> l.verboseRead(WindowSizeAlphabet())
0000 1b 1011 WSIZE windowsize=(1<<22)-16=4194288
4194288 | research/brotlidump.py | def verboseRead(self, alphabet, context='', skipExtra=False):
"""Read symbol and extra from stream and explain what happens.
Returns the value of the symbol
>>> olleke.pos = 0
>>> l = Layout(olleke)
>>> l.verboseRead(WindowSizeAlphabet())
0000 1b 1011 W... | def verboseRead(self, alphabet, context='', skipExtra=False):
"""Read symbol and extra from stream and explain what happens.
Returns the value of the symbol
>>> olleke.pos = 0
>>> l = Layout(olleke)
>>> l.verboseRead(WindowSizeAlphabet())
0000 1b 1011 W... | [
"Read",
"symbol",
"and",
"extra",
"from",
"stream",
"and",
"explain",
"what",
"happens",
".",
"Returns",
"the",
"value",
"of",
"the",
"symbol",
">>>",
"olleke",
".",
"pos",
"=",
"0",
">>>",
"l",
"=",
"Layout",
"(",
"olleke",
")",
">>>",
"l",
".",
"ve... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1618-L1657 | [
"def",
"verboseRead",
"(",
"self",
",",
"alphabet",
",",
"context",
"=",
"''",
",",
"skipExtra",
"=",
"False",
")",
":",
"#TODO 2: verbosity level, e.g. show only codes and maps in header",
"stream",
"=",
"self",
".",
"stream",
"pos",
"=",
"stream",
".",
"pos",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.metablockLength | Read MNIBBLES and meta block length;
if empty block, skip block and return true. | research/brotlidump.py | def metablockLength(self):
"""Read MNIBBLES and meta block length;
if empty block, skip block and return true.
"""
self.MLEN = self.verboseRead(MetablockLengthAlphabet())
if self.MLEN:
return False
#empty block; skip and return False
self.verboseRead(R... | def metablockLength(self):
"""Read MNIBBLES and meta block length;
if empty block, skip block and return true.
"""
self.MLEN = self.verboseRead(MetablockLengthAlphabet())
if self.MLEN:
return False
#empty block; skip and return False
self.verboseRead(R... | [
"Read",
"MNIBBLES",
"and",
"meta",
"block",
"length",
";",
"if",
"empty",
"block",
"skip",
"block",
"and",
"return",
"true",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1659-L1672 | [
"def",
"metablockLength",
"(",
"self",
")",
":",
"self",
".",
"MLEN",
"=",
"self",
".",
"verboseRead",
"(",
"MetablockLengthAlphabet",
"(",
")",
")",
"if",
"self",
".",
"MLEN",
":",
"return",
"False",
"#empty block; skip and return False",
"self",
".",
"verbos... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.uncompressed | If true, handle uncompressed data | research/brotlidump.py | def uncompressed(self):
"""If true, handle uncompressed data
"""
ISUNCOMPRESSED = self.verboseRead(
BoolCode('UNCMPR', description='Is uncompressed?'))
if ISUNCOMPRESSED:
self.verboseRead(FillerAlphabet(streamPos=self.stream.pos))
print('Uncompressed d... | def uncompressed(self):
"""If true, handle uncompressed data
"""
ISUNCOMPRESSED = self.verboseRead(
BoolCode('UNCMPR', description='Is uncompressed?'))
if ISUNCOMPRESSED:
self.verboseRead(FillerAlphabet(streamPos=self.stream.pos))
print('Uncompressed d... | [
"If",
"true",
"handle",
"uncompressed",
"data"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1674-L1684 | [
"def",
"uncompressed",
"(",
"self",
")",
":",
"ISUNCOMPRESSED",
"=",
"self",
".",
"verboseRead",
"(",
"BoolCode",
"(",
"'UNCMPR'",
",",
"description",
"=",
"'Is uncompressed?'",
")",
")",
"if",
"ISUNCOMPRESSED",
":",
"self",
".",
"verboseRead",
"(",
"FillerAlp... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.blockType | Read block type switch descriptor for given kind of blockType. | research/brotlidump.py | def blockType(self, kind):
"""Read block type switch descriptor for given kind of blockType."""
NBLTYPES = self.verboseRead(TypeCountAlphabet(
'BT#'+kind[0].upper(),
description='{} block types'.format(kind),
))
self.numberOfBlockTypes[kind] = NBLTYPES
... | def blockType(self, kind):
"""Read block type switch descriptor for given kind of blockType."""
NBLTYPES = self.verboseRead(TypeCountAlphabet(
'BT#'+kind[0].upper(),
description='{} block types'.format(kind),
))
self.numberOfBlockTypes[kind] = NBLTYPES
... | [
"Read",
"block",
"type",
"switch",
"descriptor",
"for",
"given",
"kind",
"of",
"blockType",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1686-L1701 | [
"def",
"blockType",
"(",
"self",
",",
"kind",
")",
":",
"NBLTYPES",
"=",
"self",
".",
"verboseRead",
"(",
"TypeCountAlphabet",
"(",
"'BT#'",
"+",
"kind",
"[",
"0",
"]",
".",
"upper",
"(",
")",
",",
"description",
"=",
"'{} block types'",
".",
"format",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.readLiteralContextModes | Read literal context modes.
LSB6: lower 6 bits of last char
MSB6: upper 6 bits of last char
UTF8: rougly dependent on categories:
upper 4 bits depend on category of last char:
control/whitespace/space/ punctuation/quote/%/open/close/
comma/period/=/dig... | research/brotlidump.py | def readLiteralContextModes(self):
"""Read literal context modes.
LSB6: lower 6 bits of last char
MSB6: upper 6 bits of last char
UTF8: rougly dependent on categories:
upper 4 bits depend on category of last char:
control/whitespace/space/ punctuation/quote/%/... | def readLiteralContextModes(self):
"""Read literal context modes.
LSB6: lower 6 bits of last char
MSB6: upper 6 bits of last char
UTF8: rougly dependent on categories:
upper 4 bits depend on category of last char:
control/whitespace/space/ punctuation/quote/%/... | [
"Read",
"literal",
"context",
"modes",
".",
"LSB6",
":",
"lower",
"6",
"bits",
"of",
"last",
"char",
"MSB6",
":",
"upper",
"6",
"bits",
"of",
"last",
"char",
"UTF8",
":",
"rougly",
"dependent",
"on",
"categories",
":",
"upper",
"4",
"bits",
"depend",
"... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1703-L1719 | [
"def",
"readLiteralContextModes",
"(",
"self",
")",
":",
"print",
"(",
"'Context modes'",
".",
"center",
"(",
"60",
",",
"'-'",
")",
")",
"self",
".",
"literalContextModes",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"numberOfBlockTypes",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.contextMap | Read context maps
Returns the number of differnt values on the context map
(In other words, the number of prefix trees) | research/brotlidump.py | def contextMap(self, kind):
"""Read context maps
Returns the number of differnt values on the context map
(In other words, the number of prefix trees)
"""
NTREES = self.verboseRead(TypeCountAlphabet(
kind[0].upper()+'T#',
description='{} prefix trees'.form... | def contextMap(self, kind):
"""Read context maps
Returns the number of differnt values on the context map
(In other words, the number of prefix trees)
"""
NTREES = self.verboseRead(TypeCountAlphabet(
kind[0].upper()+'T#',
description='{} prefix trees'.form... | [
"Read",
"context",
"maps",
"Returns",
"the",
"number",
"of",
"differnt",
"values",
"on",
"the",
"context",
"map",
"(",
"In",
"other",
"words",
"the",
"number",
"of",
"prefix",
"trees",
")"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1721-L1764 | [
"def",
"contextMap",
"(",
"self",
",",
"kind",
")",
":",
"NTREES",
"=",
"self",
".",
"verboseRead",
"(",
"TypeCountAlphabet",
"(",
"kind",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"'T#'",
",",
"description",
"=",
"'{} prefix trees'",
".",
"format",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.IMTF | In place inverse move to front transform. | research/brotlidump.py | def IMTF(v):
"""In place inverse move to front transform.
"""
#mtf is initialized virtually with range(infinity)
mtf = []
for i, vi in enumerate(v):
#get old value from mtf. If never seen, take virtual value
try: value = mtf.pop(vi)
except Inde... | def IMTF(v):
"""In place inverse move to front transform.
"""
#mtf is initialized virtually with range(infinity)
mtf = []
for i, vi in enumerate(v):
#get old value from mtf. If never seen, take virtual value
try: value = mtf.pop(vi)
except Inde... | [
"In",
"place",
"inverse",
"move",
"to",
"front",
"transform",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1767-L1779 | [
"def",
"IMTF",
"(",
"v",
")",
":",
"#mtf is initialized virtually with range(infinity)",
"mtf",
"=",
"[",
"]",
"for",
"i",
",",
"vi",
"in",
"enumerate",
"(",
"v",
")",
":",
"#get old value from mtf. If never seen, take virtual value",
"try",
":",
"value",
"=",
"mt... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.readPrefixArray | Read prefix code array | research/brotlidump.py | def readPrefixArray(self, kind, numberOfTrees):
"""Read prefix code array"""
prefixes = []
for i in range(numberOfTrees):
if kind==L: alphabet = LiteralAlphabet(i)
elif kind==I: alphabet = InsertAndCopyAlphabet(i)
elif kind==D: alphabet = DistanceAlphabet(
... | def readPrefixArray(self, kind, numberOfTrees):
"""Read prefix code array"""
prefixes = []
for i in range(numberOfTrees):
if kind==L: alphabet = LiteralAlphabet(i)
elif kind==I: alphabet = InsertAndCopyAlphabet(i)
elif kind==D: alphabet = DistanceAlphabet(
... | [
"Read",
"prefix",
"code",
"array"
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1781-L1791 | [
"def",
"readPrefixArray",
"(",
"self",
",",
"kind",
",",
"numberOfTrees",
")",
":",
"prefixes",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"numberOfTrees",
")",
":",
"if",
"kind",
"==",
"L",
":",
"alphabet",
"=",
"LiteralAlphabet",
"(",
"i",
")",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | Layout.metablock | Process the data.
Relevant variables of self:
numberOfBlockTypes[kind]: number of block types
currentBlockTypes[kind]: current block types (=0)
literalContextModes: the context modes for the literal block types
currentBlockCounts[kind]: counters for block types
blockTypeC... | research/brotlidump.py | def metablock(self):
"""Process the data.
Relevant variables of self:
numberOfBlockTypes[kind]: number of block types
currentBlockTypes[kind]: current block types (=0)
literalContextModes: the context modes for the literal block types
currentBlockCounts[kind]: counters fo... | def metablock(self):
"""Process the data.
Relevant variables of self:
numberOfBlockTypes[kind]: number of block types
currentBlockTypes[kind]: current block types (=0)
literalContextModes: the context modes for the literal block types
currentBlockCounts[kind]: counters fo... | [
"Process",
"the",
"data",
".",
"Relevant",
"variables",
"of",
"self",
":",
"numberOfBlockTypes",
"[",
"kind",
"]",
":",
"number",
"of",
"block",
"types",
"currentBlockTypes",
"[",
"kind",
"]",
":",
"current",
"block",
"types",
"(",
"=",
"0",
")",
"literalC... | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/research/brotlidump.py#L1794-L1892 | [
"def",
"metablock",
"(",
"self",
")",
":",
"print",
"(",
"'Meta block contents'",
".",
"center",
"(",
"60",
",",
"'='",
")",
")",
"self",
".",
"currentBlockTypes",
"=",
"{",
"L",
":",
"0",
",",
"I",
":",
"0",
",",
"D",
":",
"0",
",",
"pL",
":",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | get_version | Return BROTLI_VERSION string as defined in 'common/version.h' file. | setup.py | def get_version():
""" Return BROTLI_VERSION string as defined in 'common/version.h' file. """
version_file_path = os.path.join(CURR_DIR, 'c', 'common', 'version.h')
version = 0
with open(version_file_path, 'r') as f:
for line in f:
m = re.match(r'#define\sBROTLI_VERSION\s+0x([0-9a-f... | def get_version():
""" Return BROTLI_VERSION string as defined in 'common/version.h' file. """
version_file_path = os.path.join(CURR_DIR, 'c', 'common', 'version.h')
version = 0
with open(version_file_path, 'r') as f:
for line in f:
m = re.match(r'#define\sBROTLI_VERSION\s+0x([0-9a-f... | [
"Return",
"BROTLI_VERSION",
"string",
"as",
"defined",
"in",
"common",
"/",
"version",
".",
"h",
"file",
"."
] | google/brotli | python | https://github.com/google/brotli/blob/4b2b2d4f83ffeaac7708e44409fe34896a01a278/setup.py#L26-L41 | [
"def",
"get_version",
"(",
")",
":",
"version_file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"CURR_DIR",
",",
"'c'",
",",
"'common'",
",",
"'version.h'",
")",
"version",
"=",
"0",
"with",
"open",
"(",
"version_file_path",
",",
"'r'",
")",
"as",
... | 4b2b2d4f83ffeaac7708e44409fe34896a01a278 |
test | monochrome | Turns a intensity array to a monochrome 'image' by replacing each intensity by a scaled 'color'
Values in I between vmin and vmax get scaled between 0 and 1, and values outside this range are clipped to this.
Example
>>> I = np.arange(16.).reshape(4,4)
>>> color = (0, 0, 1) # red
>>> rgb = vx.ima... | packages/vaex-core/vaex/image.py | def monochrome(I, color, vmin=None, vmax=None):
"""Turns a intensity array to a monochrome 'image' by replacing each intensity by a scaled 'color'
Values in I between vmin and vmax get scaled between 0 and 1, and values outside this range are clipped to this.
Example
>>> I = np.arange(16.).reshape(4,... | def monochrome(I, color, vmin=None, vmax=None):
"""Turns a intensity array to a monochrome 'image' by replacing each intensity by a scaled 'color'
Values in I between vmin and vmax get scaled between 0 and 1, and values outside this range are clipped to this.
Example
>>> I = np.arange(16.).reshape(4,... | [
"Turns",
"a",
"intensity",
"array",
"to",
"a",
"monochrome",
"image",
"by",
"replacing",
"each",
"intensity",
"by",
"a",
"scaled",
"color"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/image.py#L121-L142 | [
"def",
"monochrome",
"(",
"I",
",",
"color",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
")",
":",
"if",
"vmin",
"is",
"None",
":",
"vmin",
"=",
"np",
".",
"nanmin",
"(",
"I",
")",
"if",
"vmax",
"is",
"None",
":",
"vmax",
"=",
"np",
"... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | polychrome | Similar to monochrome, but now do it for multiple colors
Example
>>> I = np.arange(32.).reshape(4,4,2)
>>> colors = [(0, 0, 1), (0, 1, 0)] # red and green
>>> rgb = vx.image.polychrome(I, colors) # shape is (4,4,3)
:param I: ndarray of any shape (3d will result in a 2d image)
:param colors: se... | packages/vaex-core/vaex/image.py | def polychrome(I, colors, vmin=None, vmax=None, axis=-1):
"""Similar to monochrome, but now do it for multiple colors
Example
>>> I = np.arange(32.).reshape(4,4,2)
>>> colors = [(0, 0, 1), (0, 1, 0)] # red and green
>>> rgb = vx.image.polychrome(I, colors) # shape is (4,4,3)
:param I: ndarray ... | def polychrome(I, colors, vmin=None, vmax=None, axis=-1):
"""Similar to monochrome, but now do it for multiple colors
Example
>>> I = np.arange(32.).reshape(4,4,2)
>>> colors = [(0, 0, 1), (0, 1, 0)] # red and green
>>> rgb = vx.image.polychrome(I, colors) # shape is (4,4,3)
:param I: ndarray ... | [
"Similar",
"to",
"monochrome",
"but",
"now",
"do",
"it",
"for",
"multiple",
"colors"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/image.py#L145-L171 | [
"def",
"polychrome",
"(",
"I",
",",
"colors",
",",
"vmin",
"=",
"None",
",",
"vmax",
"=",
"None",
",",
"axis",
"=",
"-",
"1",
")",
":",
"axes_length",
"=",
"len",
"(",
"I",
".",
"shape",
")",
"allaxes",
"=",
"list",
"(",
"range",
"(",
"axes_lengt... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | parallelize | Function decorater that executes the function in parallel
Usage::
@parallelize(cores=10, info=True)
def f(x):
return x**2
x = numpy.arange(0, 100, 0.1)
y = f(x) # this gets executed parallel
:param cores: number of cpus/cores to use (if None, it counts the cores using /proc/cpuinfo)
:param fork: fo... | packages/vaex-core/vaex/misc/parallelize.py | def parallelize(cores=None, fork=True, flatten=False, info=False, infoclass=InfoThreadProgressBar, init=None, *args, **kwargs):
"""Function decorater that executes the function in parallel
Usage::
@parallelize(cores=10, info=True)
def f(x):
return x**2
x = numpy.arange(0, 100, 0.1)
y = f(x) # this ge... | def parallelize(cores=None, fork=True, flatten=False, info=False, infoclass=InfoThreadProgressBar, init=None, *args, **kwargs):
"""Function decorater that executes the function in parallel
Usage::
@parallelize(cores=10, info=True)
def f(x):
return x**2
x = numpy.arange(0, 100, 0.1)
y = f(x) # this ge... | [
"Function",
"decorater",
"that",
"executes",
"the",
"function",
"in",
"parallel",
"Usage",
"::"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/misc/parallelize.py#L335-L422 | [
"def",
"parallelize",
"(",
"cores",
"=",
"None",
",",
"fork",
"=",
"True",
",",
"flatten",
"=",
"False",
",",
"info",
"=",
"False",
",",
"infoclass",
"=",
"InfoThreadProgressBar",
",",
"init",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
"... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | export_hdf5 | :param DatasetLocal dataset: dataset to export
:param str path: path for file
:param lis[str] column_names: list of column names to export or None for all columns
:param str byteorder: = for native, < for little endian and > for big endian
:param bool shuffle: export rows in random order
:param bool... | packages/vaex-hdf5/vaex/hdf5/export.py | def export_hdf5(dataset, path, column_names=None, byteorder="=", shuffle=False, selection=False, progress=None, virtual=True, sort=None, ascending=True):
"""
:param DatasetLocal dataset: dataset to export
:param str path: path for file
:param lis[str] column_names: list of column names to export or None... | def export_hdf5(dataset, path, column_names=None, byteorder="=", shuffle=False, selection=False, progress=None, virtual=True, sort=None, ascending=True):
"""
:param DatasetLocal dataset: dataset to export
:param str path: path for file
:param lis[str] column_names: list of column names to export or None... | [
":",
"param",
"DatasetLocal",
"dataset",
":",
"dataset",
"to",
"export",
":",
"param",
"str",
"path",
":",
"path",
"for",
"file",
":",
"param",
"lis",
"[",
"str",
"]",
"column_names",
":",
"list",
"of",
"column",
"names",
"to",
"export",
"or",
"None",
... | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-hdf5/vaex/hdf5/export.py#L108-L260 | [
"def",
"export_hdf5",
"(",
"dataset",
",",
"path",
",",
"column_names",
"=",
"None",
",",
"byteorder",
"=",
"\"=\"",
",",
"shuffle",
"=",
"False",
",",
"selection",
"=",
"False",
",",
"progress",
"=",
"None",
",",
"virtual",
"=",
"True",
",",
"sort",
"... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | arrow_table_from_vaex_df | Implementation of Dataset.to_arrow_table | packages/vaex-arrow/vaex_arrow/convert.py | def arrow_table_from_vaex_df(ds, column_names=None, selection=None, strings=True, virtual=False):
"""Implementation of Dataset.to_arrow_table"""
names = []
arrays = []
for name, array in ds.to_items(column_names=column_names, selection=selection, strings=strings, virtual=virtual):
names.append(n... | def arrow_table_from_vaex_df(ds, column_names=None, selection=None, strings=True, virtual=False):
"""Implementation of Dataset.to_arrow_table"""
names = []
arrays = []
for name, array in ds.to_items(column_names=column_names, selection=selection, strings=strings, virtual=virtual):
names.append(n... | [
"Implementation",
"of",
"Dataset",
".",
"to_arrow_table"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-arrow/vaex_arrow/convert.py#L81-L88 | [
"def",
"arrow_table_from_vaex_df",
"(",
"ds",
",",
"column_names",
"=",
"None",
",",
"selection",
"=",
"None",
",",
"strings",
"=",
"True",
",",
"virtual",
"=",
"False",
")",
":",
"names",
"=",
"[",
"]",
"arrays",
"=",
"[",
"]",
"for",
"name",
",",
"... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | patch | Adds method f to the Dataset class | packages/vaex-astro/vaex/astro/transformations.py | def patch(f):
'''Adds method f to the Dataset class'''
name = f.__name__
Dataset.__hidden__[name] = f
return f | def patch(f):
'''Adds method f to the Dataset class'''
name = f.__name__
Dataset.__hidden__[name] = f
return f | [
"Adds",
"method",
"f",
"to",
"the",
"Dataset",
"class"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L5-L9 | [
"def",
"patch",
"(",
"f",
")",
":",
"name",
"=",
"f",
".",
"__name__",
"Dataset",
".",
"__hidden__",
"[",
"name",
"]",
"=",
"f",
"return",
"f"
] | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_eq2ecl | Add ecliptic coordates (long_out, lat_out) from equatorial coordinates.
:param long_in: Name/expression for right ascension
:param lat_in: Name/expression for declination
:param long_out: Output name for lambda coordinate
:param lat_out: Output name for beta coordinate
:param name_prefix:
:par... | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_eq2ecl(self, long_in="ra", lat_in="dec", long_out="lambda_", lat_out="beta", name_prefix="__celestial_eq2ecl", radians=False):
"""Add ecliptic coordates (long_out, lat_out) from equatorial coordinates.
:param long_in: Name/expression for right ascension
:param lat_in: Name/expressio... | def add_virtual_columns_eq2ecl(self, long_in="ra", lat_in="dec", long_out="lambda_", lat_out="beta", name_prefix="__celestial_eq2ecl", radians=False):
"""Add ecliptic coordates (long_out, lat_out) from equatorial coordinates.
:param long_in: Name/expression for right ascension
:param lat_in: Name/expressio... | [
"Add",
"ecliptic",
"coordates",
"(",
"long_out",
"lat_out",
")",
"from",
"equatorial",
"coordinates",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L23-L35 | [
"def",
"add_virtual_columns_eq2ecl",
"(",
"self",
",",
"long_in",
"=",
"\"ra\"",
",",
"lat_in",
"=",
"\"dec\"",
",",
"long_out",
"=",
"\"lambda_\"",
",",
"lat_out",
"=",
"\"beta\"",
",",
"name_prefix",
"=",
"\"__celestial_eq2ecl\"",
",",
"radians",
"=",
"False",... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_distance_from_parallax | Convert parallax to distance (i.e. 1/parallax)
:param parallax: expression for the parallax, e.g. "parallax"
:param distance_name: name for the virtual column of the distance, e.g. "distance"
:param parallax_uncertainty: expression for the uncertainty on the parallax, e.g. "parallax_error"
:param uncer... | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_distance_from_parallax(self, parallax="parallax", distance_name="distance", parallax_uncertainty=None, uncertainty_postfix="_uncertainty"):
"""Convert parallax to distance (i.e. 1/parallax)
:param parallax: expression for the parallax, e.g. "parallax"
:param distance_name: name for ... | def add_virtual_columns_distance_from_parallax(self, parallax="parallax", distance_name="distance", parallax_uncertainty=None, uncertainty_postfix="_uncertainty"):
"""Convert parallax to distance (i.e. 1/parallax)
:param parallax: expression for the parallax, e.g. "parallax"
:param distance_name: name for ... | [
"Convert",
"parallax",
"to",
"distance",
"(",
"i",
".",
"e",
".",
"1",
"/",
"parallax",
")"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L70-L110 | [
"def",
"add_virtual_columns_distance_from_parallax",
"(",
"self",
",",
"parallax",
"=",
"\"parallax\"",
",",
"distance_name",
"=",
"\"distance\"",
",",
"parallax_uncertainty",
"=",
"None",
",",
"uncertainty_postfix",
"=",
"\"_uncertainty\"",
")",
":",
"\"\"\"\n\n\n \"\... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_cartesian_velocities_to_pmvr | Concert velocities from a cartesian system to proper motions and radial velocities
TODO: errors
:param x: name of x column (input)
:param y: y
:param z: z
:param vx: vx
:param vy: vy
:param vz: vz
:param vr: name of the column for the radial velocity i... | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_cartesian_velocities_to_pmvr(self, x="x", y="y", z="z", vx="vx", vy="vy", vz="vz", vr="vr", pm_long="pm_long", pm_lat="pm_lat", distance=None):
"""Concert velocities from a cartesian system to proper motions and radial velocities
TODO: errors
:param x: name of x column (input)
... | def add_virtual_columns_cartesian_velocities_to_pmvr(self, x="x", y="y", z="z", vx="vx", vy="vy", vz="vz", vr="vr", pm_long="pm_long", pm_lat="pm_lat", distance=None):
"""Concert velocities from a cartesian system to proper motions and radial velocities
TODO: errors
:param x: name of x column (input)
... | [
"Concert",
"velocities",
"from",
"a",
"cartesian",
"system",
"to",
"proper",
"motions",
"and",
"radial",
"velocities"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L114-L137 | [
"def",
"add_virtual_columns_cartesian_velocities_to_pmvr",
"(",
"self",
",",
"x",
"=",
"\"x\"",
",",
"y",
"=",
"\"y\"",
",",
"z",
"=",
"\"z\"",
",",
"vx",
"=",
"\"vx\"",
",",
"vy",
"=",
"\"vy\"",
",",
"vz",
"=",
"\"vz\"",
",",
"vr",
"=",
"\"vr\"",
",",... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_proper_motion_eq2gal | Transform/rotate proper motions from equatorial to galactic coordinates
Taken from http://arxiv.org/abs/1306.2945
:param long_in: Name/expression for right ascension
:param lat_in: Name/expression for declination
:param pm_long: Proper motion for ra
:param pm_lat: Proper motion for dec
:param ... | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_proper_motion_eq2gal(self, long_in="ra", lat_in="dec", pm_long="pm_ra", pm_lat="pm_dec", pm_long_out="pm_l", pm_lat_out="pm_b",
name_prefix="__proper_motion_eq2gal",
right_ascension_galactic_pole=192.85,
... | def add_virtual_columns_proper_motion_eq2gal(self, long_in="ra", lat_in="dec", pm_long="pm_ra", pm_lat="pm_dec", pm_long_out="pm_l", pm_lat_out="pm_b",
name_prefix="__proper_motion_eq2gal",
right_ascension_galactic_pole=192.85,
... | [
"Transform",
"/",
"rotate",
"proper",
"motions",
"from",
"equatorial",
"to",
"galactic",
"coordinates"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L141-L186 | [
"def",
"add_virtual_columns_proper_motion_eq2gal",
"(",
"self",
",",
"long_in",
"=",
"\"ra\"",
",",
"lat_in",
"=",
"\"dec\"",
",",
"pm_long",
"=",
"\"pm_ra\"",
",",
"pm_lat",
"=",
"\"pm_dec\"",
",",
"pm_long_out",
"=",
"\"pm_l\"",
",",
"pm_lat_out",
"=",
"\"pm_b... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_proper_motion_gal2eq | Transform/rotate proper motions from galactic to equatorial coordinates.
Inverse of :py:`add_virtual_columns_proper_motion_eq2gal` | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_proper_motion_gal2eq(self, long_in="ra", lat_in="dec", pm_long="pm_l", pm_lat="pm_b", pm_long_out="pm_ra", pm_lat_out="pm_dec",
name_prefix="__proper_motion_gal2eq",
right_ascension_galactic_pole=192.85,
... | def add_virtual_columns_proper_motion_gal2eq(self, long_in="ra", lat_in="dec", pm_long="pm_l", pm_lat="pm_b", pm_long_out="pm_ra", pm_lat_out="pm_dec",
name_prefix="__proper_motion_gal2eq",
right_ascension_galactic_pole=192.85,
... | [
"Transform",
"/",
"rotate",
"proper",
"motions",
"from",
"galactic",
"to",
"equatorial",
"coordinates",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L189-L202 | [
"def",
"add_virtual_columns_proper_motion_gal2eq",
"(",
"self",
",",
"long_in",
"=",
"\"ra\"",
",",
"lat_in",
"=",
"\"dec\"",
",",
"pm_long",
"=",
"\"pm_l\"",
",",
"pm_lat",
"=",
"\"pm_b\"",
",",
"pm_long_out",
"=",
"\"pm_ra\"",
",",
"pm_lat_out",
"=",
"\"pm_dec... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_lbrvr_proper_motion2vcartesian | Convert radial velocity and galactic proper motions (and positions) to cartesian velocities wrt the center_v
Based on http://adsabs.harvard.edu/abs/1987AJ.....93..864J
:param long_in: Name/expression for galactic longitude
:param lat_in: Name/expression for galactic latitude
:param distance: Name/exp... | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_lbrvr_proper_motion2vcartesian(self, long_in="l", lat_in="b", distance="distance", pm_long="pm_l", pm_lat="pm_b",
vr="vr", vx="vx", vy="vy", vz="vz",
center_v=(0, 0, 0),
... | def add_virtual_columns_lbrvr_proper_motion2vcartesian(self, long_in="l", lat_in="b", distance="distance", pm_long="pm_l", pm_lat="pm_b",
vr="vr", vx="vx", vy="vy", vz="vz",
center_v=(0, 0, 0),
... | [
"Convert",
"radial",
"velocity",
"and",
"galactic",
"proper",
"motions",
"(",
"and",
"positions",
")",
"to",
"cartesian",
"velocities",
"wrt",
"the",
"center_v"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L206-L239 | [
"def",
"add_virtual_columns_lbrvr_proper_motion2vcartesian",
"(",
"self",
",",
"long_in",
"=",
"\"l\"",
",",
"lat_in",
"=",
"\"b\"",
",",
"distance",
"=",
"\"distance\"",
",",
"pm_long",
"=",
"\"pm_l\"",
",",
"pm_lat",
"=",
"\"pm_b\"",
",",
"vr",
"=",
"\"vr\"",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_equatorial_to_galactic_cartesian | From http://arxiv.org/pdf/1306.2945v2.pdf | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_equatorial_to_galactic_cartesian(self, alpha, delta, distance, xname, yname, zname, radians=True, alpha_gp=np.radians(192.85948), delta_gp=np.radians(27.12825), l_omega=np.radians(32.93192)):
"""From http://arxiv.org/pdf/1306.2945v2.pdf"""
if not radians:
alpha = "pi/180.*%s" % a... | def add_virtual_columns_equatorial_to_galactic_cartesian(self, alpha, delta, distance, xname, yname, zname, radians=True, alpha_gp=np.radians(192.85948), delta_gp=np.radians(27.12825), l_omega=np.radians(32.93192)):
"""From http://arxiv.org/pdf/1306.2945v2.pdf"""
if not radians:
alpha = "pi/180.*%s" % a... | [
"From",
"http",
":",
"//",
"arxiv",
".",
"org",
"/",
"pdf",
"/",
"1306",
".",
"2945v2",
".",
"pdf"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L243-L250 | [
"def",
"add_virtual_columns_equatorial_to_galactic_cartesian",
"(",
"self",
",",
"alpha",
",",
"delta",
",",
"distance",
",",
"xname",
",",
"yname",
",",
"zname",
",",
"radians",
"=",
"True",
",",
"alpha_gp",
"=",
"np",
".",
"radians",
"(",
"192.85948",
")",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_proper_motion2vperpendicular | Convert proper motion to perpendicular velocities.
:param distance:
:param pm_long:
:param pm_lat:
:param vl:
:param vb:
:param cov_matrix_distance_pm_long_pm_lat:
:param uncertainty_postfix:
:param covariance_postfix:
:param radians:
:return: | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_proper_motion2vperpendicular(self, distance="distance", pm_long="pm_l", pm_lat="pm_b",
vl="vl", vb="vb",
propagate_uncertainties=False,
r... | def add_virtual_columns_proper_motion2vperpendicular(self, distance="distance", pm_long="pm_l", pm_lat="pm_b",
vl="vl", vb="vb",
propagate_uncertainties=False,
r... | [
"Convert",
"proper",
"motion",
"to",
"perpendicular",
"velocities",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L282-L304 | [
"def",
"add_virtual_columns_proper_motion2vperpendicular",
"(",
"self",
",",
"distance",
"=",
"\"distance\"",
",",
"pm_long",
"=",
"\"pm_l\"",
",",
"pm_lat",
"=",
"\"pm_b\"",
",",
"vl",
"=",
"\"vl\"",
",",
"vb",
"=",
"\"vb\"",
",",
"propagate_uncertainties",
"=",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | add_virtual_columns_cartesian_angular_momenta | Calculate the angular momentum components provided Cartesian positions and velocities.
Be mindful of the point of origin: ex. if considering Galactic dynamics, and positions and
velocities should be as seen from the Galactic centre.
:param x: x-position Cartesian component
:param y: y-position Cartesia... | packages/vaex-astro/vaex/astro/transformations.py | def add_virtual_columns_cartesian_angular_momenta(self, x='x', y='y', z='z',
vx='vx', vy='vy', vz='vz',
Lx='Lx', Ly='Ly', Lz='Lz',
propagate_uncertainties=False):
"""... | def add_virtual_columns_cartesian_angular_momenta(self, x='x', y='y', z='z',
vx='vx', vy='vy', vz='vz',
Lx='Lx', Ly='Ly', Lz='Lz',
propagate_uncertainties=False):
"""... | [
"Calculate",
"the",
"angular",
"momentum",
"components",
"provided",
"Cartesian",
"positions",
"and",
"velocities",
".",
"Be",
"mindful",
"of",
"the",
"point",
"of",
"origin",
":",
"ex",
".",
"if",
"considering",
"Galactic",
"dynamics",
"and",
"positions",
"and"... | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-astro/vaex/astro/transformations.py#L308-L335 | [
"def",
"add_virtual_columns_cartesian_angular_momenta",
"(",
"self",
",",
"x",
"=",
"'x'",
",",
"y",
"=",
"'y'",
",",
"z",
"=",
"'z'",
",",
"vx",
"=",
"'vx'",
",",
"vy",
"=",
"'vy'",
",",
"vz",
"=",
"'vz'",
",",
"Lx",
"=",
"'Lx'",
",",
"Ly",
"=",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | DispersionEllipse._recompute_transform | NOTE: This cannot be called until after this has been added
to an Axes, otherwise unit conversion will fail. This
maxes it very important to call the accessor method and
not directly access the transformation member variable. | packages/vaex-ui/vaex/ui/plugin/dispersions.py | def _recompute_transform(self):
"""NOTE: This cannot be called until after this has been added
to an Axes, otherwise unit conversion will fail. This
maxes it very important to call the accessor method and
not directly access the transformation member variable.
"""
center = (self.convert_xunits(self... | def _recompute_transform(self):
"""NOTE: This cannot be called until after this has been added
to an Axes, otherwise unit conversion will fail. This
maxes it very important to call the accessor method and
not directly access the transformation member variable.
"""
center = (self.convert_xunits(self... | [
"NOTE",
":",
"This",
"cannot",
"be",
"called",
"until",
"after",
"this",
"has",
"been",
"added",
"to",
"an",
"Axes",
"otherwise",
"unit",
"conversion",
"will",
"fail",
".",
"This",
"maxes",
"it",
"very",
"important",
"to",
"call",
"the",
"accessor",
"metho... | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-ui/vaex/ui/plugin/dispersions.py#L57-L71 | [
"def",
"_recompute_transform",
"(",
"self",
")",
":",
"center",
"=",
"(",
"self",
".",
"convert_xunits",
"(",
"self",
".",
"center",
"[",
"0",
"]",
")",
",",
"self",
".",
"convert_yunits",
"(",
"self",
".",
"center",
"[",
"1",
"]",
")",
")",
"width",... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | Expression._graph | Return a graph containing the dependencies of this expression
Structure is:
[<string expression>, <function name if callable>, <function object if callable>, [subgraph/dependencies, ....]] | packages/vaex-core/vaex/expression.py | def _graph(self):
""""Return a graph containing the dependencies of this expression
Structure is:
[<string expression>, <function name if callable>, <function object if callable>, [subgraph/dependencies, ....]]
"""
expression = self.expression
def walk(node):
... | def _graph(self):
""""Return a graph containing the dependencies of this expression
Structure is:
[<string expression>, <function name if callable>, <function object if callable>, [subgraph/dependencies, ....]]
"""
expression = self.expression
def walk(node):
... | [
"Return",
"a",
"graph",
"containing",
"the",
"dependencies",
"of",
"this",
"expression",
"Structure",
"is",
":",
"[",
"<string",
"expression",
">",
"<function",
"name",
"if",
"callable",
">",
"<function",
"object",
"if",
"callable",
">",
"[",
"subgraph",
"/",
... | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/expression.py#L191-L217 | [
"def",
"_graph",
"(",
"self",
")",
":",
"expression",
"=",
"self",
".",
"expression",
"def",
"walk",
"(",
"node",
")",
":",
"if",
"isinstance",
"(",
"node",
",",
"six",
".",
"string_types",
")",
":",
"if",
"node",
"in",
"self",
".",
"ds",
".",
"vir... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | Expression._graphviz | Return a graphviz.Digraph object with a graph of the expression | packages/vaex-core/vaex/expression.py | def _graphviz(self, dot=None):
"""Return a graphviz.Digraph object with a graph of the expression"""
from graphviz import Graph, Digraph
node = self._graph()
dot = dot or Digraph(comment=self.expression)
def walk(node):
if isinstance(node, six.string_types):
... | def _graphviz(self, dot=None):
"""Return a graphviz.Digraph object with a graph of the expression"""
from graphviz import Graph, Digraph
node = self._graph()
dot = dot or Digraph(comment=self.expression)
def walk(node):
if isinstance(node, six.string_types):
... | [
"Return",
"a",
"graphviz",
".",
"Digraph",
"object",
"with",
"a",
"graph",
"of",
"the",
"expression"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/expression.py#L219-L237 | [
"def",
"_graphviz",
"(",
"self",
",",
"dot",
"=",
"None",
")",
":",
"from",
"graphviz",
"import",
"Graph",
",",
"Digraph",
"node",
"=",
"self",
".",
"_graph",
"(",
")",
"dot",
"=",
"dot",
"or",
"Digraph",
"(",
"comment",
"=",
"self",
".",
"expression... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | Expression.min | Shortcut for ds.min(expression, ...), see `Dataset.min` | packages/vaex-core/vaex/expression.py | def min(self, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):
'''Shortcut for ds.min(expression, ...), see `Dataset.min`'''
kwargs = dict(locals())
del kwargs['self']
kwargs['expression'] = self.expression
return self.ds.min(**kwargs) | def min(self, binby=[], limits=None, shape=default_shape, selection=False, delay=False, progress=None):
'''Shortcut for ds.min(expression, ...), see `Dataset.min`'''
kwargs = dict(locals())
del kwargs['self']
kwargs['expression'] = self.expression
return self.ds.min(**kwargs) | [
"Shortcut",
"for",
"ds",
".",
"min",
"(",
"expression",
"...",
")",
"see",
"Dataset",
".",
"min"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/expression.py#L343-L348 | [
"def",
"min",
"(",
"self",
",",
"binby",
"=",
"[",
"]",
",",
"limits",
"=",
"None",
",",
"shape",
"=",
"default_shape",
",",
"selection",
"=",
"False",
",",
"delay",
"=",
"False",
",",
"progress",
"=",
"None",
")",
":",
"kwargs",
"=",
"dict",
"(",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | Expression.value_counts | Computes counts of unique values.
WARNING:
* If the expression/column is not categorical, it will be converted on the fly
* dropna is False by default, it is True by default in pandas
:param dropna: when True, it will not report the missing values
:param ascending: when Fa... | packages/vaex-core/vaex/expression.py | def value_counts(self, dropna=False, dropnull=True, ascending=False, progress=False):
"""Computes counts of unique values.
WARNING:
* If the expression/column is not categorical, it will be converted on the fly
* dropna is False by default, it is True by default in pandas
... | def value_counts(self, dropna=False, dropnull=True, ascending=False, progress=False):
"""Computes counts of unique values.
WARNING:
* If the expression/column is not categorical, it will be converted on the fly
* dropna is False by default, it is True by default in pandas
... | [
"Computes",
"counts",
"of",
"unique",
"values",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/expression.py#L371-L434 | [
"def",
"value_counts",
"(",
"self",
",",
"dropna",
"=",
"False",
",",
"dropnull",
"=",
"True",
",",
"ascending",
"=",
"False",
",",
"progress",
"=",
"False",
")",
":",
"from",
"pandas",
"import",
"Series",
"dtype",
"=",
"self",
".",
"dtype",
"transient",... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | Expression.map | Map values of an expression or in memory column accoring to an input
dictionary or a custom callable function.
Example:
>>> import vaex
>>> df = vaex.from_arrays(color=['red', 'red', 'blue', 'red', 'green'])
>>> mapper = {'red': 1, 'blue': 2, 'green': 3}
>>> df['color_m... | packages/vaex-core/vaex/expression.py | def map(self, mapper, nan_mapping=None, null_mapping=None):
"""Map values of an expression or in memory column accoring to an input
dictionary or a custom callable function.
Example:
>>> import vaex
>>> df = vaex.from_arrays(color=['red', 'red', 'blue', 'red', 'green'])
... | def map(self, mapper, nan_mapping=None, null_mapping=None):
"""Map values of an expression or in memory column accoring to an input
dictionary or a custom callable function.
Example:
>>> import vaex
>>> df = vaex.from_arrays(color=['red', 'red', 'blue', 'red', 'green'])
... | [
"Map",
"values",
"of",
"an",
"expression",
"or",
"in",
"memory",
"column",
"accoring",
"to",
"an",
"input",
"dictionary",
"or",
"a",
"custom",
"callable",
"function",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/expression.py#L528-L595 | [
"def",
"map",
"(",
"self",
",",
"mapper",
",",
"nan_mapping",
"=",
"None",
",",
"null_mapping",
"=",
"None",
")",
":",
"assert",
"isinstance",
"(",
"mapper",
",",
"collectionsAbc",
".",
"Mapping",
")",
",",
"\"mapper should be a dict like object\"",
"df",
"=",... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | app | Create a vaex app, the QApplication mainloop must be started.
In ipython notebook/jupyter do the following:
>>> import vaex.ui.main # this causes the qt api level to be set properly
>>> import vaex
Next cell:
>>> %gui qt
Next cell:
>>> app = vaex.app()
From now on, you can run the... | packages/vaex-core/vaex/__init__.py | def app(*args, **kwargs):
"""Create a vaex app, the QApplication mainloop must be started.
In ipython notebook/jupyter do the following:
>>> import vaex.ui.main # this causes the qt api level to be set properly
>>> import vaex
Next cell:
>>> %gui qt
Next cell:
>>> app = vaex.app()
... | def app(*args, **kwargs):
"""Create a vaex app, the QApplication mainloop must be started.
In ipython notebook/jupyter do the following:
>>> import vaex.ui.main # this causes the qt api level to be set properly
>>> import vaex
Next cell:
>>> %gui qt
Next cell:
>>> app = vaex.app()
... | [
"Create",
"a",
"vaex",
"app",
"the",
"QApplication",
"mainloop",
"must",
"be",
"started",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L77-L98 | [
"def",
"app",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"vaex",
".",
"ui",
".",
"main",
"return",
"vaex",
".",
"ui",
".",
"main",
".",
"VaexApp",
"(",
")"
] | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | _convert_name | Convert a filename (or list of) to a filename with .hdf5 and optionally a -shuffle suffix | packages/vaex-core/vaex/__init__.py | def _convert_name(filenames, shuffle=False):
'''Convert a filename (or list of) to a filename with .hdf5 and optionally a -shuffle suffix'''
if not isinstance(filenames, (list, tuple)):
filenames = [filenames]
base = filenames[0]
if shuffle:
base += '-shuffle'
if len(filenames) > 1:
... | def _convert_name(filenames, shuffle=False):
'''Convert a filename (or list of) to a filename with .hdf5 and optionally a -shuffle suffix'''
if not isinstance(filenames, (list, tuple)):
filenames = [filenames]
base = filenames[0]
if shuffle:
base += '-shuffle'
if len(filenames) > 1:
... | [
"Convert",
"a",
"filename",
"(",
"or",
"list",
"of",
")",
"to",
"a",
"filename",
"with",
".",
"hdf5",
"and",
"optionally",
"a",
"-",
"shuffle",
"suffix"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L101-L111 | [
"def",
"_convert_name",
"(",
"filenames",
",",
"shuffle",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"filenames",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"filenames",
"=",
"[",
"filenames",
"]",
"base",
"=",
"filenames",
"[",
"0",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | open | Open a DataFrame from file given by path.
Example:
>>> ds = vaex.open('sometable.hdf5')
>>> ds = vaex.open('somedata*.csv', convert='bigdata.hdf5')
:param str path: local or absolute path to file, or glob string
:param convert: convert files to an hdf5 file for optimization, can also be a path
... | packages/vaex-core/vaex/__init__.py | def open(path, convert=False, shuffle=False, copy_index=True, *args, **kwargs):
"""Open a DataFrame from file given by path.
Example:
>>> ds = vaex.open('sometable.hdf5')
>>> ds = vaex.open('somedata*.csv', convert='bigdata.hdf5')
:param str path: local or absolute path to file, or glob string
... | def open(path, convert=False, shuffle=False, copy_index=True, *args, **kwargs):
"""Open a DataFrame from file given by path.
Example:
>>> ds = vaex.open('sometable.hdf5')
>>> ds = vaex.open('somedata*.csv', convert='bigdata.hdf5')
:param str path: local or absolute path to file, or glob string
... | [
"Open",
"a",
"DataFrame",
"from",
"file",
"given",
"by",
"path",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L114-L200 | [
"def",
"open",
"(",
"path",
",",
"convert",
"=",
"False",
",",
"shuffle",
"=",
"False",
",",
"copy_index",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"vaex",
"try",
":",
"if",
"path",
"in",
"aliases",
":",
"path",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | open_many | Open a list of filenames, and return a DataFrame with all DataFrames cocatenated.
:param list[str] filenames: list of filenames/paths
:rtype: DataFrame | packages/vaex-core/vaex/__init__.py | def open_many(filenames):
"""Open a list of filenames, and return a DataFrame with all DataFrames cocatenated.
:param list[str] filenames: list of filenames/paths
:rtype: DataFrame
"""
dfs = []
for filename in filenames:
filename = filename.strip()
if filename and filename[0] !=... | def open_many(filenames):
"""Open a list of filenames, and return a DataFrame with all DataFrames cocatenated.
:param list[str] filenames: list of filenames/paths
:rtype: DataFrame
"""
dfs = []
for filename in filenames:
filename = filename.strip()
if filename and filename[0] !=... | [
"Open",
"a",
"list",
"of",
"filenames",
"and",
"return",
"a",
"DataFrame",
"with",
"all",
"DataFrames",
"cocatenated",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L203-L214 | [
"def",
"open_many",
"(",
"filenames",
")",
":",
"dfs",
"=",
"[",
"]",
"for",
"filename",
"in",
"filenames",
":",
"filename",
"=",
"filename",
".",
"strip",
"(",
")",
"if",
"filename",
"and",
"filename",
"[",
"0",
"]",
"!=",
"\"#\"",
":",
"dfs",
".",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_samp | Connect to a SAMP Hub and wait for a single table load event, disconnect, download the table and return the DataFrame.
Useful if you want to send a single table from say TOPCAT to vaex in a python console or notebook. | packages/vaex-core/vaex/__init__.py | def from_samp(username=None, password=None):
"""Connect to a SAMP Hub and wait for a single table load event, disconnect, download the table and return the DataFrame.
Useful if you want to send a single table from say TOPCAT to vaex in a python console or notebook.
"""
print("Waiting for SAMP message..... | def from_samp(username=None, password=None):
"""Connect to a SAMP Hub and wait for a single table load event, disconnect, download the table and return the DataFrame.
Useful if you want to send a single table from say TOPCAT to vaex in a python console or notebook.
"""
print("Waiting for SAMP message..... | [
"Connect",
"to",
"a",
"SAMP",
"Hub",
"and",
"wait",
"for",
"a",
"single",
"table",
"load",
"event",
"disconnect",
"download",
"the",
"table",
"and",
"return",
"the",
"DataFrame",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L217-L225 | [
"def",
"from_samp",
"(",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"print",
"(",
"\"Waiting for SAMP message...\"",
")",
"import",
"vaex",
".",
"samp",
"t",
"=",
"vaex",
".",
"samp",
".",
"single_table",
"(",
"username",
"=",
"userna... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_astropy_table | Create a vaex DataFrame from an Astropy Table. | packages/vaex-core/vaex/__init__.py | def from_astropy_table(table):
"""Create a vaex DataFrame from an Astropy Table."""
import vaex.file.other
return vaex.file.other.DatasetAstropyTable(table=table) | def from_astropy_table(table):
"""Create a vaex DataFrame from an Astropy Table."""
import vaex.file.other
return vaex.file.other.DatasetAstropyTable(table=table) | [
"Create",
"a",
"vaex",
"DataFrame",
"from",
"an",
"Astropy",
"Table",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L228-L231 | [
"def",
"from_astropy_table",
"(",
"table",
")",
":",
"import",
"vaex",
".",
"file",
".",
"other",
"return",
"vaex",
".",
"file",
".",
"other",
".",
"DatasetAstropyTable",
"(",
"table",
"=",
"table",
")"
] | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_items | Create an in memory DataFrame from numpy arrays, in contrast to from_arrays this keeps the order of columns intact (for Python < 3.6).
Example
>>> import vaex, numpy as np
>>> x = np.arange(5)
>>> y = x ** 2
>>> vaex.from_items(('x', x), ('y', y))
# x y
0 0 0
1 1 ... | packages/vaex-core/vaex/__init__.py | def from_items(*items):
"""Create an in memory DataFrame from numpy arrays, in contrast to from_arrays this keeps the order of columns intact (for Python < 3.6).
Example
>>> import vaex, numpy as np
>>> x = np.arange(5)
>>> y = x ** 2
>>> vaex.from_items(('x', x), ('y', y))
# x y
... | def from_items(*items):
"""Create an in memory DataFrame from numpy arrays, in contrast to from_arrays this keeps the order of columns intact (for Python < 3.6).
Example
>>> import vaex, numpy as np
>>> x = np.arange(5)
>>> y = x ** 2
>>> vaex.from_items(('x', x), ('y', y))
# x y
... | [
"Create",
"an",
"in",
"memory",
"DataFrame",
"from",
"numpy",
"arrays",
"in",
"contrast",
"to",
"from_arrays",
"this",
"keeps",
"the",
"order",
"of",
"columns",
"intact",
"(",
"for",
"Python",
"<",
"3",
".",
"6",
")",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L253-L277 | [
"def",
"from_items",
"(",
"*",
"items",
")",
":",
"import",
"numpy",
"as",
"np",
"df",
"=",
"vaex",
".",
"dataframe",
".",
"DataFrameArrays",
"(",
"\"array\"",
")",
"for",
"name",
",",
"array",
"in",
"items",
":",
"df",
".",
"add_column",
"(",
"name",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_arrays | Create an in memory DataFrame from numpy arrays.
Example
>>> import vaex, numpy as np
>>> x = np.arange(5)
>>> y = x ** 2
>>> vaex.from_arrays(x=x, y=y)
# x y
0 0 0
1 1 1
2 2 4
3 3 9
4 4 16
>>> some_dict = {'x': x, 'y': y}
... | packages/vaex-core/vaex/__init__.py | def from_arrays(**arrays):
"""Create an in memory DataFrame from numpy arrays.
Example
>>> import vaex, numpy as np
>>> x = np.arange(5)
>>> y = x ** 2
>>> vaex.from_arrays(x=x, y=y)
# x y
0 0 0
1 1 1
2 2 4
3 3 9
4 4 16
... | def from_arrays(**arrays):
"""Create an in memory DataFrame from numpy arrays.
Example
>>> import vaex, numpy as np
>>> x = np.arange(5)
>>> y = x ** 2
>>> vaex.from_arrays(x=x, y=y)
# x y
0 0 0
1 1 1
2 2 4
3 3 9
4 4 16
... | [
"Create",
"an",
"in",
"memory",
"DataFrame",
"from",
"numpy",
"arrays",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L280-L317 | [
"def",
"from_arrays",
"(",
"*",
"*",
"arrays",
")",
":",
"import",
"numpy",
"as",
"np",
"import",
"six",
"from",
".",
"column",
"import",
"Column",
"df",
"=",
"vaex",
".",
"dataframe",
".",
"DataFrameArrays",
"(",
"\"array\"",
")",
"for",
"name",
",",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_scalars | Similar to from_arrays, but convenient for a DataFrame of length 1.
Example:
>>> import vaex
>>> df = vaex.from_scalars(x=1, y=2)
:rtype: DataFrame | packages/vaex-core/vaex/__init__.py | def from_scalars(**kwargs):
"""Similar to from_arrays, but convenient for a DataFrame of length 1.
Example:
>>> import vaex
>>> df = vaex.from_scalars(x=1, y=2)
:rtype: DataFrame
"""
import numpy as np
return from_arrays(**{k: np.array([v]) for k, v in kwargs.items()}) | def from_scalars(**kwargs):
"""Similar to from_arrays, but convenient for a DataFrame of length 1.
Example:
>>> import vaex
>>> df = vaex.from_scalars(x=1, y=2)
:rtype: DataFrame
"""
import numpy as np
return from_arrays(**{k: np.array([v]) for k, v in kwargs.items()}) | [
"Similar",
"to",
"from_arrays",
"but",
"convenient",
"for",
"a",
"DataFrame",
"of",
"length",
"1",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L327-L338 | [
"def",
"from_scalars",
"(",
"*",
"*",
"kwargs",
")",
":",
"import",
"numpy",
"as",
"np",
"return",
"from_arrays",
"(",
"*",
"*",
"{",
"k",
":",
"np",
".",
"array",
"(",
"[",
"v",
"]",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"("... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_pandas | Create an in memory DataFrame from a pandas DataFrame.
:param: pandas.DataFrame df: Pandas DataFrame
:param: name: unique for the DataFrame
>>> import vaex, pandas as pd
>>> df_pandas = pd.from_csv('test.csv')
>>> df = vaex.from_pandas(df_pandas)
:rtype: DataFrame | packages/vaex-core/vaex/__init__.py | def from_pandas(df, name="pandas", copy_index=True, index_name="index"):
"""Create an in memory DataFrame from a pandas DataFrame.
:param: pandas.DataFrame df: Pandas DataFrame
:param: name: unique for the DataFrame
>>> import vaex, pandas as pd
>>> df_pandas = pd.from_csv('test.csv')
>>> df =... | def from_pandas(df, name="pandas", copy_index=True, index_name="index"):
"""Create an in memory DataFrame from a pandas DataFrame.
:param: pandas.DataFrame df: Pandas DataFrame
:param: name: unique for the DataFrame
>>> import vaex, pandas as pd
>>> df_pandas = pd.from_csv('test.csv')
>>> df =... | [
"Create",
"an",
"in",
"memory",
"DataFrame",
"from",
"a",
"pandas",
"DataFrame",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L341-L371 | [
"def",
"from_pandas",
"(",
"df",
",",
"name",
"=",
"\"pandas\"",
",",
"copy_index",
"=",
"True",
",",
"index_name",
"=",
"\"index\"",
")",
":",
"import",
"six",
"vaex_df",
"=",
"vaex",
".",
"dataframe",
".",
"DataFrameArrays",
"(",
"name",
")",
"def",
"a... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_ascii | Create an in memory DataFrame from an ascii file (whitespace seperated by default).
>>> ds = vx.from_ascii("table.asc")
>>> ds = vx.from_ascii("table.csv", seperator=",", names=["x", "y", "z"])
:param path: file path
:param seperator: value seperator, by default whitespace, use "," for comma seperated... | packages/vaex-core/vaex/__init__.py | def from_ascii(path, seperator=None, names=True, skip_lines=0, skip_after=0, **kwargs):
"""
Create an in memory DataFrame from an ascii file (whitespace seperated by default).
>>> ds = vx.from_ascii("table.asc")
>>> ds = vx.from_ascii("table.csv", seperator=",", names=["x", "y", "z"])
:param path:... | def from_ascii(path, seperator=None, names=True, skip_lines=0, skip_after=0, **kwargs):
"""
Create an in memory DataFrame from an ascii file (whitespace seperated by default).
>>> ds = vx.from_ascii("table.asc")
>>> ds = vx.from_ascii("table.csv", seperator=",", names=["x", "y", "z"])
:param path:... | [
"Create",
"an",
"in",
"memory",
"DataFrame",
"from",
"an",
"ascii",
"file",
"(",
"whitespace",
"seperated",
"by",
"default",
")",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L374-L404 | [
"def",
"from_ascii",
"(",
"path",
",",
"seperator",
"=",
"None",
",",
"names",
"=",
"True",
",",
"skip_lines",
"=",
"0",
",",
"skip_after",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"vaex",
".",
"ext",
".",
"readcol",
"as",
"rc",
"ds",... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | from_csv | Shortcut to read a csv file using pandas and convert to a DataFrame directly.
:rtype: DataFrame | packages/vaex-core/vaex/__init__.py | def from_csv(filename_or_buffer, copy_index=True, **kwargs):
"""Shortcut to read a csv file using pandas and convert to a DataFrame directly.
:rtype: DataFrame
"""
import pandas as pd
return from_pandas(pd.read_csv(filename_or_buffer, **kwargs), copy_index=copy_index) | def from_csv(filename_or_buffer, copy_index=True, **kwargs):
"""Shortcut to read a csv file using pandas and convert to a DataFrame directly.
:rtype: DataFrame
"""
import pandas as pd
return from_pandas(pd.read_csv(filename_or_buffer, **kwargs), copy_index=copy_index) | [
"Shortcut",
"to",
"read",
"a",
"csv",
"file",
"using",
"pandas",
"and",
"convert",
"to",
"a",
"DataFrame",
"directly",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L407-L413 | [
"def",
"from_csv",
"(",
"filename_or_buffer",
",",
"copy_index",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"pandas",
"as",
"pd",
"return",
"from_pandas",
"(",
"pd",
".",
"read_csv",
"(",
"filename_or_buffer",
",",
"*",
"*",
"kwargs",
")",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | read_csv_and_convert | Convert a path (or glob pattern) to a single hdf5 file, will open the hdf5 file if exists.
Example:
>>> vaex.read_csv_and_convert('test-*.csv', shuffle=True) # this may take a while
>>> vaex.read_csv_and_convert('test-*.csv', shuffle=True) # 2nd time it is instant
:param str path: pa... | packages/vaex-core/vaex/__init__.py | def read_csv_and_convert(path, shuffle=False, copy_index=True, **kwargs):
'''Convert a path (or glob pattern) to a single hdf5 file, will open the hdf5 file if exists.
Example:
>>> vaex.read_csv_and_convert('test-*.csv', shuffle=True) # this may take a while
>>> vaex.read_csv_and_conve... | def read_csv_and_convert(path, shuffle=False, copy_index=True, **kwargs):
'''Convert a path (or glob pattern) to a single hdf5 file, will open the hdf5 file if exists.
Example:
>>> vaex.read_csv_and_convert('test-*.csv', shuffle=True) # this may take a while
>>> vaex.read_csv_and_conve... | [
"Convert",
"a",
"path",
"(",
"or",
"glob",
"pattern",
")",
"to",
"a",
"single",
"hdf5",
"file",
"will",
"open",
"the",
"hdf5",
"file",
"if",
"exists",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L421-L462 | [
"def",
"read_csv_and_convert",
"(",
"path",
",",
"shuffle",
"=",
"False",
",",
"copy_index",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"concurrent",
".",
"futures",
"import",
"ProcessPoolExecutor",
"import",
"pandas",
"as",
"pd",
"filenames",
"... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | server | Connect to hostname supporting the vaex web api.
:param str hostname: hostname or ip address of server
:return vaex.dataframe.ServerRest: returns a server object, note that it does not connect to the server yet, so this will always succeed
:rtype: ServerRest | packages/vaex-core/vaex/__init__.py | def server(url, **kwargs):
"""Connect to hostname supporting the vaex web api.
:param str hostname: hostname or ip address of server
:return vaex.dataframe.ServerRest: returns a server object, note that it does not connect to the server yet, so this will always succeed
:rtype: ServerRest
"""
fr... | def server(url, **kwargs):
"""Connect to hostname supporting the vaex web api.
:param str hostname: hostname or ip address of server
:return vaex.dataframe.ServerRest: returns a server object, note that it does not connect to the server yet, so this will always succeed
:rtype: ServerRest
"""
fr... | [
"Connect",
"to",
"hostname",
"supporting",
"the",
"vaex",
"web",
"api",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L474-L491 | [
"def",
"server",
"(",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"vaex",
".",
"remote",
"import",
"ServerRest",
"url",
"=",
"urlparse",
"(",
"url",
")",
"if",
"url",
".",
"scheme",
"==",
"\"ws\"",
":",
"websocket",
"=",
"True",
"else",
":",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | example | Returns an example DataFrame which comes with vaex for testing/learning purposes.
:rtype: DataFrame | packages/vaex-core/vaex/__init__.py | def example(download=True):
"""Returns an example DataFrame which comes with vaex for testing/learning purposes.
:rtype: DataFrame
"""
from . import utils
path = utils.get_data_file("helmi-dezeeuw-2000-10p.hdf5")
if path is None and download:
return vaex.datasets.helmi_de_zeeuw_10percen... | def example(download=True):
"""Returns an example DataFrame which comes with vaex for testing/learning purposes.
:rtype: DataFrame
"""
from . import utils
path = utils.get_data_file("helmi-dezeeuw-2000-10p.hdf5")
if path is None and download:
return vaex.datasets.helmi_de_zeeuw_10percen... | [
"Returns",
"an",
"example",
"DataFrame",
"which",
"comes",
"with",
"vaex",
"for",
"testing",
"/",
"learning",
"purposes",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L494-L503 | [
"def",
"example",
"(",
"download",
"=",
"True",
")",
":",
"from",
".",
"import",
"utils",
"path",
"=",
"utils",
".",
"get_data_file",
"(",
"\"helmi-dezeeuw-2000-10p.hdf5\"",
")",
"if",
"path",
"is",
"None",
"and",
"download",
":",
"return",
"vaex",
".",
"d... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | zeldovich | Creates a zeldovich DataFrame. | packages/vaex-core/vaex/__init__.py | def zeldovich(dim=2, N=256, n=-2.5, t=None, scale=1, seed=None):
"""Creates a zeldovich DataFrame.
"""
import vaex.file
return vaex.file.other.Zeldovich(dim=dim, N=N, n=n, t=t, scale=scale) | def zeldovich(dim=2, N=256, n=-2.5, t=None, scale=1, seed=None):
"""Creates a zeldovich DataFrame.
"""
import vaex.file
return vaex.file.other.Zeldovich(dim=dim, N=N, n=n, t=t, scale=scale) | [
"Creates",
"a",
"zeldovich",
"DataFrame",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L506-L510 | [
"def",
"zeldovich",
"(",
"dim",
"=",
"2",
",",
"N",
"=",
"256",
",",
"n",
"=",
"-",
"2.5",
",",
"t",
"=",
"None",
",",
"scale",
"=",
"1",
",",
"seed",
"=",
"None",
")",
":",
"import",
"vaex",
".",
"file",
"return",
"vaex",
".",
"file",
".",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | concat | Concatenate a list of DataFrames.
:rtype: DataFrame | packages/vaex-core/vaex/__init__.py | def concat(dfs):
'''Concatenate a list of DataFrames.
:rtype: DataFrame
'''
ds = reduce((lambda x, y: x.concat(y)), dfs)
return ds | def concat(dfs):
'''Concatenate a list of DataFrames.
:rtype: DataFrame
'''
ds = reduce((lambda x, y: x.concat(y)), dfs)
return ds | [
"Concatenate",
"a",
"list",
"of",
"DataFrames",
"."
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L579-L585 | [
"def",
"concat",
"(",
"dfs",
")",
":",
"ds",
"=",
"reduce",
"(",
"(",
"lambda",
"x",
",",
"y",
":",
"x",
".",
"concat",
"(",
"y",
")",
")",
",",
"dfs",
")",
"return",
"ds"
] | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | vrange | Creates a virtual column which is the equivalent of numpy.arange, but uses 0 memory | packages/vaex-core/vaex/__init__.py | def vrange(start, stop, step=1, dtype='f8'):
"""Creates a virtual column which is the equivalent of numpy.arange, but uses 0 memory"""
from .column import ColumnVirtualRange
return ColumnVirtualRange(start, stop, step, dtype) | def vrange(start, stop, step=1, dtype='f8'):
"""Creates a virtual column which is the equivalent of numpy.arange, but uses 0 memory"""
from .column import ColumnVirtualRange
return ColumnVirtualRange(start, stop, step, dtype) | [
"Creates",
"a",
"virtual",
"column",
"which",
"is",
"the",
"equivalent",
"of",
"numpy",
".",
"arange",
"but",
"uses",
"0",
"memory"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/__init__.py#L587-L590 | [
"def",
"vrange",
"(",
"start",
",",
"stop",
",",
"step",
"=",
"1",
",",
"dtype",
"=",
"'f8'",
")",
":",
"from",
".",
"column",
"import",
"ColumnVirtualRange",
"return",
"ColumnVirtualRange",
"(",
"start",
",",
"stop",
",",
"step",
",",
"dtype",
")"
] | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
test | main | if 1:
# app = guisupport.get_app_qt4()
print_process_id()
# Create an in-process kernel
# >>> print_process_id( )
# will print the same process ID as the main process
kernel_manager = QtInProcessKernelManager()
kernel_manager.start_kernel()
kernel = ker... | packages/vaex-ui/vaex/ui/main.py | def main(argv=sys.argv[1:]):
global main_thread
global vaex
global app
global kernel
global ipython_console
global current
vaex.set_log_level_warning()
if app is None:
app = QtGui.QApplication(argv)
if not (frozen and darwin): # osx app has its own icon file
... | def main(argv=sys.argv[1:]):
global main_thread
global vaex
global app
global kernel
global ipython_console
global current
vaex.set_log_level_warning()
if app is None:
app = QtGui.QApplication(argv)
if not (frozen and darwin): # osx app has its own icon file
... | [
"if",
"1",
":",
"#",
"app",
"=",
"guisupport",
".",
"get_app_qt4",
"()",
"print_process_id",
"()"
] | vaexio/vaex | python | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-ui/vaex/ui/main.py#L1980-L2058 | [
"def",
"main",
"(",
"argv",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
":",
"global",
"main_thread",
"global",
"vaex",
"global",
"app",
"global",
"kernel",
"global",
"ipython_console",
"global",
"current",
"vaex",
".",
"set_log_level_warning",
"(",
... | a45b672f8287afca2ada8e36b74b604b9b28dd85 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.