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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
4017e4de6f5c06a8498f45b5415561b67f0357f1 | alexplaka/ML | CardiovascularDisease/CVD/preprocessor.py | [
"MIT"
] | Python | scaler | <not_specific> | def scaler(X_train: pd.DataFrame, X_test: pd.DataFrame, *, cat_feats=None, num_feats=None):
"""
Choose between scaling the data using the StandardScaler or heterogeneous scaling of features.
For heterogeneous scaling, the categorical and numerical features must be specified.
Then, apply:
- min_max ... |
Choose between scaling the data using the StandardScaler or heterogeneous scaling of features.
For heterogeneous scaling, the categorical and numerical features must be specified.
Then, apply:
- min_max scaling (from -1 to 1) for categoricals
(to avoid non-symmetric scaling about zero due to cat... | Choose between scaling the data using the StandardScaler or heterogeneous scaling of features.
For heterogeneous scaling, the categorical and numerical features must be specified.
Then, apply.
min_max scaling (from -1 to 1) for categoricals
(to avoid non-symmetric scaling about zero due to category frequencies in data... | [
"Choose",
"between",
"scaling",
"the",
"data",
"using",
"the",
"StandardScaler",
"or",
"heterogeneous",
"scaling",
"of",
"features",
".",
"For",
"heterogeneous",
"scaling",
"the",
"categorical",
"and",
"numerical",
"features",
"must",
"be",
"specified",
".",
"Then... | def scaler(X_train: pd.DataFrame, X_test: pd.DataFrame, *, cat_feats=None, num_feats=None):
if num_feats is None:
num_feats = []
if cat_feats is None:
cat_feats = []
X_train_scaled = pd.DataFrame()
X_test_scaled = pd.DataFrame()
std_scaler = StandardScaler()
if len(cat_feats) == ... | [
"def",
"scaler",
"(",
"X_train",
":",
"pd",
".",
"DataFrame",
",",
"X_test",
":",
"pd",
".",
"DataFrame",
",",
"*",
",",
"cat_feats",
"=",
"None",
",",
"num_feats",
"=",
"None",
")",
":",
"if",
"num_feats",
"is",
"None",
":",
"num_feats",
"=",
"[",
... | Choose between scaling the data using the StandardScaler or heterogeneous scaling of features. | [
"Choose",
"between",
"scaling",
"the",
"data",
"using",
"the",
"StandardScaler",
"or",
"heterogeneous",
"scaling",
"of",
"features",
"."
] | [
"\"\"\"\n Choose between scaling the data using the StandardScaler or heterogeneous scaling of features.\n For heterogeneous scaling, the categorical and numerical features must be specified.\n Then, apply:\n\n - min_max scaling (from -1 to 1) for categoricals\n (to avoid non-symmetric scaling abou... | [
{
"param": "X_train",
"type": "pd.DataFrame"
},
{
"param": "X_test",
"type": "pd.DataFrame"
},
{
"param": "cat_feats",
"type": null
},
{
"param": "num_feats",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X_train",
"type": "pd.DataFrame",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "X_test",
"type": "pd.DataFrame",
"docstring": null,
... |
601bfff40ff4e36db50878bc4951e09fe657a7db | mjburling/beneficiary-fhir-data | ops/ccs-ops-misc/load_test/common/db.py | [
"CC0-1.0"
] | Python | _execute | <not_specific> | def _execute(uri, query):
"""
Execute a PSQL select statement and return its results
"""
print('Collecting test data...')
conn = None
try:
with psycopg2.connect(uri) as conn:
with conn.cursor() as cursor:
cursor.execute(query)
results = curso... |
Execute a PSQL select statement and return its results
| Execute a PSQL select statement and return its results | [
"Execute",
"a",
"PSQL",
"select",
"statement",
"and",
"return",
"its",
"results"
] | def _execute(uri, query):
print('Collecting test data...')
conn = None
try:
with psycopg2.connect(uri) as conn:
with conn.cursor() as cursor:
cursor.execute(query)
results = cursor.fetchall()
print(f'Returned {len(results)} results from the... | [
"def",
"_execute",
"(",
"uri",
",",
"query",
")",
":",
"print",
"(",
"'Collecting test data...'",
")",
"conn",
"=",
"None",
"try",
":",
"with",
"psycopg2",
".",
"connect",
"(",
"uri",
")",
"as",
"conn",
":",
"with",
"conn",
".",
"cursor",
"(",
")",
"... | Execute a PSQL select statement and return its results | [
"Execute",
"a",
"PSQL",
"select",
"statement",
"and",
"return",
"its",
"results"
] | [
"\"\"\"\n Execute a PSQL select statement and return its results\n \"\"\""
] | [
{
"param": "uri",
"type": null
},
{
"param": "query",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "uri",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": [... |
b92c4b12504acfb84deb57c01f5f1c257df58abd | PiochU19/image-loader | image_loader/image/utils.py | [
"MIT"
] | Python | create_link | <not_specific> | def create_link(seconds, image_name, size):
"""
Function returns temporary link to the image
"""
token = signing.dumps([str(timezone.now() + timedelta(seconds=int(seconds))), image_name, size])
return settings.SERVER_PATH + reverse("image:dynamic-image", kwargs={"token": token}) |
Function returns temporary link to the image
| Function returns temporary link to the image | [
"Function",
"returns",
"temporary",
"link",
"to",
"the",
"image"
] | def create_link(seconds, image_name, size):
token = signing.dumps([str(timezone.now() + timedelta(seconds=int(seconds))), image_name, size])
return settings.SERVER_PATH + reverse("image:dynamic-image", kwargs={"token": token}) | [
"def",
"create_link",
"(",
"seconds",
",",
"image_name",
",",
"size",
")",
":",
"token",
"=",
"signing",
".",
"dumps",
"(",
"[",
"str",
"(",
"timezone",
".",
"now",
"(",
")",
"+",
"timedelta",
"(",
"seconds",
"=",
"int",
"(",
"seconds",
")",
")",
"... | Function returns temporary link to the image | [
"Function",
"returns",
"temporary",
"link",
"to",
"the",
"image"
] | [
"\"\"\"\n Function returns temporary link to the image\n \"\"\""
] | [
{
"param": "seconds",
"type": null
},
{
"param": "image_name",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "seconds",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "image_name",
"type": null,
"docstring": null,
"docstring_t... |
d882be85d3ea1c0f0b903335b48b6b624cd01aad | decarlof/CTSegNet | ct_segnet/train_utils.py | [
"BSD-3-Clause"
] | Python | data_generator | null | def data_generator(X, Y, batch_size):
"""Generator that yields randomly sampled data pairs of size batch_size.
X, Y are DataFile object pairs of train / test / validation data.
"""
while True:
idxs = sorted(random.sample(range(X.d_shape[0]), batch_size))
x = X.read_sequence(idxs)
... | Generator that yields randomly sampled data pairs of size batch_size.
X, Y are DataFile object pairs of train / test / validation data.
| Generator that yields randomly sampled data pairs of size batch_size.
X, Y are DataFile object pairs of train / test / validation data. | [
"Generator",
"that",
"yields",
"randomly",
"sampled",
"data",
"pairs",
"of",
"size",
"batch_size",
".",
"X",
"Y",
"are",
"DataFile",
"object",
"pairs",
"of",
"train",
"/",
"test",
"/",
"validation",
"data",
"."
] | def data_generator(X, Y, batch_size):
while True:
idxs = sorted(random.sample(range(X.d_shape[0]), batch_size))
x = X.read_sequence(idxs)
y = Y.read_sequence(idxs)
y = _norm(y)
yield (x[...,np.newaxis], y[...,np.newaxis]) | [
"def",
"data_generator",
"(",
"X",
",",
"Y",
",",
"batch_size",
")",
":",
"while",
"True",
":",
"idxs",
"=",
"sorted",
"(",
"random",
".",
"sample",
"(",
"range",
"(",
"X",
".",
"d_shape",
"[",
"0",
"]",
")",
",",
"batch_size",
")",
")",
"x",
"="... | Generator that yields randomly sampled data pairs of size batch_size. | [
"Generator",
"that",
"yields",
"randomly",
"sampled",
"data",
"pairs",
"of",
"size",
"batch_size",
"."
] | [
"\"\"\"Generator that yields randomly sampled data pairs of size batch_size.\n X, Y are DataFile object pairs of train / test / validation data.\n \"\"\""
] | [
{
"param": "X",
"type": null
},
{
"param": "Y",
"type": null
},
{
"param": "batch_size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "X",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "Y",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
d882be85d3ea1c0f0b903335b48b6b624cd01aad | decarlof/CTSegNet | ct_segnet/train_utils.py | [
"BSD-3-Clause"
] | Python | ROC | <not_specific> | def ROC(thresh, y_true = None, y_pred = None):
"""Receiver Operating Characteristics (ROC) curve
"""
y_p = np.zeros_like(y_pred)
y_p[y_pred > thresh] = 1
y_true = np.copy(y_true)
TN = np.sum((1-y_true)*(1-y_p)).astype(np.float32)
FP = np.sum((1-y_true)*y_p).astype(np.float32)
... | Receiver Operating Characteristics (ROC) curve
| Receiver Operating Characteristics (ROC) curve | [
"Receiver",
"Operating",
"Characteristics",
"(",
"ROC",
")",
"curve"
] | def ROC(thresh, y_true = None, y_pred = None):
y_p = np.zeros_like(y_pred)
y_p[y_pred > thresh] = 1
y_true = np.copy(y_true)
TN = np.sum((1-y_true)*(1-y_p)).astype(np.float32)
FP = np.sum((1-y_true)*y_p).astype(np.float32)
TNR = TN / (TN + FP)
FPR = 1 - TNR
TP = np.sum(y_true*y_p).astype... | [
"def",
"ROC",
"(",
"thresh",
",",
"y_true",
"=",
"None",
",",
"y_pred",
"=",
"None",
")",
":",
"y_p",
"=",
"np",
".",
"zeros_like",
"(",
"y_pred",
")",
"y_p",
"[",
"y_pred",
">",
"thresh",
"]",
"=",
"1",
"y_true",
"=",
"np",
".",
"copy",
"(",
"... | Receiver Operating Characteristics (ROC) curve | [
"Receiver",
"Operating",
"Characteristics",
"(",
"ROC",
")",
"curve"
] | [
"\"\"\"Receiver Operating Characteristics (ROC) curve\n \"\"\""
] | [
{
"param": "thresh",
"type": null
},
{
"param": "y_true",
"type": null
},
{
"param": "y_pred",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "thresh",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y_true",
"type": null,
"docstring": null,
"docstring_tokens... |
d882be85d3ea1c0f0b903335b48b6b624cd01aad | decarlof/CTSegNet | ct_segnet/train_utils.py | [
"BSD-3-Clause"
] | Python | calc_jac_acc | <not_specific> | def calc_jac_acc(y_true, y_pred):
"""Jaccard accuracy or Intersection over Union
"""
y_pred = np.round(np.copy(y_pred))
jac_acc = (np.sum(y_pred*y_true) + 1) / (np.sum(y_pred) + np.sum(y_true) - np.sum(y_pred*y_true) + 1)
return jac_acc | Jaccard accuracy or Intersection over Union
| Jaccard accuracy or Intersection over Union | [
"Jaccard",
"accuracy",
"or",
"Intersection",
"over",
"Union"
] | def calc_jac_acc(y_true, y_pred):
y_pred = np.round(np.copy(y_pred))
jac_acc = (np.sum(y_pred*y_true) + 1) / (np.sum(y_pred) + np.sum(y_true) - np.sum(y_pred*y_true) + 1)
return jac_acc | [
"def",
"calc_jac_acc",
"(",
"y_true",
",",
"y_pred",
")",
":",
"y_pred",
"=",
"np",
".",
"round",
"(",
"np",
".",
"copy",
"(",
"y_pred",
")",
")",
"jac_acc",
"=",
"(",
"np",
".",
"sum",
"(",
"y_pred",
"*",
"y_true",
")",
"+",
"1",
")",
"/",
"("... | Jaccard accuracy or Intersection over Union | [
"Jaccard",
"accuracy",
"or",
"Intersection",
"over",
"Union"
] | [
"\"\"\"Jaccard accuracy or Intersection over Union\n \"\"\""
] | [
{
"param": "y_true",
"type": null
},
{
"param": "y_pred",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "y_true",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y_pred",
"type": null,
"docstring": null,
"docstring_tokens... |
d882be85d3ea1c0f0b903335b48b6b624cd01aad | decarlof/CTSegNet | ct_segnet/train_utils.py | [
"BSD-3-Clause"
] | Python | fidelity | <not_specific> | def fidelity(y_true, y_pred, tolerance = 0.95):
"""Fidelity is number of images with IoU > tolerance
"""
XY = [(y_true[ii], y_pred[ii]) for ii in range(y_true.shape[0])]
del y_true
del y_pred
jac_acc = np.asarray(Parallelize(XY, calc_jac_acc, procs = cpu_count()))
mean_IoU = np.me... | Fidelity is number of images with IoU > tolerance
| Fidelity is number of images with IoU > tolerance | [
"Fidelity",
"is",
"number",
"of",
"images",
"with",
"IoU",
">",
"tolerance"
] | def fidelity(y_true, y_pred, tolerance = 0.95):
XY = [(y_true[ii], y_pred[ii]) for ii in range(y_true.shape[0])]
del y_true
del y_pred
jac_acc = np.asarray(Parallelize(XY, calc_jac_acc, procs = cpu_count()))
mean_IoU = np.mean(jac_acc)
jac_fid = np.zeros_like(jac_acc)
jac_fid[jac_acc > toler... | [
"def",
"fidelity",
"(",
"y_true",
",",
"y_pred",
",",
"tolerance",
"=",
"0.95",
")",
":",
"XY",
"=",
"[",
"(",
"y_true",
"[",
"ii",
"]",
",",
"y_pred",
"[",
"ii",
"]",
")",
"for",
"ii",
"in",
"range",
"(",
"y_true",
".",
"shape",
"[",
"0",
"]",... | Fidelity is number of images with IoU > tolerance | [
"Fidelity",
"is",
"number",
"of",
"images",
"with",
"IoU",
">",
"tolerance"
] | [
"\"\"\"Fidelity is number of images with IoU > tolerance\n \"\"\""
] | [
{
"param": "y_true",
"type": null
},
{
"param": "y_pred",
"type": null
},
{
"param": "tolerance",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "y_true",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "y_pred",
"type": null,
"docstring": null,
"docstring_tokens... |
d882be85d3ea1c0f0b903335b48b6b624cd01aad | decarlof/CTSegNet | ct_segnet/train_utils.py | [
"BSD-3-Clause"
] | Python | save_results | <not_specific> | def save_results(dg, model_results, segmenter):
"""Save some results on test images into a folder in the path to model repo
"""
x_test, y_test = next(dg)
y_pred = segmenter.predict(x_test)
y_pred = np.round(y_pred)
x_test, y_test, y_pred = x_test[...,0], y_test[...,0], y_pred[...,0]
... | Save some results on test images into a folder in the path to model repo
| Save some results on test images into a folder in the path to model repo | [
"Save",
"some",
"results",
"on",
"test",
"images",
"into",
"a",
"folder",
"in",
"the",
"path",
"to",
"model",
"repo"
] | def save_results(dg, model_results, segmenter):
x_test, y_test = next(dg)
y_pred = segmenter.predict(x_test)
y_pred = np.round(y_pred)
x_test, y_test, y_pred = x_test[...,0], y_test[...,0], y_pred[...,0]
if not os.path.exists(os.path.join(model_results,"data_snaps")):
os.makedirs(os.path.joi... | [
"def",
"save_results",
"(",
"dg",
",",
"model_results",
",",
"segmenter",
")",
":",
"x_test",
",",
"y_test",
"=",
"next",
"(",
"dg",
")",
"y_pred",
"=",
"segmenter",
".",
"predict",
"(",
"x_test",
")",
"y_pred",
"=",
"np",
".",
"round",
"(",
"y_pred",
... | Save some results on test images into a folder in the path to model repo | [
"Save",
"some",
"results",
"on",
"test",
"images",
"into",
"a",
"folder",
"in",
"the",
"path",
"to",
"model",
"repo"
] | [
"\"\"\"Save some results on test images into a folder in the path to model repo\n \"\"\"",
"#jac_acc = (np.sum(y_pred[ii]*y_test[ii]) + 1) / (np.sum(y_pred[ii]) + np.sum(y_test[ii]) - np.sum(y_pred[ii]*y_test[ii]) + 1)"
] | [
{
"param": "dg",
"type": null
},
{
"param": "model_results",
"type": null
},
{
"param": "segmenter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dg",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "model_results",
"type": null,
"docstring": null,
"docstring_tok... |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | show_stats | null | def show_stats(self):
"""print dataset shape and slice-wise size
"""
_message("Dataset shape: %s"%(str(self.d_shape)), self.VERBOSITY > -1)
_message("Dataset size: %.2f GB"%self.d_size_GB, self.VERBOSITY > -1)
if not self.tiff_mode: _message("Chunk shape: %s"%(str(self.chunk_shap... | print dataset shape and slice-wise size
| print dataset shape and slice-wise size | [
"print",
"dataset",
"shape",
"and",
"slice",
"-",
"wise",
"size"
] | def show_stats(self):
_message("Dataset shape: %s"%(str(self.d_shape)), self.VERBOSITY > -1)
_message("Dataset size: %.2f GB"%self.d_size_GB, self.VERBOSITY > -1)
if not self.tiff_mode: _message("Chunk shape: %s"%(str(self.chunk_shape)), self.VERBOSITY > -1)
for _i, _size in enumerate(se... | [
"def",
"show_stats",
"(",
"self",
")",
":",
"_message",
"(",
"\"Dataset shape: %s\"",
"%",
"(",
"str",
"(",
"self",
".",
"d_shape",
")",
")",
",",
"self",
".",
"VERBOSITY",
">",
"-",
"1",
")",
"_message",
"(",
"\"Dataset size: %.2f GB\"",
"%",
"self",
".... | print dataset shape and slice-wise size | [
"print",
"dataset",
"shape",
"and",
"slice",
"-",
"wise",
"size"
] | [
"\"\"\"print dataset shape and slice-wise size\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | est_chunking | <not_specific> | def est_chunking(self): # Determine the chunk shape for hdf5 file, optimized for slicing along all 3 axes
"""Determines the chunks attribute in hdf5 file based on one of two methods:
chunked_slice_size : in GB - size of a chunk of some slices along an axis
chunk_size : in GB - size of a ... | Determines the chunks attribute in hdf5 file based on one of two methods:
chunked_slice_size : in GB - size of a chunk of some slices along an axis
chunk_size : in GB - size of a hyperslab of shape proportional to data shape
| Determines the chunks attribute in hdf5 file based on one of two methods:
chunked_slice_size : in GB - size of a chunk of some slices along an axis
chunk_size : in GB - size of a hyperslab of shape proportional to data shape | [
"Determines",
"the",
"chunks",
"attribute",
"in",
"hdf5",
"file",
"based",
"on",
"one",
"of",
"two",
"methods",
":",
"chunked_slice_size",
":",
"in",
"GB",
"-",
"size",
"of",
"a",
"chunk",
"of",
"some",
"slices",
"along",
"an",
"axis",
"chunk_size",
":",
... | def est_chunking(self):
if self.tiff_mode:
self.chunked_shape = None
else:
if self.chunk_shape is not None:
return
if self.chunk_size is not None:
fac = np.cbrt((self.chunk_size) / (self.d_size_GB))
self.chunk_shape = ... | [
"def",
"est_chunking",
"(",
"self",
")",
":",
"if",
"self",
".",
"tiff_mode",
":",
"self",
".",
"chunked_shape",
"=",
"None",
"else",
":",
"if",
"self",
".",
"chunk_shape",
"is",
"not",
"None",
":",
"return",
"if",
"self",
".",
"chunk_size",
"is",
"not... | Determines the chunks attribute in hdf5 file based on one of two methods:
chunked_slice_size : in GB - size of a chunk of some slices along an axis
chunk_size : in GB - size of a hyperslab of shape proportional to data shape | [
"Determines",
"the",
"chunks",
"attribute",
"in",
"hdf5",
"file",
"based",
"on",
"one",
"of",
"two",
"methods",
":",
"chunked_slice_size",
":",
"in",
"GB",
"-",
"size",
"of",
"a",
"chunk",
"of",
"some",
"slices",
"along",
"an",
"axis",
"chunk_size",
":",
... | [
"# Determine the chunk shape for hdf5 file, optimized for slicing along all 3 axes",
"\"\"\"Determines the chunks attribute in hdf5 file based on one of two methods:\n chunked_slice_size : in GB - size of a chunk of some slices along an axis\n chunk_size : in GB - size of a hyperslab of shap... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | read_data | <not_specific> | def read_data(self, slice_3D = (slice(None,None),)*3):
"""Read a block of data. Only supported for hdf5 datasets.
slice_3D : list of three python slices e.g. [slice(start,stop,step)]*3
"""
if self.tiff_mode:
ch = np.asarray(read_tiffseq(self.fname, s = slice_3D[0])... | Read a block of data. Only supported for hdf5 datasets.
slice_3D : list of three python slices e.g. [slice(start,stop,step)]*3
| Read a block of data. Only supported for hdf5 datasets.
slice_3D : list of three python slices e.g. | [
"Read",
"a",
"block",
"of",
"data",
".",
"Only",
"supported",
"for",
"hdf5",
"datasets",
".",
"slice_3D",
":",
"list",
"of",
"three",
"python",
"slices",
"e",
".",
"g",
"."
] | def read_data(self, slice_3D = (slice(None,None),)*3):
if self.tiff_mode:
ch = np.asarray(read_tiffseq(self.fname, s = slice_3D[0]))
ch = ch[:, slice_3D[1], slice_3D[2]]
with h5py.File(self.fname, 'r') as hf:
_message("Reading hdf5: %s, Z: %s, Y: %s, X: %s"%(self.fnam... | [
"def",
"read_data",
"(",
"self",
",",
"slice_3D",
"=",
"(",
"slice",
"(",
"None",
",",
"None",
")",
",",
")",
"*",
"3",
")",
":",
"if",
"self",
".",
"tiff_mode",
":",
"ch",
"=",
"np",
".",
"asarray",
"(",
"read_tiffseq",
"(",
"self",
".",
"fname"... | Read a block of data. | [
"Read",
"a",
"block",
"of",
"data",
"."
] | [
"\"\"\"Read a block of data. Only supported for hdf5 datasets.\n slice_3D : list of three python slices e.g. [slice(start,stop,step)]*3\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "slice_3D",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "slice_3D",
"type": null,
"docstring": null,
"docstring_tokens... |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | read_sequence | <not_specific> | def read_sequence(self, idxs):
"""Read a list of indices idxs along axis 0
"""
with h5py.File(self.fname, 'r') as hf:
return np.asarray(hf[self.data_tag][idxs,...]) | Read a list of indices idxs along axis 0
| Read a list of indices idxs along axis 0 | [
"Read",
"a",
"list",
"of",
"indices",
"idxs",
"along",
"axis",
"0"
] | def read_sequence(self, idxs):
with h5py.File(self.fname, 'r') as hf:
return np.asarray(hf[self.data_tag][idxs,...]) | [
"def",
"read_sequence",
"(",
"self",
",",
"idxs",
")",
":",
"with",
"h5py",
".",
"File",
"(",
"self",
".",
"fname",
",",
"'r'",
")",
"as",
"hf",
":",
"return",
"np",
".",
"asarray",
"(",
"hf",
"[",
"self",
".",
"data_tag",
"]",
"[",
"idxs",
",",
... | Read a list of indices idxs along axis 0 | [
"Read",
"a",
"list",
"of",
"indices",
"idxs",
"along",
"axis",
"0"
] | [
"\"\"\"Read a list of indices idxs along axis 0\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "idxs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "idxs",
"type": null,
"docstring": null,
"docstring_tokens": [... |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | write_full | <not_specific> | def write_full(self, ch):
"""Write the full dataset to filepath.
"""
self.write_chunk(ch, axis = 0, s = slice(0, self.d_shape[0]))
return | Write the full dataset to filepath.
| Write the full dataset to filepath. | [
"Write",
"the",
"full",
"dataset",
"to",
"filepath",
"."
] | def write_full(self, ch):
self.write_chunk(ch, axis = 0, s = slice(0, self.d_shape[0]))
return | [
"def",
"write_full",
"(",
"self",
",",
"ch",
")",
":",
"self",
".",
"write_chunk",
"(",
"ch",
",",
"axis",
"=",
"0",
",",
"s",
"=",
"slice",
"(",
"0",
",",
"self",
".",
"d_shape",
"[",
"0",
"]",
")",
")",
"return"
] | Write the full dataset to filepath. | [
"Write",
"the",
"full",
"dataset",
"to",
"filepath",
"."
] | [
"\"\"\"Write the full dataset to filepath.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ch",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ch",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | read_tiffseq | <not_specific> | def read_tiffseq(userfilepath = '', procs = None, s = None):
"""Read a sequence of tiff images from folder.
userfilepath : path to folder containing images
s : s is either a slice(start, stop, step) or a list of indices to be read
"""
if not userfilepath:
raise ValueError("File ... | Read a sequence of tiff images from folder.
userfilepath : path to folder containing images
s : s is either a slice(start, stop, step) or a list of indices to be read
| Read a sequence of tiff images from folder.
userfilepath : path to folder containing images
s : s is either a slice(start, stop, step) or a list of indices to be read | [
"Read",
"a",
"sequence",
"of",
"tiff",
"images",
"from",
"folder",
".",
"userfilepath",
":",
"path",
"to",
"folder",
"containing",
"images",
"s",
":",
"s",
"is",
"either",
"a",
"slice",
"(",
"start",
"stop",
"step",
")",
"or",
"a",
"list",
"of",
"indic... | def read_tiffseq(userfilepath = '', procs = None, s = None):
if not userfilepath:
raise ValueError("File path is required.")
return []
if procs == None:
procs = cpu_count()
ImgFileList = sorted(glob.glob(userfilepath+'/*.tif'))
if not ImgFileList: ImgFileList = sorted(glob.glob(u... | [
"def",
"read_tiffseq",
"(",
"userfilepath",
"=",
"''",
",",
"procs",
"=",
"None",
",",
"s",
"=",
"None",
")",
":",
"if",
"not",
"userfilepath",
":",
"raise",
"ValueError",
"(",
"\"File path is required.\"",
")",
"return",
"[",
"]",
"if",
"procs",
"==",
"... | Read a sequence of tiff images from folder. | [
"Read",
"a",
"sequence",
"of",
"tiff",
"images",
"from",
"folder",
"."
] | [
"\"\"\"Read a sequence of tiff images from folder.\n userfilepath : path to folder containing images\n s : s is either a slice(start, stop, step) or a list of indices to be read \n \"\"\""
] | [
{
"param": "userfilepath",
"type": null
},
{
"param": "procs",
"type": null
},
{
"param": "s",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "userfilepath",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "procs",
"type": null,
"docstring": null,
"docstring_t... |
246492a59058b7d5b7b3ba68db2de42bfffb7bc4 | decarlof/CTSegNet | ct_segnet/data_utils/data_io.py | [
"BSD-3-Clause"
] | Python | write_tiffseq | <not_specific> | def write_tiffseq(S, SaveDir = "", increment_flag = False,\
suffix_len = None):
"""Write a sequence of tiff images to a directory.
S : numpy array (3D), sequence will be created along axis 0
SaveDir : str, path to folder, will create directory if doesn't exist
incre... | Write a sequence of tiff images to a directory.
S : numpy array (3D), sequence will be created along axis 0
SaveDir : str, path to folder, will create directory if doesn't exist
increment_flag : bool, True to write append images to existing ones in folder
suffix_len : int, e.g. 4... | Write a sequence of tiff images to a directory.
S : numpy array (3D), sequence will be created along axis 0
SaveDir : str, path to folder, will create directory if doesn't exist
increment_flag : bool, True to write append images to existing ones in folder
suffix_len : int, e.g. | [
"Write",
"a",
"sequence",
"of",
"tiff",
"images",
"to",
"a",
"directory",
".",
"S",
":",
"numpy",
"array",
"(",
"3D",
")",
"sequence",
"will",
"be",
"created",
"along",
"axis",
"0",
"SaveDir",
":",
"str",
"path",
"to",
"folder",
"will",
"create",
"dire... | def write_tiffseq(S, SaveDir = "", increment_flag = False,\
suffix_len = None):
if not suffix_len:
if increment_flag:
raise ValueError("suffix_len required if increment_flag is True.")
else:
suffix_len = len(str(S.shape[0]))
last_num = 0
if not os.pa... | [
"def",
"write_tiffseq",
"(",
"S",
",",
"SaveDir",
"=",
"\"\"",
",",
"increment_flag",
"=",
"False",
",",
"suffix_len",
"=",
"None",
")",
":",
"if",
"not",
"suffix_len",
":",
"if",
"increment_flag",
":",
"raise",
"ValueError",
"(",
"\"suffix_len required if inc... | Write a sequence of tiff images to a directory. | [
"Write",
"a",
"sequence",
"of",
"tiff",
"images",
"to",
"a",
"directory",
"."
] | [
"\"\"\"Write a sequence of tiff images to a directory.\n S : numpy array (3D), sequence will be created along axis 0\n SaveDir : str, path to folder, will create directory if doesn't exist\n increment_flag : bool, True to write append images to existing ones in folder\n suffix_len ... | [
{
"param": "S",
"type": null
},
{
"param": "SaveDir",
"type": null
},
{
"param": "increment_flag",
"type": null
},
{
"param": "suffix_len",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "S",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "SaveDir",
"type": null,
"docstring": null,
"docstring_tokens": [... |
009e774d5ab555bba8d1cfc921d3e1688be123ba | decarlof/CTSegNet | ct_segnet/seg_utils.py | [
"BSD-3-Clause"
] | Python | seg_image | <not_specific> | def seg_image(self, p, max_patches = None, overlap = None):
"""function to test the segmenter on arbitrary sized 2D image;\
extracts patches shape = input shape of 2D CNN
max_patches : tuple, (my, mx) are # of patches along Y, X in image
p : greyscale image of shape (ny, nx)
... | function to test the segmenter on arbitrary sized 2D image;\
extracts patches shape = input shape of 2D CNN
max_patches : tuple, (my, mx) are # of patches along Y, X in image
p : greyscale image of shape (ny, nx)
overlap : tuple or int, number of overlapping pixels between ... | function to test the segmenter on arbitrary sized 2D image;\
extracts patches shape = input shape of 2D CNN
max_patches : tuple, (my, mx) are # of patches along Y, X in image
p : greyscale image of shape (ny, nx)
overlap : tuple or int, number of overlapping pixels between patches | [
"function",
"to",
"test",
"the",
"segmenter",
"on",
"arbitrary",
"sized",
"2D",
"image",
";",
"\\",
"extracts",
"patches",
"shape",
"=",
"input",
"shape",
"of",
"2D",
"CNN",
"max_patches",
":",
"tuple",
"(",
"my",
"mx",
")",
"are",
"#",
"of",
"patches",
... | def seg_image(self, p, max_patches = None, overlap = None):
patch_size = self.model.output_shape[1:-1]
if type(max_patches) is not tuple:
max_patches = (max_patches, max_patches)
if type(overlap) is not tuple:
overlap = (overlap, overlap)
overlap = (0 if max_p... | [
"def",
"seg_image",
"(",
"self",
",",
"p",
",",
"max_patches",
"=",
"None",
",",
"overlap",
"=",
"None",
")",
":",
"patch_size",
"=",
"self",
".",
"model",
".",
"output_shape",
"[",
"1",
":",
"-",
"1",
"]",
"if",
"type",
"(",
"max_patches",
")",
"i... | function to test the segmenter on arbitrary sized 2D image;\
extracts patches shape = input shape of 2D CNN
max_patches : tuple, (my, mx) are # of patches along Y, X in image
p : greyscale image of shape (ny, nx)
overlap : tuple or int, number of overlapping pixels between patches | [
"function",
"to",
"test",
"the",
"segmenter",
"on",
"arbitrary",
"sized",
"2D",
"image",
";",
"\\",
"extracts",
"patches",
"shape",
"=",
"input",
"shape",
"of",
"2D",
"CNN",
"max_patches",
":",
"tuple",
"(",
"my",
"mx",
")",
"are",
"#",
"of",
"patches",
... | [
"\"\"\"function to test the segmenter on arbitrary sized 2D image;\\\n extracts patches shape = input shape of 2D CNN\n max_patches : tuple, (my, mx) are # of patches along Y, X in image\n p : greyscale image of shape (ny, nx)\n overlap : tuple or int, number of overlapping... | [
{
"param": "self",
"type": null
},
{
"param": "p",
"type": null
},
{
"param": "max_patches",
"type": null
},
{
"param": "overlap",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "p",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
009e774d5ab555bba8d1cfc921d3e1688be123ba | decarlof/CTSegNet | ct_segnet/seg_utils.py | [
"BSD-3-Clause"
] | Python | seg_chunk | <not_specific> | def seg_chunk(self, p, max_patches = None, overlap = None,\
nprocs = None, arr_split = 1):
"""Segment a volume of shape (nslices, ny, nx). The 2D keras model passes\
along nslices, segmenting images (ny, nx) with a patch size defined by input \
to the model
max_patches ... | Segment a volume of shape (nslices, ny, nx). The 2D keras model passes\
along nslices, segmenting images (ny, nx) with a patch size defined by input \
to the model
max_patches : tuple, (my, mx) are # of patches along Y, X in image (ny, nx)
overlap : tuple or int, number of overla... | Segment a volume of shape (nslices, ny, nx). The 2D keras model passes\
along nslices, segmenting images (ny, nx) with a patch size defined by input \
to the model
max_patches : tuple, (my, mx) are # of patches along Y, X in image (ny, nx)
overlap : tuple or int, number of overlapping pixels between patches
npr... | [
"Segment",
"a",
"volume",
"of",
"shape",
"(",
"nslices",
"ny",
"nx",
")",
".",
"The",
"2D",
"keras",
"model",
"passes",
"\\",
"along",
"nslices",
"segmenting",
"images",
"(",
"ny",
"nx",
")",
"with",
"a",
"patch",
"size",
"defined",
"by",
"input",
"\\"... | def seg_chunk(self, p, max_patches = None, overlap = None,\
nprocs = None, arr_split = 1):
patch_size = self.model.output_shape[1:-1]
if type(max_patches) is not tuple:
max_patches = (max_patches, max_patches)
if type(overlap) is not tuple:
overlap = (ov... | [
"def",
"seg_chunk",
"(",
"self",
",",
"p",
",",
"max_patches",
"=",
"None",
",",
"overlap",
"=",
"None",
",",
"nprocs",
"=",
"None",
",",
"arr_split",
"=",
"1",
")",
":",
"patch_size",
"=",
"self",
".",
"model",
".",
"output_shape",
"[",
"1",
":",
... | Segment a volume of shape (nslices, ny, nx). | [
"Segment",
"a",
"volume",
"of",
"shape",
"(",
"nslices",
"ny",
"nx",
")",
"."
] | [
"\"\"\"Segment a volume of shape (nslices, ny, nx). The 2D keras model passes\\\n along nslices, segmenting images (ny, nx) with a patch size defined by input \\\n to the model\n max_patches : tuple, (my, mx) are # of patches along Y, X in image (ny, nx)\n overlap : tuple or int,... | [
{
"param": "self",
"type": null
},
{
"param": "p",
"type": null
},
{
"param": "max_patches",
"type": null
},
{
"param": "overlap",
"type": null
},
{
"param": "nprocs",
"type": null
},
{
"param": "arr_split",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "p",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
009e774d5ab555bba8d1cfc921d3e1688be123ba | decarlof/CTSegNet | ct_segnet/seg_utils.py | [
"BSD-3-Clause"
] | Python | process_data | <not_specific> | def process_data(p, segmenter, preprocess_func = None, max_patches = None,\
overlap = None, nprocs = None, rot_angle = 0.0, slice_axis = 0,\
crops = None, arr_split = 1):
"""Segment a volume of shape (nz, ny, nx). The 2D keras model passes
along either axis (0,1,2), segmenting ... | Segment a volume of shape (nz, ny, nx). The 2D keras model passes
along either axis (0,1,2), segmenting images with a patch size defined by input
to the model in the segmenter class.
max_patches : tuple, (?,?) number of patches along each axis of 2D image
overlap : tuple or int, number of ov... | Segment a volume of shape (nz, ny, nx). The 2D keras model passes
along either axis (0,1,2), segmenting images with a patch size defined by input
to the model in the segmenter class.
nprocs : number of CPU processors for multiprocessing Pool
arr_split : breakdown chunk into arr_split number of smaller c... | [
"Segment",
"a",
"volume",
"of",
"shape",
"(",
"nz",
"ny",
"nx",
")",
".",
"The",
"2D",
"keras",
"model",
"passes",
"along",
"either",
"axis",
"(",
"0",
"1",
"2",
")",
"segmenting",
"images",
"with",
"a",
"patch",
"size",
"defined",
"by",
"input",
"to... | def process_data(p, segmenter, preprocess_func = None, max_patches = None,\
overlap = None, nprocs = None, rot_angle = 0.0, slice_axis = 0,\
crops = None, arr_split = 1):
if nprocs is None:
nprocs = 4
if p.ndim != 3:
raise ValueError("Invalid dimensions for 3D d... | [
"def",
"process_data",
"(",
"p",
",",
"segmenter",
",",
"preprocess_func",
"=",
"None",
",",
"max_patches",
"=",
"None",
",",
"overlap",
"=",
"None",
",",
"nprocs",
"=",
"None",
",",
"rot_angle",
"=",
"0.0",
",",
"slice_axis",
"=",
"0",
",",
"crops",
"... | Segment a volume of shape (nz, ny, nx). | [
"Segment",
"a",
"volume",
"of",
"shape",
"(",
"nz",
"ny",
"nx",
")",
"."
] | [
"\"\"\"Segment a volume of shape (nz, ny, nx). The 2D keras model passes\n along either axis (0,1,2), segmenting images with a patch size defined by input\n to the model in the segmenter class.\n max_patches : tuple, (?,?) number of patches along each axis of 2D image\n overlap : tuple or in... | [
{
"param": "p",
"type": null
},
{
"param": "segmenter",
"type": null
},
{
"param": "preprocess_func",
"type": null
},
{
"param": "max_patches",
"type": null
},
{
"param": "overlap",
"type": null
},
{
"param": "nprocs",
"type": null
},
{
"pa... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "p",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "segmenter",
"type": null,
"docstring": null,
"docstring_tokens":... |
30a3ee24d78c88f57fb2d03331a3823c6bbfbcaf | kortizceballos/codeastro-group6 | pyhips/pyhips.py | [
"BSD-3-Clause"
] | Python | resolve_name | <not_specific> | def resolve_name(self):
"""
Function to resolve target name in SIMBAD, and populate the instance variables with their relevant values.
Return:
int: status code 0 for successful operation, 1 for error. If an error is returned, it will likely have been printed to stdout
"""
... |
Function to resolve target name in SIMBAD, and populate the instance variables with their relevant values.
Return:
int: status code 0 for successful operation, 1 for error. If an error is returned, it will likely have been printed to stdout
| Function to resolve target name in SIMBAD, and populate the instance variables with their relevant values.
Return:
int: status code 0 for successful operation, 1 for error. If an error is returned, it will likely have been printed to stdout | [
"Function",
"to",
"resolve",
"target",
"name",
"in",
"SIMBAD",
"and",
"populate",
"the",
"instance",
"variables",
"with",
"their",
"relevant",
"values",
".",
"Return",
":",
"int",
":",
"status",
"code",
"0",
"for",
"successful",
"operation",
"1",
"for",
"err... | def resolve_name(self):
try:
self.coords = SkyCoord.from_name(self.id, frame=self.frame.lower())
results = self.simbad.query_object(self.id)
self.otype = results["OTYPE"][0]
self.sptype = results["SP_TYPE"][0]
self.main_id = results["MAIN_ID"][0]
... | [
"def",
"resolve_name",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"coords",
"=",
"SkyCoord",
".",
"from_name",
"(",
"self",
".",
"id",
",",
"frame",
"=",
"self",
".",
"frame",
".",
"lower",
"(",
")",
")",
"results",
"=",
"self",
".",
"simbad",... | Function to resolve target name in SIMBAD, and populate the instance variables with their relevant values. | [
"Function",
"to",
"resolve",
"target",
"name",
"in",
"SIMBAD",
"and",
"populate",
"the",
"instance",
"variables",
"with",
"their",
"relevant",
"values",
"."
] | [
"\"\"\"\n Function to resolve target name in SIMBAD, and populate the instance variables with their relevant values.\n\n Return:\n int: status code 0 for successful operation, 1 for error. If an error is returned, it will likely have been printed to stdout\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
30a3ee24d78c88f57fb2d03331a3823c6bbfbcaf | kortizceballos/codeastro-group6 | pyhips/pyhips.py | [
"BSD-3-Clause"
] | Python | grid_builder | <not_specific> | def grid_builder(id, frame="ICRS", survey_list = ['DSS', 'DSS2/red', 'CDS/P/AKARI/FIS/N160', 'PanSTARRS/DR1/z', '2MASS/J', 'AllWISE/W3'], cmap="gray", fov=1.0):
"""
Function to build grid of get_image images. Plots the grid, saves the image as a JPEG (fig.jpg).
Args:
id (string): SIMBAD... |
Function to build grid of get_image images. Plots the grid, saves the image as a JPEG (fig.jpg).
Args:
id (string): SIMBAD resolvable identifier
frame (string): coordinate frame to use (default ICRS)
survey_list (list): HiPS surveys to grab data from (default DSS, D... | Function to build grid of get_image images. Plots the grid, saves the image as a JPEG (fig.jpg). | [
"Function",
"to",
"build",
"grid",
"of",
"get_image",
"images",
".",
"Plots",
"the",
"grid",
"saves",
"the",
"image",
"as",
"a",
"JPEG",
"(",
"fig",
".",
"jpg",
")",
"."
] | def grid_builder(id, frame="ICRS", survey_list = ['DSS', 'DSS2/red', 'CDS/P/AKARI/FIS/N160', 'PanSTARRS/DR1/z', '2MASS/J', 'AllWISE/W3'], cmap="gray", fov=1.0):
tgt = Target(id=id, frame=frame, survey='DSS')
code = tgt.resolve_name()
if code != 0:
return(1)
fig, axs = plt.subplots(1, len(survey_... | [
"def",
"grid_builder",
"(",
"id",
",",
"frame",
"=",
"\"ICRS\"",
",",
"survey_list",
"=",
"[",
"'DSS'",
",",
"'DSS2/red'",
",",
"'CDS/P/AKARI/FIS/N160'",
",",
"'PanSTARRS/DR1/z'",
",",
"'2MASS/J'",
",",
"'AllWISE/W3'",
"]",
",",
"cmap",
"=",
"\"gray\"",
",",
... | Function to build grid of get_image images. | [
"Function",
"to",
"build",
"grid",
"of",
"get_image",
"images",
"."
] | [
"\"\"\"\n Function to build grid of get_image images. Plots the grid, saves the image as a JPEG (fig.jpg).\n\n Args:\n id (string): SIMBAD resolvable identifier\n frame (string): coordinate frame to use (default ICRS)\n survey_list (list): HiPS surveys to grab data fro... | [
{
"param": "id",
"type": null
},
{
"param": "frame",
"type": null
},
{
"param": "survey_list",
"type": null
},
{
"param": "cmap",
"type": null
},
{
"param": "fov",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "id",
"type": null,
"docstring": "SIMBAD resolvable identifier",
"docstring_tokens": [
"SIMBAD",
"resolvable",
"identifier"
],
"default": null,
"is_optional": false
},
{
"... |
e0905c53bde66da45379e1f70e62cac40dc9d7f6 | CaselIT/falcon-auth2 | falcon_auth2/backends/meta.py | [
"Apache-2.0"
] | Python | authenticate | dict | def authenticate(self, attributes: RequestAttributes) -> dict:
"Authenticates the request and returns the authenticated user."
try:
results = self.backend.authenticate(attributes)
results.setdefault("backend", self.backend)
if self.on_success:
_, self.... | Authenticates the request and returns the authenticated user. | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | def authenticate(self, attributes: RequestAttributes) -> dict:
try:
results = self.backend.authenticate(attributes)
results.setdefault("backend", self.backend)
if self.on_success:
_, self.on_success_is_async = call_maybe_async(
attributes[4... | [
"def",
"authenticate",
"(",
"self",
",",
"attributes",
":",
"RequestAttributes",
")",
"->",
"dict",
":",
"try",
":",
"results",
"=",
"self",
".",
"backend",
".",
"authenticate",
"(",
"attributes",
")",
"results",
".",
"setdefault",
"(",
"\"backend\"",
",",
... | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | [
"\"Authenticates the request and returns the authenticated user.\""
] | [
{
"param": "self",
"type": null
},
{
"param": "attributes",
"type": "RequestAttributes"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attributes",
"type": "RequestAttributes",
"docstring": null,
... |
e0905c53bde66da45379e1f70e62cac40dc9d7f6 | CaselIT/falcon-auth2 | falcon_auth2/backends/meta.py | [
"Apache-2.0"
] | Python | authenticate | <not_specific> | def authenticate(self, attributes: RequestAttributes):
"Authenticates the request and returns the authenticated user."
challenges = []
for backend in self.backends:
try:
result = backend.authenticate(attributes)
result.setdefault("backend", backend)
... | Authenticates the request and returns the authenticated user. | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | def authenticate(self, attributes: RequestAttributes):
challenges = []
for backend in self.backends:
try:
result = backend.authenticate(attributes)
result.setdefault("backend", backend)
return result
except HTTPUnauthorized as exc:
... | [
"def",
"authenticate",
"(",
"self",
",",
"attributes",
":",
"RequestAttributes",
")",
":",
"challenges",
"=",
"[",
"]",
"for",
"backend",
"in",
"self",
".",
"backends",
":",
"try",
":",
"result",
"=",
"backend",
".",
"authenticate",
"(",
"attributes",
")",... | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | [
"\"Authenticates the request and returns the authenticated user.\""
] | [
{
"param": "self",
"type": null
},
{
"param": "attributes",
"type": "RequestAttributes"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attributes",
"type": "RequestAttributes",
"docstring": null,
... |
fa210a6813c0acab5834222b3163d9d627dd4294 | CaselIT/falcon-auth2 | falcon_auth2/getter.py | [
"Apache-2.0"
] | Python | load | str | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
"""Loads the specified attribute from the provided request.
If a getter cannot be used with the current request, a :class:`~.BackendNotApplicable`
is raised. The ``challenges``, when provided, will be added to `... | Loads the specified attribute from the provided request.
If a getter cannot be used with the current request, a :class:`~.BackendNotApplicable`
is raised. The ``challenges``, when provided, will be added to ``WWW-Authenticate`` header
in case of error.
Args:
req (Request): ... | Loads the specified attribute from the provided request.
If a getter cannot be used with the current request, a :class:`~.BackendNotApplicable`
is raised. | [
"Loads",
"the",
"specified",
"attribute",
"from",
"the",
"provided",
"request",
".",
"If",
"a",
"getter",
"cannot",
"be",
"used",
"with",
"the",
"current",
"request",
"a",
":",
"class",
":",
"`",
"~",
".",
"BackendNotApplicable",
"`",
"is",
"raised",
"."
] | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str: | [
"def",
"load",
"(",
"self",
",",
"req",
":",
"Request",
",",
"*",
",",
"challenges",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":"
] | Loads the specified attribute from the provided request. | [
"Loads",
"the",
"specified",
"attribute",
"from",
"the",
"provided",
"request",
"."
] | [
"\"\"\"Loads the specified attribute from the provided request.\n\n If a getter cannot be used with the current request, a :class:`~.BackendNotApplicable`\n is raised. The ``challenges``, when provided, will be added to ``WWW-Authenticate`` header\n in case of error.\n\n Args:\n ... | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "challenges",
"type": "Optional[Iterable[str]]"
}
] | {
"returns": [
{
"docstring": "The loaded data, in case of success.",
"docstring_tokens": [
"The",
"loaded",
"data",
"in",
"case",
"of",
"success",
"."
],
"type": "str"
}
],
"raises": [],
"params": [
{
"ide... |
fa210a6813c0acab5834222b3163d9d627dd4294 | CaselIT/falcon-auth2 | falcon_auth2/getter.py | [
"Apache-2.0"
] | Python | load | str | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
"""Loads the header from the provided request"""
header_value = req.get_header(self.header_key)
if not header_value:
raise BackendNotApplicable(
description=f"Missing {self.header_key}... | Loads the header from the provided request | Loads the header from the provided request | [
"Loads",
"the",
"header",
"from",
"the",
"provided",
"request"
] | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
header_value = req.get_header(self.header_key)
if not header_value:
raise BackendNotApplicable(
description=f"Missing {self.header_key} header", challenges=challenges
)
ret... | [
"def",
"load",
"(",
"self",
",",
"req",
":",
"Request",
",",
"*",
",",
"challenges",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"header_value",
"=",
"req",
".",
"get_header",
"(",
"self",
".",
"heade... | Loads the header from the provided request | [
"Loads",
"the",
"header",
"from",
"the",
"provided",
"request"
] | [
"\"\"\"Loads the header from the provided request\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "challenges",
"type": "Optional[Iterable[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
fa210a6813c0acab5834222b3163d9d627dd4294 | CaselIT/falcon-auth2 | falcon_auth2/getter.py | [
"Apache-2.0"
] | Python | load | str | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
"""Loads the auth header from the provided request"""
prefix, _, value = super().load(req, challenges=challenges).partition(" ")
if prefix.casefold() != self.auth_header_type:
raise BackendNotApplicab... | Loads the auth header from the provided request | Loads the auth header from the provided request | [
"Loads",
"the",
"auth",
"header",
"from",
"the",
"provided",
"request"
] | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
prefix, _, value = super().load(req, challenges=challenges).partition(" ")
if prefix.casefold() != self.auth_header_type:
raise BackendNotApplicable(
description=f"Invalid {self.header_key} he... | [
"def",
"load",
"(",
"self",
",",
"req",
":",
"Request",
",",
"*",
",",
"challenges",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"prefix",
",",
"_",
",",
"value",
"=",
"super",
"(",
")",
".",
"loa... | Loads the auth header from the provided request | [
"Loads",
"the",
"auth",
"header",
"from",
"the",
"provided",
"request"
] | [
"\"\"\"Loads the auth header from the provided request\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "challenges",
"type": "Optional[Iterable[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
fa210a6813c0acab5834222b3163d9d627dd4294 | CaselIT/falcon-auth2 | falcon_auth2/getter.py | [
"Apache-2.0"
] | Python | load | str | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
"""Loads the parameter from the provided request"""
param_value = req.get_param_as_list(self.param_name)
if not param_value:
raise BackendNotApplicable(
description=f"Missing {self.par... | Loads the parameter from the provided request | Loads the parameter from the provided request | [
"Loads",
"the",
"parameter",
"from",
"the",
"provided",
"request"
] | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
param_value = req.get_param_as_list(self.param_name)
if not param_value:
raise BackendNotApplicable(
description=f"Missing {self.param_name} parameter", challenges=challenges
)
... | [
"def",
"load",
"(",
"self",
",",
"req",
":",
"Request",
",",
"*",
",",
"challenges",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"param_value",
"=",
"req",
".",
"get_param_as_list",
"(",
"self",
".",
... | Loads the parameter from the provided request | [
"Loads",
"the",
"parameter",
"from",
"the",
"provided",
"request"
] | [
"\"\"\"Loads the parameter from the provided request\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "challenges",
"type": "Optional[Iterable[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
fa210a6813c0acab5834222b3163d9d627dd4294 | CaselIT/falcon-auth2 | falcon_auth2/getter.py | [
"Apache-2.0"
] | Python | load | str | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
"""Loads the cookie from the provided request"""
cookie_value = req.get_cookie_values(self.cookie_name)
if not cookie_value:
raise BackendNotApplicable(
description=f"Missing {self.coo... | Loads the cookie from the provided request | Loads the cookie from the provided request | [
"Loads",
"the",
"cookie",
"from",
"the",
"provided",
"request"
] | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
cookie_value = req.get_cookie_values(self.cookie_name)
if not cookie_value:
raise BackendNotApplicable(
description=f"Missing {self.cookie_name} cookie", challenges=challenges
)
... | [
"def",
"load",
"(",
"self",
",",
"req",
":",
"Request",
",",
"*",
",",
"challenges",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"cookie_value",
"=",
"req",
".",
"get_cookie_values",
"(",
"self",
".",
... | Loads the cookie from the provided request | [
"Loads",
"the",
"cookie",
"from",
"the",
"provided",
"request"
] | [
"\"\"\"Loads the cookie from the provided request\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "challenges",
"type": "Optional[Iterable[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
fa210a6813c0acab5834222b3163d9d627dd4294 | CaselIT/falcon-auth2 | falcon_auth2/getter.py | [
"Apache-2.0"
] | Python | load | str | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
"""Loads the value from the provided request using the provided getters"""
is_async = isinstance(req, AsyncRequest)
for g in self.getters:
try:
if is_async and not g.async_calls_sync_l... | Loads the value from the provided request using the provided getters | Loads the value from the provided request using the provided getters | [
"Loads",
"the",
"value",
"from",
"the",
"provided",
"request",
"using",
"the",
"provided",
"getters"
] | def load(self, req: Request, *, challenges: Optional[Iterable[str]] = None) -> str:
is_async = isinstance(req, AsyncRequest)
for g in self.getters:
try:
if is_async and not g.async_calls_sync_load:
return await_(g.load_async(req))
else:
... | [
"def",
"load",
"(",
"self",
",",
"req",
":",
"Request",
",",
"*",
",",
"challenges",
":",
"Optional",
"[",
"Iterable",
"[",
"str",
"]",
"]",
"=",
"None",
")",
"->",
"str",
":",
"is_async",
"=",
"isinstance",
"(",
"req",
",",
"AsyncRequest",
")",
"f... | Loads the value from the provided request using the provided getters | [
"Loads",
"the",
"value",
"from",
"the",
"provided",
"request",
"using",
"the",
"provided",
"getters"
] | [
"\"\"\"Loads the value from the provided request using the provided getters\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "challenges",
"type": "Optional[Iterable[str]]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
0cf981d59bee4eca0e95f9da3a62af043c3b15c7 | CaselIT/falcon-auth2 | falcon_auth2/utils/functions.py | [
"Apache-2.0"
] | Python | check_backend | null | def check_backend(backend: Any):
"Test if input is an AuthBackend"
from ..backends import AuthBackend
if not isinstance(backend, AuthBackend):
raise TypeError(
f"Invalid authentication backend {backend}. Expected a subclass of AuthBackend"
) | Test if input is an AuthBackend | Test if input is an AuthBackend | [
"Test",
"if",
"input",
"is",
"an",
"AuthBackend"
] | def check_backend(backend: Any):
from ..backends import AuthBackend
if not isinstance(backend, AuthBackend):
raise TypeError(
f"Invalid authentication backend {backend}. Expected a subclass of AuthBackend"
) | [
"def",
"check_backend",
"(",
"backend",
":",
"Any",
")",
":",
"from",
".",
".",
"backends",
"import",
"AuthBackend",
"if",
"not",
"isinstance",
"(",
"backend",
",",
"AuthBackend",
")",
":",
"raise",
"TypeError",
"(",
"f\"Invalid authentication backend {backend}. E... | Test if input is an AuthBackend | [
"Test",
"if",
"input",
"is",
"an",
"AuthBackend"
] | [
"\"Test if input is an AuthBackend\""
] | [
{
"param": "backend",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "backend",
"type": "Any",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0cf981d59bee4eca0e95f9da3a62af043c3b15c7 | CaselIT/falcon-auth2 | falcon_auth2/utils/functions.py | [
"Apache-2.0"
] | Python | check_getter | null | def check_getter(getter: Any):
"Test if input is a Getter"
from ..getter import Getter
if not isinstance(getter, Getter):
raise TypeError(f"Invalid getter {getter}. Expected a subclass of Getter") | Test if input is a Getter | Test if input is a Getter | [
"Test",
"if",
"input",
"is",
"a",
"Getter"
] | def check_getter(getter: Any):
from ..getter import Getter
if not isinstance(getter, Getter):
raise TypeError(f"Invalid getter {getter}. Expected a subclass of Getter") | [
"def",
"check_getter",
"(",
"getter",
":",
"Any",
")",
":",
"from",
".",
".",
"getter",
"import",
"Getter",
"if",
"not",
"isinstance",
"(",
"getter",
",",
"Getter",
")",
":",
"raise",
"TypeError",
"(",
"f\"Invalid getter {getter}. Expected a subclass of Getter\"",... | Test if input is a Getter | [
"Test",
"if",
"input",
"is",
"a",
"Getter"
] | [
"\"Test if input is a Getter\""
] | [
{
"param": "getter",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "getter",
"type": "Any",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0cf981d59bee4eca0e95f9da3a62af043c3b15c7 | CaselIT/falcon-auth2 | falcon_auth2/utils/functions.py | [
"Apache-2.0"
] | Python | call_maybe_async | Tuple[Any, bool] | def call_maybe_async(
support_async: bool,
function_is_async: Optional[bool],
err_msg: str,
function: Callable,
*args,
**kwargs,
) -> Tuple[Any, bool]:
"""Calls a function and waits for the result if it is async.
Args:
support_async (bool): Can run async cuntions.
functi... | Calls a function and waits for the result if it is async.
Args:
support_async (bool): Can run async cuntions.
function_is_async (Optional[bool]): If the function is async. This function will determine
if ``function`` is async when this parameter is ``None``.
err_msg (str): Name ... | Calls a function and waits for the result if it is async. | [
"Calls",
"a",
"function",
"and",
"waits",
"for",
"the",
"result",
"if",
"it",
"is",
"async",
"."
] | def call_maybe_async(
support_async: bool,
function_is_async: Optional[bool],
err_msg: str,
function: Callable,
*args,
**kwargs,
) -> Tuple[Any, bool]:
result = function(*args, **kwargs)
if function_is_async is None:
function_is_async = iscoroutine(result)
if function_is_asyn... | [
"def",
"call_maybe_async",
"(",
"support_async",
":",
"bool",
",",
"function_is_async",
":",
"Optional",
"[",
"bool",
"]",
",",
"err_msg",
":",
"str",
",",
"function",
":",
"Callable",
",",
"*",
"args",
",",
"**",
"kwargs",
",",
")",
"->",
"Tuple",
"[",
... | Calls a function and waits for the result if it is async. | [
"Calls",
"a",
"function",
"and",
"waits",
"for",
"the",
"result",
"if",
"it",
"is",
"async",
"."
] | [
"\"\"\"Calls a function and waits for the result if it is async.\n\n Args:\n support_async (bool): Can run async cuntions.\n function_is_async (Optional[bool]): If the function is async. This function will determine\n if ``function`` is async when this parameter is ``None``.\n err... | [
{
"param": "support_async",
"type": "bool"
},
{
"param": "function_is_async",
"type": "Optional[bool]"
},
{
"param": "err_msg",
"type": "str"
},
{
"param": "function",
"type": "Callable"
}
] | {
"returns": [
{
"docstring": "Returns the result and whatever the function is async.",
"docstring_tokens": [
"Returns",
"the",
"result",
"and",
"whatever",
"the",
"function",
"is",
"async",
"."
],
"type": "Tup... |
e22cf9edb9639b3cec5074c14a7d03e642448ebd | CaselIT/falcon-auth2 | falcon_auth2/backends/base.py | [
"Apache-2.0"
] | Python | authenticate | dict | def authenticate(self, attributes: RequestAttributes) -> dict:
"""Authenticates the request and returns the authenticated user.
If a request cannot be authenticated a backed should raise:
* :class:`~.AuthenticationFailure` to indicate that the request can be handled by this
backend, ... | Authenticates the request and returns the authenticated user.
If a request cannot be authenticated a backed should raise:
* :class:`~.AuthenticationFailure` to indicate that the request can be handled by this
backend, but the authentication fails.
* :class:`~.BackendNotApplicable` if... | Authenticates the request and returns the authenticated user.
If a request cannot be authenticated a backed should raise.
:class:`~.AuthenticationFailure` to indicate that the request can be handled by this
backend, but the authentication fails.
:class:`~.BackendNotApplicable` if the provided request cannot be handled... | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
".",
"If",
"a",
"request",
"cannot",
"be",
"authenticated",
"a",
"backed",
"should",
"raise",
".",
":",
"class",
":",
"`",
"~",
".",
"AuthenticationFailure",
"`",
"to",
"ind... | def authenticate(self, attributes: RequestAttributes) -> dict: | [
"def",
"authenticate",
"(",
"self",
",",
"attributes",
":",
"RequestAttributes",
")",
"->",
"dict",
":"
] | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | [
"\"\"\"Authenticates the request and returns the authenticated user.\n\n If a request cannot be authenticated a backed should raise:\n\n * :class:`~.AuthenticationFailure` to indicate that the request can be handled by this\n backend, but the authentication fails.\n * :class:`~.Backend... | [
{
"param": "self",
"type": null
},
{
"param": "attributes",
"type": "RequestAttributes"
}
] | {
"returns": [
{
"docstring": "A dictionary with a required ``\"user\"`` key containing the authenticated\nuser. This dictionary may optionally contain additional keys specific to this\nbackend. If the ``\"backend\"`` key is specified, the middleware will not override it.",
"docstring_tokens": [
... |
e22cf9edb9639b3cec5074c14a7d03e642448ebd | CaselIT/falcon-auth2 | falcon_auth2/backends/base.py | [
"Apache-2.0"
] | Python | authenticate | dict | def authenticate(self, attributes: RequestAttributes) -> dict:
"Authenticates the request and returns the authenticated user."
is_async = attributes[4]
if is_async and not self.getter.async_calls_sync_load:
auth_data = await_(self.getter.load_async(attributes[0], challenges=self.chal... | Authenticates the request and returns the authenticated user. | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | def authenticate(self, attributes: RequestAttributes) -> dict:
is_async = attributes[4]
if is_async and not self.getter.async_calls_sync_load:
auth_data = await_(self.getter.load_async(attributes[0], challenges=self.challenges))
else:
auth_data = self.getter.load(attribut... | [
"def",
"authenticate",
"(",
"self",
",",
"attributes",
":",
"RequestAttributes",
")",
"->",
"dict",
":",
"is_async",
"=",
"attributes",
"[",
"4",
"]",
"if",
"is_async",
"and",
"not",
"self",
".",
"getter",
".",
"async_calls_sync_load",
":",
"auth_data",
"=",... | Authenticates the request and returns the authenticated user. | [
"Authenticates",
"the",
"request",
"and",
"returns",
"the",
"authenticated",
"user",
"."
] | [
"\"Authenticates the request and returns the authenticated user.\""
] | [
{
"param": "self",
"type": null
},
{
"param": "attributes",
"type": "RequestAttributes"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "attributes",
"type": "RequestAttributes",
"docstring": null,
... |
5c69982fad97726b5ba4acb166122e9d88b98687 | CaselIT/falcon-auth2 | falcon_auth2/middleware.py | [
"Apache-2.0"
] | Python | _get_auth_settings | Tuple[bool, frozenset, AuthBackend] | def _get_auth_settings(self, resource: Any) -> Tuple[bool, frozenset, AuthBackend]:
"Returns a tuple with the configuration to use for this resource."
auth_settings = getattr(resource, "auth", None)
if auth_settings:
return (
auth_settings.get("auth_disabled", False),... | Returns a tuple with the configuration to use for this resource. | Returns a tuple with the configuration to use for this resource. | [
"Returns",
"a",
"tuple",
"with",
"the",
"configuration",
"to",
"use",
"for",
"this",
"resource",
"."
] | def _get_auth_settings(self, resource: Any) -> Tuple[bool, frozenset, AuthBackend]:
auth_settings = getattr(resource, "auth", None)
if auth_settings:
return (
auth_settings.get("auth_disabled", False),
auth_settings.get("exempt_methods", self.exempt_methods),
... | [
"def",
"_get_auth_settings",
"(",
"self",
",",
"resource",
":",
"Any",
")",
"->",
"Tuple",
"[",
"bool",
",",
"frozenset",
",",
"AuthBackend",
"]",
":",
"auth_settings",
"=",
"getattr",
"(",
"resource",
",",
"\"auth\"",
",",
"None",
")",
"if",
"auth_setting... | Returns a tuple with the configuration to use for this resource. | [
"Returns",
"a",
"tuple",
"with",
"the",
"configuration",
"to",
"use",
"for",
"this",
"resource",
"."
] | [
"\"Returns a tuple with the configuration to use for this resource.\""
] | [
{
"param": "self",
"type": null
},
{
"param": "resource",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "resource",
"type": "Any",
"docstring": null,
"docstring_token... |
5c69982fad97726b5ba4acb166122e9d88b98687 | CaselIT/falcon-auth2 | falcon_auth2/middleware.py | [
"Apache-2.0"
] | Python | process_resource | null | def process_resource(self, req: Request, resp: Response, resource: Any, params: dict):
"""Called by falcon when processing a resource.
It will obtain the configuration to use on the resource and, if required, call the
provided backend to authenticate the request.
"""
self._proce... | Called by falcon when processing a resource.
It will obtain the configuration to use on the resource and, if required, call the
provided backend to authenticate the request.
| Called by falcon when processing a resource.
It will obtain the configuration to use on the resource and, if required, call the
provided backend to authenticate the request. | [
"Called",
"by",
"falcon",
"when",
"processing",
"a",
"resource",
".",
"It",
"will",
"obtain",
"the",
"configuration",
"to",
"use",
"on",
"the",
"resource",
"and",
"if",
"required",
"call",
"the",
"provided",
"backend",
"to",
"authenticate",
"the",
"request",
... | def process_resource(self, req: Request, resp: Response, resource: Any, params: dict):
self._process_resource(RequestAttributes(req, resp, resource, params, False)) | [
"def",
"process_resource",
"(",
"self",
",",
"req",
":",
"Request",
",",
"resp",
":",
"Response",
",",
"resource",
":",
"Any",
",",
"params",
":",
"dict",
")",
":",
"self",
".",
"_process_resource",
"(",
"RequestAttributes",
"(",
"req",
",",
"resp",
",",... | Called by falcon when processing a resource. | [
"Called",
"by",
"falcon",
"when",
"processing",
"a",
"resource",
"."
] | [
"\"\"\"Called by falcon when processing a resource.\n\n It will obtain the configuration to use on the resource and, if required, call the\n provided backend to authenticate the request.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "resp",
"type": "Response"
},
{
"param": "resource",
"type": "Any"
},
{
"param": "params",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
5c69982fad97726b5ba4acb166122e9d88b98687 | CaselIT/falcon-auth2 | falcon_auth2/middleware.py | [
"Apache-2.0"
] | Python | process_resource_async | null | async def process_resource_async(
self, req: Request, resp: Response, resource: Any, params: dict
):
"""Called by async falcon when processing a resource.
It will obtain the configuration to use on the resource and, if required, call the
provided backend to authenticate the request.... | Called by async falcon when processing a resource.
It will obtain the configuration to use on the resource and, if required, call the
provided backend to authenticate the request.
| Called by async falcon when processing a resource.
It will obtain the configuration to use on the resource and, if required, call the
provided backend to authenticate the request. | [
"Called",
"by",
"async",
"falcon",
"when",
"processing",
"a",
"resource",
".",
"It",
"will",
"obtain",
"the",
"configuration",
"to",
"use",
"on",
"the",
"resource",
"and",
"if",
"required",
"call",
"the",
"provided",
"backend",
"to",
"authenticate",
"the",
"... | async def process_resource_async(
self, req: Request, resp: Response, resource: Any, params: dict
):
await greenlet_spawn(
self._process_resource, RequestAttributes(req, resp, resource, params, True)
) | [
"async",
"def",
"process_resource_async",
"(",
"self",
",",
"req",
":",
"Request",
",",
"resp",
":",
"Response",
",",
"resource",
":",
"Any",
",",
"params",
":",
"dict",
")",
":",
"await",
"greenlet_spawn",
"(",
"self",
".",
"_process_resource",
",",
"Requ... | Called by async falcon when processing a resource. | [
"Called",
"by",
"async",
"falcon",
"when",
"processing",
"a",
"resource",
"."
] | [
"\"\"\"Called by async falcon when processing a resource.\n\n It will obtain the configuration to use on the resource and, if required, call the\n provided backend to authenticate the request.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "req",
"type": "Request"
},
{
"param": "resp",
"type": "Response"
},
{
"param": "resource",
"type": "Any"
},
{
"param": "params",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "req",
"type": "Request",
"docstring": null,
"docstring_tokens... |
1022a8a2cf259cb3f3ccb4707012501893921235 | Work4Labs/django-short-urls | django_short_urls/middleware.py | [
"MIT"
] | Python | process_view | <not_specific> | def process_view(self, request, view_func, view_args, view_kwargs): # pylint: disable=no-self-use
"""
Called for every view, and catches database connection issues to serve the proper maintenance page.
"""
try:
return view_func(request, *view_args, **view_kwargs)
exc... |
Called for every view, and catches database connection issues to serve the proper maintenance page.
| Called for every view, and catches database connection issues to serve the proper maintenance page. | [
"Called",
"for",
"every",
"view",
"and",
"catches",
"database",
"connection",
"issues",
"to",
"serve",
"the",
"proper",
"maintenance",
"page",
"."
] | def process_view(self, request, view_func, view_args, view_kwargs):
try:
return view_func(request, *view_args, **view_kwargs)
except mongoengine.connection.ConnectionFailure as err:
getLogger('app').error('Database access error: %s', err)
return response_service_una... | [
"def",
"process_view",
"(",
"self",
",",
"request",
",",
"view_func",
",",
"view_args",
",",
"view_kwargs",
")",
":",
"try",
":",
"return",
"view_func",
"(",
"request",
",",
"*",
"view_args",
",",
"**",
"view_kwargs",
")",
"except",
"mongoengine",
".",
"co... | Called for every view, and catches database connection issues to serve the proper maintenance page. | [
"Called",
"for",
"every",
"view",
"and",
"catches",
"database",
"connection",
"issues",
"to",
"serve",
"the",
"proper",
"maintenance",
"page",
"."
] | [
"# pylint: disable=no-self-use",
"\"\"\"\n Called for every view, and catches database connection issues to serve the proper maintenance page.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "request",
"type": null
},
{
"param": "view_func",
"type": null
},
{
"param": "view_args",
"type": null
},
{
"param": "view_kwargs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "request",
"type": null,
"docstring": null,
"docstring_tokens"... |
0b2e156f3684d25fd716997c4011fc0b56d6c2ac | packetflare/ipwatch | src/ipwatch.py | [
"MIT"
] | Python | infoMenu | null | def infoMenu(self) :
"""
Sub-menu "Details" which displays information such as hostname, ASN, etc.
"""
self.detailMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Details...", None, '')
detailSubMenu = NSMenu.alloc().init()
# data is dict... |
Sub-menu "Details" which displays information such as hostname, ASN, etc.
| Sub-menu "Details" which displays information such as hostname, ASN, etc. | [
"Sub",
"-",
"menu",
"\"",
"Details",
"\"",
"which",
"displays",
"information",
"such",
"as",
"hostname",
"ASN",
"etc",
"."
] | def infoMenu(self) :
self.detailMenuItem = NSMenuItem.alloc().initWithTitle_action_keyEquivalent_("Details...", None, '')
detailSubMenu = NSMenu.alloc().init()
for k, v in self.ipWatchApp.data.items() :
item = "%s: %s" % (k, v)
detailSubMenu.addItemWithTitle_action_keyEqu... | [
"def",
"infoMenu",
"(",
"self",
")",
":",
"self",
".",
"detailMenuItem",
"=",
"NSMenuItem",
".",
"alloc",
"(",
")",
".",
"initWithTitle_action_keyEquivalent_",
"(",
"\"Details...\"",
",",
"None",
",",
"''",
")",
"detailSubMenu",
"=",
"NSMenu",
".",
"alloc",
... | Sub-menu "Details" which displays information such as hostname, ASN, etc. | [
"Sub",
"-",
"menu",
"\"",
"Details",
"\"",
"which",
"displays",
"information",
"such",
"as",
"hostname",
"ASN",
"etc",
"."
] | [
"\"\"\"\n Sub-menu \"Details\" which displays information such as hostname, ASN, etc.\n \"\"\"",
"# data is dictionary of the JSON response from ipinfo.io/json",
"# TODO: order the listing ",
"# position 0 specified as info sub-menu deleted and re-added later when updated"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0b2e156f3684d25fd716997c4011fc0b56d6c2ac | packetflare/ipwatch | src/ipwatch.py | [
"MIT"
] | Python | ifaceTimerCallback_ | null | def ifaceTimerCallback_(self, notification) :
"""
Callback for interface address check timer
"""
self.ipWatchApp.checkForIfaceChange() |
Callback for interface address check timer
| Callback for interface address check timer | [
"Callback",
"for",
"interface",
"address",
"check",
"timer"
] | def ifaceTimerCallback_(self, notification) :
self.ipWatchApp.checkForIfaceChange() | [
"def",
"ifaceTimerCallback_",
"(",
"self",
",",
"notification",
")",
":",
"self",
".",
"ipWatchApp",
".",
"checkForIfaceChange",
"(",
")"
] | Callback for interface address check timer | [
"Callback",
"for",
"interface",
"address",
"check",
"timer"
] | [
"\"\"\"\n Callback for interface address check timer\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "notification",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "notification",
"type": null,
"docstring": null,
"docstring_to... |
0b2e156f3684d25fd716997c4011fc0b56d6c2ac | packetflare/ipwatch | src/ipwatch.py | [
"MIT"
] | Python | updateNow_ | null | def updateNow_(self, notification):
"""
callback when user clicks update menu item
"""
self.ipWatchApp.updateNow() |
callback when user clicks update menu item
| callback when user clicks update menu item | [
"callback",
"when",
"user",
"clicks",
"update",
"menu",
"item"
] | def updateNow_(self, notification):
self.ipWatchApp.updateNow() | [
"def",
"updateNow_",
"(",
"self",
",",
"notification",
")",
":",
"self",
".",
"ipWatchApp",
".",
"updateNow",
"(",
")"
] | callback when user clicks update menu item | [
"callback",
"when",
"user",
"clicks",
"update",
"menu",
"item"
] | [
"\"\"\"\n callback when user clicks update menu item\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "notification",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "notification",
"type": null,
"docstring": null,
"docstring_to... |
0b2e156f3684d25fd716997c4011fc0b56d6c2ac | packetflare/ipwatch | src/ipwatch.py | [
"MIT"
] | Python | checkTimerCallback_ | null | def checkTimerCallback_(self, notification):
"""
callback for periodic check of the public IP address
"""
self.ipWatchApp.updateNow() |
callback for periodic check of the public IP address
| callback for periodic check of the public IP address | [
"callback",
"for",
"periodic",
"check",
"of",
"the",
"public",
"IP",
"address"
] | def checkTimerCallback_(self, notification):
self.ipWatchApp.updateNow() | [
"def",
"checkTimerCallback_",
"(",
"self",
",",
"notification",
")",
":",
"self",
".",
"ipWatchApp",
".",
"updateNow",
"(",
")"
] | callback for periodic check of the public IP address | [
"callback",
"for",
"periodic",
"check",
"of",
"the",
"public",
"IP",
"address"
] | [
"\"\"\"\n callback for periodic check of the public IP address\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "notification",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "notification",
"type": null,
"docstring": null,
"docstring_to... |
49f8e2fd04ac1d9aec37befcb090e3965c3126ef | egoetz/DNC-tensorflow | tasks/vowels/test.py | [
"MIT"
] | Python | load | <not_specific> | def load(path):
"""
Unpickle the file located at path.
:param path: The path to the pickled file.
:return: Returns the object hierarchy stored in the file.
"""
return pickle.load(open(path, 'rb')) |
Unpickle the file located at path.
:param path: The path to the pickled file.
:return: Returns the object hierarchy stored in the file.
| Unpickle the file located at path. | [
"Unpickle",
"the",
"file",
"located",
"at",
"path",
"."
] | def load(path):
return pickle.load(open(path, 'rb')) | [
"def",
"load",
"(",
"path",
")",
":",
"return",
"pickle",
".",
"load",
"(",
"open",
"(",
"path",
",",
"'rb'",
")",
")"
] | Unpickle the file located at path. | [
"Unpickle",
"the",
"file",
"located",
"at",
"path",
"."
] | [
"\"\"\"\n Unpickle the file located at path.\n :param path: The path to the pickled file.\n :return: Returns the object hierarchy stored in the file.\n \"\"\""
] | [
{
"param": "path",
"type": null
}
] | {
"returns": [
{
"docstring": "Returns the object hierarchy stored in the file.",
"docstring_tokens": [
"Returns",
"the",
"object",
"hierarchy",
"stored",
"in",
"the",
"file",
"."
],
"type": null
}
],
"raises":... |
49f8e2fd04ac1d9aec37befcb090e3965c3126ef | egoetz/DNC-tensorflow | tasks/vowels/test.py | [
"MIT"
] | Python | onehot | <not_specific> | def onehot(index, size):
"""
Create a numpy vector that has all zeros except at index. index has the value 1.
:param index: The index where the vector should be one.
:param size: The length of the vector.
:return: A one-hot vector encoding for the given index.
"""
vec = np.zeros(size, dtype=... |
Create a numpy vector that has all zeros except at index. index has the value 1.
:param index: The index where the vector should be one.
:param size: The length of the vector.
:return: A one-hot vector encoding for the given index.
| Create a numpy vector that has all zeros except at index. index has the value 1. | [
"Create",
"a",
"numpy",
"vector",
"that",
"has",
"all",
"zeros",
"except",
"at",
"index",
".",
"index",
"has",
"the",
"value",
"1",
"."
] | def onehot(index, size):
vec = np.zeros(size, dtype=np.float32)
vec[index] = 1.0
return vec | [
"def",
"onehot",
"(",
"index",
",",
"size",
")",
":",
"vec",
"=",
"np",
".",
"zeros",
"(",
"size",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"vec",
"[",
"index",
"]",
"=",
"1.0",
"return",
"vec"
] | Create a numpy vector that has all zeros except at index. | [
"Create",
"a",
"numpy",
"vector",
"that",
"has",
"all",
"zeros",
"except",
"at",
"index",
"."
] | [
"\"\"\"\n Create a numpy vector that has all zeros except at index. index has the value 1.\n :param index: The index where the vector should be one.\n :param size: The length of the vector.\n :return: A one-hot vector encoding for the given index.\n \"\"\""
] | [
{
"param": "index",
"type": null
},
{
"param": "size",
"type": null
}
] | {
"returns": [
{
"docstring": "A one-hot vector encoding for the given index.",
"docstring_tokens": [
"A",
"one",
"-",
"hot",
"vector",
"encoding",
"for",
"the",
"given",
"index",
"."
],
"type": null
... |
49f8e2fd04ac1d9aec37befcb090e3965c3126ef | egoetz/DNC-tensorflow | tasks/vowels/test.py | [
"MIT"
] | Python | prepare_sample | <not_specific> | def prepare_sample(sample, word_space_size):
"""
Transform a sequence of letters and the correct response into an input vector.
:param sample: list of letters forming word.
:param word_space_size: how many total letters exist.
:return: tuple including input vector and the length of its first dimensi... |
Transform a sequence of letters and the correct response into an input vector.
:param sample: list of letters forming word.
:param word_space_size: how many total letters exist.
:return: tuple including input vector and the length of its first dimension (i.e. how many one-hot vectors).
| Transform a sequence of letters and the correct response into an input vector. | [
"Transform",
"a",
"sequence",
"of",
"letters",
"and",
"the",
"correct",
"response",
"into",
"an",
"input",
"vector",
"."
] | def prepare_sample(sample, word_space_size):
input_vec = np.array(sample[0]['inputs'], dtype=np.float32)
seq_len = input_vec.shape[0]
input_vec = np.array([onehot(int(code), word_space_size) for code in input_vec])
return (
np.reshape(input_vec, (1, -1, word_space_size)),
seq_len
) | [
"def",
"prepare_sample",
"(",
"sample",
",",
"word_space_size",
")",
":",
"input_vec",
"=",
"np",
".",
"array",
"(",
"sample",
"[",
"0",
"]",
"[",
"'inputs'",
"]",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"seq_len",
"=",
"input_vec",
".",
"shape",... | Transform a sequence of letters and the correct response into an input vector. | [
"Transform",
"a",
"sequence",
"of",
"letters",
"and",
"the",
"correct",
"response",
"into",
"an",
"input",
"vector",
"."
] | [
"\"\"\"\n Transform a sequence of letters and the correct response into an input vector.\n :param sample: list of letters forming word.\n :param word_space_size: how many total letters exist.\n :return: tuple including input vector and the length of its first dimension (i.e. how many one-hot vectors).\n... | [
{
"param": "sample",
"type": null
},
{
"param": "word_space_size",
"type": null
}
] | {
"returns": [
{
"docstring": "tuple including input vector and the length of its first dimension .",
"docstring_tokens": [
"tuple",
"including",
"input",
"vector",
"and",
"the",
"length",
"of",
"its",
"first",
"di... |
49f8e2fd04ac1d9aec37befcb090e3965c3126ef | egoetz/DNC-tensorflow | tasks/vowels/test.py | [
"MIT"
] | Python | main | null | def main():
"""
Tests the latest checkpoint of the DNC that was trained on the vowels task. In this task, the DNC is given an input
that consist of a sequence of letters and asked to return any vowels contained in that sequence in order of
their appearance in the sequence. For simplicity's sake, y is no... |
Tests the latest checkpoint of the DNC that was trained on the vowels task. In this task, the DNC is given an input
that consist of a sequence of letters and asked to return any vowels contained in that sequence in order of
their appearance in the sequence. For simplicity's sake, y is not considered a vowe... | Tests the latest checkpoint of the DNC that was trained on the vowels task. In this task, the DNC is given an input
that consist of a sequence of letters and asked to return any vowels contained in that sequence in order of
their appearance in the sequence. For simplicity's sake, y is not considered a vowel. | [
"Tests",
"the",
"latest",
"checkpoint",
"of",
"the",
"DNC",
"that",
"was",
"trained",
"on",
"the",
"vowels",
"task",
".",
"In",
"this",
"task",
"the",
"DNC",
"is",
"given",
"an",
"input",
"that",
"consist",
"of",
"a",
"sequence",
"of",
"letters",
"and",
... | def main():
ckpts_dir = './checkpoints/'
lexicon_dictionary = load('./data/encoded/lexicon-dict.pkl')
target_code = lexicon_dictionary["#"]
test_files = []
for entry_name in os.listdir('./data/encoded/test/'):
entry_path = os.path.join('./data/encoded/test/', entry_name)
if os.path.i... | [
"def",
"main",
"(",
")",
":",
"ckpts_dir",
"=",
"'./checkpoints/'",
"lexicon_dictionary",
"=",
"load",
"(",
"'./data/encoded/lexicon-dict.pkl'",
")",
"target_code",
"=",
"lexicon_dictionary",
"[",
"\"#\"",
"]",
"test_files",
"=",
"[",
"]",
"for",
"entry_name",
"in... | Tests the latest checkpoint of the DNC that was trained on the vowels task. | [
"Tests",
"the",
"latest",
"checkpoint",
"of",
"the",
"DNC",
"that",
"was",
"trained",
"on",
"the",
"vowels",
"task",
"."
] | [
"\"\"\"\n Tests the latest checkpoint of the DNC that was trained on the vowels task. In this task, the DNC is given an input\n that consist of a sequence of letters and asked to return any vowels contained in that sequence in order of\n their appearance in the sequence. For simplicity's sake, y is not con... | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
c415d0093aafe2851061f75a30bbdcb2ea44b542 | egoetz/DNC-tensorflow | tasks/vowels/interact.py | [
"MIT"
] | Python | prepare_sample | <not_specific> | def prepare_sample(sample, answers, target_code, word_space_size):
"""
Transform a sequence of letters and the correct response into input and output vectors.
:param sample: list of letters forming word.
:param answers: response that the DNC should give.
:param target_code: code indicating end of sa... |
Transform a sequence of letters and the correct response into input and output vectors.
:param sample: list of letters forming word.
:param answers: response that the DNC should give.
:param target_code: code indicating end of sample and beginning of answer (also used in input as
... | Transform a sequence of letters and the correct response into input and output vectors. | [
"Transform",
"a",
"sequence",
"of",
"letters",
"and",
"the",
"correct",
"response",
"into",
"input",
"and",
"output",
"vectors",
"."
] | def prepare_sample(sample, answers, target_code, word_space_size):
input_vec = np.array(sample[0], dtype=np.float32)
output_vec = np.array(sample[0], dtype=np.float32)
seq_len = input_vec.shape[0]
weights_vec = np.zeros(seq_len, dtype=np.float32)
output_vec = np.append(output_vec, np.array(answers, ... | [
"def",
"prepare_sample",
"(",
"sample",
",",
"answers",
",",
"target_code",
",",
"word_space_size",
")",
":",
"input_vec",
"=",
"np",
".",
"array",
"(",
"sample",
"[",
"0",
"]",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"output_vec",
"=",
"np",
"."... | Transform a sequence of letters and the correct response into input and output vectors. | [
"Transform",
"a",
"sequence",
"of",
"letters",
"and",
"the",
"correct",
"response",
"into",
"input",
"and",
"output",
"vectors",
"."
] | [
"\"\"\"\n Transform a sequence of letters and the correct response into input and output vectors.\n :param sample: list of letters forming word.\n :param answers: response that the DNC should give.\n :param target_code: code indicating end of sample and beginning of answer (also used in input as\n ... | [
{
"param": "sample",
"type": null
},
{
"param": "answers",
"type": null
},
{
"param": "target_code",
"type": null
},
{
"param": "word_space_size",
"type": null
}
] | {
"returns": [
{
"docstring": "tuple including input vector, output vector, length of sequence, and associated weights.",
"docstring_tokens": [
"tuple",
"including",
"input",
"vector",
"output",
"vector",
"length",
"of",
"sequence... |
c415d0093aafe2851061f75a30bbdcb2ea44b542 | egoetz/DNC-tensorflow | tasks/vowels/interact.py | [
"MIT"
] | Python | main | null | def main():
"""
Runs an interactive shell where the user can submit input with their chosen deliminator and see the output of the
DNC's latest checkpoint.
:return: None
"""
dir_path = os.path.dirname(os.path.realpath(__file__))
ckpts_dir = os.path.join(dir_path, 'checkpoints')
lexicon_d... |
Runs an interactive shell where the user can submit input with their chosen deliminator and see the output of the
DNC's latest checkpoint.
:return: None
| Runs an interactive shell where the user can submit input with their chosen deliminator and see the output of the
DNC's latest checkpoint. | [
"Runs",
"an",
"interactive",
"shell",
"where",
"the",
"user",
"can",
"submit",
"input",
"with",
"their",
"chosen",
"deliminator",
"and",
"see",
"the",
"output",
"of",
"the",
"DNC",
"'",
"s",
"latest",
"checkpoint",
"."
] | def main():
dir_path = os.path.dirname(os.path.realpath(__file__))
ckpts_dir = os.path.join(dir_path, 'checkpoints')
lexicon_dictionary = load(os.path.join(dir_path, 'data', 'encoded', 'lexicon-dict.pkl'))
target_code = lexicon_dictionary["#"]
graph = tf.Graph()
with graph.as_default():
... | [
"def",
"main",
"(",
")",
":",
"dir_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"ckpts_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dir_path",
",",
"'checkpoints'",
")",
"lex... | Runs an interactive shell where the user can submit input with their chosen deliminator and see the output of the
DNC's latest checkpoint. | [
"Runs",
"an",
"interactive",
"shell",
"where",
"the",
"user",
"can",
"submit",
"input",
"with",
"their",
"chosen",
"deliminator",
"and",
"see",
"the",
"output",
"of",
"the",
"DNC",
"'",
"s",
"latest",
"checkpoint",
"."
] | [
"\"\"\"\n Runs an interactive shell where the user can submit input with their chosen deliminator and see the output of the\n DNC's latest checkpoint. \n :return: None\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
174254ed4a105d4861d81f770ad1d18d297aaa01 | egoetz/DNC-tensorflow | tasks/DREAM/cleaning.py | [
"MIT"
] | Python | split_up_digits | <not_specific> | def split_up_digits(number):
"""
split up a single number expressed as a string into individual digits.
ex. "12" becomes "1 2".
:param number: the numerical string to split.
:return: the new string.
"""
new_str = ""
for char in number:
if len(new_str) != 0:
new_str +=... |
split up a single number expressed as a string into individual digits.
ex. "12" becomes "1 2".
:param number: the numerical string to split.
:return: the new string.
| split up a single number expressed as a string into individual digits.
ex. | [
"split",
"up",
"a",
"single",
"number",
"expressed",
"as",
"a",
"string",
"into",
"individual",
"digits",
".",
"ex",
"."
] | def split_up_digits(number):
new_str = ""
for char in number:
if len(new_str) != 0:
new_str += f" {char}"
else:
new_str = char
return new_str | [
"def",
"split_up_digits",
"(",
"number",
")",
":",
"new_str",
"=",
"\"\"",
"for",
"char",
"in",
"number",
":",
"if",
"len",
"(",
"new_str",
")",
"!=",
"0",
":",
"new_str",
"+=",
"f\" {char}\"",
"else",
":",
"new_str",
"=",
"char",
"return",
"new_str"
] | split up a single number expressed as a string into individual digits. | [
"split",
"up",
"a",
"single",
"number",
"expressed",
"as",
"a",
"string",
"into",
"individual",
"digits",
"."
] | [
"\"\"\"\n split up a single number expressed as a string into individual digits.\n ex. \"12\" becomes \"1 2\".\n :param number: the numerical string to split.\n :return: the new string.\n \"\"\""
] | [
{
"param": "number",
"type": null
}
] | {
"returns": [
{
"docstring": "the new string.",
"docstring_tokens": [
"the",
"new",
"string",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "number",
"type": null,
"docstring": "the numerical string to sp... |
174254ed4a105d4861d81f770ad1d18d297aaa01 | egoetz/DNC-tensorflow | tasks/DREAM/cleaning.py | [
"MIT"
] | Python | replace_word | <not_specific> | def replace_word(word_array, dict_of_words_to_replace):
"""
Given an array of words, replace any words matching a key in dict_of_words_to_replace with its corresponding
value.
:param word_array: The array of words to check.
:param dict_of_words_to_replace: The dictionary of words to replace paired w... |
Given an array of words, replace any words matching a key in dict_of_words_to_replace with its corresponding
value.
:param word_array: The array of words to check.
:param dict_of_words_to_replace: The dictionary of words to replace paired with their replacements.
:return: The new array of words.
... | Given an array of words, replace any words matching a key in dict_of_words_to_replace with its corresponding
value. | [
"Given",
"an",
"array",
"of",
"words",
"replace",
"any",
"words",
"matching",
"a",
"key",
"in",
"dict_of_words_to_replace",
"with",
"its",
"corresponding",
"value",
"."
] | def replace_word(word_array, dict_of_words_to_replace):
new_word_array = []
for word in word_array:
if word in dict_of_words_to_replace:
new_word_array.extend(dict_of_words_to_replace[word])
else:
new_word_array.append(word)
return new_word_array | [
"def",
"replace_word",
"(",
"word_array",
",",
"dict_of_words_to_replace",
")",
":",
"new_word_array",
"=",
"[",
"]",
"for",
"word",
"in",
"word_array",
":",
"if",
"word",
"in",
"dict_of_words_to_replace",
":",
"new_word_array",
".",
"extend",
"(",
"dict_of_words_... | Given an array of words, replace any words matching a key in dict_of_words_to_replace with its corresponding
value. | [
"Given",
"an",
"array",
"of",
"words",
"replace",
"any",
"words",
"matching",
"a",
"key",
"in",
"dict_of_words_to_replace",
"with",
"its",
"corresponding",
"value",
"."
] | [
"\"\"\"\n Given an array of words, replace any words matching a key in dict_of_words_to_replace with its corresponding\n value.\n :param word_array: The array of words to check.\n :param dict_of_words_to_replace: The dictionary of words to replace paired with their replacements.\n :return: The new ar... | [
{
"param": "word_array",
"type": null
},
{
"param": "dict_of_words_to_replace",
"type": null
}
] | {
"returns": [
{
"docstring": "The new array of words.",
"docstring_tokens": [
"The",
"new",
"array",
"of",
"words",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "word_array",
"type": null,
... |
174254ed4a105d4861d81f770ad1d18d297aaa01 | egoetz/DNC-tensorflow | tasks/DREAM/cleaning.py | [
"MIT"
] | Python | clean_word_array | <not_specific> | def clean_word_array(word_array):
"""
Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
errors in the DREAM dataset.
:param word_array: An array of words from the DREAM dataset.
:return: a new word array with equivalent or improved gramm... |
Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
errors in the DREAM dataset.
:param word_array: An array of words from the DREAM dataset.
:return: a new word array with equivalent or improved grammar/spelling/syntax.
| Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for
errors in the DREAM dataset. | [
"Fix",
"syntax",
"spelling",
"and",
"grammar",
"errors",
"in",
"word_array",
".",
"Note",
"that",
"this",
"function",
"is",
"only",
"designed",
"to",
"account",
"for",
"errors",
"in",
"the",
"DREAM",
"dataset",
"."
] | def clean_word_array(word_array):
new_word_array = word_array
for word in word_array:
if word in spacing_dict:
new_words = spacing_dict[word].split()
new_word_array = replace_word(new_word_array, {word: new_words})
elif word in spelling_dict:
new_words = [spel... | [
"def",
"clean_word_array",
"(",
"word_array",
")",
":",
"new_word_array",
"=",
"word_array",
"for",
"word",
"in",
"word_array",
":",
"if",
"word",
"in",
"spacing_dict",
":",
"new_words",
"=",
"spacing_dict",
"[",
"word",
"]",
".",
"split",
"(",
")",
"new_wor... | Fix syntax, spelling, and grammar errors in word_array. | [
"Fix",
"syntax",
"spelling",
"and",
"grammar",
"errors",
"in",
"word_array",
"."
] | [
"\"\"\"\n Fix syntax, spelling, and grammar errors in word_array. Note, that this function is only designed to account for\n errors in the DREAM dataset.\n :param word_array: An array of words from the DREAM dataset.\n :return: a new word array with equivalent or improved grammar/spelling/syntax.\n \... | [
{
"param": "word_array",
"type": null
}
] | {
"returns": [
{
"docstring": "a new word array with equivalent or improved grammar/spelling/syntax.",
"docstring_tokens": [
"a",
"new",
"word",
"array",
"with",
"equivalent",
"or",
"improved",
"grammar",
"/",
"spe... |
73f2bd5c85530b5500532eba9efce21304b486b2 | egoetz/DNC-tensorflow | tasks/vowels/train.py | [
"MIT"
] | Python | prepare_sample | <not_specific> | def prepare_sample(sample, target_code, dict_size):
"""
Transform a sequence of letters and the correct response into input and output vectors.
:param sample: list of letters forming word.
:param target_code: code indicating end of sample and beginning of answer (also used in input as
... |
Transform a sequence of letters and the correct response into input and output vectors.
:param sample: list of letters forming word.
:param target_code: code indicating end of sample and beginning of answer (also used in input as
a replacement for each letter in the answer.
:par... | Transform a sequence of letters and the correct response into input and output vectors. | [
"Transform",
"a",
"sequence",
"of",
"letters",
"and",
"the",
"correct",
"response",
"into",
"input",
"and",
"output",
"vectors",
"."
] | def prepare_sample(sample, target_code, dict_size):
input_vec = np.array(sample[0]['inputs'], dtype=np.float32)
output_vec = np.array(sample[0]['inputs'], dtype=np.float32)
seq_len = input_vec.shape[0]
weights_vec = np.zeros(seq_len, dtype=np.float32)
target_mask = (input_vec == target_code)
if ... | [
"def",
"prepare_sample",
"(",
"sample",
",",
"target_code",
",",
"dict_size",
")",
":",
"input_vec",
"=",
"np",
".",
"array",
"(",
"sample",
"[",
"0",
"]",
"[",
"'inputs'",
"]",
",",
"dtype",
"=",
"np",
".",
"float32",
")",
"output_vec",
"=",
"np",
"... | Transform a sequence of letters and the correct response into input and output vectors. | [
"Transform",
"a",
"sequence",
"of",
"letters",
"and",
"the",
"correct",
"response",
"into",
"input",
"and",
"output",
"vectors",
"."
] | [
"\"\"\"\n Transform a sequence of letters and the correct response into input and output vectors.\n :param sample: list of letters forming word.\n :param target_code: code indicating end of sample and beginning of answer (also used in input as\n a replacement for each letter in the a... | [
{
"param": "sample",
"type": null
},
{
"param": "target_code",
"type": null
},
{
"param": "dict_size",
"type": null
}
] | {
"returns": [
{
"docstring": "tuple including input vector, output vector, length of sequence, and associated weights.",
"docstring_tokens": [
"tuple",
"including",
"input",
"vector",
"output",
"vector",
"length",
"of",
"sequence... |
73f2bd5c85530b5500532eba9efce21304b486b2 | egoetz/DNC-tensorflow | tasks/vowels/train.py | [
"MIT"
] | Python | main | null | def main():
"""
Train the DNC to take a word and list its instances of vowels in order of occurrence.
:return: None.
"""
dirname = os.path.dirname(__file__)
ckpts_dir = os.path.join(dirname, 'checkpoints')
data_dir = os.path.join(dirname, 'data', 'encoded')
tb_logs_dir = os.path.join(dir... |
Train the DNC to take a word and list its instances of vowels in order of occurrence.
:return: None.
| Train the DNC to take a word and list its instances of vowels in order of occurrence. | [
"Train",
"the",
"DNC",
"to",
"take",
"a",
"word",
"and",
"list",
"its",
"instances",
"of",
"vowels",
"in",
"order",
"of",
"occurrence",
"."
] | def main():
dirname = os.path.dirname(__file__)
ckpts_dir = os.path.join(dirname, 'checkpoints')
data_dir = os.path.join(dirname, 'data', 'encoded')
tb_logs_dir = os.path.join(dirname, 'logs')
llprint("Loading Data ... ")
lexicon_dict = load(os.path.join(data_dir, 'lexicon-dict.pkl'))
data =... | [
"def",
"main",
"(",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"ckpts_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"'checkpoints'",
")",
"data_dir",
"=",
"os",
".",
"path",
".",
"join",
"("... | Train the DNC to take a word and list its instances of vowels in order of occurrence. | [
"Train",
"the",
"DNC",
"to",
"take",
"a",
"word",
"and",
"list",
"its",
"instances",
"of",
"vowels",
"in",
"order",
"of",
"occurrence",
"."
] | [
"\"\"\"\n Train the DNC to take a word and list its instances of vowels in order of occurrence.\n :return: None.\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
cc4c02db5619cff520d1ab0da532a73e17a326ab | egoetz/DNC-tensorflow | tasks/vowels/preprocess.py | [
"MIT"
] | Python | create_dictionary | <not_specific> | def create_dictionary(files_list):
"""
Create a dictionary of unique lexicons in the dataset and their mapping to numbers.
:param files_list: the list of files to scan through.
:return: the constructed dictionary of lexicons
"""
lexicons_dict = {}
id_counter = 0
llprint("Creating Dicti... |
Create a dictionary of unique lexicons in the dataset and their mapping to numbers.
:param files_list: the list of files to scan through.
:return: the constructed dictionary of lexicons
| Create a dictionary of unique lexicons in the dataset and their mapping to numbers. | [
"Create",
"a",
"dictionary",
"of",
"unique",
"lexicons",
"in",
"the",
"dataset",
"and",
"their",
"mapping",
"to",
"numbers",
"."
] | def create_dictionary(files_list):
lexicons_dict = {}
id_counter = 0
llprint("Creating Dictionary ... 0/%d" % (len(files_list)))
for indx, filename in enumerate(files_list):
with open(filename, 'r') as fobj:
for line in fobj:
word = line.strip()
if not... | [
"def",
"create_dictionary",
"(",
"files_list",
")",
":",
"lexicons_dict",
"=",
"{",
"}",
"id_counter",
"=",
"0",
"llprint",
"(",
"\"Creating Dictionary ... 0/%d\"",
"%",
"(",
"len",
"(",
"files_list",
")",
")",
")",
"for",
"indx",
",",
"filename",
"in",
"enu... | Create a dictionary of unique lexicons in the dataset and their mapping to numbers. | [
"Create",
"a",
"dictionary",
"of",
"unique",
"lexicons",
"in",
"the",
"dataset",
"and",
"their",
"mapping",
"to",
"numbers",
"."
] | [
"\"\"\"\n Create a dictionary of unique lexicons in the dataset and their mapping to numbers.\n :param files_list: the list of files to scan through.\n :return: the constructed dictionary of lexicons\n \"\"\""
] | [
{
"param": "files_list",
"type": null
}
] | {
"returns": [
{
"docstring": "the constructed dictionary of lexicons",
"docstring_tokens": [
"the",
"constructed",
"dictionary",
"of",
"lexicons"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "files_list",
... |
cc4c02db5619cff520d1ab0da532a73e17a326ab | egoetz/DNC-tensorflow | tasks/vowels/preprocess.py | [
"MIT"
] | Python | encode_data | <not_specific> | def encode_data(files_list, lexicons_dictionary):
"""
Encode the dataset into its numeric form given a constructed dictionary
:param files_list: the list of files to scan through.
:param lexicons_dictionary: the mappings of unique lexicons.
:return: the data in its numeric form, maximum story length... |
Encode the dataset into its numeric form given a constructed dictionary
:param files_list: the list of files to scan through.
:param lexicons_dictionary: the mappings of unique lexicons.
:return: the data in its numeric form, maximum story length
| Encode the dataset into its numeric form given a constructed dictionary | [
"Encode",
"the",
"dataset",
"into",
"its",
"numeric",
"form",
"given",
"a",
"constructed",
"dictionary"
] | def encode_data(files_list, lexicons_dictionary):
files = {}
llprint("Encoding Data ... 0/%d" % (len(files_list)))
for indx, filename in enumerate(files_list):
files[filename] = []
with open(filename, 'r') as fobj:
on_answer = False
story_inputs = []
story... | [
"def",
"encode_data",
"(",
"files_list",
",",
"lexicons_dictionary",
")",
":",
"files",
"=",
"{",
"}",
"llprint",
"(",
"\"Encoding Data ... 0/%d\"",
"%",
"(",
"len",
"(",
"files_list",
")",
")",
")",
"for",
"indx",
",",
"filename",
"in",
"enumerate",
"(",
... | Encode the dataset into its numeric form given a constructed dictionary | [
"Encode",
"the",
"dataset",
"into",
"its",
"numeric",
"form",
"given",
"a",
"constructed",
"dictionary"
] | [
"\"\"\"\n Encode the dataset into its numeric form given a constructed dictionary\n :param files_list: the list of files to scan through.\n :param lexicons_dictionary: the mappings of unique lexicons.\n :return: the data in its numeric form, maximum story length\n \"\"\""
] | [
{
"param": "files_list",
"type": null
},
{
"param": "lexicons_dictionary",
"type": null
}
] | {
"returns": [
{
"docstring": "the data in its numeric form, maximum story length",
"docstring_tokens": [
"the",
"data",
"in",
"its",
"numeric",
"form",
"maximum",
"story",
"length"
],
"type": null
}
],
"raises... |
cc4c02db5619cff520d1ab0da532a73e17a326ab | egoetz/DNC-tensorflow | tasks/vowels/preprocess.py | [
"MIT"
] | Python | generate_data | null | def generate_data(directory, total_examples):
"""
Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
single example of extracting vowels from a word. Each line in a given text files contains one character. Before
the '#' character, the lines sp... |
Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
single example of extracting vowels from a word. Each line in a given text files contains one character. Before
the '#' character, the lines spell out a word. After the '#' character, the lines re... | Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
single example of extracting vowels from a word. Each line in a given text files contains one character. Before
the '#' character, the lines spell out a word. After the '#' character, the lines repeat the vowels... | [
"Create",
"a",
"training",
"(",
"9",
"/",
"10",
"of",
"total_examples",
")",
"and",
"testing",
"(",
"1",
"/",
"10",
"of",
"total_examples",
")",
"files",
"that",
"each",
"contain",
"a",
"single",
"example",
"of",
"extracting",
"vowels",
"from",
"a",
"wor... | def generate_data(directory, total_examples):
word_file = "/usr/share/dict/words"
words = list(map(str.lower, open(word_file).read().splitlines()))
for i in range(0, total_examples):
my_inputs = list(words[i])
if i < np.floor(total_examples * 9 / 10):
path = join(directory, "%dtr... | [
"def",
"generate_data",
"(",
"directory",
",",
"total_examples",
")",
":",
"word_file",
"=",
"\"/usr/share/dict/words\"",
"words",
"=",
"list",
"(",
"map",
"(",
"str",
".",
"lower",
",",
"open",
"(",
"word_file",
")",
".",
"read",
"(",
")",
".",
"splitline... | Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a
single example of extracting vowels from a word. | [
"Create",
"a",
"training",
"(",
"9",
"/",
"10",
"of",
"total_examples",
")",
"and",
"testing",
"(",
"1",
"/",
"10",
"of",
"total_examples",
")",
"files",
"that",
"each",
"contain",
"a",
"single",
"example",
"of",
"extracting",
"vowels",
"from",
"a",
"wor... | [
"\"\"\"\n Create a training (9 /10 of total_examples) and testing (1 / 10 of total_examples) files that each contain a\n single example of extracting vowels from a word. Each line in a given text files contains one character. Before\n the '#' character, the lines spell out a word. After the '#' character... | [
{
"param": "directory",
"type": null
},
{
"param": "total_examples",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "directory",
"type": null,
"docstring": "The directory in which to store training and testing examples",
"docstring_... |
cc4c02db5619cff520d1ab0da532a73e17a326ab | egoetz/DNC-tensorflow | tasks/vowels/preprocess.py | [
"MIT"
] | Python | main | null | def main():
"""
Generate the data used for training the DNC on how to find vowels in words. Create data directories storing this
information in its unencoded form and encoded form.
:return: None.
"""
task_dir = dirname(abspath(__file__))
options, _ = getopt.getopt(sys.argv[1:], '', ['data_di... |
Generate the data used for training the DNC on how to find vowels in words. Create data directories storing this
information in its unencoded form and encoded form.
:return: None.
| Generate the data used for training the DNC on how to find vowels in words. Create data directories storing this
information in its unencoded form and encoded form. | [
"Generate",
"the",
"data",
"used",
"for",
"training",
"the",
"DNC",
"on",
"how",
"to",
"find",
"vowels",
"in",
"words",
".",
"Create",
"data",
"directories",
"storing",
"this",
"information",
"in",
"its",
"unencoded",
"form",
"and",
"encoded",
"form",
"."
] | def main():
task_dir = dirname(abspath(__file__))
options, _ = getopt.getopt(sys.argv[1:], '', ['data_dir=', 'single_train'])
joint_train = True
files_list = []
total_examples = 10000
if not exists(join(task_dir, 'data')):
mkdir(join(task_dir, 'data'))
if not exists(join(task_dir, 'd... | [
"def",
"main",
"(",
")",
":",
"task_dir",
"=",
"dirname",
"(",
"abspath",
"(",
"__file__",
")",
")",
"options",
",",
"_",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"''",
",",
"[",
"'data_dir='",
",",
"'single... | Generate the data used for training the DNC on how to find vowels in words. | [
"Generate",
"the",
"data",
"used",
"for",
"training",
"the",
"DNC",
"on",
"how",
"to",
"find",
"vowels",
"in",
"words",
"."
] | [
"\"\"\"\n Generate the data used for training the DNC on how to find vowels in words. Create data directories storing this\n information in its unencoded form and encoded form.\n :return: None.\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
94e8f0beabd2d8488002db22170f99e67840999d | egoetz/DNC-tensorflow | tasks/DREAM/train.py | [
"MIT"
] | Python | prepare_sample | <not_specific> | def prepare_sample(sample, target_code, word_space_size):
"""
Transform a sample into input and output vectors.
:param sample: the dialogue connected by '+' characters followed by the '\' character and then a question. Where
the question is followed by the target_code and the answer (wit... |
Transform a sample into input and output vectors.
:param sample: the dialogue connected by '+' characters followed by the '\' character and then a question. Where
the question is followed by the target_code and the answer (with all words encoded).
:param target_code: code indicating end... | Transform a sample into input and output vectors. | [
"Transform",
"a",
"sample",
"into",
"input",
"and",
"output",
"vectors",
"."
] | def prepare_sample(sample, target_code, word_space_size):
input_vec = np.array(sample[:sample.index(target_code)], dtype=np.float32)
output_vec = sample[sample.index(target_code) + 1:]
while len(output_vec) < len(input_vec):
output_vec.append(target_code)
output_vec = np.array(output_vec, dtype=... | [
"def",
"prepare_sample",
"(",
"sample",
",",
"target_code",
",",
"word_space_size",
")",
":",
"input_vec",
"=",
"np",
".",
"array",
"(",
"sample",
"[",
":",
"sample",
".",
"index",
"(",
"target_code",
")",
"]",
",",
"dtype",
"=",
"np",
".",
"float32",
... | Transform a sample into input and output vectors. | [
"Transform",
"a",
"sample",
"into",
"input",
"and",
"output",
"vectors",
"."
] | [
"\"\"\"\n Transform a sample into input and output vectors.\n :param sample: the dialogue connected by '+' characters followed by the '\\' character and then a question. Where\n the question is followed by the target_code and the answer (with all words encoded).\n :param target_code: cod... | [
{
"param": "sample",
"type": null
},
{
"param": "target_code",
"type": null
},
{
"param": "word_space_size",
"type": null
}
] | {
"returns": [
{
"docstring": "tuple including input vector, output vector, length of sequence, and associated weights.",
"docstring_tokens": [
"tuple",
"including",
"input",
"vector",
"output",
"vector",
"length",
"of",
"sequence... |
10d42aaabe6fe3e49e1358a76bf4c47fb438755b | egoetz/DNC-tensorflow | tasks/DREAM/preprocess.py | [
"MIT"
] | Python | clean_sentences | <not_specific> | def clean_sentences(sentence_list):
"""
Cleans sentence_list by: indicating title words by placing a separate word "\^{}" in front of the capitalized word,
indicating all-caps word by placing a separate word "\^{}\^{}" in front of the all-caps word, making all words
lower case, fixing spelling errors, s... |
Cleans sentence_list by: indicating title words by placing a separate word "\^{}" in front of the capitalized word,
indicating all-caps word by placing a separate word "\^{}\^{}" in front of the all-caps word, making all words
lower case, fixing spelling errors, separating units from numbers, giving all on... | Cleans sentence_list by: indicating title words by placing a separate word "\^{}" in front of the capitalized word,
indicating all-caps word by placing a separate word "\^{}\^{}" in front of the all-caps word, making all words
lower case, fixing spelling errors, separating units from numbers, giving all onomatopoeia wo... | [
"Cleans",
"sentence_list",
"by",
":",
"indicating",
"title",
"words",
"by",
"placing",
"a",
"separate",
"word",
"\"",
"\\",
"^",
"{}",
"\"",
"in",
"front",
"of",
"the",
"capitalized",
"word",
"indicating",
"all",
"-",
"caps",
"word",
"by",
"placing",
"a",
... | def clean_sentences(sentence_list):
new_sentence_list = []
for sentence in sentence_list:
if sentence in sentence_dict.keys():
sentence_list[sentence_list.index(sentence)] = sentence_dict[sentence]
for index, sentence in enumerate(sentence_list):
capitalized = set()
abbre... | [
"def",
"clean_sentences",
"(",
"sentence_list",
")",
":",
"new_sentence_list",
"=",
"[",
"]",
"for",
"sentence",
"in",
"sentence_list",
":",
"if",
"sentence",
"in",
"sentence_dict",
".",
"keys",
"(",
")",
":",
"sentence_list",
"[",
"sentence_list",
".",
"index... | Cleans sentence_list by: indicating title words by placing a separate word "\^{}" in front of the capitalized word,
indicating all-caps word by placing a separate word "\^{}\^{}" in front of the all-caps word, making all words
lower case, fixing spelling errors, separating units from numbers, giving all onomatopoeia wo... | [
"Cleans",
"sentence_list",
"by",
":",
"indicating",
"title",
"words",
"by",
"placing",
"a",
"separate",
"word",
"\"",
"\\",
"^",
"{}",
"\"",
"in",
"front",
"of",
"the",
"capitalized",
"word",
"indicating",
"all",
"-",
"caps",
"word",
"by",
"placing",
"a",
... | [
"\"\"\"\n Cleans sentence_list by: indicating title words by placing a separate word \"\\^{}\" in front of the capitalized word,\n indicating all-caps word by placing a separate word \"\\^{}\\^{}\" in front of the all-caps word, making all words\n lower case, fixing spelling errors, separating units from n... | [
{
"param": "sentence_list",
"type": null
}
] | {
"returns": [
{
"docstring": "The modified sentence list.",
"docstring_tokens": [
"The",
"modified",
"sentence",
"list",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "sentence_list",
"type": null,
... |
10d42aaabe6fe3e49e1358a76bf4c47fb438755b | egoetz/DNC-tensorflow | tasks/DREAM/preprocess.py | [
"MIT"
] | Python | create_dictionary | <not_specific> | def create_dictionary(data):
"""
Create a dictionary of unique lexicons in the dataset and their mapping to numbers.
:param data:
:return:
"""
lexicons_dict = {}
id_counter = 0
llprint("Creating Dictionary ... 0/%d" % (len(data)))
for index, entry in enumerate(data):
sente... |
Create a dictionary of unique lexicons in the dataset and their mapping to numbers.
:param data:
:return:
| Create a dictionary of unique lexicons in the dataset and their mapping to numbers. | [
"Create",
"a",
"dictionary",
"of",
"unique",
"lexicons",
"in",
"the",
"dataset",
"and",
"their",
"mapping",
"to",
"numbers",
"."
] | def create_dictionary(data):
lexicons_dict = {}
id_counter = 0
llprint("Creating Dictionary ... 0/%d" % (len(data)))
for index, entry in enumerate(data):
sentences = entry[0]
for question_dictionary in entry[1]:
sentences.append(question_dictionary["question"])
se... | [
"def",
"create_dictionary",
"(",
"data",
")",
":",
"lexicons_dict",
"=",
"{",
"}",
"id_counter",
"=",
"0",
"llprint",
"(",
"\"Creating Dictionary ... 0/%d\"",
"%",
"(",
"len",
"(",
"data",
")",
")",
")",
"for",
"index",
",",
"entry",
"in",
"enumerate",
"("... | Create a dictionary of unique lexicons in the dataset and their mapping to numbers. | [
"Create",
"a",
"dictionary",
"of",
"unique",
"lexicons",
"in",
"the",
"dataset",
"and",
"their",
"mapping",
"to",
"numbers",
"."
] | [
"\"\"\"\n Create a dictionary of unique lexicons in the dataset and their mapping to numbers.\n :param data:\n :return:\n \"\"\""
] | [
{
"param": "data",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
10d42aaabe6fe3e49e1358a76bf4c47fb438755b | egoetz/DNC-tensorflow | tasks/DREAM/preprocess.py | [
"MIT"
] | Python | encode_sentences | <not_specific> | def encode_sentences(sentences, lexicon_dictionary):
"""
Change words in sentences into their one-hot index.
:param sentences: A list of sentences where all words are in lexicon_dictionary
:param lexicon_dictionary: A dictionary including all the words in the dataset
sentences are being drawn... |
Change words in sentences into their one-hot index.
:param sentences: A list of sentences where all words are in lexicon_dictionary
:param lexicon_dictionary: A dictionary including all the words in the dataset
sentences are being drawn from.
:return: sentences with each word replaced by a n... | Change words in sentences into their one-hot index. | [
"Change",
"words",
"in",
"sentences",
"into",
"their",
"one",
"-",
"hot",
"index",
"."
] | def encode_sentences(sentences, lexicon_dictionary):
new_sentence = []
for word in sentences.split():
new_sentence.append(lexicon_dictionary[word])
return new_sentence | [
"def",
"encode_sentences",
"(",
"sentences",
",",
"lexicon_dictionary",
")",
":",
"new_sentence",
"=",
"[",
"]",
"for",
"word",
"in",
"sentences",
".",
"split",
"(",
")",
":",
"new_sentence",
".",
"append",
"(",
"lexicon_dictionary",
"[",
"word",
"]",
")",
... | Change words in sentences into their one-hot index. | [
"Change",
"words",
"in",
"sentences",
"into",
"their",
"one",
"-",
"hot",
"index",
"."
] | [
"\"\"\"\n Change words in sentences into their one-hot index.\n :param sentences: A list of sentences where all words are in lexicon_dictionary\n :param lexicon_dictionary: A dictionary including all the words in the dataset\n sentences are being drawn from.\n :return: sentences with each word... | [
{
"param": "sentences",
"type": null
},
{
"param": "lexicon_dictionary",
"type": null
}
] | {
"returns": [
{
"docstring": "sentences with each word replaced by a number.",
"docstring_tokens": [
"sentences",
"with",
"each",
"word",
"replaced",
"by",
"a",
"number",
"."
],
"type": null
}
],
"raises": [],... |
10d42aaabe6fe3e49e1358a76bf4c47fb438755b | egoetz/DNC-tensorflow | tasks/DREAM/preprocess.py | [
"MIT"
] | Python | encode_data | <not_specific> | def encode_data(files_list, encoded_dir, lexicon_dictionary):
"""
Convert open files in files_list, convert their words into numerical equivalents
as defined in lexicon_dictionary, and then store the encoded information in a
file of the same name but which is located in encoded_dir.
:param files_lis... |
Convert open files in files_list, convert their words into numerical equivalents
as defined in lexicon_dictionary, and then store the encoded information in a
file of the same name but which is located in encoded_dir.
:param files_list: The list of files that should have their information converted
... | Convert open files in files_list, convert their words into numerical equivalents
as defined in lexicon_dictionary, and then store the encoded information in a
file of the same name but which is located in encoded_dir. | [
"Convert",
"open",
"files",
"in",
"files_list",
"convert",
"their",
"words",
"into",
"numerical",
"equivalents",
"as",
"defined",
"in",
"lexicon_dictionary",
"and",
"then",
"store",
"the",
"encoded",
"information",
"in",
"a",
"file",
"of",
"the",
"same",
"name",... | def encode_data(files_list, encoded_dir, lexicon_dictionary):
story_inputs = []
stories_lengths = []
llprint("Encoding Data ... 0/%d" % (len(files_list)))
for index, file_path in enumerate(files_list):
write_path = join(encoded_dir, basename(file_path)[:basename(file_path).rfind('.json')])
... | [
"def",
"encode_data",
"(",
"files_list",
",",
"encoded_dir",
",",
"lexicon_dictionary",
")",
":",
"story_inputs",
"=",
"[",
"]",
"stories_lengths",
"=",
"[",
"]",
"llprint",
"(",
"\"Encoding Data ... 0/%d\"",
"%",
"(",
"len",
"(",
"files_list",
")",
")",
")",
... | Convert open files in files_list, convert their words into numerical equivalents
as defined in lexicon_dictionary, and then store the encoded information in a
file of the same name but which is located in encoded_dir. | [
"Convert",
"open",
"files",
"in",
"files_list",
"convert",
"their",
"words",
"into",
"numerical",
"equivalents",
"as",
"defined",
"in",
"lexicon_dictionary",
"and",
"then",
"store",
"the",
"encoded",
"information",
"in",
"a",
"file",
"of",
"the",
"same",
"name",... | [
"\"\"\"\n Convert open files in files_list, convert their words into numerical equivalents\n as defined in lexicon_dictionary, and then store the encoded information in a\n file of the same name but which is located in encoded_dir.\n :param files_list: The list of files that should have their informatio... | [
{
"param": "files_list",
"type": null
},
{
"param": "encoded_dir",
"type": null
},
{
"param": "lexicon_dictionary",
"type": null
}
] | {
"returns": [
{
"docstring": "the list of paths containing the encoded information.",
"docstring_tokens": [
"the",
"list",
"of",
"paths",
"containing",
"the",
"encoded",
"information",
"."
],
"type": null
}
],
... |
10d42aaabe6fe3e49e1358a76bf4c47fb438755b | egoetz/DNC-tensorflow | tasks/DREAM/preprocess.py | [
"MIT"
] | Python | main | null | def main():
"""
Takes json data files in data_dir in the same format as the DREAM dataset and then creates a new directory
that contains the same files. But in these files, the dialogue, question and answer's words are cleaned. A second
new directory is also created, this directory stores the cleaned da... |
Takes json data files in data_dir in the same format as the DREAM dataset and then creates a new directory
that contains the same files. But in these files, the dialogue, question and answer's words are cleaned. A second
new directory is also created, this directory stores the cleaned data in its numerical... | Takes json data files in data_dir in the same format as the DREAM dataset and then creates a new directory
that contains the same files. But in these files, the dialogue, question and answer's words are cleaned. A second
new directory is also created, this directory stores the cleaned data in its numerical format.
thei... | [
"Takes",
"json",
"data",
"files",
"in",
"data_dir",
"in",
"the",
"same",
"format",
"as",
"the",
"DREAM",
"dataset",
"and",
"then",
"creates",
"a",
"new",
"directory",
"that",
"contains",
"the",
"same",
"files",
".",
"But",
"in",
"these",
"files",
"the",
... | def main():
task_dir = dirname(abspath(__file__))
options, _ = getopt.getopt(sys.argv[1:], '', ['data_dir=', 'single_train', 'length_limit='])
data_dir = None
joint_train = True
length_limit = None
training_files = []
testing_files = []
if not exists(join(task_dir, 'data')):
mkdi... | [
"def",
"main",
"(",
")",
":",
"task_dir",
"=",
"dirname",
"(",
"abspath",
"(",
"__file__",
")",
")",
"options",
",",
"_",
"=",
"getopt",
".",
"getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"''",
",",
"[",
"'data_dir='",
",",
"'single... | Takes json data files in data_dir in the same format as the DREAM dataset and then creates a new directory
that contains the same files. | [
"Takes",
"json",
"data",
"files",
"in",
"data_dir",
"in",
"the",
"same",
"format",
"as",
"the",
"DREAM",
"dataset",
"and",
"then",
"creates",
"a",
"new",
"directory",
"that",
"contains",
"the",
"same",
"files",
"."
] | [
"\"\"\"\n Takes json data files in data_dir in the same format as the DREAM dataset and then creates a new directory\n that contains the same files. But in these files, the dialogue, question and answer's words are cleaned. A second\n new directory is also created, this directory stores the cleaned data in... | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7229a6396e99e9b3e26517df8e2e05418d442229 | LtanHonor/py-pi-zero-timer-project | timer_project/run.py | [
"MIT"
] | Python | pi_after_timer_event | None | def pi_after_timer_event() -> None:
""" function that gets called after the timeout event occurs
:return:
"""
print("Job Done")
GPIO.output(12, GPIO.LOW) | function that gets called after the timeout event occurs
:return:
| function that gets called after the timeout event occurs | [
"function",
"that",
"gets",
"called",
"after",
"the",
"timeout",
"event",
"occurs"
] | def pi_after_timer_event() -> None:
print("Job Done")
GPIO.output(12, GPIO.LOW) | [
"def",
"pi_after_timer_event",
"(",
")",
"->",
"None",
":",
"print",
"(",
"\"Job Done\"",
")",
"GPIO",
".",
"output",
"(",
"12",
",",
"GPIO",
".",
"LOW",
")"
] | function that gets called after the timeout event occurs | [
"function",
"that",
"gets",
"called",
"after",
"the",
"timeout",
"event",
"occurs"
] | [
"\"\"\" function that gets called after the timeout event occurs\n\n :return:\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
7229a6396e99e9b3e26517df8e2e05418d442229 | LtanHonor/py-pi-zero-timer-project | timer_project/run.py | [
"MIT"
] | Python | pi_timer_event_abort | None | def pi_timer_event_abort() -> None:
""" function that gets called when the timer event is aborted
:return:
"""
print("Abort Job")
GPIO.output(12, GPIO.LOW) | function that gets called when the timer event is aborted
:return:
| function that gets called when the timer event is aborted | [
"function",
"that",
"gets",
"called",
"when",
"the",
"timer",
"event",
"is",
"aborted"
] | def pi_timer_event_abort() -> None:
print("Abort Job")
GPIO.output(12, GPIO.LOW) | [
"def",
"pi_timer_event_abort",
"(",
")",
"->",
"None",
":",
"print",
"(",
"\"Abort Job\"",
")",
"GPIO",
".",
"output",
"(",
"12",
",",
"GPIO",
".",
"LOW",
")"
] | function that gets called when the timer event is aborted | [
"function",
"that",
"gets",
"called",
"when",
"the",
"timer",
"event",
"is",
"aborted"
] | [
"\"\"\" function that gets called when the timer event is aborted\n\n :return:\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
6395fe0295be36d49110da49f3566d930248fe0a | VincentKaras/VGGFace2-pytorch | vggface2_pytorch/models/senet.py | [
"MIT"
] | Python | senet50 | <not_specific> | def senet50(**kwargs):
"""Constructs a SENet-50 model.
"""
model = SENet(Bottleneck, [3, 4, 6, 3], **kwargs)
return model | Constructs a SENet-50 model.
| Constructs a SENet-50 model. | [
"Constructs",
"a",
"SENet",
"-",
"50",
"model",
"."
] | def senet50(**kwargs):
model = SENet(Bottleneck, [3, 4, 6, 3], **kwargs)
return model | [
"def",
"senet50",
"(",
"**",
"kwargs",
")",
":",
"model",
"=",
"SENet",
"(",
"Bottleneck",
",",
"[",
"3",
",",
"4",
",",
"6",
",",
"3",
"]",
",",
"**",
"kwargs",
")",
"return",
"model"
] | Constructs a SENet-50 model. | [
"Constructs",
"a",
"SENet",
"-",
"50",
"model",
"."
] | [
"\"\"\"Constructs a SENet-50 model.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
d2952a302a74cf6b9b2f704801302fabe1f5b146 | VincentKaras/VGGFace2-pytorch | vggface2_pytorch/utils.py | [
"MIT"
] | Python | accuracy | <not_specific> | def accuracy(output, target, topk=(1,)):
"""Computes the precision@k for the specified values of k"""
maxk = max(topk)
batch_size = target.size(0)
output_sorted, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k... | Computes the precision@k for the specified values of k | Computes the precision@k for the specified values of k | [
"Computes",
"the",
"precision@k",
"for",
"the",
"specified",
"values",
"of",
"k"
] | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
output_sorted, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, k... | [
"def",
"accuracy",
"(",
"output",
",",
"target",
",",
"topk",
"=",
"(",
"1",
",",
")",
")",
":",
"maxk",
"=",
"max",
"(",
"topk",
")",
"batch_size",
"=",
"target",
".",
"size",
"(",
"0",
")",
"output_sorted",
",",
"pred",
"=",
"output",
".",
"top... | Computes the precision@k for the specified values of k | [
"Computes",
"the",
"precision@k",
"for",
"the",
"specified",
"values",
"of",
"k"
] | [
"\"\"\"Computes the precision@k for the specified values of k\"\"\""
] | [
{
"param": "output",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "topk",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "output",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens... |
05fb56a9a626b6a96990dd8216108b43f0fde986 | DIT4FUN/kendryte-model-compiler | h5_converter.py | [
"Apache-2.0"
] | Python | freeze_session | <not_specific> | def freeze_session(session, keep_var_names=None, output_names=None, clear_devices=True):
"""
Freezes the state of a session into a prunned computation graph.
Creates a new computation graph where variable nodes are replaced by
constants taking their current value in the session. The new graph will... |
Freezes the state of a session into a prunned computation graph.
Creates a new computation graph where variable nodes are replaced by
constants taking their current value in the session. The new graph will be
prunned so subgraphs that are not neccesary to compute the requested
outputs are re... | Freezes the state of a session into a prunned computation graph.
Creates a new computation graph where variable nodes are replaced by
constants taking their current value in the session. The new graph will be
prunned so subgraphs that are not neccesary to compute the requested
outputs are removed.
@param session The Te... | [
"Freezes",
"the",
"state",
"of",
"a",
"session",
"into",
"a",
"prunned",
"computation",
"graph",
".",
"Creates",
"a",
"new",
"computation",
"graph",
"where",
"variable",
"nodes",
"are",
"replaced",
"by",
"constants",
"taking",
"their",
"current",
"value",
"in"... | def freeze_session(session, keep_var_names=None, output_names=None, clear_devices=True):
from tensorflow.python.framework.graph_util import convert_variables_to_constants
graph = session.graph
with graph.as_default():
freeze_var_names = None
output_names = output_names or []
input_g... | [
"def",
"freeze_session",
"(",
"session",
",",
"keep_var_names",
"=",
"None",
",",
"output_names",
"=",
"None",
",",
"clear_devices",
"=",
"True",
")",
":",
"from",
"tensorflow",
".",
"python",
".",
"framework",
".",
"graph_util",
"import",
"convert_variables_to_... | Freezes the state of a session into a prunned computation graph. | [
"Freezes",
"the",
"state",
"of",
"a",
"session",
"into",
"a",
"prunned",
"computation",
"graph",
"."
] | [
"\"\"\"\r\n Freezes the state of a session into a prunned computation graph.\r\n\r\n Creates a new computation graph where variable nodes are replaced by\r\n constants taking their current value in the session. The new graph will be\r\n prunned so subgraphs that are not neccesary to compute the requeste... | [
{
"param": "session",
"type": null
},
{
"param": "keep_var_names",
"type": null
},
{
"param": "output_names",
"type": null
},
{
"param": "clear_devices",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "session",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "keep_var_names",
"type": null,
"docstring": null,
"docstri... |
bec4d8046cd2d550b4ac3fa0acf9854dda654f01 | janivanecky/Numpy-RNNs | nprnn.py | [
"MIT"
] | Python | forward_backward | <not_specific> | def forward_backward(inputs, targets, initial_states):
'''
Computes forward and backward pass through the recurrent net, for SEQ_SIZE time steps
-inputs is an array of shape [BATCH_SIZE, SEQ_SIZE, VOCABULARY_SIZE] and holds one hot encoded inputs to the model
-targets has a shape [BATCH_SIZE, SEQ_SIZE], holds just ... |
Computes forward and backward pass through the recurrent net, for SEQ_SIZE time steps
-inputs is an array of shape [BATCH_SIZE, SEQ_SIZE, VOCABULARY_SIZE] and holds one hot encoded inputs to the model
-targets has a shape [BATCH_SIZE, SEQ_SIZE], holds just the indices of the target chars
-initial_states contains s... | Computes forward and backward pass through the recurrent net, for SEQ_SIZE time steps
inputs is an array of shape [BATCH_SIZE, SEQ_SIZE, VOCABULARY_SIZE] and holds one hot encoded inputs to the model
targets has a shape [BATCH_SIZE, SEQ_SIZE], holds just the indices of the target chars
initial_states contains state of ... | [
"Computes",
"forward",
"and",
"backward",
"pass",
"through",
"the",
"recurrent",
"net",
"for",
"SEQ_SIZE",
"time",
"steps",
"inputs",
"is",
"an",
"array",
"of",
"shape",
"[",
"BATCH_SIZE",
"SEQ_SIZE",
"VOCABULARY_SIZE",
"]",
"and",
"holds",
"one",
"hot",
"enco... | def forward_backward(inputs, targets, initial_states):
loss = 0
dropout = [{} for i in xrange(DEPTH)]
x,h,z = [{} for i in xrange(DEPTH + 1)], [{} for i in xrange(DEPTH)], {}
h = [{-1: initial_states[d]} for d in xrange(DEPTH)]
for t in xrange(SEQ_SIZE):
x[0][t] = np.reshape(inputs[:,t,:], (BATCH_SIZE, VOCABULAR... | [
"def",
"forward_backward",
"(",
"inputs",
",",
"targets",
",",
"initial_states",
")",
":",
"loss",
"=",
"0",
"dropout",
"=",
"[",
"{",
"}",
"for",
"i",
"in",
"xrange",
"(",
"DEPTH",
")",
"]",
"x",
",",
"h",
",",
"z",
"=",
"[",
"{",
"}",
"for",
... | Computes forward and backward pass through the recurrent net, for SEQ_SIZE time steps
inputs is an array of shape [BATCH_SIZE, SEQ_SIZE, VOCABULARY_SIZE] and holds one hot encoded inputs to the model
targets has a shape [BATCH_SIZE, SEQ_SIZE], holds just the indices of the target chars
initial_states contains state of ... | [
"Computes",
"forward",
"and",
"backward",
"pass",
"through",
"the",
"recurrent",
"net",
"for",
"SEQ_SIZE",
"time",
"steps",
"inputs",
"is",
"an",
"array",
"of",
"shape",
"[",
"BATCH_SIZE",
"SEQ_SIZE",
"VOCABULARY_SIZE",
"]",
"and",
"holds",
"one",
"hot",
"enco... | [
"'''\n\tComputes forward and backward pass through the recurrent net, for SEQ_SIZE time steps\n\t-inputs is an array of shape [BATCH_SIZE, SEQ_SIZE, VOCABULARY_SIZE] and holds one hot encoded inputs to the model\n\t-targets has a shape [BATCH_SIZE, SEQ_SIZE], holds just the indices of the target chars\n\t-initial_s... | [
{
"param": "inputs",
"type": null
},
{
"param": "targets",
"type": null
},
{
"param": "initial_states",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inputs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "targets",
"type": null,
"docstring": null,
"docstring_token... |
bec4d8046cd2d550b4ac3fa0acf9854dda654f01 | janivanecky/Numpy-RNNs | nprnn.py | [
"MIT"
] | Python | forward | <not_specific> | def forward(input, state):
'''
Computes only the forward pass through one step of the time, note that the input to the softmax is divided by a hyperparameter TEMPERATURE
-input is an index of the char in vocabulary
-state, the same as for forward_backward, but the BATCH_SIZE is 1, so the final shape is [DEPTH, 1, H... |
Computes only the forward pass through one step of the time, note that the input to the softmax is divided by a hyperparameter TEMPERATURE
-input is an index of the char in vocabulary
-state, the same as for forward_backward, but the BATCH_SIZE is 1, so the final shape is [DEPTH, 1, HIDDEN_LAYER_SIZE]
Returns p... | Computes only the forward pass through one step of the time, note that the input to the softmax is divided by a hyperparameter TEMPERATURE
input is an index of the char in vocabulary
state, the same as for forward_backward, but the BATCH_SIZE is 1, so the final shape is [DEPTH, 1, HIDDEN_LAYER_SIZE]
Returns probabilit... | [
"Computes",
"only",
"the",
"forward",
"pass",
"through",
"one",
"step",
"of",
"the",
"time",
"note",
"that",
"the",
"input",
"to",
"the",
"softmax",
"is",
"divided",
"by",
"a",
"hyperparameter",
"TEMPERATURE",
"input",
"is",
"an",
"index",
"of",
"the",
"ch... | def forward(input, state):
ox = np.zeros((1, VOCABULARY_SIZE))
ox[0, input] = 1
for d in xrange(DEPTH):
state[d] = relu(np.dot(ox, Wxh[d]) + np.dot(state[d], Whh[d]) + bh[d])
ox = state[d]
y = np.dot(ox, Why) + by
y = np.clip(y, -100, 100)
oz = softmax(y / TEMPERATURE)
return np.reshape(oz, (VOCABULARY_SIZE)... | [
"def",
"forward",
"(",
"input",
",",
"state",
")",
":",
"ox",
"=",
"np",
".",
"zeros",
"(",
"(",
"1",
",",
"VOCABULARY_SIZE",
")",
")",
"ox",
"[",
"0",
",",
"input",
"]",
"=",
"1",
"for",
"d",
"in",
"xrange",
"(",
"DEPTH",
")",
":",
"state",
... | Computes only the forward pass through one step of the time, note that the input to the softmax is divided by a hyperparameter TEMPERATURE
input is an index of the char in vocabulary
state, the same as for forward_backward, but the BATCH_SIZE is 1, so the final shape is [DEPTH, 1, HIDDEN_LAYER_SIZE] | [
"Computes",
"only",
"the",
"forward",
"pass",
"through",
"one",
"step",
"of",
"the",
"time",
"note",
"that",
"the",
"input",
"to",
"the",
"softmax",
"is",
"divided",
"by",
"a",
"hyperparameter",
"TEMPERATURE",
"input",
"is",
"an",
"index",
"of",
"the",
"ch... | [
"'''\n\tComputes only the forward pass through one step of the time, note that the input to the softmax is divided by a hyperparameter TEMPERATURE\n\t-input is an index of the char in vocabulary\n\t-state, the same as for forward_backward, but the BATCH_SIZE is 1, so the final shape is [DEPTH, 1, HIDDEN_LAYER_SIZE]... | [
{
"param": "input",
"type": null
},
{
"param": "state",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "state",
"type": null,
"docstring": null,
"docstring_tokens":... |
bec4d8046cd2d550b4ac3fa0acf9854dda654f01 | janivanecky/Numpy-RNNs | nprnn.py | [
"MIT"
] | Python | evaluate_loss | <not_specific> | def evaluate_loss(input):
'''
Evaluates and returns loss on the input string (array of chars)
'''
oh = [np.zeros((1, HIDDEN_LAYER_SIZE)) for i in xrange(DEPTH)]
loss = 0
N = len(input) - 1
for i in xrange(N):
inpt = char_to_index[input[i]]
target = char_to_index[input[i + 1]]
prob, oh = forward(inpt, oh)
... |
Evaluates and returns loss on the input string (array of chars)
| Evaluates and returns loss on the input string (array of chars) | [
"Evaluates",
"and",
"returns",
"loss",
"on",
"the",
"input",
"string",
"(",
"array",
"of",
"chars",
")"
] | def evaluate_loss(input):
oh = [np.zeros((1, HIDDEN_LAYER_SIZE)) for i in xrange(DEPTH)]
loss = 0
N = len(input) - 1
for i in xrange(N):
inpt = char_to_index[input[i]]
target = char_to_index[input[i + 1]]
prob, oh = forward(inpt, oh)
target_prob = -np.log(prob[target]) / N
loss += target_prob
return loss | [
"def",
"evaluate_loss",
"(",
"input",
")",
":",
"oh",
"=",
"[",
"np",
".",
"zeros",
"(",
"(",
"1",
",",
"HIDDEN_LAYER_SIZE",
")",
")",
"for",
"i",
"in",
"xrange",
"(",
"DEPTH",
")",
"]",
"loss",
"=",
"0",
"N",
"=",
"len",
"(",
"input",
")",
"-"... | Evaluates and returns loss on the input string (array of chars) | [
"Evaluates",
"and",
"returns",
"loss",
"on",
"the",
"input",
"string",
"(",
"array",
"of",
"chars",
")"
] | [
"'''\n\tEvaluates and returns loss on the input string (array of chars)\n\t'''"
] | [
{
"param": "input",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bec4d8046cd2d550b4ac3fa0acf9854dda654f01 | janivanecky/Numpy-RNNs | nprnn.py | [
"MIT"
] | Python | sample_model | <not_specific> | def sample_model(N):
'''
Samples the model, returns the sample of length N as a string
'''
ix = np.random.randint(0, VOCABULARY_SIZE)
output = []
output.append(index_to_char[ix])
oh = [np.zeros((1, HIDDEN_LAYER_SIZE)) for i in xrange(DEPTH)]
for c in xrange(N):
oz, oh = forward(ix, oh)
result = np.random.c... |
Samples the model, returns the sample of length N as a string
| Samples the model, returns the sample of length N as a string | [
"Samples",
"the",
"model",
"returns",
"the",
"sample",
"of",
"length",
"N",
"as",
"a",
"string"
] | def sample_model(N):
ix = np.random.randint(0, VOCABULARY_SIZE)
output = []
output.append(index_to_char[ix])
oh = [np.zeros((1, HIDDEN_LAYER_SIZE)) for i in xrange(DEPTH)]
for c in xrange(N):
oz, oh = forward(ix, oh)
result = np.random.choice(range(VOCABULARY_SIZE), p=oz.ravel())
output.append(index_to_char... | [
"def",
"sample_model",
"(",
"N",
")",
":",
"ix",
"=",
"np",
".",
"random",
".",
"randint",
"(",
"0",
",",
"VOCABULARY_SIZE",
")",
"output",
"=",
"[",
"]",
"output",
".",
"append",
"(",
"index_to_char",
"[",
"ix",
"]",
")",
"oh",
"=",
"[",
"np",
"... | Samples the model, returns the sample of length N as a string | [
"Samples",
"the",
"model",
"returns",
"the",
"sample",
"of",
"length",
"N",
"as",
"a",
"string"
] | [
"'''\n\tSamples the model, returns the sample of length N as a string\n\t'''"
] | [
{
"param": "N",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "N",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
297246dabf1c9cdce63d85c102facac1c9a914c2 | SunYanCN/BAND | webapp/app.py | [
"Apache-2.0"
] | Python | classification | <not_specific> | def classification():
"""
Home Page.
URL: /
POST HTTP Method: Renders page along with Keras Model's output
GET HTTP Method: Renders page without any computation.
"""
if request.method == 'POST':
# Retrive review and get rating from model
endpoint = "http://127.0.0.1:8501"
... |
Home Page.
URL: /
POST HTTP Method: Renders page along with Keras Model's output
GET HTTP Method: Renders page without any computation.
| Home Page.
URL:
POST HTTP Method: Renders page along with Keras Model's output
GET HTTP Method: Renders page without any computation. | [
"Home",
"Page",
".",
"URL",
":",
"POST",
"HTTP",
"Method",
":",
"Renders",
"page",
"along",
"with",
"Keras",
"Model",
"'",
"s",
"output",
"GET",
"HTTP",
"Method",
":",
"Renders",
"page",
"without",
"any",
"computation",
"."
] | def classification():
if request.method == 'POST':
endpoint = "http://127.0.0.1:8501"
review = request.form["review"]
processor = utils.load_processor(model_path='saved_model/blstm/1')
x = list(review)
tensor = processor.process_x_dataset([x])
json_data = {"model_name... | [
"def",
"classification",
"(",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"endpoint",
"=",
"\"http://127.0.0.1:8501\"",
"review",
"=",
"request",
".",
"form",
"[",
"\"review\"",
"]",
"processor",
"=",
"utils",
".",
"load_processor",
"(",
"... | Home Page. | [
"Home",
"Page",
"."
] | [
"\"\"\"\n Home Page.\n\n URL: /\n POST HTTP Method: Renders page along with Keras Model's output\n GET HTTP Method: Renders page without any computation.\n \"\"\"",
"# Retrive review and get rating from model",
"# Open results file to save output for analysis.",
"# Same IP address and browser i... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
297246dabf1c9cdce63d85c102facac1c9a914c2 | SunYanCN/BAND | webapp/app.py | [
"Apache-2.0"
] | Python | ner | <not_specific> | def ner():
"""
Home Page.
URL: /
POST HTTP Method: Renders page along with Keras Model's output
GET HTTP Method: Renders page without any computation.
"""
if request.method == 'POST':
# Retrive review and get rating from model
endpoint = "http://127.0.0.1:8500"
revie... |
Home Page.
URL: /
POST HTTP Method: Renders page along with Keras Model's output
GET HTTP Method: Renders page without any computation.
| Home Page.
URL:
POST HTTP Method: Renders page along with Keras Model's output
GET HTTP Method: Renders page without any computation. | [
"Home",
"Page",
".",
"URL",
":",
"POST",
"HTTP",
"Method",
":",
"Renders",
"page",
"along",
"with",
"Keras",
"Model",
"'",
"s",
"output",
"GET",
"HTTP",
"Method",
":",
"Renders",
"page",
"without",
"any",
"computation",
"."
] | def ner():
if request.method == 'POST':
endpoint = "http://127.0.0.1:8500"
review = request.form["review"]
processor = utils.load_processor(model_path='saved_model/bilstm/1')
x = list(review)
tensor = processor.process_x_dataset([x])
json_data = {"model_name": "defaul... | [
"def",
"ner",
"(",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"endpoint",
"=",
"\"http://127.0.0.1:8500\"",
"review",
"=",
"request",
".",
"form",
"[",
"\"review\"",
"]",
"processor",
"=",
"utils",
".",
"load_processor",
"(",
"model_path"... | Home Page. | [
"Home",
"Page",
"."
] | [
"\"\"\"\n Home Page.\n\n URL: /\n POST HTTP Method: Renders page along with Keras Model's output\n GET HTTP Method: Renders page without any computation.\n \"\"\"",
"# Retrive review and get rating from model",
"# Open results file to save output for analysis.",
"# Same IP address and browser i... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
0cbe280a3c04e76b859bc082b03c6fb8b6d30823 | SunYanCN/BAND | band/utils.py | [
"Apache-2.0"
] | Python | process_feature | <not_specific> | def process_feature(self, feature):
"""Write a InputFeature to the TFRecordWriter as a tf.train.Example."""
self.num_features += 1
def create_int_feature(values):
feature = tf.train.Feature(
int64_list=tf.train.Int64List(value=list(values)))
return featur... | Write a InputFeature to the TFRecordWriter as a tf.train.Example. | Write a InputFeature to the TFRecordWriter as a tf.train.Example. | [
"Write",
"a",
"InputFeature",
"to",
"the",
"TFRecordWriter",
"as",
"a",
"tf",
".",
"train",
".",
"Example",
"."
] | def process_feature(self, feature):
self.num_features += 1
def create_int_feature(values):
feature = tf.train.Feature(
int64_list=tf.train.Int64List(value=list(values)))
return feature
features = collections.OrderedDict()
features["input_ids"] = cr... | [
"def",
"process_feature",
"(",
"self",
",",
"feature",
")",
":",
"self",
".",
"num_features",
"+=",
"1",
"def",
"create_int_feature",
"(",
"values",
")",
":",
"feature",
"=",
"tf",
".",
"train",
".",
"Feature",
"(",
"int64_list",
"=",
"tf",
".",
"train",... | Write a InputFeature to the TFRecordWriter as a tf.train.Example. | [
"Write",
"a",
"InputFeature",
"to",
"the",
"TFRecordWriter",
"as",
"a",
"tf",
".",
"train",
".",
"Example",
"."
] | [
"\"\"\"Write a InputFeature to the TFRecordWriter as a tf.train.Example.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "feature",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "feature",
"type": null,
"docstring": null,
"docstring_tokens"... |
0cbe280a3c04e76b859bc082b03c6fb8b6d30823 | SunYanCN/BAND | band/utils.py | [
"Apache-2.0"
] | Python | process_feature | <not_specific> | def process_feature(self, feature):
"""Write a InputFeature to the TFRecordWriter as a tf.train.Example."""
self.num_features += 1
def create_int_feature(values):
feature = tf.train.Feature(
int64_list=tf.train.Int64List(value=list(values)))
return featur... | Write a InputFeature to the TFRecordWriter as a tf.train.Example. | Write a InputFeature to the TFRecordWriter as a tf.train.Example. | [
"Write",
"a",
"InputFeature",
"to",
"the",
"TFRecordWriter",
"as",
"a",
"tf",
".",
"train",
".",
"Example",
"."
] | def process_feature(self, feature):
self.num_features += 1
def create_int_feature(values):
feature = tf.train.Feature(
int64_list=tf.train.Int64List(value=list(values)))
return feature
features = collections.OrderedDict()
features["unique_ids"] = c... | [
"def",
"process_feature",
"(",
"self",
",",
"feature",
")",
":",
"self",
".",
"num_features",
"+=",
"1",
"def",
"create_int_feature",
"(",
"values",
")",
":",
"feature",
"=",
"tf",
".",
"train",
".",
"Feature",
"(",
"int64_list",
"=",
"tf",
".",
"train",... | Write a InputFeature to the TFRecordWriter as a tf.train.Example. | [
"Write",
"a",
"InputFeature",
"to",
"the",
"TFRecordWriter",
"as",
"a",
"tf",
".",
"train",
".",
"Example",
"."
] | [
"\"\"\"Write a InputFeature to the TFRecordWriter as a tf.train.Example.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "feature",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "feature",
"type": null,
"docstring": null,
"docstring_tokens"... |
dca346625122b797046ae49b4ff6231bf4e198d0 | SunYanCN/BAND | band/progress.py | [
"Apache-2.0"
] | Python | classification_convert_examples_to_features | <not_specific> | def classification_convert_examples_to_features(examples, tokenizer,
max_length=512,
label_list=None,
output_mode=None,
pad_on_l... |
Loads a data file into a list of ``InputFeatures``
Args:
examples: List of ``InputExamples`` or ``tf.data.Dataset`` containing the examples.
tokenizer: Instance of a tokenizer that will tokenize the examples
max_length: Maximum example length
label_list: List of labels. Can be ... | Loads a data file into a list of ``InputFeatures`` | [
"Loads",
"a",
"data",
"file",
"into",
"a",
"list",
"of",
"`",
"`",
"InputFeatures",
"`",
"`"
] | def classification_convert_examples_to_features(examples, tokenizer,
max_length=512,
label_list=None,
output_mode=None,
pad_on_l... | [
"def",
"classification_convert_examples_to_features",
"(",
"examples",
",",
"tokenizer",
",",
"max_length",
"=",
"512",
",",
"label_list",
"=",
"None",
",",
"output_mode",
"=",
"None",
",",
"pad_on_left",
"=",
"False",
",",
"pad_token",
"=",
"0",
",",
"pad_token... | Loads a data file into a list of ``InputFeatures`` | [
"Loads",
"a",
"data",
"file",
"into",
"a",
"list",
"of",
"`",
"`",
"InputFeatures",
"`",
"`"
] | [
"\"\"\"\n Loads a data file into a list of ``InputFeatures``\n\n Args:\n examples: List of ``InputExamples`` or ``tf.data.Dataset`` containing the examples.\n tokenizer: Instance of a tokenizer that will tokenize the examples\n max_length: Maximum example length\n label_list: List ... | [
{
"param": "examples",
"type": null
},
{
"param": "tokenizer",
"type": null
},
{
"param": "max_length",
"type": null
},
{
"param": "label_list",
"type": null
},
{
"param": "output_mode",
"type": null
},
{
"param": "pad_on_left",
"type": null
},
... | {
"returns": [
{
"docstring": "If the ``examples`` input is a ``tf.data.Dataset``, will return a ``tf.data.Dataset``\ncontaining the task-specific features. If the input is a list of ``InputExamples``, will return\na list of task-specific ``InputFeatures`` which can be fed to the model.",
"docstring_t... |
dca346625122b797046ae49b4ff6231bf4e198d0 | SunYanCN/BAND | band/progress.py | [
"Apache-2.0"
] | Python | write_predictions_extended | <not_specific> | def write_predictions_extended(all_examples, all_features, all_results, n_best_size,
max_answer_length, output_prediction_file,
output_nbest_file,
output_null_log_odds_file, orig_data_file,
start_... | XLNet write prediction logic (more complex than Bert's).
Write final predictions to the json file and log-odds of null if needed.
Requires utils_squad_evaluate.py
| XLNet write prediction logic (more complex than Bert's).
Write final predictions to the json file and log-odds of null if needed. | [
"XLNet",
"write",
"prediction",
"logic",
"(",
"more",
"complex",
"than",
"Bert",
"'",
"s",
")",
".",
"Write",
"final",
"predictions",
"to",
"the",
"json",
"file",
"and",
"log",
"-",
"odds",
"of",
"null",
"if",
"needed",
"."
] | def write_predictions_extended(all_examples, all_features, all_results, n_best_size,
max_answer_length, output_prediction_file,
output_nbest_file,
output_null_log_odds_file, orig_data_file,
start_... | [
"def",
"write_predictions_extended",
"(",
"all_examples",
",",
"all_features",
",",
"all_results",
",",
"n_best_size",
",",
"max_answer_length",
",",
"output_prediction_file",
",",
"output_nbest_file",
",",
"output_null_log_odds_file",
",",
"orig_data_file",
",",
"start_n_t... | XLNet write prediction logic (more complex than Bert's). | [
"XLNet",
"write",
"prediction",
"logic",
"(",
"more",
"complex",
"than",
"Bert",
"'",
"s",
")",
"."
] | [
"\"\"\" XLNet write prediction logic (more complex than Bert's).\n Write final predictions to the json file and log-odds of null if needed.\n Requires utils_squad_evaluate.py\n \"\"\"",
"# pylint: disable=invalid-name",
"# pylint: disable=invalid-name",
"# logger.info(\"Writing nbest to: %s\"... | [
{
"param": "all_examples",
"type": null
},
{
"param": "all_features",
"type": null
},
{
"param": "all_results",
"type": null
},
{
"param": "n_best_size",
"type": null
},
{
"param": "max_answer_length",
"type": null
},
{
"param": "output_prediction_file... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "all_examples",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "all_features",
"type": null,
"docstring": null,
"docs... |
dca346625122b797046ae49b4ff6231bf4e198d0 | SunYanCN/BAND | band/progress.py | [
"Apache-2.0"
] | Python | decode_record | <not_specific> | def decode_record(record, features):
"""Decodes a record to a TensorFlow example."""
example = tf.io.parse_single_example(record, features)
# tf.Example only supports tf.int64, but the TPU only supports tf.int32.
# So cast all int64 to int32.
for name in list(example.keys()):
... | Decodes a record to a TensorFlow example. | Decodes a record to a TensorFlow example. | [
"Decodes",
"a",
"record",
"to",
"a",
"TensorFlow",
"example",
"."
] | def decode_record(record, features):
example = tf.io.parse_single_example(record, features)
for name in list(example.keys()):
t = example[name]
if t.dtype == tf.int64:
t = tf.cast(t, tf.int32)
example[name] = t
return example | [
"def",
"decode_record",
"(",
"record",
",",
"features",
")",
":",
"example",
"=",
"tf",
".",
"io",
".",
"parse_single_example",
"(",
"record",
",",
"features",
")",
"for",
"name",
"in",
"list",
"(",
"example",
".",
"keys",
"(",
")",
")",
":",
"t",
"=... | Decodes a record to a TensorFlow example. | [
"Decodes",
"a",
"record",
"to",
"a",
"TensorFlow",
"example",
"."
] | [
"\"\"\"Decodes a record to a TensorFlow example.\"\"\"",
"# tf.Example only supports tf.int64, but the TPU only supports tf.int32.",
"# So cast all int64 to int32."
] | [
{
"param": "record",
"type": null
},
{
"param": "features",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "record",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "features",
"type": null,
"docstring": null,
"docstring_toke... |
a686e35a7002a93a0b5a54dde97d769f64879645 | SunYanCN/BAND | band/seqeval/callbacks.py | [
"Apache-2.0"
] | Python | convert_idx_to_name | <not_specific> | def convert_idx_to_name(self, y, array_indexes):
"""Convert label index to name.
Args:
y (np.ndarray): label index 2d array.
array_indexes (list): list of valid index arrays for each row.
Returns:
y: label name list.
"""
y = [[self.id2label[i... | Convert label index to name.
Args:
y (np.ndarray): label index 2d array.
array_indexes (list): list of valid index arrays for each row.
Returns:
y: label name list.
| Convert label index to name. | [
"Convert",
"label",
"index",
"to",
"name",
"."
] | def convert_idx_to_name(self, y, array_indexes):
y = [[self.id2label[idx] for idx in row[row_indexes]] for
row, row_indexes in zip(y, array_indexes)]
return y | [
"def",
"convert_idx_to_name",
"(",
"self",
",",
"y",
",",
"array_indexes",
")",
":",
"y",
"=",
"[",
"[",
"self",
".",
"id2label",
"[",
"idx",
"]",
"for",
"idx",
"in",
"row",
"[",
"row_indexes",
"]",
"]",
"for",
"row",
",",
"row_indexes",
"in",
"zip",... | Convert label index to name. | [
"Convert",
"label",
"index",
"to",
"name",
"."
] | [
"\"\"\"Convert label index to name.\n\n Args:\n y (np.ndarray): label index 2d array.\n array_indexes (list): list of valid index arrays for each row.\n\n Returns:\n y: label name list.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "y",
"type": null
},
{
"param": "array_indexes",
"type": null
}
] | {
"returns": [
{
"docstring": "label name list.",
"docstring_tokens": [
"label",
"name",
"list",
"."
],
"type": "y"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_token... |
f5d20baede1a2fb19b08e04ace7d9c326b0773ef | prashantsagar73/bitcoin-bubble-index | original_data/process_data.py | [
"Apache-2.0"
] | Python | process_data | null | def process_data():
"""Convert original data to json file
"""
# Bitcoin price in USD
price = read_datafile('price.txt')
# Difficulty index for bitcoin mining
difficulty = read_datafile('difficulty.txt')
# Google trend index
gtread = read_datafile('gtrend.txt')
# Number of active addr... | Convert original data to json file
| Convert original data to json file | [
"Convert",
"original",
"data",
"to",
"json",
"file"
] | def process_data():
price = read_datafile('price.txt')
difficulty = read_datafile('difficulty.txt')
gtread = read_datafile('gtrend.txt')
sentaddr = read_datafile('sentaddr.txt')
transaction = read_datafile('transaction.txt')
tweets = add_missing_data(
start_date='2010/07/17',
end... | [
"def",
"process_data",
"(",
")",
":",
"price",
"=",
"read_datafile",
"(",
"'price.txt'",
")",
"difficulty",
"=",
"read_datafile",
"(",
"'difficulty.txt'",
")",
"gtread",
"=",
"read_datafile",
"(",
"'gtrend.txt'",
")",
"sentaddr",
"=",
"read_datafile",
"(",
"'sen... | Convert original data to json file | [
"Convert",
"original",
"data",
"to",
"json",
"file"
] | [
"\"\"\"Convert original data to json file\n \"\"\"",
"# Bitcoin price in USD",
"# Difficulty index for bitcoin mining",
"# Google trend index",
"# Number of active address ",
"# Number of transaction per day",
"# Number of tweets per day",
"# Tweets file lacks of the data before the date '2014/04/0... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
883d260adadf40f9f58a80910dd9eb6dcd743121 | com4/poor-richards-settings | conf.py | [
"MIT"
] | Python | update_from_env | null | def update_from_env(settings_class, *, prefix):
"""Update a global settings class with environment variables.
This function pulls environment variables starting with ``prefix``, removes
``prefix``, lower cases the remaining suffix and sets the value on the
class attribute.
.. note::
This f... | Update a global settings class with environment variables.
This function pulls environment variables starting with ``prefix``, removes
``prefix``, lower cases the remaining suffix and sets the value on the
class attribute.
.. note::
This function is thread-safe.
Args:
settings_cla... | Update a global settings class with environment variables.
This function is thread-safe. | [
"Update",
"a",
"global",
"settings",
"class",
"with",
"environment",
"variables",
".",
"This",
"function",
"is",
"thread",
"-",
"safe",
"."
] | def update_from_env(settings_class, *, prefix):
type_hints = get_type_hints(settings_class)
with threading.Lock():
for k in os.environ:
if not k.startswith(prefix):
continue
attr = k.replace(prefix, "").lower()
if attr in getattr(settings_class, "_no_e... | [
"def",
"update_from_env",
"(",
"settings_class",
",",
"*",
",",
"prefix",
")",
":",
"type_hints",
"=",
"get_type_hints",
"(",
"settings_class",
")",
"with",
"threading",
".",
"Lock",
"(",
")",
":",
"for",
"k",
"in",
"os",
".",
"environ",
":",
"if",
"not"... | Update a global settings class with environment variables. | [
"Update",
"a",
"global",
"settings",
"class",
"with",
"environment",
"variables",
"."
] | [
"\"\"\"Update a global settings class with environment variables.\n\n This function pulls environment variables starting with ``prefix``, removes\n ``prefix``, lower cases the remaining suffix and sets the value on the\n class attribute.\n\n .. note::\n\n This function is thread-safe.\n\n Args:... | [
{
"param": "settings_class",
"type": null
},
{
"param": "prefix",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "settings_class",
"type": null,
"docstring": "The global settings class to update",
"docstring_tokens": [
"The",
"global",
"settings",
"class",
"to",
"update"
],
"defa... |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | print_global_stats | null | def print_global_stats():
"""
Print the following stats:
-- Time elapsed since Theano was imported
-- Time spent inside Theano functions
-- Time spent in compiling Theano functions
-- on graph optimization
-- on linker
"""
if config.profiling.destination == 'stde... |
Print the following stats:
-- Time elapsed since Theano was imported
-- Time spent inside Theano functions
-- Time spent in compiling Theano functions
-- on graph optimization
-- on linker
| Print the following stats:
Time elapsed since Theano was imported
Time spent inside Theano functions
Time spent in compiling Theano functions
on graph optimization
on linker | [
"Print",
"the",
"following",
"stats",
":",
"Time",
"elapsed",
"since",
"Theano",
"was",
"imported",
"Time",
"spent",
"inside",
"Theano",
"functions",
"Time",
"spent",
"in",
"compiling",
"Theano",
"functions",
"on",
"graph",
"optimization",
"on",
"linker"
] | def print_global_stats():
if config.profiling.destination == 'stderr':
destination_file = sys.stderr
elif config.profiling.destination == 'stdout':
destination_file = sys.stdout
else:
destination_file = open(config.profiling.destination, 'w')
print('=' * 50, file=destination_file... | [
"def",
"print_global_stats",
"(",
")",
":",
"if",
"config",
".",
"profiling",
".",
"destination",
"==",
"'stderr'",
":",
"destination_file",
"=",
"sys",
".",
"stderr",
"elif",
"config",
".",
"profiling",
".",
"destination",
"==",
"'stdout'",
":",
"destination_... | Print the following stats:
Time elapsed since Theano was imported
Time spent inside Theano functions
Time spent in compiling Theano functions
on graph optimization
on linker | [
"Print",
"the",
"following",
"stats",
":",
"Time",
"elapsed",
"since",
"Theano",
"was",
"imported",
"Time",
"spent",
"inside",
"Theano",
"functions",
"Time",
"spent",
"in",
"compiling",
"Theano",
"functions",
"on",
"graph",
"optimization",
"on",
"linker"
] | [
"\"\"\"\n Print the following stats:\n -- Time elapsed since Theano was imported\n -- Time spent inside Theano functions\n -- Time spent in compiling Theano functions\n -- on graph optimization\n -- on linker\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | class_time | <not_specific> | def class_time(self):
"""
dict op -> total time on thunks
"""
# timing is stored by node, we compute timing by class on demand
rval = {}
for node, t in iteritems(self.apply_time):
typ = type(node.op)
rval.setdefault(typ, 0)
rval[typ] +... |
dict op -> total time on thunks
| dict op -> total time on thunks | [
"dict",
"op",
"-",
">",
"total",
"time",
"on",
"thunks"
] | def class_time(self):
rval = {}
for node, t in iteritems(self.apply_time):
typ = type(node.op)
rval.setdefault(typ, 0)
rval[typ] += t
return rval | [
"def",
"class_time",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
",",
"t",
"in",
"iteritems",
"(",
"self",
".",
"apply_time",
")",
":",
"typ",
"=",
"type",
"(",
"node",
".",
"op",
")",
"rval",
".",
"setdefault",
"(",
"typ",
",",
... | dict op -> total time on thunks | [
"dict",
"op",
"-",
">",
"total",
"time",
"on",
"thunks"
] | [
"\"\"\"\n dict op -> total time on thunks\n\n \"\"\"",
"# timing is stored by node, we compute timing by class on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | class_callcount | <not_specific> | def class_callcount(self):
"""
dict op -> total number of thunk calls
"""
# timing is stored by node, we compute timing by class on demand
rval = {}
for node, count in iteritems(self.apply_callcount):
typ = type(node.op)
rval.setdefault(typ, 0)
... |
dict op -> total number of thunk calls
| dict op -> total number of thunk calls | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"thunk",
"calls"
] | def class_callcount(self):
rval = {}
for node, count in iteritems(self.apply_callcount):
typ = type(node.op)
rval.setdefault(typ, 0)
rval[typ] += count
return rval | [
"def",
"class_callcount",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
",",
"count",
"in",
"iteritems",
"(",
"self",
".",
"apply_callcount",
")",
":",
"typ",
"=",
"type",
"(",
"node",
".",
"op",
")",
"rval",
".",
"setdefault",
"(",
... | dict op -> total number of thunk calls | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"thunk",
"calls"
] | [
"\"\"\"\n dict op -> total number of thunk calls\n\n \"\"\"",
"# timing is stored by node, we compute timing by class on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | class_nodes | <not_specific> | def class_nodes(self):
"""
dict op -> total number of nodes
"""
# timing is stored by node, we compute timing by class on demand
rval = {}
for node, count in iteritems(self.apply_callcount):
typ = type(node.op)
rval.setdefault(typ, 0)
... |
dict op -> total number of nodes
| dict op -> total number of nodes | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"nodes"
] | def class_nodes(self):
rval = {}
for node, count in iteritems(self.apply_callcount):
typ = type(node.op)
rval.setdefault(typ, 0)
rval[typ] += 1
return rval | [
"def",
"class_nodes",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
",",
"count",
"in",
"iteritems",
"(",
"self",
".",
"apply_callcount",
")",
":",
"typ",
"=",
"type",
"(",
"node",
".",
"op",
")",
"rval",
".",
"setdefault",
"(",
"typ... | dict op -> total number of nodes | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"nodes"
] | [
"\"\"\"\n dict op -> total number of nodes\n\n \"\"\"",
"# timing is stored by node, we compute timing by class on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | class_impl | <not_specific> | def class_impl(self):
"""
dict op -> total number of nodes
"""
# timing is stored by node, we compute timing by class on demand
rval = {}
for node in self.apply_callcount:
typ = type(node.op)
if self.apply_cimpl[node]:
impl = 'C '
... |
dict op -> total number of nodes
| dict op -> total number of nodes | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"nodes"
] | def class_impl(self):
rval = {}
for node in self.apply_callcount:
typ = type(node.op)
if self.apply_cimpl[node]:
impl = 'C '
else:
impl = 'Py'
rval.setdefault(typ, impl)
if rval[typ] != impl and len(rval[typ]) ==... | [
"def",
"class_impl",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
"in",
"self",
".",
"apply_callcount",
":",
"typ",
"=",
"type",
"(",
"node",
".",
"op",
")",
"if",
"self",
".",
"apply_cimpl",
"[",
"node",
"]",
":",
"impl",
"=",
"'... | dict op -> total number of nodes | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"nodes"
] | [
"\"\"\"\n dict op -> total number of nodes\n\n \"\"\"",
"# timing is stored by node, we compute timing by class on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | op_time | <not_specific> | def op_time(self):
"""
dict op -> total time on thunks
"""
# timing is stored by node, we compute timing by Op on demand
rval = {}
for node, t in iteritems(self.apply_time):
rval.setdefault(node.op, 0)
rval[node.op] += t
return rval |
dict op -> total time on thunks
| dict op -> total time on thunks | [
"dict",
"op",
"-",
">",
"total",
"time",
"on",
"thunks"
] | def op_time(self):
rval = {}
for node, t in iteritems(self.apply_time):
rval.setdefault(node.op, 0)
rval[node.op] += t
return rval | [
"def",
"op_time",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
",",
"t",
"in",
"iteritems",
"(",
"self",
".",
"apply_time",
")",
":",
"rval",
".",
"setdefault",
"(",
"node",
".",
"op",
",",
"0",
")",
"rval",
"[",
"node",
".",
"o... | dict op -> total time on thunks | [
"dict",
"op",
"-",
">",
"total",
"time",
"on",
"thunks"
] | [
"\"\"\"\n dict op -> total time on thunks\n\n \"\"\"",
"# timing is stored by node, we compute timing by Op on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | fill_node_total_time | null | def fill_node_total_time(self, node, total_times):
"""
node -> fill total time icluding its parents (returns nothing)
"""
# timing is stored by node, we compute total time on demand
total = self.apply_time[node]
for parent in node.get_parents():
if parent.own... |
node -> fill total time icluding its parents (returns nothing)
| > fill total time icluding its parents (returns nothing) | [
">",
"fill",
"total",
"time",
"icluding",
"its",
"parents",
"(",
"returns",
"nothing",
")"
] | def fill_node_total_time(self, node, total_times):
total = self.apply_time[node]
for parent in node.get_parents():
if parent.owner in self.apply_time:
if parent.owner not in total_times:
self.fill_node_total_time(parent.owner, total_times)
... | [
"def",
"fill_node_total_time",
"(",
"self",
",",
"node",
",",
"total_times",
")",
":",
"total",
"=",
"self",
".",
"apply_time",
"[",
"node",
"]",
"for",
"parent",
"in",
"node",
".",
"get_parents",
"(",
")",
":",
"if",
"parent",
".",
"owner",
"in",
"sel... | node -> fill total time icluding its parents (returns nothing) | [
"node",
"-",
">",
"fill",
"total",
"time",
"icluding",
"its",
"parents",
"(",
"returns",
"nothing",
")"
] | [
"\"\"\"\n node -> fill total time icluding its parents (returns nothing)\n\n \"\"\"",
"# timing is stored by node, we compute total time on demand"
] | [
{
"param": "self",
"type": null
},
{
"param": "node",
"type": null
},
{
"param": "total_times",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "node",
"type": null,
"docstring": null,
"docstring_tokens": [... |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | compute_total_times | <not_specific> | def compute_total_times(self):
"""
dict op -> total time icluding the time for parents
"""
rval = {}
for node in self.apply_time:
if node not in rval:
self.fill_node_total_time(node, rval)
return rval |
dict op -> total time icluding the time for parents
| dict op -> total time icluding the time for parents | [
"dict",
"op",
"-",
">",
"total",
"time",
"icluding",
"the",
"time",
"for",
"parents"
] | def compute_total_times(self):
rval = {}
for node in self.apply_time:
if node not in rval:
self.fill_node_total_time(node, rval)
return rval | [
"def",
"compute_total_times",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
"in",
"self",
".",
"apply_time",
":",
"if",
"node",
"not",
"in",
"rval",
":",
"self",
".",
"fill_node_total_time",
"(",
"node",
",",
"rval",
")",
"return",
"rval... | dict op -> total time icluding the time for parents | [
"dict",
"op",
"-",
">",
"total",
"time",
"icluding",
"the",
"time",
"for",
"parents"
] | [
"\"\"\"\n dict op -> total time icluding the time for parents\n\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | op_callcount | <not_specific> | def op_callcount(self):
"""
dict op -> total number of thunk calls
"""
# timing is stored by node, we compute timing by Op on demand
rval = {}
for node, count in iteritems(self.apply_callcount):
rval.setdefault(node.op, 0)
rval[node.op] += count
... |
dict op -> total number of thunk calls
| dict op -> total number of thunk calls | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"thunk",
"calls"
] | def op_callcount(self):
rval = {}
for node, count in iteritems(self.apply_callcount):
rval.setdefault(node.op, 0)
rval[node.op] += count
return rval | [
"def",
"op_callcount",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
",",
"count",
"in",
"iteritems",
"(",
"self",
".",
"apply_callcount",
")",
":",
"rval",
".",
"setdefault",
"(",
"node",
".",
"op",
",",
"0",
")",
"rval",
"[",
"node... | dict op -> total number of thunk calls | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"thunk",
"calls"
] | [
"\"\"\"\n dict op -> total number of thunk calls\n\n \"\"\"",
"# timing is stored by node, we compute timing by Op on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | op_nodes | <not_specific> | def op_nodes(self):
"""
dict op -> total number of nodes
"""
# timing is stored by node, we compute timing by Op on demand
rval = {}
for node, count in iteritems(self.apply_callcount):
rval.setdefault(node.op, 0)
rval[node.op] += 1
return ... |
dict op -> total number of nodes
| dict op -> total number of nodes | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"nodes"
] | def op_nodes(self):
rval = {}
for node, count in iteritems(self.apply_callcount):
rval.setdefault(node.op, 0)
rval[node.op] += 1
return rval | [
"def",
"op_nodes",
"(",
"self",
")",
":",
"rval",
"=",
"{",
"}",
"for",
"node",
",",
"count",
"in",
"iteritems",
"(",
"self",
".",
"apply_callcount",
")",
":",
"rval",
".",
"setdefault",
"(",
"node",
".",
"op",
",",
"0",
")",
"rval",
"[",
"node",
... | dict op -> total number of nodes | [
"dict",
"op",
"-",
">",
"total",
"number",
"of",
"nodes"
] | [
"\"\"\"\n dict op -> total number of nodes\n\n \"\"\"",
"# timing is stored by node, we compute timing by Op on demand"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | count_running_memory | <not_specific> | def count_running_memory(order, fgraph, nodes_mem, ignore_dmap=False):
"""
Calculate memory with specific node order.
Return a list including the following values
1. node_memory_size
Sum of the size of all variables that actually allocate
... |
Calculate memory with specific node order.
Return a list including the following values
1. node_memory_size
Sum of the size of all variables that actually allocate
memory (excluding views, and inplace).
2. running_memory_size
... | Calculate memory with specific node order.
Return a list including the following values
1. node_memory_size
Sum of the size of all variables that actually allocate
memory (excluding views, and inplace).
2. running_memory_size
The memory allocated after the current apply node.
3. running_max_memory_size
The maximum o... | [
"Calculate",
"memory",
"with",
"specific",
"node",
"order",
".",
"Return",
"a",
"list",
"including",
"the",
"following",
"values",
"1",
".",
"node_memory_size",
"Sum",
"of",
"the",
"size",
"of",
"all",
"variables",
"that",
"actually",
"allocate",
"memory",
"("... | def count_running_memory(order, fgraph, nodes_mem, ignore_dmap=False):
from theano.gpuarray import GpuArrayType
node_memory_size = [0, 0]
running_memory_size = [0, 0]
running_max_memory_size = [0, 0]
node_memory_saved_by_view = 0
node_memory_saved_... | [
"def",
"count_running_memory",
"(",
"order",
",",
"fgraph",
",",
"nodes_mem",
",",
"ignore_dmap",
"=",
"False",
")",
":",
"from",
"theano",
".",
"gpuarray",
"import",
"GpuArrayType",
"node_memory_size",
"=",
"[",
"0",
",",
"0",
"]",
"running_memory_size",
"=",... | Calculate memory with specific node order. | [
"Calculate",
"memory",
"with",
"specific",
"node",
"order",
"."
] | [
"\"\"\"\n Calculate memory with specific node order.\n\n Return a list including the following values\n 1. node_memory_size\n Sum of the size of all variables that actually allocate\n memory (excluding views, and inplace).\n 2. running_memo... | [
{
"param": "order",
"type": null
},
{
"param": "fgraph",
"type": null
},
{
"param": "nodes_mem",
"type": null
},
{
"param": "ignore_dmap",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "order",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fgraph",
"type": null,
"docstring": null,
"docstring_tokens"... |
56a7268db418a8076f24bf9b4b2bcba97d29307f | AIPYX/theano | theano/compile/profiling.py | [
"BSD-3-Clause"
] | Python | min_memory_generator | null | def min_memory_generator(executable_nodes, viewed_by, view_of):
"""
Generate all valid node order from node_list and compute its
memory peak.
Parameters
----------
executable_nodes
Set of executable node... |
Generate all valid node order from node_list and compute its
memory peak.
Parameters
----------
executable_nodes
Set of executable nodes.
| Generate all valid node order from node_list and compute its
memory peak.
Parameters
executable_nodes
Set of executable nodes. | [
"Generate",
"all",
"valid",
"node",
"order",
"from",
"node_list",
"and",
"compute",
"its",
"memory",
"peak",
".",
"Parameters",
"executable_nodes",
"Set",
"of",
"executable",
"nodes",
"."
] | def min_memory_generator(executable_nodes, viewed_by, view_of):
global mem_count, mem_bound, max_mem_count
for node in executable_nodes:
new_exec_nodes = executable_nodes.copy()
new_exec_nodes.remove(node)
if max_mem_count > mem... | [
"def",
"min_memory_generator",
"(",
"executable_nodes",
",",
"viewed_by",
",",
"view_of",
")",
":",
"global",
"mem_count",
",",
"mem_bound",
",",
"max_mem_count",
"for",
"node",
"in",
"executable_nodes",
":",
"new_exec_nodes",
"=",
"executable_nodes",
".",
"copy",
... | Generate all valid node order from node_list and compute its
memory peak. | [
"Generate",
"all",
"valid",
"node",
"order",
"from",
"node_list",
"and",
"compute",
"its",
"memory",
"peak",
"."
] | [
"\"\"\"\n Generate all valid node order from node_list and compute its\n memory peak.\n\n Parameters\n ----------\n executable_nodes\n Set of executable nodes.\n\n \"\"\"",
"# Check if cut path now",
"# ... | [
{
"param": "executable_nodes",
"type": null
},
{
"param": "viewed_by",
"type": null
},
{
"param": "view_of",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "executable_nodes",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "viewed_by",
"type": null,
"docstring": null,
"doc... |
1bbbf4c186226428db9da917f6bf4284ed547764 | AIPYX/theano | theano/compile/nanguardmode.py | [
"BSD-3-Clause"
] | Python | _is_numeric_value | <not_specific> | def _is_numeric_value(arr, var):
"""
Checks a variable against non-numeric types such as types, slices,
empty arrays, and None, that need not be checked for NaN and Inf values.
Parameters
----------
arr : the data of that correspond to any Theano Variable
var : The corresponding Theano vari... |
Checks a variable against non-numeric types such as types, slices,
empty arrays, and None, that need not be checked for NaN and Inf values.
Parameters
----------
arr : the data of that correspond to any Theano Variable
var : The corresponding Theano variable
Returns
-------
is_non... | Checks a variable against non-numeric types such as types, slices,
empty arrays, and None, that need not be checked for NaN and Inf values.
Parameters
arr : the data of that correspond to any Theano Variable
var : The corresponding Theano variable
Returns
is_non_numeric : bool
`True` the value is non-numeric. | [
"Checks",
"a",
"variable",
"against",
"non",
"-",
"numeric",
"types",
"such",
"as",
"types",
"slices",
"empty",
"arrays",
"and",
"None",
"that",
"need",
"not",
"be",
"checked",
"for",
"NaN",
"and",
"Inf",
"values",
".",
"Parameters",
"arr",
":",
"the",
"... | def _is_numeric_value(arr, var):
if isinstance(arr, theano.gof.type._cdata_type):
return False
elif isinstance(arr, np.random.mtrand.RandomState):
return False
elif var and getattr(var.tag, 'is_rng', False):
return False
elif isinstance(arr, slice):
return False
elif ... | [
"def",
"_is_numeric_value",
"(",
"arr",
",",
"var",
")",
":",
"if",
"isinstance",
"(",
"arr",
",",
"theano",
".",
"gof",
".",
"type",
".",
"_cdata_type",
")",
":",
"return",
"False",
"elif",
"isinstance",
"(",
"arr",
",",
"np",
".",
"random",
".",
"m... | Checks a variable against non-numeric types such as types, slices,
empty arrays, and None, that need not be checked for NaN and Inf values. | [
"Checks",
"a",
"variable",
"against",
"non",
"-",
"numeric",
"types",
"such",
"as",
"types",
"slices",
"empty",
"arrays",
"and",
"None",
"that",
"need",
"not",
"be",
"checked",
"for",
"NaN",
"and",
"Inf",
"values",
"."
] | [
"\"\"\"\n Checks a variable against non-numeric types such as types, slices,\n empty arrays, and None, that need not be checked for NaN and Inf values.\n\n Parameters\n ----------\n arr : the data of that correspond to any Theano Variable\n var : The corresponding Theano variable\n\n Returns\n ... | [
{
"param": "arr",
"type": null
},
{
"param": "var",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "var",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
8623ec0061ad2fd0b908c85c00bc5679e133d1d3 | AIPYX/theano | theano/tensor/sort.py | [
"BSD-3-Clause"
] | Python | _check_tensor_is_scalar | null | def _check_tensor_is_scalar(var):
'''
Checks if a tensor variable is scalar, raise ValueError otherwise
'''
msg = '%(var)s is expected to be 0d tensor, got %(ndim)d'
if var.ndim != 0:
raise ValueError(
msg % (var, var.ndim)) |
Checks if a tensor variable is scalar, raise ValueError otherwise
| Checks if a tensor variable is scalar, raise ValueError otherwise | [
"Checks",
"if",
"a",
"tensor",
"variable",
"is",
"scalar",
"raise",
"ValueError",
"otherwise"
] | def _check_tensor_is_scalar(var):
msg = '%(var)s is expected to be 0d tensor, got %(ndim)d'
if var.ndim != 0:
raise ValueError(
msg % (var, var.ndim)) | [
"def",
"_check_tensor_is_scalar",
"(",
"var",
")",
":",
"msg",
"=",
"'%(var)s is expected to be 0d tensor, got %(ndim)d'",
"if",
"var",
".",
"ndim",
"!=",
"0",
":",
"raise",
"ValueError",
"(",
"msg",
"%",
"(",
"var",
",",
"var",
".",
"ndim",
")",
")"
] | Checks if a tensor variable is scalar, raise ValueError otherwise | [
"Checks",
"if",
"a",
"tensor",
"variable",
"is",
"scalar",
"raise",
"ValueError",
"otherwise"
] | [
"'''\n Checks if a tensor variable is scalar, raise ValueError otherwise\n '''"
] | [
{
"param": "var",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "var",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8623ec0061ad2fd0b908c85c00bc5679e133d1d3 | AIPYX/theano | theano/tensor/sort.py | [
"BSD-3-Clause"
] | Python | __get_argsort_indices | <not_specific> | def __get_argsort_indices(self, a, axis):
"""
Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".
Returns
-------
1d array if axis is None
list of length len(a.shape) otherwise
"""
# The goal is to get g... |
Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".
Returns
-------
1d array if axis is None
list of length len(a.shape) otherwise
| Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".
Returns
1d array if axis is None
list of length len(a.shape) otherwise | [
"Calculates",
"indices",
"which",
"can",
"be",
"used",
"to",
"reverse",
"sorting",
"operation",
"of",
"\"",
"a",
"\"",
"tensor",
"along",
"\"",
"axis",
"\"",
".",
"Returns",
"1d",
"array",
"if",
"axis",
"is",
"None",
"list",
"of",
"length",
"len",
"(",
... | def __get_argsort_indices(self, a, axis):
idx = argsort(a, axis, kind=self.kind, order=self.order)
rev_idx = argsort(idx, axis, kind=self.kind, order=self.order)
indices = []
axis_data = theano.tensor.switch(theano.tensor.ge(axis.data, 0),
axis.da... | [
"def",
"__get_argsort_indices",
"(",
"self",
",",
"a",
",",
"axis",
")",
":",
"idx",
"=",
"argsort",
"(",
"a",
",",
"axis",
",",
"kind",
"=",
"self",
".",
"kind",
",",
"order",
"=",
"self",
".",
"order",
")",
"rev_idx",
"=",
"argsort",
"(",
"idx",
... | Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis". | [
"Calculates",
"indices",
"which",
"can",
"be",
"used",
"to",
"reverse",
"sorting",
"operation",
"of",
"\"",
"a",
"\"",
"tensor",
"along",
"\"",
"axis",
"\"",
"."
] | [
"\"\"\"\n Calculates indices which can be used to reverse sorting operation of\n \"a\" tensor along \"axis\".\n\n Returns\n -------\n 1d array if axis is None\n list of length len(a.shape) otherwise\n\n \"\"\"",
"# The goal is to get gradient wrt input from gradien... | [
{
"param": "self",
"type": null
},
{
"param": "a",
"type": null
},
{
"param": "axis",
"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": [],
... |
8623ec0061ad2fd0b908c85c00bc5679e133d1d3 | AIPYX/theano | theano/tensor/sort.py | [
"BSD-3-Clause"
] | Python | argsort | <not_specific> | def argsort(a, axis=-1, kind='quicksort', order=None):
"""
Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm
specified by the kind keyword. It returns an array of indices of
the same shape as a that index data along the given axis in so... |
Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm
specified by the kind keyword. It returns an array of indices of
the same shape as a that index data along the given axis in sorted
order.
| Returns the indices that would sort an array.
Perform an indirect sort along the given axis using the algorithm
specified by the kind keyword. It returns an array of indices of
the same shape as a that index data along the given axis in sorted
order. | [
"Returns",
"the",
"indices",
"that",
"would",
"sort",
"an",
"array",
".",
"Perform",
"an",
"indirect",
"sort",
"along",
"the",
"given",
"axis",
"using",
"the",
"algorithm",
"specified",
"by",
"the",
"kind",
"keyword",
".",
"It",
"returns",
"an",
"array",
"... | def argsort(a, axis=-1, kind='quicksort', order=None):
if axis is None:
a = a.flatten()
axis = 0
return ArgSortOp(kind, order)(a, axis) | [
"def",
"argsort",
"(",
"a",
",",
"axis",
"=",
"-",
"1",
",",
"kind",
"=",
"'quicksort'",
",",
"order",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"a",
"=",
"a",
".",
"flatten",
"(",
")",
"axis",
"=",
"0",
"return",
"ArgSortOp",
"("... | Returns the indices that would sort an array. | [
"Returns",
"the",
"indices",
"that",
"would",
"sort",
"an",
"array",
"."
] | [
"\"\"\"\n Returns the indices that would sort an array.\n\n Perform an indirect sort along the given axis using the algorithm\n specified by the kind keyword. It returns an array of indices of\n the same shape as a that index data along the given axis in sorted\n order.\n\n \"\"\""
] | [
{
"param": "a",
"type": null
},
{
"param": "axis",
"type": null
},
{
"param": "kind",
"type": null
},
{
"param": "order",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "a",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "axis",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
db948112d380555a98c8be0467602650996d7a35 | AIPYX/theano | theano/sandbox/rng_mrg.py | [
"BSD-3-Clause"
] | Python | multMatVect | <not_specific> | def multMatVect(v, A, m1, B, m2):
# TODO : need description for parameter and return
"""
Multiply the first half of v by A with a modulo of m1 and the second half
by B with a modulo of m2.
Notes
-----
The parameters of dot_modulo are passed implicitly because passing them
explicitly tak... |
Multiply the first half of v by A with a modulo of m1 and the second half
by B with a modulo of m2.
Notes
-----
The parameters of dot_modulo are passed implicitly because passing them
explicitly takes more time than running the function's C-code.
| Multiply the first half of v by A with a modulo of m1 and the second half
by B with a modulo of m2.
Notes
The parameters of dot_modulo are passed implicitly because passing them
explicitly takes more time than running the function's C-code. | [
"Multiply",
"the",
"first",
"half",
"of",
"v",
"by",
"A",
"with",
"a",
"modulo",
"of",
"m1",
"and",
"the",
"second",
"half",
"by",
"B",
"with",
"a",
"modulo",
"of",
"m2",
".",
"Notes",
"The",
"parameters",
"of",
"dot_modulo",
"are",
"passed",
"implicit... | def multMatVect(v, A, m1, B, m2):
if multMatVect.dot_modulo is None:
A_sym = tensor.lmatrix('A')
s_sym = tensor.ivector('s')
m_sym = tensor.iscalar('m')
A2_sym = tensor.lmatrix('A2')
s2_sym = tensor.ivector('s2')
m2_sym = tensor.iscalar('m2')
o = DotModulo()(A... | [
"def",
"multMatVect",
"(",
"v",
",",
"A",
",",
"m1",
",",
"B",
",",
"m2",
")",
":",
"if",
"multMatVect",
".",
"dot_modulo",
"is",
"None",
":",
"A_sym",
"=",
"tensor",
".",
"lmatrix",
"(",
"'A'",
")",
"s_sym",
"=",
"tensor",
".",
"ivector",
"(",
"... | Multiply the first half of v by A with a modulo of m1 and the second half
by B with a modulo of m2. | [
"Multiply",
"the",
"first",
"half",
"of",
"v",
"by",
"A",
"with",
"a",
"modulo",
"of",
"m1",
"and",
"the",
"second",
"half",
"by",
"B",
"with",
"a",
"modulo",
"of",
"m2",
"."
] | [
"# TODO : need description for parameter and return",
"\"\"\"\n Multiply the first half of v by A with a modulo of m1 and the second half\n by B with a modulo of m2.\n\n Notes\n -----\n The parameters of dot_modulo are passed implicitly because passing them\n explicitly takes more time than runn... | [
{
"param": "v",
"type": null
},
{
"param": "A",
"type": null
},
{
"param": "m1",
"type": null
},
{
"param": "B",
"type": null
},
{
"param": "m2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "v",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "A",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
db948112d380555a98c8be0467602650996d7a35 | AIPYX/theano | theano/sandbox/rng_mrg.py | [
"BSD-3-Clause"
] | Python | seed | null | def seed(self, seed=None):
"""
Re-initialize each random stream.
Parameters
----------
seed : None or integer in range 0 to 2**30
Each random stream will be assigned a unique state that depends
deterministically on this value.
Returns
---... |
Re-initialize each random stream.
Parameters
----------
seed : None or integer in range 0 to 2**30
Each random stream will be assigned a unique state that depends
deterministically on this value.
Returns
-------
None
| Re-initialize each random stream.
Parameters
seed : None or integer in range 0 to 2**30
Each random stream will be assigned a unique state that depends
deterministically on this value.
Returns
None | [
"Re",
"-",
"initialize",
"each",
"random",
"stream",
".",
"Parameters",
"seed",
":",
"None",
"or",
"integer",
"in",
"range",
"0",
"to",
"2",
"**",
"30",
"Each",
"random",
"stream",
"will",
"be",
"assigned",
"a",
"unique",
"state",
"that",
"depends",
"det... | def seed(self, seed=None):
if seed is None:
seed = self.default_instance_seed
self.set_rstate(seed)
for old_r, new_r, size, nstreams in self.state_updates:
if nstreams is None:
nstreams = self.n_streams(size)
rstates = self.get_substream_rstate... | [
"def",
"seed",
"(",
"self",
",",
"seed",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"None",
":",
"seed",
"=",
"self",
".",
"default_instance_seed",
"self",
".",
"set_rstate",
"(",
"seed",
")",
"for",
"old_r",
",",
"new_r",
",",
"size",
",",
"nstreams... | Re-initialize each random stream. | [
"Re",
"-",
"initialize",
"each",
"random",
"stream",
"."
] | [
"\"\"\"\n Re-initialize each random stream.\n\n Parameters\n ----------\n seed : None or integer in range 0 to 2**30\n Each random stream will be assigned a unique state that depends\n deterministically on this value.\n\n Returns\n -------\n Non... | [
{
"param": "self",
"type": null
},
{
"param": "seed",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "seed",
"type": null,
"docstring": null,
"docstring_tokens": [... |
db948112d380555a98c8be0467602650996d7a35 | AIPYX/theano | theano/sandbox/rng_mrg.py | [
"BSD-3-Clause"
] | Python | inc_rstate | null | def inc_rstate(self):
"""
Update self.rstate to be skipped 2^134 steps forward to the next stream
start.
"""
# self.rstate = ff_2p134(self.rstate)
self.rstate = multMatVect(self.rstate, A1p134, M1, A2p134, M2)
assert self.rstate.dtype == np.int32 |
Update self.rstate to be skipped 2^134 steps forward to the next stream
start.
| Update self.rstate to be skipped 2^134 steps forward to the next stream
start. | [
"Update",
"self",
".",
"rstate",
"to",
"be",
"skipped",
"2^134",
"steps",
"forward",
"to",
"the",
"next",
"stream",
"start",
"."
] | def inc_rstate(self):
self.rstate = multMatVect(self.rstate, A1p134, M1, A2p134, M2)
assert self.rstate.dtype == np.int32 | [
"def",
"inc_rstate",
"(",
"self",
")",
":",
"self",
".",
"rstate",
"=",
"multMatVect",
"(",
"self",
".",
"rstate",
",",
"A1p134",
",",
"M1",
",",
"A2p134",
",",
"M2",
")",
"assert",
"self",
".",
"rstate",
".",
"dtype",
"==",
"np",
".",
"int32"
] | Update self.rstate to be skipped 2^134 steps forward to the next stream
start. | [
"Update",
"self",
".",
"rstate",
"to",
"be",
"skipped",
"2^134",
"steps",
"forward",
"to",
"the",
"next",
"stream",
"start",
"."
] | [
"\"\"\"\n Update self.rstate to be skipped 2^134 steps forward to the next stream\n start.\n\n \"\"\"",
"# self.rstate = ff_2p134(self.rstate)"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"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.