repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_create | def experiments_predictions_create(self, experiment_id, model_id, argument_defs, name, arguments=None, properties=None):
"""Create new model run for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
model_id : string
... | python | def experiments_predictions_create(self, experiment_id, model_id, argument_defs, name, arguments=None, properties=None):
"""Create new model run for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
model_id : string
... | [
"def",
"experiments_predictions_create",
"(",
"self",
",",
"experiment_id",
",",
"model_id",
",",
"argument_defs",
",",
"name",
",",
"arguments",
"=",
"None",
",",
"properties",
"=",
"None",
")",
":",
"# Get experiment to ensure that it exists",
"if",
"self",
".",
... | Create new model run for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
model_id : string
Unique identifier of model to run
name : string
User-provided name for the model run
argument_defs :... | [
"Create",
"new",
"model",
"run",
"for",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L429-L463 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_delete | def experiments_predictions_delete(self, experiment_id, run_id, erase=False):
"""Delete given prediction for experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier... | python | def experiments_predictions_delete(self, experiment_id, run_id, erase=False):
"""Delete given prediction for experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier... | [
"def",
"experiments_predictions_delete",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"erase",
"=",
"False",
")",
":",
"# Get model run to ensure that it exists",
"model_run",
"=",
"self",
".",
"experiments_predictions_get",
"(",
"experiment_id",
",",
"run_id"... | Delete given prediction for experiment.
Raises ValueError if an attempt is made to delete a read-only resource.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
erase : Boolean,... | [
"Delete",
"given",
"prediction",
"for",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L465-L492 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_download | def experiments_predictions_download(self, experiment_id, run_id):
"""Donwload the results of a prediction for a given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
... | python | def experiments_predictions_download(self, experiment_id, run_id):
"""Donwload the results of a prediction for a given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
... | [
"def",
"experiments_predictions_download",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
")",
":",
"# Get model run to ensure that it exists",
"model_run",
"=",
"self",
".",
"experiments_predictions_get",
"(",
"experiment_id",
",",
"run_id",
")",
"if",
"model_run",
... | Donwload the results of a prediction for a given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
Returns
-------
FileInfo
Information about pred... | [
"Donwload",
"the",
"results",
"of",
"a",
"prediction",
"for",
"a",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L494-L527 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_get | def experiments_predictions_get(self, experiment_id, run_id):
"""Get prediction object with given identifier for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
... | python | def experiments_predictions_get(self, experiment_id, run_id):
"""Get prediction object with given identifier for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
... | [
"def",
"experiments_predictions_get",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
")",
":",
"# Get experiment to ensure that it exists",
"if",
"self",
".",
"experiments_get",
"(",
"experiment_id",
")",
"is",
"None",
":",
"return",
"None",
"# Get predition handle t... | Get prediction object with given identifier for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
Returns
-------
ModelRunHandle
Handle for ... | [
"Get",
"prediction",
"object",
"with",
"given",
"identifier",
"for",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L529-L556 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_image_set_create | def experiments_predictions_image_set_create(self, experiment_id, run_id, filename):
"""Create a prediction image set from a given tar archive that was
produced as the result of a successful model run.
Returns None if the specified model run does not exist or did not
finish successfully... | python | def experiments_predictions_image_set_create(self, experiment_id, run_id, filename):
"""Create a prediction image set from a given tar archive that was
produced as the result of a successful model run.
Returns None if the specified model run does not exist or did not
finish successfully... | [
"def",
"experiments_predictions_image_set_create",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"filename",
")",
":",
"# Ensure that the model run exists and is in state SUCCESS",
"model_run",
"=",
"self",
".",
"experiments_predictions_get",
"(",
"experiment_id",
",... | Create a prediction image set from a given tar archive that was
produced as the result of a successful model run.
Returns None if the specified model run does not exist or did not
finish successfully. Raises a ValueError if the given file is invalid or
model run.
Parameters
... | [
"Create",
"a",
"prediction",
"image",
"set",
"from",
"a",
"given",
"tar",
"archive",
"that",
"was",
"produced",
"as",
"the",
"result",
"of",
"a",
"successful",
"model",
"run",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L558-L613 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_list | def experiments_predictions_list(self, experiment_id, limit=-1, offset=-1):
"""List of all predictions for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
limit : int
Limit number of results in returned object l... | python | def experiments_predictions_list(self, experiment_id, limit=-1, offset=-1):
"""List of all predictions for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
limit : int
Limit number of results in returned object l... | [
"def",
"experiments_predictions_list",
"(",
"self",
",",
"experiment_id",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"# Get experiment to ensure that it exists",
"if",
"self",
".",
"experiments_get",
"(",
"experiment_id",
")",
"is",
"No... | List of all predictions for given experiment.
Parameters
----------
experiment_id : string
Unique experiment identifier
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object ... | [
"List",
"of",
"all",
"predictions",
"for",
"given",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L615-L640 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_update_state_active | def experiments_predictions_update_state_active(self, experiment_id, run_id):
"""Update state of given prediction to active.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
Ret... | python | def experiments_predictions_update_state_active(self, experiment_id, run_id):
"""Update state of given prediction to active.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
Ret... | [
"def",
"experiments_predictions_update_state_active",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
")",
":",
"# Get prediction to ensure that it exists",
"model_run",
"=",
"self",
".",
"experiments_predictions_get",
"(",
"experiment_id",
",",
"run_id",
")",
"if",
"mo... | Update state of given prediction to active.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
Returns
-------
ModelRunHandle
Handle for updated model run or N... | [
"Update",
"state",
"of",
"given",
"prediction",
"to",
"active",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L642-L665 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_update_state_error | def experiments_predictions_update_state_error(self, experiment_id, run_id, errors):
"""Update state of given prediction to failed. Set error messages that
where generated by the failed run execution.
Parameters
----------
experiment_id : string
Unique experiment ide... | python | def experiments_predictions_update_state_error(self, experiment_id, run_id, errors):
"""Update state of given prediction to failed. Set error messages that
where generated by the failed run execution.
Parameters
----------
experiment_id : string
Unique experiment ide... | [
"def",
"experiments_predictions_update_state_error",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"errors",
")",
":",
"# Get prediction to ensure that it exists",
"model_run",
"=",
"self",
".",
"experiments_predictions_get",
"(",
"experiment_id",
",",
"run_id",
... | Update state of given prediction to failed. Set error messages that
where generated by the failed run execution.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifier
errors : List(st... | [
"Update",
"state",
"of",
"given",
"prediction",
"to",
"failed",
".",
"Set",
"error",
"messages",
"that",
"where",
"generated",
"by",
"the",
"failed",
"run",
"execution",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L667-L693 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_update_state_success | def experiments_predictions_update_state_success(self, experiment_id, run_id, result_file):
"""Update state of given prediction to success. Create a function data
resource for the given result file and associate it with the model run.
Parameters
----------
experiment_id : string... | python | def experiments_predictions_update_state_success(self, experiment_id, run_id, result_file):
"""Update state of given prediction to success. Create a function data
resource for the given result file and associate it with the model run.
Parameters
----------
experiment_id : string... | [
"def",
"experiments_predictions_update_state_success",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"result_file",
")",
":",
"# Get prediction to ensure that it exists",
"model_run",
"=",
"self",
".",
"experiments_predictions_get",
"(",
"experiment_id",
",",
"run_... | Update state of given prediction to success. Create a function data
resource for the given result file and associate it with the model run.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifi... | [
"Update",
"state",
"of",
"given",
"prediction",
"to",
"success",
".",
"Create",
"a",
"function",
"data",
"resource",
"for",
"the",
"given",
"result",
"file",
"and",
"associate",
"it",
"with",
"the",
"model",
"run",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L695-L723 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.experiments_predictions_upsert_property | def experiments_predictions_upsert_property(self, experiment_id, run_id, properties):
"""Upsert property of a prodiction for an experiment.
Raises ValueError if given property dictionary results in an illegal
operation.
Parameters
----------
experiment_id : string
... | python | def experiments_predictions_upsert_property(self, experiment_id, run_id, properties):
"""Upsert property of a prodiction for an experiment.
Raises ValueError if given property dictionary results in an illegal
operation.
Parameters
----------
experiment_id : string
... | [
"def",
"experiments_predictions_upsert_property",
"(",
"self",
",",
"experiment_id",
",",
"run_id",
",",
"properties",
")",
":",
"# Get predition to ensure that it exists. Ensures that the combination",
"# of experiment and prediction identifier is valid.",
"if",
"self",
".",
"expe... | Upsert property of a prodiction for an experiment.
Raises ValueError if given property dictionary results in an illegal
operation.
Parameters
----------
experiment_id : string
Unique experiment identifier
run_id : string
Unique model run identifi... | [
"Upsert",
"property",
"of",
"a",
"prodiction",
"for",
"an",
"experiment",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L725-L750 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.images_create | def images_create(self, filename):
"""Create and image file or image group object from the given file. The
type of the created database object is determined by the suffix of the
given file. An ValueError exception is thrown if the file has an unknown
suffix.
Raises ValueError if... | python | def images_create(self, filename):
"""Create and image file or image group object from the given file. The
type of the created database object is determined by the suffix of the
given file. An ValueError exception is thrown if the file has an unknown
suffix.
Raises ValueError if... | [
"def",
"images_create",
"(",
"self",
",",
"filename",
")",
":",
"# Check if file is a single image",
"suffix",
"=",
"get_filename_suffix",
"(",
"filename",
",",
"image",
".",
"VALID_IMGFILE_SUFFIXES",
")",
"if",
"not",
"suffix",
"is",
"None",
":",
"# Create image ob... | Create and image file or image group object from the given file. The
type of the created database object is determined by the suffix of the
given file. An ValueError exception is thrown if the file has an unknown
suffix.
Raises ValueError if invalid file is given.
Parameters
... | [
"Create",
"and",
"image",
"file",
"or",
"image",
"group",
"object",
"from",
"the",
"given",
"file",
".",
"The",
"type",
"of",
"the",
"created",
"database",
"object",
"is",
"determined",
"by",
"the",
"suffix",
"of",
"the",
"given",
"file",
".",
"An",
"Val... | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L776-L834 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.image_files_download | def image_files_download(self, image_id):
"""Get data file for image with given identifier.
Parameters
----------
image_id : string
Unique image identifier
Returns
-------
FileInfo
Information about image file on disk or None if identifie... | python | def image_files_download(self, image_id):
"""Get data file for image with given identifier.
Parameters
----------
image_id : string
Unique image identifier
Returns
-------
FileInfo
Information about image file on disk or None if identifie... | [
"def",
"image_files_download",
"(",
"self",
",",
"image_id",
")",
":",
"# Retrieve image to ensure that it exist",
"img",
"=",
"self",
".",
"image_files_get",
"(",
"image_id",
")",
"if",
"img",
"is",
"None",
":",
"# Return None if image is unknown",
"return",
"None",
... | Get data file for image with given identifier.
Parameters
----------
image_id : string
Unique image identifier
Returns
-------
FileInfo
Information about image file on disk or None if identifier
is unknown | [
"Get",
"data",
"file",
"for",
"image",
"with",
"given",
"identifier",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L854-L879 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.image_files_list | def image_files_list(self, limit=-1, offset=-1):
"""Retrieve list of all images in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
... | python | def image_files_list(self, limit=-1, offset=-1):
"""Retrieve list of all images in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
... | [
"def",
"image_files_list",
"(",
"self",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"images",
".",
"list_objects",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
")"
] | Retrieve list of all images in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
Returns
-------
ObjectListing
... | [
"Retrieve",
"list",
"of",
"all",
"images",
"in",
"the",
"data",
"store",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L896-L911 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.image_groups_download | def image_groups_download(self, image_group_id):
"""Get data file for image group with given identifier.
Parameters
----------
image_group_id : string
Unique image group identifier
Returns
-------
FileInfo
Information about image group ar... | python | def image_groups_download(self, image_group_id):
"""Get data file for image group with given identifier.
Parameters
----------
image_group_id : string
Unique image group identifier
Returns
-------
FileInfo
Information about image group ar... | [
"def",
"image_groups_download",
"(",
"self",
",",
"image_group_id",
")",
":",
"# Retrieve image group to ensure that it exist",
"img_grp",
"=",
"self",
".",
"image_groups_get",
"(",
"image_group_id",
")",
"if",
"img_grp",
"is",
"None",
":",
"# Return None if image group i... | Get data file for image group with given identifier.
Parameters
----------
image_group_id : string
Unique image group identifier
Returns
-------
FileInfo
Information about image group archive file on disk or None if
identifier is unkn... | [
"Get",
"data",
"file",
"for",
"image",
"group",
"with",
"given",
"identifier",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L951-L976 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.image_group_images_list | def image_group_images_list(self, image_group_id, limit=-1, offset=-1):
"""List images in the given image group.
Parameters
----------
image_group_id : string
Unique image group object identifier
limit : int
Limit number of results in returned object list... | python | def image_group_images_list(self, image_group_id, limit=-1, offset=-1):
"""List images in the given image group.
Parameters
----------
image_group_id : string
Unique image group object identifier
limit : int
Limit number of results in returned object list... | [
"def",
"image_group_images_list",
"(",
"self",
",",
"image_group_id",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"image_groups",
".",
"list_images",
"(",
"image_group_id",
",",
"limit",
"=",
"limit",
",",
... | List images in the given image group.
Parameters
----------
image_group_id : string
Unique image group object identifier
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object... | [
"List",
"images",
"in",
"the",
"given",
"image",
"group",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L993-L1014 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.image_groups_list | def image_groups_list(self, limit=-1, offset=-1):
"""Retrieve list of all image groups in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object stor... | python | def image_groups_list(self, limit=-1, offset=-1):
"""Retrieve list of all image groups in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object stor... | [
"def",
"image_groups_list",
"(",
"self",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"image_groups",
".",
"list_objects",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
")"
] | Retrieve list of all image groups in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
Returns
-------
ObjectListing
... | [
"Retrieve",
"list",
"of",
"all",
"image",
"groups",
"in",
"the",
"data",
"store",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L1016-L1031 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.subjects_create | def subjects_create(self, filename):
"""Create subject from given data files. Expects the file to be a
Freesurfer archive.
Raises ValueError if given file is not a valid subject file.
Parameters
----------
filename : File-type object
Freesurfer archive file
... | python | def subjects_create(self, filename):
"""Create subject from given data files. Expects the file to be a
Freesurfer archive.
Raises ValueError if given file is not a valid subject file.
Parameters
----------
filename : File-type object
Freesurfer archive file
... | [
"def",
"subjects_create",
"(",
"self",
",",
"filename",
")",
":",
"# Ensure that the file name has a valid archive suffix",
"if",
"get_filename_suffix",
"(",
"filename",
",",
"ARCHIVE_SUFFIXES",
")",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'invalid file suffix: '"... | Create subject from given data files. Expects the file to be a
Freesurfer archive.
Raises ValueError if given file is not a valid subject file.
Parameters
----------
filename : File-type object
Freesurfer archive file
Returns
-------
Subject... | [
"Create",
"subject",
"from",
"given",
"data",
"files",
".",
"Expects",
"the",
"file",
"to",
"be",
"a",
"Freesurfer",
"archive",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L1086-L1107 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.subjects_download | def subjects_download(self, subject_id):
"""Get data file for subject with given identifier.
Parameters
----------
subject_id : string
Unique subject identifier
Returns
-------
FileInfo
Information about subject's data file on disk or Non... | python | def subjects_download(self, subject_id):
"""Get data file for subject with given identifier.
Parameters
----------
subject_id : string
Unique subject identifier
Returns
-------
FileInfo
Information about subject's data file on disk or Non... | [
"def",
"subjects_download",
"(",
"self",
",",
"subject_id",
")",
":",
"# Retrieve subject to ensure that it exist",
"subject",
"=",
"self",
".",
"subjects_get",
"(",
"subject_id",
")",
"if",
"subject",
"is",
"None",
":",
"# Return None if subject is unknown",
"return",
... | Get data file for subject with given identifier.
Parameters
----------
subject_id : string
Unique subject identifier
Returns
-------
FileInfo
Information about subject's data file on disk or None if identifier
is unknown | [
"Get",
"data",
"file",
"for",
"subject",
"with",
"given",
"identifier",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L1127-L1152 |
heikomuller/sco-datastore | scodata/__init__.py | SCODataStore.subjects_list | def subjects_list(self, limit=-1, offset=-1):
"""Retrieve list of all subjects in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
... | python | def subjects_list(self, limit=-1, offset=-1):
"""Retrieve list of all subjects in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
... | [
"def",
"subjects_list",
"(",
"self",
",",
"limit",
"=",
"-",
"1",
",",
"offset",
"=",
"-",
"1",
")",
":",
"return",
"self",
".",
"subjects",
".",
"list_objects",
"(",
"limit",
"=",
"limit",
",",
"offset",
"=",
"offset",
")"
] | Retrieve list of all subjects in the data store.
Parameters
----------
limit : int
Limit number of results in returned object listing
offset : int
Set offset in list (order as defined by object store)
Returns
-------
ObjectListing
... | [
"Retrieve",
"list",
"of",
"all",
"subjects",
"in",
"the",
"data",
"store",
"."
] | train | https://github.com/heikomuller/sco-datastore/blob/7180a6b51150667e47629da566aedaa742e39342/scodata/__init__.py#L1169-L1184 |
ulf1/oxyba | oxyba/leland94.py | leland94 | def leland94(V, s, r, a, t, C=None, d=None, PosEq=False):
"""Leland94 Capital Structure model, Corporate Bond valuation model
Parameters:
-----------
V : float
Asset Value of the unlevered firm
s : float
Volatility s of the asset value V of the unlevered firm
r : float
... | python | def leland94(V, s, r, a, t, C=None, d=None, PosEq=False):
"""Leland94 Capital Structure model, Corporate Bond valuation model
Parameters:
-----------
V : float
Asset Value of the unlevered firm
s : float
Volatility s of the asset value V of the unlevered firm
r : float
... | [
"def",
"leland94",
"(",
"V",
",",
"s",
",",
"r",
",",
"a",
",",
"t",
",",
"C",
"=",
"None",
",",
"d",
"=",
"None",
",",
"PosEq",
"=",
"False",
")",
":",
"# subfunction for",
"def",
"netcashpayout_by_dividend",
"(",
"r",
",",
"d",
",",
"s",
")",
... | Leland94 Capital Structure model, Corporate Bond valuation model
Parameters:
-----------
V : float
Asset Value of the unlevered firm
s : float
Volatility s of the asset value V of the unlevered firm
r : float
Risk free rate
a : float
Bankruptcy cost
t : f... | [
"Leland94",
"Capital",
"Structure",
"model",
"Corporate",
"Bond",
"valuation",
"model"
] | train | https://github.com/ulf1/oxyba/blob/b3043116050de275124365cb11e7df91fb40169d/oxyba/leland94.py#L2-L225 |
lizardsystem/tags2sdists | tags2sdists/checkoutdir.py | find_tarball | def find_tarball(directory, name, version):
"""Return matching tarball filename from dist/ dir (if found).
Setuptools generates a source distribution in a ``dist/`` directory and we
need to find the exact filename, whether .tgz or .zip.
We expect "name + '-' + version + '.tar.gz'", but we *can* get a
... | python | def find_tarball(directory, name, version):
"""Return matching tarball filename from dist/ dir (if found).
Setuptools generates a source distribution in a ``dist/`` directory and we
need to find the exact filename, whether .tgz or .zip.
We expect "name + '-' + version + '.tar.gz'", but we *can* get a
... | [
"def",
"find_tarball",
"(",
"directory",
",",
"name",
",",
"version",
")",
":",
"dir_contents",
"=",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"'dist'",
")",
")",
"candidates",
"=",
"[",
"tarball",
"for",
"tarbal... | Return matching tarball filename from dist/ dir (if found).
Setuptools generates a source distribution in a ``dist/`` directory and we
need to find the exact filename, whether .tgz or .zip.
We expect "name + '-' + version + '.tar.gz'", but we *can* get a
-dev.r1234.tar.gz as that can be configured in ... | [
"Return",
"matching",
"tarball",
"filename",
"from",
"dist",
"/",
"dir",
"(",
"if",
"found",
")",
"."
] | train | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/checkoutdir.py#L14-L39 |
lizardsystem/tags2sdists | tags2sdists/checkoutdir.py | CheckoutBaseDir.checkout_dirs | def checkout_dirs(self):
"""Return directories inside the base directory."""
directories = [os.path.join(self.base_directory, d)
for d in os.listdir(self.base_directory)]
return [d for d in directories if os.path.isdir(d)] | python | def checkout_dirs(self):
"""Return directories inside the base directory."""
directories = [os.path.join(self.base_directory, d)
for d in os.listdir(self.base_directory)]
return [d for d in directories if os.path.isdir(d)] | [
"def",
"checkout_dirs",
"(",
"self",
")",
":",
"directories",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"base_directory",
",",
"d",
")",
"for",
"d",
"in",
"os",
".",
"listdir",
"(",
"self",
".",
"base_directory",
")",
"]",
"return",... | Return directories inside the base directory. | [
"Return",
"directories",
"inside",
"the",
"base",
"directory",
"."
] | train | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/checkoutdir.py#L48-L52 |
lizardsystem/tags2sdists | tags2sdists/checkoutdir.py | CheckoutDir.missing_tags | def missing_tags(self, existing_sdists=None):
"""Return difference between existing sdists and available tags."""
if existing_sdists is None:
existing_sdists = []
logger.debug("Existing sdists: %s", existing_sdists)
if self._missing_tags is None:
missing = []
... | python | def missing_tags(self, existing_sdists=None):
"""Return difference between existing sdists and available tags."""
if existing_sdists is None:
existing_sdists = []
logger.debug("Existing sdists: %s", existing_sdists)
if self._missing_tags is None:
missing = []
... | [
"def",
"missing_tags",
"(",
"self",
",",
"existing_sdists",
"=",
"None",
")",
":",
"if",
"existing_sdists",
"is",
"None",
":",
"existing_sdists",
"=",
"[",
"]",
"logger",
".",
"debug",
"(",
"\"Existing sdists: %s\"",
",",
"existing_sdists",
")",
"if",
"self",
... | Return difference between existing sdists and available tags. | [
"Return",
"difference",
"between",
"existing",
"sdists",
"and",
"available",
"tags",
"."
] | train | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/checkoutdir.py#L70-L100 |
lizardsystem/tags2sdists | tags2sdists/checkoutdir.py | CheckoutDir.create_sdist | def create_sdist(self, tag):
"""Create an sdist and return the full file path of the .tar.gz."""
logger.info("Making tempdir for %s with tag %s...",
self.package, tag)
self.wrapper.vcs.checkout_from_tag(tag)
# checkout_from_tag() chdirs to a temp directory that we nee... | python | def create_sdist(self, tag):
"""Create an sdist and return the full file path of the .tar.gz."""
logger.info("Making tempdir for %s with tag %s...",
self.package, tag)
self.wrapper.vcs.checkout_from_tag(tag)
# checkout_from_tag() chdirs to a temp directory that we nee... | [
"def",
"create_sdist",
"(",
"self",
",",
"tag",
")",
":",
"logger",
".",
"info",
"(",
"\"Making tempdir for %s with tag %s...\"",
",",
"self",
".",
"package",
",",
"tag",
")",
"self",
".",
"wrapper",
".",
"vcs",
".",
"checkout_from_tag",
"(",
"tag",
")",
"... | Create an sdist and return the full file path of the .tar.gz. | [
"Create",
"an",
"sdist",
"and",
"return",
"the",
"full",
"file",
"path",
"of",
"the",
".",
"tar",
".",
"gz",
"."
] | train | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/checkoutdir.py#L102-L114 |
lizardsystem/tags2sdists | tags2sdists/checkoutdir.py | CheckoutDir.cleanup | def cleanup(self):
"""Clean up temporary tag checkout dir."""
shutil.rmtree(self.temp_tagdir)
# checkout_from_tag might operate on a subdirectory (mostly
# 'gitclone'), so cleanup the parent dir as well
parentdir = os.path.dirname(self.temp_tagdir)
# ensure we don't remov... | python | def cleanup(self):
"""Clean up temporary tag checkout dir."""
shutil.rmtree(self.temp_tagdir)
# checkout_from_tag might operate on a subdirectory (mostly
# 'gitclone'), so cleanup the parent dir as well
parentdir = os.path.dirname(self.temp_tagdir)
# ensure we don't remov... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"temp_tagdir",
")",
"# checkout_from_tag might operate on a subdirectory (mostly",
"# 'gitclone'), so cleanup the parent dir as well",
"parentdir",
"=",
"os",
".",
"path",
".",
"dirname",
... | Clean up temporary tag checkout dir. | [
"Clean",
"up",
"temporary",
"tag",
"checkout",
"dir",
"."
] | train | https://github.com/lizardsystem/tags2sdists/blob/72f3c664940133e3238fca4d87edcc36b9775e48/tags2sdists/checkoutdir.py#L116-L125 |
shad7/tvdbapi_client | tvdbapi_client/__init__.py | get_client | def get_client(config_file=None, apikey=None, username=None, userpass=None,
service_url=None, verify_ssl_certs=None, select_first=None):
"""Configure the API service and creates a new instance of client.
:param str config_file: absolute path to configuration file
:param str apikey: apikey fr... | python | def get_client(config_file=None, apikey=None, username=None, userpass=None,
service_url=None, verify_ssl_certs=None, select_first=None):
"""Configure the API service and creates a new instance of client.
:param str config_file: absolute path to configuration file
:param str apikey: apikey fr... | [
"def",
"get_client",
"(",
"config_file",
"=",
"None",
",",
"apikey",
"=",
"None",
",",
"username",
"=",
"None",
",",
"userpass",
"=",
"None",
",",
"service_url",
"=",
"None",
",",
"verify_ssl_certs",
"=",
"None",
",",
"select_first",
"=",
"None",
")",
":... | Configure the API service and creates a new instance of client.
:param str config_file: absolute path to configuration file
:param str apikey: apikey from thetvdb
:param str username: username used on thetvdb
:param str userpass: password used on thetvdb
:param str service_url: the url for thetvdb ... | [
"Configure",
"the",
"API",
"service",
"and",
"creates",
"a",
"new",
"instance",
"of",
"client",
"."
] | train | https://github.com/shad7/tvdbapi_client/blob/edf1771184122f4db42af7fc087407a3e6a4e377/tvdbapi_client/__init__.py#L11-L47 |
rorr73/LifeSOSpy | lifesospy/protocol.py | Protocol.close | def close(self) -> None:
"""Closes connection to the LifeSOS ethernet interface."""
self.cancel_pending_tasks()
_LOGGER.debug("Disconnected")
if self._transport:
self._transport.close()
self._is_connected = False | python | def close(self) -> None:
"""Closes connection to the LifeSOS ethernet interface."""
self.cancel_pending_tasks()
_LOGGER.debug("Disconnected")
if self._transport:
self._transport.close()
self._is_connected = False | [
"def",
"close",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"cancel_pending_tasks",
"(",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Disconnected\"",
")",
"if",
"self",
".",
"_transport",
":",
"self",
".",
"_transport",
".",
"close",
"(",
")",
"self",
... | Closes connection to the LifeSOS ethernet interface. | [
"Closes",
"connection",
"to",
"the",
"LifeSOS",
"ethernet",
"interface",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/protocol.py#L177-L185 |
rorr73/LifeSOSpy | lifesospy/protocol.py | Protocol.async_execute | async def async_execute(self, command: Command, password: str = '',
timeout: int = EXECUTE_TIMEOUT_SECS) -> Response:
"""
Execute a command and return response.
command: the command instance to be executed
password: if specified, will be used to execute ... | python | async def async_execute(self, command: Command, password: str = '',
timeout: int = EXECUTE_TIMEOUT_SECS) -> Response:
"""
Execute a command and return response.
command: the command instance to be executed
password: if specified, will be used to execute ... | [
"async",
"def",
"async_execute",
"(",
"self",
",",
"command",
":",
"Command",
",",
"password",
":",
"str",
"=",
"''",
",",
"timeout",
":",
"int",
"=",
"EXECUTE_TIMEOUT_SECS",
")",
"->",
"Response",
":",
"if",
"not",
"self",
".",
"_is_connected",
":",
"ra... | Execute a command and return response.
command: the command instance to be executed
password: if specified, will be used to execute this command (overriding any
global password that may have been assigned to the property)
timeout: maximum number of seconds to wait fo... | [
"Execute",
"a",
"command",
"and",
"return",
"response",
"."
] | train | https://github.com/rorr73/LifeSOSpy/blob/62360fbab2e90bf04d52b547093bdab2d4e389b4/lifesospy/protocol.py#L187-L209 |
hitchtest/hitchserve | hitchserve/service_engine.py | ServiceEngine.longest_service_name | def longest_service_name(self):
"""Length of the longest service name."""
return max([len(service_handle.service.name) for service_handle in self.service_handles] + [0]) | python | def longest_service_name(self):
"""Length of the longest service name."""
return max([len(service_handle.service.name) for service_handle in self.service_handles] + [0]) | [
"def",
"longest_service_name",
"(",
"self",
")",
":",
"return",
"max",
"(",
"[",
"len",
"(",
"service_handle",
".",
"service",
".",
"name",
")",
"for",
"service_handle",
"in",
"self",
".",
"service_handles",
"]",
"+",
"[",
"0",
"]",
")"
] | Length of the longest service name. | [
"Length",
"of",
"the",
"longest",
"service",
"name",
"."
] | train | https://github.com/hitchtest/hitchserve/blob/a2def19979264186d283e76f7f0c88f3ed97f2e0/hitchserve/service_engine.py#L42-L44 |
knagra/farnsworth | threads/templatetags/thread_tags.py | display_user | def display_user(value, arg):
''' Return 'You' if value is equal to arg.
Parameters:
value should be a userprofile
arg should be another user.
Ideally, value should be a userprofile from an object and arg the user logged in.
'''
if value.user == arg and arg.username !... | python | def display_user(value, arg):
''' Return 'You' if value is equal to arg.
Parameters:
value should be a userprofile
arg should be another user.
Ideally, value should be a userprofile from an object and arg the user logged in.
'''
if value.user == arg and arg.username !... | [
"def",
"display_user",
"(",
"value",
",",
"arg",
")",
":",
"if",
"value",
".",
"user",
"==",
"arg",
"and",
"arg",
".",
"username",
"!=",
"ANONYMOUS_USERNAME",
":",
"return",
"\"You\"",
"else",
":",
"return",
"value",
".",
"user",
".",
"get_full_name",
"(... | Return 'You' if value is equal to arg.
Parameters:
value should be a userprofile
arg should be another user.
Ideally, value should be a userprofile from an object and arg the user logged in. | [
"Return",
"You",
"if",
"value",
"is",
"equal",
"to",
"arg",
".",
"Parameters",
":",
"value",
"should",
"be",
"a",
"userprofile",
"arg",
"should",
"be",
"another",
"user",
".",
"Ideally",
"value",
"should",
"be",
"a",
"userprofile",
"from",
"an",
"object",
... | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/threads/templatetags/thread_tags.py#L16-L26 |
knagra/farnsworth | threads/views.py | list_all_threads_view | def list_all_threads_view(request):
''' View of all threads. '''
threads = Thread.objects.all()
create_form = ThreadForm(
request.POST if "submit_thread_form" in request.POST else None,
profile=UserProfile.objects.get(user=request.user),
)
if create_form.is_valid():
thr... | python | def list_all_threads_view(request):
''' View of all threads. '''
threads = Thread.objects.all()
create_form = ThreadForm(
request.POST if "submit_thread_form" in request.POST else None,
profile=UserProfile.objects.get(user=request.user),
)
if create_form.is_valid():
thr... | [
"def",
"list_all_threads_view",
"(",
"request",
")",
":",
"threads",
"=",
"Thread",
".",
"objects",
".",
"all",
"(",
")",
"create_form",
"=",
"ThreadForm",
"(",
"request",
".",
"POST",
"if",
"\"submit_thread_form\"",
"in",
"request",
".",
"POST",
"else",
"No... | View of all threads. | [
"View",
"of",
"all",
"threads",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/threads/views.py#L44-L64 |
knagra/farnsworth | threads/views.py | thread_view | def thread_view(request, pk):
''' View an individual thread. '''
if request.is_ajax():
if not request.user.is_authenticated():
return HttpResponse(json.dumps(dict()),
content_type="application/json")
try:
user_profile = UserProfile.objects.... | python | def thread_view(request, pk):
''' View an individual thread. '''
if request.is_ajax():
if not request.user.is_authenticated():
return HttpResponse(json.dumps(dict()),
content_type="application/json")
try:
user_profile = UserProfile.objects.... | [
"def",
"thread_view",
"(",
"request",
",",
"pk",
")",
":",
"if",
"request",
".",
"is_ajax",
"(",
")",
":",
"if",
"not",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
":",
"return",
"HttpResponse",
"(",
"json",
".",
"dumps",
"(",
"dict",
... | View an individual thread. | [
"View",
"an",
"individual",
"thread",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/threads/views.py#L68-L190 |
knagra/farnsworth | threads/views.py | list_user_threads_view | def list_user_threads_view(request, targetUsername):
''' View of threads a user has created. '''
targetUser = get_object_or_404(User, username=targetUsername)
targetProfile = get_object_or_404(UserProfile, user=targetUser)
threads = Thread.objects.filter(owner=targetProfile)
page_name = "{0}'s Threa... | python | def list_user_threads_view(request, targetUsername):
''' View of threads a user has created. '''
targetUser = get_object_or_404(User, username=targetUsername)
targetProfile = get_object_or_404(UserProfile, user=targetUser)
threads = Thread.objects.filter(owner=targetProfile)
page_name = "{0}'s Threa... | [
"def",
"list_user_threads_view",
"(",
"request",
",",
"targetUsername",
")",
":",
"targetUser",
"=",
"get_object_or_404",
"(",
"User",
",",
"username",
"=",
"targetUsername",
")",
"targetProfile",
"=",
"get_object_or_404",
"(",
"UserProfile",
",",
"user",
"=",
"ta... | View of threads a user has created. | [
"View",
"of",
"threads",
"a",
"user",
"has",
"created",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/threads/views.py#L193-L216 |
knagra/farnsworth | threads/views.py | list_user_messages_view | def list_user_messages_view(request, targetUsername):
''' View of threads a user has posted in. '''
targetUser = get_object_or_404(User, username=targetUsername)
targetProfile = get_object_or_404(UserProfile, user=targetUser)
user_messages = Message.objects.filter(owner=targetProfile)
thread_pks = l... | python | def list_user_messages_view(request, targetUsername):
''' View of threads a user has posted in. '''
targetUser = get_object_or_404(User, username=targetUsername)
targetProfile = get_object_or_404(UserProfile, user=targetUser)
user_messages = Message.objects.filter(owner=targetProfile)
thread_pks = l... | [
"def",
"list_user_messages_view",
"(",
"request",
",",
"targetUsername",
")",
":",
"targetUser",
"=",
"get_object_or_404",
"(",
"User",
",",
"username",
"=",
"targetUsername",
")",
"targetProfile",
"=",
"get_object_or_404",
"(",
"UserProfile",
",",
"user",
"=",
"t... | View of threads a user has posted in. | [
"View",
"of",
"threads",
"a",
"user",
"has",
"posted",
"in",
"."
] | train | https://github.com/knagra/farnsworth/blob/1b6589f0d9fea154f0a1e2231ed906764ed26d26/threads/views.py#L219-L231 |
zvadym/django-stored-settings | stored_settings/admin.py | SettingsAdmin.get_form | def get_form(self, request, obj=None, **kwargs):
"""
Use special form during user creation
"""
defaults = {}
if obj is None:
defaults['form'] = self.add_form
defaults.update(kwargs)
return super(SettingsAdmin, self).get_form(request, obj, **defaults) | python | def get_form(self, request, obj=None, **kwargs):
"""
Use special form during user creation
"""
defaults = {}
if obj is None:
defaults['form'] = self.add_form
defaults.update(kwargs)
return super(SettingsAdmin, self).get_form(request, obj, **defaults) | [
"def",
"get_form",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"}",
"if",
"obj",
"is",
"None",
":",
"defaults",
"[",
"'form'",
"]",
"=",
"self",
".",
"add_form",
"defaults",
".",
... | Use special form during user creation | [
"Use",
"special",
"form",
"during",
"user",
"creation"
] | train | https://github.com/zvadym/django-stored-settings/blob/e68421e5f8c1be95be76a3c21367e1acccd75b71/stored_settings/admin.py#L39-L47 |
tducret/precisionmapper-python | precisionmapper/__init__.py | _css_select | def _css_select(soup, css_selector):
""" Returns the content of the element pointed by the CSS selector,
or an empty string if not found """
selection = soup.select(css_selector)
if len(selection) > 0:
if hasattr(selection[0], 'text'):
retour = selection[0].te... | python | def _css_select(soup, css_selector):
""" Returns the content of the element pointed by the CSS selector,
or an empty string if not found """
selection = soup.select(css_selector)
if len(selection) > 0:
if hasattr(selection[0], 'text'):
retour = selection[0].te... | [
"def",
"_css_select",
"(",
"soup",
",",
"css_selector",
")",
":",
"selection",
"=",
"soup",
".",
"select",
"(",
"css_selector",
")",
"if",
"len",
"(",
"selection",
")",
">",
"0",
":",
"if",
"hasattr",
"(",
"selection",
"[",
"0",
"]",
",",
"'text'",
"... | Returns the content of the element pointed by the CSS selector,
or an empty string if not found | [
"Returns",
"the",
"content",
"of",
"the",
"element",
"pointed",
"by",
"the",
"CSS",
"selector",
"or",
"an",
"empty",
"string",
"if",
"not",
"found"
] | train | https://github.com/tducret/precisionmapper-python/blob/462dcc5bccf6edec780b8b7bc42e8c1d717db942/precisionmapper/__init__.py#L219-L230 |
tducret/precisionmapper-python | precisionmapper/__init__.py | PrecisionMapper.get_authenticity_token | def get_authenticity_token(self, url=_SIGNIN_URL):
""" Returns an authenticity_token, mandatory for signing in """
res = self.client._get(url=url, expected_status_code=200)
soup = BeautifulSoup(res.text, _DEFAULT_BEAUTIFULSOUP_PARSER)
selection = soup.select(_AUTHENTICITY_TOKEN_SELECTOR)... | python | def get_authenticity_token(self, url=_SIGNIN_URL):
""" Returns an authenticity_token, mandatory for signing in """
res = self.client._get(url=url, expected_status_code=200)
soup = BeautifulSoup(res.text, _DEFAULT_BEAUTIFULSOUP_PARSER)
selection = soup.select(_AUTHENTICITY_TOKEN_SELECTOR)... | [
"def",
"get_authenticity_token",
"(",
"self",
",",
"url",
"=",
"_SIGNIN_URL",
")",
":",
"res",
"=",
"self",
".",
"client",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"expected_status_code",
"=",
"200",
")",
"soup",
"=",
"BeautifulSoup",
"(",
"res",
".",
... | Returns an authenticity_token, mandatory for signing in | [
"Returns",
"an",
"authenticity_token",
"mandatory",
"for",
"signing",
"in"
] | train | https://github.com/tducret/precisionmapper-python/blob/462dcc5bccf6edec780b8b7bc42e8c1d717db942/precisionmapper/__init__.py#L131-L142 |
tducret/precisionmapper-python | precisionmapper/__init__.py | PrecisionMapper.get_surveys | def get_surveys(self, url=_SURVEYS_URL):
""" Function to get the surveys for the account """
res = self.client._get(url=url, expected_status_code=200)
soup = BeautifulSoup(res.text, _DEFAULT_BEAUTIFULSOUP_PARSER)
surveys_soup = soup.select(_SURVEYS_SELECTOR)
survey_list = []
... | python | def get_surveys(self, url=_SURVEYS_URL):
""" Function to get the surveys for the account """
res = self.client._get(url=url, expected_status_code=200)
soup = BeautifulSoup(res.text, _DEFAULT_BEAUTIFULSOUP_PARSER)
surveys_soup = soup.select(_SURVEYS_SELECTOR)
survey_list = []
... | [
"def",
"get_surveys",
"(",
"self",
",",
"url",
"=",
"_SURVEYS_URL",
")",
":",
"res",
"=",
"self",
".",
"client",
".",
"_get",
"(",
"url",
"=",
"url",
",",
"expected_status_code",
"=",
"200",
")",
"soup",
"=",
"BeautifulSoup",
"(",
"res",
".",
"text",
... | Function to get the surveys for the account | [
"Function",
"to",
"get",
"the",
"surveys",
"for",
"the",
"account"
] | train | https://github.com/tducret/precisionmapper-python/blob/462dcc5bccf6edec780b8b7bc42e8c1d717db942/precisionmapper/__init__.py#L159-L213 |
unistra/britney-utils | britney_utils.py | get_client | def get_client(name, description, base_url=None, middlewares=None,
reset=False):
""" Build a complete spore client and store it
:param name: name of the client
:param description: the REST API description as a file or URL
:param base_url: the base URL of the REST API
:param middlewar... | python | def get_client(name, description, base_url=None, middlewares=None,
reset=False):
""" Build a complete spore client and store it
:param name: name of the client
:param description: the REST API description as a file or URL
:param base_url: the base URL of the REST API
:param middlewar... | [
"def",
"get_client",
"(",
"name",
",",
"description",
",",
"base_url",
"=",
"None",
",",
"middlewares",
"=",
"None",
",",
"reset",
"=",
"False",
")",
":",
"if",
"name",
"in",
"__clients",
"and",
"not",
"reset",
":",
"return",
"__clients",
"[",
"name",
... | Build a complete spore client and store it
:param name: name of the client
:param description: the REST API description as a file or URL
:param base_url: the base URL of the REST API
:param middlewares: middlewares to enable
:type middlewares: ordered list of 2-elements tuples -> (middleware_class,... | [
"Build",
"a",
"complete",
"spore",
"client",
"and",
"store",
"it"
] | train | https://github.com/unistra/britney-utils/blob/d6b948ab220ee9d5809f3bf9ccd69a46e46f7f20/britney_utils.py#L13-L62 |
b3j0f/utils | b3j0f/utils/iterable.py | isiterable | def isiterable(element, exclude=None):
"""Check whatever or not if input element is an iterable.
:param element: element to check among iterable types.
:param type/tuple exclude: not allowed types in the test.
:Example:
>>> isiterable({})
True
>>> isiterable({}, exclude=dict)
False
... | python | def isiterable(element, exclude=None):
"""Check whatever or not if input element is an iterable.
:param element: element to check among iterable types.
:param type/tuple exclude: not allowed types in the test.
:Example:
>>> isiterable({})
True
>>> isiterable({}, exclude=dict)
False
... | [
"def",
"isiterable",
"(",
"element",
",",
"exclude",
"=",
"None",
")",
":",
"# check for allowed type",
"allowed",
"=",
"exclude",
"is",
"None",
"or",
"not",
"isinstance",
"(",
"element",
",",
"exclude",
")",
"result",
"=",
"allowed",
"and",
"isinstance",
"(... | Check whatever or not if input element is an iterable.
:param element: element to check among iterable types.
:param type/tuple exclude: not allowed types in the test.
:Example:
>>> isiterable({})
True
>>> isiterable({}, exclude=dict)
False
>>> isiterable({}, exclude=(dict,))
Fals... | [
"Check",
"whatever",
"or",
"not",
"if",
"input",
"element",
"is",
"an",
"iterable",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L39-L59 |
b3j0f/utils | b3j0f/utils/iterable.py | ensureiterable | def ensureiterable(value, iterable=list, exclude=None):
"""Convert a value into an iterable if it is not.
:param object value: object to convert
:param type iterable: iterable type to apply (default: list)
:param type/tuple exclude: types to not convert
:Example:
>>> ensureiterable([])
[]... | python | def ensureiterable(value, iterable=list, exclude=None):
"""Convert a value into an iterable if it is not.
:param object value: object to convert
:param type iterable: iterable type to apply (default: list)
:param type/tuple exclude: types to not convert
:Example:
>>> ensureiterable([])
[]... | [
"def",
"ensureiterable",
"(",
"value",
",",
"iterable",
"=",
"list",
",",
"exclude",
"=",
"None",
")",
":",
"result",
"=",
"value",
"if",
"not",
"isiterable",
"(",
"value",
",",
"exclude",
"=",
"exclude",
")",
":",
"result",
"=",
"[",
"value",
"]",
"... | Convert a value into an iterable if it is not.
:param object value: object to convert
:param type iterable: iterable type to apply (default: list)
:param type/tuple exclude: types to not convert
:Example:
>>> ensureiterable([])
[]
>>> ensureiterable([], iterable=tuple)
()
>>> ensu... | [
"Convert",
"a",
"value",
"into",
"an",
"iterable",
"if",
"it",
"is",
"not",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L62-L90 |
b3j0f/utils | b3j0f/utils/iterable.py | first | def first(iterable, default=None):
"""Try to get input iterable first item or default if iterable is empty.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not ... | python | def first(iterable, default=None):
"""Try to get input iterable first item or default if iterable is empty.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not ... | [
"def",
"first",
"(",
"iterable",
",",
"default",
"=",
"None",
")",
":",
"result",
"=",
"default",
"# start to get the iterable iterator (raises TypeError if iter)",
"iterator",
"=",
"iter",
"(",
"iterable",
")",
"# get first element",
"try",
":",
"result",
"=",
"nex... | Try to get input iterable first item or default if iterable is empty.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not an iterable value.
:Example:
>>>... | [
"Try",
"to",
"get",
"input",
"iterable",
"first",
"item",
"or",
"default",
"if",
"iterable",
"is",
"empty",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L93-L121 |
b3j0f/utils | b3j0f/utils/iterable.py | last | def last(iterable, default=None):
"""Try to get the last iterable item by successive iteration on it.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not an ite... | python | def last(iterable, default=None):
"""Try to get the last iterable item by successive iteration on it.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not an ite... | [
"def",
"last",
"(",
"iterable",
",",
"default",
"=",
"None",
")",
":",
"result",
"=",
"default",
"iterator",
"=",
"iter",
"(",
"iterable",
")",
"while",
"True",
":",
"try",
":",
"result",
"=",
"next",
"(",
"iterator",
")",
"except",
"StopIteration",
":... | Try to get the last iterable item by successive iteration on it.
:param Iterable iterable: iterable to iterate on. Must provide the method
__iter__.
:param default: default value to get if input iterable is empty.
:raises TypeError: if iterable is not an iterable value.
:Example:
>>> last... | [
"Try",
"to",
"get",
"the",
"last",
"iterable",
"item",
"by",
"successive",
"iteration",
"on",
"it",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L123-L151 |
b3j0f/utils | b3j0f/utils/iterable.py | itemat | def itemat(iterable, index):
"""Try to get the item at index position in iterable after iterate on
iterable items.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int index: item position to get.
"""
result = None
handleindex = True
if isinstance(ite... | python | def itemat(iterable, index):
"""Try to get the item at index position in iterable after iterate on
iterable items.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int index: item position to get.
"""
result = None
handleindex = True
if isinstance(ite... | [
"def",
"itemat",
"(",
"iterable",
",",
"index",
")",
":",
"result",
"=",
"None",
"handleindex",
"=",
"True",
"if",
"isinstance",
"(",
"iterable",
",",
"dict",
")",
":",
"handleindex",
"=",
"False",
"else",
":",
"try",
":",
"result",
"=",
"iterable",
"[... | Try to get the item at index position in iterable after iterate on
iterable items.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int index: item position to get. | [
"Try",
"to",
"get",
"the",
"item",
"at",
"index",
"position",
"in",
"iterable",
"after",
"iterate",
"on",
"iterable",
"items",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L153-L197 |
b3j0f/utils | b3j0f/utils/iterable.py | sliceit | def sliceit(iterable, lower=0, upper=None):
"""Apply a slice on input iterable.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int lower: lower bound from where start to get items.
:param int upper: upper bound from where finish to get items.
:return: sliced objec... | python | def sliceit(iterable, lower=0, upper=None):
"""Apply a slice on input iterable.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int lower: lower bound from where start to get items.
:param int upper: upper bound from where finish to get items.
:return: sliced objec... | [
"def",
"sliceit",
"(",
"iterable",
",",
"lower",
"=",
"0",
",",
"upper",
"=",
"None",
")",
":",
"if",
"upper",
"is",
"None",
":",
"upper",
"=",
"len",
"(",
"iterable",
")",
"try",
":",
"result",
"=",
"iterable",
"[",
"lower",
":",
"upper",
"]",
"... | Apply a slice on input iterable.
:param iterable: object which provides the method __getitem__ or __iter__.
:param int lower: lower bound from where start to get items.
:param int upper: upper bound from where finish to get items.
:return: sliced object of the same type of iterable if not dict, or spec... | [
"Apply",
"a",
"slice",
"on",
"input",
"iterable",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L199-L247 |
b3j0f/utils | b3j0f/utils/iterable.py | hashiter | def hashiter(iterable):
"""Try to hash input iterable in doing the sum of its content if not
hashable.
Hash method on not iterable depends on type:
hash(iterable.__class__) + ...
- dict: sum of (hash(key) + 1) * (hash(value) + 1).
- Otherwise: sum of (pos + 1) * (hash(item) + 1)."""
... | python | def hashiter(iterable):
"""Try to hash input iterable in doing the sum of its content if not
hashable.
Hash method on not iterable depends on type:
hash(iterable.__class__) + ...
- dict: sum of (hash(key) + 1) * (hash(value) + 1).
- Otherwise: sum of (pos + 1) * (hash(item) + 1)."""
... | [
"def",
"hashiter",
"(",
"iterable",
")",
":",
"result",
"=",
"0",
"try",
":",
"result",
"=",
"hash",
"(",
"iterable",
")",
"except",
"TypeError",
":",
"result",
"=",
"hash",
"(",
"iterable",
".",
"__class__",
")",
"isdict",
"=",
"isinstance",
"(",
"ite... | Try to hash input iterable in doing the sum of its content if not
hashable.
Hash method on not iterable depends on type:
hash(iterable.__class__) + ...
- dict: sum of (hash(key) + 1) * (hash(value) + 1).
- Otherwise: sum of (pos + 1) * (hash(item) + 1). | [
"Try",
"to",
"hash",
"input",
"iterable",
"in",
"doing",
"the",
"sum",
"of",
"its",
"content",
"if",
"not",
"hashable",
"."
] | train | https://github.com/b3j0f/utils/blob/793871b98e90fd1c7ce9ef0dce839cc18fcbc6ff/b3j0f/utils/iterable.py#L250-L283 |
thespacedoctor/qubits | qubits/commonutils.py | set_python_path | def set_python_path():
"""
*Used simply to set the python path for the project modules
- note, the Apache pythonpath is not the same as the users path so this function is particularly usful if the project is a web-based.*
**Key Arguments:**
- ``None``
**Return:**
- ``None``
"""... | python | def set_python_path():
"""
*Used simply to set the python path for the project modules
- note, the Apache pythonpath is not the same as the users path so this function is particularly usful if the project is a web-based.*
**Key Arguments:**
- ``None``
**Return:**
- ``None``
"""... | [
"def",
"set_python_path",
"(",
")",
":",
"################ > IMPORTS ################",
"import",
"yaml",
"## IMPORT THE YAML PYTHONPATH DICTIONARY ##",
"path",
"=",
"os",
".",
"getcwd",
"(",
")",
"################ >ACTION(S) ################",
"# READ THE ABSOLUTE PATH TO THE ROOT... | *Used simply to set the python path for the project modules
- note, the Apache pythonpath is not the same as the users path so this function is particularly usful if the project is a web-based.*
**Key Arguments:**
- ``None``
**Return:**
- ``None`` | [
"*",
"Used",
"simply",
"to",
"set",
"the",
"python",
"path",
"for",
"the",
"project",
"modules",
"-",
"note",
"the",
"Apache",
"pythonpath",
"is",
"not",
"the",
"same",
"as",
"the",
"users",
"path",
"so",
"this",
"function",
"is",
"particularly",
"usful",
... | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/commonutils.py#L56-L90 |
thespacedoctor/qubits | qubits/commonutils.py | read_in_survey_parameters | def read_in_survey_parameters(
log,
pathToSettingsFile
):
"""
*First reads in the mcs_settings.yaml file to determine the name of the settings file to read in the survey parameters.*
**Key Arguments:**
- ``log`` -- logger
- ``pathToSettingsFile`` -- path to the settings file for the... | python | def read_in_survey_parameters(
log,
pathToSettingsFile
):
"""
*First reads in the mcs_settings.yaml file to determine the name of the settings file to read in the survey parameters.*
**Key Arguments:**
- ``log`` -- logger
- ``pathToSettingsFile`` -- path to the settings file for the... | [
"def",
"read_in_survey_parameters",
"(",
"log",
",",
"pathToSettingsFile",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"## THIRD PARTY ##",
"import",
"yaml",
"## LOCAL APPLICATION ##",
"############### VARIABLE ATTRIBUTES #############",
"############... | *First reads in the mcs_settings.yaml file to determine the name of the settings file to read in the survey parameters.*
**Key Arguments:**
- ``log`` -- logger
- ``pathToSettingsFile`` -- path to the settings file for the simulation
**Return:**
- a tuple of settings lists and dictionar... | [
"*",
"First",
"reads",
"in",
"the",
"mcs_settings",
".",
"yaml",
"file",
"to",
"determine",
"the",
"name",
"of",
"the",
"settings",
"file",
"to",
"read",
"in",
"the",
"survey",
"parameters",
".",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/commonutils.py#L96-L215 |
thespacedoctor/qubits | qubits/commonutils.py | settings | def settings(
pathToSettingsFile,
dbConn=True,
log=True
):
"""
*Create a connector to the database if required & setup logging*
**Key Arguments:**
- ``pathToOutputDirectory`` -- path to the outpur directory
- ``dbConn`` -- want a dbConn?
- ``logger`` -- want a logger?
... | python | def settings(
pathToSettingsFile,
dbConn=True,
log=True
):
"""
*Create a connector to the database if required & setup logging*
**Key Arguments:**
- ``pathToOutputDirectory`` -- path to the outpur directory
- ``dbConn`` -- want a dbConn?
- ``logger`` -- want a logger?
... | [
"def",
"settings",
"(",
"pathToSettingsFile",
",",
"dbConn",
"=",
"True",
",",
"log",
"=",
"True",
")",
":",
"################ > IMPORTS ################",
"# set_python_path()",
"import",
"os",
"import",
"dryxPython",
".",
"mysql",
"as",
"m",
"import",
"dryxPython"... | *Create a connector to the database if required & setup logging*
**Key Arguments:**
- ``pathToOutputDirectory`` -- path to the outpur directory
- ``dbConn`` -- want a dbConn?
- ``logger`` -- want a logger?
**Return:**
- dbConn - database connection
- log - logger | [
"*",
"Create",
"a",
"connector",
"to",
"the",
"database",
"if",
"required",
"&",
"setup",
"logging",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/commonutils.py#L225-L258 |
thespacedoctor/qubits | qubits/commonutils.py | plot_polynomial | def plot_polynomial(
log,
title,
polynomialDict,
orginalDataDictionary=False,
pathToOutputPlotsFolder="~/Desktop",
xRange=False,
xlabel=False,
ylabel=False,
xAxisLimits=False,
yAxisLimits=False,
yAxisInvert=False,
prependNum... | python | def plot_polynomial(
log,
title,
polynomialDict,
orginalDataDictionary=False,
pathToOutputPlotsFolder="~/Desktop",
xRange=False,
xlabel=False,
ylabel=False,
xAxisLimits=False,
yAxisLimits=False,
yAxisInvert=False,
prependNum... | [
"def",
"plot_polynomial",
"(",
"log",
",",
"title",
",",
"polynomialDict",
",",
"orginalDataDictionary",
"=",
"False",
",",
"pathToOutputPlotsFolder",
"=",
"\"~/Desktop\"",
",",
"xRange",
"=",
"False",
",",
"xlabel",
"=",
"False",
",",
"ylabel",
"=",
"False",
... | *Plot a dictionary of numpy lightcurves polynomials*
**Key Arguments:**
- ``log`` -- logger
- ``title`` -- title for the plot
- ``polynomialDict`` -- dictionary of polynomials { label01 : poly01, label02 : poly02 }
- ``orginalDataDictionary`` -- the orginal data points {name: [x, y]... | [
"*",
"Plot",
"a",
"dictionary",
"of",
"numpy",
"lightcurves",
"polynomials",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/commonutils.py#L261-L391 |
thespacedoctor/qubits | qubits/commonutils.py | plot_polar | def plot_polar(
log,
title,
dataDictionary,
pathToOutputPlotsFolder="~/Desktop",
dataRange=False,
ylabel=False,
radius=False,
circumference=True,
circleTicksRange=(0, 360, 60),
circleTicksLabels=".",
prependNum=False):
"""
*... | python | def plot_polar(
log,
title,
dataDictionary,
pathToOutputPlotsFolder="~/Desktop",
dataRange=False,
ylabel=False,
radius=False,
circumference=True,
circleTicksRange=(0, 360, 60),
circleTicksLabels=".",
prependNum=False):
"""
*... | [
"def",
"plot_polar",
"(",
"log",
",",
"title",
",",
"dataDictionary",
",",
"pathToOutputPlotsFolder",
"=",
"\"~/Desktop\"",
",",
"dataRange",
"=",
"False",
",",
"ylabel",
"=",
"False",
",",
"radius",
"=",
"False",
",",
"circumference",
"=",
"True",
",",
"cir... | *Plot a dictionary of numpy lightcurves polynomials*
**Key Arguments:**
- ``log`` -- logger
- ``title`` -- title for the plot
- ``dataDictionary`` -- dictionary of data to plot { label01 : dataArray01, label02 : dataArray02 }
- ``pathToOutputPlotsFolder`` -- path the the output fold... | [
"*",
"Plot",
"a",
"dictionary",
"of",
"numpy",
"lightcurves",
"polynomials",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/commonutils.py#L397-L528 |
jjjake/giganews | giganews/utils.py | clean_up | def clean_up(group, identifier, date):
"""Delete all of a groups local mbox, index, and state files.
:type group: str
:param group: group name
:type identifier: str
:param identifier: the identifier for the given group.
:rtype: bool
:returns: True
"""
#log.error('exception raised... | python | def clean_up(group, identifier, date):
"""Delete all of a groups local mbox, index, and state files.
:type group: str
:param group: group name
:type identifier: str
:param identifier: the identifier for the given group.
:rtype: bool
:returns: True
"""
#log.error('exception raised... | [
"def",
"clean_up",
"(",
"group",
",",
"identifier",
",",
"date",
")",
":",
"#log.error('exception raised, cleaning up files.')",
"glob_pat",
"=",
"'{g}.{d}.mbox*'",
".",
"format",
"(",
"g",
"=",
"group",
",",
"d",
"=",
"date",
")",
"for",
"f",
"in",
"glob",
... | Delete all of a groups local mbox, index, and state files.
:type group: str
:param group: group name
:type identifier: str
:param identifier: the identifier for the given group.
:rtype: bool
:returns: True | [
"Delete",
"all",
"of",
"a",
"groups",
"local",
"mbox",
"index",
"and",
"state",
"files",
"."
] | train | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/utils.py#L15-L43 |
jjjake/giganews | giganews/utils.py | utf8_encode_str | def utf8_encode_str(string, encoding='UTF-8'):
"""Attempt to detect the native encoding of `string`, and re-encode
to utf-8
:type string: str
:param string: The string to be encoded.
:rtype: str
:returns: A utf-8 encoded string.
"""
if not string:
return ''
src_enc = chard... | python | def utf8_encode_str(string, encoding='UTF-8'):
"""Attempt to detect the native encoding of `string`, and re-encode
to utf-8
:type string: str
:param string: The string to be encoded.
:rtype: str
:returns: A utf-8 encoded string.
"""
if not string:
return ''
src_enc = chard... | [
"def",
"utf8_encode_str",
"(",
"string",
",",
"encoding",
"=",
"'UTF-8'",
")",
":",
"if",
"not",
"string",
":",
"return",
"''",
"src_enc",
"=",
"chardet",
".",
"detect",
"(",
"string",
")",
"[",
"'encoding'",
"]",
"try",
":",
"return",
"string",
".",
"... | Attempt to detect the native encoding of `string`, and re-encode
to utf-8
:type string: str
:param string: The string to be encoded.
:rtype: str
:returns: A utf-8 encoded string. | [
"Attempt",
"to",
"detect",
"the",
"native",
"encoding",
"of",
"string",
"and",
"re",
"-",
"encode",
"to",
"utf",
"-",
"8"
] | train | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/utils.py#L64-L81 |
jjjake/giganews | giganews/utils.py | inline_compress_chunk | def inline_compress_chunk(chunk, level=1):
"""Compress a string using gzip.
:type chunk: str
:param chunk: The string to be compressed.
:rtype: str
:returns: `chunk` compressed.
"""
b = cStringIO.StringIO()
g = gzip.GzipFile(fileobj=b, mode='wb', compresslevel=level)
g.write(chunk... | python | def inline_compress_chunk(chunk, level=1):
"""Compress a string using gzip.
:type chunk: str
:param chunk: The string to be compressed.
:rtype: str
:returns: `chunk` compressed.
"""
b = cStringIO.StringIO()
g = gzip.GzipFile(fileobj=b, mode='wb', compresslevel=level)
g.write(chunk... | [
"def",
"inline_compress_chunk",
"(",
"chunk",
",",
"level",
"=",
"1",
")",
":",
"b",
"=",
"cStringIO",
".",
"StringIO",
"(",
")",
"g",
"=",
"gzip",
".",
"GzipFile",
"(",
"fileobj",
"=",
"b",
",",
"mode",
"=",
"'wb'",
",",
"compresslevel",
"=",
"level... | Compress a string using gzip.
:type chunk: str
:param chunk: The string to be compressed.
:rtype: str
:returns: `chunk` compressed. | [
"Compress",
"a",
"string",
"using",
"gzip",
"."
] | train | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/utils.py#L86-L102 |
jjjake/giganews | giganews/utils.py | get_utc_iso_date | def get_utc_iso_date(date_str):
"""Convert date str into a iso-formatted UTC date str, i.e.:
yyyymmddhhmmss
:type date_str: str
:param date_str: date string to be parsed.
:rtype: str
:returns: iso-formatted UTC date str.
"""
try:
utc_tuple = dateutil.parser.parse(date_str).utc... | python | def get_utc_iso_date(date_str):
"""Convert date str into a iso-formatted UTC date str, i.e.:
yyyymmddhhmmss
:type date_str: str
:param date_str: date string to be parsed.
:rtype: str
:returns: iso-formatted UTC date str.
"""
try:
utc_tuple = dateutil.parser.parse(date_str).utc... | [
"def",
"get_utc_iso_date",
"(",
"date_str",
")",
":",
"try",
":",
"utc_tuple",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"date_str",
")",
".",
"utctimetuple",
"(",
")",
"except",
"ValueError",
":",
"try",
":",
"date_str",
"=",
"' '",
".",
"join"... | Convert date str into a iso-formatted UTC date str, i.e.:
yyyymmddhhmmss
:type date_str: str
:param date_str: date string to be parsed.
:rtype: str
:returns: iso-formatted UTC date str. | [
"Convert",
"date",
"str",
"into",
"a",
"iso",
"-",
"formatted",
"UTC",
"date",
"str",
"i",
".",
"e",
".",
":",
"yyyymmddhhmmss"
] | train | https://github.com/jjjake/giganews/blob/8cfb26de6c10c482a8da348d438f0ce19e477573/giganews/utils.py#L107-L129 |
adamatan/gitpull | gitpull.py | get_list_of_git_directories | def get_list_of_git_directories():
"""Returns a list of paths of git repos under the current directory."""
dirs = [path[0] for path in list(os.walk('.')) if path[0].endswith('.git')]
dirs = ['/'.join(path.split('/')[:-1]) for path in dirs]
return sorted(dirs) | python | def get_list_of_git_directories():
"""Returns a list of paths of git repos under the current directory."""
dirs = [path[0] for path in list(os.walk('.')) if path[0].endswith('.git')]
dirs = ['/'.join(path.split('/')[:-1]) for path in dirs]
return sorted(dirs) | [
"def",
"get_list_of_git_directories",
"(",
")",
":",
"dirs",
"=",
"[",
"path",
"[",
"0",
"]",
"for",
"path",
"in",
"list",
"(",
"os",
".",
"walk",
"(",
"'.'",
")",
")",
"if",
"path",
"[",
"0",
"]",
".",
"endswith",
"(",
"'.git'",
")",
"]",
"dirs"... | Returns a list of paths of git repos under the current directory. | [
"Returns",
"a",
"list",
"of",
"paths",
"of",
"git",
"repos",
"under",
"the",
"current",
"directory",
"."
] | train | https://github.com/adamatan/gitpull/blob/1f4439f903ef05982eea7c3bb67004d4ef3c4098/gitpull.py#L41-L45 |
adamatan/gitpull | gitpull.py | run_git_concurrently | def run_git_concurrently(base_dir):
"""Runs the 'git status' and 'git pull' commands in threads and reports
the results in a pretty table."""
os.chdir(base_dir)
git_dirs = get_list_of_git_directories()
print("Processing %d git repos: %s" % (len(git_dirs), ', '.join(git_dirs)))
widgets = [Percen... | python | def run_git_concurrently(base_dir):
"""Runs the 'git status' and 'git pull' commands in threads and reports
the results in a pretty table."""
os.chdir(base_dir)
git_dirs = get_list_of_git_directories()
print("Processing %d git repos: %s" % (len(git_dirs), ', '.join(git_dirs)))
widgets = [Percen... | [
"def",
"run_git_concurrently",
"(",
"base_dir",
")",
":",
"os",
".",
"chdir",
"(",
"base_dir",
")",
"git_dirs",
"=",
"get_list_of_git_directories",
"(",
")",
"print",
"(",
"\"Processing %d git repos: %s\"",
"%",
"(",
"len",
"(",
"git_dirs",
")",
",",
"', '",
"... | Runs the 'git status' and 'git pull' commands in threads and reports
the results in a pretty table. | [
"Runs",
"the",
"git",
"status",
"and",
"git",
"pull",
"commands",
"in",
"threads",
"and",
"reports",
"the",
"results",
"in",
"a",
"pretty",
"table",
"."
] | train | https://github.com/adamatan/gitpull/blob/1f4439f903ef05982eea7c3bb67004d4ef3c4098/gitpull.py#L47-L103 |
dossier/dossier.web | dossier/web/routes.py | v1_search | def v1_search(request, response, visid_to_dbid, config,
search_engines, filters, cid, engine_name):
'''Search feature collections.
The route for this endpoint is:
``/dossier/v1/<content_id>/search/<search_engine_name>``.
``content_id`` can be any *profile* content identifier. (This
r... | python | def v1_search(request, response, visid_to_dbid, config,
search_engines, filters, cid, engine_name):
'''Search feature collections.
The route for this endpoint is:
``/dossier/v1/<content_id>/search/<search_engine_name>``.
``content_id`` can be any *profile* content identifier. (This
r... | [
"def",
"v1_search",
"(",
"request",
",",
"response",
",",
"visid_to_dbid",
",",
"config",
",",
"search_engines",
",",
"filters",
",",
"cid",
",",
"engine_name",
")",
":",
"db_cid",
"=",
"visid_to_dbid",
"(",
"cid",
")",
"try",
":",
"search_engine",
"=",
"s... | Search feature collections.
The route for this endpoint is:
``/dossier/v1/<content_id>/search/<search_engine_name>``.
``content_id`` can be any *profile* content identifier. (This
restriction may be lifted at some point.) Namely, it must start
with ``p|``.
``engine_name`` corresponds to the s... | [
"Search",
"feature",
"collections",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L105-L145 |
dossier/dossier.web | dossier/web/routes.py | v1_fc_get | def v1_fc_get(visid_to_dbid, store, cid):
'''Retrieve a single feature collection.
The route for this endpoint is:
``/dossier/v1/feature-collections/<content_id>``.
This endpoint returns a JSON serialization of the feature collection
identified by ``content_id``.
'''
fc = store.get(visid_t... | python | def v1_fc_get(visid_to_dbid, store, cid):
'''Retrieve a single feature collection.
The route for this endpoint is:
``/dossier/v1/feature-collections/<content_id>``.
This endpoint returns a JSON serialization of the feature collection
identified by ``content_id``.
'''
fc = store.get(visid_t... | [
"def",
"v1_fc_get",
"(",
"visid_to_dbid",
",",
"store",
",",
"cid",
")",
":",
"fc",
"=",
"store",
".",
"get",
"(",
"visid_to_dbid",
"(",
"cid",
")",
")",
"if",
"fc",
"is",
"None",
":",
"bottle",
".",
"abort",
"(",
"404",
",",
"'Feature collection \"%s\... | Retrieve a single feature collection.
The route for this endpoint is:
``/dossier/v1/feature-collections/<content_id>``.
This endpoint returns a JSON serialization of the feature collection
identified by ``content_id``. | [
"Retrieve",
"a",
"single",
"feature",
"collection",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L164-L176 |
dossier/dossier.web | dossier/web/routes.py | v1_fc_put | def v1_fc_put(request, response, visid_to_dbid, store, cid):
'''Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in the ... | python | def v1_fc_put(request, response, visid_to_dbid, store, cid):
'''Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in the ... | [
"def",
"v1_fc_put",
"(",
"request",
",",
"response",
",",
"visid_to_dbid",
",",
"store",
",",
"cid",
")",
":",
"fc",
"=",
"FeatureCollection",
".",
"from_dict",
"(",
"json",
".",
"load",
"(",
"request",
".",
"body",
")",
")",
"store",
".",
"put",
"(",
... | Store a single feature collection.
The route for this endpoint is:
``PUT /dossier/v1/feature-collections/<content_id>``.
``content_id`` is the id to associate with the given feature
collection. The feature collection should be in the request
body serialized as JSON.
This endpoint returns stat... | [
"Store",
"a",
"single",
"feature",
"collection",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L180-L196 |
dossier/dossier.web | dossier/web/routes.py | v1_random_fc_get | def v1_random_fc_get(response, dbid_to_visid, store):
'''Retrieves a random feature collection from the database.
The route for this endpoint is:
``GET /dossier/v1/random/feature-collection``.
Assuming the database has at least one feature collection,
this end point returns an array of two element... | python | def v1_random_fc_get(response, dbid_to_visid, store):
'''Retrieves a random feature collection from the database.
The route for this endpoint is:
``GET /dossier/v1/random/feature-collection``.
Assuming the database has at least one feature collection,
this end point returns an array of two element... | [
"def",
"v1_random_fc_get",
"(",
"response",
",",
"dbid_to_visid",
",",
"store",
")",
":",
"# Careful, `store.scan()` would be obscenely slow here...",
"sample",
"=",
"streaming_sample",
"(",
"store",
".",
"scan_ids",
"(",
")",
",",
"1",
",",
"1000",
")",
"if",
"le... | Retrieves a random feature collection from the database.
The route for this endpoint is:
``GET /dossier/v1/random/feature-collection``.
Assuming the database has at least one feature collection,
this end point returns an array of two elements. The first
element is the content id and the second ele... | [
"Retrieves",
"a",
"random",
"feature",
"collection",
"from",
"the",
"database",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L200-L220 |
dossier/dossier.web | dossier/web/routes.py | v1_label_put | def v1_label_put(request, response, visid_to_dbid, config, label_hooks,
label_store, cid1, cid2, annotator_id):
'''Store a single label.
The route for this endpoint is:
``PUT /dossier/v1/labels/<content_id1>/<content_id2>/<annotator_id>``.
``content_id`` are the ids of the feature col... | python | def v1_label_put(request, response, visid_to_dbid, config, label_hooks,
label_store, cid1, cid2, annotator_id):
'''Store a single label.
The route for this endpoint is:
``PUT /dossier/v1/labels/<content_id1>/<content_id2>/<annotator_id>``.
``content_id`` are the ids of the feature col... | [
"def",
"v1_label_put",
"(",
"request",
",",
"response",
",",
"visid_to_dbid",
",",
"config",
",",
"label_hooks",
",",
"label_store",
",",
"cid1",
",",
"cid2",
",",
"annotator_id",
")",
":",
"coref_value",
"=",
"CorefValue",
"(",
"int",
"(",
"request",
".",
... | Store a single label.
The route for this endpoint is:
``PUT /dossier/v1/labels/<content_id1>/<content_id2>/<annotator_id>``.
``content_id`` are the ids of the feature collections to
associate. ``annotator_id`` is a string that identifies the
human that created the label. The value of the label sho... | [
"Store",
"a",
"single",
"label",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L224-L253 |
dossier/dossier.web | dossier/web/routes.py | v1_label_direct | def v1_label_direct(request, response, visid_to_dbid, dbid_to_visid,
label_store, cid, subid=None):
'''Return directly connected labels.
The routes for this endpoint are
``/dossier/v1/label/<cid>/direct`` and
``/dossier/v1/label/<cid>/subtopic/<subid>/direct``.
This returns all... | python | def v1_label_direct(request, response, visid_to_dbid, dbid_to_visid,
label_store, cid, subid=None):
'''Return directly connected labels.
The routes for this endpoint are
``/dossier/v1/label/<cid>/direct`` and
``/dossier/v1/label/<cid>/subtopic/<subid>/direct``.
This returns all... | [
"def",
"v1_label_direct",
"(",
"request",
",",
"response",
",",
"visid_to_dbid",
",",
"dbid_to_visid",
",",
"label_store",
",",
"cid",
",",
"subid",
"=",
"None",
")",
":",
"lab_to_json",
"=",
"partial",
"(",
"label_to_json",
",",
"dbid_to_visid",
")",
"ident",... | Return directly connected labels.
The routes for this endpoint are
``/dossier/v1/label/<cid>/direct`` and
``/dossier/v1/label/<cid>/subtopic/<subid>/direct``.
This returns all directly connected labels for ``cid``. Or, if
a subtopic id is given, then only directly connected labels for
``(cid, ... | [
"Return",
"directly",
"connected",
"labels",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L258-L278 |
dossier/dossier.web | dossier/web/routes.py | v1_label_negative_inference | def v1_label_negative_inference(request, response,
visid_to_dbid, dbid_to_visid,
label_store, cid):
'''Return inferred negative labels.
The route for this endpoint is:
``/dossier/v1/label/<cid>/negative-inference``.
Negative labels are in... | python | def v1_label_negative_inference(request, response,
visid_to_dbid, dbid_to_visid,
label_store, cid):
'''Return inferred negative labels.
The route for this endpoint is:
``/dossier/v1/label/<cid>/negative-inference``.
Negative labels are in... | [
"def",
"v1_label_negative_inference",
"(",
"request",
",",
"response",
",",
"visid_to_dbid",
",",
"dbid_to_visid",
",",
"label_store",
",",
"cid",
")",
":",
"# No subtopics yet? :-(",
"lab_to_json",
"=",
"partial",
"(",
"label_to_json",
",",
"dbid_to_visid",
")",
"l... | Return inferred negative labels.
The route for this endpoint is:
``/dossier/v1/label/<cid>/negative-inference``.
Negative labels are inferred by first getting all other content ids
connected to ``cid`` through a negative label. For each directly
adjacent ``cid'``, the connected components of ``cid... | [
"Return",
"inferred",
"negative",
"labels",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L336-L358 |
dossier/dossier.web | dossier/web/routes.py | v1_folder_list | def v1_folder_list(request, kvlclient):
'''Retrieves a list of folders for the current user.
The route for this endpoint is: ``GET /dossier/v1/folder``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload returned is a list of folder identifiers.
... | python | def v1_folder_list(request, kvlclient):
'''Retrieves a list of folders for the current user.
The route for this endpoint is: ``GET /dossier/v1/folder``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload returned is a list of folder identifiers.
... | [
"def",
"v1_folder_list",
"(",
"request",
",",
"kvlclient",
")",
":",
"return",
"sorted",
"(",
"imap",
"(",
"attrgetter",
"(",
"'name'",
")",
",",
"ifilter",
"(",
"lambda",
"it",
":",
"it",
".",
"is_folder",
"(",
")",
",",
"new_folders",
"(",
"kvlclient",... | Retrieves a list of folders for the current user.
The route for this endpoint is: ``GET /dossier/v1/folder``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload returned is a list of folder identifiers. | [
"Retrieves",
"a",
"list",
"of",
"folders",
"for",
"the",
"current",
"user",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L362-L374 |
dossier/dossier.web | dossier/web/routes.py | v1_folder_add | def v1_folder_add(request, response, kvlclient, fid):
'''Adds a folder belonging to the current user.
The route for this endpoint is: ``PUT /dossier/v1/folder/<fid>``.
If the folder was added successfully, ``201`` status is returned.
(Temporarily, the "current user" can be set via the
``annotator... | python | def v1_folder_add(request, response, kvlclient, fid):
'''Adds a folder belonging to the current user.
The route for this endpoint is: ``PUT /dossier/v1/folder/<fid>``.
If the folder was added successfully, ``201`` status is returned.
(Temporarily, the "current user" can be set via the
``annotator... | [
"def",
"v1_folder_add",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"fid",
")",
":",
"fid",
"=",
"urllib",
".",
"unquote",
"(",
"fid",
")",
"new_folders",
"(",
"kvlclient",
",",
"request",
")",
".",
"put_folder",
"(",
"fid",
")",
"response",
... | Adds a folder belonging to the current user.
The route for this endpoint is: ``PUT /dossier/v1/folder/<fid>``.
If the folder was added successfully, ``201`` status is returned.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.) | [
"Adds",
"a",
"folder",
"belonging",
"to",
"the",
"current",
"user",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L378-L390 |
dossier/dossier.web | dossier/web/routes.py | v1_subfolder_list | def v1_subfolder_list(request, response, kvlclient, fid):
'''Retrieves a list of subfolders in a folder for the current user.
The route for this endpoint is:
``GET /dossier/v1/folder/<fid>/subfolder``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The ... | python | def v1_subfolder_list(request, response, kvlclient, fid):
'''Retrieves a list of subfolders in a folder for the current user.
The route for this endpoint is:
``GET /dossier/v1/folder/<fid>/subfolder``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The ... | [
"def",
"v1_subfolder_list",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"fid",
")",
":",
"fid",
"=",
"urllib",
".",
"unquote",
"(",
"fid",
")",
"try",
":",
"return",
"sorted",
"(",
"imap",
"(",
"attrgetter",
"(",
"'name'",
")",
",",
"ifilte... | Retrieves a list of subfolders in a folder for the current user.
The route for this endpoint is:
``GET /dossier/v1/folder/<fid>/subfolder``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload returned is a list of subfolder identifiers. | [
"Retrieves",
"a",
"list",
"of",
"subfolders",
"in",
"a",
"folder",
"for",
"the",
"current",
"user",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L394-L412 |
dossier/dossier.web | dossier/web/routes.py | v1_subfolder_add | def v1_subfolder_add(request, response, kvlclient,
fid, sfid, cid, subid=None):
'''Adds a subtopic to a subfolder for the current user.
The route for this endpoint is:
``PUT /dossier/v1/folder/<fid>/subfolder/<sfid>/<cid>/<subid>``.
``fid`` is the folder identifier, e.g., ``My_Fol... | python | def v1_subfolder_add(request, response, kvlclient,
fid, sfid, cid, subid=None):
'''Adds a subtopic to a subfolder for the current user.
The route for this endpoint is:
``PUT /dossier/v1/folder/<fid>/subfolder/<sfid>/<cid>/<subid>``.
``fid`` is the folder identifier, e.g., ``My_Fol... | [
"def",
"v1_subfolder_add",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"fid",
",",
"sfid",
",",
"cid",
",",
"subid",
"=",
"None",
")",
":",
"if",
"subid",
"is",
"not",
"None",
":",
"assert",
"'@'",
"not",
"in",
"subid",
"path",
"=",
"[",
... | Adds a subtopic to a subfolder for the current user.
The route for this endpoint is:
``PUT /dossier/v1/folder/<fid>/subfolder/<sfid>/<cid>/<subid>``.
``fid`` is the folder identifier, e.g., ``My_Folder``.
``sfid`` is the subfolder identifier, e.g., ``My_Subtopic``.
``cid`` and ``subid`` are the ... | [
"Adds",
"a",
"subtopic",
"to",
"a",
"subfolder",
"for",
"the",
"current",
"user",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L417-L448 |
dossier/dossier.web | dossier/web/routes.py | v1_subtopic_list | def v1_subtopic_list(request, response, kvlclient, fid, sfid):
'''Retrieves a list of items in a subfolder.
The route for this endpoint is:
``GET /dossier/v1/folder/<fid>/subfolder/<sfid>``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload ret... | python | def v1_subtopic_list(request, response, kvlclient, fid, sfid):
'''Retrieves a list of items in a subfolder.
The route for this endpoint is:
``GET /dossier/v1/folder/<fid>/subfolder/<sfid>``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload ret... | [
"def",
"v1_subtopic_list",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"fid",
",",
"sfid",
")",
":",
"path",
"=",
"urllib",
".",
"unquote",
"(",
"fid",
")",
"+",
"'/'",
"+",
"urllib",
".",
"unquote",
"(",
"sfid",
")",
"try",
":",
"items",... | Retrieves a list of items in a subfolder.
The route for this endpoint is:
``GET /dossier/v1/folder/<fid>/subfolder/<sfid>``.
(Temporarily, the "current user" can be set via the
``annotator_id`` query parameter.)
The payload returned is a list of two element arrays. The first
element in the ar... | [
"Retrieves",
"a",
"list",
"of",
"items",
"in",
"a",
"subfolder",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L452-L476 |
dossier/dossier.web | dossier/web/routes.py | v1_folder_delete | def v1_folder_delete(request, response, kvlclient,
fid, sfid=None, cid=None, subid=None):
'''Deletes a folder, subfolder or item.
The routes for this endpoint are:
* ``DELETE /dossier/v1/folder/<fid>``
* ``DELETE /dossier/v1/folder/<fid>/subfolder/<sfid>``
* ``DELETE /dossier/... | python | def v1_folder_delete(request, response, kvlclient,
fid, sfid=None, cid=None, subid=None):
'''Deletes a folder, subfolder or item.
The routes for this endpoint are:
* ``DELETE /dossier/v1/folder/<fid>``
* ``DELETE /dossier/v1/folder/<fid>/subfolder/<sfid>``
* ``DELETE /dossier/... | [
"def",
"v1_folder_delete",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"fid",
",",
"sfid",
"=",
"None",
",",
"cid",
"=",
"None",
",",
"subid",
"=",
"None",
")",
":",
"new_folders",
"(",
"kvlclient",
",",
"request",
")",
".",
"delete",
"(",
... | Deletes a folder, subfolder or item.
The routes for this endpoint are:
* ``DELETE /dossier/v1/folder/<fid>``
* ``DELETE /dossier/v1/folder/<fid>/subfolder/<sfid>``
* ``DELETE /dossier/v1/folder/<fid>/subfolder/<sfid>/<cid>``
* ``DELETE /dossier/v1/folder/<fid>/subfolder/<sfid>/<cid>/<subid>`` | [
"Deletes",
"a",
"folder",
"subfolder",
"or",
"item",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L483-L495 |
dossier/dossier.web | dossier/web/routes.py | v1_folder_rename | def v1_folder_rename(request, response, kvlclient,
fid_src, fid_dest, sfid_src=None, sfid_dest=None):
'''Rename a folder or a subfolder.
The routes for this endpoint are:
* ``POST /dossier/v1/<fid_src>/rename/<fid_dest>``
* ``POST /dossier/v1/<fid_src>/subfolder/<sfid_src>/rename/... | python | def v1_folder_rename(request, response, kvlclient,
fid_src, fid_dest, sfid_src=None, sfid_dest=None):
'''Rename a folder or a subfolder.
The routes for this endpoint are:
* ``POST /dossier/v1/<fid_src>/rename/<fid_dest>``
* ``POST /dossier/v1/<fid_src>/subfolder/<sfid_src>/rename/... | [
"def",
"v1_folder_rename",
"(",
"request",
",",
"response",
",",
"kvlclient",
",",
"fid_src",
",",
"fid_dest",
",",
"sfid_src",
"=",
"None",
",",
"sfid_dest",
"=",
"None",
")",
":",
"src",
",",
"dest",
"=",
"make_path",
"(",
"fid_src",
",",
"sfid_src",
"... | Rename a folder or a subfolder.
The routes for this endpoint are:
* ``POST /dossier/v1/<fid_src>/rename/<fid_dest>``
* ``POST /dossier/v1/<fid_src>/subfolder/<sfid_src>/rename/
<fid_dest>/subfolder/<sfid_dest>`` | [
"Rename",
"a",
"folder",
"or",
"a",
"subfolder",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L500-L512 |
dossier/dossier.web | dossier/web/routes.py | set_query_param | def set_query_param(url, param, value):
'''Returns a new URL with the given query parameter set to ``value``.
``value`` may be a list.'''
scheme, netloc, path, qs, frag = urlparse.urlsplit(url)
params = urlparse.parse_qs(qs)
params[param] = value
qs = urllib.urlencode(params, doseq=True)
re... | python | def set_query_param(url, param, value):
'''Returns a new URL with the given query parameter set to ``value``.
``value`` may be a list.'''
scheme, netloc, path, qs, frag = urlparse.urlsplit(url)
params = urlparse.parse_qs(qs)
params[param] = value
qs = urllib.urlencode(params, doseq=True)
re... | [
"def",
"set_query_param",
"(",
"url",
",",
"param",
",",
"value",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"qs",
",",
"frag",
"=",
"urlparse",
".",
"urlsplit",
"(",
"url",
")",
"params",
"=",
"urlparse",
".",
"parse_qs",
"(",
"qs",
")",
... | Returns a new URL with the given query parameter set to ``value``.
``value`` may be a list. | [
"Returns",
"a",
"new",
"URL",
"with",
"the",
"given",
"query",
"parameter",
"set",
"to",
"value",
"."
] | train | https://github.com/dossier/dossier.web/blob/1cad1cce3c37d3a4e956abc710a2bc1afe16a092/dossier/web/routes.py#L617-L625 |
DoWhileGeek/authentise-services | authentise_services/slice.py | Slice._get_status | def _get_status(self):
"""utility method to get the status of a slicing job resource, but also used to initialize slice
objects by location"""
if self._state in ["processed", "error"]:
return self._state
get_resp = requests.get(self.location, cookies={"session": ... | python | def _get_status(self):
"""utility method to get the status of a slicing job resource, but also used to initialize slice
objects by location"""
if self._state in ["processed", "error"]:
return self._state
get_resp = requests.get(self.location, cookies={"session": ... | [
"def",
"_get_status",
"(",
"self",
")",
":",
"if",
"self",
".",
"_state",
"in",
"[",
"\"processed\"",
",",
"\"error\"",
"]",
":",
"return",
"self",
".",
"_state",
"get_resp",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"location",
",",
"cookies",
"=... | utility method to get the status of a slicing job resource, but also used to initialize slice
objects by location | [
"utility",
"method",
"to",
"get",
"the",
"status",
"of",
"a",
"slicing",
"job",
"resource",
"but",
"also",
"used",
"to",
"initialize",
"slice",
"objects",
"by",
"location"
] | train | https://github.com/DoWhileGeek/authentise-services/blob/ee32bd7f7de15d3fb24c0a6374640d3a1ec8096d/authentise_services/slice.py#L55-L66 |
b3j0f/conf | b3j0f/conf/parser/resolver/core.py | resolver | def resolver(
expr, safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,
besteffort=DEFAULT_BESTEFFORT
):
"""Resolve input expression.
This function is given such as template resolution function. For wrapping
test for example.
:param str expr: configuration expression to resolv... | python | def resolver(
expr, safe=DEFAULT_SAFE, tostr=DEFAULT_TOSTR, scope=DEFAULT_SCOPE,
besteffort=DEFAULT_BESTEFFORT
):
"""Resolve input expression.
This function is given such as template resolution function. For wrapping
test for example.
:param str expr: configuration expression to resolv... | [
"def",
"resolver",
"(",
"expr",
",",
"safe",
"=",
"DEFAULT_SAFE",
",",
"tostr",
"=",
"DEFAULT_TOSTR",
",",
"scope",
"=",
"DEFAULT_SCOPE",
",",
"besteffort",
"=",
"DEFAULT_BESTEFFORT",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | Resolve input expression.
This function is given such as template resolution function. For wrapping
test for example.
:param str expr: configuration expression to resolve.
:param bool safe: if True (default), run safely execution context.
:param bool tostr: format the result.
:param dict scope... | [
"Resolve",
"input",
"expression",
"."
] | train | https://github.com/b3j0f/conf/blob/18dd6d5d6560f9b202793739e2330a2181163511/b3j0f/conf/parser/resolver/core.py#L41-L60 |
eeue56/PyChat.js | pychatjs/server/user_server.py | User._to_json | def _to_json(self):
""" Gets a dict of this object's properties so that it can be used to send a dump to the client """
return dict(( (k, v) for k, v in self.__dict__.iteritems() if k != 'server')) | python | def _to_json(self):
""" Gets a dict of this object's properties so that it can be used to send a dump to the client """
return dict(( (k, v) for k, v in self.__dict__.iteritems() if k != 'server')) | [
"def",
"_to_json",
"(",
"self",
")",
":",
"return",
"dict",
"(",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"__dict__",
".",
"iteritems",
"(",
")",
"if",
"k",
"!=",
"'server'",
")",
")"
] | Gets a dict of this object's properties so that it can be used to send a dump to the client | [
"Gets",
"a",
"dict",
"of",
"this",
"object",
"s",
"properties",
"so",
"that",
"it",
"can",
"be",
"used",
"to",
"send",
"a",
"dump",
"to",
"the",
"client"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/user_server.py#L16-L18 |
eeue56/PyChat.js | pychatjs/server/user_server.py | User.change_name | def change_name(self, username):
""" changes the username to given username, throws exception if username used """
self.release_name()
try:
self.server.register_name(username)
except UsernameInUseException:
logging.log(', '.join(self.server.registered_name... | python | def change_name(self, username):
""" changes the username to given username, throws exception if username used """
self.release_name()
try:
self.server.register_name(username)
except UsernameInUseException:
logging.log(', '.join(self.server.registered_name... | [
"def",
"change_name",
"(",
"self",
",",
"username",
")",
":",
"self",
".",
"release_name",
"(",
")",
"try",
":",
"self",
".",
"server",
".",
"register_name",
"(",
"username",
")",
"except",
"UsernameInUseException",
":",
"logging",
".",
"log",
"(",
"', '",... | changes the username to given username, throws exception if username used | [
"changes",
"the",
"username",
"to",
"given",
"username",
"throws",
"exception",
"if",
"username",
"used"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/user_server.py#L28-L39 |
eeue56/PyChat.js | pychatjs/server/user_server.py | UserServer.register_name | def register_name(self, username):
""" register a name """
if self.is_username_used(username):
raise UsernameInUseException('Username {username} already in use!'.format(username=username))
self.registered_names.append(username) | python | def register_name(self, username):
""" register a name """
if self.is_username_used(username):
raise UsernameInUseException('Username {username} already in use!'.format(username=username))
self.registered_names.append(username) | [
"def",
"register_name",
"(",
"self",
",",
"username",
")",
":",
"if",
"self",
".",
"is_username_used",
"(",
"username",
")",
":",
"raise",
"UsernameInUseException",
"(",
"'Username {username} already in use!'",
".",
"format",
"(",
"username",
"=",
"username",
")",... | register a name | [
"register",
"a",
"name"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/user_server.py#L59-L63 |
eeue56/PyChat.js | pychatjs/server/user_server.py | UserServer.release_name | def release_name(self, username):
""" release a name and add it to the temp list """
self.temp_names.append(username)
if self.is_username_used(username):
self.registered_names.remove(username) | python | def release_name(self, username):
""" release a name and add it to the temp list """
self.temp_names.append(username)
if self.is_username_used(username):
self.registered_names.remove(username) | [
"def",
"release_name",
"(",
"self",
",",
"username",
")",
":",
"self",
".",
"temp_names",
".",
"append",
"(",
"username",
")",
"if",
"self",
".",
"is_username_used",
"(",
"username",
")",
":",
"self",
".",
"registered_names",
".",
"remove",
"(",
"username"... | release a name and add it to the temp list | [
"release",
"a",
"name",
"and",
"add",
"it",
"to",
"the",
"temp",
"list"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/user_server.py#L66-L70 |
Deathnerd/pyterp | pyterp/scripts/cli.py | cli | def cli(filename, direct, language):
# TODO: Flesh this description out
"""
Runs the program
:param language:
:param filename:
:param direct:
:return:
"""
file_extension = filename.split(".")[-1]
if file_extension not in extensions.keys():
error = "{} is not currently sup... | python | def cli(filename, direct, language):
# TODO: Flesh this description out
"""
Runs the program
:param language:
:param filename:
:param direct:
:return:
"""
file_extension = filename.split(".")[-1]
if file_extension not in extensions.keys():
error = "{} is not currently sup... | [
"def",
"cli",
"(",
"filename",
",",
"direct",
",",
"language",
")",
":",
"# TODO: Flesh this description out",
"file_extension",
"=",
"filename",
".",
"split",
"(",
"\".\"",
")",
"[",
"-",
"1",
"]",
"if",
"file_extension",
"not",
"in",
"extensions",
".",
"ke... | Runs the program
:param language:
:param filename:
:param direct:
:return: | [
"Runs",
"the",
"program",
":",
"param",
"language",
":",
":",
"param",
"filename",
":",
":",
"param",
"direct",
":",
":",
"return",
":"
] | train | https://github.com/Deathnerd/pyterp/blob/baf2957263685f03873f368226f5752da4e51f08/pyterp/scripts/cli.py#L12-L35 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._do_exec | def _do_exec(self, cmd, args):
"""Execute a command using subprocess.Popen().
"""
if not args:
self.stderr.write("execute: empty command\n")
return
proc = subprocess.Popen(subprocess.list2cmdline(args),
shell = True, stdout = self.stdout)
p... | python | def _do_exec(self, cmd, args):
"""Execute a command using subprocess.Popen().
"""
if not args:
self.stderr.write("execute: empty command\n")
return
proc = subprocess.Popen(subprocess.list2cmdline(args),
shell = True, stdout = self.stdout)
p... | [
"def",
"_do_exec",
"(",
"self",
",",
"cmd",
",",
"args",
")",
":",
"if",
"not",
"args",
":",
"self",
".",
"stderr",
".",
"write",
"(",
"\"execute: empty command\\n\"",
")",
"return",
"proc",
"=",
"subprocess",
".",
"Popen",
"(",
"subprocess",
".",
"list2... | Execute a command using subprocess.Popen(). | [
"Execute",
"a",
"command",
"using",
"subprocess",
".",
"Popen",
"()",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L16-L24 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._do_exit | def _do_exit(self, cmd, args):
"""\
Exit shell.
exit | C-D Exit to the parent shell.
exit root | end Exit to the root shell.
exit all Exit to the command line.
"""
if cmd == 'end':
if not args:
return... | python | def _do_exit(self, cmd, args):
"""\
Exit shell.
exit | C-D Exit to the parent shell.
exit root | end Exit to the root shell.
exit all Exit to the command line.
"""
if cmd == 'end':
if not args:
return... | [
"def",
"_do_exit",
"(",
"self",
",",
"cmd",
",",
"args",
")",
":",
"if",
"cmd",
"==",
"'end'",
":",
"if",
"not",
"args",
":",
"return",
"'root'",
"else",
":",
"self",
".",
"stderr",
".",
"write",
"(",
"textwrap",
".",
"dedent",
"(",
"'''\\\n ... | \
Exit shell.
exit | C-D Exit to the parent shell.
exit root | end Exit to the root shell.
exit all Exit to the command line. | [
"\\",
"Exit",
"shell",
".",
"exit",
"|",
"C",
"-",
"D",
"Exit",
"to",
"the",
"parent",
"shell",
".",
"exit",
"root",
"|",
"end",
"Exit",
"to",
"the",
"root",
"shell",
".",
"exit",
"all",
"Exit",
"to",
"the",
"command",
"line",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L27-L56 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._complete_exit | def _complete_exit(self, cmd, args, text):
"""Find candidates for the 'exit' command."""
if args:
return
return [ x for x in { 'root', 'all', } \
if x.startswith(text) ] | python | def _complete_exit(self, cmd, args, text):
"""Find candidates for the 'exit' command."""
if args:
return
return [ x for x in { 'root', 'all', } \
if x.startswith(text) ] | [
"def",
"_complete_exit",
"(",
"self",
",",
"cmd",
",",
"args",
",",
"text",
")",
":",
"if",
"args",
":",
"return",
"return",
"[",
"x",
"for",
"x",
"in",
"{",
"'root'",
",",
"'all'",
",",
"}",
"if",
"x",
".",
"startswith",
"(",
"text",
")",
"]"
] | Find candidates for the 'exit' command. | [
"Find",
"candidates",
"for",
"the",
"exit",
"command",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L59-L64 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._do_history | def _do_history(self, cmd, args):
"""\
Display history.
history Display history.
history clear Clear history.
history clearall Clear history for all shells.
"""
if args and args[0] == 'clear':
readline.clear_history()
... | python | def _do_history(self, cmd, args):
"""\
Display history.
history Display history.
history clear Clear history.
history clearall Clear history for all shells.
"""
if args and args[0] == 'clear':
readline.clear_history()
... | [
"def",
"_do_history",
"(",
"self",
",",
"cmd",
",",
"args",
")",
":",
"if",
"args",
"and",
"args",
"[",
"0",
"]",
"==",
"'clear'",
":",
"readline",
".",
"clear_history",
"(",
")",
"readline",
".",
"write_history_file",
"(",
"self",
".",
"history_fname",
... | \
Display history.
history Display history.
history clear Clear history.
history clearall Clear history for all shells. | [
"\\",
"Display",
"history",
".",
"history",
"Display",
"history",
".",
"history",
"clear",
"Clear",
"history",
".",
"history",
"clearall",
"Clear",
"history",
"for",
"all",
"shells",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L67-L84 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._complete_history | def _complete_history(self, cmd, args, text):
"""Find candidates for the 'history' command."""
if args:
return
return [ x for x in { 'clear', 'clearall' } \
if x.startswith(text) ] | python | def _complete_history(self, cmd, args, text):
"""Find candidates for the 'history' command."""
if args:
return
return [ x for x in { 'clear', 'clearall' } \
if x.startswith(text) ] | [
"def",
"_complete_history",
"(",
"self",
",",
"cmd",
",",
"args",
",",
"text",
")",
":",
"if",
"args",
":",
"return",
"return",
"[",
"x",
"for",
"x",
"in",
"{",
"'clear'",
",",
"'clearall'",
"}",
"if",
"x",
".",
"startswith",
"(",
"text",
")",
"]"
... | Find candidates for the 'history' command. | [
"Find",
"candidates",
"for",
"the",
"history",
"command",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L87-L92 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._do_stack | def _do_stack(self, cmd, args):
"""\
Manage the shell stack.
stack Display the stack.
stack <depth> Exit to the stack by its depth.
"""
if not args:
self.__dump_stack()
return
if len(args) > 1:
self.s... | python | def _do_stack(self, cmd, args):
"""\
Manage the shell stack.
stack Display the stack.
stack <depth> Exit to the stack by its depth.
"""
if not args:
self.__dump_stack()
return
if len(args) > 1:
self.s... | [
"def",
"_do_stack",
"(",
"self",
",",
"cmd",
",",
"args",
")",
":",
"if",
"not",
"args",
":",
"self",
".",
"__dump_stack",
"(",
")",
"return",
"if",
"len",
"(",
"args",
")",
">",
"1",
":",
"self",
".",
"stderr",
".",
"write",
"(",
"'stack: too many... | \
Manage the shell stack.
stack Display the stack.
stack <depth> Exit to the stack by its depth. | [
"\\",
"Manage",
"the",
"shell",
"stack",
".",
"stack",
"Display",
"the",
"stack",
".",
"stack",
"<depth",
">",
"Exit",
"to",
"the",
"stack",
"by",
"its",
"depth",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L95-L115 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell.__dump_stack | def __dump_stack(self):
"""Dump the shell stack in a human friendly way.
An example output is:
0 PlayBoy
1 └── foo-prompt: foo@[]
2 └── karPROMPT: kar@[]
3 └── DEBUG: debug@['shell']
"""
maxdepth = l... | python | def __dump_stack(self):
"""Dump the shell stack in a human friendly way.
An example output is:
0 PlayBoy
1 └── foo-prompt: foo@[]
2 └── karPROMPT: kar@[]
3 └── DEBUG: debug@['shell']
"""
maxdepth = l... | [
"def",
"__dump_stack",
"(",
"self",
")",
":",
"maxdepth",
"=",
"len",
"(",
"self",
".",
"_mode_stack",
")",
"maxdepth_strlen",
"=",
"len",
"(",
"str",
"(",
"maxdepth",
")",
")",
"index_width",
"=",
"4",
"-",
"(",
"-",
"maxdepth_strlen",
")",
"%",
"4",
... | Dump the shell stack in a human friendly way.
An example output is:
0 PlayBoy
1 └── foo-prompt: foo@[]
2 └── karPROMPT: kar@[]
3 └── DEBUG: debug@['shell'] | [
"Dump",
"the",
"shell",
"stack",
"in",
"a",
"human",
"friendly",
"way",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L122-L148 |
qzmfranklin/easyshell | easyshell/basic_shell.py | BasicShell._do_help | def _do_help(self, cmd, args):
"""Display doc strings of the shell and its commands.
"""
print(self.doc_string())
print()
# Create data of the commands table.
data_unsorted = []
cls = self.__class__
for name in dir(cls):
obj = getattr(cls, nam... | python | def _do_help(self, cmd, args):
"""Display doc strings of the shell and its commands.
"""
print(self.doc_string())
print()
# Create data of the commands table.
data_unsorted = []
cls = self.__class__
for name in dir(cls):
obj = getattr(cls, nam... | [
"def",
"_do_help",
"(",
"self",
",",
"cmd",
",",
"args",
")",
":",
"print",
"(",
"self",
".",
"doc_string",
"(",
")",
")",
"print",
"(",
")",
"# Create data of the commands table.",
"data_unsorted",
"=",
"[",
"]",
"cls",
"=",
"self",
".",
"__class__",
"f... | Display doc strings of the shell and its commands. | [
"Display",
"doc",
"strings",
"of",
"the",
"shell",
"and",
"its",
"commands",
"."
] | train | https://github.com/qzmfranklin/easyshell/blob/00c2e90e7767d32e7e127fc8c6875845aa308295/easyshell/basic_shell.py#L151-L178 |
tschaume/ccsgp_get_started | ccsgp_get_started/examples/gp_rdiff.py | gp_rdiff | def gp_rdiff(version, nomed, noxerr, diffRel, divdNdy):
"""example for ratio or difference plots using QM12 data (see gp_panel)
- uses uncertainties package for easier error propagation and rebinning
- stat. error for medium = 0!
- stat. error for cocktail ~ 0!
- statistical error bar on data stays the same ... | python | def gp_rdiff(version, nomed, noxerr, diffRel, divdNdy):
"""example for ratio or difference plots using QM12 data (see gp_panel)
- uses uncertainties package for easier error propagation and rebinning
- stat. error for medium = 0!
- stat. error for cocktail ~ 0!
- statistical error bar on data stays the same ... | [
"def",
"gp_rdiff",
"(",
"version",
",",
"nomed",
",",
"noxerr",
",",
"diffRel",
",",
"divdNdy",
")",
":",
"inDir",
",",
"outDir",
"=",
"getWorkDirs",
"(",
")",
"inDir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"inDir",
",",
"version",
")",
"data",
... | example for ratio or difference plots using QM12 data (see gp_panel)
- uses uncertainties package for easier error propagation and rebinning
- stat. error for medium = 0!
- stat. error for cocktail ~ 0!
- statistical error bar on data stays the same for diff
- TODO: implement ratio!
- TODO: adjust statisti... | [
"example",
"for",
"ratio",
"or",
"difference",
"plots",
"using",
"QM12",
"data",
"(",
"see",
"gp_panel",
")"
] | train | https://github.com/tschaume/ccsgp_get_started/blob/e4e29844a3e6fc7574e9b4b8cd84131f28ddc3f2/ccsgp_get_started/examples/gp_rdiff.py#L17-L491 |
MacHu-GWU/windtalker-project | windtalker/fingerprint.py | FingerPrint.of_bytes | def of_bytes(self, py_bytes):
"""Use default hash method to return hash value of bytes.
"""
m = self.hash_algo()
m.update(py_bytes)
if self.return_int:
return int(m.hexdigest(), 16)
else:
return m.hexdigest() | python | def of_bytes(self, py_bytes):
"""Use default hash method to return hash value of bytes.
"""
m = self.hash_algo()
m.update(py_bytes)
if self.return_int:
return int(m.hexdigest(), 16)
else:
return m.hexdigest() | [
"def",
"of_bytes",
"(",
"self",
",",
"py_bytes",
")",
":",
"m",
"=",
"self",
".",
"hash_algo",
"(",
")",
"m",
".",
"update",
"(",
"py_bytes",
")",
"if",
"self",
".",
"return_int",
":",
"return",
"int",
"(",
"m",
".",
"hexdigest",
"(",
")",
",",
"... | Use default hash method to return hash value of bytes. | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"bytes",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/fingerprint.py#L103-L111 |
MacHu-GWU/windtalker-project | windtalker/fingerprint.py | FingerPrint.of_text | def of_text(self, text, encoding="utf-8"):
"""Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding.
"""
m = self.hash_algo()
m.update(text.encode(encoding))
if self.return_int:
return int(m.hexdigest(), 16)
... | python | def of_text(self, text, encoding="utf-8"):
"""Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding.
"""
m = self.hash_algo()
m.update(text.encode(encoding))
if self.return_int:
return int(m.hexdigest(), 16)
... | [
"def",
"of_text",
"(",
"self",
",",
"text",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"m",
"=",
"self",
".",
"hash_algo",
"(",
")",
"m",
".",
"update",
"(",
"text",
".",
"encode",
"(",
"encoding",
")",
")",
"if",
"self",
".",
"return_int",
":",
... | Use default hash method to return hash value of a piece of string
default setting use 'utf-8' encoding. | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"a",
"piece",
"of",
"string",
"default",
"setting",
"use",
"utf",
"-",
"8",
"encoding",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/fingerprint.py#L113-L122 |
MacHu-GWU/windtalker-project | windtalker/fingerprint.py | FingerPrint.of_pyobj | def of_pyobj(self, pyobj):
"""Use default hash method to return hash value of a piece of Python
picklable object.
"""
m = self.hash_algo()
m.update(pickle.dumps(pyobj, protocol=self.pk_protocol))
if self.return_int:
return int(m.hexdigest(), 16)
else:
... | python | def of_pyobj(self, pyobj):
"""Use default hash method to return hash value of a piece of Python
picklable object.
"""
m = self.hash_algo()
m.update(pickle.dumps(pyobj, protocol=self.pk_protocol))
if self.return_int:
return int(m.hexdigest(), 16)
else:
... | [
"def",
"of_pyobj",
"(",
"self",
",",
"pyobj",
")",
":",
"m",
"=",
"self",
".",
"hash_algo",
"(",
")",
"m",
".",
"update",
"(",
"pickle",
".",
"dumps",
"(",
"pyobj",
",",
"protocol",
"=",
"self",
".",
"pk_protocol",
")",
")",
"if",
"self",
".",
"r... | Use default hash method to return hash value of a piece of Python
picklable object. | [
"Use",
"default",
"hash",
"method",
"to",
"return",
"hash",
"value",
"of",
"a",
"piece",
"of",
"Python",
"picklable",
"object",
"."
] | train | https://github.com/MacHu-GWU/windtalker-project/blob/1dcff7c3692d5883cf1b55d1ea745723cfc6c3ce/windtalker/fingerprint.py#L124-L133 |
thespacedoctor/qubits | qubits/datagenerator.py | generate_model_lightcurves | def generate_model_lightcurves(
log,
pathToSpectralDatabase,
pathToOutputDirectory,
pathToOutputPlotDirectory,
explosionDaysFromSettings,
extendLightCurveTail,
polyOrder
):
"""
*Generate the lightcurve plots and polynomials by extracting the data from the ... | python | def generate_model_lightcurves(
log,
pathToSpectralDatabase,
pathToOutputDirectory,
pathToOutputPlotDirectory,
explosionDaysFromSettings,
extendLightCurveTail,
polyOrder
):
"""
*Generate the lightcurve plots and polynomials by extracting the data from the ... | [
"def",
"generate_model_lightcurves",
"(",
"log",
",",
"pathToSpectralDatabase",
",",
"pathToOutputDirectory",
",",
"pathToOutputPlotDirectory",
",",
"explosionDaysFromSettings",
",",
"extendLightCurveTail",
",",
"polyOrder",
")",
":",
"################ > IMPORTS ################"... | *Generate the lightcurve plots and polynomials by extracting the data from the provided spectra.*
**Key Arguments:**
- ``log`` -- logger
- ``pathToSpectralDatabase`` -- path to the nested-folders and files spectral database (provided by the user)
- ``pathToOutputDirectory`` -- path to the o... | [
"*",
"Generate",
"the",
"lightcurve",
"plots",
"and",
"polynomials",
"by",
"extracting",
"the",
"data",
"from",
"the",
"provided",
"spectra",
".",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L34-L189 |
thespacedoctor/qubits | qubits/datagenerator.py | extract_spectra_from_file | def extract_spectra_from_file(
log,
pathToSpectrum,
convertLumToFlux=False):
"""
*Given a spectrum file this function shall convert the two columns (wavelength and luminosity) to a wavelegnth (wavelengthArray) and flux (fluxArray) array*
**Key Arguments:**
- ``log`` -- logge... | python | def extract_spectra_from_file(
log,
pathToSpectrum,
convertLumToFlux=False):
"""
*Given a spectrum file this function shall convert the two columns (wavelength and luminosity) to a wavelegnth (wavelengthArray) and flux (fluxArray) array*
**Key Arguments:**
- ``log`` -- logge... | [
"def",
"extract_spectra_from_file",
"(",
"log",
",",
"pathToSpectrum",
",",
"convertLumToFlux",
"=",
"False",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"import",
"os",
"## THIRD PARTY ##",
"import",
"numpy",
"as",
"np",
"## LOCAL APPLICA... | *Given a spectrum file this function shall convert the two columns (wavelength and luminosity) to a wavelegnth (wavelengthArray) and flux (fluxArray) array*
**Key Arguments:**
- ``log`` -- logger
- ``pathToSpectrum`` -- absolute path the the spectrum file
**Return:**
- None | [
"*",
"Given",
"a",
"spectrum",
"file",
"this",
"function",
"shall",
"convert",
"the",
"two",
"columns",
"(",
"wavelength",
"and",
"luminosity",
")",
"to",
"a",
"wavelegnth",
"(",
"wavelengthArray",
")",
"and",
"flux",
"(",
"fluxArray",
")",
"array",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L195-L239 |
thespacedoctor/qubits | qubits/datagenerator.py | plot_filter_transmissions | def plot_filter_transmissions(log, filterList):
"""
*Plot the filters on a single plot*
**Key Arguments:**
- ``log`` -- logger
- ``filterList`` -- list of absolute paths to plain text files containing filter transmission profiles
**Return:**
- None
"""
################ ... | python | def plot_filter_transmissions(log, filterList):
"""
*Plot the filters on a single plot*
**Key Arguments:**
- ``log`` -- logger
- ``filterList`` -- list of absolute paths to plain text files containing filter transmission profiles
**Return:**
- None
"""
################ ... | [
"def",
"plot_filter_transmissions",
"(",
"log",
",",
"filterList",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"## THIRD PARTY ##",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"numpy",
"as",
"np",
"## LOCAL APPLICATION ##... | *Plot the filters on a single plot*
**Key Arguments:**
- ``log`` -- logger
- ``filterList`` -- list of absolute paths to plain text files containing filter transmission profiles
**Return:**
- None | [
"*",
"Plot",
"the",
"filters",
"on",
"a",
"single",
"plot",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L245-L270 |
thespacedoctor/qubits | qubits/datagenerator.py | calcphot | def calcphot(log, wavelengthArray, fluxArray, obsmode, extrapolate=False):
"""
*Run calcphot on single spectrum and filter.*
**Key Arguments:**
- ``log`` -- logger
- ``wavelengthArray`` -- the array containing the wavelength range of the spectrum
- ``fluxArray`` -- the array contain... | python | def calcphot(log, wavelengthArray, fluxArray, obsmode, extrapolate=False):
"""
*Run calcphot on single spectrum and filter.*
**Key Arguments:**
- ``log`` -- logger
- ``wavelengthArray`` -- the array containing the wavelength range of the spectrum
- ``fluxArray`` -- the array contain... | [
"def",
"calcphot",
"(",
"log",
",",
"wavelengthArray",
",",
"fluxArray",
",",
"obsmode",
",",
"extrapolate",
"=",
"False",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"## THIRD PARTY ##",
"import",
"pysynphot",
"as",
"syn",
"## LOCAL A... | *Run calcphot on single spectrum and filter.*
**Key Arguments:**
- ``log`` -- logger
- ``wavelengthArray`` -- the array containing the wavelength range of the spectrum
- ``fluxArray`` -- the array contain the respective spectrum flux (as function of wavelength)
- ``obsmode`` -- the ... | [
"*",
"Run",
"calcphot",
"on",
"single",
"spectrum",
"and",
"filter",
".",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L277-L310 |
thespacedoctor/qubits | qubits/datagenerator.py | plotLightCurves | def plotLightCurves(
log,
lightCurves,
polyOrder,
pathToOutputDirectory):
"""
*plot lightcurve(s) given an list of magnitude, time pairs*
**Key Arguments:**
- ``log`` -- logger
- ``lightCurves`` -- list of magnitude, time numPy arrays
- ``polyOrder`` ... | python | def plotLightCurves(
log,
lightCurves,
polyOrder,
pathToOutputDirectory):
"""
*plot lightcurve(s) given an list of magnitude, time pairs*
**Key Arguments:**
- ``log`` -- logger
- ``lightCurves`` -- list of magnitude, time numPy arrays
- ``polyOrder`` ... | [
"def",
"plotLightCurves",
"(",
"log",
",",
"lightCurves",
",",
"polyOrder",
",",
"pathToOutputDirectory",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"## THIRD PARTY ##",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"import",
"num... | *plot lightcurve(s) given an list of magnitude, time pairs*
**Key Arguments:**
- ``log`` -- logger
- ``lightCurves`` -- list of magnitude, time numPy arrays
- ``polyOrder`` -- order of polynomial used to fit the model lightcurves extracted from spectra
- ``pathToOutputDirectory`` --... | [
"*",
"plot",
"lightcurve",
"(",
"s",
")",
"given",
"an",
"list",
"of",
"magnitude",
"time",
"pairs",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L316-L391 |
thespacedoctor/qubits | qubits/datagenerator.py | extract_lightcurve | def extract_lightcurve(
log,
spectrumFiles,
userExplosionDay,
extendLightCurveTail,
obsmode):
"""
*Extract the requested lightcurve from list of spectrum files*
**Key Arguments:**
- ``log`` -- logger
- ``spectrumFiles`` -- list of the spectrum files
... | python | def extract_lightcurve(
log,
spectrumFiles,
userExplosionDay,
extendLightCurveTail,
obsmode):
"""
*Extract the requested lightcurve from list of spectrum files*
**Key Arguments:**
- ``log`` -- logger
- ``spectrumFiles`` -- list of the spectrum files
... | [
"def",
"extract_lightcurve",
"(",
"log",
",",
"spectrumFiles",
",",
"userExplosionDay",
",",
"extendLightCurveTail",
",",
"obsmode",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"import",
"re",
"## THIRD PARTY ##",
"import",
"numpy",
"as",
... | *Extract the requested lightcurve from list of spectrum files*
**Key Arguments:**
- ``log`` -- logger
- ``spectrumFiles`` -- list of the spectrum files
- ``userExplosionDay`` -- explosion day for transient as set by the user in the settings file
- ``extendLightCurveTail`` -- extend ... | [
"*",
"Extract",
"the",
"requested",
"lightcurve",
"from",
"list",
"of",
"spectrum",
"files",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L397-L525 |
thespacedoctor/qubits | qubits/datagenerator.py | find_peak_magnitude | def find_peak_magnitude(
log,
poly,
model,
start,
end):
"""
*Determine peakMag and time from an initial polynomial lightcurve*
**Key Arguments:**
- ``log`` -- logger
- ``poly`` -- initial polynomial lightcurve
- ``model`` -- the transient bein... | python | def find_peak_magnitude(
log,
poly,
model,
start,
end):
"""
*Determine peakMag and time from an initial polynomial lightcurve*
**Key Arguments:**
- ``log`` -- logger
- ``poly`` -- initial polynomial lightcurve
- ``model`` -- the transient bein... | [
"def",
"find_peak_magnitude",
"(",
"log",
",",
"poly",
",",
"model",
",",
"start",
",",
"end",
")",
":",
"################ > IMPORTS ################",
"## STANDARD LIB ##",
"## THIRD PARTY ##",
"import",
"numpy",
"as",
"np",
"## LOCAL APPLICATION ##",
"################ >... | *Determine peakMag and time from an initial polynomial lightcurve*
**Key Arguments:**
- ``log`` -- logger
- ``poly`` -- initial polynomial lightcurve
- ``model`` -- the transient being considered
- ``start`` -- lower time bound of spectrum
- ``end`` -- upper time bound of sp... | [
"*",
"Determine",
"peakMag",
"and",
"time",
"from",
"an",
"initial",
"polynomial",
"lightcurve",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L531-L591 |
thespacedoctor/qubits | qubits/datagenerator.py | generate_kcorrection_listing_database | def generate_kcorrection_listing_database(
log,
restFrameFilter,
pathToOutputDirectory,
pathToSpectralDatabase,
temporalResolution=4.0,
redshiftResolution=0.1,
redshiftLower=0.0,
redshiftUpper=1.0):
"""
*Generate the Kg* k-corrections for a range o... | python | def generate_kcorrection_listing_database(
log,
restFrameFilter,
pathToOutputDirectory,
pathToSpectralDatabase,
temporalResolution=4.0,
redshiftResolution=0.1,
redshiftLower=0.0,
redshiftUpper=1.0):
"""
*Generate the Kg* k-corrections for a range o... | [
"def",
"generate_kcorrection_listing_database",
"(",
"log",
",",
"restFrameFilter",
",",
"pathToOutputDirectory",
",",
"pathToSpectralDatabase",
",",
"temporalResolution",
"=",
"4.0",
",",
"redshiftResolution",
"=",
"0.1",
",",
"redshiftLower",
"=",
"0.0",
",",
"redshif... | *Generate the Kg* k-corrections for a range of redshifts given a list of spectra*
**Key Arguments:**
- ``log`` -- logger
- ``restFrameFilter`` -- the filter to generate the K-corrections against
- ``pathToOutputDirectory`` -- path to the output directory (provided by the user)
- ``p... | [
"*",
"Generate",
"the",
"Kg",
"*",
"k",
"-",
"corrections",
"for",
"a",
"range",
"of",
"redshifts",
"given",
"a",
"list",
"of",
"spectra",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L598-L661 |
thespacedoctor/qubits | qubits/datagenerator.py | generate_single_kcorrection_listing | def generate_single_kcorrection_listing(
log,
pathToOutputDirectory,
pathToSpectralDatabase,
model,
restFrameFilter,
redshift,
temporalResolution=4.0):
"""
*Given a redshift generate a dictionary of k-correction polynomials for the MCS.*
**Key Argumen... | python | def generate_single_kcorrection_listing(
log,
pathToOutputDirectory,
pathToSpectralDatabase,
model,
restFrameFilter,
redshift,
temporalResolution=4.0):
"""
*Given a redshift generate a dictionary of k-correction polynomials for the MCS.*
**Key Argumen... | [
"def",
"generate_single_kcorrection_listing",
"(",
"log",
",",
"pathToOutputDirectory",
",",
"pathToSpectralDatabase",
",",
"model",
",",
"restFrameFilter",
",",
"redshift",
",",
"temporalResolution",
"=",
"4.0",
")",
":",
"################ > IMPORTS ################",
"## ... | *Given a redshift generate a dictionary of k-correction polynomials for the MCS.*
**Key Arguments:**
- ``log`` -- logger
- ``pathToOutputDirectory`` -- path to the output directory (provided by the user)
- ``pathToSpectralDatabase`` -- path to the directory containing the spectral database
... | [
"*",
"Given",
"a",
"redshift",
"generate",
"a",
"dictionary",
"of",
"k",
"-",
"correction",
"polynomials",
"for",
"the",
"MCS",
".",
"*"
] | train | https://github.com/thespacedoctor/qubits/blob/3c02ace7226389841c6bb838d045c11bed61a3c2/qubits/datagenerator.py#L667-L869 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.