hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1ce34cb86abfa41a1846a9486c25fdd87a456f44 | ntoand/DeepDeblur | BaseModel.py | [
"MIT"
] | Python | _BNRelu | <not_specific> | def _BNRelu(self, x):
"""Helper to build a BN with relu block
"""
x = BatchNormalization()(x)
return Activation("relu")(x) | Helper to build a BN with relu block
| Helper to build a BN with relu block | [
"Helper",
"to",
"build",
"a",
"BN",
"with",
"relu",
"block"
] | def _BNRelu(self, x):
x = BatchNormalization()(x)
return Activation("relu")(x) | [
"def",
"_BNRelu",
"(",
"self",
",",
"x",
")",
":",
"x",
"=",
"BatchNormalization",
"(",
")",
"(",
"x",
")",
"return",
"Activation",
"(",
"\"relu\"",
")",
"(",
"x",
")"
] | Helper to build a BN with relu block | [
"Helper",
"to",
"build",
"a",
"BN",
"with",
"relu",
"block"
] | [
"\"\"\"Helper to build a BN with relu block\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
1ce34cb86abfa41a1846a9486c25fdd87a456f44 | ntoand/DeepDeblur | BaseModel.py | [
"MIT"
] | Python | DeblurResidualNet | <not_specific> | def DeblurResidualNet(self, input_shape, num_block):
'''Base residual net network for deblur.
'''
input_x = Input(shape=input_shape)
# Model
# trainable flag just for debug
self.trainable = True
#self.trainable = False
self.kernel_size = (25, 25)
... | Base residual net network for deblur.
| Base residual net network for deblur. | [
"Base",
"residual",
"net",
"network",
"for",
"deblur",
"."
] | def DeblurResidualNet(self, input_shape, num_block):
input_x = Input(shape=input_shape)
self.trainable = True
self.kernel_size = (25, 25)
self.padding = "valid"
layer_25by25 = self._ConvBNRelu(input_x)
self.kernel_size = (3, 3)
self.padding = "same"
shortc... | [
"def",
"DeblurResidualNet",
"(",
"self",
",",
"input_shape",
",",
"num_block",
")",
":",
"input_x",
"=",
"Input",
"(",
"shape",
"=",
"input_shape",
")",
"self",
".",
"trainable",
"=",
"True",
"self",
".",
"kernel_size",
"=",
"(",
"25",
",",
"25",
")",
... | Base residual net network for deblur. | [
"Base",
"residual",
"net",
"network",
"for",
"deblur",
"."
] | [
"'''Base residual net network for deblur.\n '''",
"# Model",
"# trainable flag just for debug",
"#self.trainable = False"
] | [
{
"param": "self",
"type": null
},
{
"param": "input_shape",
"type": null
},
{
"param": "num_block",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_shape",
"type": null,
"docstring": null,
"docstring_tok... |
1ce34cb86abfa41a1846a9486c25fdd87a456f44 | ntoand/DeepDeblur | BaseModel.py | [
"MIT"
] | Python | DeblurSHCNet | <not_specific> | def DeblurSHCNet(self, input_shape, num_block):
'''Base SHC net network for deblur.
'''
input_x = Input(shape=input_shape)
# Model
# trainable flag just for debug
self.trainable = True
#self.trainable = False
self.kernel_size = (25, 25)
self.pad... | Base SHC net network for deblur.
| Base SHC net network for deblur. | [
"Base",
"SHC",
"net",
"network",
"for",
"deblur",
"."
] | def DeblurSHCNet(self, input_shape, num_block):
input_x = Input(shape=input_shape)
self.trainable = True
self.kernel_size = (25, 25)
self.padding = "valid"
layer_25by25 = self._ConvBNRelu(input_x)
self.kernel_size = (3, 3)
self.padding = "same"
shortcut = ... | [
"def",
"DeblurSHCNet",
"(",
"self",
",",
"input_shape",
",",
"num_block",
")",
":",
"input_x",
"=",
"Input",
"(",
"shape",
"=",
"input_shape",
")",
"self",
".",
"trainable",
"=",
"True",
"self",
".",
"kernel_size",
"=",
"(",
"25",
",",
"25",
")",
"self... | Base SHC net network for deblur. | [
"Base",
"SHC",
"net",
"network",
"for",
"deblur",
"."
] | [
"'''Base SHC net network for deblur.\n '''",
"# Model",
"# trainable flag just for debug",
"#self.trainable = False"
] | [
{
"param": "self",
"type": null
},
{
"param": "input_shape",
"type": null
},
{
"param": "num_block",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "input_shape",
"type": null,
"docstring": null,
"docstring_tok... |
dfc1ab3b557a615be727edc40e0f7954e08655f4 | ContinuumIO/pyalge | alge.py | [
"BSD-2-Clause"
] | Python | otherwise | null | def otherwise(self, value):
"""Default is to raise MissingCaseError exception with `value` as
argument.
Can be overridden.
"""
raise MissingCaseError(value) | Default is to raise MissingCaseError exception with `value` as
argument.
Can be overridden.
| Default is to raise MissingCaseError exception with `value` as
argument.
Can be overridden. | [
"Default",
"is",
"to",
"raise",
"MissingCaseError",
"exception",
"with",
"`",
"value",
"`",
"as",
"argument",
".",
"Can",
"be",
"overridden",
"."
] | def otherwise(self, value):
raise MissingCaseError(value) | [
"def",
"otherwise",
"(",
"self",
",",
"value",
")",
":",
"raise",
"MissingCaseError",
"(",
"value",
")"
] | Default is to raise MissingCaseError exception with `value` as
argument. | [
"Default",
"is",
"to",
"raise",
"MissingCaseError",
"exception",
"with",
"`",
"value",
"`",
"as",
"argument",
"."
] | [
"\"\"\"Default is to raise MissingCaseError exception with `value` as\n argument.\n\n Can be overridden.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "value",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "value",
"type": null,
"docstring": null,
"docstring_tokens": ... |
dfc1ab3b557a615be727edc40e0f7954e08655f4 | ContinuumIO/pyalge | alge.py | [
"BSD-2-Clause"
] | Python | __process | <not_specific> | def __process(self):
"""The actual matching/dispatch.
Returns the result of the match.
"""
ofs = self._case_ofs
for case in ofs:
res = case(self)
if res is not NoMatch:
# Matches
return res
# Run default
ret... | The actual matching/dispatch.
Returns the result of the match.
| The actual matching/dispatch.
Returns the result of the match. | [
"The",
"actual",
"matching",
"/",
"dispatch",
".",
"Returns",
"the",
"result",
"of",
"the",
"match",
"."
] | def __process(self):
ofs = self._case_ofs
for case in ofs:
res = case(self)
if res is not NoMatch:
return res
return self.otherwise(self.value) | [
"def",
"__process",
"(",
"self",
")",
":",
"ofs",
"=",
"self",
".",
"_case_ofs",
"for",
"case",
"in",
"ofs",
":",
"res",
"=",
"case",
"(",
"self",
")",
"if",
"res",
"is",
"not",
"NoMatch",
":",
"return",
"res",
"return",
"self",
".",
"otherwise",
"... | The actual matching/dispatch. | [
"The",
"actual",
"matching",
"/",
"dispatch",
"."
] | [
"\"\"\"The actual matching/dispatch.\n Returns the result of the match.\n \"\"\"",
"# Matches",
"# Run default"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
dfc1ab3b557a615be727edc40e0f7954e08655f4 | ContinuumIO/pyalge | alge.py | [
"BSD-2-Clause"
] | Python | of | <not_specific> | def of(pat):
"""Decorator for methods of Case to describe the pattern.
Args
----
pat: str
Patterns are like writing tuples (of tuples (of ...)) for the type
structure to match against. Names starting with a lowercase letter are
used as binding slots that the matcher will capture and used ... | Decorator for methods of Case to describe the pattern.
Args
----
pat: str
Patterns are like writing tuples (of tuples (of ...)) for the type
structure to match against. Names starting with a lowercase letter are
used as binding slots that the matcher will capture and used as argument
to t... | Decorator for methods of Case to describe the pattern.
Args
str
Patterns are like writing tuples (of tuples (of ...)) for the type
structure to match against. Names starting with a lowercase letter are
used as binding slots that the matcher will capture and used as argument
to the action function, the function being... | [
"Decorator",
"for",
"methods",
"of",
"Case",
"to",
"describe",
"the",
"pattern",
".",
"Args",
"str",
"Patterns",
"are",
"like",
"writing",
"tuples",
"(",
"of",
"tuples",
"(",
"of",
"...",
"))",
"for",
"the",
"type",
"structure",
"to",
"match",
"against",
... | def of(pat):
glbls = inspect.currentframe().f_back.f_globals
parser = _PatternParser(pat, glbls)
parser.parse()
codes = []
keepalive = tuple(parser.result.gen_match())
stacksz = 2
for m in keepalive:
codes.extend(m.codify())
stacksz += m.stackuse()
codes = tuple(codes)
... | [
"def",
"of",
"(",
"pat",
")",
":",
"glbls",
"=",
"inspect",
".",
"currentframe",
"(",
")",
".",
"f_back",
".",
"f_globals",
"parser",
"=",
"_PatternParser",
"(",
"pat",
",",
"glbls",
")",
"parser",
".",
"parse",
"(",
")",
"codes",
"=",
"[",
"]",
"k... | Decorator for methods of Case to describe the pattern. | [
"Decorator",
"for",
"methods",
"of",
"Case",
"to",
"describe",
"the",
"pattern",
"."
] | [
"\"\"\"Decorator for methods of Case to describe the pattern.\n\n Args\n ----\n pat: str\n\n Patterns are like writing tuples (of tuples (of ...)) for the type\n structure to match against. Names starting with a lowercase letter are\n used as binding slots that the matcher will capture and used a... | [
{
"param": "pat",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pat",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
73248d7ddebb8f73e9511002616eea5d48964ce4 | ContinuumIO/pyalge | test.py | [
"BSD-2-Clause"
] | Python | branch | null | def branch(self, a, b):
"""Search the leftmost subtree first.
Then, try the right subtree
"""
print("at", self.value)
yield self.recurse(a)
yield self.recurse(b) | Search the leftmost subtree first.
Then, try the right subtree
| Search the leftmost subtree first.
Then, try the right subtree | [
"Search",
"the",
"leftmost",
"subtree",
"first",
".",
"Then",
"try",
"the",
"right",
"subtree"
] | def branch(self, a, b):
print("at", self.value)
yield self.recurse(a)
yield self.recurse(b) | [
"def",
"branch",
"(",
"self",
",",
"a",
",",
"b",
")",
":",
"print",
"(",
"\"at\"",
",",
"self",
".",
"value",
")",
"yield",
"self",
".",
"recurse",
"(",
"a",
")",
"yield",
"self",
".",
"recurse",
"(",
"b",
")"
] | Search the leftmost subtree first. | [
"Search",
"the",
"leftmost",
"subtree",
"first",
"."
] | [
"\"\"\"Search the leftmost subtree first.\n Then, try the right subtree\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "a",
"type": null
},
{
"param": "b",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "a",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | decode_time_values | <not_specific> | def decode_time_values(dataset, time_var_name):
''' Decode NetCDF time values into Python datetime objects.
:param dataset: The dataset from which time values should be extracted.
:type dataset: netCDF4.Dataset
:param time_var_name: The name of the time variable in dataset.
:type time_var_name: :mo... | Decode NetCDF time values into Python datetime objects.
:param dataset: The dataset from which time values should be extracted.
:type dataset: netCDF4.Dataset
:param time_var_name: The name of the time variable in dataset.
:type time_var_name: :mod:`string`
:returns: The list of converted datetim... | Decode NetCDF time values into Python datetime objects. | [
"Decode",
"NetCDF",
"time",
"values",
"into",
"Python",
"datetime",
"objects",
"."
] | def decode_time_values(dataset, time_var_name):
time_data = dataset.variables[time_var_name]
time_format = time_data.units
if time_format[-1].lower() == 'z':
time_format = time_format[:-1]
if time_format[-3:].lower() == 'utc':
time_format = time_format[:-3]
time_units = parse_time_un... | [
"def",
"decode_time_values",
"(",
"dataset",
",",
"time_var_name",
")",
":",
"time_data",
"=",
"dataset",
".",
"variables",
"[",
"time_var_name",
"]",
"time_format",
"=",
"time_data",
".",
"units",
"if",
"time_format",
"[",
"-",
"1",
"]",
".",
"lower",
"(",
... | Decode NetCDF time values into Python datetime objects. | [
"Decode",
"NetCDF",
"time",
"values",
"into",
"Python",
"datetime",
"objects",
"."
] | [
"''' Decode NetCDF time values into Python datetime objects.\n\n :param dataset: The dataset from which time values should be extracted.\n :type dataset: netCDF4.Dataset\n :param time_var_name: The name of the time variable in dataset.\n :type time_var_name: :mod:`string`\n\n :returns: The list of co... | [
{
"param": "dataset",
"type": null
},
{
"param": "time_var_name",
"type": null
}
] | {
"returns": [
{
"docstring": "The list of converted datetime values.",
"docstring_tokens": [
"The",
"list",
"of",
"converted",
"datetime",
"values",
"."
],
"type": null
}
],
"raises": [
{
"docstring": "If the time u... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | parse_time_base | <not_specific> | def parse_time_base(time_format):
''' Parse time base object from the time units string.
:param time_format: The time data units string from the dataset
being processed. The string should be of the format
'<units> since <base time date>'
:type time_format: :mod:`string`
:returns: The b... | Parse time base object from the time units string.
:param time_format: The time data units string from the dataset
being processed. The string should be of the format
'<units> since <base time date>'
:type time_format: :mod:`string`
:returns: The base time as a datetime object.
:rais... | Parse time base object from the time units string. | [
"Parse",
"time",
"base",
"object",
"from",
"the",
"time",
"units",
"string",
"."
] | def parse_time_base(time_format):
base_time_string = parse_base_time_string(time_format)
time_format = time_format.strip()
possible_time_formats = [
'%Y:%m:%d %H:%M:%S', '%Y-%m-%d %H-%M-%S', '%Y/%m/%d %H/%M/%S',
'%Y-%m-%d %H:%M:%S', '%Y/%m/%d %H:%M:%S', '%Y%m%d %H:%M:%S',
'%Y%m%d%H%M... | [
"def",
"parse_time_base",
"(",
"time_format",
")",
":",
"base_time_string",
"=",
"parse_base_time_string",
"(",
"time_format",
")",
"time_format",
"=",
"time_format",
".",
"strip",
"(",
")",
"possible_time_formats",
"=",
"[",
"'%Y:%m:%d %H:%M:%S'",
",",
"'%Y-%m-%d %H-... | Parse time base object from the time units string. | [
"Parse",
"time",
"base",
"object",
"from",
"the",
"time",
"units",
"string",
"."
] | [
"''' Parse time base object from the time units string.\n\n :param time_format: The time data units string from the dataset\n being processed. The string should be of the format\n '<units> since <base time date>'\n :type time_format: :mod:`string`\n\n :returns: The base time as a datetime obj... | [
{
"param": "time_format",
"type": null
}
] | {
"returns": [
{
"docstring": "The base time as a datetime object.",
"docstring_tokens": [
"The",
"base",
"time",
"as",
"a",
"datetime",
"object",
"."
],
"type": null
}
],
"raises": [
{
"docstring": "When the... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | reshape_monthly_to_annually | <not_specific> | def reshape_monthly_to_annually(dataset):
''' Reshape monthly binned dataset to annual bins.
Reshape a monthly binned dataset's 3D value array with shape
(num_months, num_lats, num_lons) to a 4D array with shape
(num_years, 12, num_lats, num_lons). This causes the data to be binned
annually while r... | Reshape monthly binned dataset to annual bins.
Reshape a monthly binned dataset's 3D value array with shape
(num_months, num_lats, num_lons) to a 4D array with shape
(num_years, 12, num_lats, num_lons). This causes the data to be binned
annually while retaining its original shape.
It is assumed t... | Reshape monthly binned dataset to annual bins.
Reshape a monthly binned dataset's 3D value array with shape
(num_months, num_lats, num_lons) to a 4D array with shape
(num_years, 12, num_lats, num_lons). This causes the data to be binned
annually while retaining its original shape.
It is assumed that the number of mont... | [
"Reshape",
"monthly",
"binned",
"dataset",
"to",
"annual",
"bins",
".",
"Reshape",
"a",
"monthly",
"binned",
"dataset",
"'",
"s",
"3D",
"value",
"array",
"with",
"shape",
"(",
"num_months",
"num_lats",
"num_lons",
")",
"to",
"a",
"4D",
"array",
"with",
"sh... | def reshape_monthly_to_annually(dataset):
values = dataset.values[:]
data_shape = values.shape
num_total_month = data_shape[0]
num_year = num_total_month // 12
if num_total_month % 12 != 0:
raise ValueError("Number of months in dataset ({}) does not "
"divide evenly ... | [
"def",
"reshape_monthly_to_annually",
"(",
"dataset",
")",
":",
"values",
"=",
"dataset",
".",
"values",
"[",
":",
"]",
"data_shape",
"=",
"values",
".",
"shape",
"num_total_month",
"=",
"data_shape",
"[",
"0",
"]",
"num_year",
"=",
"num_total_month",
"//",
... | Reshape monthly binned dataset to annual bins. | [
"Reshape",
"monthly",
"binned",
"dataset",
"to",
"annual",
"bins",
"."
] | [
"''' Reshape monthly binned dataset to annual bins.\n\n Reshape a monthly binned dataset's 3D value array with shape\n (num_months, num_lats, num_lons) to a 4D array with shape\n (num_years, 12, num_lats, num_lons). This causes the data to be binned\n annually while retaining its original shape.\n\n ... | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "Dataset values array with shape (num_year, 12, num_lat, num_lon)",
"docstring_tokens": [
"Dataset",
"values",
"array",
"with",
"shape",
"(",
"num_year",
"12",
"num_lat",
"num_lon",
")... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calc_temporal_mean | <not_specific> | def calc_temporal_mean(dataset):
''' Calculate temporal mean of dataset's values
:param dataset: OCW Dataset whose first dimension is time
:type dataset: :class:`dataset.Dataset`
:returns: Mean values averaged for the first dimension (time)
'''
return ma.mean(dataset.values, axis=0) | Calculate temporal mean of dataset's values
:param dataset: OCW Dataset whose first dimension is time
:type dataset: :class:`dataset.Dataset`
:returns: Mean values averaged for the first dimension (time)
| Calculate temporal mean of dataset's values | [
"Calculate",
"temporal",
"mean",
"of",
"dataset",
"'",
"s",
"values"
] | def calc_temporal_mean(dataset):
return ma.mean(dataset.values, axis=0) | [
"def",
"calc_temporal_mean",
"(",
"dataset",
")",
":",
"return",
"ma",
".",
"mean",
"(",
"dataset",
".",
"values",
",",
"axis",
"=",
"0",
")"
] | Calculate temporal mean of dataset's values | [
"Calculate",
"temporal",
"mean",
"of",
"dataset",
"'",
"s",
"values"
] | [
"''' Calculate temporal mean of dataset's values\n\n :param dataset: OCW Dataset whose first dimension is time\n :type dataset: :class:`dataset.Dataset`\n\n :returns: Mean values averaged for the first dimension (time)\n '''"
] | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "Mean values averaged for the first dimension (time)",
"docstring_tokens": [
"Mean",
"values",
"averaged",
"for",
"the",
"first",
"dimension",
"(",
"time",
")"
],
"type": null
... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calc_climatology_monthly | <not_specific> | def calc_climatology_monthly(dataset):
''' Calculate monthly mean values for a dataset.
Follow COARDS climo stats calculation, the year can be given as 0
but the min year allowed in Python is 1
http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology
:param dataset: Monthly binned Datas... | Calculate monthly mean values for a dataset.
Follow COARDS climo stats calculation, the year can be given as 0
but the min year allowed in Python is 1
http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology
:param dataset: Monthly binned Dataset object with the number of months
di... | Calculate monthly mean values for a dataset. | [
"Calculate",
"monthly",
"mean",
"values",
"for",
"a",
"dataset",
"."
] | def calc_climatology_monthly(dataset):
if dataset.values.shape[0] % 12:
error = (
"The length of the time axis in the values array should be "
"divisible by 12."
)
raise ValueError(error)
else:
values = reshape_monthly_to_annually(dataset).mean(axis=0)
... | [
"def",
"calc_climatology_monthly",
"(",
"dataset",
")",
":",
"if",
"dataset",
".",
"values",
".",
"shape",
"[",
"0",
"]",
"%",
"12",
":",
"error",
"=",
"(",
"\"The length of the time axis in the values array should be \"",
"\"divisible by 12.\"",
")",
"raise",
"Valu... | Calculate monthly mean values for a dataset. | [
"Calculate",
"monthly",
"mean",
"values",
"for",
"a",
"dataset",
"."
] | [
"''' Calculate monthly mean values for a dataset.\n Follow COARDS climo stats calculation, the year can be given as 0\n but the min year allowed in Python is 1\n http://www.cgd.ucar.edu/cms/eaton/netcdf/CF-20010629.htm#climatology\n\n :param dataset: Monthly binned Dataset object with the number of mont... | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "Mean values for each month of the year of shape\n(12, num_lats, num_lons) and times array of datetime objects\nof length 12",
"docstring_tokens": [
"Mean",
"values",
"for",
"each",
"month",
"of",
"the",
"yea... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calc_time_series | <not_specific> | def calc_time_series(dataset):
''' Calculate time series mean values for a dataset
:param dataset: Dataset object
:type dataset: :class:`dataset.Dataset`
:returns: time series for the dataset of shape (nT)
'''
t_series = []
for t in range(dataset.values.shape[0]):
t_series.append(... | Calculate time series mean values for a dataset
:param dataset: Dataset object
:type dataset: :class:`dataset.Dataset`
:returns: time series for the dataset of shape (nT)
| Calculate time series mean values for a dataset | [
"Calculate",
"time",
"series",
"mean",
"values",
"for",
"a",
"dataset"
] | def calc_time_series(dataset):
t_series = []
for t in range(dataset.values.shape[0]):
t_series.append(dataset.values[t, :, :].mean())
return t_series | [
"def",
"calc_time_series",
"(",
"dataset",
")",
":",
"t_series",
"=",
"[",
"]",
"for",
"t",
"in",
"range",
"(",
"dataset",
".",
"values",
".",
"shape",
"[",
"0",
"]",
")",
":",
"t_series",
".",
"append",
"(",
"dataset",
".",
"values",
"[",
"t",
","... | Calculate time series mean values for a dataset | [
"Calculate",
"time",
"series",
"mean",
"values",
"for",
"a",
"dataset"
] | [
"''' Calculate time series mean values for a dataset\n\n :param dataset: Dataset object\n :type dataset: :class:`dataset.Dataset`\n\n :returns: time series for the dataset of shape (nT)\n '''"
] | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "time series for the dataset of shape (nT)",
"docstring_tokens": [
"time",
"series",
"for",
"the",
"dataset",
"of",
"shape",
"(",
"nT",
")"
],
"type": null
}
],
"raises": [... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | adjust_model_years_for_climatology_calculation | <not_specific> | def adjust_model_years_for_climatology_calculation(dataset_array):
''' Using the time length of the first element in the input dataset_array,
adjust years in the rest ofi the dataset_array so that every dataset ends in the same year.
:param dataset_array: an array of OCW datasets
'''
slc = trim... | Using the time length of the first element in the input dataset_array,
adjust years in the rest ofi the dataset_array so that every dataset ends in the same year.
:param dataset_array: an array of OCW datasets
| Using the time length of the first element in the input dataset_array,
adjust years in the rest ofi the dataset_array so that every dataset ends in the same year. | [
"Using",
"the",
"time",
"length",
"of",
"the",
"first",
"element",
"in",
"the",
"input",
"dataset_array",
"adjust",
"years",
"in",
"the",
"rest",
"ofi",
"the",
"dataset_array",
"so",
"that",
"every",
"dataset",
"ends",
"in",
"the",
"same",
"year",
"."
] | def adjust_model_years_for_climatology_calculation(dataset_array):
slc = trim_dataset(dataset_array[0])
obs_times = dataset_array[0].times[slc]
for idata, dataset in enumerate(dataset_array[1:]):
year_diff = obs_times[-1].year - dataset.times[-1].year
nt = dataset.times.size
for ... | [
"def",
"adjust_model_years_for_climatology_calculation",
"(",
"dataset_array",
")",
":",
"slc",
"=",
"trim_dataset",
"(",
"dataset_array",
"[",
"0",
"]",
")",
"obs_times",
"=",
"dataset_array",
"[",
"0",
"]",
".",
"times",
"[",
"slc",
"]",
"for",
"idata",
",",... | Using the time length of the first element in the input dataset_array,
adjust years in the rest ofi the dataset_array so that every dataset ends in the same year. | [
"Using",
"the",
"time",
"length",
"of",
"the",
"first",
"element",
"in",
"the",
"input",
"dataset_array",
"adjust",
"years",
"in",
"the",
"rest",
"ofi",
"the",
"dataset_array",
"so",
"that",
"every",
"dataset",
"ends",
"in",
"the",
"same",
"year",
"."
] | [
"''' Using the time length of the first element in the input dataset_array, \n adjust years in the rest ofi the dataset_array so that every dataset ends in the same year.\n :param dataset_array: an array of OCW datasets\n '''"
] | [
{
"param": "dataset_array",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dataset_array",
"type": null,
"docstring": "an array of OCW datasets",
"docstring_tokens": [
"an",
"array",
"of",
"OCW",
"datasets"
],
"default": null,
"is_optional": n... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | trim_dataset | <not_specific> | def trim_dataset(dataset):
''' Trim datasets such that first and last year of data have all 12 months
:param dataset: Dataset object
:type dataset: :class:`dataset.Dataset`
:returns: Slice index for trimmed dataset
'''
start_time, end_time = dataset.temporal_boundaries()
start_month = 13 i... | Trim datasets such that first and last year of data have all 12 months
:param dataset: Dataset object
:type dataset: :class:`dataset.Dataset`
:returns: Slice index for trimmed dataset
| Trim datasets such that first and last year of data have all 12 months | [
"Trim",
"datasets",
"such",
"that",
"first",
"and",
"last",
"year",
"of",
"data",
"have",
"all",
"12",
"months"
] | def trim_dataset(dataset):
start_time, end_time = dataset.temporal_boundaries()
start_month = 13 if start_time.month == 1 else start_time.month
end_month = 0 if end_time.month == 12 else end_time.month
slc = slice(13 - start_month, len(dataset.times) - end_month)
return slc | [
"def",
"trim_dataset",
"(",
"dataset",
")",
":",
"start_time",
",",
"end_time",
"=",
"dataset",
".",
"temporal_boundaries",
"(",
")",
"start_month",
"=",
"13",
"if",
"start_time",
".",
"month",
"==",
"1",
"else",
"start_time",
".",
"month",
"end_month",
"=",... | Trim datasets such that first and last year of data have all 12 months | [
"Trim",
"datasets",
"such",
"that",
"first",
"and",
"last",
"year",
"of",
"data",
"have",
"all",
"12",
"months"
] | [
"''' Trim datasets such that first and last year of data have all 12 months\n\n :param dataset: Dataset object\n :type dataset: :class:`dataset.Dataset`\n\n :returns: Slice index for trimmed dataset\n '''"
] | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "Slice index for trimmed dataset",
"docstring_tokens": [
"Slice",
"index",
"for",
"trimmed",
"dataset"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dataset",
"type": null,
... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calc_subregion_area_mean_and_std | <not_specific> | def calc_subregion_area_mean_and_std(dataset_array, subregions):
''' Calculate area mean and standard deviation values for a given \
subregions using datasets on common grid points
:param dataset_array: An array of OCW Dataset Objects \
:type list: :mod:'list'
:param subregions: list of subreg... | Calculate area mean and standard deviation values for a given \
subregions using datasets on common grid points
:param dataset_array: An array of OCW Dataset Objects \
:type list: :mod:'list'
:param subregions: list of subregions \
:type subregions: :class:`numpy.ma.array`
:returns: area... | Calculate area mean and standard deviation values for a given \
subregions using datasets on common grid points | [
"Calculate",
"area",
"mean",
"and",
"standard",
"deviation",
"values",
"for",
"a",
"given",
"\\",
"subregions",
"using",
"datasets",
"on",
"common",
"grid",
"points"
] | def calc_subregion_area_mean_and_std(dataset_array, subregions):
ndata = len(dataset_array)
dataset0 = dataset_array[0]
if dataset0.lons.ndim == 1:
lons, lats = np.meshgrid(dataset0.lons, dataset0.lats)
else:
lons = dataset0.lons
lats = dataset0.lats
subregion_array = np.zero... | [
"def",
"calc_subregion_area_mean_and_std",
"(",
"dataset_array",
",",
"subregions",
")",
":",
"ndata",
"=",
"len",
"(",
"dataset_array",
")",
"dataset0",
"=",
"dataset_array",
"[",
"0",
"]",
"if",
"dataset0",
".",
"lons",
".",
"ndim",
"==",
"1",
":",
"lons",... | Calculate area mean and standard deviation values for a given \
subregions using datasets on common grid points | [
"Calculate",
"area",
"mean",
"and",
"standard",
"deviation",
"values",
"for",
"a",
"given",
"\\",
"subregions",
"using",
"datasets",
"on",
"common",
"grid",
"points"
] | [
"''' Calculate area mean and standard deviation values for a given \\\n subregions using datasets on common grid points\n\n :param dataset_array: An array of OCW Dataset Objects \\\n :type list: :mod:'list'\n\n :param subregions: list of subregions \\\n :type subregions: :class:`numpy.ma.array`\n... | [
{
"param": "dataset_array",
"type": null
},
{
"param": "subregions",
"type": null
}
] | {
"returns": [
{
"docstring": "area averaged time series for the dataset of shape \\\n(ntime, nsubregion)",
"docstring_tokens": [
"area",
"averaged",
"time",
"series",
"for",
"the",
"dataset",
"of",
"shape",
"\\",
... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calc_area_weighted_spatial_average | <not_specific> | def calc_area_weighted_spatial_average(dataset, area_weight=False):
'''Calculate area weighted average of the values in OCW dataset
:param dataset: Dataset object
:type dataset: :class:`dataset.Dataset`
:returns: time series for the dataset of shape (nT)
'''
if dataset.lats.ndim == 1:
... | Calculate area weighted average of the values in OCW dataset
:param dataset: Dataset object
:type dataset: :class:`dataset.Dataset`
:returns: time series for the dataset of shape (nT)
| Calculate area weighted average of the values in OCW dataset | [
"Calculate",
"area",
"weighted",
"average",
"of",
"the",
"values",
"in",
"OCW",
"dataset"
] | def calc_area_weighted_spatial_average(dataset, area_weight=False):
if dataset.lats.ndim == 1:
lons, lats = np.meshgrid(dataset.lons, dataset.lats)
else:
lats = dataset.lats
weights = np.cos(lats * np.pi / 180.)
nt, ny, nx = dataset.values.shape
spatial_average = ma.zeros(nt)
for... | [
"def",
"calc_area_weighted_spatial_average",
"(",
"dataset",
",",
"area_weight",
"=",
"False",
")",
":",
"if",
"dataset",
".",
"lats",
".",
"ndim",
"==",
"1",
":",
"lons",
",",
"lats",
"=",
"np",
".",
"meshgrid",
"(",
"dataset",
".",
"lons",
",",
"datase... | Calculate area weighted average of the values in OCW dataset | [
"Calculate",
"area",
"weighted",
"average",
"of",
"the",
"values",
"in",
"OCW",
"dataset"
] | [
"'''Calculate area weighted average of the values in OCW dataset\n\n :param dataset: Dataset object\n :type dataset: :class:`dataset.Dataset`\n\n :returns: time series for the dataset of shape (nT)\n '''"
] | [
{
"param": "dataset",
"type": null
},
{
"param": "area_weight",
"type": null
}
] | {
"returns": [
{
"docstring": "time series for the dataset of shape (nT)",
"docstring_tokens": [
"time",
"series",
"for",
"the",
"dataset",
"of",
"shape",
"(",
"nT",
")"
],
"type": null
}
],
"raises": [... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | _force_unicode | <not_specific> | def _force_unicode(s, encoding='utf-8'):
'''
If the input is bytes, convert to unicode, otherwise return the input
'''
if hasattr(s, 'decode'):
s = s.decode(encoding=encoding)
return s |
If the input is bytes, convert to unicode, otherwise return the input
| If the input is bytes, convert to unicode, otherwise return the input | [
"If",
"the",
"input",
"is",
"bytes",
"convert",
"to",
"unicode",
"otherwise",
"return",
"the",
"input"
] | def _force_unicode(s, encoding='utf-8'):
if hasattr(s, 'decode'):
s = s.decode(encoding=encoding)
return s | [
"def",
"_force_unicode",
"(",
"s",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"hasattr",
"(",
"s",
",",
"'decode'",
")",
":",
"s",
"=",
"s",
".",
"decode",
"(",
"encoding",
"=",
"encoding",
")",
"return",
"s"
] | If the input is bytes, convert to unicode, otherwise return the input | [
"If",
"the",
"input",
"is",
"bytes",
"convert",
"to",
"unicode",
"otherwise",
"return",
"the",
"input"
] | [
"'''\n If the input is bytes, convert to unicode, otherwise return the input\n '''"
] | [
{
"param": "s",
"type": null
},
{
"param": "encoding",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "encoding",
"type": null,
"docstring": null,
"docstring_tokens": ... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calculate_temporal_trends | <not_specific> | def calculate_temporal_trends(dataset):
''' Calculate temporal trends in dataset.values
:param dataset: The dataset from which time values should be extracted.
:type dataset: :class:`dataset.Dataset`
:returns: Arrays of the temporal trend and standard error
:rtype: :class:`numpy.ma.core.MaskedArray... | Calculate temporal trends in dataset.values
:param dataset: The dataset from which time values should be extracted.
:type dataset: :class:`dataset.Dataset`
:returns: Arrays of the temporal trend and standard error
:rtype: :class:`numpy.ma.core.MaskedArray`
| Calculate temporal trends in dataset.values | [
"Calculate",
"temporal",
"trends",
"in",
"dataset",
".",
"values"
] | def calculate_temporal_trends(dataset):
nt, ny, nx = dataset.values.shape
x = np.arange(nt)
trend = np.zeros([ny, nx])-999.
slope_err = np.zeros([ny, nx])-999.
for iy in np.arange(ny):
for ix in np.arange(nx):
if dataset.values[:,iy,ix].count() == nt:
trend[iy,ix]... | [
"def",
"calculate_temporal_trends",
"(",
"dataset",
")",
":",
"nt",
",",
"ny",
",",
"nx",
"=",
"dataset",
".",
"values",
".",
"shape",
"x",
"=",
"np",
".",
"arange",
"(",
"nt",
")",
"trend",
"=",
"np",
".",
"zeros",
"(",
"[",
"ny",
",",
"nx",
"]"... | Calculate temporal trends in dataset.values | [
"Calculate",
"temporal",
"trends",
"in",
"dataset",
".",
"values"
] | [
"''' Calculate temporal trends in dataset.values\n :param dataset: The dataset from which time values should be extracted.\n :type dataset: :class:`dataset.Dataset`\n\n :returns: Arrays of the temporal trend and standard error\n :rtype: :class:`numpy.ma.core.MaskedArray`\n '''"
] | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "Arrays of the temporal trend and standard error",
"docstring_tokens": [
"Arrays",
"of",
"the",
"temporal",
"trend",
"and",
"standard",
"error"
],
"type": ":class:`numpy.ma.core.MaskedArray`"
... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calculate_ensemble_temporal_trends | <not_specific> | def calculate_ensemble_temporal_trends(timeseries_array, number_of_samples=1000):
''' Calculate temporal trends in an ensemble of time series
:param timeseries_array: Two dimensional array. 1st index: model, 2nd index: time.
:type timeseries_array: :class:`numpy.ndarray`
:param sampling: A list whose e... | Calculate temporal trends in an ensemble of time series
:param timeseries_array: Two dimensional array. 1st index: model, 2nd index: time.
:type timeseries_array: :class:`numpy.ndarray`
:param sampling: A list whose elements are one-dimensional numpy arrays
:type timeseries_array: :class:`list`
:... | Calculate temporal trends in an ensemble of time series | [
"Calculate",
"temporal",
"trends",
"in",
"an",
"ensemble",
"of",
"time",
"series"
] | def calculate_ensemble_temporal_trends(timeseries_array, number_of_samples=1000):
nmodels, nt = timeseries_array.shape
x = np.arange(nt)
sampled_trend = np.zeros(number_of_samples)
ensemble_trend, _ = calculate_temporal_trend_of_time_series(
x, np.mean(timeseries_array, axis=0))
... | [
"def",
"calculate_ensemble_temporal_trends",
"(",
"timeseries_array",
",",
"number_of_samples",
"=",
"1000",
")",
":",
"nmodels",
",",
"nt",
"=",
"timeseries_array",
".",
"shape",
"x",
"=",
"np",
".",
"arange",
"(",
"nt",
")",
"sampled_trend",
"=",
"np",
".",
... | Calculate temporal trends in an ensemble of time series | [
"Calculate",
"temporal",
"trends",
"in",
"an",
"ensemble",
"of",
"time",
"series"
] | [
"''' Calculate temporal trends in an ensemble of time series\n :param timeseries_array: Two dimensional array. 1st index: model, 2nd index: time.\n :type timeseries_array: :class:`numpy.ndarray`\n\n :param sampling: A list whose elements are one-dimensional numpy arrays\n :type timeseries_array: :class:... | [
{
"param": "timeseries_array",
"type": null
},
{
"param": "number_of_samples",
"type": null
}
] | {
"returns": [
{
"docstring": "temporal trend and estimated error from bootstrapping",
"docstring_tokens": [
"temporal",
"trend",
"and",
"estimated",
"error",
"from",
"bootstrapping"
],
"type": ":class:`float`, :class:`float`"
}
... |
df0324f91ac4ee4210a2a3d456a315bc2053df2d | mastermindharsh/climate | ocw/utils.py | [
"Apache-2.0"
] | Python | calculate_daily_climatology | <not_specific> | def calculate_daily_climatology(dataset):
'''Calculate daily climatology from the input dataset
:param dataset: The dataset to convert.
:type dataset: :class:`dataset.Dataset`
:returns: values_clim
:rtype: 3d masked numpy array.shape (number of unique days, y, x)
'''
days = [d.month * 100. ... | Calculate daily climatology from the input dataset
:param dataset: The dataset to convert.
:type dataset: :class:`dataset.Dataset`
:returns: values_clim
:rtype: 3d masked numpy array.shape (number of unique days, y, x)
| Calculate daily climatology from the input dataset | [
"Calculate",
"daily",
"climatology",
"from",
"the",
"input",
"dataset"
] | def calculate_daily_climatology(dataset):
days = [d.month * 100. + d.day for d in dataset.times]
days_sorted = np.unique(days)
ndays = days_sorted.size
nt, ny, nx = dataset.values.shape
values_clim = ma.zeros([ndays, ny, nx])
for iday, day in enumerate(days_sorted):
t_index = np.where(da... | [
"def",
"calculate_daily_climatology",
"(",
"dataset",
")",
":",
"days",
"=",
"[",
"d",
".",
"month",
"*",
"100.",
"+",
"d",
".",
"day",
"for",
"d",
"in",
"dataset",
".",
"times",
"]",
"days_sorted",
"=",
"np",
".",
"unique",
"(",
"days",
")",
"ndays"... | Calculate daily climatology from the input dataset | [
"Calculate",
"daily",
"climatology",
"from",
"the",
"input",
"dataset"
] | [
"'''Calculate daily climatology from the input dataset\n :param dataset: The dataset to convert.\n :type dataset: :class:`dataset.Dataset`\n :returns: values_clim\n :rtype: 3d masked numpy array.shape (number of unique days, y, x)\n '''"
] | [
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": "3d masked numpy array.shape (number of unique days, y, x)"
}
],
"raises": [],
"params": [
{
"identifier": "dataset",
"type": null,
"docstring": "The dataset to convert.",
... |
3a03c9274fa4894ac01be505f01f80cef80dbb67 | mastermindharsh/climate | obs4MIPs/obs4MIPs_process.py | [
"Apache-2.0"
] | Python | process | <not_specific> | def process( rc ):
'''
Convert netcdf/matlab/grads files into CMIP5 format.
'''
pdb.set_trace()
# ----------------------------
# Loop yearly on file list.
# ----------------------------
file_template = rc['file_template'].split(",");
if( len(file_template) == 2 ):
template... |
Convert netcdf/matlab/grads files into CMIP5 format.
| Convert netcdf/matlab/grads files into CMIP5 format. | [
"Convert",
"netcdf",
"/",
"matlab",
"/",
"grads",
"files",
"into",
"CMIP5",
"format",
"."
] | def process( rc ):
pdb.set_trace()
file_template = rc['file_template'].split(",");
if( len(file_template) == 2 ):
template_parameter = file_template[1]
rc['file_template'] = file_template[0]
else:
template_parameter = 'years'
for year in rc[template_parameter].split(","):
... | [
"def",
"process",
"(",
"rc",
")",
":",
"pdb",
".",
"set_trace",
"(",
")",
"file_template",
"=",
"rc",
"[",
"'file_template'",
"]",
".",
"split",
"(",
"\",\"",
")",
";",
"if",
"(",
"len",
"(",
"file_template",
")",
"==",
"2",
")",
":",
"template_param... | Convert netcdf/matlab/grads files into CMIP5 format. | [
"Convert",
"netcdf",
"/",
"matlab",
"/",
"grads",
"files",
"into",
"CMIP5",
"format",
"."
] | [
"'''\n Convert netcdf/matlab/grads files into CMIP5 format.\n '''",
"# ----------------------------",
"# Loop yearly on file list. ",
"# ----------------------------",
"# ------------------------------------------------",
"# Use string formating for path with same argument ",
"# ----------------... | [
{
"param": "rc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "rc",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3a03c9274fa4894ac01be505f01f80cef80dbb67 | mastermindharsh/climate | obs4MIPs/obs4MIPs_process.py | [
"Apache-2.0"
] | Python | createTime | <not_specific> | def createTime(Handler, rc):
'''
InputtimeUnits: specified from resource file or from first file
in a list of file.
return relative time and time bounds using OutputTimeUnits from
resource file.
'''
# ----------------------------------------------------
# Retrieve time units from fi... |
InputtimeUnits: specified from resource file or from first file
in a list of file.
return relative time and time bounds using OutputTimeUnits from
resource file.
| specified from resource file or from first file
in a list of file.
return relative time and time bounds using OutputTimeUnits from
resource file. | [
"specified",
"from",
"resource",
"file",
"or",
"from",
"first",
"file",
"in",
"a",
"list",
"of",
"file",
".",
"return",
"relative",
"time",
"and",
"time",
"bounds",
"using",
"OutputTimeUnits",
"from",
"resource",
"file",
"."
] | def createTime(Handler, rc):
InputTimeUnits = Handler.getTimeUnits(rc['InputTimeUnits'])
cur_time = Handler.getTime(InputTimeUnits)
rel_time =[cur_time[i].torel(rc['OutputTimeUnits']).value
for i in range(len(cur_time))]
if( len(rel_time) == 1 ) :
deltarel = 1
else:
... | [
"def",
"createTime",
"(",
"Handler",
",",
"rc",
")",
":",
"InputTimeUnits",
"=",
"Handler",
".",
"getTimeUnits",
"(",
"rc",
"[",
"'InputTimeUnits'",
"]",
")",
"cur_time",
"=",
"Handler",
".",
"getTime",
"(",
"InputTimeUnits",
")",
"rel_time",
"=",
"[",
"cu... | InputtimeUnits: specified from resource file or from first file
in a list of file. | [
"InputtimeUnits",
":",
"specified",
"from",
"resource",
"file",
"or",
"from",
"first",
"file",
"in",
"a",
"list",
"of",
"file",
"."
] | [
"'''\n InputtimeUnits: specified from resource file or from first file\n in a list of file.\n \n return relative time and time bounds using OutputTimeUnits from\n resource file.\n '''",
"# ----------------------------------------------------",
"# Retrieve time units from file if not provided i... | [
{
"param": "Handler",
"type": null
},
{
"param": "rc",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "Handler",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "rc",
"type": null,
"docstring": null,
"docstring_tokens": ... |
e559e2a63b2a584e51acd674556e88da67715835 | mastermindharsh/climate | obs4MIPs/Toolbox/ESGFexcel.py | [
"Apache-2.0"
] | Python | ReadXCL | <not_specific> | def ReadXCL(self):
'''
Read Excel Table and fill rc variable related field.
'''
try:
import xlrd
except:
print("****** Could not find xlrd Python Package ****")
print("****** Please install xlrd package to read excel files ****")
if( os.p... |
Read Excel Table and fill rc variable related field.
| Read Excel Table and fill rc variable related field. | [
"Read",
"Excel",
"Table",
"and",
"fill",
"rc",
"variable",
"related",
"field",
"."
] | def ReadXCL(self):
try:
import xlrd
except:
print("****** Could not find xlrd Python Package ****")
print("****** Please install xlrd package to read excel files ****")
if( os.path.isfile(self.xcl) ):
wb=xlrd.open_workbook(self.xcl)
else:
... | [
"def",
"ReadXCL",
"(",
"self",
")",
":",
"try",
":",
"import",
"xlrd",
"except",
":",
"print",
"(",
"\"****** Could not find xlrd Python Package ****\"",
")",
"print",
"(",
"\"****** Please install xlrd package to read excel files ****\"",
")",
"if",
"(",
"os",
".",
"... | Read Excel Table and fill rc variable related field. | [
"Read",
"Excel",
"Table",
"and",
"fill",
"rc",
"variable",
"related",
"field",
"."
] | [
"'''\n Read Excel Table and fill rc variable related field.\n '''",
"# -----------------------------------------------------------------",
"# Make sure it is a string. The main program will call eval on it.",
"# -----------------------------------------------------------------"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0286daadd9ca4c4416ba833320b804a05d3eac6b | mtakahiro/niriss_ghost | niriss_ghost/utils.py | [
"BSD-3-Clause"
] | Python | check_keyword | <not_specific> | def check_keyword(file_cat, keywords, keys_str=None):
'''
file_cat : str
Ascii catalog to be used.
keywords : list
list of strings for keywords to be checked.
'''
flag = True
fd_cat = ascii.read(file_cat)
for kk,key in enumerate(keywords):
try:
value_tmp =... |
file_cat : str
Ascii catalog to be used.
keywords : list
list of strings for keywords to be checked.
| file_cat : str
Ascii catalog to be used.
keywords : list
list of strings for keywords to be checked. | [
"file_cat",
":",
"str",
"Ascii",
"catalog",
"to",
"be",
"used",
".",
"keywords",
":",
"list",
"list",
"of",
"strings",
"for",
"keywords",
"to",
"be",
"checked",
"."
] | def check_keyword(file_cat, keywords, keys_str=None):
flag = True
fd_cat = ascii.read(file_cat)
for kk,key in enumerate(keywords):
try:
value_tmp = fd_cat[key]
except:
print('\n!!! Warning !!!\n`%s` column is not found in the input catalog.'%key)
flag = Fa... | [
"def",
"check_keyword",
"(",
"file_cat",
",",
"keywords",
",",
"keys_str",
"=",
"None",
")",
":",
"flag",
"=",
"True",
"fd_cat",
"=",
"ascii",
".",
"read",
"(",
"file_cat",
")",
"for",
"kk",
",",
"key",
"in",
"enumerate",
"(",
"keywords",
")",
":",
"... | file_cat : str
Ascii catalog to be used. | [
"file_cat",
":",
"str",
"Ascii",
"catalog",
"to",
"be",
"used",
"."
] | [
"'''\n file_cat : str\n Ascii catalog to be used.\n keywords : list\n list of strings for keywords to be checked.\n '''"
] | [
{
"param": "file_cat",
"type": null
},
{
"param": "keywords",
"type": null
},
{
"param": "keys_str",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_cat",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "keywords",
"type": null,
"docstring": null,
"docstring_to... |
0286daadd9ca4c4416ba833320b804a05d3eac6b | mtakahiro/niriss_ghost | niriss_ghost/utils.py | [
"BSD-3-Clause"
] | Python | tweak_dq | <not_specific> | def tweak_dq(id_gst, infile, segfile, outfile=None, DQ_SET=1, DQ_KEY='DQ'):
'''
Purpose
-------
To make a copy of input fits file and tweak its DQ array.
'''
if not outfile == None:
outfile = infile.replace('.fits','_gst.fits')
try:
dq_array = fits.open(infile)[DQ_KEY]
e... |
Purpose
-------
To make a copy of input fits file and tweak its DQ array.
| Purpose
To make a copy of input fits file and tweak its DQ array. | [
"Purpose",
"To",
"make",
"a",
"copy",
"of",
"input",
"fits",
"file",
"and",
"tweak",
"its",
"DQ",
"array",
"."
] | def tweak_dq(id_gst, infile, segfile, outfile=None, DQ_SET=1, DQ_KEY='DQ'):
if not outfile == None:
outfile = infile.replace('.fits','_gst.fits')
try:
dq_array = fits.open(infile)[DQ_KEY]
except:
print('DQ array, `%s`, not found. No DQ tweaking.'%DQ_KEY)
return False
os.s... | [
"def",
"tweak_dq",
"(",
"id_gst",
",",
"infile",
",",
"segfile",
",",
"outfile",
"=",
"None",
",",
"DQ_SET",
"=",
"1",
",",
"DQ_KEY",
"=",
"'DQ'",
")",
":",
"if",
"not",
"outfile",
"==",
"None",
":",
"outfile",
"=",
"infile",
".",
"replace",
"(",
"... | Purpose
To make a copy of input fits file and tweak its DQ array. | [
"Purpose",
"To",
"make",
"a",
"copy",
"of",
"input",
"fits",
"file",
"and",
"tweak",
"its",
"DQ",
"array",
"."
] | [
"'''\n Purpose\n -------\n To make a copy of input fits file and tweak its DQ array.\n '''",
"# 1073741824",
"#hdul[DQ_KEY].data[con] += DQ_SET",
"# changes are written back to original.fits"
] | [
{
"param": "id_gst",
"type": null
},
{
"param": "infile",
"type": null
},
{
"param": "segfile",
"type": null
},
{
"param": "outfile",
"type": null
},
{
"param": "DQ_SET",
"type": null
},
{
"param": "DQ_KEY",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id_gst",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "infile",
"type": null,
"docstring": null,
"docstring_tokens... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | init_clustering_props | null | def init_clustering_props(self):
"""Fetch configuration parameters for image clustering with K-Means unsupervised learning"""
# Flag to enable or disable clustering with K-Means.
self.do_clustering = self.config.getboolean('clustering', 'cluster')
# To which labeled image should the cl... | Fetch configuration parameters for image clustering with K-Means unsupervised learning | Fetch configuration parameters for image clustering with K-Means unsupervised learning | [
"Fetch",
"configuration",
"parameters",
"for",
"image",
"clustering",
"with",
"K",
"-",
"Means",
"unsupervised",
"learning"
] | def init_clustering_props(self):
self.do_clustering = self.config.getboolean('clustering', 'cluster')
self.cluster_for_labels = json.loads(self.config.get('clustering', 'cluster_for_labels'))
self.cluster_k = self.config.getint('clustering', 'cluster_k')
self.cluster_collect_threshold = ... | [
"def",
"init_clustering_props",
"(",
"self",
")",
":",
"self",
".",
"do_clustering",
"=",
"self",
".",
"config",
".",
"getboolean",
"(",
"'clustering'",
",",
"'cluster'",
")",
"self",
".",
"cluster_for_labels",
"=",
"json",
".",
"loads",
"(",
"self",
".",
... | Fetch configuration parameters for image clustering with K-Means unsupervised learning | [
"Fetch",
"configuration",
"parameters",
"for",
"image",
"clustering",
"with",
"K",
"-",
"Means",
"unsupervised",
"learning"
] | [
"\"\"\"Fetch configuration parameters for image clustering with K-Means unsupervised learning\"\"\"",
"# Flag to enable or disable clustering with K-Means.",
"# To which labeled image should the clustering apply to.",
"# The K value for the K-Means algorithm.",
"# How many training images need to be collect... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | is_daytime | <not_specific> | def is_daytime(self, ephem_lat, ephem_lng, dt):
"""Check if it's daytime at the given location for the given time."""
try:
# Create an Observer object.
observer = ephem.Observer()
# Set the observer to the given location and time.
observer.lat = ephem_la... | Check if it's daytime at the given location for the given time. | Check if it's daytime at the given location for the given time. | [
"Check",
"if",
"it",
"'",
"s",
"daytime",
"at",
"the",
"given",
"location",
"for",
"the",
"given",
"time",
"."
] | def is_daytime(self, ephem_lat, ephem_lng, dt):
try:
observer = ephem.Observer()
observer.lat = ephem_lat
observer.long = ephem_lng
observer.date = ephem.Date(dt)
sun = ephem.Sun()
sun.compute(observer)
return sun.alt > 0
... | [
"def",
"is_daytime",
"(",
"self",
",",
"ephem_lat",
",",
"ephem_lng",
",",
"dt",
")",
":",
"try",
":",
"observer",
"=",
"ephem",
".",
"Observer",
"(",
")",
"observer",
".",
"lat",
"=",
"ephem_lat",
"observer",
".",
"long",
"=",
"ephem_lng",
"observer",
... | Check if it's daytime at the given location for the given time. | [
"Check",
"if",
"it",
"'",
"s",
"daytime",
"at",
"the",
"given",
"location",
"for",
"the",
"given",
"time",
"."
] | [
"\"\"\"Check if it's daytime at the given location for the given time.\"\"\"",
"# Create an Observer object.",
"# Set the observer to the given location and time.",
"# Create a Sun object.",
"# Compute the sun's position with respect to the observer.",
"# If the sun is above the observer then it's daytime... | [
{
"param": "self",
"type": null
},
{
"param": "ephem_lat",
"type": null
},
{
"param": "ephem_lng",
"type": null
},
{
"param": "dt",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ephem_lat",
"type": null,
"docstring": null,
"docstring_token... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | collect_metadata | <not_specific> | def collect_metadata(self, filename_png, label, confidence, keep):
"""Collect metadata for the image acquired at the given timestamp."""
# Track if tle compuation is successful or not.
# If not successful then fallback to minimum metadata collection that does not depend on TLE.
tle_comp... | Collect metadata for the image acquired at the given timestamp. | Collect metadata for the image acquired at the given timestamp. | [
"Collect",
"metadata",
"for",
"the",
"image",
"acquired",
"at",
"the",
"given",
"timestamp",
"."
] | def collect_metadata(self, filename_png, label, confidence, keep):
tle_compute_success = False
timestamp = None
metadata = None
filename = filename_png.replace(BASE_PATH + "/", "").replace(".png", "")
try:
timestamp = int(re.match(".*" + IMG_FILENAME_PREFIX + "(\d+)_\... | [
"def",
"collect_metadata",
"(",
"self",
",",
"filename_png",
",",
"label",
",",
"confidence",
",",
"keep",
")",
":",
"tle_compute_success",
"=",
"False",
"timestamp",
"=",
"None",
"metadata",
"=",
"None",
"filename",
"=",
"filename_png",
".",
"replace",
"(",
... | Collect metadata for the image acquired at the given timestamp. | [
"Collect",
"metadata",
"for",
"the",
"image",
"acquired",
"at",
"the",
"given",
"timestamp",
"."
] | [
"\"\"\"Collect metadata for the image acquired at the given timestamp.\"\"\"",
"# Track if tle compuation is successful or not.",
"# If not successful then fallback to minimum metadata collection that does not depend on TLE.",
"# Image acquisition timestamp.",
"# The dictionary that will contain the image's... | [
{
"param": "self",
"type": null
},
{
"param": "filename_png",
"type": null
},
{
"param": "label",
"type": null
},
{
"param": "confidence",
"type": null
},
{
"param": "keep",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filename_png",
"type": null,
"docstring": null,
"docstring_to... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | is_point_in_polygon | <not_specific> | def is_point_in_polygon(self, lat, lng):
"""Check if given point coordinates is located inside the polygon defined in the GeoJSON file."""
# Default to False if GeoJSON file was not loaded.
if self.geojson is None:
return False
# Define a point based on the given longitude ... | Check if given point coordinates is located inside the polygon defined in the GeoJSON file. | Check if given point coordinates is located inside the polygon defined in the GeoJSON file. | [
"Check",
"if",
"given",
"point",
"coordinates",
"is",
"located",
"inside",
"the",
"polygon",
"defined",
"in",
"the",
"GeoJSON",
"file",
"."
] | def is_point_in_polygon(self, lat, lng):
if self.geojson is None:
return False
point = geometry.Point(lng, lat)
for feature in self.geojson['features']:
shape = geometry.shape(feature['geometry'])
if isinstance(shape, geometry.Polygon):
if pol... | [
"def",
"is_point_in_polygon",
"(",
"self",
",",
"lat",
",",
"lng",
")",
":",
"if",
"self",
".",
"geojson",
"is",
"None",
":",
"return",
"False",
"point",
"=",
"geometry",
".",
"Point",
"(",
"lng",
",",
"lat",
")",
"for",
"feature",
"in",
"self",
".",... | Check if given point coordinates is located inside the polygon defined in the GeoJSON file. | [
"Check",
"if",
"given",
"point",
"coordinates",
"is",
"located",
"inside",
"the",
"polygon",
"defined",
"in",
"the",
"GeoJSON",
"file",
"."
] | [
"\"\"\"Check if given point coordinates is located inside the polygon defined in the GeoJSON file.\"\"\"",
"# Default to False if GeoJSON file was not loaded.",
"# Define a point based on the given longitude and latitude.",
"# Check each feature to see if it contains the point.",
"# Features representing a ... | [
{
"param": "self",
"type": null
},
{
"param": "lat",
"type": null
},
{
"param": "lng",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lat",
"type": null,
"docstring": null,
"docstring_tokens": []... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | cleanup | <not_specific> | def cleanup(self):
"""Delete files created on the project's root directory while processing the acquired image.
These files could exist due to an unhandled error during a previous run so as a precaution
we also run this function prior to image acquisition.
"""
# Count the numb... | Delete files created on the project's root directory while processing the acquired image.
These files could exist due to an unhandled error during a previous run so as a precaution
we also run this function prior to image acquisition.
| Delete files created on the project's root directory while processing the acquired image.
These files could exist due to an unhandled error during a previous run so as a precaution
we also run this function prior to image acquisition. | [
"Delete",
"files",
"created",
"on",
"the",
"project",
"'",
"s",
"root",
"directory",
"while",
"processing",
"the",
"acquired",
"image",
".",
"These",
"files",
"could",
"exist",
"due",
"to",
"an",
"unhandled",
"error",
"during",
"a",
"previous",
"run",
"so",
... | def cleanup(self):
delete_count = 0
for ext in ['ims_rgb', 'png', 'jpeg', 'tar', 'tar.gz']:
img_files = glob.glob(BASE_PATH + "/*." + ext)
for f in img_files:
try:
os.remove(f)
delete_count = delete_count + 1
... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"delete_count",
"=",
"0",
"for",
"ext",
"in",
"[",
"'ims_rgb'",
",",
"'png'",
",",
"'jpeg'",
",",
"'tar'",
",",
"'tar.gz'",
"]",
":",
"img_files",
"=",
"glob",
".",
"glob",
"(",
"BASE_PATH",
"+",
"\"/*.\"",
"+... | Delete files created on the project's root directory while processing the acquired image. | [
"Delete",
"files",
"created",
"on",
"the",
"project",
"'",
"s",
"root",
"directory",
"while",
"processing",
"the",
"acquired",
"image",
"."
] | [
"\"\"\"Delete files created on the project's root directory while processing the acquired image.\n\n These files could exist due to an unhandled error during a previous run so as a precaution \n we also run this function prior to image acquisition.\n \"\"\"",
"# Count the number of files dele... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | move_images_for_keeping | null | def move_images_for_keeping(self, raw_keep, png_keep, applied_label):
"""Move the images to keep into to experiment's toGround folder."""
# Remove the raw image file if it is not flagged to be kept.
if not raw_keep:
cmd_remove_raw_image = 'rm ' + BASE_PATH + '/*.ims_rgb'
... | Move the images to keep into to experiment's toGround folder. | Move the images to keep into to experiment's toGround folder. | [
"Move",
"the",
"images",
"to",
"keep",
"into",
"to",
"experiment",
"'",
"s",
"toGround",
"folder",
"."
] | def move_images_for_keeping(self, raw_keep, png_keep, applied_label):
if not raw_keep:
cmd_remove_raw_image = 'rm ' + BASE_PATH + '/*.ims_rgb'
os.system(cmd_remove_raw_image)
if not png_keep:
cmd_remove_png_image = 'rm ' + BASE_PATH + '/*.png'
os.system(cm... | [
"def",
"move_images_for_keeping",
"(",
"self",
",",
"raw_keep",
",",
"png_keep",
",",
"applied_label",
")",
":",
"if",
"not",
"raw_keep",
":",
"cmd_remove_raw_image",
"=",
"'rm '",
"+",
"BASE_PATH",
"+",
"'/*.ims_rgb'",
"os",
".",
"system",
"(",
"cmd_remove_raw_... | Move the images to keep into to experiment's toGround folder. | [
"Move",
"the",
"images",
"to",
"keep",
"into",
"to",
"experiment",
"'",
"s",
"toGround",
"folder",
"."
] | [
"\"\"\"Move the images to keep into to experiment's toGround folder.\"\"\"",
"# Remove the raw image file if it is not flagged to be kept.",
"# Remove the png image file if it is not flagged to be kept.",
"# Remove the jpeg image that was used as an input for the image classification program.",
"# Create a ... | [
{
"param": "self",
"type": null
},
{
"param": "raw_keep",
"type": null
},
{
"param": "png_keep",
"type": null
},
{
"param": "applied_label",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "raw_keep",
"type": null,
"docstring": null,
"docstring_tokens... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | package_files_for_downlinking | <not_specific> | def package_files_for_downlinking(self, file_ext, downlink_log_if_no_images, do_clustering, experiment_start_time, files_from_previous_runs, do_logging):
"""Package the files for downlinking.
Logging is optional via the do_logging flag in case we start the experiment by tarring files leftover f... | Package the files for downlinking.
Logging is optional via the do_logging flag in case we start the experiment by tarring files leftover from a previous run that was abruptly interrupted.
In that case we don't want to prematurely write a new log file for the current experiment run or else it's ... | Package the files for downlinking.
Logging is optional via the do_logging flag in case we start the experiment by tarring files leftover from a previous run that was abruptly interrupted.
In that case we don't want to prematurely write a new log file for the current experiment run or else it's going to end up being tar... | [
"Package",
"the",
"files",
"for",
"downlinking",
".",
"Logging",
"is",
"optional",
"via",
"the",
"do_logging",
"flag",
"in",
"case",
"we",
"start",
"the",
"experiment",
"by",
"tarring",
"files",
"leftover",
"from",
"a",
"previous",
"run",
"that",
"was",
"abr... | def package_files_for_downlinking(self, file_ext, downlink_log_if_no_images, do_clustering, experiment_start_time, files_from_previous_runs, do_logging):
try:
tar_options = '-cf' if file_ext in SUPPORTED_COMPRESSION_TYPES else '-czf'
tar_ext = 'tar' if file_ext in SUPPORTED_COMPRESSION_T... | [
"def",
"package_files_for_downlinking",
"(",
"self",
",",
"file_ext",
",",
"downlink_log_if_no_images",
",",
"do_clustering",
",",
"experiment_start_time",
",",
"files_from_previous_runs",
",",
"do_logging",
")",
":",
"try",
":",
"tar_options",
"=",
"'-cf'",
"if",
"fi... | Package the files for downlinking. | [
"Package",
"the",
"files",
"for",
"downlinking",
"."
] | [
"\"\"\"Package the files for downlinking.\n \n Logging is optional via the do_logging flag in case we start the experiment by tarring files leftover from a previous run that was abruptly interrupted.\n In that case we don't want to prematurely write a new log file for the current experiment run... | [
{
"param": "self",
"type": null
},
{
"param": "file_ext",
"type": null
},
{
"param": "downlink_log_if_no_images",
"type": null
},
{
"param": "do_clustering",
"type": null
},
{
"param": "experiment_start_time",
"type": null
},
{
"param": "files_from_pre... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_ext",
"type": null,
"docstring": null,
"docstring_tokens... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | split_and_move_tar | null | def split_and_move_tar(self, tar_path, split_bytes):
"""Split packaged files for downlink and move the chunks to the filestore's toGround folder."""
# Thumbnail packages can be large when acquiring a lot of images.
# Split the tar file and save smaller chunks in filestore's toGround fol... | Split packaged files for downlink and move the chunks to the filestore's toGround folder. | Split packaged files for downlink and move the chunks to the filestore's toGround folder. | [
"Split",
"packaged",
"files",
"for",
"downlink",
"and",
"move",
"the",
"chunks",
"to",
"the",
"filestore",
"'",
"s",
"toGround",
"folder",
"."
] | def split_and_move_tar(self, tar_path, split_bytes):
cmd_split_tar = 'split -b {B} {T} {P}'.format(\
B=split_bytes,\
T=tar_path,\
P=FILESTORE_TOGROUND_PATH + "/" + ntpath.basename(tar_path) + "_")
os.system(cmd_split_tar)
chunk_counter = len(glob.glob1(FILESTO... | [
"def",
"split_and_move_tar",
"(",
"self",
",",
"tar_path",
",",
"split_bytes",
")",
":",
"cmd_split_tar",
"=",
"'split -b {B} {T} {P}'",
".",
"format",
"(",
"B",
"=",
"split_bytes",
",",
"T",
"=",
"tar_path",
",",
"P",
"=",
"FILESTORE_TOGROUND_PATH",
"+",
"\"/... | Split packaged files for downlink and move the chunks to the filestore's toGround folder. | [
"Split",
"packaged",
"files",
"for",
"downlink",
"and",
"move",
"the",
"chunks",
"to",
"the",
"filestore",
"'",
"s",
"toGround",
"folder",
"."
] | [
"\"\"\"Split packaged files for downlink and move the chunks to the filestore's toGround folder.\"\"\"",
"# Thumbnail packages can be large when acquiring a lot of images.",
"# Split the tar file and save smaller chunks in filestore's toGround folder.",
"# Move the split chunks of the tar package to filestore... | [
{
"param": "self",
"type": null
},
{
"param": "tar_path",
"type": null
},
{
"param": "split_bytes",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tar_path",
"type": null,
"docstring": null,
"docstring_tokens... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | log_housekeeping_data | null | def log_housekeeping_data(self):
"""Log some housekeeping data, i.e. the available disk space."""
# Disk usage.
df_output = subprocess.check_output(['df', '-h']).decode('utf-8')
logger.info('Disk usage:\n' + df_output) | Log some housekeeping data, i.e. the available disk space. | Log some housekeeping data, i.e. the available disk space. | [
"Log",
"some",
"housekeeping",
"data",
"i",
".",
"e",
".",
"the",
"available",
"disk",
"space",
"."
] | def log_housekeeping_data(self):
df_output = subprocess.check_output(['df', '-h']).decode('utf-8')
logger.info('Disk usage:\n' + df_output) | [
"def",
"log_housekeeping_data",
"(",
"self",
")",
":",
"df_output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'df'",
",",
"'-h'",
"]",
")",
".",
"decode",
"(",
"'utf-8'",
")",
"logger",
".",
"info",
"(",
"'Disk usage:\\n'",
"+",
"df_output",
")"
] | Log some housekeeping data, i.e. | [
"Log",
"some",
"housekeeping",
"data",
"i",
".",
"e",
"."
] | [
"\"\"\"Log some housekeeping data, i.e. the available disk space.\"\"\"",
"# Disk usage."
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | acquire_image | <not_specific> | def acquire_image(self):
"""Acquire an image with the on-board camera."""
# Build the image acquisition execution command string.
cmd_image_acquisition = 'ims100_testapp -R {R} -G {G} -B {B} -c /dev/cam_tty -m /dev/cam_sd -v 0 -n 1 -p -e {E} >> {L} 2>&1'.format(\
R=self.gains[0],\
... | Acquire an image with the on-board camera. | Acquire an image with the on-board camera. | [
"Acquire",
"an",
"image",
"with",
"the",
"on",
"-",
"board",
"camera",
"."
] | def acquire_image(self):
cmd_image_acquisition = 'ims100_testapp -R {R} -G {G} -B {B} -c /dev/cam_tty -m /dev/cam_sd -v 0 -n 1 -p -e {E} >> {L} 2>&1'.format(\
R=self.gains[0],\
G=self.gains[1],\
B=self.gains[2],\
E=self.exposure,\
L=LOG_FILE)
l... | [
"def",
"acquire_image",
"(",
"self",
")",
":",
"cmd_image_acquisition",
"=",
"'ims100_testapp -R {R} -G {G} -B {B} -c /dev/cam_tty -m /dev/cam_sd -v 0 -n 1 -p -e {E} >> {L} 2>&1'",
".",
"format",
"(",
"R",
"=",
"self",
".",
"gains",
"[",
"0",
"]",
",",
"G",
"=",
"self",... | Acquire an image with the on-board camera. | [
"Acquire",
"an",
"image",
"with",
"the",
"on",
"-",
"board",
"camera",
"."
] | [
"\"\"\"Acquire an image with the on-board camera.\"\"\"",
"# Build the image acquisition execution command string.",
"# Log the command that will be executed.",
"# Run the image acquisition command. ",
"# Check that png file exists...",
"# If the png file doesn't exist then skip this iteration.",
"# An ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | create_input_image | <not_specific> | def create_input_image(self, png_src_filename, jpeg_dest_filename, input_height, input_width, jpeg_scaling, jpeg_quality, jpeg_processing):
"""Create image file as an input to the image classifier."""
# Build the command string to create the image input for the image classification program.
# F... | Create image file as an input to the image classifier. | Create image file as an input to the image classifier. | [
"Create",
"image",
"file",
"as",
"an",
"input",
"to",
"the",
"image",
"classifier",
"."
] | def create_input_image(self, png_src_filename, jpeg_dest_filename, input_height, input_width, jpeg_scaling, jpeg_quality, jpeg_processing):
if jpeg_processing != 'none':
cmd_create_input_image = 'pngtopam {F} | pamscale -xsize {X} -ysize {Y} | {P} | pnmtojpeg -quality {Q} > {O}'.format(\
... | [
"def",
"create_input_image",
"(",
"self",
",",
"png_src_filename",
",",
"jpeg_dest_filename",
",",
"input_height",
",",
"input_width",
",",
"jpeg_scaling",
",",
"jpeg_quality",
",",
"jpeg_processing",
")",
":",
"if",
"jpeg_processing",
"!=",
"'none'",
":",
"cmd_crea... | Create image file as an input to the image classifier. | [
"Create",
"image",
"file",
"as",
"an",
"input",
"to",
"the",
"image",
"classifier",
"."
] | [
"\"\"\"Create image file as an input to the image classifier.\"\"\"",
"# Build the command string to create the image input for the image classification program.",
"# FIXME create input jpeg directly from the thumbnail jpeg instead of from the png. Maye require an ipk to install jpegtopnm.",
"# Log the comman... | [
{
"param": "self",
"type": null
},
{
"param": "png_src_filename",
"type": null
},
{
"param": "jpeg_dest_filename",
"type": null
},
{
"param": "input_height",
"type": null
},
{
"param": "input_width",
"type": null
},
{
"param": "jpeg_scaling",
"type... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "png_src_filename",
"type": null,
"docstring": null,
"docstrin... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | label_image | <not_specific> | def label_image(self, image_filename, model_tflite_filename, labels_filename, image_height, image_width, image_mean, image_std):
"""Label an image using the image classifier with the given model and labels files."""
try:
# Build the image labeling command.
cmd_label_image = '{P}... | Label an image using the image classifier with the given model and labels files. | Label an image using the image classifier with the given model and labels files. | [
"Label",
"an",
"image",
"using",
"the",
"image",
"classifier",
"with",
"the",
"given",
"model",
"and",
"labels",
"files",
"."
] | def label_image(self, image_filename, model_tflite_filename, labels_filename, image_height, image_width, image_mean, image_std):
try:
cmd_label_image = '{P} {I} {M} {L} {height} {width} {mean} {std}'.format(\
P=IMAGE_CLASSIFIER_BIN_PATH,\
I=image_filename,\
... | [
"def",
"label_image",
"(",
"self",
",",
"image_filename",
",",
"model_tflite_filename",
",",
"labels_filename",
",",
"image_height",
",",
"image_width",
",",
"image_mean",
",",
"image_std",
")",
":",
"try",
":",
"cmd_label_image",
"=",
"'{P} {I} {M} {L} {height} {widt... | Label an image using the image classifier with the given model and labels files. | [
"Label",
"an",
"image",
"using",
"the",
"image",
"classifier",
"with",
"the",
"given",
"model",
"and",
"labels",
"files",
"."
] | [
"\"\"\"Label an image using the image classifier with the given model and labels files.\"\"\"",
"# Build the image labeling command.",
"# Log the command that will be executed.",
"# Create a subprocess to execute the image classification program.",
"# Get program stdout.",
"# Get program return code.",
... | [
{
"param": "self",
"type": null
},
{
"param": "image_filename",
"type": null
},
{
"param": "model_tflite_filename",
"type": null
},
{
"param": "labels_filename",
"type": null
},
{
"param": "image_height",
"type": null
},
{
"param": "image_width",
"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "image_filename",
"type": null,
"docstring": null,
"docstring_... |
a947ef92576ebb3996abfb8e8f6538a7d2891796 | georgeslabreche/opssat-smartcam | home/exp1000/acquire_and_label_images.py | [
"MIT"
] | Python | cluster_labeled_images | null | def cluster_labeled_images(self, cluster_for_labels, k, training_data_size_threshold, image_types_to_cluster):
"""Train or apply K-Means clustering to subclassify images that have already been classifed byt the TensorFlow Lite classification pipeline."""
for label in cluster_for_labels:
# B... | Train or apply K-Means clustering to subclassify images that have already been classifed byt the TensorFlow Lite classification pipeline. | Train or apply K-Means clustering to subclassify images that have already been classifed byt the TensorFlow Lite classification pipeline. | [
"Train",
"or",
"apply",
"K",
"-",
"Means",
"clustering",
"to",
"subclassify",
"images",
"that",
"have",
"already",
"been",
"classifed",
"byt",
"the",
"TensorFlow",
"Lite",
"classification",
"pipeline",
"."
] | def cluster_labeled_images(self, cluster_for_labels, k, training_data_size_threshold, image_types_to_cluster):
for label in cluster_for_labels:
toGround_label_dir = TOGROUND_PATH + '/' + label
if os.path.exists(toGround_label_dir):
centroids_file_path = KMEANS_CENTROIDS_D... | [
"def",
"cluster_labeled_images",
"(",
"self",
",",
"cluster_for_labels",
",",
"k",
",",
"training_data_size_threshold",
",",
"image_types_to_cluster",
")",
":",
"for",
"label",
"in",
"cluster_for_labels",
":",
"toGround_label_dir",
"=",
"TOGROUND_PATH",
"+",
"'/'",
"+... | Train or apply K-Means clustering to subclassify images that have already been classifed byt the TensorFlow Lite classification pipeline. | [
"Train",
"or",
"apply",
"K",
"-",
"Means",
"clustering",
"to",
"subclassify",
"images",
"that",
"have",
"already",
"been",
"classifed",
"byt",
"the",
"TensorFlow",
"Lite",
"classification",
"pipeline",
"."
] | [
"\"\"\"Train or apply K-Means clustering to subclassify images that have already been classifed byt the TensorFlow Lite classification pipeline.\"\"\"",
"# Build the path to the labeled images that we want to cluster/sub-classify.",
"# Only cluster/sub-classify the labeled images of thumbnail images exist for t... | [
{
"param": "self",
"type": null
},
{
"param": "cluster_for_labels",
"type": null
},
{
"param": "k",
"type": null
},
{
"param": "training_data_size_threshold",
"type": null
},
{
"param": "image_types_to_cluster",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "cluster_for_labels",
"type": null,
"docstring": null,
"docstr... |
be4813daad18851280cef49055aa3dd3f24b0deb | thorwhalen/guise | guise/nlp.py | [
"Apache-2.0"
] | Python | stem_based_word_mapping | WordMap | def stem_based_word_mapping(
words: Words, stemmer: StemmerSpec = 'lancaster'
) -> WordMap:
"""Returns a dict of {word: replace_with_word, ...} mapping based on stemming.
stemming is great to reduce the number of words by replacing several
The words (or word counts) are stemmed, then for each stem, t... | Returns a dict of {word: replace_with_word, ...} mapping based on stemming.
stemming is great to reduce the number of words by replacing several
The words (or word counts) are stemmed, then for each stem, the word with the
highest count gets to represent the others.
>>> _words = ['happy', 'happier',... | Returns a dict of {word: replace_with_word, ...} mapping based on stemming.
stemming is great to reduce the number of words by replacing several
The words (or word counts) are stemmed, then for each stem, the word with the
highest count gets to represent the others.
| [
"Returns",
"a",
"dict",
"of",
"{",
"word",
":",
"replace_with_word",
"...",
"}",
"mapping",
"based",
"on",
"stemming",
".",
"stemming",
"is",
"great",
"to",
"reduce",
"the",
"number",
"of",
"words",
"by",
"replacing",
"several",
"The",
"words",
"(",
"or",
... | def stem_based_word_mapping(
words: Words, stemmer: StemmerSpec = 'lancaster'
) -> WordMap:
if not callable(stemmer):
from nltk.stem import PorterStemmer
from nltk.stem import LancasterStemmer
if stemmer is None:
stemmer = lambda word: word
elif isinstance(stemmer, st... | [
"def",
"stem_based_word_mapping",
"(",
"words",
":",
"Words",
",",
"stemmer",
":",
"StemmerSpec",
"=",
"'lancaster'",
")",
"->",
"WordMap",
":",
"if",
"not",
"callable",
"(",
"stemmer",
")",
":",
"from",
"nltk",
".",
"stem",
"import",
"PorterStemmer",
"from"... | Returns a dict of {word: replace_with_word, ...} mapping based on stemming. | [
"Returns",
"a",
"dict",
"of",
"{",
"word",
":",
"replace_with_word",
"...",
"}",
"mapping",
"based",
"on",
"stemming",
"."
] | [
"\"\"\"Returns a dict of {word: replace_with_word, ...} mapping based on stemming.\n\n stemming is great to reduce the number of words by replacing several\n\n\n The words (or word counts) are stemmed, then for each stem, the word with the\n highest count gets to represent the others.\n\n >>> _words = [... | [
{
"param": "words",
"type": "Words"
},
{
"param": "stemmer",
"type": "StemmerSpec"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "words",
"type": "Words",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "stemmer",
"type": "StemmerSpec",
"docstring": null,
"docs... |
b7bf7473e41db685e5a1707efe867d7788870911 | rpatil524/pybel | src/pybel/parser/utils.py | [
"MIT"
] | Python | is_int | bool | def is_int(s: Any) -> bool:
"""Determine if an object can be cast to an int.
:param s: any object
:return: true if argument can be cast to an int:
"""
try:
int(s)
return True
except ValueError:
return False | Determine if an object can be cast to an int.
:param s: any object
:return: true if argument can be cast to an int:
| Determine if an object can be cast to an int. | [
"Determine",
"if",
"an",
"object",
"can",
"be",
"cast",
"to",
"an",
"int",
"."
] | def is_int(s: Any) -> bool:
try:
int(s)
return True
except ValueError:
return False | [
"def",
"is_int",
"(",
"s",
":",
"Any",
")",
"->",
"bool",
":",
"try",
":",
"int",
"(",
"s",
")",
"return",
"True",
"except",
"ValueError",
":",
"return",
"False"
] | Determine if an object can be cast to an int. | [
"Determine",
"if",
"an",
"object",
"can",
"be",
"cast",
"to",
"an",
"int",
"."
] | [
"\"\"\"Determine if an object can be cast to an int.\n\n :param s: any object\n :return: true if argument can be cast to an int:\n \"\"\""
] | [
{
"param": "s",
"type": "Any"
}
] | {
"returns": [
{
"docstring": "true if argument can be cast to an int.",
"docstring_tokens": [
"true",
"if",
"argument",
"can",
"be",
"cast",
"to",
"an",
"int",
"."
],
"type": null
}
],
"raises": [],
... |
b7bf7473e41db685e5a1707efe867d7788870911 | rpatil524/pybel | src/pybel/parser/utils.py | [
"MIT"
] | Python | nest | <not_specific> | def nest(*content):
"""Define a delimited list by enumerating each element of the list."""
if len(content) == 0:
raise ValueError('no arguments supplied')
return And([LPF, content[0]] + list(itt.chain.from_iterable(zip(itt.repeat(C), content[1:]))) + [RPF]) | Define a delimited list by enumerating each element of the list. | Define a delimited list by enumerating each element of the list. | [
"Define",
"a",
"delimited",
"list",
"by",
"enumerating",
"each",
"element",
"of",
"the",
"list",
"."
] | def nest(*content):
if len(content) == 0:
raise ValueError('no arguments supplied')
return And([LPF, content[0]] + list(itt.chain.from_iterable(zip(itt.repeat(C), content[1:]))) + [RPF]) | [
"def",
"nest",
"(",
"*",
"content",
")",
":",
"if",
"len",
"(",
"content",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"'no arguments supplied'",
")",
"return",
"And",
"(",
"[",
"LPF",
",",
"content",
"[",
"0",
"]",
"]",
"+",
"list",
"(",
"itt... | Define a delimited list by enumerating each element of the list. | [
"Define",
"a",
"delimited",
"list",
"by",
"enumerating",
"each",
"element",
"of",
"the",
"list",
"."
] | [
"\"\"\"Define a delimited list by enumerating each element of the list.\"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | to_graphdati_file | None | def to_graphdati_file(graph: BELGraph, path: Union[str, TextIO], use_identifiers: bool = True, **kwargs) -> None:
"""Write this graph as GraphDati JSON to a file.
:param graph: A BEL graph
:param path: A path or file-like
"""
json.dump(to_graphdati(graph, use_identifiers=use_identifiers), path, ens... | Write this graph as GraphDati JSON to a file.
:param graph: A BEL graph
:param path: A path or file-like
| Write this graph as GraphDati JSON to a file. | [
"Write",
"this",
"graph",
"as",
"GraphDati",
"JSON",
"to",
"a",
"file",
"."
] | def to_graphdati_file(graph: BELGraph, path: Union[str, TextIO], use_identifiers: bool = True, **kwargs) -> None:
json.dump(to_graphdati(graph, use_identifiers=use_identifiers), path, ensure_ascii=False, **kwargs) | [
"def",
"to_graphdati_file",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"json",
".",
"dump",
"(",
"to_graphdati... | Write this graph as GraphDati JSON to a file. | [
"Write",
"this",
"graph",
"as",
"GraphDati",
"JSON",
"to",
"a",
"file",
"."
] | [
"\"\"\"Write this graph as GraphDati JSON to a file.\n\n :param graph: A BEL graph\n :param path: A path or file-like\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "use_identifiers",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "path",
... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | from_graphdati_file | BELGraph | def from_graphdati_file(path: Union[str, TextIO]) -> BELGraph:
"""Load a file containing GraphDati JSON.
:param path: A path or file-like
"""
return from_graphdati(json.load(path)) | Load a file containing GraphDati JSON.
:param path: A path or file-like
| Load a file containing GraphDati JSON. | [
"Load",
"a",
"file",
"containing",
"GraphDati",
"JSON",
"."
] | def from_graphdati_file(path: Union[str, TextIO]) -> BELGraph:
return from_graphdati(json.load(path)) | [
"def",
"from_graphdati_file",
"(",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
")",
"->",
"BELGraph",
":",
"return",
"from_graphdati",
"(",
"json",
".",
"load",
"(",
"path",
")",
")"
] | Load a file containing GraphDati JSON. | [
"Load",
"a",
"file",
"containing",
"GraphDati",
"JSON",
"."
] | [
"\"\"\"Load a file containing GraphDati JSON.\n\n :param path: A path or file-like\n \"\"\""
] | [
{
"param": "path",
"type": "Union[str, TextIO]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "Union[str, TextIO]",
"docstring": "A path or file-like",
"docstring_tokens": [
"A",
"path",
"or",
"file",
"-",
"like"
],
"default": null,
"is_op... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | to_graphdati_jsons | str | def to_graphdati_jsons(graph: BELGraph, **kwargs) -> str:
"""Dump this graph as a GraphDati JSON object to a string.
:param graph: A BEL graph
"""
return json.dumps(to_graphdati(graph), ensure_ascii=False, **kwargs) | Dump this graph as a GraphDati JSON object to a string.
:param graph: A BEL graph
| Dump this graph as a GraphDati JSON object to a string. | [
"Dump",
"this",
"graph",
"as",
"a",
"GraphDati",
"JSON",
"object",
"to",
"a",
"string",
"."
] | def to_graphdati_jsons(graph: BELGraph, **kwargs) -> str:
return json.dumps(to_graphdati(graph), ensure_ascii=False, **kwargs) | [
"def",
"to_graphdati_jsons",
"(",
"graph",
":",
"BELGraph",
",",
"**",
"kwargs",
")",
"->",
"str",
":",
"return",
"json",
".",
"dumps",
"(",
"to_graphdati",
"(",
"graph",
")",
",",
"ensure_ascii",
"=",
"False",
",",
"**",
"kwargs",
")"
] | Dump this graph as a GraphDati JSON object to a string. | [
"Dump",
"this",
"graph",
"as",
"a",
"GraphDati",
"JSON",
"object",
"to",
"a",
"string",
"."
] | [
"\"\"\"Dump this graph as a GraphDati JSON object to a string.\n\n :param graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others":... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | from_graphdati_jsons | BELGraph | def from_graphdati_jsons(s: str) -> BELGraph:
"""Load a graph from a GraphDati JSON string.
:param graph: A BEL graph
"""
return from_graphdati(json.loads(s)) | Load a graph from a GraphDati JSON string.
:param graph: A BEL graph
| Load a graph from a GraphDati JSON string. | [
"Load",
"a",
"graph",
"from",
"a",
"GraphDati",
"JSON",
"string",
"."
] | def from_graphdati_jsons(s: str) -> BELGraph:
return from_graphdati(json.loads(s)) | [
"def",
"from_graphdati_jsons",
"(",
"s",
":",
"str",
")",
"->",
"BELGraph",
":",
"return",
"from_graphdati",
"(",
"json",
".",
"loads",
"(",
"s",
")",
")"
] | Load a graph from a GraphDati JSON string. | [
"Load",
"a",
"graph",
"from",
"a",
"GraphDati",
"JSON",
"string",
"."
] | [
"\"\"\"Load a graph from a GraphDati JSON string.\n\n :param graph: A BEL graph\n \"\"\""
] | [
{
"param": "s",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "s",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL g... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | to_graphdati_jsonl | null | def to_graphdati_jsonl(graph, file, use_identifiers: bool = True, use_tqdm: bool = True):
"""Write this graph as a GraphDati JSON lines file.
:param graph: A BEL graph
"""
for nanopub in _iter_graphdati(graph, use_identifiers=use_identifiers, use_tqdm=use_tqdm):
print(json.dumps(nanopub), file=... | Write this graph as a GraphDati JSON lines file.
:param graph: A BEL graph
| Write this graph as a GraphDati JSON lines file. | [
"Write",
"this",
"graph",
"as",
"a",
"GraphDati",
"JSON",
"lines",
"file",
"."
] | def to_graphdati_jsonl(graph, file, use_identifiers: bool = True, use_tqdm: bool = True):
for nanopub in _iter_graphdati(graph, use_identifiers=use_identifiers, use_tqdm=use_tqdm):
print(json.dumps(nanopub), file=file) | [
"def",
"to_graphdati_jsonl",
"(",
"graph",
",",
"file",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
",",
"use_tqdm",
":",
"bool",
"=",
"True",
")",
":",
"for",
"nanopub",
"in",
"_iter_graphdati",
"(",
"graph",
",",
"use_identifiers",
"=",
"use_identifi... | Write this graph as a GraphDati JSON lines file. | [
"Write",
"this",
"graph",
"as",
"a",
"GraphDati",
"JSON",
"lines",
"file",
"."
] | [
"\"\"\"Write this graph as a GraphDati JSON lines file.\n\n :param graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": null
},
{
"param": "file",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
},
{
"param": "use_tqdm",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "file",
"type... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | to_graphdati_jsonl_gz | None | def to_graphdati_jsonl_gz(graph: BELGraph, path: str, **kwargs) -> None:
"""Write a graph as GraphDati JSONL to a gzip file.
:param graph: A BEL graph
"""
with gzip.open(path, 'wt') as file:
to_graphdati_jsonl(graph, file, **kwargs) | Write a graph as GraphDati JSONL to a gzip file.
:param graph: A BEL graph
| Write a graph as GraphDati JSONL to a gzip file. | [
"Write",
"a",
"graph",
"as",
"GraphDati",
"JSONL",
"to",
"a",
"gzip",
"file",
"."
] | def to_graphdati_jsonl_gz(graph: BELGraph, path: str, **kwargs) -> None:
with gzip.open(path, 'wt') as file:
to_graphdati_jsonl(graph, file, **kwargs) | [
"def",
"to_graphdati_jsonl_gz",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"str",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"with",
"gzip",
".",
"open",
"(",
"path",
",",
"'wt'",
")",
"as",
"file",
":",
"to_graphdati_jsonl",
"(",
"graph",
",",... | Write a graph as GraphDati JSONL to a gzip file. | [
"Write",
"a",
"graph",
"as",
"GraphDati",
"JSONL",
"to",
"a",
"gzip",
"file",
"."
] | [
"\"\"\"Write a graph as GraphDati JSONL to a gzip file.\n\n :param graph: A BEL graph\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "path",
... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | to_graphdati | List[NanopubMapping] | def to_graphdati(
graph,
*,
use_identifiers: bool = True,
skip_unqualified: bool = True,
use_tqdm: bool = False,
metadata_extras: Optional[Mapping[str, Any]] = None
) -> List[NanopubMapping]:
"""Export a GraphDati list using the nanopub.
:param graph: A BEL graph
:param use_identifi... | Export a GraphDati list using the nanopub.
:param graph: A BEL graph
:param use_identifiers: use OBO-style identifiers
:param use_tqdm: Show a progress bar while generating nanopubs
:param skip_unqualified: Should unqualified edges be output as nanopubs? Defaults to false.
:param metadata_extras: E... | Export a GraphDati list using the nanopub. | [
"Export",
"a",
"GraphDati",
"list",
"using",
"the",
"nanopub",
"."
] | def to_graphdati(
graph,
*,
use_identifiers: bool = True,
skip_unqualified: bool = True,
use_tqdm: bool = False,
metadata_extras: Optional[Mapping[str, Any]] = None
) -> List[NanopubMapping]:
return list(_iter_graphdati(
graph,
use_identifiers=use_identifiers,
skip_un... | [
"def",
"to_graphdati",
"(",
"graph",
",",
"*",
",",
"use_identifiers",
":",
"bool",
"=",
"True",
",",
"skip_unqualified",
":",
"bool",
"=",
"True",
",",
"use_tqdm",
":",
"bool",
"=",
"False",
",",
"metadata_extras",
":",
"Optional",
"[",
"Mapping",
"[",
... | Export a GraphDati list using the nanopub. | [
"Export",
"a",
"GraphDati",
"list",
"using",
"the",
"nanopub",
"."
] | [
"\"\"\"Export a GraphDati list using the nanopub.\n\n :param graph: A BEL graph\n :param use_identifiers: use OBO-style identifiers\n :param use_tqdm: Show a progress bar while generating nanopubs\n :param skip_unqualified: Should unqualified edges be output as nanopubs? Defaults to false.\n :param m... | [
{
"param": "graph",
"type": null
},
{
"param": "use_identifiers",
"type": "bool"
},
{
"param": "skip_unqualified",
"type": "bool"
},
{
"param": "use_tqdm",
"type": "bool"
},
{
"param": "metadata_extras",
"type": "Optional[Mapping[str, Any]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": null,
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "use_identifiers",
... |
f1d5462c47ffeff3c6c8f98a3d1ccf47f9d0fd26 | rpatil524/pybel | src/pybel/io/graphdati.py | [
"MIT"
] | Python | from_graphdati | BELGraph | def from_graphdati(j, use_tqdm: bool = True) -> BELGraph:
"""Convert data from the "normal" network format.
.. warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported
"""
root = j['graph']
graph = BELGraph(
name=root.get('label'),
... | Convert data from the "normal" network format.
.. warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported
| Convert data from the "normal" network format.
warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported | [
"Convert",
"data",
"from",
"the",
"\"",
"normal",
"\"",
"network",
"format",
".",
"warning",
"::",
"BioDati",
"crashes",
"when",
"requesting",
"the",
"`",
"`",
"full",
"`",
"`",
"network",
"format",
"so",
"this",
"isn",
"'",
"t",
"yet",
"explicitly",
"su... | def from_graphdati(j, use_tqdm: bool = True) -> BELGraph:
root = j['graph']
graph = BELGraph(
name=root.get('label'),
version=root['metadata'].get('gd_rev'),
authors=root['metadata'].get('gd_creator'),
description=root.get('gd_description'),
)
graph.graph['biodati_network... | [
"def",
"from_graphdati",
"(",
"j",
",",
"use_tqdm",
":",
"bool",
"=",
"True",
")",
"->",
"BELGraph",
":",
"root",
"=",
"j",
"[",
"'graph'",
"]",
"graph",
"=",
"BELGraph",
"(",
"name",
"=",
"root",
".",
"get",
"(",
"'label'",
")",
",",
"version",
"=... | Convert data from the "normal" network format. | [
"Convert",
"data",
"from",
"the",
"\"",
"normal",
"\"",
"network",
"format",
"."
] | [
"\"\"\"Convert data from the \"normal\" network format.\n\n .. warning:: BioDati crashes when requesting the ``full`` network format, so this isn't yet explicitly supported\n \"\"\"",
"# Just in case you want to find it again",
"# To be updated manually depending on what William is up to",
"# don't need... | [
{
"param": "j",
"type": null
},
{
"param": "use_tqdm",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "j",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_tqdm",
"type": "bool",
"docstring": null,
"docstring_tokens"... |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | sanitize_date | str | def sanitize_date(publication_date: str) -> str:
"""Sanitize lots of different date strings into ISO-8601."""
if re1.search(publication_date):
return datetime.strptime(publication_date, '%Y %b %d').strftime('%Y-%m-%d')
if re2.search(publication_date):
return datetime.strptime(publication_da... | Sanitize lots of different date strings into ISO-8601. | Sanitize lots of different date strings into ISO-8601. | [
"Sanitize",
"lots",
"of",
"different",
"date",
"strings",
"into",
"ISO",
"-",
"8601",
"."
] | def sanitize_date(publication_date: str) -> str:
if re1.search(publication_date):
return datetime.strptime(publication_date, '%Y %b %d').strftime('%Y-%m-%d')
if re2.search(publication_date):
return datetime.strptime(publication_date, '%Y %b').strftime('%Y-%m-01')
if re3.search(publication_da... | [
"def",
"sanitize_date",
"(",
"publication_date",
":",
"str",
")",
"->",
"str",
":",
"if",
"re1",
".",
"search",
"(",
"publication_date",
")",
":",
"return",
"datetime",
".",
"strptime",
"(",
"publication_date",
",",
"'%Y %b %d'",
")",
".",
"strftime",
"(",
... | Sanitize lots of different date strings into ISO-8601. | [
"Sanitize",
"lots",
"of",
"different",
"date",
"strings",
"into",
"ISO",
"-",
"8601",
"."
] | [
"\"\"\"Sanitize lots of different date strings into ISO-8601.\"\"\""
] | [
{
"param": "publication_date",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "publication_date",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | enrich_citation_model | bool | def enrich_citation_model(manager: Manager, citation: models.Citation, p: Mapping[str, Any]) -> bool:
"""Enrich a citation model with the information from PubMed.
:param manager: A database manager
:param citation: A citation model
:param p: The dictionary from PubMed E-Utils corresponding to d["result... | Enrich a citation model with the information from PubMed.
:param manager: A database manager
:param citation: A citation model
:param p: The dictionary from PubMed E-Utils corresponding to d["result"][pmid]
| Enrich a citation model with the information from PubMed. | [
"Enrich",
"a",
"citation",
"model",
"with",
"the",
"information",
"from",
"PubMed",
"."
] | def enrich_citation_model(manager: Manager, citation: models.Citation, p: Mapping[str, Any]) -> bool:
if 'error' in p:
logger.warning('Error downloading PubMed')
return False
citation.title = p['title']
citation.journal = p['fulljournalname']
citation.volume = p['volume']
citation.is... | [
"def",
"enrich_citation_model",
"(",
"manager",
":",
"Manager",
",",
"citation",
":",
"models",
".",
"Citation",
",",
"p",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"if",
"'error'",
"in",
"p",
":",
"logger",
".",
"warning",
... | Enrich a citation model with the information from PubMed. | [
"Enrich",
"a",
"citation",
"model",
"with",
"the",
"information",
"from",
"PubMed",
"."
] | [
"\"\"\"Enrich a citation model with the information from PubMed.\n\n :param manager: A database manager\n :param citation: A citation model\n :param p: The dictionary from PubMed E-Utils corresponding to d[\"result\"][pmid]\n \"\"\""
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "citation",
"type": "models.Citation"
},
{
"param": "p",
"type": "Mapping[str, Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": "A database manager",
"docstring_tokens": [
"A",
"database",
"manager"
],
"default": null,
"is_optional": null
},
{
"identifier"... |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | _get_citations_by_identifiers | Tuple[Dict[str, Dict], Set[str]] | def _get_citations_by_identifiers(
manager: Manager,
identifiers: Iterable[Union[str, int]],
*,
group_size: Optional[int] = None,
offline: bool = False,
prefix: Optional[str] = None,
) -> Tuple[Dict[str, Dict], Set[str]]:
"""Get citation information for the given list of PubMed identifiers u... | Get citation information for the given list of PubMed identifiers using the NCBI's eUtils service.
:type manager: pybel.Manager
:param identifiers: an iterable of PubMed identifiers
:param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers.
:return: A dictionar... | Get citation information for the given list of PubMed identifiers using the NCBI's eUtils service. | [
"Get",
"citation",
"information",
"for",
"the",
"given",
"list",
"of",
"PubMed",
"identifiers",
"using",
"the",
"NCBI",
"'",
"s",
"eUtils",
"service",
"."
] | def _get_citations_by_identifiers(
manager: Manager,
identifiers: Iterable[Union[str, int]],
*,
group_size: Optional[int] = None,
offline: bool = False,
prefix: Optional[str] = None,
) -> Tuple[Dict[str, Dict], Set[str]]:
if prefix is None:
prefix = 'pubmed'
helper = _HELPERS.get... | [
"def",
"_get_citations_by_identifiers",
"(",
"manager",
":",
"Manager",
",",
"identifiers",
":",
"Iterable",
"[",
"Union",
"[",
"str",
",",
"int",
"]",
"]",
",",
"*",
",",
"group_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"offline",
":",
... | Get citation information for the given list of PubMed identifiers using the NCBI's eUtils service. | [
"Get",
"citation",
"information",
"for",
"the",
"given",
"list",
"of",
"PubMed",
"identifiers",
"using",
"the",
"NCBI",
"'",
"s",
"eUtils",
"service",
"."
] | [
"\"\"\"Get citation information for the given list of PubMed identifiers using the NCBI's eUtils service.\n\n :type manager: pybel.Manager\n :param identifiers: an iterable of PubMed identifiers\n :param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers.\n :ret... | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "identifiers",
"type": "Iterable[Union[str, int]]"
},
{
"param": "group_size",
"type": "Optional[int]"
},
{
"param": "offline",
"type": "bool"
},
{
"param": "prefix",
"type": "Optional[str]"
}
] | {
"returns": [
{
"docstring": "A dictionary of {identifier: data dictionary} or a pair of this dictionary and a set ot erroneous\nidentifiers.",
"docstring_tokens": [
"A",
"dictionary",
"of",
"{",
"identifier",
":",
"data",
"dictionary",
... |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | enrich_pubmed_citations | Set[str] | def enrich_pubmed_citations(
graph: BELGraph,
*,
manager: Optional[Manager] = None,
group_size: Optional[int] = None,
offline: bool = False,
) -> Set[str]:
"""Overwrite all PubMed citations with values from NCBI's eUtils lookup service.
:param graph: A BEL graph
:param manager: A PyBEL ... | Overwrite all PubMed citations with values from NCBI's eUtils lookup service.
:param graph: A BEL graph
:param manager: A PyBEL database manager
:param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers.
:param offline: An override for when you don't want to hi... | Overwrite all PubMed citations with values from NCBI's eUtils lookup service. | [
"Overwrite",
"all",
"PubMed",
"citations",
"with",
"values",
"from",
"NCBI",
"'",
"s",
"eUtils",
"lookup",
"service",
"."
] | def enrich_pubmed_citations(
graph: BELGraph,
*,
manager: Optional[Manager] = None,
group_size: Optional[int] = None,
offline: bool = False,
) -> Set[str]:
return _enrich_citations(
manager=manager, graph=graph, group_size=group_size, offline=offline, prefix='pubmed',
) | [
"def",
"enrich_pubmed_citations",
"(",
"graph",
":",
"BELGraph",
",",
"*",
",",
"manager",
":",
"Optional",
"[",
"Manager",
"]",
"=",
"None",
",",
"group_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"offline",
":",
"bool",
"=",
"False",
"... | Overwrite all PubMed citations with values from NCBI's eUtils lookup service. | [
"Overwrite",
"all",
"PubMed",
"citations",
"with",
"values",
"from",
"NCBI",
"'",
"s",
"eUtils",
"lookup",
"service",
"."
] | [
"\"\"\"Overwrite all PubMed citations with values from NCBI's eUtils lookup service.\n\n :param graph: A BEL graph\n :param manager: A PyBEL database manager\n :param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers.\n :param offline: An override for when you ... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "manager",
"type": "Optional[Manager]"
},
{
"param": "group_size",
"type": "Optional[int]"
},
{
"param": "offline",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "A set of PMIDs for which the eUtils service crashed",
"docstring_tokens": [
"A",
"set",
"of",
"PMIDs",
"for",
"which",
"the",
"eUtils",
"service",
"crashed"
],
"type": null
}
... |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | enrich_pmc_citations | Set[str] | def enrich_pmc_citations(
graph: BELGraph,
*,
manager: Optional[Manager] = None,
group_size: Optional[int] = None,
offline: bool = False,
) -> Set[str]:
"""Overwrite all PubMed citations with values from NCBI's eUtils lookup service.
:param graph: A BEL graph
:param manager: A PyBEL dat... | Overwrite all PubMed citations with values from NCBI's eUtils lookup service.
:param graph: A BEL graph
:param manager: A PyBEL database manager
:param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers.
:param offline: An override for when you don't want to hi... | Overwrite all PubMed citations with values from NCBI's eUtils lookup service. | [
"Overwrite",
"all",
"PubMed",
"citations",
"with",
"values",
"from",
"NCBI",
"'",
"s",
"eUtils",
"lookup",
"service",
"."
] | def enrich_pmc_citations(
graph: BELGraph,
*,
manager: Optional[Manager] = None,
group_size: Optional[int] = None,
offline: bool = False,
) -> Set[str]:
return _enrich_citations(
manager=manager, graph=graph, group_size=group_size, offline=offline, prefix='pmc',
) | [
"def",
"enrich_pmc_citations",
"(",
"graph",
":",
"BELGraph",
",",
"*",
",",
"manager",
":",
"Optional",
"[",
"Manager",
"]",
"=",
"None",
",",
"group_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"offline",
":",
"bool",
"=",
"False",
",",... | Overwrite all PubMed citations with values from NCBI's eUtils lookup service. | [
"Overwrite",
"all",
"PubMed",
"citations",
"with",
"values",
"from",
"NCBI",
"'",
"s",
"eUtils",
"lookup",
"service",
"."
] | [
"\"\"\"Overwrite all PubMed citations with values from NCBI's eUtils lookup service.\n\n :param graph: A BEL graph\n :param manager: A PyBEL database manager\n :param group_size: The number of PubMed identifiers to query at a time. Defaults to 200 identifiers.\n :param offline: An override for when you ... | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "manager",
"type": "Optional[Manager]"
},
{
"param": "group_size",
"type": "Optional[int]"
},
{
"param": "offline",
"type": "bool"
}
] | {
"returns": [
{
"docstring": "A set of PMIDs for which the eUtils service crashed",
"docstring_tokens": [
"A",
"set",
"of",
"PMIDs",
"for",
"which",
"the",
"eUtils",
"service",
"crashed"
],
"type": null
}
... |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | _enrich_citations | Set[str] | def _enrich_citations(
graph: BELGraph,
manager: Optional[Manager],
group_size: Optional[int] = None,
offline: bool = False,
prefix: Optional[str] = None,
) -> Set[str]:
"""Overwrite all citations of the given prefix using the predefined lookup functions.
:param graph: A BEL Graph
:para... | Overwrite all citations of the given prefix using the predefined lookup functions.
:param graph: A BEL Graph
:param group_size: The number of identifiers to query at a time. Defaults to 200 identifiers.
:return: A set of identifiers for which lookup was not possible
| Overwrite all citations of the given prefix using the predefined lookup functions. | [
"Overwrite",
"all",
"citations",
"of",
"the",
"given",
"prefix",
"using",
"the",
"predefined",
"lookup",
"functions",
"."
] | def _enrich_citations(
graph: BELGraph,
manager: Optional[Manager],
group_size: Optional[int] = None,
offline: bool = False,
prefix: Optional[str] = None,
) -> Set[str]:
if manager is None:
manager = Manager()
if prefix is None:
prefix = 'pubmed'
identifiers = {identifier... | [
"def",
"_enrich_citations",
"(",
"graph",
":",
"BELGraph",
",",
"manager",
":",
"Optional",
"[",
"Manager",
"]",
",",
"group_size",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
",",
"offline",
":",
"bool",
"=",
"False",
",",
"prefix",
":",
"Optional",
... | Overwrite all citations of the given prefix using the predefined lookup functions. | [
"Overwrite",
"all",
"citations",
"of",
"the",
"given",
"prefix",
"using",
"the",
"predefined",
"lookup",
"functions",
"."
] | [
"\"\"\"Overwrite all citations of the given prefix using the predefined lookup functions.\n\n :param graph: A BEL Graph\n :param group_size: The number of identifiers to query at a time. Defaults to 200 identifiers.\n :return: A set of identifiers for which lookup was not possible\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "manager",
"type": "Optional[Manager]"
},
{
"param": "group_size",
"type": "Optional[int]"
},
{
"param": "offline",
"type": "bool"
},
{
"param": "prefix",
"type": "Optional[str]"
}
] | {
"returns": [
{
"docstring": "A set of identifiers for which lookup was not possible",
"docstring_tokens": [
"A",
"set",
"of",
"identifiers",
"for",
"which",
"lookup",
"was",
"not",
"possible"
],
"type": null
... |
bcbc35a0b3311198fe8956f054b8e0545b37fc40 | rpatil524/pybel | src/pybel/manager/citation_utils.py | [
"MIT"
] | Python | enrich_citation_model_from_pmc | bool | def enrich_citation_model_from_pmc(manager: Manager, citation: models.Citation, csl: Mapping[str, Any]) -> bool:
"""Enrich a citation model with the information from PubMed Central.
:param manager: A database manager
:param citation: A citation model
:param dict csl: The dictionary from PMC
"""
... | Enrich a citation model with the information from PubMed Central.
:param manager: A database manager
:param citation: A citation model
:param dict csl: The dictionary from PMC
| Enrich a citation model with the information from PubMed Central. | [
"Enrich",
"a",
"citation",
"model",
"with",
"the",
"information",
"from",
"PubMed",
"Central",
"."
] | def enrich_citation_model_from_pmc(manager: Manager, citation: models.Citation, csl: Mapping[str, Any]) -> bool:
citation.title = csl.get('title')
citation.journal = csl.get('container-title')
citation.volume = csl.get('volume')
citation.pages = csl.get('page')
citation.article_type = csl.get('type'... | [
"def",
"enrich_citation_model_from_pmc",
"(",
"manager",
":",
"Manager",
",",
"citation",
":",
"models",
".",
"Citation",
",",
"csl",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"bool",
":",
"citation",
".",
"title",
"=",
"csl",
".",
"get",
... | Enrich a citation model with the information from PubMed Central. | [
"Enrich",
"a",
"citation",
"model",
"with",
"the",
"information",
"from",
"PubMed",
"Central",
"."
] | [
"\"\"\"Enrich a citation model with the information from PubMed Central.\n\n :param manager: A database manager\n :param citation: A citation model\n :param dict csl: The dictionary from PMC\n \"\"\"",
"# citation.issue = csl['issue']"
] | [
{
"param": "manager",
"type": "Manager"
},
{
"param": "citation",
"type": "models.Citation"
},
{
"param": "csl",
"type": "Mapping[str, Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "manager",
"type": "Manager",
"docstring": "A database manager",
"docstring_tokens": [
"A",
"database",
"manager"
],
"default": null,
"is_optional": null
},
{
"identifier"... |
417097a1db29af40b4f4fe99cda3b7193c885cbc | rpatil524/pybel | src/pybel/testing/cases.py | [
"MIT"
] | Python | tearDown | null | def tearDown(self):
"""Tear down the test function by closing the session and removing the database."""
self.manager.session.close()
if not TEST_CONNECTION:
os.close(self.fd)
os.remove(self.path)
else:
self.manager.drop_all() | Tear down the test function by closing the session and removing the database. | Tear down the test function by closing the session and removing the database. | [
"Tear",
"down",
"the",
"test",
"function",
"by",
"closing",
"the",
"session",
"and",
"removing",
"the",
"database",
"."
] | def tearDown(self):
self.manager.session.close()
if not TEST_CONNECTION:
os.close(self.fd)
os.remove(self.path)
else:
self.manager.drop_all() | [
"def",
"tearDown",
"(",
"self",
")",
":",
"self",
".",
"manager",
".",
"session",
".",
"close",
"(",
")",
"if",
"not",
"TEST_CONNECTION",
":",
"os",
".",
"close",
"(",
"self",
".",
"fd",
")",
"os",
".",
"remove",
"(",
"self",
".",
"path",
")",
"e... | Tear down the test function by closing the session and removing the database. | [
"Tear",
"down",
"the",
"test",
"function",
"by",
"closing",
"the",
"session",
"and",
"removing",
"the",
"database",
"."
] | [
"\"\"\"Tear down the test function by closing the session and removing the database.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
417097a1db29af40b4f4fe99cda3b7193c885cbc | rpatil524/pybel | src/pybel/testing/cases.py | [
"MIT"
] | Python | tearDownClass | null | def tearDownClass(cls):
"""Tear down the test class by closing the session and removing the database."""
cls.manager.session.close()
if not TEST_CONNECTION:
os.close(cls.fd)
os.remove(cls.path)
else:
cls.manager.drop_all() | Tear down the test class by closing the session and removing the database. | Tear down the test class by closing the session and removing the database. | [
"Tear",
"down",
"the",
"test",
"class",
"by",
"closing",
"the",
"session",
"and",
"removing",
"the",
"database",
"."
] | def tearDownClass(cls):
cls.manager.session.close()
if not TEST_CONNECTION:
os.close(cls.fd)
os.remove(cls.path)
else:
cls.manager.drop_all() | [
"def",
"tearDownClass",
"(",
"cls",
")",
":",
"cls",
".",
"manager",
".",
"session",
".",
"close",
"(",
")",
"if",
"not",
"TEST_CONNECTION",
":",
"os",
".",
"close",
"(",
"cls",
".",
"fd",
")",
"os",
".",
"remove",
"(",
"cls",
".",
"path",
")",
"... | Tear down the test class by closing the session and removing the database. | [
"Tear",
"down",
"the",
"test",
"class",
"by",
"closing",
"the",
"session",
"and",
"removing",
"the",
"database",
"."
] | [
"\"\"\"Tear down the test class by closing the session and removing the database.\"\"\""
] | [
{
"param": "cls",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | parse_result_to_dsl | BaseEntity | def parse_result_to_dsl(tokens) -> BaseEntity:
"""Convert a ParseResult to a PyBEL DSL object.
:type tokens: dict or pyparsing.ParseResults
"""
# if MODIFIER in tokens:
# return parse_result_to_dsl(tokens[TARGET])
if REACTION == tokens[FUNCTION]:
return _reaction_po_to_dict(tokens)
... | Convert a ParseResult to a PyBEL DSL object.
:type tokens: dict or pyparsing.ParseResults
| Convert a ParseResult to a PyBEL DSL object. | [
"Convert",
"a",
"ParseResult",
"to",
"a",
"PyBEL",
"DSL",
"object",
"."
] | def parse_result_to_dsl(tokens) -> BaseEntity:
if REACTION == tokens[FUNCTION]:
return _reaction_po_to_dict(tokens)
elif VARIANTS in tokens:
return _variant_po_to_dict(tokens)
elif MEMBERS in tokens:
if CONCEPT in tokens:
return _list_po_with_concept_to_dict(tokens)
... | [
"def",
"parse_result_to_dsl",
"(",
"tokens",
")",
"->",
"BaseEntity",
":",
"if",
"REACTION",
"==",
"tokens",
"[",
"FUNCTION",
"]",
":",
"return",
"_reaction_po_to_dict",
"(",
"tokens",
")",
"elif",
"VARIANTS",
"in",
"tokens",
":",
"return",
"_variant_po_to_dict"... | Convert a ParseResult to a PyBEL DSL object. | [
"Convert",
"a",
"ParseResult",
"to",
"a",
"PyBEL",
"DSL",
"object",
"."
] | [
"\"\"\"Convert a ParseResult to a PyBEL DSL object.\n\n :type tokens: dict or pyparsing.ParseResults\n \"\"\"",
"# if MODIFIER in tokens:",
"# return parse_result_to_dsl(tokens[TARGET])"
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _fusion_to_dsl | FusionBase | def _fusion_to_dsl(tokens) -> FusionBase:
"""Convert a PyParsing data dictionary to a PyBEL fusion data dictionary.
:param tokens: A PyParsing data dictionary representing a fusion
:type tokens: ParseResult
"""
func = tokens[FUNCTION]
fusion_dsl = FUNC_TO_FUSION_DSL[func]
member_dsl = FUNC_... | Convert a PyParsing data dictionary to a PyBEL fusion data dictionary.
:param tokens: A PyParsing data dictionary representing a fusion
:type tokens: ParseResult
| Convert a PyParsing data dictionary to a PyBEL fusion data dictionary. | [
"Convert",
"a",
"PyParsing",
"data",
"dictionary",
"to",
"a",
"PyBEL",
"fusion",
"data",
"dictionary",
"."
] | def _fusion_to_dsl(tokens) -> FusionBase:
func = tokens[FUNCTION]
fusion_dsl = FUNC_TO_FUSION_DSL[func]
member_dsl = FUNC_TO_DSL[func]
partner_5p = tokens[FUSION][PARTNER_5P]
partner_5p_concept = (
partner_5p[CONCEPT]
if CONCEPT in tokens[FUSION][PARTNER_5P] else
partner_5p
... | [
"def",
"_fusion_to_dsl",
"(",
"tokens",
")",
"->",
"FusionBase",
":",
"func",
"=",
"tokens",
"[",
"FUNCTION",
"]",
"fusion_dsl",
"=",
"FUNC_TO_FUSION_DSL",
"[",
"func",
"]",
"member_dsl",
"=",
"FUNC_TO_DSL",
"[",
"func",
"]",
"partner_5p",
"=",
"tokens",
"["... | Convert a PyParsing data dictionary to a PyBEL fusion data dictionary. | [
"Convert",
"a",
"PyParsing",
"data",
"dictionary",
"to",
"a",
"PyBEL",
"fusion",
"data",
"dictionary",
"."
] | [
"\"\"\"Convert a PyParsing data dictionary to a PyBEL fusion data dictionary.\n\n :param tokens: A PyParsing data dictionary representing a fusion\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": "A PyParsing data dictionary representing a fusion",
"docstring_tokens": [
"A",
"PyParsing",
"data",
"dictionary",
"representing",
"a",
... |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _simple_po_to_dict | BaseAbundance | def _simple_po_to_dict(tokens) -> BaseAbundance:
"""Convert a simple named entity to a DSL object.
:type tokens: ParseResult
"""
dsl = FUNC_TO_DSL.get(tokens[FUNCTION])
if dsl is None:
raise ValueError('invalid tokens: {}'.format(tokens))
concept = tokens[CONCEPT]
return dsl(
... | Convert a simple named entity to a DSL object.
:type tokens: ParseResult
| Convert a simple named entity to a DSL object. | [
"Convert",
"a",
"simple",
"named",
"entity",
"to",
"a",
"DSL",
"object",
"."
] | def _simple_po_to_dict(tokens) -> BaseAbundance:
dsl = FUNC_TO_DSL.get(tokens[FUNCTION])
if dsl is None:
raise ValueError('invalid tokens: {}'.format(tokens))
concept = tokens[CONCEPT]
return dsl(
namespace=concept[NAMESPACE],
name=concept.get(NAME),
identifier=concept.ge... | [
"def",
"_simple_po_to_dict",
"(",
"tokens",
")",
"->",
"BaseAbundance",
":",
"dsl",
"=",
"FUNC_TO_DSL",
".",
"get",
"(",
"tokens",
"[",
"FUNCTION",
"]",
")",
"if",
"dsl",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'invalid tokens: {}'",
".",
"format",
... | Convert a simple named entity to a DSL object. | [
"Convert",
"a",
"simple",
"named",
"entity",
"to",
"a",
"DSL",
"object",
"."
] | [
"\"\"\"Convert a simple named entity to a DSL object.\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _variant_po_to_dict | CentralDogma | def _variant_po_to_dict(tokens) -> CentralDogma:
"""Convert a PyParsing data dictionary to a central dogma abundance (i.e., Protein, RNA, miRNA, Gene).
:type tokens: ParseResult
"""
dsl = FUNC_TO_DSL.get(tokens[FUNCTION])
if dsl is None:
raise ValueError('invalid tokens: {}'.format(tokens))... | Convert a PyParsing data dictionary to a central dogma abundance (i.e., Protein, RNA, miRNA, Gene).
:type tokens: ParseResult
| Convert a PyParsing data dictionary to a central dogma abundance . | [
"Convert",
"a",
"PyParsing",
"data",
"dictionary",
"to",
"a",
"central",
"dogma",
"abundance",
"."
] | def _variant_po_to_dict(tokens) -> CentralDogma:
dsl = FUNC_TO_DSL.get(tokens[FUNCTION])
if dsl is None:
raise ValueError('invalid tokens: {}'.format(tokens))
concept = tokens[CONCEPT]
return dsl(
namespace=concept[NAMESPACE],
name=concept[NAME],
identifier=concept.get(ID... | [
"def",
"_variant_po_to_dict",
"(",
"tokens",
")",
"->",
"CentralDogma",
":",
"dsl",
"=",
"FUNC_TO_DSL",
".",
"get",
"(",
"tokens",
"[",
"FUNCTION",
"]",
")",
"if",
"dsl",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'invalid tokens: {}'",
".",
"format",
... | Convert a PyParsing data dictionary to a central dogma abundance (i.e., Protein, RNA, miRNA, Gene). | [
"Convert",
"a",
"PyParsing",
"data",
"dictionary",
"to",
"a",
"central",
"dogma",
"abundance",
"(",
"i",
".",
"e",
".",
"Protein",
"RNA",
"miRNA",
"Gene",
")",
"."
] | [
"\"\"\"Convert a PyParsing data dictionary to a central dogma abundance (i.e., Protein, RNA, miRNA, Gene).\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _variant_to_dsl_helper | Variant | def _variant_to_dsl_helper(tokens) -> Variant:
"""Convert variant tokens to DSL objects.
:type tokens: ParseResult
"""
kind = tokens[KIND]
if kind == HGVS:
return Hgvs(tokens[HGVS])
if kind == GMOD:
concept = tokens[CONCEPT]
return GeneModification(
name=co... | Convert variant tokens to DSL objects.
:type tokens: ParseResult
| Convert variant tokens to DSL objects. | [
"Convert",
"variant",
"tokens",
"to",
"DSL",
"objects",
"."
] | def _variant_to_dsl_helper(tokens) -> Variant:
kind = tokens[KIND]
if kind == HGVS:
return Hgvs(tokens[HGVS])
if kind == GMOD:
concept = tokens[CONCEPT]
return GeneModification(
name=concept[NAME],
namespace=concept[NAMESPACE],
identifier=concept.g... | [
"def",
"_variant_to_dsl_helper",
"(",
"tokens",
")",
"->",
"Variant",
":",
"kind",
"=",
"tokens",
"[",
"KIND",
"]",
"if",
"kind",
"==",
"HGVS",
":",
"return",
"Hgvs",
"(",
"tokens",
"[",
"HGVS",
"]",
")",
"if",
"kind",
"==",
"GMOD",
":",
"concept",
"... | Convert variant tokens to DSL objects. | [
"Convert",
"variant",
"tokens",
"to",
"DSL",
"objects",
"."
] | [
"\"\"\"Convert variant tokens to DSL objects.\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _reaction_po_to_dict | Reaction | def _reaction_po_to_dict(tokens) -> Reaction:
"""Convert a reaction parse object to a DSL.
:type tokens: ParseResult
"""
return Reaction(
reactants=_parse_tokens_list(tokens[REACTANTS]),
products=_parse_tokens_list(tokens[PRODUCTS]),
) | Convert a reaction parse object to a DSL.
:type tokens: ParseResult
| Convert a reaction parse object to a DSL. | [
"Convert",
"a",
"reaction",
"parse",
"object",
"to",
"a",
"DSL",
"."
] | def _reaction_po_to_dict(tokens) -> Reaction:
return Reaction(
reactants=_parse_tokens_list(tokens[REACTANTS]),
products=_parse_tokens_list(tokens[PRODUCTS]),
) | [
"def",
"_reaction_po_to_dict",
"(",
"tokens",
")",
"->",
"Reaction",
":",
"return",
"Reaction",
"(",
"reactants",
"=",
"_parse_tokens_list",
"(",
"tokens",
"[",
"REACTANTS",
"]",
")",
",",
"products",
"=",
"_parse_tokens_list",
"(",
"tokens",
"[",
"PRODUCTS",
... | Convert a reaction parse object to a DSL. | [
"Convert",
"a",
"reaction",
"parse",
"object",
"to",
"a",
"DSL",
"."
] | [
"\"\"\"Convert a reaction parse object to a DSL.\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _list_po_with_concept_to_dict | ListAbundance | def _list_po_with_concept_to_dict(tokens: Union[ParseResults, Mapping[str, Any]]) -> ListAbundance:
"""Convert a list parse object to a node.
:type tokens: ParseResult
"""
func = tokens[FUNCTION]
dsl = FUNC_TO_LIST_DSL[func]
members = _parse_tokens_list(tokens[MEMBERS])
concept = tokens[CO... | Convert a list parse object to a node.
:type tokens: ParseResult
| Convert a list parse object to a node. | [
"Convert",
"a",
"list",
"parse",
"object",
"to",
"a",
"node",
"."
] | def _list_po_with_concept_to_dict(tokens: Union[ParseResults, Mapping[str, Any]]) -> ListAbundance:
func = tokens[FUNCTION]
dsl = FUNC_TO_LIST_DSL[func]
members = _parse_tokens_list(tokens[MEMBERS])
concept = tokens[CONCEPT]
return dsl(
members=members,
namespace=concept[NAMESPACE],
... | [
"def",
"_list_po_with_concept_to_dict",
"(",
"tokens",
":",
"Union",
"[",
"ParseResults",
",",
"Mapping",
"[",
"str",
",",
"Any",
"]",
"]",
")",
"->",
"ListAbundance",
":",
"func",
"=",
"tokens",
"[",
"FUNCTION",
"]",
"dsl",
"=",
"FUNC_TO_LIST_DSL",
"[",
"... | Convert a list parse object to a node. | [
"Convert",
"a",
"list",
"parse",
"object",
"to",
"a",
"node",
"."
] | [
"\"\"\"Convert a list parse object to a node.\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": "Union[ParseResults, Mapping[str, Any]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": "Union[ParseResults, Mapping[str, Any]]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _list_po_to_dict | ListAbundance | def _list_po_to_dict(tokens) -> ListAbundance:
"""Convert a list parse object to a node.
:type tokens: ParseResult
"""
func = tokens[FUNCTION]
dsl = FUNC_TO_LIST_DSL[func]
members = _parse_tokens_list(tokens[MEMBERS])
return dsl(members) | Convert a list parse object to a node.
:type tokens: ParseResult
| Convert a list parse object to a node. | [
"Convert",
"a",
"list",
"parse",
"object",
"to",
"a",
"node",
"."
] | def _list_po_to_dict(tokens) -> ListAbundance:
func = tokens[FUNCTION]
dsl = FUNC_TO_LIST_DSL[func]
members = _parse_tokens_list(tokens[MEMBERS])
return dsl(members) | [
"def",
"_list_po_to_dict",
"(",
"tokens",
")",
"->",
"ListAbundance",
":",
"func",
"=",
"tokens",
"[",
"FUNCTION",
"]",
"dsl",
"=",
"FUNC_TO_LIST_DSL",
"[",
"func",
"]",
"members",
"=",
"_parse_tokens_list",
"(",
"tokens",
"[",
"MEMBERS",
"]",
")",
"return",... | Convert a list parse object to a node. | [
"Convert",
"a",
"list",
"parse",
"object",
"to",
"a",
"node",
"."
] | [
"\"\"\"Convert a list parse object to a node.\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9c34502d5d43155eba1eef3a81ca12511e985b97 | rpatil524/pybel | src/pybel/tokens.py | [
"MIT"
] | Python | _parse_tokens_list | List[BaseEntity] | def _parse_tokens_list(tokens) -> List[BaseEntity]:
"""Convert a PyParsing result to a reaction.
:type tokens: ParseResult
"""
return [
parse_result_to_dsl(token)
for token in tokens
] | Convert a PyParsing result to a reaction.
:type tokens: ParseResult
| Convert a PyParsing result to a reaction. | [
"Convert",
"a",
"PyParsing",
"result",
"to",
"a",
"reaction",
"."
] | def _parse_tokens_list(tokens) -> List[BaseEntity]:
return [
parse_result_to_dsl(token)
for token in tokens
] | [
"def",
"_parse_tokens_list",
"(",
"tokens",
")",
"->",
"List",
"[",
"BaseEntity",
"]",
":",
"return",
"[",
"parse_result_to_dsl",
"(",
"token",
")",
"for",
"token",
"in",
"tokens",
"]"
] | Convert a PyParsing result to a reaction. | [
"Convert",
"a",
"PyParsing",
"result",
"to",
"a",
"reaction",
"."
] | [
"\"\"\"Convert a PyParsing result to a reaction.\n\n :type tokens: ParseResult\n \"\"\""
] | [
{
"param": "tokens",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "tokens",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | not_resource_cachable | <not_specific> | def not_resource_cachable(bel_resource):
"""Check if the BEL resource is cacheable.
:param dict bel_resource: A dictionary returned by :func:`get_bel_resource`.
"""
return bel_resource['Processing'].get('CacheableFlag') not in {'yes', 'Yes', 'True', 'true'} | Check if the BEL resource is cacheable.
:param dict bel_resource: A dictionary returned by :func:`get_bel_resource`.
| Check if the BEL resource is cacheable. | [
"Check",
"if",
"the",
"BEL",
"resource",
"is",
"cacheable",
"."
] | def not_resource_cachable(bel_resource):
return bel_resource['Processing'].get('CacheableFlag') not in {'yes', 'Yes', 'True', 'true'} | [
"def",
"not_resource_cachable",
"(",
"bel_resource",
")",
":",
"return",
"bel_resource",
"[",
"'Processing'",
"]",
".",
"get",
"(",
"'CacheableFlag'",
")",
"not",
"in",
"{",
"'yes'",
",",
"'Yes'",
",",
"'True'",
",",
"'true'",
"}"
] | Check if the BEL resource is cacheable. | [
"Check",
"if",
"the",
"BEL",
"resource",
"is",
"cacheable",
"."
] | [
"\"\"\"Check if the BEL resource is cacheable.\n\n :param dict bel_resource: A dictionary returned by :func:`get_bel_resource`.\n \"\"\""
] | [
{
"param": "bel_resource",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "bel_resource",
"type": null,
"docstring": "A dictionary returned by :func:`get_bel_resource`.",
"docstring_tokens": [
"A",
"dictionary",
"returned",
"by",
":",
"func",
":... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | drop_namespace_by_url | None | def drop_namespace_by_url(self, url: str) -> None:
"""Drop the namespace at the given URL.
Won't work if the edge store is in use.
:param url: The URL of the namespace to drop
"""
namespace = self.get_namespace_by_url(url)
self.session.query(NamespaceEntry).filter(Names... | Drop the namespace at the given URL.
Won't work if the edge store is in use.
:param url: The URL of the namespace to drop
| Drop the namespace at the given URL.
Won't work if the edge store is in use. | [
"Drop",
"the",
"namespace",
"at",
"the",
"given",
"URL",
".",
"Won",
"'",
"t",
"work",
"if",
"the",
"edge",
"store",
"is",
"in",
"use",
"."
] | def drop_namespace_by_url(self, url: str) -> None:
namespace = self.get_namespace_by_url(url)
self.session.query(NamespaceEntry).filter(NamespaceEntry.namespace == namespace).delete()
self.session.delete(namespace)
self.session.commit() | [
"def",
"drop_namespace_by_url",
"(",
"self",
",",
"url",
":",
"str",
")",
"->",
"None",
":",
"namespace",
"=",
"self",
".",
"get_namespace_by_url",
"(",
"url",
")",
"self",
".",
"session",
".",
"query",
"(",
"NamespaceEntry",
")",
".",
"filter",
"(",
"Na... | Drop the namespace at the given URL. | [
"Drop",
"the",
"namespace",
"at",
"the",
"given",
"URL",
"."
] | [
"\"\"\"Drop the namespace at the given URL.\n\n Won't work if the edge store is in use.\n\n :param url: The URL of the namespace to drop\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "url",
"type": "str",
"docstring": "The URL of the namespace to drop... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | ensure_regex_namespace | Namespace | def ensure_regex_namespace(self, keyword: str, pattern: str) -> Namespace:
"""Get or create a regular expression namespace.
:param keyword: The keyword of a regular expression namespace
:param pattern: The pattern for a regular expression namespace
"""
if pattern is None:
... | Get or create a regular expression namespace.
:param keyword: The keyword of a regular expression namespace
:param pattern: The pattern for a regular expression namespace
| Get or create a regular expression namespace. | [
"Get",
"or",
"create",
"a",
"regular",
"expression",
"namespace",
"."
] | def ensure_regex_namespace(self, keyword: str, pattern: str) -> Namespace:
if pattern is None:
raise ValueError('cannot have null pattern')
namespace = self.get_namespace_by_keyword_pattern(keyword, pattern)
if namespace is None:
logger.info('creating regex namespace: %s:... | [
"def",
"ensure_regex_namespace",
"(",
"self",
",",
"keyword",
":",
"str",
",",
"pattern",
":",
"str",
")",
"->",
"Namespace",
":",
"if",
"pattern",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'cannot have null pattern'",
")",
"namespace",
"=",
"self",
".... | Get or create a regular expression namespace. | [
"Get",
"or",
"create",
"a",
"regular",
"expression",
"namespace",
"."
] | [
"\"\"\"Get or create a regular expression namespace.\n\n :param keyword: The keyword of a regular expression namespace\n :param pattern: The pattern for a regular expression namespace\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "keyword",
"type": "str"
},
{
"param": "pattern",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "keyword",
"type": "str",
"docstring": "The keyword of a regular exp... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | list_recent_networks | List[Network] | def list_recent_networks(self) -> List[Network]:
"""List the most recently created version of each network (by name)."""
most_recent_times = self.session.query(
Network.name.label('network_name'),
func.max(Network.created).label('max_created'),
)
most_recent_time... | List the most recently created version of each network (by name). | List the most recently created version of each network (by name). | [
"List",
"the",
"most",
"recently",
"created",
"version",
"of",
"each",
"network",
"(",
"by",
"name",
")",
"."
] | def list_recent_networks(self) -> List[Network]:
most_recent_times = self.session.query(
Network.name.label('network_name'),
func.max(Network.created).label('max_created'),
)
most_recent_times = most_recent_times.group_by(Network.name).subquery('most_recent_times')
... | [
"def",
"list_recent_networks",
"(",
"self",
")",
"->",
"List",
"[",
"Network",
"]",
":",
"most_recent_times",
"=",
"self",
".",
"session",
".",
"query",
"(",
"Network",
".",
"name",
".",
"label",
"(",
"'network_name'",
")",
",",
"func",
".",
"max",
"(",
... | List the most recently created version of each network (by name). | [
"List",
"the",
"most",
"recently",
"created",
"version",
"of",
"each",
"network",
"(",
"by",
"name",
")",
"."
] | [
"\"\"\"List the most recently created version of each network (by name).\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | drop_network | None | def drop_network(self, network: Network) -> None:
"""Drop a network, while also cleaning up any edges that are no longer part of any network."""
# get the IDs of the edges that will be orphaned by deleting this network
# FIXME: this list could be a problem if it becomes very large; possible opti... | Drop a network, while also cleaning up any edges that are no longer part of any network. | Drop a network, while also cleaning up any edges that are no longer part of any network. | [
"Drop",
"a",
"network",
"while",
"also",
"cleaning",
"up",
"any",
"edges",
"that",
"are",
"no",
"longer",
"part",
"of",
"any",
"network",
"."
] | def drop_network(self, network: Network) -> None:
edge_ids = [result.edge_id for result in self.query_singleton_edges_from_network(network)]
self.session.query(network_node).filter(network_node.c.network_id == network.id).delete(
synchronize_session=False,
)
self.session.quer... | [
"def",
"drop_network",
"(",
"self",
",",
"network",
":",
"Network",
")",
"->",
"None",
":",
"edge_ids",
"=",
"[",
"result",
".",
"edge_id",
"for",
"result",
"in",
"self",
".",
"query_singleton_edges_from_network",
"(",
"network",
")",
"]",
"self",
".",
"se... | Drop a network, while also cleaning up any edges that are no longer part of any network. | [
"Drop",
"a",
"network",
"while",
"also",
"cleaning",
"up",
"any",
"edges",
"that",
"are",
"no",
"longer",
"part",
"of",
"any",
"network",
"."
] | [
"\"\"\"Drop a network, while also cleaning up any edges that are no longer part of any network.\"\"\"",
"# get the IDs of the edges that will be orphaned by deleting this network",
"# FIXME: this list could be a problem if it becomes very large; possible optimization is a temporary table in DB",
"# delete the... | [
{
"param": "self",
"type": null
},
{
"param": "network",
"type": "Network"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "network",
"type": "Network",
"docstring": null,
"docstring_to... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | query_singleton_edges_from_network | sqlalchemy.orm.query.Query | def query_singleton_edges_from_network(self, network: Network) -> sqlalchemy.orm.query.Query:
"""Return a query selecting all edge ids that only belong to the given network."""
ne1 = aliased(network_edge, name='ne1')
ne2 = aliased(network_edge, name='ne2')
singleton_edge_ids_for_network ... | Return a query selecting all edge ids that only belong to the given network. | Return a query selecting all edge ids that only belong to the given network. | [
"Return",
"a",
"query",
"selecting",
"all",
"edge",
"ids",
"that",
"only",
"belong",
"to",
"the",
"given",
"network",
"."
] | def query_singleton_edges_from_network(self, network: Network) -> sqlalchemy.orm.query.Query:
ne1 = aliased(network_edge, name='ne1')
ne2 = aliased(network_edge, name='ne2')
singleton_edge_ids_for_network = (
self.session
.query(ne1.c.edge_id)
.outerjo... | [
"def",
"query_singleton_edges_from_network",
"(",
"self",
",",
"network",
":",
"Network",
")",
"->",
"sqlalchemy",
".",
"orm",
".",
"query",
".",
"Query",
":",
"ne1",
"=",
"aliased",
"(",
"network_edge",
",",
"name",
"=",
"'ne1'",
")",
"ne2",
"=",
"aliased... | Return a query selecting all edge ids that only belong to the given network. | [
"Return",
"a",
"query",
"selecting",
"all",
"edge",
"ids",
"that",
"only",
"belong",
"to",
"the",
"given",
"network",
"."
] | [
"\"\"\"Return a query selecting all edge ids that only belong to the given network.\"\"\"",
"# noqa: E131",
"# noqa: E711"
] | [
{
"param": "self",
"type": null
},
{
"param": "network",
"type": "Network"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "network",
"type": "Network",
"docstring": null,
"docstring_to... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | insert_graph | Network | def insert_graph(
self,
graph: BELGraph,
use_tqdm: bool = True,
) -> Network:
"""Insert a graph in the database and returns the corresponding Network model.
:raises: pybel.resources.exc.ResourceError
"""
if not graph.name:
raise ValueError('Can no... | Insert a graph in the database and returns the corresponding Network model.
:raises: pybel.resources.exc.ResourceError
| Insert a graph in the database and returns the corresponding Network model. | [
"Insert",
"a",
"graph",
"in",
"the",
"database",
"and",
"returns",
"the",
"corresponding",
"Network",
"model",
"."
] | def insert_graph(
self,
graph: BELGraph,
use_tqdm: bool = True,
) -> Network:
if not graph.name:
raise ValueError('Can not upload a graph without a name')
if not graph.version:
raise ValueError('Can not upload a graph without a version')
logger... | [
"def",
"insert_graph",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"use_tqdm",
":",
"bool",
"=",
"True",
",",
")",
"->",
"Network",
":",
"if",
"not",
"graph",
".",
"name",
":",
"raise",
"ValueError",
"(",
"'Can not upload a graph without a name'",
")",
... | Insert a graph in the database and returns the corresponding Network model. | [
"Insert",
"a",
"graph",
"in",
"the",
"database",
"and",
"returns",
"the",
"corresponding",
"Network",
"model",
"."
] | [
"\"\"\"Insert a graph in the database and returns the corresponding Network model.\n\n :raises: pybel.resources.exc.ResourceError\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "use_tqdm",
"type": "bool"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | _store_graph_parts | Tuple[List[Node], List[Edge]] | def _store_graph_parts(self, graph: BELGraph, use_tqdm: bool = False) -> Tuple[List[Node], List[Edge]]:
"""Store the given graph into the edge store.
:raises: pybel.resources.exc.ResourceError
:raises: EdgeAddError
"""
logger.debug('inserting %s into edge store', graph)
... | Store the given graph into the edge store.
:raises: pybel.resources.exc.ResourceError
:raises: EdgeAddError
| Store the given graph into the edge store. | [
"Store",
"the",
"given",
"graph",
"into",
"the",
"edge",
"store",
"."
] | def _store_graph_parts(self, graph: BELGraph, use_tqdm: bool = False) -> Tuple[List[Node], List[Edge]]:
logger.debug('inserting %s into edge store', graph)
logger.debug('building node models')
node_model_build_start = time.time()
nodes = list(graph)
if use_tqdm:
nodes... | [
"def",
"_store_graph_parts",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"use_tqdm",
":",
"bool",
"=",
"False",
")",
"->",
"Tuple",
"[",
"List",
"[",
"Node",
"]",
",",
"List",
"[",
"Edge",
"]",
"]",
":",
"logger",
".",
"debug",
"(",
"'inserting ... | Store the given graph into the edge store. | [
"Store",
"the",
"given",
"graph",
"into",
"the",
"edge",
"store",
"."
] | [
"\"\"\"Store the given graph into the edge store.\n\n :raises: pybel.resources.exc.ResourceError\n :raises: EdgeAddError\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "use_tqdm",
"type": "bool"
}
] | {
"returns": [],
"raises": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
},
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"params": [
{
"identifier": "self",
"type": nul... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | _iter_from_annotations_dict | Iterable[Tuple[str, Set[Entity]]] | def _iter_from_annotations_dict(
graph: BELGraph,
annotations_dict: AnnotationsDict,
) -> Iterable[Tuple[str, Set[Entity]]]:
"""Iterate over the key/value pairs in this edge data dictionary normalized to their source URLs."""
for key, entities in annotations_dict.items():
... | Iterate over the key/value pairs in this edge data dictionary normalized to their source URLs. | Iterate over the key/value pairs in this edge data dictionary normalized to their source URLs. | [
"Iterate",
"over",
"the",
"key",
"/",
"value",
"pairs",
"in",
"this",
"edge",
"data",
"dictionary",
"normalized",
"to",
"their",
"source",
"URLs",
"."
] | def _iter_from_annotations_dict(
graph: BELGraph,
annotations_dict: AnnotationsDict,
) -> Iterable[Tuple[str, Set[Entity]]]:
for key, entities in annotations_dict.items():
if key in graph.annotation_url:
url = graph.annotation_url[key]
elif key in grap... | [
"def",
"_iter_from_annotations_dict",
"(",
"graph",
":",
"BELGraph",
",",
"annotations_dict",
":",
"AnnotationsDict",
",",
")",
"->",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"Set",
"[",
"Entity",
"]",
"]",
"]",
":",
"for",
"key",
",",
"entities",
"in",
... | Iterate over the key/value pairs in this edge data dictionary normalized to their source URLs. | [
"Iterate",
"over",
"the",
"key",
"/",
"value",
"pairs",
"in",
"this",
"edge",
"data",
"dictionary",
"normalized",
"to",
"their",
"source",
"URLs",
"."
] | [
"\"\"\"Iterate over the key/value pairs in this edge data dictionary normalized to their source URLs.\"\"\"",
"# skip those",
"# FIXME"
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "annotations_dict",
"type": "AnnotationsDict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "annotations_dict",
"type": "AnnotationsDict",
"docstring": n... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | _get_annotation_entries_from_data | Optional[List[NamespaceEntry]] | def _get_annotation_entries_from_data(self, graph: BELGraph, data: EdgeData) -> Optional[List[NamespaceEntry]]:
"""Get the annotation entries from an edge data dictionary."""
annotations_dict = data.get(ANNOTATIONS)
if annotations_dict is None:
return
rv = []
for url,... | Get the annotation entries from an edge data dictionary. | Get the annotation entries from an edge data dictionary. | [
"Get",
"the",
"annotation",
"entries",
"from",
"an",
"edge",
"data",
"dictionary",
"."
] | def _get_annotation_entries_from_data(self, graph: BELGraph, data: EdgeData) -> Optional[List[NamespaceEntry]]:
annotations_dict = data.get(ANNOTATIONS)
if annotations_dict is None:
return
rv = []
for url, entities in self._iter_from_annotations_dict(graph, annotations_dict=a... | [
"def",
"_get_annotation_entries_from_data",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"data",
":",
"EdgeData",
")",
"->",
"Optional",
"[",
"List",
"[",
"NamespaceEntry",
"]",
"]",
":",
"annotations_dict",
"=",
"data",
".",
"get",
"(",
"ANNOTATIONS",
"... | Get the annotation entries from an edge data dictionary. | [
"Get",
"the",
"annotation",
"entries",
"from",
"an",
"edge",
"data",
"dictionary",
"."
] | [
"\"\"\"Get the annotation entries from an edge data dictionary.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "data",
"type": "EdgeData"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tok... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | _add_qualified_edge | Optional[Edge] | def _add_qualified_edge(
self,
graph: BELGraph,
source: Node,
target: Node,
key: str,
bel: str,
data: EdgeData,
) -> Optional[Edge]:
"""Add a qualified edge to the network."""
citation_dict = data[CITATION]
citation = self.get_or_create... | Add a qualified edge to the network. | Add a qualified edge to the network. | [
"Add",
"a",
"qualified",
"edge",
"to",
"the",
"network",
"."
] | def _add_qualified_edge(
self,
graph: BELGraph,
source: Node,
target: Node,
key: str,
bel: str,
data: EdgeData,
) -> Optional[Edge]:
citation_dict = data[CITATION]
citation = self.get_or_create_citation(
namespace=citation_dict[NAME... | [
"def",
"_add_qualified_edge",
"(",
"self",
",",
"graph",
":",
"BELGraph",
",",
"source",
":",
"Node",
",",
"target",
":",
"Node",
",",
"key",
":",
"str",
",",
"bel",
":",
"str",
",",
"data",
":",
"EdgeData",
",",
")",
"->",
"Optional",
"[",
"Edge",
... | Add a qualified edge to the network. | [
"Add",
"a",
"qualified",
"edge",
"to",
"the",
"network",
"."
] | [
"\"\"\"Add a qualified edge to the network.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "source",
"type": "Node"
},
{
"param": "target",
"type": "Node"
},
{
"param": "key",
"type": "str"
},
{
"param": "bel",
"type": "str"
},
{
"param": "dat... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tok... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | _add_unqualified_edge | Edge | def _add_unqualified_edge(self, source: Node, target: Node, key: str, bel: str, data: EdgeData) -> Edge:
"""Add an unqualified edge to the network."""
return self.get_or_create_edge(
source=source,
target=target,
relation=data[RELATION],
bel=bel,
... | Add an unqualified edge to the network. | Add an unqualified edge to the network. | [
"Add",
"an",
"unqualified",
"edge",
"to",
"the",
"network",
"."
] | def _add_unqualified_edge(self, source: Node, target: Node, key: str, bel: str, data: EdgeData) -> Edge:
return self.get_or_create_edge(
source=source,
target=target,
relation=data[RELATION],
bel=bel,
md5=key,
data=data,
) | [
"def",
"_add_unqualified_edge",
"(",
"self",
",",
"source",
":",
"Node",
",",
"target",
":",
"Node",
",",
"key",
":",
"str",
",",
"bel",
":",
"str",
",",
"data",
":",
"EdgeData",
")",
"->",
"Edge",
":",
"return",
"self",
".",
"get_or_create_edge",
"(",... | Add an unqualified edge to the network. | [
"Add",
"an",
"unqualified",
"edge",
"to",
"the",
"network",
"."
] | [
"\"\"\"Add an unqualified edge to the network.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "source",
"type": "Node"
},
{
"param": "target",
"type": "Node"
},
{
"param": "key",
"type": "str"
},
{
"param": "bel",
"type": "str"
},
{
"param": "data",
"type": "EdgeData"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "source",
"type": "Node",
"docstring": null,
"docstring_tokens... |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | drop_nodes | None | def drop_nodes(self) -> None:
"""Drop all nodes in the database."""
t = time.time()
self.session.query(Node).delete()
self.session.commit()
logger.info('dropped all nodes in %.2f seconds', time.time() - t) | Drop all nodes in the database. | Drop all nodes in the database. | [
"Drop",
"all",
"nodes",
"in",
"the",
"database",
"."
] | def drop_nodes(self) -> None:
t = time.time()
self.session.query(Node).delete()
self.session.commit()
logger.info('dropped all nodes in %.2f seconds', time.time() - t) | [
"def",
"drop_nodes",
"(",
"self",
")",
"->",
"None",
":",
"t",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"session",
".",
"query",
"(",
"Node",
")",
".",
"delete",
"(",
")",
"self",
".",
"session",
".",
"commit",
"(",
")",
"logger",
".",
... | Drop all nodes in the database. | [
"Drop",
"all",
"nodes",
"in",
"the",
"database",
"."
] | [
"\"\"\"Drop all nodes in the database.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2f4b5b45cc07140b576bc2e5cc0d7d0b844a40f9 | rpatil524/pybel | src/pybel/manager/cache_manager.py | [
"MIT"
] | Python | drop_edges | None | def drop_edges(self) -> None:
"""Drop all edges in the database."""
t = time.time()
self.session.query(Edge).delete()
self.session.commit()
logger.info('dropped all edges in %.2f seconds', time.time() - t) | Drop all edges in the database. | Drop all edges in the database. | [
"Drop",
"all",
"edges",
"in",
"the",
"database",
"."
] | def drop_edges(self) -> None:
t = time.time()
self.session.query(Edge).delete()
self.session.commit()
logger.info('dropped all edges in %.2f seconds', time.time() - t) | [
"def",
"drop_edges",
"(",
"self",
")",
"->",
"None",
":",
"t",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"session",
".",
"query",
"(",
"Edge",
")",
".",
"delete",
"(",
")",
"self",
".",
"session",
".",
"commit",
"(",
")",
"logger",
".",
... | Drop all edges in the database. | [
"Drop",
"all",
"edges",
"in",
"the",
"database",
"."
] | [
"\"\"\"Drop all edges in the database.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4ef7a15d6405dbde43a567aee489f0b312a0406c | rpatil524/pybel | src/pybel/parser/parse_concept.py | [
"MIT"
] | Python | raise_for_missing_name | None | def raise_for_missing_name(self, line: str, position: int, namespace: str, name: str) -> None:
"""Raise an exception if the namespace is not defined or if it does not validate the given name."""
self.raise_for_missing_namespace(line, position, namespace, name)
if self.has_enumerated_namespace(n... | Raise an exception if the namespace is not defined or if it does not validate the given name. | Raise an exception if the namespace is not defined or if it does not validate the given name. | [
"Raise",
"an",
"exception",
"if",
"the",
"namespace",
"is",
"not",
"defined",
"or",
"if",
"it",
"does",
"not",
"validate",
"the",
"given",
"name",
"."
] | def raise_for_missing_name(self, line: str, position: int, namespace: str, name: str) -> None:
self.raise_for_missing_namespace(line, position, namespace, name)
if self.has_enumerated_namespace(namespace) and name not in self.namespace_to_name_to_encoding[namespace]:
raise MissingNamespaceNa... | [
"def",
"raise_for_missing_name",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"namespace",
":",
"str",
",",
"name",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"raise_for_missing_namespace",
"(",
"line",
",",
"position",
"... | Raise an exception if the namespace is not defined or if it does not validate the given name. | [
"Raise",
"an",
"exception",
"if",
"the",
"namespace",
"is",
"not",
"defined",
"or",
"if",
"it",
"does",
"not",
"validate",
"the",
"given",
"name",
"."
] | [
"\"\"\"Raise an exception if the namespace is not defined or if it does not validate the given name.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "namespace",
"type": "str"
},
{
"param": "name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
4ef7a15d6405dbde43a567aee489f0b312a0406c | rpatil524/pybel | src/pybel/parser/parse_concept.py | [
"MIT"
] | Python | _handle_identifier | ParseResults | def _handle_identifier(self, line: str, position: int, tokens: ParseResults, key) -> ParseResults:
"""Handle parsing a qualified identifier."""
namespace, name = tokens[NAMESPACE], tokens[key]
self.raise_for_missing_namespace(line, position, namespace, name)
self.raise_for_missing_name(... | Handle parsing a qualified identifier. | Handle parsing a qualified identifier. | [
"Handle",
"parsing",
"a",
"qualified",
"identifier",
"."
] | def _handle_identifier(self, line: str, position: int, tokens: ParseResults, key) -> ParseResults:
namespace, name = tokens[NAMESPACE], tokens[key]
self.raise_for_missing_namespace(line, position, namespace, name)
self.raise_for_missing_name(line, position, namespace, name)
return tokens | [
"def",
"_handle_identifier",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
",",
"key",
")",
"->",
"ParseResults",
":",
"namespace",
",",
"name",
"=",
"tokens",
"[",
"NAMESPACE",
"]",
",",
"tokens",... | Handle parsing a qualified identifier. | [
"Handle",
"parsing",
"a",
"qualified",
"identifier",
"."
] | [
"\"\"\"Handle parsing a qualified identifier.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
},
{
"param": "key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
4ef7a15d6405dbde43a567aee489f0b312a0406c | rpatil524/pybel | src/pybel/parser/parse_concept.py | [
"MIT"
] | Python | handle_namespace_default | ParseResults | def handle_namespace_default(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Handle parsing an identifier for the default namespace."""
name = tokens[NAME]
if not self.default_namespace:
raise ValueError('Default namespace is not set')
if name not in... | Handle parsing an identifier for the default namespace. | Handle parsing an identifier for the default namespace. | [
"Handle",
"parsing",
"an",
"identifier",
"for",
"the",
"default",
"namespace",
"."
] | def handle_namespace_default(self, line: str, position: int, tokens: ParseResults) -> ParseResults:
name = tokens[NAME]
if not self.default_namespace:
raise ValueError('Default namespace is not set')
if name not in self.default_namespace:
raise MissingDefaultNameWarning(s... | [
"def",
"handle_namespace_default",
"(",
"self",
",",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"name",
"=",
"tokens",
"[",
"NAME",
"]",
"if",
"not",
"self",
".",
"default_namespace"... | Handle parsing an identifier for the default namespace. | [
"Handle",
"parsing",
"an",
"identifier",
"for",
"the",
"default",
"namespace",
"."
] | [
"\"\"\"Handle parsing an identifier for the default namespace.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "line",
"type": "str",
"docstring": null,
"docstring_tokens": ... |
4ef7a15d6405dbde43a567aee489f0b312a0406c | rpatil524/pybel | src/pybel/parser/parse_concept.py | [
"MIT"
] | Python | handle_namespace_lenient | ParseResults | def handle_namespace_lenient(line: str, position: int, tokens: ParseResults) -> ParseResults:
"""Handle parsing an identifier for names missing a namespace that are outside the default namespace."""
tokens[NAMESPACE] = DIRTY
logger.debug('Naked namespace: [%d] %s', position, line)
return... | Handle parsing an identifier for names missing a namespace that are outside the default namespace. | Handle parsing an identifier for names missing a namespace that are outside the default namespace. | [
"Handle",
"parsing",
"an",
"identifier",
"for",
"names",
"missing",
"a",
"namespace",
"that",
"are",
"outside",
"the",
"default",
"namespace",
"."
] | def handle_namespace_lenient(line: str, position: int, tokens: ParseResults) -> ParseResults:
tokens[NAMESPACE] = DIRTY
logger.debug('Naked namespace: [%d] %s', position, line)
return tokens | [
"def",
"handle_namespace_lenient",
"(",
"line",
":",
"str",
",",
"position",
":",
"int",
",",
"tokens",
":",
"ParseResults",
")",
"->",
"ParseResults",
":",
"tokens",
"[",
"NAMESPACE",
"]",
"=",
"DIRTY",
"logger",
".",
"debug",
"(",
"'Naked namespace: [%d] %s'... | Handle parsing an identifier for names missing a namespace that are outside the default namespace. | [
"Handle",
"parsing",
"an",
"identifier",
"for",
"names",
"missing",
"a",
"namespace",
"that",
"are",
"outside",
"the",
"default",
"namespace",
"."
] | [
"\"\"\"Handle parsing an identifier for names missing a namespace that are outside the default namespace.\"\"\""
] | [
{
"param": "line",
"type": "str"
},
{
"param": "position",
"type": "int"
},
{
"param": "tokens",
"type": "ParseResults"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "line",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "position",
"type": "int",
"docstring": null,
"docstring_toke... |
977b34f9b78d8f714e05e769c102b103cd1056c0 | rpatil524/pybel | src/pybel/dsl/edges.py | [
"MIT"
] | Python | activity | ModifierDict | def activity(
name: Optional[str] = None,
namespace: Optional[str] = None,
identifier: Optional[str] = None,
location: Optional[LocationDict] = None,
) -> ModifierDict:
"""Make a subject/object modifier dictionary.
:param name: The name of the activity. If no namespace given, uses BEL default n... | Make a subject/object modifier dictionary.
:param name: The name of the activity. If no namespace given, uses BEL default namespace
:param namespace: The namespace of the activity
:param identifier: The identifier of the name in the database
:param location: An entity from :func:`pybel.dsl.entity` repr... | Make a subject/object modifier dictionary. | [
"Make",
"a",
"subject",
"/",
"object",
"modifier",
"dictionary",
"."
] | def activity(
name: Optional[str] = None,
namespace: Optional[str] = None,
identifier: Optional[str] = None,
location: Optional[LocationDict] = None,
) -> ModifierDict:
rv = _modifier_helper(ACTIVITY, location=location)
if name and not namespace:
rv[EFFECT] = activity_mapping[name]
e... | [
"def",
"activity",
"(",
"name",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"namespace",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"identifier",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"location",
":",
"Optional",
"[",
... | Make a subject/object modifier dictionary. | [
"Make",
"a",
"subject",
"/",
"object",
"modifier",
"dictionary",
"."
] | [
"\"\"\"Make a subject/object modifier dictionary.\n\n :param name: The name of the activity. If no namespace given, uses BEL default namespace\n :param namespace: The namespace of the activity\n :param identifier: The identifier of the name in the database\n :param location: An entity from :func:`pybel.... | [
{
"param": "name",
"type": "Optional[str]"
},
{
"param": "namespace",
"type": "Optional[str]"
},
{
"param": "identifier",
"type": "Optional[str]"
},
{
"param": "location",
"type": "Optional[LocationDict]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "name",
"type": "Optional[str]",
"docstring": "The name of the activity. If no namespace given, uses BEL default namespace",
"docstring_tokens": [
"The",
"name",
"of",
"the",
"activity",
... |
977b34f9b78d8f714e05e769c102b103cd1056c0 | rpatil524/pybel | src/pybel/dsl/edges.py | [
"MIT"
] | Python | secretion | ModifierDict | def secretion() -> ModifierDict:
"""Make a secretion translocation dictionary.
This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the
extracellular space.
"""
return translocation(INTRACELLULAR, EXTRACELLULAR) | Make a secretion translocation dictionary.
This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the
extracellular space.
| Make a secretion translocation dictionary.
This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the
extracellular space. | [
"Make",
"a",
"secretion",
"translocation",
"dictionary",
".",
"This",
"is",
"a",
"convenient",
"wrapper",
"representing",
"the",
":",
"func",
":",
"`",
"translocation",
"`",
"from",
"the",
"intracellular",
"location",
"to",
"the",
"extracellular",
"space",
"."
] | def secretion() -> ModifierDict:
return translocation(INTRACELLULAR, EXTRACELLULAR) | [
"def",
"secretion",
"(",
")",
"->",
"ModifierDict",
":",
"return",
"translocation",
"(",
"INTRACELLULAR",
",",
"EXTRACELLULAR",
")"
] | Make a secretion translocation dictionary. | [
"Make",
"a",
"secretion",
"translocation",
"dictionary",
"."
] | [
"\"\"\"Make a secretion translocation dictionary.\n\n This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the\n extracellular space.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
977b34f9b78d8f714e05e769c102b103cd1056c0 | rpatil524/pybel | src/pybel/dsl/edges.py | [
"MIT"
] | Python | cell_surface_expression | ModifierDict | def cell_surface_expression() -> ModifierDict:
"""Make a cellular surface expression translocation dictionary.
This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the cell
surface.
"""
return translocation(INTRACELLULAR, CELL_SURFACE) | Make a cellular surface expression translocation dictionary.
This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the cell
surface.
| Make a cellular surface expression translocation dictionary.
This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the cell
surface. | [
"Make",
"a",
"cellular",
"surface",
"expression",
"translocation",
"dictionary",
".",
"This",
"is",
"a",
"convenient",
"wrapper",
"representing",
"the",
":",
"func",
":",
"`",
"translocation",
"`",
"from",
"the",
"intracellular",
"location",
"to",
"the",
"cell",... | def cell_surface_expression() -> ModifierDict:
return translocation(INTRACELLULAR, CELL_SURFACE) | [
"def",
"cell_surface_expression",
"(",
")",
"->",
"ModifierDict",
":",
"return",
"translocation",
"(",
"INTRACELLULAR",
",",
"CELL_SURFACE",
")"
] | Make a cellular surface expression translocation dictionary. | [
"Make",
"a",
"cellular",
"surface",
"expression",
"translocation",
"dictionary",
"."
] | [
"\"\"\"Make a cellular surface expression translocation dictionary.\n\n This is a convenient wrapper representing the :func:`translocation` from the intracellular location to the cell\n surface.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
977b34f9b78d8f714e05e769c102b103cd1056c0 | rpatil524/pybel | src/pybel/dsl/edges.py | [
"MIT"
] | Python | location | LocationDict | def location(identifier: Entity) -> LocationDict:
"""Make a location object modifier dictionary.
:param identifier: A namespace/name/identifier pair
Usage:
X increases the abundance of Y in the cytoplasm
.. code-block:: python
from pybel import BELGraph
from pybel.dsl import pro... | Make a location object modifier dictionary.
:param identifier: A namespace/name/identifier pair
Usage:
X increases the abundance of Y in the cytoplasm
.. code-block:: python
from pybel import BELGraph
from pybel.dsl import protein, location
graph = BELGraph()
sourc... | Make a location object modifier dictionary. | [
"Make",
"a",
"location",
"object",
"modifier",
"dictionary",
"."
] | def location(identifier: Entity) -> LocationDict:
return {
LOCATION: identifier,
} | [
"def",
"location",
"(",
"identifier",
":",
"Entity",
")",
"->",
"LocationDict",
":",
"return",
"{",
"LOCATION",
":",
"identifier",
",",
"}"
] | Make a location object modifier dictionary. | [
"Make",
"a",
"location",
"object",
"modifier",
"dictionary",
"."
] | [
"\"\"\"Make a location object modifier dictionary.\n\n :param identifier: A namespace/name/identifier pair\n\n Usage:\n\n X increases the abundance of Y in the cytoplasm\n\n .. code-block:: python\n\n from pybel import BELGraph\n from pybel.dsl import protein, location\n\n graph = B... | [
{
"param": "identifier",
"type": "Entity"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "identifier",
"type": "Entity",
"docstring": "A namespace/name/identifier pair\nUsage.\n\nX increases the abundance of Y in the cytoplasm\n\ncode-block:: python\n\nfrom pybel import BELGraph\nfrom pybel.dsl import protein, location\n... |
faf4e05f7c5c0de10050ce3086771f39d0f48ccf | rpatil524/pybel | src/pybel/io/triples/converters.py | [
"MIT"
] | Python | predicate | bool | def predicate(cls, u, v, key, edge_data) -> bool:
"""Test a BEL edge has a given relation."""
return (
isinstance(u, cls.subject_type)
and edge_data[RELATION] in cls.relations
and isinstance(v, cls.object_type)
) | Test a BEL edge has a given relation. | Test a BEL edge has a given relation. | [
"Test",
"a",
"BEL",
"edge",
"has",
"a",
"given",
"relation",
"."
] | def predicate(cls, u, v, key, edge_data) -> bool:
return (
isinstance(u, cls.subject_type)
and edge_data[RELATION] in cls.relations
and isinstance(v, cls.object_type)
) | [
"def",
"predicate",
"(",
"cls",
",",
"u",
",",
"v",
",",
"key",
",",
"edge_data",
")",
"->",
"bool",
":",
"return",
"(",
"isinstance",
"(",
"u",
",",
"cls",
".",
"subject_type",
")",
"and",
"edge_data",
"[",
"RELATION",
"]",
"in",
"cls",
".",
"rela... | Test a BEL edge has a given relation. | [
"Test",
"a",
"BEL",
"edge",
"has",
"a",
"given",
"relation",
"."
] | [
"\"\"\"Test a BEL edge has a given relation.\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "u",
"type": null
},
{
"param": "v",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "edge_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "u",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
faf4e05f7c5c0de10050ce3086771f39d0f48ccf | rpatil524/pybel | src/pybel/io/triples/converters.py | [
"MIT"
] | Python | convert | Tuple[str, str, str] | def convert(cls, u: BaseEntity, v: BaseEntity, key: str, edge_data: EdgeData) -> Tuple[str, str, str]:
"""Convert a transcription factor for edge."""
gene = v.get_gene()
if gene == u.members[0]:
return u.members[1].safe_label, edge_data[RELATION], v.safe_label
else:
... | Convert a transcription factor for edge. | Convert a transcription factor for edge. | [
"Convert",
"a",
"transcription",
"factor",
"for",
"edge",
"."
] | def convert(cls, u: BaseEntity, v: BaseEntity, key: str, edge_data: EdgeData) -> Tuple[str, str, str]:
gene = v.get_gene()
if gene == u.members[0]:
return u.members[1].safe_label, edge_data[RELATION], v.safe_label
else:
return u.members[0].safe_label, edge_data[RELATION],... | [
"def",
"convert",
"(",
"cls",
",",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"key",
":",
"str",
",",
"edge_data",
":",
"EdgeData",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
":",
"gene",
"=",
"v",
".",
"get_gene"... | Convert a transcription factor for edge. | [
"Convert",
"a",
"transcription",
"factor",
"for",
"edge",
"."
] | [
"\"\"\"Convert a transcription factor for edge.\"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "key",
"type": "str"
},
{
"param": "edge_data",
"type": "EdgeData"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "u",
"type": "BaseEntity",
"docstring": null,
"docstring_tokens... |
faf4e05f7c5c0de10050ce3086771f39d0f48ccf | rpatil524/pybel | src/pybel/io/triples/converters.py | [
"MIT"
] | Python | convert | Tuple[str, str, str] | def convert(u: BaseEntity, v: BaseEntity, key: str, edge_data: EdgeData) -> Tuple[str, str, str]:
"""Convert a transcription factor for edge."""
relation = edge_data[RELATION]
if relation in CAUSAL_INCREASE_RELATIONS:
relation = 'increasesAmountOf'
elif relation in CAUSAL_DEC... | Convert a transcription factor for edge. | Convert a transcription factor for edge. | [
"Convert",
"a",
"transcription",
"factor",
"for",
"edge",
"."
] | def convert(u: BaseEntity, v: BaseEntity, key: str, edge_data: EdgeData) -> Tuple[str, str, str]:
relation = edge_data[RELATION]
if relation in CAUSAL_INCREASE_RELATIONS:
relation = 'increasesAmountOf'
elif relation in CAUSAL_DECREASE_RELATIONS:
relation = 'decreasesAmoun... | [
"def",
"convert",
"(",
"u",
":",
"BaseEntity",
",",
"v",
":",
"BaseEntity",
",",
"key",
":",
"str",
",",
"edge_data",
":",
"EdgeData",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
",",
"str",
"]",
":",
"relation",
"=",
"edge_data",
"[",
"RELATION",
... | Convert a transcription factor for edge. | [
"Convert",
"a",
"transcription",
"factor",
"for",
"edge",
"."
] | [
"\"\"\"Convert a transcription factor for edge.\"\"\""
] | [
{
"param": "u",
"type": "BaseEntity"
},
{
"param": "v",
"type": "BaseEntity"
},
{
"param": "key",
"type": "str"
},
{
"param": "edge_data",
"type": "EdgeData"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "u",
"type": "BaseEntity",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "v",
"type": "BaseEntity",
"docstring": null,
"docstring_... |
1c2ac59cb95ab9b612e5fe0ce2de7aba2ecd8eb7 | rpatil524/pybel | src/pybel/io/hetionet/hetionet.py | [
"MIT"
] | Python | from_hetionet_gz | BELGraph | def from_hetionet_gz(path: str) -> BELGraph:
"""Get Hetionet from its JSON GZ file."""
logger.info('opening %s', path)
with bz2.open(path) as file:
return from_hetionet_file(file) | Get Hetionet from its JSON GZ file. | Get Hetionet from its JSON GZ file. | [
"Get",
"Hetionet",
"from",
"its",
"JSON",
"GZ",
"file",
"."
] | def from_hetionet_gz(path: str) -> BELGraph:
logger.info('opening %s', path)
with bz2.open(path) as file:
return from_hetionet_file(file) | [
"def",
"from_hetionet_gz",
"(",
"path",
":",
"str",
")",
"->",
"BELGraph",
":",
"logger",
".",
"info",
"(",
"'opening %s'",
",",
"path",
")",
"with",
"bz2",
".",
"open",
"(",
"path",
")",
"as",
"file",
":",
"return",
"from_hetionet_file",
"(",
"file",
... | Get Hetionet from its JSON GZ file. | [
"Get",
"Hetionet",
"from",
"its",
"JSON",
"GZ",
"file",
"."
] | [
"\"\"\"Get Hetionet from its JSON GZ file.\"\"\""
] | [
{
"param": "path",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "path",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1c2ac59cb95ab9b612e5fe0ce2de7aba2ecd8eb7 | rpatil524/pybel | src/pybel/io/hetionet/hetionet.py | [
"MIT"
] | Python | from_hetionet_file | BELGraph | def from_hetionet_file(file) -> BELGraph:
"""Get Hetionet from a JSON file."""
logger.info('parsing json from %s', file)
j = json.load(file)
logger.info('converting hetionet dict to BEL')
return from_hetionet_json(j) | Get Hetionet from a JSON file. | Get Hetionet from a JSON file. | [
"Get",
"Hetionet",
"from",
"a",
"JSON",
"file",
"."
] | def from_hetionet_file(file) -> BELGraph:
logger.info('parsing json from %s', file)
j = json.load(file)
logger.info('converting hetionet dict to BEL')
return from_hetionet_json(j) | [
"def",
"from_hetionet_file",
"(",
"file",
")",
"->",
"BELGraph",
":",
"logger",
".",
"info",
"(",
"'parsing json from %s'",
",",
"file",
")",
"j",
"=",
"json",
".",
"load",
"(",
"file",
")",
"logger",
".",
"info",
"(",
"'converting hetionet dict to BEL'",
")... | Get Hetionet from a JSON file. | [
"Get",
"Hetionet",
"from",
"a",
"JSON",
"file",
"."
] | [
"\"\"\"Get Hetionet from a JSON file.\"\"\""
] | [
{
"param": "file",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1c2ac59cb95ab9b612e5fe0ce2de7aba2ecd8eb7 | rpatil524/pybel | src/pybel/io/hetionet/hetionet.py | [
"MIT"
] | Python | from_hetionet_json | BELGraph | def from_hetionet_json(
hetionet_dict: Mapping[str, Any],
use_tqdm: bool = True,
) -> BELGraph:
"""Convert a Hetionet dictionary to a BEL graph."""
graph = BELGraph( # FIXME what metadata is appropriate?
name='Hetionet',
version='1.0',
authors='Daniel Himmelstein',
)
# F... | Convert a Hetionet dictionary to a BEL graph. | Convert a Hetionet dictionary to a BEL graph. | [
"Convert",
"a",
"Hetionet",
"dictionary",
"to",
"a",
"BEL",
"graph",
"."
] | def from_hetionet_json(
hetionet_dict: Mapping[str, Any],
use_tqdm: bool = True,
) -> BELGraph:
graph = BELGraph(
name='Hetionet',
version='1.0',
authors='Daniel Himmelstein',
)
kind_identifier_to_name = {
(x['kind'], x['identifier']): x['name']
for x in het... | [
"def",
"from_hetionet_json",
"(",
"hetionet_dict",
":",
"Mapping",
"[",
"str",
",",
"Any",
"]",
",",
"use_tqdm",
":",
"bool",
"=",
"True",
",",
")",
"->",
"BELGraph",
":",
"graph",
"=",
"BELGraph",
"(",
"name",
"=",
"'Hetionet'",
",",
"version",
"=",
"... | Convert a Hetionet dictionary to a BEL graph. | [
"Convert",
"a",
"Hetionet",
"dictionary",
"to",
"a",
"BEL",
"graph",
"."
] | [
"\"\"\"Convert a Hetionet dictionary to a BEL graph.\"\"\"",
"# FIXME what metadata is appropriate?",
"# FIXME add namespaces",
"# graph.namespace_pattern.update({})"
] | [
{
"param": "hetionet_dict",
"type": "Mapping[str, Any]"
},
{
"param": "use_tqdm",
"type": "bool"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "hetionet_dict",
"type": "Mapping[str, Any]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "use_tqdm",
"type": "bool",
"docstring": nul... |
44729a704d788b2d7c141ef49eedfe1c66834960 | rpatil524/pybel | tests/test_grounding.py | [
"MIT"
] | Python | normalize_gmod_default_methylation | null | def normalize_gmod_default_methylation(self, *_):
"""Test normalizing the default namespace's Me entry because of conflict with pmods."""
self._help(
{
CONCEPT: {NAMESPACE: 'hgnc', NAME: 'MAPT', IDENTIFIER: '6893'},
VARIANTS: [
{CONCEPT: {N... | Test normalizing the default namespace's Me entry because of conflict with pmods. | Test normalizing the default namespace's Me entry because of conflict with pmods. | [
"Test",
"normalizing",
"the",
"default",
"namespace",
"'",
"s",
"Me",
"entry",
"because",
"of",
"conflict",
"with",
"pmods",
"."
] | def normalize_gmod_default_methylation(self, *_):
self._help(
{
CONCEPT: {NAMESPACE: 'hgnc', NAME: 'MAPT', IDENTIFIER: '6893'},
VARIANTS: [
{CONCEPT: {NAMESPACE: 'go', IDENTIFIER: '0006306', NAME: 'DNA methylation'}, KIND: GMOD},
]
... | [
"def",
"normalize_gmod_default_methylation",
"(",
"self",
",",
"*",
"_",
")",
":",
"self",
".",
"_help",
"(",
"{",
"CONCEPT",
":",
"{",
"NAMESPACE",
":",
"'hgnc'",
",",
"NAME",
":",
"'MAPT'",
",",
"IDENTIFIER",
":",
"'6893'",
"}",
",",
"VARIANTS",
":",
... | Test normalizing the default namespace's Me entry because of conflict with pmods. | [
"Test",
"normalizing",
"the",
"default",
"namespace",
"'",
"s",
"Me",
"entry",
"because",
"of",
"conflict",
"with",
"pmods",
"."
] | [
"\"\"\"Test normalizing the default namespace's Me entry because of conflict with pmods.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | to_sbel_file | None | def to_sbel_file(graph: BELGraph, path: Union[str, TextIO], separators=(',', ':'), **kwargs) -> None:
"""Write this graph as BEL JSONL to a file.
:param graph: A BEL graph
:param separators: The separators used in :func:`json.dumps`
:param path: A path or file-like
"""
for i in iterate_sbel(gra... | Write this graph as BEL JSONL to a file.
:param graph: A BEL graph
:param separators: The separators used in :func:`json.dumps`
:param path: A path or file-like
| Write this graph as BEL JSONL to a file. | [
"Write",
"this",
"graph",
"as",
"BEL",
"JSONL",
"to",
"a",
"file",
"."
] | def to_sbel_file(graph: BELGraph, path: Union[str, TextIO], separators=(',', ':'), **kwargs) -> None:
for i in iterate_sbel(graph):
print(json.dumps(i, ensure_ascii=False, separators=separators, **kwargs), file=path) | [
"def",
"to_sbel_file",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"Union",
"[",
"str",
",",
"TextIO",
"]",
",",
"separators",
"=",
"(",
"','",
",",
"':'",
")",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"for",
"i",
"in",
"iterate_sbel",
"("... | Write this graph as BEL JSONL to a file. | [
"Write",
"this",
"graph",
"as",
"BEL",
"JSONL",
"to",
"a",
"file",
"."
] | [
"\"\"\"Write this graph as BEL JSONL to a file.\n\n :param graph: A BEL graph\n :param separators: The separators used in :func:`json.dumps`\n :param path: A path or file-like\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "Union[str, TextIO]"
},
{
"param": "separators",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "path",
... |
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | to_sbel_gz | None | def to_sbel_gz(graph: BELGraph, path: str, separators=(',', ':'), **kwargs) -> None:
"""Write a graph as BEL JSONL to a gzip file.
:param graph: A BEL graph
:param separators: The separators used in :func:`json.dumps`
:param path: A path for a gzip file
"""
with gzip.open(path, 'wt') as file:
... | Write a graph as BEL JSONL to a gzip file.
:param graph: A BEL graph
:param separators: The separators used in :func:`json.dumps`
:param path: A path for a gzip file
| Write a graph as BEL JSONL to a gzip file. | [
"Write",
"a",
"graph",
"as",
"BEL",
"JSONL",
"to",
"a",
"gzip",
"file",
"."
] | def to_sbel_gz(graph: BELGraph, path: str, separators=(',', ':'), **kwargs) -> None:
with gzip.open(path, 'wt') as file:
to_sbel_file(graph, file, separators=separators, **kwargs) | [
"def",
"to_sbel_gz",
"(",
"graph",
":",
"BELGraph",
",",
"path",
":",
"str",
",",
"separators",
"=",
"(",
"','",
",",
"':'",
")",
",",
"**",
"kwargs",
")",
"->",
"None",
":",
"with",
"gzip",
".",
"open",
"(",
"path",
",",
"'wt'",
")",
"as",
"file... | Write a graph as BEL JSONL to a gzip file. | [
"Write",
"a",
"graph",
"as",
"BEL",
"JSONL",
"to",
"a",
"gzip",
"file",
"."
] | [
"\"\"\"Write a graph as BEL JSONL to a gzip file.\n\n :param graph: A BEL graph\n :param separators: The separators used in :func:`json.dumps`\n :param path: A path for a gzip file\n \"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
},
{
"param": "path",
"type": "str"
},
{
"param": "separators",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": "A BEL graph",
"docstring_tokens": [
"A",
"BEL",
"graph"
],
"default": null,
"is_optional": null
},
{
"identifier": "path",
... |
44b3a086bf3b737d75906e237b8f768878d145e2 | rpatil524/pybel | src/pybel/io/sbel.py | [
"MIT"
] | Python | iterate_sbel | Iterable[SBEL] | def iterate_sbel(graph: BELGraph) -> Iterable[SBEL]:
"""Iterate over JSON dictionaries corresponding to lines in BEL JSONL."""
g = graph.graph.copy()
_prepare_graph_dict(g)
yield g
for u, v, k, d in graph.edges(data=True, keys=True):
yield {
'source': _augment_node(u),
... | Iterate over JSON dictionaries corresponding to lines in BEL JSONL. | Iterate over JSON dictionaries corresponding to lines in BEL JSONL. | [
"Iterate",
"over",
"JSON",
"dictionaries",
"corresponding",
"to",
"lines",
"in",
"BEL",
"JSONL",
"."
] | def iterate_sbel(graph: BELGraph) -> Iterable[SBEL]:
g = graph.graph.copy()
_prepare_graph_dict(g)
yield g
for u, v, k, d in graph.edges(data=True, keys=True):
yield {
'source': _augment_node(u),
'target': _augment_node(v),
'key': k,
**d,
} | [
"def",
"iterate_sbel",
"(",
"graph",
":",
"BELGraph",
")",
"->",
"Iterable",
"[",
"SBEL",
"]",
":",
"g",
"=",
"graph",
".",
"graph",
".",
"copy",
"(",
")",
"_prepare_graph_dict",
"(",
"g",
")",
"yield",
"g",
"for",
"u",
",",
"v",
",",
"k",
",",
"... | Iterate over JSON dictionaries corresponding to lines in BEL JSONL. | [
"Iterate",
"over",
"JSON",
"dictionaries",
"corresponding",
"to",
"lines",
"in",
"BEL",
"JSONL",
"."
] | [
"\"\"\"Iterate over JSON dictionaries corresponding to lines in BEL JSONL.\"\"\""
] | [
{
"param": "graph",
"type": "BELGraph"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "graph",
"type": "BELGraph",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.