hexsha
stringlengths
40
40
repo
stringlengths
7
114
path
stringlengths
4
124
license
listlengths
1
9
language
stringclasses
1 value
identifier
stringlengths
1
71
return_type
stringlengths
1
749
original_string
stringlengths
76
22.7k
original_docstring
stringlengths
16
7.61k
docstring
stringlengths
16
2.47k
docstring_tokens
listlengths
6
477
code
stringlengths
14
10.2k
code_tokens
listlengths
6
996
short_docstring
stringlengths
2
644
short_docstring_tokens
listlengths
1
116
comment
listlengths
1
89
parameters
listlengths
0
64
docstring_params
dict
afdf1d513ec7d49ebe9b649c6f83a84147d0805b
jeremiahwander/sample-metadata
models/models/sequence.py
[ "MIT" ]
Python
from_db
<not_specific>
def from_db(d: Dict): """Take DB mapping object, and return SampleSequencing""" type_ = d.pop('type') status = d.pop('status') meta = d.pop('meta', None) if type_: type_ = SequenceType(type_) if status: status = SequenceStatus(status) if ...
Take DB mapping object, and return SampleSequencing
Take DB mapping object, and return SampleSequencing
[ "Take", "DB", "mapping", "object", "and", "return", "SampleSequencing" ]
def from_db(d: Dict): type_ = d.pop('type') status = d.pop('status') meta = d.pop('meta', None) if type_: type_ = SequenceType(type_) if status: status = SequenceStatus(status) if meta: if isinstance(meta, bytes): meta =...
[ "def", "from_db", "(", "d", ":", "Dict", ")", ":", "type_", "=", "d", ".", "pop", "(", "'type'", ")", "status", "=", "d", ".", "pop", "(", "'status'", ")", "meta", "=", "d", ".", "pop", "(", "'meta'", ",", "None", ")", "if", "type_", ":", "ty...
Take DB mapping object, and return SampleSequencing
[ "Take", "DB", "mapping", "object", "and", "return", "SampleSequencing" ]
[ "\"\"\"Take DB mapping object, and return SampleSequencing\"\"\"" ]
[ { "param": "d", "type": "Dict" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "d", "type": "Dict", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
6c867ba7aefcd3c0f9d83b942898af98abbbe65f
jeremiahwander/sample-metadata
test/test_joint_calling_workflow.py
[ "MIT" ]
Python
_add_samples
<not_specific>
def _add_samples(test_run_id: str, project: str): """ Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input. :param test_run_id: to suffix sample names for uniqueness """ s1 = NewSample( external_id=f'NA12878-from-fq-{test_run_id}', type=SampleType('blood'), ...
Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input. :param test_run_id: to suffix sample names for uniqueness
Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input.
[ "Add", "3", "samples", ":", "one", "with", "fastq", "input", "one", "with", "CRAM", "input", "one", "with", "GVCF", "input", "." ]
def _add_samples(test_run_id: str, project: str): s1 = NewSample( external_id=f'NA12878-from-fq-{test_run_id}', type=SampleType('blood'), meta={ 'reads': [ [ 'gs://cpg-seqr-test/batches/NA12878-trio-tiny/NA12878_L001_R1.fq', ...
[ "def", "_add_samples", "(", "test_run_id", ":", "str", ",", "project", ":", "str", ")", ":", "s1", "=", "NewSample", "(", "external_id", "=", "f'NA12878-from-fq-{test_run_id}'", ",", "type", "=", "SampleType", "(", "'blood'", ")", ",", "meta", "=", "{", "'...
Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input.
[ "Add", "3", "samples", ":", "one", "with", "fastq", "input", "one", "with", "CRAM", "input", "one", "with", "GVCF", "input", "." ]
[ "\"\"\"\n Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input.\n :param test_run_id: to suffix sample names for uniqueness\n \"\"\"" ]
[ { "param": "test_run_id", "type": "str" }, { "param": "project", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "test_run_id", "type": "str", "docstring": "to suffix sample names for uniqueness", "docstring_tokens": [ "to", "suffix", "sample", "names", "for", "uniqueness" ], "de...
6c867ba7aefcd3c0f9d83b942898af98abbbe65f
jeremiahwander/sample-metadata
test/test_joint_calling_workflow.py
[ "MIT" ]
Python
_submit_analyses
null
def _submit_analyses(samples: List, output_project: str, a_type: str): """ Add or update analyses. Iterate over completed analyses, and submit next-step analyses """ if a_type in ['gvcf', 'cram']: for s in samples: if a_type == 'gvcf': cram_analysis = aapi.get_la...
Add or update analyses. Iterate over completed analyses, and submit next-step analyses
Add or update analyses. Iterate over completed analyses, and submit next-step analyses
[ "Add", "or", "update", "analyses", ".", "Iterate", "over", "completed", "analyses", "and", "submit", "next", "-", "step", "analyses" ]
def _submit_analyses(samples: List, output_project: str, a_type: str): if a_type in ['gvcf', 'cram']: for s in samples: if a_type == 'gvcf': cram_analysis = aapi.get_latest_analysis_for_samples_and_type( project=output_project, analysis_typ...
[ "def", "_submit_analyses", "(", "samples", ":", "List", ",", "output_project", ":", "str", ",", "a_type", ":", "str", ")", ":", "if", "a_type", "in", "[", "'gvcf'", ",", "'cram'", "]", ":", "for", "s", "in", "samples", ":", "if", "a_type", "==", "'gv...
Add or update analyses.
[ "Add", "or", "update", "analyses", "." ]
[ "\"\"\"\n Add or update analyses. Iterate over completed analyses,\n and submit next-step analyses\n \"\"\"", "# completed_analysis = latest_by_type_and_sids.get(('cram', (s['id'],)))," ]
[ { "param": "samples", "type": "List" }, { "param": "output_project", "type": "str" }, { "param": "a_type", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "samples", "type": "List", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "output_project", "type": "str", "docstring": null, "docs...
c418ef6cd60b254af636ac049a8378fca2261c40
jeremiahwander/sample-metadata
api/utils/exceptions.py
[ "MIT" ]
Python
determine_code_from_error
<not_specific>
def determine_code_from_error(e): """From error / exception, determine appropriate http code""" if isinstance(e, NotFoundError): return 404 if isinstance(e, ValueError): # HTTP Bad Request return 400 if isinstance(e, Forbidden): return 403 if isinstance(e, NotImplemen...
From error / exception, determine appropriate http code
From error / exception, determine appropriate http code
[ "From", "error", "/", "exception", "determine", "appropriate", "http", "code" ]
def determine_code_from_error(e): if isinstance(e, NotFoundError): return 404 if isinstance(e, ValueError): return 400 if isinstance(e, Forbidden): return 403 if isinstance(e, NotImplementedError): return 501 return 500
[ "def", "determine_code_from_error", "(", "e", ")", ":", "if", "isinstance", "(", "e", ",", "NotFoundError", ")", ":", "return", "404", "if", "isinstance", "(", "e", ",", "ValueError", ")", ":", "return", "400", "if", "isinstance", "(", "e", ",", "Forbidd...
From error / exception, determine appropriate http code
[ "From", "error", "/", "exception", "determine", "appropriate", "http", "code" ]
[ "\"\"\"From error / exception, determine appropriate http code\"\"\"", "# HTTP Bad Request" ]
[ { "param": "e", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "e", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9bc413c9c84751a1697097d23aaa6125205faba8
jeremiahwander/sample-metadata
db/backup/backup.py
[ "MIT" ]
Python
perform_backup
<not_specific>
def perform_backup(): """Completes a backup of the databases within a local mariadb instance and uploads this backup to GCS.""" # Logging: Any log with `severity >= ERROR` get's logged to #software-alerts logging_client = logging.Client() log_name = 'backup_log' logger = logging_client.logger(l...
Completes a backup of the databases within a local mariadb instance and uploads this backup to GCS.
Completes a backup of the databases within a local mariadb instance and uploads this backup to GCS.
[ "Completes", "a", "backup", "of", "the", "databases", "within", "a", "local", "mariadb", "instance", "and", "uploads", "this", "backup", "to", "GCS", "." ]
def perform_backup(): logging_client = logging.Client() log_name = 'backup_log' logger = logging_client.logger(log_name) utc_now = pytz.utc.localize(datetime.utcnow()) timestamp_str = utc_now.strftime('%d_%m_%Y_%H-%M-%S') tmp_dir = f'backup_{timestamp_str}' try: subprocess.run( ...
[ "def", "perform_backup", "(", ")", ":", "logging_client", "=", "logging", ".", "Client", "(", ")", "log_name", "=", "'backup_log'", "logger", "=", "logging_client", ".", "logger", "(", "log_name", ")", "utc_now", "=", "pytz", ".", "utc", ".", "localize", "...
Completes a backup of the databases within a local mariadb instance and uploads this backup to GCS.
[ "Completes", "a", "backup", "of", "the", "databases", "within", "a", "local", "mariadb", "instance", "and", "uploads", "this", "backup", "to", "GCS", "." ]
[ "\"\"\"Completes a backup of the databases within a local mariadb instance\n and uploads this backup to GCS.\"\"\"", "# Logging: Any log with `severity >= ERROR` get's logged to #software-alerts", "# Get timestamp", "# Export SQL Data", "# mariabackup creates awkward permissions for the output files,", ...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
dcf4c600a84d616ff40e11b299f4981e597f4814
jeremiahwander/sample-metadata
api/utils/db.py
[ "MIT" ]
Python
authenticate
Optional[str]
def authenticate( token: Optional[HTTPAuthorizationCredentials] = Depends(auth), ) -> Optional[str]: """If a token is provided, return the email, else return None""" if token: return email_from_id_token(token.credentials) return None
If a token is provided, return the email, else return None
If a token is provided, return the email, else return None
[ "If", "a", "token", "is", "provided", "return", "the", "email", "else", "return", "None" ]
def authenticate( token: Optional[HTTPAuthorizationCredentials] = Depends(auth), ) -> Optional[str]: if token: return email_from_id_token(token.credentials) return None
[ "def", "authenticate", "(", "token", ":", "Optional", "[", "HTTPAuthorizationCredentials", "]", "=", "Depends", "(", "auth", ")", ",", ")", "->", "Optional", "[", "str", "]", ":", "if", "token", ":", "return", "email_from_id_token", "(", "token", ".", "cre...
If a token is provided, return the email, else return None
[ "If", "a", "token", "is", "provided", "return", "the", "email", "else", "return", "None" ]
[ "\"\"\"If a token is provided, return the email, else return None\"\"\"" ]
[ { "param": "token", "type": "Optional[HTTPAuthorizationCredentials]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "token", "type": "Optional[HTTPAuthorizationCredentials]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5af71b8d36975d5ce07147b2e6cb1adb702eebee
jeremiahwander/sample-metadata
db/python/tables/project.py
[ "MIT" ]
Python
_read_secret
<not_specific>
def _read_secret(self, project_id: str, secret_name: str): """Reads the latest version of a GCP Secret Manager secret. Returns None if the secret doesn't exist.""" secret_manager = self._get_secret_manager_client() secret_path = secret_manager.secret_path(project_id, secret_name) ...
Reads the latest version of a GCP Secret Manager secret. Returns None if the secret doesn't exist.
Reads the latest version of a GCP Secret Manager secret. Returns None if the secret doesn't exist.
[ "Reads", "the", "latest", "version", "of", "a", "GCP", "Secret", "Manager", "secret", ".", "Returns", "None", "if", "the", "secret", "doesn", "'", "t", "exist", "." ]
def _read_secret(self, project_id: str, secret_name: str): secret_manager = self._get_secret_manager_client() secret_path = secret_manager.secret_path(project_id, secret_name) response = secret_manager.access_secret_version( request={'name': f'{secret_path}/versions/latest'} ...
[ "def", "_read_secret", "(", "self", ",", "project_id", ":", "str", ",", "secret_name", ":", "str", ")", ":", "secret_manager", "=", "self", ".", "_get_secret_manager_client", "(", ")", "secret_path", "=", "secret_manager", ".", "secret_path", "(", "project_id", ...
Reads the latest version of a GCP Secret Manager secret.
[ "Reads", "the", "latest", "version", "of", "a", "GCP", "Secret", "Manager", "secret", "." ]
[ "\"\"\"Reads the latest version of a GCP Secret Manager secret.\n Returns None if the secret doesn't exist.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "project_id", "type": "str" }, { "param": "secret_name", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "project_id", "type": "str", "docstring": null, "docstring_tok...
5af71b8d36975d5ce07147b2e6cb1adb702eebee
jeremiahwander/sample-metadata
db/python/tables/project.py
[ "MIT" ]
Python
check_access_to_project_ids
bool
async def check_access_to_project_ids( self, user: str, project_ids: Iterable[ProjectId], readonly: bool, raise_exception=True, ) -> bool: """Check user has access to list of project_ids""" if not project_ids: raise Forbidden( "You ...
Check user has access to list of project_ids
Check user has access to list of project_ids
[ "Check", "user", "has", "access", "to", "list", "of", "project_ids" ]
async def check_access_to_project_ids( self, user: str, project_ids: Iterable[ProjectId], readonly: bool, raise_exception=True, ) -> bool: if not project_ids: raise Forbidden( "You don't have access to this resources, as the resource you re...
[ "async", "def", "check_access_to_project_ids", "(", "self", ",", "user", ":", "str", ",", "project_ids", ":", "Iterable", "[", "ProjectId", "]", ",", "readonly", ":", "bool", ",", "raise_exception", "=", "True", ",", ")", "->", "bool", ":", "if", "not", ...
Check user has access to list of project_ids
[ "Check", "user", "has", "access", "to", "list", "of", "project_ids" ]
[ "\"\"\"Check user has access to list of project_ids\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "user", "type": "str" }, { "param": "project_ids", "type": "Iterable[ProjectId]" }, { "param": "readonly", "type": "bool" }, { "param": "raise_exception", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user", "type": "str", "docstring": null, "docstring_tokens": ...
5af71b8d36975d5ce07147b2e6cb1adb702eebee
jeremiahwander/sample-metadata
db/python/tables/project.py
[ "MIT" ]
Python
check_access_to_project_id
bool
async def check_access_to_project_id( self, user: str, project_id: ProjectId, readonly: bool, raise_exception=True ) -> bool: """Check whether a user has access to project_id""" if self.allow_full_access: return True if not readonly: # validate write privilege...
Check whether a user has access to project_id
Check whether a user has access to project_id
[ "Check", "whether", "a", "user", "has", "access", "to", "project_id" ]
async def check_access_to_project_id( self, user: str, project_id: ProjectId, readonly: bool, raise_exception=True ) -> bool: if self.allow_full_access: return True if not readonly: pass users = await self.get_allowed_users_for_project_id( project_...
[ "async", "def", "check_access_to_project_id", "(", "self", ",", "user", ":", "str", ",", "project_id", ":", "ProjectId", ",", "readonly", ":", "bool", ",", "raise_exception", "=", "True", ")", "->", "bool", ":", "if", "self", ".", "allow_full_access", ":", ...
Check whether a user has access to project_id
[ "Check", "whether", "a", "user", "has", "access", "to", "project_id" ]
[ "\"\"\"Check whether a user has access to project_id\"\"\"", "# validate write privileges here connection" ]
[ { "param": "self", "type": null }, { "param": "user", "type": "str" }, { "param": "project_id", "type": "ProjectId" }, { "param": "readonly", "type": "bool" }, { "param": "raise_exception", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "user", "type": "str", "docstring": null, "docstring_tokens": ...
5af71b8d36975d5ce07147b2e6cb1adb702eebee
jeremiahwander/sample-metadata
db/python/tables/project.py
[ "MIT" ]
Python
ensure_project_id_cache_is_filled
null
async def ensure_project_id_cache_is_filled(self): """(CACHED) Get map of project names to project IDs""" if ( not ProjectPermissionsTable._cached_project_names or ProjectPermissionsTable._cache_expiry < datetime.utcnow() ): project_rows = await self.get_proje...
(CACHED) Get map of project names to project IDs
(CACHED) Get map of project names to project IDs
[ "(", "CACHED", ")", "Get", "map", "of", "project", "names", "to", "project", "IDs" ]
async def ensure_project_id_cache_is_filled(self): if ( not ProjectPermissionsTable._cached_project_names or ProjectPermissionsTable._cache_expiry < datetime.utcnow() ): project_rows = await self.get_project_rows(check_permissions=False) ProjectPermissions...
[ "async", "def", "ensure_project_id_cache_is_filled", "(", "self", ")", ":", "if", "(", "not", "ProjectPermissionsTable", ".", "_cached_project_names", "or", "ProjectPermissionsTable", ".", "_cache_expiry", "<", "datetime", ".", "utcnow", "(", ")", ")", ":", "project...
(CACHED) Get map of project names to project IDs
[ "(", "CACHED", ")", "Get", "map", "of", "project", "names", "to", "project", "IDs" ]
[ "\"\"\"(CACHED) Get map of project names to project IDs\"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5114ad3a40063d7f764d53b67353ee28355ef83b
jeremiahwander/sample-metadata
scripts/parse_vcgs_manifest.py
[ "MIT" ]
Python
sequence_meta_map
<not_specific>
def sequence_meta_map(): """Columns that will be put into sequence.meta""" fields = [ Columns.LIBRARY_ID, Columns.LIBRARY_STRATEGY, Columns.LIBRARY_SOURCE, Columns.LIBRARY_SELECTION, Columns.LIBRARY_LAYOUT, Columns.PLATFORM, ...
Columns that will be put into sequence.meta
Columns that will be put into sequence.meta
[ "Columns", "that", "will", "be", "put", "into", "sequence", ".", "meta" ]
def sequence_meta_map(): fields = [ Columns.LIBRARY_ID, Columns.LIBRARY_STRATEGY, Columns.LIBRARY_SOURCE, Columns.LIBRARY_SELECTION, Columns.LIBRARY_LAYOUT, Columns.PLATFORM, Columns.INSTRUMENT_MODEL, Columns.DESIGN_...
[ "def", "sequence_meta_map", "(", ")", ":", "fields", "=", "[", "Columns", ".", "LIBRARY_ID", ",", "Columns", ".", "LIBRARY_STRATEGY", ",", "Columns", ".", "LIBRARY_SOURCE", ",", "Columns", ".", "LIBRARY_SELECTION", ",", "Columns", ".", "LIBRARY_LAYOUT", ",", "...
Columns that will be put into sequence.meta
[ "Columns", "that", "will", "be", "put", "into", "sequence", ".", "meta" ]
[ "\"\"\"Columns that will be put into sequence.meta\"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
0c097f4d6d2bbfffb40499628e58feeb485f48af
jeremiahwander/sample-metadata
db/python/tables/participant.py
[ "MIT" ]
Python
create_participant
int
async def create_participant( self, external_id: str, reported_sex: int = None, reported_gender: str = None, karyotype: str = None, meta: Dict = None, author: str = None, project: ProjectId = None, ) -> int: """ Create a new sample, and...
Create a new sample, and add it to database
Create a new sample, and add it to database
[ "Create", "a", "new", "sample", "and", "add", "it", "to", "database" ]
async def create_participant( self, external_id: str, reported_sex: int = None, reported_gender: str = None, karyotype: str = None, meta: Dict = None, author: str = None, project: ProjectId = None, ) -> int: _query = f""" INSERT INTO participan...
[ "async", "def", "create_participant", "(", "self", ",", "external_id", ":", "str", ",", "reported_sex", ":", "int", "=", "None", ",", "reported_gender", ":", "str", "=", "None", ",", "karyotype", ":", "str", "=", "None", ",", "meta", ":", "Dict", "=", ...
Create a new sample, and add it to database
[ "Create", "a", "new", "sample", "and", "add", "it", "to", "database" ]
[ "\"\"\"\n Create a new sample, and add it to database\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "external_id", "type": "str" }, { "param": "reported_sex", "type": "int" }, { "param": "reported_gender", "type": "str" }, { "param": "karyotype", "type": "str" }, { "param": "meta", "type": "Dict" },...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "external_id", "type": "str", "docstring": null, "docstring_to...
0c097f4d6d2bbfffb40499628e58feeb485f48af
jeremiahwander/sample-metadata
db/python/tables/participant.py
[ "MIT" ]
Python
update_participants
null
async def update_participants( self, participant_ids: List[int], reported_sexes: List[int] = None, reported_genders: List[str] = None, karyotypes: List[str] = None, metas: List[Dict] = None, author=None, ): """ Update many participants, expects...
Update many participants, expects that all lists contain the same number of values. You can't update selective fields on selective samples, if you provide metas, this function will update EVERY participant with the provided meta values.
Update many participants, expects that all lists contain the same number of values. You can't update selective fields on selective samples, if you provide metas, this function will update EVERY participant with the provided meta values.
[ "Update", "many", "participants", "expects", "that", "all", "lists", "contain", "the", "same", "number", "of", "values", ".", "You", "can", "'", "t", "update", "selective", "fields", "on", "selective", "samples", "if", "you", "provide", "metas", "this", "fun...
async def update_participants( self, participant_ids: List[int], reported_sexes: List[int] = None, reported_genders: List[str] = None, karyotypes: List[str] = None, metas: List[Dict] = None, author=None, ): _author = author or self.author updat...
[ "async", "def", "update_participants", "(", "self", ",", "participant_ids", ":", "List", "[", "int", "]", ",", "reported_sexes", ":", "List", "[", "int", "]", "=", "None", ",", "reported_genders", ":", "List", "[", "str", "]", "=", "None", ",", "karyotyp...
Update many participants, expects that all lists contain the same number of values.
[ "Update", "many", "participants", "expects", "that", "all", "lists", "contain", "the", "same", "number", "of", "values", "." ]
[ "\"\"\"\n Update many participants, expects that all lists contain the same number of values.\n You can't update selective fields on selective samples, if you provide metas, this\n function will update EVERY participant with the provided meta values.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "participant_ids", "type": "List[int]" }, { "param": "reported_sexes", "type": "List[int]" }, { "param": "reported_genders", "type": "List[str]" }, { "param": "karyotypes", "type": "List[str]" }, { "param":...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "participant_ids", "type": "List[int]", "docstring": null, "do...
0c097f4d6d2bbfffb40499628e58feeb485f48af
jeremiahwander/sample-metadata
db/python/tables/participant.py
[ "MIT" ]
Python
update_many_participant_external_ids
<not_specific>
async def update_many_participant_external_ids( self, internal_to_external_id: Dict[int, str] ): """Update many participant external_ids through the {internal: external} map""" _query = 'UPDATE participant SET external_id = :external_id WHERE id = :participant_id' mapped_values = [ ...
Update many participant external_ids through the {internal: external} map
Update many participant external_ids through the {internal: external} map
[ "Update", "many", "participant", "external_ids", "through", "the", "{", "internal", ":", "external", "}", "map" ]
async def update_many_participant_external_ids( self, internal_to_external_id: Dict[int, str] ): _query = 'UPDATE participant SET external_id = :external_id WHERE id = :participant_id' mapped_values = [ {'participant_id': k, 'external_id': v} for k, v in internal_to_e...
[ "async", "def", "update_many_participant_external_ids", "(", "self", ",", "internal_to_external_id", ":", "Dict", "[", "int", ",", "str", "]", ")", ":", "_query", "=", "'UPDATE participant SET external_id = :external_id WHERE id = :participant_id'", "mapped_values", "=", "[...
Update many participant external_ids through the {internal: external} map
[ "Update", "many", "participant", "external_ids", "through", "the", "{", "internal", ":", "external", "}", "map" ]
[ "\"\"\"Update many participant external_ids through the {internal: external} map\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "internal_to_external_id", "type": "Dict[int, str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "internal_to_external_id", "type": "Dict[int, str]", "docstring": nu...
37a05e8560dd94b574b02f8588298646544b8b76
jeremiahwander/sample-metadata
sample_metadata/parser/generic_parser.py
[ "MIT" ]
Python
file_path
str
def file_path(self, filename: str) -> str: """ Get complete filepath of filename: - Includes gs://{bucket} if relevant - Includes path_prefix decided early on """ if filename.startswith('gs://'): return filename if self.client and not filename.startsw...
Get complete filepath of filename: - Includes gs://{bucket} if relevant - Includes path_prefix decided early on
Get complete filepath of filename: Includes gs://{bucket} if relevant Includes path_prefix decided early on
[ "Get", "complete", "filepath", "of", "filename", ":", "Includes", "gs", ":", "//", "{", "bucket", "}", "if", "relevant", "Includes", "path_prefix", "decided", "early", "on" ]
def file_path(self, filename: str) -> str: if filename.startswith('gs://'): return filename if self.client and not filename.startswith('/'): return os.path.join( 'gs://', self.default_bucket or '', self.path_prefix or '', filename or '' ) retur...
[ "def", "file_path", "(", "self", ",", "filename", ":", "str", ")", "->", "str", ":", "if", "filename", ".", "startswith", "(", "'gs://'", ")", ":", "return", "filename", "if", "self", ".", "client", "and", "not", "filename", ".", "startswith", "(", "'/...
Get complete filepath of filename: Includes gs://{bucket} if relevant Includes path_prefix decided early on
[ "Get", "complete", "filepath", "of", "filename", ":", "Includes", "gs", ":", "//", "{", "bucket", "}", "if", "relevant", "Includes", "path_prefix", "decided", "early", "on" ]
[ "\"\"\"\n Get complete filepath of filename:\n - Includes gs://{bucket} if relevant\n - Includes path_prefix decided early on\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": "str", "docstring": null, "docstring_token...
37a05e8560dd94b574b02f8588298646544b8b76
jeremiahwander/sample-metadata
sample_metadata/parser/generic_parser.py
[ "MIT" ]
Python
file_contents
Optional[str]
def file_contents(self, filename) -> Optional[str]: """Get contents of file (decoded as utf8)""" path = self.file_path(filename) if path.startswith('gs://'): blob = self.get_blob(path) try: retval = blob.download_as_string() if isinstance(r...
Get contents of file (decoded as utf8)
Get contents of file (decoded as utf8)
[ "Get", "contents", "of", "file", "(", "decoded", "as", "utf8", ")" ]
def file_contents(self, filename) -> Optional[str]: path = self.file_path(filename) if path.startswith('gs://'): blob = self.get_blob(path) try: retval = blob.download_as_string() if isinstance(retval, bytes): retval = retval.de...
[ "def", "file_contents", "(", "self", ",", "filename", ")", "->", "Optional", "[", "str", "]", ":", "path", "=", "self", ".", "file_path", "(", "filename", ")", "if", "path", ".", "startswith", "(", "'gs://'", ")", ":", "blob", "=", "self", ".", "get_...
Get contents of file (decoded as utf8)
[ "Get", "contents", "of", "file", "(", "decoded", "as", "utf8", ")" ]
[ "\"\"\"Get contents of file (decoded as utf8)\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
37a05e8560dd94b574b02f8588298646544b8b76
jeremiahwander/sample-metadata
sample_metadata/parser/generic_parser.py
[ "MIT" ]
Python
file_size
<not_specific>
def file_size(self, filename): """Get size of file in bytes""" path = self.file_path(filename) if path.startswith('gs://'): blob = self.get_blob(filename) return blob.size return os.path.getsize(path)
Get size of file in bytes
Get size of file in bytes
[ "Get", "size", "of", "file", "in", "bytes" ]
def file_size(self, filename): path = self.file_path(filename) if path.startswith('gs://'): blob = self.get_blob(filename) return blob.size return os.path.getsize(path)
[ "def", "file_size", "(", "self", ",", "filename", ")", ":", "path", "=", "self", ".", "file_path", "(", "filename", ")", "if", "path", ".", "startswith", "(", "'gs://'", ")", ":", "blob", "=", "self", ".", "get_blob", "(", "filename", ")", "return", ...
Get size of file in bytes
[ "Get", "size", "of", "file", "in", "bytes" ]
[ "\"\"\"Get size of file in bytes\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
37a05e8560dd94b574b02f8588298646544b8b76
jeremiahwander/sample-metadata
sample_metadata/parser/generic_parser.py
[ "MIT" ]
Python
parse_manifest
Union[Dict[str, str], Tuple[List, Dict, Dict, Dict, Dict]]
def parse_manifest( # pylint: disable=too-many-branches self, file_pointer, delimiter=',', confirm=False, dry_run=False ) -> Union[Dict[str, str], Tuple[List, Dict, Dict, Dict, Dict]]: """ Parse manifest from iterable (file pointer / String.IO) Returns a dict mapping external sampl...
Parse manifest from iterable (file pointer / String.IO) Returns a dict mapping external sample ID to CPG sample ID
Parse manifest from iterable (file pointer / String.IO) Returns a dict mapping external sample ID to CPG sample ID
[ "Parse", "manifest", "from", "iterable", "(", "file", "pointer", "/", "String", ".", "IO", ")", "Returns", "a", "dict", "mapping", "external", "sample", "ID", "to", "CPG", "sample", "ID" ]
def parse_manifest( self, file_pointer, delimiter=',', confirm=False, dry_run=False ) -> Union[Dict[str, str], Tuple[List, Dict, Dict, Dict, Dict]]: sample_map = defaultdict(list) reader = csv.DictReader(file_pointer, delimiter=delimiter) for row in reader: sample_id = ...
[ "def", "parse_manifest", "(", "self", ",", "file_pointer", ",", "delimiter", "=", "','", ",", "confirm", "=", "False", ",", "dry_run", "=", "False", ")", "->", "Union", "[", "Dict", "[", "str", ",", "str", "]", ",", "Tuple", "[", "List", ",", "Dict",...
Parse manifest from iterable (file pointer / String.IO) Returns a dict mapping external sample ID to CPG sample ID
[ "Parse", "manifest", "from", "iterable", "(", "file", "pointer", "/", "String", ".", "IO", ")", "Returns", "a", "dict", "mapping", "external", "sample", "ID", "to", "CPG", "sample", "ID" ]
[ "# pylint: disable=too-many-branches", "\"\"\"\n Parse manifest from iterable (file pointer / String.IO)\n\n Returns a dict mapping external sample ID to CPG sample ID\n \"\"\"", "# a sample has many rows", "# now we can start adding!!", "# determine if any samples exist", "# by exter...
[ { "param": "self", "type": null }, { "param": "file_pointer", "type": null }, { "param": "delimiter", "type": null }, { "param": "confirm", "type": null }, { "param": "dry_run", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "file_pointer", "type": null, "docstring": null, "docstring_to...
37a05e8560dd94b574b02f8588298646544b8b76
jeremiahwander/sample-metadata
sample_metadata/parser/generic_parser.py
[ "MIT" ]
Python
create_file_object
Dict[str, Any]
def create_file_object( self, filename: str, secondary_files: List[Dict[str, Any]] = None, ) -> Dict[str, Any]: """Takes filename, returns formed CWL dictionary""" checksum = None if not self.skip_checking_gcs_objects: md5_filename = self.file_path(filenam...
Takes filename, returns formed CWL dictionary
Takes filename, returns formed CWL dictionary
[ "Takes", "filename", "returns", "formed", "CWL", "dictionary" ]
def create_file_object( self, filename: str, secondary_files: List[Dict[str, Any]] = None, ) -> Dict[str, Any]: checksum = None if not self.skip_checking_gcs_objects: md5_filename = self.file_path(filename + '.md5') if self.file_exists(md5_filename): ...
[ "def", "create_file_object", "(", "self", ",", "filename", ":", "str", ",", "secondary_files", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ",", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "checksum", "=", "None...
Takes filename, returns formed CWL dictionary
[ "Takes", "filename", "returns", "formed", "CWL", "dictionary" ]
[ "\"\"\"Takes filename, returns formed CWL dictionary\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": "str" }, { "param": "secondary_files", "type": "List[Dict[str, Any]]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": "str", "docstring": null, "docstring_token...
37a05e8560dd94b574b02f8588298646544b8b76
jeremiahwander/sample-metadata
sample_metadata/parser/generic_parser.py
[ "MIT" ]
Python
create_secondary_file_objects_by_potential_pattern
List[Dict[str, Any]]
def create_secondary_file_objects_by_potential_pattern( self, filename, potential_secondary_patterns: List[str] ) -> List[Dict[str, Any]]: """ Take a base filename and potential secondary patterns: - Try each secondary pattern, see if it works - If it works, create a CWL file...
Take a base filename and potential secondary patterns: - Try each secondary pattern, see if it works - If it works, create a CWL file object - return a list of those secondary file objects that exist
Take a base filename and potential secondary patterns: Try each secondary pattern, see if it works If it works, create a CWL file object return a list of those secondary file objects that exist
[ "Take", "a", "base", "filename", "and", "potential", "secondary", "patterns", ":", "Try", "each", "secondary", "pattern", "see", "if", "it", "works", "If", "it", "works", "create", "a", "CWL", "file", "object", "return", "a", "list", "of", "those", "second...
def create_secondary_file_objects_by_potential_pattern( self, filename, potential_secondary_patterns: List[str] ) -> List[Dict[str, Any]]: secondaries = [] for sec in potential_secondary_patterns: sec_file = _apply_secondary_file_format_to_filename(filename, sec) if s...
[ "def", "create_secondary_file_objects_by_potential_pattern", "(", "self", ",", "filename", ",", "potential_secondary_patterns", ":", "List", "[", "str", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "secondaries", "=", "[", "]", ...
Take a base filename and potential secondary patterns: Try each secondary pattern, see if it works If it works, create a CWL file object return a list of those secondary file objects that exist
[ "Take", "a", "base", "filename", "and", "potential", "secondary", "patterns", ":", "Try", "each", "secondary", "pattern", "see", "if", "it", "works", "If", "it", "works", "create", "a", "CWL", "file", "object", "return", "a", "list", "of", "those", "second...
[ "\"\"\"\n Take a base filename and potential secondary patterns:\n - Try each secondary pattern, see if it works\n - If it works, create a CWL file object\n - return a list of those secondary file objects that exist\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": null }, { "param": "potential_secondary_patterns", "type": "List[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": null, "docstring": null, "docstring_tokens...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
transfer
null
def transfer(self, hbatch): """ Search files in buckets using search patterns and copy to CPG upload buckets """ for region, buckets in SRC_BUCKETS[NAMESPACE].items(): for bucket in buckets: for ending, pattern in self.search_pattern_by_ending.items(): ...
Search files in buckets using search patterns and copy to CPG upload buckets
Search files in buckets using search patterns and copy to CPG upload buckets
[ "Search", "files", "in", "buckets", "using", "search", "patterns", "and", "copy", "to", "CPG", "upload", "buckets" ]
def transfer(self, hbatch): for region, buckets in SRC_BUCKETS[NAMESPACE].items(): for bucket in buckets: for ending, pattern in self.search_pattern_by_ending.items(): _add_batch_job( cmd=( f"gsutil ls '{bucket}/...
[ "def", "transfer", "(", "self", ",", "hbatch", ")", ":", "for", "region", ",", "buckets", "in", "SRC_BUCKETS", "[", "NAMESPACE", "]", ".", "items", "(", ")", ":", "for", "bucket", "in", "buckets", ":", "for", "ending", ",", "pattern", "in", "self", "...
Search files in buckets using search patterns and copy to CPG upload buckets
[ "Search", "files", "in", "buckets", "using", "search", "patterns", "and", "copy", "to", "CPG", "upload", "buckets" ]
[ "\"\"\"\n Search files in buckets using search patterns and copy to CPG upload buckets\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "hbatch", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hbatch", "type": null, "docstring": null, "docstring_tokens":...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
transfer
<not_specific>
def transfer( tmp_dir, use_batch: bool, dry_run: bool, ): """ Transfer data from the Terra workspaces to the GCP bucket. Must be run with a personal account, because the read permissions to Terra buckets match to the Terra user emails for whom the workspace is sharred, so Hail service ac...
Transfer data from the Terra workspaces to the GCP bucket. Must be run with a personal account, because the read permissions to Terra buckets match to the Terra user emails for whom the workspace is sharred, so Hail service acounts won't work here.
Transfer data from the Terra workspaces to the GCP bucket. Must be run with a personal account, because the read permissions to Terra buckets match to the Terra user emails for whom the workspace is sharred, so Hail service acounts won't work here.
[ "Transfer", "data", "from", "the", "Terra", "workspaces", "to", "the", "GCP", "bucket", ".", "Must", "be", "run", "with", "a", "personal", "account", "because", "the", "read", "permissions", "to", "Terra", "buckets", "match", "to", "the", "Terra", "user", ...
def transfer( tmp_dir, use_batch: bool, dry_run: bool, ): if not tmp_dir: tmp_dir = tempfile.gettempdir() if use_batch: hbatch = setup_batch( title='Transferring NAGIM data', keep_scratch=False, tmp_bucket=f'cpg-{NAGIM_PROJ_ID}-{NAMESPACE}-tmp', ...
[ "def", "transfer", "(", "tmp_dir", ",", "use_batch", ":", "bool", ",", "dry_run", ":", "bool", ",", ")", ":", "if", "not", "tmp_dir", ":", "tmp_dir", "=", "tempfile", ".", "gettempdir", "(", ")", "if", "use_batch", ":", "hbatch", "=", "setup_batch", "(...
Transfer data from the Terra workspaces to the GCP bucket.
[ "Transfer", "data", "from", "the", "Terra", "workspaces", "to", "the", "GCP", "bucket", "." ]
[ "\"\"\"\n Transfer data from the Terra workspaces to the GCP bucket. Must be run with\n a personal account, because the read permissions to Terra buckets match\n to the Terra user emails for whom the workspace is sharred, so Hail service\n acounts won't work here.\n \"\"\"", "# Find GVCFs, CRAMs an...
[ { "param": "tmp_dir", "type": null }, { "param": "use_batch", "type": "bool" }, { "param": "dry_run", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tmp_dir", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "use_batch", "type": "bool", "docstring": null, "docstring_...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
_find_upload_files
null
def _find_upload_files(samples: List[Sample], tmp_dir, overwrite=False): """ Populate fields for each sample and verify that every sample has an expected set of files. """ sample_by_sid = {s.nagim_id: s for s in samples} # Find files for source_name in SOURCES_TO_PROCESS: source = S...
Populate fields for each sample and verify that every sample has an expected set of files.
Populate fields for each sample and verify that every sample has an expected set of files.
[ "Populate", "fields", "for", "each", "sample", "and", "verify", "that", "every", "sample", "has", "an", "expected", "set", "of", "files", "." ]
def _find_upload_files(samples: List[Sample], tmp_dir, overwrite=False): sample_by_sid = {s.nagim_id: s for s in samples} for source_name in SOURCES_TO_PROCESS: source = SOURCES[source_name] for ending in source.search_pattern_by_ending: paths = _cache_bucket_ls( endi...
[ "def", "_find_upload_files", "(", "samples", ":", "List", "[", "Sample", "]", ",", "tmp_dir", ",", "overwrite", "=", "False", ")", ":", "sample_by_sid", "=", "{", "s", ".", "nagim_id", ":", "s", "for", "s", "in", "samples", "}", "for", "source_name", "...
Populate fields for each sample and verify that every sample has an expected set of files.
[ "Populate", "fields", "for", "each", "sample", "and", "verify", "that", "every", "sample", "has", "an", "expected", "set", "of", "files", "." ]
[ "\"\"\"\n Populate fields for each sample and verify that every sample has an expected\n set of files.\n \"\"\"", "# Find files", "# Tally found files", "# For each sample, verify that the set of found files is consistent" ]
[ { "param": "samples", "type": "List[Sample]" }, { "param": "tmp_dir", "type": null }, { "param": "overwrite", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "samples", "type": "List[Sample]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "tmp_dir", "type": null, "docstring": null, "docs...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
parse
null
def parse( tmp_dir, confirm: bool, dry_run: bool, overwrite_multiqc: bool, skip_checking_objects: bool, ): """ Assuming the data is transferred to the CPG bucket, populate the SM projects. """ if not tmp_dir: tmp_dir = tempfile.gettempdir() samples = _parse_sample_projec...
Assuming the data is transferred to the CPG bucket, populate the SM projects.
Assuming the data is transferred to the CPG bucket, populate the SM projects.
[ "Assuming", "the", "data", "is", "transferred", "to", "the", "CPG", "bucket", "populate", "the", "SM", "projects", "." ]
def parse( tmp_dir, confirm: bool, dry_run: bool, overwrite_multiqc: bool, skip_checking_objects: bool, ): if not tmp_dir: tmp_dir = tempfile.gettempdir() samples = _parse_sample_project_map(SAMPLE_TO_PROJECT_TSV_PATH) _find_upload_files(samples, tmp_dir) _fix_sample_ids(samp...
[ "def", "parse", "(", "tmp_dir", ",", "confirm", ":", "bool", ",", "dry_run", ":", "bool", ",", "overwrite_multiqc", ":", "bool", ",", "skip_checking_objects", ":", "bool", ",", ")", ":", "if", "not", "tmp_dir", ":", "tmp_dir", "=", "tempfile", ".", "gett...
Assuming the data is transferred to the CPG bucket, populate the SM projects.
[ "Assuming", "the", "data", "is", "transferred", "to", "the", "CPG", "bucket", "populate", "the", "SM", "projects", "." ]
[ "\"\"\"\n Assuming the data is transferred to the CPG bucket, populate the SM projects.\n \"\"\"", "# Find GVCFs, CRAMs and other files after transferring, and checks that all", "# of them have corresponding tbi/crai/md5.", "# Some samples processed with Terra use CPG IDs, checking if we already", "# ...
[ { "param": "tmp_dir", "type": null }, { "param": "confirm", "type": "bool" }, { "param": "dry_run", "type": "bool" }, { "param": "overwrite_multiqc", "type": "bool" }, { "param": "skip_checking_objects", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tmp_dir", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "confirm", "type": "bool", "docstring": null, "docstring_to...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
_run_multiqc
str
def _run_multiqc( samples: List[Sample], html_fpath: str, json_fpath: str, overwrite: bool = False, ) -> str: """ Runs MultiQC on QC files from Picard and VerifyBAMID. Generates an HTML report and puts in into nagim web bucket. Generates a JSON with metrics, extracts useful metrics int...
Runs MultiQC on QC files from Picard and VerifyBAMID. Generates an HTML report and puts in into nagim web bucket. Generates a JSON with metrics, extracts useful metrics into another JSON indexed by sample, and returns path to this JSON.
Runs MultiQC on QC files from Picard and VerifyBAMID. Generates an HTML report and puts in into nagim web bucket. Generates a JSON with metrics, extracts useful metrics into another JSON indexed by sample, and returns path to this JSON.
[ "Runs", "MultiQC", "on", "QC", "files", "from", "Picard", "and", "VerifyBAMID", ".", "Generates", "an", "HTML", "report", "and", "puts", "in", "into", "nagim", "web", "bucket", ".", "Generates", "a", "JSON", "with", "metrics", "extracts", "useful", "metrics"...
def _run_multiqc( samples: List[Sample], html_fpath: str, json_fpath: str, overwrite: bool = False, ) -> str: tmp_bucket = f'gs://cpg-{NAGIM_PROJ_ID}-{NAMESPACE}-tmp/qc' row_by_sample_json_path = f'{tmp_bucket}/parsed-qc.json' if can_reuse(row_by_sample_json_path, overwrite): return ...
[ "def", "_run_multiqc", "(", "samples", ":", "List", "[", "Sample", "]", ",", "html_fpath", ":", "str", ",", "json_fpath", ":", "str", ",", "overwrite", ":", "bool", "=", "False", ",", ")", "->", "str", ":", "tmp_bucket", "=", "f'gs://cpg-{NAGIM_PROJ_ID}-{N...
Runs MultiQC on QC files from Picard and VerifyBAMID.
[ "Runs", "MultiQC", "on", "QC", "files", "from", "Picard", "and", "VerifyBAMID", "." ]
[ "\"\"\"\n Runs MultiQC on QC files from Picard and VerifyBAMID.\n\n Generates an HTML report and puts in into nagim web bucket.\n\n Generates a JSON with metrics, extracts useful metrics into another JSON\n indexed by sample, and returns path to this JSON.\n \"\"\"" ]
[ { "param": "samples", "type": "List[Sample]" }, { "param": "html_fpath", "type": "str" }, { "param": "json_fpath", "type": "str" }, { "param": "overwrite", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "samples", "type": "List[Sample]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "html_fpath", "type": "str", "docstring": null, "...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
_get_sm_proj_id
<not_specific>
def _get_sm_proj_id(proj: str, namespace='main'): """ Matching the project ID to a sample-metadata project. """ if proj == 'csiro-als': # We don't have a project for ALS yet proj = 'nagim' if namespace != 'main': proj = f'{proj}-test' return proj
Matching the project ID to a sample-metadata project.
Matching the project ID to a sample-metadata project.
[ "Matching", "the", "project", "ID", "to", "a", "sample", "-", "metadata", "project", "." ]
def _get_sm_proj_id(proj: str, namespace='main'): if proj == 'csiro-als': proj = 'nagim' if namespace != 'main': proj = f'{proj}-test' return proj
[ "def", "_get_sm_proj_id", "(", "proj", ":", "str", ",", "namespace", "=", "'main'", ")", ":", "if", "proj", "==", "'csiro-als'", ":", "proj", "=", "'nagim'", "if", "namespace", "!=", "'main'", ":", "proj", "=", "f'{proj}-test'", "return", "proj" ]
Matching the project ID to a sample-metadata project.
[ "Matching", "the", "project", "ID", "to", "a", "sample", "-", "metadata", "project", "." ]
[ "\"\"\"\n Matching the project ID to a sample-metadata project.\n \"\"\"", "# We don't have a project for ALS yet" ]
[ { "param": "proj", "type": "str" }, { "param": "namespace", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "proj", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "namespace", "type": null, "docstring": null, "docstring_toke...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
_fix_sample_ids
null
def _fix_sample_ids(samples: List[Sample], namespace: str = 'main'): """ Some samples processed with Terra use CPG IDs, so checking if we already have them in the SMDB, and fixing the external IDs. """ sm_proj_ids = [_get_sm_proj_id(proj, namespace) for proj in PROJECT_ID_MAP.values()] sapi = Sa...
Some samples processed with Terra use CPG IDs, so checking if we already have them in the SMDB, and fixing the external IDs.
Some samples processed with Terra use CPG IDs, so checking if we already have them in the SMDB, and fixing the external IDs.
[ "Some", "samples", "processed", "with", "Terra", "use", "CPG", "IDs", "so", "checking", "if", "we", "already", "have", "them", "in", "the", "SMDB", "and", "fixing", "the", "external", "IDs", "." ]
def _fix_sample_ids(samples: List[Sample], namespace: str = 'main'): sm_proj_ids = [_get_sm_proj_id(proj, namespace) for proj in PROJECT_ID_MAP.values()] sapi = SampleApi() sm_sample_dicts = sapi.get_samples( body_get_samples_by_criteria_api_v1_sample_post={ 'project_ids': sm_proj_ids, ...
[ "def", "_fix_sample_ids", "(", "samples", ":", "List", "[", "Sample", "]", ",", "namespace", ":", "str", "=", "'main'", ")", ":", "sm_proj_ids", "=", "[", "_get_sm_proj_id", "(", "proj", ",", "namespace", ")", "for", "proj", "in", "PROJECT_ID_MAP", ".", ...
Some samples processed with Terra use CPG IDs, so checking if we already have them in the SMDB, and fixing the external IDs.
[ "Some", "samples", "processed", "with", "Terra", "use", "CPG", "IDs", "so", "checking", "if", "we", "already", "have", "them", "in", "the", "SMDB", "and", "fixing", "the", "external", "IDs", "." ]
[ "\"\"\"\n Some samples processed with Terra use CPG IDs, so checking if we already\n have them in the SMDB, and fixing the external IDs.\n \"\"\"", "# Fixing sample IDs. Some samples (tob-wgs and acute-care)", "# have CPG IDs as nagim ids, some don't" ]
[ { "param": "samples", "type": "List[Sample]" }, { "param": "namespace", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "samples", "type": "List[Sample]", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "namespace", "type": "str", "docstring": null, "d...
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
_parse_sample_project_map
List[Sample]
def _parse_sample_project_map(tsv_path: str) -> List[Sample]: """ Initialize list of Sample object and set project IDs. """ sample_by_nagim_id = {} df = pd.read_csv(tsv_path, sep='\t', header=None, names=['nagim_id', 'proj']) for (nagim_id, proj) in zip(df.nagim_id, df.proj): if proj in ...
Initialize list of Sample object and set project IDs.
Initialize list of Sample object and set project IDs.
[ "Initialize", "list", "of", "Sample", "object", "and", "set", "project", "IDs", "." ]
def _parse_sample_project_map(tsv_path: str) -> List[Sample]: sample_by_nagim_id = {} df = pd.read_csv(tsv_path, sep='\t', header=None, names=['nagim_id', 'proj']) for (nagim_id, proj) in zip(df.nagim_id, df.proj): if proj in PROJECT_ID_MAP.values(): cpg_proj = proj elif proj in ...
[ "def", "_parse_sample_project_map", "(", "tsv_path", ":", "str", ")", "->", "List", "[", "Sample", "]", ":", "sample_by_nagim_id", "=", "{", "}", "df", "=", "pd", ".", "read_csv", "(", "tsv_path", ",", "sep", "=", "'\\t'", ",", "header", "=", "None", "...
Initialize list of Sample object and set project IDs.
[ "Initialize", "list", "of", "Sample", "object", "and", "set", "project", "IDs", "." ]
[ "\"\"\"\n Initialize list of Sample object and set project IDs.\n \"\"\"" ]
[ { "param": "tsv_path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tsv_path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
b02bade433efb6d0fd7721d08d9e2b04fedcb5ac
jeremiahwander/sample-metadata
scripts/parse_nagim.py
[ "MIT" ]
Python
_add_batch_job
<not_specific>
def _add_batch_job(cmd: str, hbatch, job_name: str): """ Add cmd as a Batch job. """ j = hbatch.new_job(job_name) j.cpu(32) j.memory('lowmem') j.image('australia-southeast1-docker.pkg.dev/cpg-common/images/aspera:v1') j.command('export GOOGLE_APPLICATION_CREDENTIALS=/gsa-key/key.json') ...
Add cmd as a Batch job.
Add cmd as a Batch job.
[ "Add", "cmd", "as", "a", "Batch", "job", "." ]
def _add_batch_job(cmd: str, hbatch, job_name: str): j = hbatch.new_job(job_name) j.cpu(32) j.memory('lowmem') j.image('australia-southeast1-docker.pkg.dev/cpg-common/images/aspera:v1') j.command('export GOOGLE_APPLICATION_CREDENTIALS=/gsa-key/key.json') j.command( 'gcloud -q auth activa...
[ "def", "_add_batch_job", "(", "cmd", ":", "str", ",", "hbatch", ",", "job_name", ":", "str", ")", ":", "j", "=", "hbatch", ".", "new_job", "(", "job_name", ")", "j", ".", "cpu", "(", "32", ")", "j", ".", "memory", "(", "'lowmem'", ")", "j", ".", ...
Add cmd as a Batch job.
[ "Add", "cmd", "as", "a", "Batch", "job", "." ]
[ "\"\"\"\n Add cmd as a Batch job.\n \"\"\"" ]
[ { "param": "cmd", "type": "str" }, { "param": "hbatch", "type": null }, { "param": "job_name", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cmd", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "hbatch", "type": null, "docstring": null, "docstring_tokens":...
5d4ba2c56c95ef8f18da522929011831b749ae45
jeremiahwander/sample-metadata
api/routes/family.py
[ "MIT" ]
Python
update_family
<not_specific>
async def update_family( family: FamilyUpdateModel, connection: Connection = get_projectless_db_connection ): """Update information for a single family""" family_layer = FamilyLayer(connection) return { 'success': await family_layer.update_family( id_=family.id, external_...
Update information for a single family
Update information for a single family
[ "Update", "information", "for", "a", "single", "family" ]
async def update_family( family: FamilyUpdateModel, connection: Connection = get_projectless_db_connection ): family_layer = FamilyLayer(connection) return { 'success': await family_layer.update_family( id_=family.id, external_id=family.external_id, description=fa...
[ "async", "def", "update_family", "(", "family", ":", "FamilyUpdateModel", ",", "connection", ":", "Connection", "=", "get_projectless_db_connection", ")", ":", "family_layer", "=", "FamilyLayer", "(", "connection", ")", "return", "{", "'success'", ":", "await", "f...
Update information for a single family
[ "Update", "information", "for", "a", "single", "family" ]
[ "\"\"\"Update information for a single family\"\"\"" ]
[ { "param": "family", "type": "FamilyUpdateModel" }, { "param": "connection", "type": "Connection" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "family", "type": "FamilyUpdateModel", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "connection", "type": "Connection", "docstring": nu...
c396249acd6225595569e7d92d3fbb577f1e1aca
jeremiahwander/sample-metadata
models/models/analysis.py
[ "MIT" ]
Python
from_db
<not_specific>
def from_db(**kwargs): """ Convert from db keys, mainly converting id to id_ """ analysis_type = kwargs.pop('type', None) status = kwargs.pop('status', None) timestamp_completed = kwargs.pop('timestamp_completed', None) meta = kwargs.get('meta') if meta a...
Convert from db keys, mainly converting id to id_
Convert from db keys, mainly converting id to id_
[ "Convert", "from", "db", "keys", "mainly", "converting", "id", "to", "id_" ]
def from_db(**kwargs): analysis_type = kwargs.pop('type', None) status = kwargs.pop('status', None) timestamp_completed = kwargs.pop('timestamp_completed', None) meta = kwargs.get('meta') if meta and isinstance(meta, str): meta = json.loads(meta) if timestamp_...
[ "def", "from_db", "(", "**", "kwargs", ")", ":", "analysis_type", "=", "kwargs", ".", "pop", "(", "'type'", ",", "None", ")", "status", "=", "kwargs", ".", "pop", "(", "'status'", ",", "None", ")", "timestamp_completed", "=", "kwargs", ".", "pop", "(",...
Convert from db keys, mainly converting id to id_
[ "Convert", "from", "db", "keys", "mainly", "converting", "id", "to", "id_" ]
[ "\"\"\"\n Convert from db keys, mainly converting id to id_\n \"\"\"" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
fd5a076600a7e75b121610809501e723531dc99c
jeremiahwander/sample-metadata
scripts/arbitrary_sm.py
[ "MIT" ]
Python
run_sm
<not_specific>
def run_sm( api_name: str, method_name: str, args: List[str] = None, kwargs: dict = None ): """ Use the sample metadata API based on: :param api_name: pure name of API, eg: 'analysis' :param method_name: name of method in snake case :param args: positional args of endpoint :param kwargs: key...
Use the sample metadata API based on: :param api_name: pure name of API, eg: 'analysis' :param method_name: name of method in snake case :param args: positional args of endpoint :param kwargs: keyword arguments of endpoint, note: POST requests have funny kwarg names, eg: 'body_get_s...
Use the sample metadata API based on.
[ "Use", "the", "sample", "metadata", "API", "based", "on", "." ]
def run_sm( api_name: str, method_name: str, args: List[str] = None, kwargs: dict = None ): api_class_name = api_name.title() + 'Api' api = getattr(sample_metadata.api, api_class_name) api_instance = api() response = getattr(api_instance, method_name)(*(args or []), **(kwargs or {})) return resp...
[ "def", "run_sm", "(", "api_name", ":", "str", ",", "method_name", ":", "str", ",", "args", ":", "List", "[", "str", "]", "=", "None", ",", "kwargs", ":", "dict", "=", "None", ")", ":", "api_class_name", "=", "api_name", ".", "title", "(", ")", "+",...
Use the sample metadata API based on:
[ "Use", "the", "sample", "metadata", "API", "based", "on", ":" ]
[ "\"\"\"\n Use the sample metadata API based on:\n :param api_name: pure name of API, eg: 'analysis'\n :param method_name: name of method in snake case\n :param args: positional args of endpoint\n :param kwargs: keyword arguments of endpoint, note:\n POST requests have funny kwarg names, eg:\n ...
[ { "param": "api_name", "type": "str" }, { "param": "method_name", "type": "str" }, { "param": "args", "type": "List[str]" }, { "param": "kwargs", "type": "dict" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "api_name", "type": "str", "docstring": "pure name of API, eg: 'analysis'", "docstring_tokens": [ "pure", "name", "of", "API", "eg", ":", "'", "analysis", ...
c0c0a20dc113fc7c88658962d2561b8e707a4812
jeremiahwander/sample-metadata
scripts/parse_tobwgs_csv.py
[ "MIT" ]
Python
find_gvcf
Optional[str]
def find_gvcf(self, sample_id: str, cpg_id: Optional[str] = None) -> Optional[str]: """ Find GVCF for the sample. """ extension = 'g.vcf.gz' search_locations = [f'gs://cpg-tob-wgs-main-upload/{sample_id}.{extension}'] if cpg_id: # Sample was added before and...
Find GVCF for the sample.
Find GVCF for the sample.
[ "Find", "GVCF", "for", "the", "sample", "." ]
def find_gvcf(self, sample_id: str, cpg_id: Optional[str] = None) -> Optional[str]: extension = 'g.vcf.gz' search_locations = [f'gs://cpg-tob-wgs-main-upload/{sample_id}.{extension}'] if cpg_id: search_locations += [ f'gs://cpg-tob-wgs-main-archive/{SOURCE}/gvcf/stagi...
[ "def", "find_gvcf", "(", "self", ",", "sample_id", ":", "str", ",", "cpg_id", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "extension", "=", "'g.vcf.gz'", "search_locations", "=", "[", "f'gs://cpg-tob-wgs-main...
Find GVCF for the sample.
[ "Find", "GVCF", "for", "the", "sample", "." ]
[ "\"\"\"\n Find GVCF for the sample.\n \"\"\"", "# Sample was added before and CPG ID is known, so can search the locations", "# where downstream upload processor and pipelines might have moved files.", "# After GVCFs were processed with joint-calling, staging ones", "# are moved to the archive...
[ { "param": "self", "type": null }, { "param": "sample_id", "type": "str" }, { "param": "cpg_id", "type": "Optional[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sample_id", "type": "str", "docstring": null, "docstring_toke...
c0c0a20dc113fc7c88658962d2561b8e707a4812
jeremiahwander/sample-metadata
scripts/parse_tobwgs_csv.py
[ "MIT" ]
Python
find_cram
Optional[str]
def find_cram(self, sample_id: str, cpg_id: Optional[str] = None) -> Optional[str]: """ Find CRAM for the sample. """ extension = 'cram' search_locations = [f'gs://cpg-tob-wgs-main-upload/{sample_id}.{extension}'] if cpg_id: # Sample was added before and CPG...
Find CRAM for the sample.
Find CRAM for the sample.
[ "Find", "CRAM", "for", "the", "sample", "." ]
def find_cram(self, sample_id: str, cpg_id: Optional[str] = None) -> Optional[str]: extension = 'cram' search_locations = [f'gs://cpg-tob-wgs-main-upload/{sample_id}.{extension}'] if cpg_id: search_locations += [ f'gs://cpg-tob-wgs-main-archive/{SOURCE}/cram/{cpg_id}....
[ "def", "find_cram", "(", "self", ",", "sample_id", ":", "str", ",", "cpg_id", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "extension", "=", "'cram'", "search_locations", "=", "[", "f'gs://cpg-tob-wgs-main-upl...
Find CRAM for the sample.
[ "Find", "CRAM", "for", "the", "sample", "." ]
[ "\"\"\"\n Find CRAM for the sample.\n \"\"\"", "# Sample was added before and CPG ID is known, so can search the locations", "# where downstream upload processor and pipelines might have moved files.", "# Upload processor moves CRAMs to the archive:" ]
[ { "param": "self", "type": null }, { "param": "sample_id", "type": "str" }, { "param": "cpg_id", "type": "Optional[str]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sample_id", "type": "str", "docstring": null, "docstring_toke...
ca69d0ed6b2dcf2b96e6159a3ff810170702785f
jeremiahwander/sample-metadata
scripts/create_test_subset.py
[ "MIT" ]
Python
main
null
def main( project: str, samples_n: Optional[int], families_n: Optional[int], ): """ Script creates a test subset for a given project. A new project with a prefix -test is created, and for any files in sample/meta, sequence/meta, or analysis/output a copy in the -test namespace is created. ...
Script creates a test subset for a given project. A new project with a prefix -test is created, and for any files in sample/meta, sequence/meta, or analysis/output a copy in the -test namespace is created.
Script creates a test subset for a given project. A new project with a prefix -test is created, and for any files in sample/meta, sequence/meta, or analysis/output a copy in the -test namespace is created.
[ "Script", "creates", "a", "test", "subset", "for", "a", "given", "project", ".", "A", "new", "project", "with", "a", "prefix", "-", "test", "is", "created", "and", "for", "any", "files", "in", "sample", "/", "meta", "sequence", "/", "meta", "or", "anal...
def main( project: str, samples_n: Optional[int], families_n: Optional[int], ): samples_n, families_n = _validate_opts(samples_n, families_n) all_samples = sapi.get_samples( body_get_samples_by_criteria_api_v1_sample_post={ 'project_ids': [project], 'active': True, ...
[ "def", "main", "(", "project", ":", "str", ",", "samples_n", ":", "Optional", "[", "int", "]", ",", "families_n", ":", "Optional", "[", "int", "]", ",", ")", ":", "samples_n", ",", "families_n", "=", "_validate_opts", "(", "samples_n", ",", "families_n",...
Script creates a test subset for a given project.
[ "Script", "creates", "a", "test", "subset", "for", "a", "given", "project", "." ]
[ "\"\"\"\n Script creates a test subset for a given project.\n A new project with a prefix -test is created, and for any files in sample/meta,\n sequence/meta, or analysis/output a copy in the -test namespace is created.\n \"\"\"", "# for reproducibility", "# Populating test project" ]
[ { "param": "project", "type": "str" }, { "param": "samples_n", "type": "Optional[int]" }, { "param": "families_n", "type": "Optional[int]" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "project", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "samples_n", "type": "Optional[int]", "docstring": null, "...
ca69d0ed6b2dcf2b96e6159a3ff810170702785f
jeremiahwander/sample-metadata
scripts/create_test_subset.py
[ "MIT" ]
Python
export_ped_file
List[str]
def export_ped_file( # pylint: disable=invalid-name project: str, replace_with_participant_external_ids: bool = False, replace_with_family_external_ids: bool = False, ) -> List[str]: """ Generates a PED file for the project, returs PED file lines in a list """ route = f'/api/v1/family/{proj...
Generates a PED file for the project, returs PED file lines in a list
Generates a PED file for the project, returs PED file lines in a list
[ "Generates", "a", "PED", "file", "for", "the", "project", "returs", "PED", "file", "lines", "in", "a", "list" ]
def export_ped_file( project: str, replace_with_participant_external_ids: bool = False, replace_with_family_external_ids: bool = False, ) -> List[str]: route = f'/api/v1/family/{project}/pedigree' opts = [] if replace_with_participant_external_ids: opts.append('replace_with_participant...
[ "def", "export_ped_file", "(", "project", ":", "str", ",", "replace_with_participant_external_ids", ":", "bool", "=", "False", ",", "replace_with_family_external_ids", ":", "bool", "=", "False", ",", ")", "->", "List", "[", "str", "]", ":", "route", "=", "f'/a...
Generates a PED file for the project, returs PED file lines in a list
[ "Generates", "a", "PED", "file", "for", "the", "project", "returs", "PED", "file", "lines", "in", "a", "list" ]
[ "# pylint: disable=invalid-name", "\"\"\"\n Generates a PED file for the project, returs PED file lines in a list\n \"\"\"" ]
[ { "param": "project", "type": "str" }, { "param": "replace_with_participant_external_ids", "type": "bool" }, { "param": "replace_with_family_external_ids", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "project", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "replace_with_participant_external_ids", "type": "bool", "docstr...
2d7a280799a10d06db8729e4d01cc572e913825a
jeremiahwander/sample-metadata
sample_metadata/parser/generic_metadata_parser.py
[ "MIT" ]
Python
file_path
str
def file_path(self, filename: str) -> str: """ Get complete filepath of filename: - Includes gs://{bucket} if relevant - Includes path_prefix decided early on """ if filename in self.filename_map: return self.filename_map[filename] return super().file...
Get complete filepath of filename: - Includes gs://{bucket} if relevant - Includes path_prefix decided early on
Get complete filepath of filename: Includes gs://{bucket} if relevant Includes path_prefix decided early on
[ "Get", "complete", "filepath", "of", "filename", ":", "Includes", "gs", ":", "//", "{", "bucket", "}", "if", "relevant", "Includes", "path_prefix", "decided", "early", "on" ]
def file_path(self, filename: str) -> str: if filename in self.filename_map: return self.filename_map[filename] return super().file_path(filename)
[ "def", "file_path", "(", "self", ",", "filename", ":", "str", ")", "->", "str", ":", "if", "filename", "in", "self", ".", "filename_map", ":", "return", "self", ".", "filename_map", "[", "filename", "]", "return", "super", "(", ")", ".", "file_path", "...
Get complete filepath of filename: Includes gs://{bucket} if relevant Includes path_prefix decided early on
[ "Get", "complete", "filepath", "of", "filename", ":", "Includes", "gs", ":", "//", "{", "bucket", "}", "if", "relevant", "Includes", "path_prefix", "decided", "early", "on" ]
[ "\"\"\"\n Get complete filepath of filename:\n - Includes gs://{bucket} if relevant\n - Includes path_prefix decided early on\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "filename", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filename", "type": "str", "docstring": null, "docstring_token...
2d7a280799a10d06db8729e4d01cc572e913825a
jeremiahwander/sample-metadata
sample_metadata/parser/generic_metadata_parser.py
[ "MIT" ]
Python
from_manifest_path
<not_specific>
def from_manifest_path( self, manifest: str, confirm=False, delimiter=None, dry_run=False, ): """Parse manifest from path, and return result of parsing manifest""" _delimiter = delimiter or GenericMetadataParser.guess_delimiter_from_filename( mani...
Parse manifest from path, and return result of parsing manifest
Parse manifest from path, and return result of parsing manifest
[ "Parse", "manifest", "from", "path", "and", "return", "result", "of", "parsing", "manifest" ]
def from_manifest_path( self, manifest: str, confirm=False, delimiter=None, dry_run=False, ): _delimiter = delimiter or GenericMetadataParser.guess_delimiter_from_filename( manifest ) file_contents = self.file_contents(manifest) ret...
[ "def", "from_manifest_path", "(", "self", ",", "manifest", ":", "str", ",", "confirm", "=", "False", ",", "delimiter", "=", "None", ",", "dry_run", "=", "False", ",", ")", ":", "_delimiter", "=", "delimiter", "or", "GenericMetadataParser", ".", "guess_delimi...
Parse manifest from path, and return result of parsing manifest
[ "Parse", "manifest", "from", "path", "and", "return", "result", "of", "parsing", "manifest" ]
[ "\"\"\"Parse manifest from path, and return result of parsing manifest\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "manifest", "type": "str" }, { "param": "confirm", "type": null }, { "param": "delimiter", "type": null }, { "param": "dry_run", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "manifest", "type": "str", "docstring": null, "docstring_token...
59a661356ed8df76fc2212db59c8d121d61d090e
jeremiahwander/sample-metadata
test/test_add_samples_for_joint_calling.py
[ "MIT" ]
Python
_add_samples
<not_specific>
def _add_samples(run_id: str, project: str): """ Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input. :param run_id: to suffix sample names for uniqueness """ s1 = NewSample( external_id=f'NA12878-from-fq-{run_id}', type=SampleType('blood'), meta={ ...
Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input. :param run_id: to suffix sample names for uniqueness
Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input.
[ "Add", "3", "samples", ":", "one", "with", "fastq", "input", "one", "with", "CRAM", "input", "one", "with", "GVCF", "input", "." ]
def _add_samples(run_id: str, project: str): s1 = NewSample( external_id=f'NA12878-from-fq-{run_id}', type=SampleType('blood'), meta={ 'reads': [ [ 'gs://cpg-seqr-test/batches/NA12878-trio-tiny/NA12878_L001_R1.fq', 'gs://cpg...
[ "def", "_add_samples", "(", "run_id", ":", "str", ",", "project", ":", "str", ")", ":", "s1", "=", "NewSample", "(", "external_id", "=", "f'NA12878-from-fq-{run_id}'", ",", "type", "=", "SampleType", "(", "'blood'", ")", ",", "meta", "=", "{", "'reads'", ...
Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input.
[ "Add", "3", "samples", ":", "one", "with", "fastq", "input", "one", "with", "CRAM", "input", "one", "with", "GVCF", "input", "." ]
[ "\"\"\"\n Add 3 samples: one with fastq input, one with CRAM input, one with GVCF input.\n :param run_id: to suffix sample names for uniqueness\n \"\"\"" ]
[ { "param": "run_id", "type": "str" }, { "param": "project", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "run_id", "type": "str", "docstring": "to suffix sample names for uniqueness", "docstring_tokens": [ "to", "suffix", "sample", "names", "for", "uniqueness" ], "default...
479f52dddde3f2ec5e418e5b565fe1eb9b2b93bc
jeremiahwander/sample-metadata
db/python/layers/sequence.py
[ "MIT" ]
Python
insert_many_sequencing
None
async def insert_many_sequencing( self, sequencing: List[SampleSequencing], author=None, check_project_ids=True ) -> None: """Insert many sequencing, returning no IDs""" if check_project_ids: sample_ids = set(int(s.sample_id) for s in sequencing) st = SampleTable(self...
Insert many sequencing, returning no IDs
Insert many sequencing, returning no IDs
[ "Insert", "many", "sequencing", "returning", "no", "IDs" ]
async def insert_many_sequencing( self, sequencing: List[SampleSequencing], author=None, check_project_ids=True ) -> None: if check_project_ids: sample_ids = set(int(s.sample_id) for s in sequencing) st = SampleTable(self.connection) project_ids = await st.get_pro...
[ "async", "def", "insert_many_sequencing", "(", "self", ",", "sequencing", ":", "List", "[", "SampleSequencing", "]", ",", "author", "=", "None", ",", "check_project_ids", "=", "True", ")", "->", "None", ":", "if", "check_project_ids", ":", "sample_ids", "=", ...
Insert many sequencing, returning no IDs
[ "Insert", "many", "sequencing", "returning", "no", "IDs" ]
[ "\"\"\"Insert many sequencing, returning no IDs\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "sequencing", "type": "List[SampleSequencing]" }, { "param": "author", "type": null }, { "param": "check_project_ids", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sequencing", "type": "List[SampleSequencing]", "docstring": null, ...
479f52dddde3f2ec5e418e5b565fe1eb9b2b93bc
jeremiahwander/sample-metadata
db/python/layers/sequence.py
[ "MIT" ]
Python
insert_sequencing
int
async def insert_sequencing( self, sample_id, sequence_type: SequenceType, status: SequenceStatus, sequence_meta: Dict[str, Any] = None, author=None, check_project_id=True, ) -> int: """ Create a new sequence for a sample, and add it to databas...
Create a new sequence for a sample, and add it to database
Create a new sequence for a sample, and add it to database
[ "Create", "a", "new", "sequence", "for", "a", "sample", "and", "add", "it", "to", "database" ]
async def insert_sequencing( self, sample_id, sequence_type: SequenceType, status: SequenceStatus, sequence_meta: Dict[str, Any] = None, author=None, check_project_id=True, ) -> int: if check_project_id: st = SampleTable(self.connection) ...
[ "async", "def", "insert_sequencing", "(", "self", ",", "sample_id", ",", "sequence_type", ":", "SequenceType", ",", "status", ":", "SequenceStatus", ",", "sequence_meta", ":", "Dict", "[", "str", ",", "Any", "]", "=", "None", ",", "author", "=", "None", ",...
Create a new sequence for a sample, and add it to database
[ "Create", "a", "new", "sequence", "for", "a", "sample", "and", "add", "it", "to", "database" ]
[ "\"\"\"\n Create a new sequence for a sample, and add it to database\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "sample_id", "type": null }, { "param": "sequence_type", "type": "SequenceType" }, { "param": "status", "type": "SequenceStatus" }, { "param": "sequence_meta", "type": "Dict[str, Any]" }, { "param": "author...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sample_id", "type": null, "docstring": null, "docstring_token...
479f52dddde3f2ec5e418e5b565fe1eb9b2b93bc
jeremiahwander/sample-metadata
db/python/layers/sequence.py
[ "MIT" ]
Python
update_sequencing_status_from_internal_sample_id
<not_specific>
async def update_sequencing_status_from_internal_sample_id( self, sample_id: int, status: SequenceStatus ): """Update the sequencing status from the internal sample id""" # check project ID in first one seq_id = self.get_latest_sequence_id_for_sample_id(sample_id) return self...
Update the sequencing status from the internal sample id
Update the sequencing status from the internal sample id
[ "Update", "the", "sequencing", "status", "from", "the", "internal", "sample", "id" ]
async def update_sequencing_status_from_internal_sample_id( self, sample_id: int, status: SequenceStatus ): seq_id = self.get_latest_sequence_id_for_sample_id(sample_id) return self.update_status(seq_id, status, check_project_id=False)
[ "async", "def", "update_sequencing_status_from_internal_sample_id", "(", "self", ",", "sample_id", ":", "int", ",", "status", ":", "SequenceStatus", ")", ":", "seq_id", "=", "self", ".", "get_latest_sequence_id_for_sample_id", "(", "sample_id", ")", "return", "self", ...
Update the sequencing status from the internal sample id
[ "Update", "the", "sequencing", "status", "from", "the", "internal", "sample", "id" ]
[ "\"\"\"Update the sequencing status from the internal sample id\"\"\"", "# check project ID in first one" ]
[ { "param": "self", "type": null }, { "param": "sample_id", "type": "int" }, { "param": "status", "type": "SequenceStatus" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sample_id", "type": "int", "docstring": null, "docstring_toke...
479f52dddde3f2ec5e418e5b565fe1eb9b2b93bc
jeremiahwander/sample-metadata
db/python/layers/sequence.py
[ "MIT" ]
Python
update_sequencing_status_from_external_sample_id
<not_specific>
async def update_sequencing_status_from_external_sample_id( self, project: ProjectId, external_sample_id: str, status: SequenceStatus ): """ Update the sequencing status from the external sample id, by first looking up the internal sample id. """ # project ID check do...
Update the sequencing status from the external sample id, by first looking up the internal sample id.
Update the sequencing status from the external sample id, by first looking up the internal sample id.
[ "Update", "the", "sequencing", "status", "from", "the", "external", "sample", "id", "by", "first", "looking", "up", "the", "internal", "sample", "id", "." ]
async def update_sequencing_status_from_external_sample_id( self, project: ProjectId, external_sample_id: str, status: SequenceStatus ): seq_id = await self.get_latest_sequence_id_for_external_sample_id( project=project, external_sample_id=external_sample_id ) return awai...
[ "async", "def", "update_sequencing_status_from_external_sample_id", "(", "self", ",", "project", ":", "ProjectId", ",", "external_sample_id", ":", "str", ",", "status", ":", "SequenceStatus", ")", ":", "seq_id", "=", "await", "self", ".", "get_latest_sequence_id_for_e...
Update the sequencing status from the external sample id, by first looking up the internal sample id.
[ "Update", "the", "sequencing", "status", "from", "the", "external", "sample", "id", "by", "first", "looking", "up", "the", "internal", "sample", "id", "." ]
[ "\"\"\"\n Update the sequencing status from the external sample id,\n by first looking up the internal sample id.\n \"\"\"", "# project ID check done here" ]
[ { "param": "self", "type": null }, { "param": "project", "type": "ProjectId" }, { "param": "external_sample_id", "type": "str" }, { "param": "status", "type": "SequenceStatus" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "project", "type": "ProjectId", "docstring": null, "docstring_...
be78036e058d0877ee5fe7f9599c7a713b9b10c7
dweindl/fides
fides/stepback.py
[ "BSD-3-Clause" ]
Python
stepback_reflect
List[Step]
def stepback_reflect(tr_step: Step, x: np.ndarray, sg: np.ndarray, hess: np.ndarray, scaling: csc_matrix, g_dscaling: csc_matrix, delta: float, theta: float, ...
Compute new proposal steps according to a reflection strategy. :param tr_step: Reference trust region step that will be reflected :param x: Current values of the optimization variables :param sg: Rescaled objective function gradient at x :param hess: (Approximate) o...
Compute new proposal steps according to a reflection strategy.
[ "Compute", "new", "proposal", "steps", "according", "to", "a", "reflection", "strategy", "." ]
def stepback_reflect(tr_step: Step, x: np.ndarray, sg: np.ndarray, hess: np.ndarray, scaling: csc_matrix, g_dscaling: csc_matrix, delta: float, theta: float, ...
[ "def", "stepback_reflect", "(", "tr_step", ":", "Step", ",", "x", ":", "np", ".", "ndarray", ",", "sg", ":", "np", ".", "ndarray", ",", "hess", ":", "np", ".", "ndarray", ",", "scaling", ":", "csc_matrix", ",", "g_dscaling", ":", "csc_matrix", ",", "...
Compute new proposal steps according to a reflection strategy.
[ "Compute", "new", "proposal", "steps", "according", "to", "a", "reflection", "strategy", "." ]
[ "\"\"\"\n Compute new proposal steps according to a reflection strategy.\n\n :param tr_step:\n Reference trust region step that will be reflected\n :param x:\n Current values of the optimization variables\n :param sg:\n Rescaled objective function gradient at x\n :param hess:\n ...
[ { "param": "tr_step", "type": "Step" }, { "param": "x", "type": "np.ndarray" }, { "param": "sg", "type": "np.ndarray" }, { "param": "hess", "type": "np.ndarray" }, { "param": "scaling", "type": "csc_matrix" }, { "param": "g_dscaling", "type": "csc_...
{ "returns": [ { "docstring": "New proposal steps", "docstring_tokens": [ "New", "proposal", "steps" ], "type": null } ], "raises": [], "params": [ { "identifier": "tr_step", "type": "Step", "docstring": "Reference trust region step t...
be78036e058d0877ee5fe7f9599c7a713b9b10c7
dweindl/fides
fides/stepback.py
[ "BSD-3-Clause" ]
Python
stepback_truncate
List[Step]
def stepback_truncate(tr_step: Step, x: np.ndarray, sg: np.ndarray, hess: np.ndarray, scaling: csc_matrix, g_dscaling: csc_matrix, delta: float, theta: float, ...
Compute new proposal steps according to a truncation strategy. :param tr_step: Reference trust region step that will be reflect :param x: Current values of the optimization variables :param sg: Rescaled objective function gradient at x :param hess: (Approximate) obj...
Compute new proposal steps according to a truncation strategy.
[ "Compute", "new", "proposal", "steps", "according", "to", "a", "truncation", "strategy", "." ]
def stepback_truncate(tr_step: Step, x: np.ndarray, sg: np.ndarray, hess: np.ndarray, scaling: csc_matrix, g_dscaling: csc_matrix, delta: float, theta: float, ...
[ "def", "stepback_truncate", "(", "tr_step", ":", "Step", ",", "x", ":", "np", ".", "ndarray", ",", "sg", ":", "np", ".", "ndarray", ",", "hess", ":", "np", ".", "ndarray", ",", "scaling", ":", "csc_matrix", ",", "g_dscaling", ":", "csc_matrix", ",", ...
Compute new proposal steps according to a truncation strategy.
[ "Compute", "new", "proposal", "steps", "according", "to", "a", "truncation", "strategy", "." ]
[ "\"\"\"\n Compute new proposal steps according to a truncation strategy.\n\n :param tr_step:\n Reference trust region step that will be reflect\n :param x:\n Current values of the optimization variables\n :param sg:\n Rescaled objective function gradient at x\n :param hess:\n ...
[ { "param": "tr_step", "type": "Step" }, { "param": "x", "type": "np.ndarray" }, { "param": "sg", "type": "np.ndarray" }, { "param": "hess", "type": "np.ndarray" }, { "param": "scaling", "type": "csc_matrix" }, { "param": "g_dscaling", "type": "csc_...
{ "returns": [ { "docstring": "New proposal steps", "docstring_tokens": [ "New", "proposal", "steps" ], "type": null } ], "raises": [], "params": [ { "identifier": "tr_step", "type": "Step", "docstring": "Reference trust region step t...
be78036e058d0877ee5fe7f9599c7a713b9b10c7
dweindl/fides
fides/stepback.py
[ "BSD-3-Clause" ]
Python
stepback_refine
List[Step]
def stepback_refine(steps: Sequence[Step], x: np.ndarray, sg: np.ndarray, hess: np.ndarray, scaling: csc_matrix, g_dscaling: csc_matrix, delta: float, theta: float, ...
Refine a promising subset of the provided steps based on trust-constr optimization :param steps: Reference trust region step that will be reflect :param x: Current values of the optimization variables :param sg: Rescaled objective function gradient at x :param hess: ...
Refine a promising subset of the provided steps based on trust-constr optimization
[ "Refine", "a", "promising", "subset", "of", "the", "provided", "steps", "based", "on", "trust", "-", "constr", "optimization" ]
def stepback_refine(steps: Sequence[Step], x: np.ndarray, sg: np.ndarray, hess: np.ndarray, scaling: csc_matrix, g_dscaling: csc_matrix, delta: float, theta: float, ...
[ "def", "stepback_refine", "(", "steps", ":", "Sequence", "[", "Step", "]", ",", "x", ":", "np", ".", "ndarray", ",", "sg", ":", "np", ".", "ndarray", ",", "hess", ":", "np", ".", "ndarray", ",", "scaling", ":", "csc_matrix", ",", "g_dscaling", ":", ...
Refine a promising subset of the provided steps based on trust-constr optimization
[ "Refine", "a", "promising", "subset", "of", "the", "provided", "steps", "based", "on", "trust", "-", "constr", "optimization" ]
[ "\"\"\"\n Refine a promising subset of the provided steps based on trust-constr\n optimization\n\n :param steps:\n Reference trust region step that will be reflect\n :param x:\n Current values of the optimization variables\n :param sg:\n Rescaled objective function gradient at x\...
[ { "param": "steps", "type": "Sequence[Step]" }, { "param": "x", "type": "np.ndarray" }, { "param": "sg", "type": "np.ndarray" }, { "param": "hess", "type": "np.ndarray" }, { "param": "scaling", "type": "csc_matrix" }, { "param": "g_dscaling", "type...
{ "returns": [ { "docstring": "New proposal steps", "docstring_tokens": [ "New", "proposal", "steps" ], "type": null } ], "raises": [], "params": [ { "identifier": "steps", "type": "Sequence[Step]", "docstring": "Reference trust regio...
5bb7efa78ec4e44815228e61ffa1eb37105edf68
dweindl/fides
fides/hessian_approximation.py
[ "BSD-3-Clause" ]
Python
init_mat
null
def init_mat(self, dim: int): """ Initializes this approximation instance and checks the dimensionality :param dim: dimension of optimization variables """ if self.hess_init is None: self._hess = np.eye(dim) else: self._hess = self.hes...
Initializes this approximation instance and checks the dimensionality :param dim: dimension of optimization variables
Initializes this approximation instance and checks the dimensionality
[ "Initializes", "this", "approximation", "instance", "and", "checks", "the", "dimensionality" ]
def init_mat(self, dim: int): if self.hess_init is None: self._hess = np.eye(dim) else: self._hess = self.hess_init.copy() if self._hess.shape[0] != dim: raise ValueError('Initial approximation had inconsistent ' f'dime...
[ "def", "init_mat", "(", "self", ",", "dim", ":", "int", ")", ":", "if", "self", ".", "hess_init", "is", "None", ":", "self", ".", "_hess", "=", "np", ".", "eye", "(", "dim", ")", "else", ":", "self", ".", "_hess", "=", "self", ".", "hess_init", ...
Initializes this approximation instance and checks the dimensionality
[ "Initializes", "this", "approximation", "instance", "and", "checks", "the", "dimensionality" ]
[ "\"\"\"\n Initializes this approximation instance and checks the dimensionality\n\n :param dim:\n dimension of optimization variables\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "dim", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "dim", "type": "int", "docstring": "dimension of optimization variab...
550fe3f14bf36c4d2229f24dcf796503790650b2
dweindl/fides
fides/trust_region.py
[ "BSD-3-Clause" ]
Python
trust_region
Step
def trust_region(x: np.ndarray, g: np.ndarray, hess: np.ndarray, scaling: csc_matrix, delta: float, dv: np.ndarray, theta: float, lb: np.ndarray, ub: np.ndarray, subsp...
Compute a step according to the solution of the trust-region subproblem. If step-back is necessary, gradient and reflected trust region step are also evaluated in terms of their performance according to the local quadratic approximation :param x: Current values of the optimization variable...
Compute a step according to the solution of the trust-region subproblem. If step-back is necessary, gradient and reflected trust region step are also evaluated in terms of their performance according to the local quadratic approximation
[ "Compute", "a", "step", "according", "to", "the", "solution", "of", "the", "trust", "-", "region", "subproblem", ".", "If", "step", "-", "back", "is", "necessary", "gradient", "and", "reflected", "trust", "region", "step", "are", "also", "evaluated", "in", ...
def trust_region(x: np.ndarray, g: np.ndarray, hess: np.ndarray, scaling: csc_matrix, delta: float, dv: np.ndarray, theta: float, lb: np.ndarray, ub: np.ndarray, subsp...
[ "def", "trust_region", "(", "x", ":", "np", ".", "ndarray", ",", "g", ":", "np", ".", "ndarray", ",", "hess", ":", "np", ".", "ndarray", ",", "scaling", ":", "csc_matrix", ",", "delta", ":", "float", ",", "dv", ":", "np", ".", "ndarray", ",", "th...
Compute a step according to the solution of the trust-region subproblem.
[ "Compute", "a", "step", "according", "to", "the", "solution", "of", "the", "trust", "-", "region", "subproblem", "." ]
[ "\"\"\"\n Compute a step according to the solution of the trust-region subproblem.\n If step-back is necessary, gradient and reflected trust region step are\n also evaluated in terms of their performance according to the local\n quadratic approximation\n\n :param x:\n Current values of the opt...
[ { "param": "x", "type": "np.ndarray" }, { "param": "g", "type": "np.ndarray" }, { "param": "hess", "type": "np.ndarray" }, { "param": "scaling", "type": "csc_matrix" }, { "param": "delta", "type": "float" }, { "param": "dv", "type": "np.ndarray" ...
{ "returns": [ { "docstring": "proposed step,\nss: rescaled proposed step,\nqpval: expected function value according to local quadratic\napproximation,\nsubspace: computed subspace for reuse if proposed step is not accepted,\nsteptype: type of step that was selected for proposal", "docstring_tokens": ...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
track_minimum
None
def track_minimum(self, x_new: np.ndarray, fval_new: float, grad_new: np.ndarray) -> None: """ Function that tracks the optimization variables that have minimal function value independent of whether the step is accepted or not. ...
Function that tracks the optimization variables that have minimal function value independent of whether the step is accepted or not. :param x_new: :param fval_new: :param grad_new: :return:
Function that tracks the optimization variables that have minimal function value independent of whether the step is accepted or not.
[ "Function", "that", "tracks", "the", "optimization", "variables", "that", "have", "minimal", "function", "value", "independent", "of", "whether", "the", "step", "is", "accepted", "or", "not", "." ]
def track_minimum(self, x_new: np.ndarray, fval_new: float, grad_new: np.ndarray) -> None: if np.isfinite(fval_new) and fval_new < self.fval_min: self.x_min = x_new self.fval_min = fval_new self.grad_min = grad...
[ "def", "track_minimum", "(", "self", ",", "x_new", ":", "np", ".", "ndarray", ",", "fval_new", ":", "float", ",", "grad_new", ":", "np", ".", "ndarray", ")", "->", "None", ":", "if", "np", ".", "isfinite", "(", "fval_new", ")", "and", "fval_new", "<"...
Function that tracks the optimization variables that have minimal function value independent of whether the step is accepted or not.
[ "Function", "that", "tracks", "the", "optimization", "variables", "that", "have", "minimal", "function", "value", "independent", "of", "whether", "the", "step", "is", "accepted", "or", "not", "." ]
[ "\"\"\"\n Function that tracks the optimization variables that have minimal\n function value independent of whether the step is accepted or not.\n\n :param x_new:\n :param fval_new:\n :param grad_new:\n :return:\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x_new", "type": "np.ndarray" }, { "param": "fval_new", "type": "float" }, { "param": "grad_new", "type": "np.ndarray" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null ...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
update
None
def update(self, step: Step, x_new: np.ndarray, fval_new: float, grad_new: np.ndarray, hess_new: Optional[np.ndarray] = None) -> None: """ Update self according to employed step :param step: Employed step ...
Update self according to employed step :param step: Employed step :param x_new: New optimization variable values :param fval_new: Objective function value at x_new :param grad_new: Objective function gradient at x_new :par...
Update self according to employed step
[ "Update", "self", "according", "to", "employed", "step" ]
def update(self, step: Step, x_new: np.ndarray, fval_new: float, grad_new: np.ndarray, hess_new: Optional[np.ndarray] = None) -> None: if self.hessian_update is not None: self.hessian_update.update(step.s + step.s0, ...
[ "def", "update", "(", "self", ",", "step", ":", "Step", ",", "x_new", ":", "np", ".", "ndarray", ",", "fval_new", ":", "float", ",", "grad_new", ":", "np", ".", "ndarray", ",", "hess_new", ":", "Optional", "[", "np", ".", "ndarray", "]", "=", "None...
Update self according to employed step
[ "Update", "self", "according", "to", "employed", "step" ]
[ "\"\"\"\n Update self according to employed step\n\n :param step:\n Employed step\n :param x_new:\n New optimization variable values\n :param fval_new:\n Objective function value at x_new\n :param grad_new:\n Objective function gradient ...
[ { "param": "self", "type": null }, { "param": "step", "type": "Step" }, { "param": "x_new", "type": "np.ndarray" }, { "param": "fval_new", "type": "float" }, { "param": "grad_new", "type": "np.ndarray" }, { "param": "hess_new", "type": "Optional[np...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "step", "type": "Step", "docstring": null, "docstring_tokens":...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
check_convergence
None
def check_convergence(self, step: Step, fval: float, grad: np.ndarray) -> None: """ Check whether optimization has converged. :param step: update to optimization variables :param fval: updated objective function value :param gr...
Check whether optimization has converged. :param step: update to optimization variables :param fval: updated objective function value :param grad: updated objective function gradient
Check whether optimization has converged.
[ "Check", "whether", "optimization", "has", "converged", "." ]
def check_convergence(self, step: Step, fval: float, grad: np.ndarray) -> None: converged = False fatol = self.get_option(Options.FATOL) frtol = self.get_option(Options.FRTOL) xtol = self.get_option(Options.XTOL) gatol = self.get_option(Options.GATOL) ...
[ "def", "check_convergence", "(", "self", ",", "step", ":", "Step", ",", "fval", ":", "float", ",", "grad", ":", "np", ".", "ndarray", ")", "->", "None", ":", "converged", "=", "False", "fatol", "=", "self", ".", "get_option", "(", "Options", ".", "FA...
Check whether optimization has converged.
[ "Check", "whether", "optimization", "has", "converged", "." ]
[ "\"\"\"\n Check whether optimization has converged.\n\n :param step:\n update to optimization variables\n\n :param fval:\n updated objective function value\n\n :param grad:\n updated objective function gradient\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "step", "type": "Step" }, { "param": "fval", "type": "float" }, { "param": "grad", "type": "np.ndarray" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "step", "type": "Step", "docstring": "update to optimization variabl...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
check_continue
bool
def check_continue(self) -> bool: """ Checks whether minimization should continue based on convergence, iteration count and remaining computational budget :return: flag indicating whether minimization should continue """ if self.converged: return...
Checks whether minimization should continue based on convergence, iteration count and remaining computational budget :return: flag indicating whether minimization should continue
Checks whether minimization should continue based on convergence, iteration count and remaining computational budget
[ "Checks", "whether", "minimization", "should", "continue", "based", "on", "convergence", "iteration", "count", "and", "remaining", "computational", "budget" ]
def check_continue(self) -> bool: if self.converged: return False maxiter = self.get_option(Options.MAXITER) if self.iteration >= maxiter: self.exitflag = ExitFlag.MAXITER self.logger.warning( f'Stopping as maximum number of iterations {maxiter...
[ "def", "check_continue", "(", "self", ")", "->", "bool", ":", "if", "self", ".", "converged", ":", "return", "False", "maxiter", "=", "self", ".", "get_option", "(", "Options", ".", "MAXITER", ")", "if", "self", ".", "iteration", ">=", "maxiter", ":", ...
Checks whether minimization should continue based on convergence, iteration count and remaining computational budget
[ "Checks", "whether", "minimization", "should", "continue", "based", "on", "convergence", "iteration", "count", "and", "remaining", "computational", "budget" ]
[ "\"\"\"\n Checks whether minimization should continue based on convergence,\n iteration count and remaining computational budget\n\n :return:\n flag indicating whether minimization should continue\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [ { "docstring": "flag indicating whether minimization should continue", "docstring_tokens": [ "flag", "indicating", "whether", "minimization", "should", "continue" ], "type": null } ], "raises": [], "params": [ { ...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
make_non_degenerate
None
def make_non_degenerate(self, eps=1e2 * np.spacing(1)) -> None: """ Ensures that x is non-degenerate, this should only be necessary for initial points. :param eps: degeneracy threshold """ if np.min(np.abs(self.ub - self.x)) < eps or \ np.min(np.abs(self....
Ensures that x is non-degenerate, this should only be necessary for initial points. :param eps: degeneracy threshold
Ensures that x is non-degenerate, this should only be necessary for initial points.
[ "Ensures", "that", "x", "is", "non", "-", "degenerate", "this", "should", "only", "be", "necessary", "for", "initial", "points", "." ]
def make_non_degenerate(self, eps=1e2 * np.spacing(1)) -> None: if np.min(np.abs(self.ub - self.x)) < eps or \ np.min(np.abs(self.x - self.lb)) < eps: upperi = (self.ub - self.x) < eps loweri = (self.x - self.lb) < eps self.x[upperi] = self.x[upperi] - eps ...
[ "def", "make_non_degenerate", "(", "self", ",", "eps", "=", "1e2", "*", "np", ".", "spacing", "(", "1", ")", ")", "->", "None", ":", "if", "np", ".", "min", "(", "np", ".", "abs", "(", "self", ".", "ub", "-", "self", ".", "x", ")", ")", "<", ...
Ensures that x is non-degenerate, this should only be necessary for initial points.
[ "Ensures", "that", "x", "is", "non", "-", "degenerate", "this", "should", "only", "be", "necessary", "for", "initial", "points", "." ]
[ "\"\"\"\n Ensures that x is non-degenerate, this should only be necessary for\n initial points.\n\n :param eps: degeneracy threshold\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "eps", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "eps", "type": null, "docstring": null, "docstring_tokens": [ ...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
log_step
null
def log_step(self, accepted: bool, step: Step, fval: float): """ Prints diagnostic information about the current step to the log :param accepted: flag indicating whether the current step was accepted :param step: proposal step :param fval: new...
Prints diagnostic information about the current step to the log :param accepted: flag indicating whether the current step was accepted :param step: proposal step :param fval: new fval if step is accepted
Prints diagnostic information about the current step to the log
[ "Prints", "diagnostic", "information", "about", "the", "current", "step", "to", "the", "log" ]
def log_step(self, accepted: bool, step: Step, fval: float): normdx = norm(step.s + step.s0) iterspaces = max(len(str(self.get_option(Options.MAXITER))), 5) - \ len(str(self.iteration)) steptypespaces = 4 - len(step.type) reflspaces, trunspaces = [ 4 - len(str(cou...
[ "def", "log_step", "(", "self", ",", "accepted", ":", "bool", ",", "step", ":", "Step", ",", "fval", ":", "float", ")", ":", "normdx", "=", "norm", "(", "step", ".", "s", "+", "step", ".", "s0", ")", "iterspaces", "=", "max", "(", "len", "(", "...
Prints diagnostic information about the current step to the log
[ "Prints", "diagnostic", "information", "about", "the", "current", "step", "to", "the", "log" ]
[ "\"\"\"\n Prints diagnostic information about the current step to the log\n\n :param accepted:\n flag indicating whether the current step was accepted\n :param step:\n proposal step\n :param fval:\n new fval if step is accepted\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "accepted", "type": "bool" }, { "param": "step", "type": "Step" }, { "param": "fval", "type": "float" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "accepted", "type": "bool", "docstring": "flag indicating whether th...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
log_step_initial
null
def log_step_initial(self): """ Prints diagnostic information about the initial step to the log """ iterspaces = max(len(str(self.get_option(Options.MAXITER))), 5) - \ len(str(self.iteration)) self.logger.info( f'{" " * iterspaces}{self.iteration}' ...
Prints diagnostic information about the initial step to the log
Prints diagnostic information about the initial step to the log
[ "Prints", "diagnostic", "information", "about", "the", "initial", "step", "to", "the", "log" ]
def log_step_initial(self): iterspaces = max(len(str(self.get_option(Options.MAXITER))), 5) - \ len(str(self.iteration)) self.logger.info( f'{" " * iterspaces}{self.iteration}' f' | {self.fval:+.3E}' f' | NaN ' f' | NaN ' ...
[ "def", "log_step_initial", "(", "self", ")", ":", "iterspaces", "=", "max", "(", "len", "(", "str", "(", "self", ".", "get_option", "(", "Options", ".", "MAXITER", ")", ")", ")", ",", "5", ")", "-", "len", "(", "str", "(", "self", ".", "iteration",...
Prints diagnostic information about the initial step to the log
[ "Prints", "diagnostic", "information", "about", "the", "initial", "step", "to", "the", "log" ]
[ "\"\"\"\n Prints diagnostic information about the initial step to the log\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
log_header
null
def log_header(self): """ Prints the header for diagnostic information, should complement :py:func:`Optimizer.log_step`. """ iterspaces = len(str(self.get_option(Options.MAXITER))) - 5 self.logger.info( f'{" " * iterspaces} iter ' f'| fval |...
Prints the header for diagnostic information, should complement :py:func:`Optimizer.log_step`.
Prints the header for diagnostic information, should complement
[ "Prints", "the", "header", "for", "diagnostic", "information", "should", "complement" ]
def log_header(self): iterspaces = len(str(self.get_option(Options.MAXITER))) - 5 self.logger.info( f'{" " * iterspaces} iter ' f'| fval | fval diff | pred diff | tr ratio ' f'| delta | ||g|| | ||step|| | theta | alpha ' f'| step | refl ...
[ "def", "log_header", "(", "self", ")", ":", "iterspaces", "=", "len", "(", "str", "(", "self", ".", "get_option", "(", "Options", ".", "MAXITER", ")", ")", ")", "-", "5", "self", ".", "logger", ".", "info", "(", "f'{\" \" * iterspaces} iter '", "f'| f...
Prints the header for diagnostic information, should complement
[ "Prints", "the", "header", "for", "diagnostic", "information", "should", "complement" ]
[ "\"\"\"\n Prints the header for diagnostic information, should complement\n :py:func:`Optimizer.log_step`.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [ { "identifier": "py", "docstring": null, "...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
check_finite
null
def check_finite(self, grad: Optional[np.ndarray] = None, hess: Optional[np.ndarray] = None): """ Checks whether objective function value, gradient and Hessian ( approximation) have finite values and optimization can continue. :param grad: ...
Checks whether objective function value, gradient and Hessian ( approximation) have finite values and optimization can continue. :param grad: gradient to be checked for finiteness, if not provided, current one will be checked :param hess: Hessian (a...
Checks whether objective function value, gradient and Hessian ( approximation) have finite values and optimization can continue.
[ "Checks", "whether", "objective", "function", "value", "gradient", "and", "Hessian", "(", "approximation", ")", "have", "finite", "values", "and", "optimization", "can", "continue", "." ]
def check_finite(self, grad: Optional[np.ndarray] = None, hess: Optional[np.ndarray] = None): if self.iteration == 0: pointstr = 'at initial point.' else: pointstr = f'at iteration {self.iteration}.' if grad is None: g...
[ "def", "check_finite", "(", "self", ",", "grad", ":", "Optional", "[", "np", ".", "ndarray", "]", "=", "None", ",", "hess", ":", "Optional", "[", "np", ".", "ndarray", "]", "=", "None", ")", ":", "if", "self", ".", "iteration", "==", "0", ":", "p...
Checks whether objective function value, gradient and Hessian ( approximation) have finite values and optimization can continue.
[ "Checks", "whether", "objective", "function", "value", "gradient", "and", "Hessian", "(", "approximation", ")", "have", "finite", "values", "and", "optimization", "can", "continue", "." ]
[ "\"\"\"\n Checks whether objective function value, gradient and Hessian (\n approximation) have finite values and optimization can continue.\n\n :param grad:\n gradient to be checked for finiteness, if not provided, current\n one will be checked\n\n :param hess:\n ...
[ { "param": "self", "type": null }, { "param": "grad", "type": "Optional[np.ndarray]" }, { "param": "hess", "type": "Optional[np.ndarray]" } ]
{ "returns": [], "raises": [ { "docstring": "RuntimeError if any of the variables have non-finite entries", "docstring_tokens": [ "RuntimeError", "if", "any", "of", "the", "variables", "have", "non", "-", "finite", ...
434a1c51dc4d9a4d576e5e297ed8b95bfadbb171
dweindl/fides
fides/minimize.py
[ "BSD-3-Clause" ]
Python
check_in_bounds
null
def check_in_bounds(self, x: Optional[np.ndarray] = None): """ Checks whether the current optimization variables are all within the specified boundaries :raises: RuntimeError if any of the variables are not within boundaries """ if x is None: x = ...
Checks whether the current optimization variables are all within the specified boundaries :raises: RuntimeError if any of the variables are not within boundaries
Checks whether the current optimization variables are all within the specified boundaries
[ "Checks", "whether", "the", "current", "optimization", "variables", "are", "all", "within", "the", "specified", "boundaries" ]
def check_in_bounds(self, x: Optional[np.ndarray] = None): if x is None: x = self.x if self.iteration == 0: pointstr = 'at initial point.' else: pointstr = f'at iteration {self.iteration}.' for ref, sign, name in zip([self.ub, self.lb], ...
[ "def", "check_in_bounds", "(", "self", ",", "x", ":", "Optional", "[", "np", ".", "ndarray", "]", "=", "None", ")", ":", "if", "x", "is", "None", ":", "x", "=", "self", ".", "x", "if", "self", ".", "iteration", "==", "0", ":", "pointstr", "=", ...
Checks whether the current optimization variables are all within the specified boundaries
[ "Checks", "whether", "the", "current", "optimization", "variables", "are", "all", "within", "the", "specified", "boundaries" ]
[ "\"\"\"\n Checks whether the current optimization variables are all within the\n specified boundaries\n\n :raises:\n RuntimeError if any of the variables are not within boundaries\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "x", "type": "Optional[np.ndarray]" } ]
{ "returns": [], "raises": [ { "docstring": "RuntimeError if any of the variables are not within boundaries", "docstring_tokens": [ "RuntimeError", "if", "any", "of", "the", "variables", "are", "not", "within", "boundari...
4d3eeaf685f301cc755ae1842b45344db6b8a51d
dweindl/fides
fides/logging.py
[ "BSD-3-Clause" ]
Python
create_logger
logging.Logger
def create_logger(level: int) -> logging.Logger: """ Creates a logger instance. To avoid unnecessary locks during multithreading, different logger instance should be created for every :param level: logging level :return: logger instance """ global logger_count logger_co...
Creates a logger instance. To avoid unnecessary locks during multithreading, different logger instance should be created for every :param level: logging level :return: logger instance
Creates a logger instance. To avoid unnecessary locks during multithreading, different logger instance should be created for every
[ "Creates", "a", "logger", "instance", ".", "To", "avoid", "unnecessary", "locks", "during", "multithreading", "different", "logger", "instance", "should", "be", "created", "for", "every" ]
def create_logger(level: int) -> logging.Logger: global logger_count logger_count += 1 logger = logging.getLogger(f'fides_{logger_count}') ch = logging.StreamHandler() formatter = logging.Formatter( '%(asctime)s - fides - %(levelname)s - %(message)s' ) ch.setFormatter(formatter) ...
[ "def", "create_logger", "(", "level", ":", "int", ")", "->", "logging", ".", "Logger", ":", "global", "logger_count", "logger_count", "+=", "1", "logger", "=", "logging", ".", "getLogger", "(", "f'fides_{logger_count}'", ")", "ch", "=", "logging", ".", "Stre...
Creates a logger instance.
[ "Creates", "a", "logger", "instance", "." ]
[ "\"\"\"\n Creates a logger instance. To avoid unnecessary locks during\n multithreading, different logger instance should be created for every\n\n :param level:\n logging level\n\n :return:\n logger instance\n \"\"\"", "# add logger count to differentiate between different fides", "...
[ { "param": "level", "type": "int" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "level", "type": "int", "docstring": null, "docstring_tokens": [ "None" ], "default": null, ...
2b8e031f931e2339538d029cb74ef1d19bf91934
dweindl/fides
tests/test_subproblem.py
[ "BSD-3-Clause" ]
Python
is_local_quad_min
<not_specific>
def is_local_quad_min(s, B, g): """ make local perturbations to verify s is a local minimum of quad(s, B, g) """ _, ev = linalg.eig(B) perturbs = np.array([ quad(s + eps*ev[:, iv], B, g) for iv in range(ev.shape[1]) for eps in [1e-2, -1e-2] ]) return np.all((perturbs ...
make local perturbations to verify s is a local minimum of quad(s, B, g)
make local perturbations to verify s is a local minimum of quad(s, B, g)
[ "make", "local", "perturbations", "to", "verify", "s", "is", "a", "local", "minimum", "of", "quad", "(", "s", "B", "g", ")" ]
def is_local_quad_min(s, B, g): _, ev = linalg.eig(B) perturbs = np.array([ quad(s + eps*ev[:, iv], B, g) for iv in range(ev.shape[1]) for eps in [1e-2, -1e-2] ]) return np.all((perturbs - quad(s, B, g)) > 0)
[ "def", "is_local_quad_min", "(", "s", ",", "B", ",", "g", ")", ":", "_", ",", "ev", "=", "linalg", ".", "eig", "(", "B", ")", "perturbs", "=", "np", ".", "array", "(", "[", "quad", "(", "s", "+", "eps", "*", "ev", "[", ":", ",", "iv", "]", ...
make local perturbations to verify s is a local minimum of quad(s, B, g)
[ "make", "local", "perturbations", "to", "verify", "s", "is", "a", "local", "minimum", "of", "quad", "(", "s", "B", "g", ")" ]
[ "\"\"\"\n make local perturbations to verify s is a local minimum of quad(s, B, g)\n \"\"\"" ]
[ { "param": "s", "type": null }, { "param": "B", "type": null }, { "param": "g", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "B", "type": null, "docstring": null, "docstring_tokens": [], ...
1907acc366ea1368948d32302fd60bfd153cc8aa
dweindl/fides
fides/subproblem.py
[ "BSD-3-Clause" ]
Python
solve_1d_trust_region_subproblem
np.ndarray
def solve_1d_trust_region_subproblem(B: np.ndarray, g: np.ndarray, s: np.ndarray, delta: float, s0: np.ndarray) -> np.ndarray: """ Solves the special case of a one-...
Solves the special case of a one-dimensional subproblem :param B: Hessian of the quadratic subproblem :param g: Gradient of the quadratic subproblem :param s: Vector defining the one-dimensional search direction :param delta: Norm boundary for the solution of the qu...
Solves the special case of a one-dimensional subproblem
[ "Solves", "the", "special", "case", "of", "a", "one", "-", "dimensional", "subproblem" ]
def solve_1d_trust_region_subproblem(B: np.ndarray, g: np.ndarray, s: np.ndarray, delta: float, s0: np.ndarray) -> np.ndarray: if delta == 0.0: return delta * n...
[ "def", "solve_1d_trust_region_subproblem", "(", "B", ":", "np", ".", "ndarray", ",", "g", ":", "np", ".", "ndarray", ",", "s", ":", "np", ".", "ndarray", ",", "delta", ":", "float", ",", "s0", ":", "np", ".", "ndarray", ")", "->", "np", ".", "ndarr...
Solves the special case of a one-dimensional subproblem
[ "Solves", "the", "special", "case", "of", "a", "one", "-", "dimensional", "subproblem" ]
[ "\"\"\"\n Solves the special case of a one-dimensional subproblem\n\n :param B:\n Hessian of the quadratic subproblem\n :param g:\n Gradient of the quadratic subproblem\n :param s:\n Vector defining the one-dimensional search direction\n :param delta:\n Norm boundary for t...
[ { "param": "B", "type": "np.ndarray" }, { "param": "g", "type": "np.ndarray" }, { "param": "s", "type": "np.ndarray" }, { "param": "delta", "type": "float" }, { "param": "s0", "type": "np.ndarray" } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [ { "identifier": "B", "type": "np.ndarray", "docstring": "Hessian of the quadratic subproblem", "docstring_tokens": [ "Hessia...
e5f2361479fbd51aaa76f53e7992319c0b2b5706
charnley/optimize_gamess_parameters
bin/nodes.py
[ "MIT" ]
Python
terminate
<not_specific>
def terminate(slaves): """ Terminate slave process if they are still on """ [proc.terminate() for proc in slaves] return
Terminate slave process if they are still on
Terminate slave process if they are still on
[ "Terminate", "slave", "process", "if", "they", "are", "still", "on" ]
def terminate(slaves): [proc.terminate() for proc in slaves] return
[ "def", "terminate", "(", "slaves", ")", ":", "[", "proc", ".", "terminate", "(", ")", "for", "proc", "in", "slaves", "]", "return" ]
Terminate slave process if they are still on
[ "Terminate", "slave", "process", "if", "they", "are", "still", "on" ]
[ "\"\"\" Terminate slave process if they are still on\n \"\"\"" ]
[ { "param": "slaves", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "slaves", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
cab88485243f5b624c12e078d8b20fd9a3aae8d1
xuecan/ganggu
ganggu/forms.py
[ "MIT" ]
Python
html_params
<not_specific>
def html_params(**kwargs): """ Generate HTML parameters from inputted keyword arguments. """ params = [] for k, v in sorted(iteritems(kwargs)): if k.endswith("_"): k = k[:-1] elif k.endswith("__"): k = k[:-2] else: k = k.replace("_", "-") ...
Generate HTML parameters from inputted keyword arguments.
Generate HTML parameters from inputted keyword arguments.
[ "Generate", "HTML", "parameters", "from", "inputted", "keyword", "arguments", "." ]
def html_params(**kwargs): params = [] for k, v in sorted(iteritems(kwargs)): if k.endswith("_"): k = k[:-1] elif k.endswith("__"): k = k[:-2] else: k = k.replace("_", "-") if v is True: params.append(k) elif v is False: ...
[ "def", "html_params", "(", "**", "kwargs", ")", ":", "params", "=", "[", "]", "for", "k", ",", "v", "in", "sorted", "(", "iteritems", "(", "kwargs", ")", ")", ":", "if", "k", ".", "endswith", "(", "\"_\"", ")", ":", "k", "=", "k", "[", ":", "...
Generate HTML parameters from inputted keyword arguments.
[ "Generate", "HTML", "parameters", "from", "inputted", "keyword", "arguments", "." ]
[ "\"\"\"\n Generate HTML parameters from inputted keyword arguments.\n \"\"\"", "# PATCH HERE: data_custom => data-custom" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
4bbdecac431688b40bf237871868b89cff3ce856
xuecan/ganggu
ganggu/httpkit.py
[ "MIT" ]
Python
request
<not_specific>
def request(self, method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None, json=None): """Constructs and sends an HTTP request. ...
Constructs and sends an HTTP request. Args: method (str): Method for the request. url (str|callable): URL for the request. Or a callable should return the URL. params (bytes|dict): Dictionary or bytes to be sent in the query ...
Constructs and sends an HTTP request.
[ "Constructs", "and", "sends", "an", "HTTP", "request", "." ]
def request(self, method, url, params=None, data=None, headers=None, cookies=None, files=None, auth=None, timeout=None, allow_redirects=True, proxies=None, hooks=None, stream=None, verify=None, cert=None, json=None): if not timeout: timeout = TIMEOUT ...
[ "def", "request", "(", "self", ",", "method", ",", "url", ",", "params", "=", "None", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "cookies", "=", "None", ",", "files", "=", "None", ",", "auth", "=", "None", ",", "timeout", "=", "N...
Constructs and sends an HTTP request.
[ "Constructs", "and", "sends", "an", "HTTP", "request", "." ]
[ "\"\"\"Constructs and sends an HTTP request.\n\n Args:\n method (str): Method for the request.\n url (str|callable): URL for the request. Or a callable should return\n the URL.\n params (bytes|dict): Dictionary or bytes to be sent in the query\n...
[ { "param": "self", "type": null }, { "param": "method", "type": null }, { "param": "url", "type": null }, { "param": "params", "type": null }, { "param": "data", "type": null }, { "param": "headers", "type": null }, { "param": "cookies", ...
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "requests.Response" } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_opt...
4bbdecac431688b40bf237871868b89cff3ce856
xuecan/ganggu
ganggu/httpkit.py
[ "MIT" ]
Python
request
<not_specific>
def request(method, url, **kwargs): """Constructs and sends an HTTP request. Args: method (str): Method for the request. url (str|callable): URL for the request. Or a callable should return the URL. \*\*kwargs: Optional arguments that ``Session.request()`` ta...
Constructs and sends an HTTP request. Args: method (str): Method for the request. url (str|callable): URL for the request. Or a callable should return the URL. \*\*kwargs: Optional arguments that ``Session.request()`` takes. Returns: requests.Respons...
Constructs and sends an HTTP request.
[ "Constructs", "and", "sends", "an", "HTTP", "request", "." ]
def request(method, url, **kwargs): with Session() as session: return session.request(method, url, **kwargs)
[ "def", "request", "(", "method", ",", "url", ",", "**", "kwargs", ")", ":", "with", "Session", "(", ")", "as", "session", ":", "return", "session", ".", "request", "(", "method", ",", "url", ",", "**", "kwargs", ")" ]
Constructs and sends an HTTP request.
[ "Constructs", "and", "sends", "an", "HTTP", "request", "." ]
[ "\"\"\"Constructs and sends an HTTP request.\n\n Args:\n method (str): Method for the request.\n url (str|callable): URL for the request. Or a callable should return\n the URL.\n \\*\\*kwargs: Optional arguments that ``Session.request()`` takes.\n\n Returns:\n ...
[ { "param": "method", "type": null }, { "param": "url", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "requests.Response" } ], "raises": [], "params": [ { "identifier": "method", "type": null, "docstring": "Method for the request.", "docstring_tokens": [ "Method...
bcf73818eaed2c33e7e0ed98dba80cae7fb705f2
cloudrainstar/efai_clock
apollo.py
[ "MIT" ]
Python
work_day_query
<not_specific>
def work_day_query(self): """Look up today's date on the schedule to see if it is a work day. Requires login.""" if self.logged_in: self.browser.get(URL_SCHEDULE) delay = 30 # seconds try: _ = WebDriverWait(self.browser, delay).until( ...
Look up today's date on the schedule to see if it is a work day. Requires login.
Look up today's date on the schedule to see if it is a work day. Requires login.
[ "Look", "up", "today", "'", "s", "date", "on", "the", "schedule", "to", "see", "if", "it", "is", "a", "work", "day", ".", "Requires", "login", "." ]
def work_day_query(self): if self.logged_in: self.browser.get(URL_SCHEDULE) delay = 30 try: _ = WebDriverWait(self.browser, delay).until( EC.presence_of_element_located( (By.CLASS_NAME, "schedule-info__time") ...
[ "def", "work_day_query", "(", "self", ")", ":", "if", "self", ".", "logged_in", ":", "self", ".", "browser", ".", "get", "(", "URL_SCHEDULE", ")", "delay", "=", "30", "try", ":", "_", "=", "WebDriverWait", "(", "self", ".", "browser", ",", "delay", "...
Look up today's date on the schedule to see if it is a work day.
[ "Look", "up", "today", "'", "s", "date", "on", "the", "schedule", "to", "see", "if", "it", "is", "a", "work", "day", "." ]
[ "\"\"\"Look up today's date on the schedule to see if it is a work day. Requires login.\"\"\"", "# seconds" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a58e51cf1119307431b8c84860dcfbf197c70a63
cloudrainstar/efai_clock
run.py
[ "MIT" ]
Python
login
null
def login(update, context): """Command handler: /login <username> <password> - save login to database.""" logging.info(f"Command: /login triggered by {update.effective_chat.id}") if len(context.args) != 2: context.bot.send_message( chat_id=update.effective_chat.id, text="Not ...
Command handler: /login <username> <password> - save login to database.
Command handler: /login - save login to database.
[ "Command", "handler", ":", "/", "login", "-", "save", "login", "to", "database", "." ]
def login(update, context): logging.info(f"Command: /login triggered by {update.effective_chat.id}") if len(context.args) != 2: context.bot.send_message( chat_id=update.effective_chat.id, text="Not enough or too many parameters, I need both usernamae and password.", ) ...
[ "def", "login", "(", "update", ",", "context", ")", ":", "logging", ".", "info", "(", "f\"Command: /login triggered by {update.effective_chat.id}\"", ")", "if", "len", "(", "context", ".", "args", ")", "!=", "2", ":", "context", ".", "bot", ".", "send_message"...
Command handler: /login <username> <password> - save login to database.
[ "Command", "handler", ":", "/", "login", "<username", ">", "<password", ">", "-", "save", "login", "to", "database", "." ]
[ "\"\"\"Command handler: /login <username> <password> - save login to database.\"\"\"" ]
[ { "param": "update", "type": null }, { "param": "context", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "update", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "context", "type": null, "docstring": null, "docstring_token...
a58e51cf1119307431b8c84860dcfbf197c70a63
cloudrainstar/efai_clock
run.py
[ "MIT" ]
Python
reminder
null
def reminder(update, context): """Command handler: /reminder <on/off> - set clock reminder on or off.""" logging.info(f"Command: /reminder triggered by {update.effective_chat.id}") if len(context.args) != 1: context.bot.send_message( chat_id=update.effective_chat.id, text="No...
Command handler: /reminder <on/off> - set clock reminder on or off.
Command handler: /reminder - set clock reminder on or off.
[ "Command", "handler", ":", "/", "reminder", "-", "set", "clock", "reminder", "on", "or", "off", "." ]
def reminder(update, context): logging.info(f"Command: /reminder triggered by {update.effective_chat.id}") if len(context.args) != 1: context.bot.send_message( chat_id=update.effective_chat.id, text="Not enough or too many parameters, reminder either on or off.", ) el...
[ "def", "reminder", "(", "update", ",", "context", ")", ":", "logging", ".", "info", "(", "f\"Command: /reminder triggered by {update.effective_chat.id}\"", ")", "if", "len", "(", "context", ".", "args", ")", "!=", "1", ":", "context", ".", "bot", ".", "send_me...
Command handler: /reminder <on/off> - set clock reminder on or off.
[ "Command", "handler", ":", "/", "reminder", "<on", "/", "off", ">", "-", "set", "clock", "reminder", "on", "or", "off", "." ]
[ "\"\"\"Command handler: /reminder <on/off> - set clock reminder on or off.\"\"\"" ]
[ { "param": "update", "type": null }, { "param": "context", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "update", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "context", "type": null, "docstring": null, "docstring_token...
a58e51cf1119307431b8c84860dcfbf197c70a63
cloudrainstar/efai_clock
run.py
[ "MIT" ]
Python
autolog
null
def autolog(update, context): """Command handler: /autolog <on/off> - set autolog on or off.""" logging.info(f"Command: /autolog triggered by {update.effective_chat.id}") if len(context.args) != 1: context.bot.send_message( chat_id=update.effective_chat.id, text="Not enough o...
Command handler: /autolog <on/off> - set autolog on or off.
Command handler: /autolog - set autolog on or off.
[ "Command", "handler", ":", "/", "autolog", "-", "set", "autolog", "on", "or", "off", "." ]
def autolog(update, context): logging.info(f"Command: /autolog triggered by {update.effective_chat.id}") if len(context.args) != 1: context.bot.send_message( chat_id=update.effective_chat.id, text="Not enough or too many parameters, autolog either on or off.", ) else:...
[ "def", "autolog", "(", "update", ",", "context", ")", ":", "logging", ".", "info", "(", "f\"Command: /autolog triggered by {update.effective_chat.id}\"", ")", "if", "len", "(", "context", ".", "args", ")", "!=", "1", ":", "context", ".", "bot", ".", "send_mess...
Command handler: /autolog <on/off> - set autolog on or off.
[ "Command", "handler", ":", "/", "autolog", "<on", "/", "off", ">", "-", "set", "autolog", "on", "or", "off", "." ]
[ "\"\"\"Command handler: /autolog <on/off> - set autolog on or off.\"\"\"" ]
[ { "param": "update", "type": null }, { "param": "context", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "update", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "context", "type": null, "docstring": null, "docstring_token...
a58e51cf1119307431b8c84860dcfbf197c70a63
cloudrainstar/efai_clock
run.py
[ "MIT" ]
Python
callback_clock
None
def callback_clock(context: CallbackContext, out: bool = False) -> None: """Handle callback: a clock in/out callback using job queue.""" u = context.job.context clock_string = "clockin_" if out: clock_string = "clockout_" logging.info(f"{clock_string}: {str(u.userid)}") br = apollo.Apoll...
Handle callback: a clock in/out callback using job queue.
Handle callback: a clock in/out callback using job queue.
[ "Handle", "callback", ":", "a", "clock", "in", "/", "out", "callback", "using", "job", "queue", "." ]
def callback_clock(context: CallbackContext, out: bool = False) -> None: u = context.job.context clock_string = "clockin_" if out: clock_string = "clockout_" logging.info(f"{clock_string}: {str(u.userid)}") br = apollo.ApolloSession() retry_count = 3 for i in range(retry_count): ...
[ "def", "callback_clock", "(", "context", ":", "CallbackContext", ",", "out", ":", "bool", "=", "False", ")", "->", "None", ":", "u", "=", "context", ".", "job", ".", "context", "clock_string", "=", "\"clockin_\"", "if", "out", ":", "clock_string", "=", "...
Handle callback: a clock in/out callback using job queue.
[ "Handle", "callback", ":", "a", "clock", "in", "/", "out", "callback", "using", "job", "queue", "." ]
[ "\"\"\"Handle callback: a clock in/out callback using job queue.\"\"\"" ]
[ { "param": "context", "type": "CallbackContext" }, { "param": "out", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "context", "type": "CallbackContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out", "type": "bool", "docstring": null, "doc...
a58e51cf1119307431b8c84860dcfbf197c70a63
cloudrainstar/efai_clock
run.py
[ "MIT" ]
Python
callback_reminder_clock
None
def callback_reminder_clock(context: CallbackContext, out: bool = False) -> None: """Handle callback: a clock in/out reminder schedule using job queue.""" ses = apollodb.UserQuery(apollodb.Session()) us = ses.get_reminder() clock_string = "clockin_" if out: clock_string = "clockout_" for...
Handle callback: a clock in/out reminder schedule using job queue.
Handle callback: a clock in/out reminder schedule using job queue.
[ "Handle", "callback", ":", "a", "clock", "in", "/", "out", "reminder", "schedule", "using", "job", "queue", "." ]
def callback_reminder_clock(context: CallbackContext, out: bool = False) -> None: ses = apollodb.UserQuery(apollodb.Session()) us = ses.get_reminder() clock_string = "clockin_" if out: clock_string = "clockout_" for u in us: max_half_hour_delay = random.randint(0, 60 * 29) lo...
[ "def", "callback_reminder_clock", "(", "context", ":", "CallbackContext", ",", "out", ":", "bool", "=", "False", ")", "->", "None", ":", "ses", "=", "apollodb", ".", "UserQuery", "(", "apollodb", ".", "Session", "(", ")", ")", "us", "=", "ses", ".", "g...
Handle callback: a clock in/out reminder schedule using job queue.
[ "Handle", "callback", ":", "a", "clock", "in", "/", "out", "reminder", "schedule", "using", "job", "queue", "." ]
[ "\"\"\"Handle callback: a clock in/out reminder schedule using job queue.\"\"\"" ]
[ { "param": "context", "type": "CallbackContext" }, { "param": "out", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "context", "type": "CallbackContext", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "out", "type": "bool", "docstring": null, "doc...
8de2e8aac95607a86ba8cda653f9f3d0efc21ddb
Menosse/python-programmer
1. Spyder python files/9.0.1_Files_&_Functions.py
[ "MIT" ]
Python
fib
<not_specific>
def fib(n): ''' Calculates and returns the nth fibonacci number''' a = 0 b = 1 for i in range(n): a,b = b,a+b return a
Calculates and returns the nth fibonacci number
Calculates and returns the nth fibonacci number
[ "Calculates", "and", "returns", "the", "nth", "fibonacci", "number" ]
def fib(n): a = 0 b = 1 for i in range(n): a,b = b,a+b return a
[ "def", "fib", "(", "n", ")", ":", "a", "=", "0", "b", "=", "1", "for", "i", "in", "range", "(", "n", ")", ":", "a", ",", "b", "=", "b", ",", "a", "+", "b", "return", "a" ]
Calculates and returns the nth fibonacci number
[ "Calculates", "and", "returns", "the", "nth", "fibonacci", "number" ]
[ "''' Calculates and returns the nth fibonacci number'''" ]
[ { "param": "n", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
5bd17e13501edc6baf65632db30f28ef39afd437
Liulinghzi/DeepCTR
mydeepctr/models/pnn.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = PNNConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = PNNConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "PNNConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__",...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
ac8c3b99628ebaf434a58f5123f0346068562384
Liulinghzi/DeepCTR
deepctr/models/deepfm.py
[ "Apache-2.0" ]
Python
DeepFM
<not_specific>
def DeepFM(linear_feature_columns, dnn_feature_columns, fm_group=[DEFAULT_GROUP_NAME], dnn_hidden_units=(128, 128), l2_reg_linear=0.00001, l2_reg_embedding=0.00001, l2_reg_dnn=0, init_std=0.0001, seed=1024, dnn_dropout=0, dnn_activation='relu', dnn_use_bn=False, task='binary'): """Instantiates...
Instantiates the DeepFM Network architecture. :param linear_feature_columns: An iterable containing all the features used by linear part of the model. :param dnn_feature_columns: An iterable containing all the features used by deep part of the model. :param fm_group: list, group_name of features that will ...
Instantiates the DeepFM Network architecture.
[ "Instantiates", "the", "DeepFM", "Network", "architecture", "." ]
def DeepFM(linear_feature_columns, dnn_feature_columns, fm_group=[DEFAULT_GROUP_NAME], dnn_hidden_units=(128, 128), l2_reg_linear=0.00001, l2_reg_embedding=0.00001, l2_reg_dnn=0, init_std=0.0001, seed=1024, dnn_dropout=0, dnn_activation='relu', dnn_use_bn=False, task='binary'): features = buil...
[ "def", "DeepFM", "(", "linear_feature_columns", ",", "dnn_feature_columns", ",", "fm_group", "=", "[", "DEFAULT_GROUP_NAME", "]", ",", "dnn_hidden_units", "=", "(", "128", ",", "128", ")", ",", "l2_reg_linear", "=", "0.00001", ",", "l2_reg_embedding", "=", "0.00...
Instantiates the DeepFM Network architecture.
[ "Instantiates", "the", "DeepFM", "Network", "architecture", "." ]
[ "\"\"\"Instantiates the DeepFM Network architecture.\n\n :param linear_feature_columns: An iterable containing all the features used by linear part of the model.\n :param dnn_feature_columns: An iterable containing all the features used by deep part of the model.\n :param fm_group: list, group_name of feat...
[ { "param": "linear_feature_columns", "type": null }, { "param": "dnn_feature_columns", "type": null }, { "param": "fm_group", "type": null }, { "param": "dnn_hidden_units", "type": null }, { "param": "l2_reg_linear", "type": null }, { "param": "l2_reg_...
{ "returns": [ { "docstring": "A Keras model instance.", "docstring_tokens": [ "A", "Keras", "model", "instance", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "linear_feature_columns", "type": null, ...
f3fe7666c2127e81b45f67a86f5350166dfd75a2
Liulinghzi/DeepCTR
mydeepctr/models/wdl.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = WDLConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = WDLConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "WDLConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__",...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
7b044b0d37f21b0fd839f9a2b324954326c5c70a
Liulinghzi/DeepCTR
mydeepctr/models/ffm.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = FFMConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = FFMConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "FFMConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__",...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
0971a129579a314d25aedd3be2664e024bbc6aed
Liulinghzi/DeepCTR
mydeepctr/models/mlr.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = MLRConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = MLRConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "MLRConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__",...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
3efc380b4b0be2c881c58de1fd8ea80d03dcf2c2
Liulinghzi/DeepCTR
datapreprocess/tfrecord.py
[ "Apache-2.0" ]
Python
_decode_record
<not_specific>
def _decode_record(record, name_to_features, label, mode): """Decodes a record to a TensorFlow example.""" example = tf.parse_single_example(record, name_to_features) # tf.Example only supports tf.int64, but the TPU only supports tf.int32. # So cast all int64 to int32. ...
Decodes a record to a TensorFlow example.
Decodes a record to a TensorFlow example.
[ "Decodes", "a", "record", "to", "a", "TensorFlow", "example", "." ]
def _decode_record(record, name_to_features, label, mode): example = tf.parse_single_example(record, name_to_features) for name in list(example.keys()): t = example[name] if t.dtype == tf.int64: t = tf.to_int32(t) example[name] ...
[ "def", "_decode_record", "(", "record", ",", "name_to_features", ",", "label", ",", "mode", ")", ":", "example", "=", "tf", ".", "parse_single_example", "(", "record", ",", "name_to_features", ")", "for", "name", "in", "list", "(", "example", ".", "keys", ...
Decodes a record to a TensorFlow example.
[ "Decodes", "a", "record", "to", "a", "TensorFlow", "example", "." ]
[ "\"\"\"Decodes a record to a TensorFlow example.\"\"\"", "# tf.Example only supports tf.int64, but the TPU only supports tf.int32.", "# So cast all int64 to int32.", "# 如果需要把feature和label分开,需要从这里入手" ]
[ { "param": "record", "type": null }, { "param": "name_to_features", "type": null }, { "param": "label", "type": null }, { "param": "mode", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "record", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "name_to_features", "type": null, "docstring": null, "docstr...
6854d58ceb605c1dcbd8977f279023c6662184c8
Liulinghzi/DeepCTR
deepctr/models/pnn.py
[ "Apache-2.0" ]
Python
PNN
<not_specific>
def PNN(dnn_feature_columns, dnn_hidden_units=(128, 128), l2_reg_embedding=1e-5, l2_reg_dnn=0, init_std=0.0001, seed=1024, dnn_dropout=0, dnn_activation='relu', use_inner=True, use_outter=False, kernel_type='mat', task='binary'): """Instantiates the Product-based Neural Network architecture. :p...
Instantiates the Product-based Neural Network architecture. :param dnn_feature_columns: An iterable containing all the features used by deep part of the model. :param dnn_hidden_units: list,list of positive integer or empty list, the layer number and units in each layer of deep net :param l2_reg_embedding:...
Instantiates the Product-based Neural Network architecture.
[ "Instantiates", "the", "Product", "-", "based", "Neural", "Network", "architecture", "." ]
def PNN(dnn_feature_columns, dnn_hidden_units=(128, 128), l2_reg_embedding=1e-5, l2_reg_dnn=0, init_std=0.0001, seed=1024, dnn_dropout=0, dnn_activation='relu', use_inner=True, use_outter=False, kernel_type='mat', task='binary'): if kernel_type not in ['mat', 'vec', 'num']: raise ValueError(...
[ "def", "PNN", "(", "dnn_feature_columns", ",", "dnn_hidden_units", "=", "(", "128", ",", "128", ")", ",", "l2_reg_embedding", "=", "1e-5", ",", "l2_reg_dnn", "=", "0", ",", "init_std", "=", "0.0001", ",", "seed", "=", "1024", ",", "dnn_dropout", "=", "0"...
Instantiates the Product-based Neural Network architecture.
[ "Instantiates", "the", "Product", "-", "based", "Neural", "Network", "architecture", "." ]
[ "\"\"\"Instantiates the Product-based Neural Network architecture.\n\n :param dnn_feature_columns: An iterable containing all the features used by deep part of the model.\n :param dnn_hidden_units: list,list of positive integer or empty list, the layer number and units in each layer of deep net\n :param l2...
[ { "param": "dnn_feature_columns", "type": null }, { "param": "dnn_hidden_units", "type": null }, { "param": "l2_reg_embedding", "type": null }, { "param": "l2_reg_dnn", "type": null }, { "param": "init_std", "type": null }, { "param": "seed", "type...
{ "returns": [ { "docstring": "A Keras model instance.", "docstring_tokens": [ "A", "Keras", "model", "instance", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "dnn_feature_columns", "type": null, ...
ba067fb56adeb90823767824a020df2c7ea01886
Liulinghzi/DeepCTR
deepctr/models/wdl.py
[ "Apache-2.0" ]
Python
WDL
<not_specific>
def WDL(linear_feature_columns, dnn_feature_columns, dnn_hidden_units=(128, 128), l2_reg_linear=1e-5, l2_reg_embedding=1e-5, l2_reg_dnn=0, init_std=0.0001, seed=1024, dnn_dropout=0, dnn_activation='relu', task='binary'): """Instantiates the Wide&Deep Learning architecture. :param linear_feature...
Instantiates the Wide&Deep Learning architecture. :param linear_feature_columns: An iterable containing all the features used by linear part of the model. :param dnn_feature_columns: An iterable containing all the features used by deep part of the model. :param dnn_hidden_units: list,list of positive integ...
Instantiates the Wide&Deep Learning architecture.
[ "Instantiates", "the", "Wide&Deep", "Learning", "architecture", "." ]
def WDL(linear_feature_columns, dnn_feature_columns, dnn_hidden_units=(128, 128), l2_reg_linear=1e-5, l2_reg_embedding=1e-5, l2_reg_dnn=0, init_std=0.0001, seed=1024, dnn_dropout=0, dnn_activation='relu', task='binary'): features = build_input_features( linear_feature_columns + dnn_feature_c...
[ "def", "WDL", "(", "linear_feature_columns", ",", "dnn_feature_columns", ",", "dnn_hidden_units", "=", "(", "128", ",", "128", ")", ",", "l2_reg_linear", "=", "1e-5", ",", "l2_reg_embedding", "=", "1e-5", ",", "l2_reg_dnn", "=", "0", ",", "init_std", "=", "0...
Instantiates the Wide&Deep Learning architecture.
[ "Instantiates", "the", "Wide&Deep", "Learning", "architecture", "." ]
[ "\"\"\"Instantiates the Wide&Deep Learning architecture.\n\n :param linear_feature_columns: An iterable containing all the features used by linear part of the model.\n :param dnn_feature_columns: An iterable containing all the features used by deep part of the model.\n :param dnn_hidden_units: list,list of...
[ { "param": "linear_feature_columns", "type": null }, { "param": "dnn_feature_columns", "type": null }, { "param": "dnn_hidden_units", "type": null }, { "param": "l2_reg_linear", "type": null }, { "param": "l2_reg_embedding", "type": null }, { "param": ...
{ "returns": [ { "docstring": "A Keras model instance.", "docstring_tokens": [ "A", "Keras", "model", "instance", "." ], "type": null } ], "raises": [], "params": [ { "identifier": "linear_feature_columns", "type": null, ...
67c318a06e7e9c0c709ec6b234b9a95005f13263
Liulinghzi/DeepCTR
mydeepctr/examples/fm/model.py
[ "Apache-2.0" ]
Python
create_optimizer
<not_specific>
def create_optimizer(loss, init_lr): """Creates an optimizer training op.""" global_step = tf.train.get_or_create_global_step() optimizer = tf.train.AdamOptimizer(init_lr) # optimizer = tf.train.FtrlOptimizer(init_lr) tvars = tf.trainable_variables() grads = tf.gradients(loss, tvars) # Thi...
Creates an optimizer training op.
Creates an optimizer training op.
[ "Creates", "an", "optimizer", "training", "op", "." ]
def create_optimizer(loss, init_lr): global_step = tf.train.get_or_create_global_step() optimizer = tf.train.AdamOptimizer(init_lr) tvars = tf.trainable_variables() grads = tf.gradients(loss, tvars) (grads, _) = tf.clip_by_global_norm(grads, clip_norm=1.0) value_summaries = [] for g, v in zi...
[ "def", "create_optimizer", "(", "loss", ",", "init_lr", ")", ":", "global_step", "=", "tf", ".", "train", ".", "get_or_create_global_step", "(", ")", "optimizer", "=", "tf", ".", "train", ".", "AdamOptimizer", "(", "init_lr", ")", "tvars", "=", "tf", ".", ...
Creates an optimizer training op.
[ "Creates", "an", "optimizer", "training", "op", "." ]
[ "\"\"\"Creates an optimizer training op.\"\"\"", "# optimizer = tf.train.FtrlOptimizer(init_lr)", "# This is how the model was pre-trained.", "# 梯度的计算是固定的,和优化器无关,优化器只是去自适应的确定学习率,所以操作流程是", "# 1. 梯度计算", "# 2. 梯度截断", "# 3. 优化器把梯度加到原变量中", "# 稀疏度检验, 计算0元素占的比例, relu中梯度为0的比例应该很大" ]
[ { "param": "loss", "type": null }, { "param": "init_lr", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "loss", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "init_lr", "type": null, "docstring": null, "docstring_tokens"...
64dbb9b52f5efe2ec927def6b600c2c328bd2ca2
Liulinghzi/DeepCTR
mydeepctr/models/fm.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = FMConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = FMConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "FMConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__", ...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
4df59cb9d804319f6b46b47f65bd6d34d715d1cb
Liulinghzi/DeepCTR
mydeepctr/models/xdeepfm.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = XDeepFMConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = XDeepFMConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "XDeepFMConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
7e20102e9de1a192f978524ab12fc314ef723f84
Liulinghzi/DeepCTR
mydeepctr/models/dcn.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = DCNConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = DCNConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "DCNConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__",...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
3c8ef3bd40ce6291b42bbdaa0bf767755a8a3529
Liulinghzi/DeepCTR
mydeepctr/models/lr.py
[ "Apache-2.0" ]
Python
from_dict
<not_specific>
def from_dict(cls, json_object): """Constructs a `BertConfig` from a Python dictionary of parameters.""" config = LRConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
Constructs a `BertConfig` from a Python dictionary of parameters.
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
def from_dict(cls, json_object): config = LRConfig(vocab_size=None) for (key, value) in six.iteritems(json_object): config.__dict__[key] = value return config
[ "def", "from_dict", "(", "cls", ",", "json_object", ")", ":", "config", "=", "LRConfig", "(", "vocab_size", "=", "None", ")", "for", "(", "key", ",", "value", ")", "in", "six", ".", "iteritems", "(", "json_object", ")", ":", "config", ".", "__dict__", ...
Constructs a `BertConfig` from a Python dictionary of parameters.
[ "Constructs", "a", "`", "BertConfig", "`", "from", "a", "Python", "dictionary", "of", "parameters", "." ]
[ "\"\"\"Constructs a `BertConfig` from a Python dictionary of parameters.\"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "json_object", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "json_object", "type": null, "docstring": null, "docstring_toke...
c470383c0227dd3850bc3b5457b6331465ecb0c7
tienthanh-le/API1
profiles_api/models.py
[ "MIT" ]
Python
create_superuser
<not_specific>
def create_superuser(self, email, name, password): """Create and save a new superuser with given details""" user = self.create_user(email, name, password) user.is_superuser = True # is_superuser created by PermissionsMixin user.is_staff = True user.save(using=self._db) ...
Create and save a new superuser with given details
Create and save a new superuser with given details
[ "Create", "and", "save", "a", "new", "superuser", "with", "given", "details" ]
def create_superuser(self, email, name, password): user = self.create_user(email, name, password) user.is_superuser = True user.is_staff = True user.save(using=self._db) return user
[ "def", "create_superuser", "(", "self", ",", "email", ",", "name", ",", "password", ")", ":", "user", "=", "self", ".", "create_user", "(", "email", ",", "name", ",", "password", ")", "user", ".", "is_superuser", "=", "True", "user", ".", "is_staff", "...
Create and save a new superuser with given details
[ "Create", "and", "save", "a", "new", "superuser", "with", "given", "details" ]
[ "\"\"\"Create and save a new superuser with given details\"\"\"", "# is_superuser created by PermissionsMixin" ]
[ { "param": "self", "type": null }, { "param": "email", "type": null }, { "param": "name", "type": null }, { "param": "password", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "email", "type": null, "docstring": null, "docstring_tokens": ...
9fa8052bf5281a3352eba4cd73e7a58ba8a5f7d4
vighneshvnkt/data-ductus-challenge
ParanthesisTreePrinter.py
[ "MIT" ]
Python
paranthesesChecker
<not_specific>
def paranthesesChecker(tree): ''' Check if given tree has equal number of closing and opening square brackets using the paranthesesStack input : tree as string output : boolean value indicating paranthesesCheck ''' paranthesesStack = [] #try-except required to ensure you dont pop from an empty list, which me...
Check if given tree has equal number of closing and opening square brackets using the paranthesesStack input : tree as string output : boolean value indicating paranthesesCheck
Check if given tree has equal number of closing and opening square brackets using the paranthesesStack input : tree as string output : boolean value indicating paranthesesCheck
[ "Check", "if", "given", "tree", "has", "equal", "number", "of", "closing", "and", "opening", "square", "brackets", "using", "the", "paranthesesStack", "input", ":", "tree", "as", "string", "output", ":", "boolean", "value", "indicating", "paranthesesCheck" ]
def paranthesesChecker(tree): paranthesesStack = [] try: for elem in tree: if(elem == "["): paranthesesStack.append(elem) elif(elem == "]"): paranthesesStack.pop() if(len(paranthesesStack) == 0): return True else: return False except: return False
[ "def", "paranthesesChecker", "(", "tree", ")", ":", "paranthesesStack", "=", "[", "]", "try", ":", "for", "elem", "in", "tree", ":", "if", "(", "elem", "==", "\"[\"", ")", ":", "paranthesesStack", ".", "append", "(", "elem", ")", "elif", "(", "elem", ...
Check if given tree has equal number of closing and opening square brackets using the paranthesesStack input : tree as string output : boolean value indicating paranthesesCheck
[ "Check", "if", "given", "tree", "has", "equal", "number", "of", "closing", "and", "opening", "square", "brackets", "using", "the", "paranthesesStack", "input", ":", "tree", "as", "string", "output", ":", "boolean", "value", "indicating", "paranthesesCheck" ]
[ "'''\n\t\tCheck if given tree has equal number of closing and opening square brackets using the paranthesesStack\n\t\tinput : tree as string\n\t\toutput : boolean value indicating paranthesesCheck\n\t'''", "#try-except required to ensure you dont pop from an empty list, which means we get a closing bracket before...
[ { "param": "tree", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "tree", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
9fa8052bf5281a3352eba4cd73e7a58ba8a5f7d4
vighneshvnkt/data-ductus-challenge
ParanthesisTreePrinter.py
[ "MIT" ]
Python
tabs
<not_specific>
def tabs(count): ''' Return String with n number of tabs input : number of tabs needed output : string with tabs = count ''' emptySpaces = '' if(count <= 0): return emptySpaces while(count > 0): emptySpaces = emptySpaces + ' ' count = count - 1 return emptySpaces
Return String with n number of tabs input : number of tabs needed output : string with tabs = count
Return String with n number of tabs input : number of tabs needed output : string with tabs = count
[ "Return", "String", "with", "n", "number", "of", "tabs", "input", ":", "number", "of", "tabs", "needed", "output", ":", "string", "with", "tabs", "=", "count" ]
def tabs(count): emptySpaces = '' if(count <= 0): return emptySpaces while(count > 0): emptySpaces = emptySpaces + ' ' count = count - 1 return emptySpaces
[ "def", "tabs", "(", "count", ")", ":", "emptySpaces", "=", "''", "if", "(", "count", "<=", "0", ")", ":", "return", "emptySpaces", "while", "(", "count", ">", "0", ")", ":", "emptySpaces", "=", "emptySpaces", "+", "' '", "count", "=", "count", "-"...
Return String with n number of tabs input : number of tabs needed output : string with tabs = count
[ "Return", "String", "with", "n", "number", "of", "tabs", "input", ":", "number", "of", "tabs", "needed", "output", ":", "string", "with", "tabs", "=", "count" ]
[ "'''\n\t\tReturn String with n number of tabs\n\t\tinput : number of tabs needed\n\t\toutput : string with tabs = count\n\t'''" ]
[ { "param": "count", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "count", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7c54cfbf4c6d99b9abcffe5c4852a33a936bc7fa
Vaidic/Udacity-Deep-Reinforcement-Learning-Nanodegree
coursework/lab-taxi/agent.py
[ "Apache-2.0" ]
Python
select_action
<not_specific>
def select_action(self, state, i_episode, num_episodes): """ Given the state, select an action. Params ====== - state: the current state of the environment Returns ======= - action: an integer, compatible with the task's action space """ if i_epi...
Given the state, select an action. Params ====== - state: the current state of the environment Returns ======= - action: an integer, compatible with the task's action space
Given the state, select an action. Params the current state of the environment Returns an integer, compatible with the task's action space
[ "Given", "the", "state", "select", "an", "action", ".", "Params", "the", "current", "state", "of", "the", "environment", "Returns", "an", "integer", "compatible", "with", "the", "task", "'", "s", "action", "space" ]
def select_action(self, state, i_episode, num_episodes): if i_episode != self.episode and i_episode % (num_episodes * 0.0005) == 0: self.epsilon -= 50/num_episodes if i_episode != self.episode and i_episode % (num_episodes * 0.005) == 0: self.alpha -= 20/num_episodes ...
[ "def", "select_action", "(", "self", ",", "state", ",", "i_episode", ",", "num_episodes", ")", ":", "if", "i_episode", "!=", "self", ".", "episode", "and", "i_episode", "%", "(", "num_episodes", "*", "0.0005", ")", "==", "0", ":", "self", ".", "epsilon",...
Given the state, select an action.
[ "Given", "the", "state", "select", "an", "action", "." ]
[ "\"\"\" Given the state, select an action.\n\n Params\n ======\n - state: the current state of the environment\n\n Returns\n =======\n - action: an integer, compatible with the task's action space\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "state", "type": null }, { "param": "i_episode", "type": null }, { "param": "num_episodes", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": null, "docstring": null, "docstring_tokens": ...
7c54cfbf4c6d99b9abcffe5c4852a33a936bc7fa
Vaidic/Udacity-Deep-Reinforcement-Learning-Nanodegree
coursework/lab-taxi/agent.py
[ "Apache-2.0" ]
Python
step
null
def step(self, state, action, reward, next_state, done): """ Update the agent's knowledge, using the most recently sampled tuple. Params ====== - state: the previous state of the environment - action: the agent's previous choice of action - reward: last reward received ...
Update the agent's knowledge, using the most recently sampled tuple. Params ====== - state: the previous state of the environment - action: the agent's previous choice of action - reward: last reward received - next_state: the current state of the environment - ...
Update the agent's knowledge, using the most recently sampled tuple. Params the previous state of the environment action: the agent's previous choice of action reward: last reward received next_state: the current state of the environment done: whether the episode is complete (True or False)
[ "Update", "the", "agent", "'", "s", "knowledge", "using", "the", "most", "recently", "sampled", "tuple", ".", "Params", "the", "previous", "state", "of", "the", "environment", "action", ":", "the", "agent", "'", "s", "previous", "choice", "of", "action", "...
def step(self, state, action, reward, next_state, done): next_action = np.argmax(self.Q[state]) self.Q[state][action] = self.Q[state][action] + (self.alpha * (reward + \ (self.gamma * np.max(self.Q[next_state])) - self.Q[state][action]))
[ "def", "step", "(", "self", ",", "state", ",", "action", ",", "reward", ",", "next_state", ",", "done", ")", ":", "next_action", "=", "np", ".", "argmax", "(", "self", ".", "Q", "[", "state", "]", ")", "self", ".", "Q", "[", "state", "]", "[", ...
Update the agent's knowledge, using the most recently sampled tuple.
[ "Update", "the", "agent", "'", "s", "knowledge", "using", "the", "most", "recently", "sampled", "tuple", "." ]
[ "\"\"\" Update the agent's knowledge, using the most recently sampled tuple.\n\n Params\n ======\n - state: the previous state of the environment\n - action: the agent's previous choice of action\n - reward: last reward received\n - next_state: the current state of the envi...
[ { "param": "self", "type": null }, { "param": "state", "type": null }, { "param": "action", "type": null }, { "param": "reward", "type": null }, { "param": "next_state", "type": null }, { "param": "done", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": null, "docstring": null, "docstring_tokens": ...
62bab8caf9c34fe17fc02cbc65373e935cfd010d
Vaidic/Udacity-Deep-Reinforcement-Learning-Nanodegree
projects/p3_collab-compet/agent.py
[ "Apache-2.0" ]
Python
act
<not_specific>
def act(self, state, add_noise=True): """Returns actions for given state as per current policy.""" state = torch.from_numpy(state).float().to(device) self.actor_local.eval() with torch.no_grad(): action = self.actor_local(state).cpu().data.numpy() self.actor_local.tra...
Returns actions for given state as per current policy.
Returns actions for given state as per current policy.
[ "Returns", "actions", "for", "given", "state", "as", "per", "current", "policy", "." ]
def act(self, state, add_noise=True): state = torch.from_numpy(state).float().to(device) self.actor_local.eval() with torch.no_grad(): action = self.actor_local(state).cpu().data.numpy() self.actor_local.train() if add_noise: for i in range(NUM_AGENTS): ...
[ "def", "act", "(", "self", ",", "state", ",", "add_noise", "=", "True", ")", ":", "state", "=", "torch", ".", "from_numpy", "(", "state", ")", ".", "float", "(", ")", ".", "to", "(", "device", ")", "self", ".", "actor_local", ".", "eval", "(", ")...
Returns actions for given state as per current policy.
[ "Returns", "actions", "for", "given", "state", "as", "per", "current", "policy", "." ]
[ "\"\"\"Returns actions for given state as per current policy.\"\"\"" ]
[ { "param": "self", "type": null }, { "param": "state", "type": null }, { "param": "add_noise", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "state", "type": null, "docstring": null, "docstring_tokens": ...
a1dea3953fd089b91e5f2e41b5ecc57343a92fa0
JakubCzech/ROS_Modbus_Mobile_Robot
modbus_sterring/src/agv.py
[ "MIT" ]
Python
check_all_info
<not_specific>
def check_all_info(self): """ Check if all the information are available """ base_data_struct = self.client.read_holding_registers(self.__BASE_DATA_STRUCT_ADDR,13) manual_control_struct = self.client.read_holding_registers(self.MANUAL_CONTROL_STRUCT,7) SYSTEM_TI...
Check if all the information are available
Check if all the information are available
[ "Check", "if", "all", "the", "information", "are", "available" ]
def check_all_info(self): base_data_struct = self.client.read_holding_registers(self.__BASE_DATA_STRUCT_ADDR,13) manual_control_struct = self.client.read_holding_registers(self.MANUAL_CONTROL_STRUCT,7) SYSTEM_TICK_MS = self.client.read_holding_registers(self.__SYSTEM_TICK_MS_ADDR,2) if(b...
[ "def", "check_all_info", "(", "self", ")", ":", "base_data_struct", "=", "self", ".", "client", ".", "read_holding_registers", "(", "self", ".", "__BASE_DATA_STRUCT_ADDR", ",", "13", ")", "manual_control_struct", "=", "self", ".", "client", ".", "read_holding_regi...
Check if all the information are available
[ "Check", "if", "all", "the", "information", "are", "available" ]
[ "\"\"\"\n Check if all the information are available\n\n \n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
a1dea3953fd089b91e5f2e41b5ecc57343a92fa0
JakubCzech/ROS_Modbus_Mobile_Robot
modbus_sterring/src/agv.py
[ "MIT" ]
Python
update_time
<not_specific>
def update_time(self): """ Update the time of the robot """ try: SYSTEM_TICK_MS = self.client.read_holding_registers(self.__SYSTEM_TICK_MS_ADDR,2) if(SYSTEM_TICK_MS): self.__ROBOT_TIME = SYSTEM_TICK_MS[0] return True ...
Update the time of the robot
Update the time of the robot
[ "Update", "the", "time", "of", "the", "robot" ]
def update_time(self): try: SYSTEM_TICK_MS = self.client.read_holding_registers(self.__SYSTEM_TICK_MS_ADDR,2) if(SYSTEM_TICK_MS): self.__ROBOT_TIME = SYSTEM_TICK_MS[0] return True else: self.log_error("Time error") ...
[ "def", "update_time", "(", "self", ")", ":", "try", ":", "SYSTEM_TICK_MS", "=", "self", ".", "client", ".", "read_holding_registers", "(", "self", ".", "__SYSTEM_TICK_MS_ADDR", ",", "2", ")", "if", "(", "SYSTEM_TICK_MS", ")", ":", "self", ".", "__ROBOT_TIME"...
Update the time of the robot
[ "Update", "the", "time", "of", "the", "robot" ]
[ "\"\"\"\n Update the time of the robot\n \n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
00d8067ecd72003472d0b552650efbcc012e403d
neilferg/matlab2cpp
conftest.py
[ "BSD-3-Clause" ]
Python
workspace
null
def workspace(workspace_folder, doctest_namespace): """Fill temporary folder for each test.""" # move data to workspace: source = os.path.join(os.path.dirname(inspect.stack()[0][1]), "test", "data") if os.path.isdir(workspace_folder): shutil.rmtree(workspace_folder) shutil.copytree(source, w...
Fill temporary folder for each test.
Fill temporary folder for each test.
[ "Fill", "temporary", "folder", "for", "each", "test", "." ]
def workspace(workspace_folder, doctest_namespace): source = os.path.join(os.path.dirname(inspect.stack()[0][1]), "test", "data") if os.path.isdir(workspace_folder): shutil.rmtree(workspace_folder) shutil.copytree(source, workspace_folder) doctest_namespace["workspace"] = workspace_folder do...
[ "def", "workspace", "(", "workspace_folder", ",", "doctest_namespace", ")", ":", "source", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "inspect", ".", "stack", "(", ")", "[", "0", "]", "[", "1", "]", ")", ",", ...
Fill temporary folder for each test.
[ "Fill", "temporary", "folder", "for", "each", "test", "." ]
[ "\"\"\"Fill temporary folder for each test.\"\"\"", "# move data to workspace:", "# add content to doctest namespace:", "# change to workspace:", "# clean up:" ]
[ { "param": "workspace_folder", "type": null }, { "param": "doctest_namespace", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "workspace_folder", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "doctest_namespace", "type": null, "docstring": null, ...
1a9aa6f116020180ebd30617e5a5310750c6ffd8
Steinbeck-Lab/DECIMER-Image_Transformer
DECIMER/config.py
[ "MIT" ]
Python
central_square_image
<not_specific>
def central_square_image(im): """ This function takes a Pillow Image object and will add white padding so that the image has a square shape with the width/height of the longest side of the original image. ___ im: PIL.Image ___ output: PIL.Image """ max_wh = int(1.2 * max(im.size)...
This function takes a Pillow Image object and will add white padding so that the image has a square shape with the width/height of the longest side of the original image. ___ im: PIL.Image ___ output: PIL.Image
This function takes a Pillow Image object and will add white padding so that the image has a square shape with the width/height of the longest side of the original image.
[ "This", "function", "takes", "a", "Pillow", "Image", "object", "and", "will", "add", "white", "padding", "so", "that", "the", "image", "has", "a", "square", "shape", "with", "the", "width", "/", "height", "of", "the", "longest", "side", "of", "the", "ori...
def central_square_image(im): max_wh = int(1.2 * max(im.size)) if max_wh < 299: max_wh = 299 new_im = Image.new(im.mode, (max_wh, max_wh), "white") paste_pos = ( int((new_im.size[0] - im.size[0]) / 2), int((new_im.size[1] - im.size[1]) / 2), ) new_im.paste(im, paste_pos) ...
[ "def", "central_square_image", "(", "im", ")", ":", "max_wh", "=", "int", "(", "1.2", "*", "max", "(", "im", ".", "size", ")", ")", "if", "max_wh", "<", "299", ":", "max_wh", "=", "299", "new_im", "=", "Image", ".", "new", "(", "im", ".", "mode",...
This function takes a Pillow Image object and will add white padding so that the image has a square shape with the width/height of the longest side of the original image.
[ "This", "function", "takes", "a", "Pillow", "Image", "object", "and", "will", "add", "white", "padding", "so", "that", "the", "image", "has", "a", "square", "shape", "with", "the", "width", "/", "height", "of", "the", "longest", "side", "of", "the", "ori...
[ "\"\"\"\n This function takes a Pillow Image object and will add white padding\n so that the image has a square shape with the width/height of the longest side\n of the original image.\n ___\n im: PIL.Image\n ___\n output: PIL.Image\n \"\"\"", "# If the new image is smaller than 299x299, t...
[ { "param": "im", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "im", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1a9aa6f116020180ebd30617e5a5310750c6ffd8
Steinbeck-Lab/DECIMER-Image_Transformer
DECIMER/config.py
[ "MIT" ]
Python
delete_empty_borders
<not_specific>
def delete_empty_borders(im): """This function takes a Pillow Image object, converts it to grayscale and deletes white space at the borders. ___ im: PIL.Image ___ output: PIL.Image """ im = np.asarray(im.convert("L")) mask = im > 200 rows = np.flatnonzero((~mask).sum(axis=1)) ...
This function takes a Pillow Image object, converts it to grayscale and deletes white space at the borders. ___ im: PIL.Image ___ output: PIL.Image
This function takes a Pillow Image object, converts it to grayscale and deletes white space at the borders.
[ "This", "function", "takes", "a", "Pillow", "Image", "object", "converts", "it", "to", "grayscale", "and", "deletes", "white", "space", "at", "the", "borders", "." ]
def delete_empty_borders(im): im = np.asarray(im.convert("L")) mask = im > 200 rows = np.flatnonzero((~mask).sum(axis=1)) cols = np.flatnonzero((~mask).sum(axis=0)) crop = im[rows.min() : rows.max() + 1, cols.min() : cols.max() + 1] return Image.fromarray(crop)
[ "def", "delete_empty_borders", "(", "im", ")", ":", "im", "=", "np", ".", "asarray", "(", "im", ".", "convert", "(", "\"L\"", ")", ")", "mask", "=", "im", ">", "200", "rows", "=", "np", ".", "flatnonzero", "(", "(", "~", "mask", ")", ".", "sum", ...
This function takes a Pillow Image object, converts it to grayscale and deletes white space at the borders.
[ "This", "function", "takes", "a", "Pillow", "Image", "object", "converts", "it", "to", "grayscale", "and", "deletes", "white", "space", "at", "the", "borders", "." ]
[ "\"\"\"This function takes a Pillow Image object, converts it to grayscale and\n deletes white space at the borders.\n ___\n im: PIL.Image\n ___\n output: PIL.Image\n \"\"\"" ]
[ { "param": "im", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "im", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1a9aa6f116020180ebd30617e5a5310750c6ffd8
Steinbeck-Lab/DECIMER-Image_Transformer
DECIMER/config.py
[ "MIT" ]
Python
PIL_im_to_BytesIO
<not_specific>
def PIL_im_to_BytesIO(im): """ Convert pillow image to io.BytesIO object ___ im: PIL.Image ___ Output: io.BytesIO object with the image data """ output = io.BytesIO() im.save(output, format="PNG") return output
Convert pillow image to io.BytesIO object ___ im: PIL.Image ___ Output: io.BytesIO object with the image data
Convert pillow image to io.BytesIO object im: PIL.Image Output: io.BytesIO object with the image data
[ "Convert", "pillow", "image", "to", "io", ".", "BytesIO", "object", "im", ":", "PIL", ".", "Image", "Output", ":", "io", ".", "BytesIO", "object", "with", "the", "image", "data" ]
def PIL_im_to_BytesIO(im): output = io.BytesIO() im.save(output, format="PNG") return output
[ "def", "PIL_im_to_BytesIO", "(", "im", ")", ":", "output", "=", "io", ".", "BytesIO", "(", ")", "im", ".", "save", "(", "output", ",", "format", "=", "\"PNG\"", ")", "return", "output" ]
Convert pillow image to io.BytesIO object ___ im: PIL.Image ___ Output: io.BytesIO object with the image data
[ "Convert", "pillow", "image", "to", "io", ".", "BytesIO", "object", "___", "im", ":", "PIL", ".", "Image", "___", "Output", ":", "io", ".", "BytesIO", "object", "with", "the", "image", "data" ]
[ "\"\"\"\n Convert pillow image to io.BytesIO object\n ___\n im: PIL.Image\n ___\n Output: io.BytesIO object with the image data\n \"\"\"" ]
[ { "param": "im", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "im", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1a9aa6f116020180ebd30617e5a5310750c6ffd8
Steinbeck-Lab/DECIMER-Image_Transformer
DECIMER/config.py
[ "MIT" ]
Python
remove_transparent
<not_specific>
def remove_transparent(image_path: str): """ Removes the transparent layer from a PNG image with an alpha channel ___ image_path (str): path of input image ___ Output: PIL.Image """ png = Image.open(image_path).convert("RGBA") background = Image.new("RGBA", png.size, (255, 255, 255))...
Removes the transparent layer from a PNG image with an alpha channel ___ image_path (str): path of input image ___ Output: PIL.Image
Removes the transparent layer from a PNG image with an alpha channel image_path (str): path of input image Output: PIL.Image
[ "Removes", "the", "transparent", "layer", "from", "a", "PNG", "image", "with", "an", "alpha", "channel", "image_path", "(", "str", ")", ":", "path", "of", "input", "image", "Output", ":", "PIL", ".", "Image" ]
def remove_transparent(image_path: str): png = Image.open(image_path).convert("RGBA") background = Image.new("RGBA", png.size, (255, 255, 255)) alpha_composite = Image.alpha_composite(background, png) return alpha_composite
[ "def", "remove_transparent", "(", "image_path", ":", "str", ")", ":", "png", "=", "Image", ".", "open", "(", "image_path", ")", ".", "convert", "(", "\"RGBA\"", ")", "background", "=", "Image", ".", "new", "(", "\"RGBA\"", ",", "png", ".", "size", ",",...
Removes the transparent layer from a PNG image with an alpha channel ___ image_path (str): path of input image ___ Output: PIL.Image
[ "Removes", "the", "transparent", "layer", "from", "a", "PNG", "image", "with", "an", "alpha", "channel", "___", "image_path", "(", "str", ")", ":", "path", "of", "input", "image", "___", "Output", ":", "PIL", ".", "Image" ]
[ "\"\"\"\n Removes the transparent layer from a PNG image with an alpha channel\n ___\n image_path (str): path of input image\n ___\n Output: PIL.Image\n \"\"\"" ]
[ { "param": "image_path", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "image_path", "type": "str", "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
1a9aa6f116020180ebd30617e5a5310750c6ffd8
Steinbeck-Lab/DECIMER-Image_Transformer
DECIMER/config.py
[ "MIT" ]
Python
initialize_encoder_config
null
def initialize_encoder_config( self, image_embedding_dim, preprocessing_fn, backbone_fn, image_shape, do_permute=False, pretrained_weights=None, ): """This functions initializes the Efficient-Net V2 encoder with user defined configurations. ...
This functions initializes the Efficient-Net V2 encoder with user defined configurations. Args: image_embedding_dim (int): Embedding dimention of the input image preprocessing_fn (method): Efficient Net preprocessing function for input image backbone_fn (method): Cal...
This functions initializes the Efficient-Net V2 encoder with user defined configurations.
[ "This", "functions", "initializes", "the", "Efficient", "-", "Net", "V2", "encoder", "with", "user", "defined", "configurations", "." ]
def initialize_encoder_config( self, image_embedding_dim, preprocessing_fn, backbone_fn, image_shape, do_permute=False, pretrained_weights=None, ): self.encoder_config = dict( image_embedding_dim=image_embedding_dim, preprocessi...
[ "def", "initialize_encoder_config", "(", "self", ",", "image_embedding_dim", ",", "preprocessing_fn", ",", "backbone_fn", ",", "image_shape", ",", "do_permute", "=", "False", ",", "pretrained_weights", "=", "None", ",", ")", ":", "self", ".", "encoder_config", "="...
This functions initializes the Efficient-Net V2 encoder with user defined configurations.
[ "This", "functions", "initializes", "the", "Efficient", "-", "Net", "V2", "encoder", "with", "user", "defined", "configurations", "." ]
[ "\"\"\"This functions initializes the Efficient-Net V2 encoder with user defined\n configurations.\n\n Args:\n image_embedding_dim (int): Embedding dimention of the input image\n preprocessing_fn (method): Efficient Net preprocessing function for input image\n backbone...
[ { "param": "self", "type": null }, { "param": "image_embedding_dim", "type": null }, { "param": "preprocessing_fn", "type": null }, { "param": "backbone_fn", "type": null }, { "param": "image_shape", "type": null }, { "param": "do_permute", "type":...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "image_embedding_dim", "type": null, "docstring": "Embedding dimenti...
1a9aa6f116020180ebd30617e5a5310750c6ffd8
Steinbeck-Lab/DECIMER-Image_Transformer
DECIMER/config.py
[ "MIT" ]
Python
initialize_transformer_config
null
def initialize_transformer_config( self, vocab_len, max_len, n_transformer_layers, transformer_d_dff, transformer_n_heads, image_embedding_dim, dropout_rate=0.1, ): """This functions initializes the Transformer model as decoder with user define...
This functions initializes the Transformer model as decoder with user defined configurations. Args: vocab_len (int): Total number of words in the input vocabulary max_len (int): Maximum length of the string found on the training dataset n_transformer_layers (int): N...
This functions initializes the Transformer model as decoder with user defined configurations.
[ "This", "functions", "initializes", "the", "Transformer", "model", "as", "decoder", "with", "user", "defined", "configurations", "." ]
def initialize_transformer_config( self, vocab_len, max_len, n_transformer_layers, transformer_d_dff, transformer_n_heads, image_embedding_dim, dropout_rate=0.1, ): self.transformer_config = dict( num_layers=n_transformer_layers, ...
[ "def", "initialize_transformer_config", "(", "self", ",", "vocab_len", ",", "max_len", ",", "n_transformer_layers", ",", "transformer_d_dff", ",", "transformer_n_heads", ",", "image_embedding_dim", ",", "dropout_rate", "=", "0.1", ",", ")", ":", "self", ".", "transf...
This functions initializes the Transformer model as decoder with user defined configurations.
[ "This", "functions", "initializes", "the", "Transformer", "model", "as", "decoder", "with", "user", "defined", "configurations", "." ]
[ "\"\"\"This functions initializes the Transformer model as decoder with user defined\n configurations.\n\n\n Args:\n vocab_len (int): Total number of words in the input vocabulary\n max_len (int): Maximum length of the string found on the training dataset\n n_transform...
[ { "param": "self", "type": null }, { "param": "vocab_len", "type": null }, { "param": "max_len", "type": null }, { "param": "n_transformer_layers", "type": null }, { "param": "transformer_d_dff", "type": null }, { "param": "transformer_n_heads", "t...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "vocab_len", "type": null, "docstring": "Total number of words in th...