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
f7aae630c3c904c338ebdee22ac3bc0f5b1dafd8
ksaur/DaskKubernetes
config.py
[ "MIT" ]
Python
load_config
<not_specific>
def load_config(): """ Load the variables from the .env file Returns: .env variables(dict) """ logger = logging.getLogger(__name__) dot_env_path = find_dotenv(raise_error_if_not_found=True) logger.info(f"Found config in {dot_env_path}") return dotenv_values(dot_env_path)
Load the variables from the .env file Returns: .env variables(dict)
Load the variables from the .env file
[ "Load", "the", "variables", "from", "the", ".", "env", "file" ]
def load_config(): logger = logging.getLogger(__name__) dot_env_path = find_dotenv(raise_error_if_not_found=True) logger.info(f"Found config in {dot_env_path}") return dotenv_values(dot_env_path)
[ "def", "load_config", "(", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "__name__", ")", "dot_env_path", "=", "find_dotenv", "(", "raise_error_if_not_found", "=", "True", ")", "logger", ".", "info", "(", "f\"Found config in {dot_env_path}\"", ")", ...
Load the variables from the .env file
[ "Load", "the", "variables", "from", "the", ".", "env", "file" ]
[ "\"\"\" Load the variables from the .env file\n\n Returns:\n .env variables(dict)\n\n \"\"\"" ]
[]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "raises": [], "params": [], "outlier_params": [], "others": [] }
e978c8f82aa032c47ea58a96c176d2e21f0d221c
ksaur/DaskKubernetes
src/maskrcnn/model.py
[ "MIT" ]
Python
compute_colors_for_labels
<not_specific>
def compute_colors_for_labels( labels, palette=torch.tensor([2 ** 25 - 1, 2 ** 15 - 1, 2 ** 21 - 1]) ): """ Simple function that adds fixed colors depending on the class """ colors = labels[:, None] * palette colors = (colors % 255).numpy().astype("uint8") return colors
Simple function that adds fixed colors depending on the class
Simple function that adds fixed colors depending on the class
[ "Simple", "function", "that", "adds", "fixed", "colors", "depending", "on", "the", "class" ]
def compute_colors_for_labels( labels, palette=torch.tensor([2 ** 25 - 1, 2 ** 15 - 1, 2 ** 21 - 1]) ): colors = labels[:, None] * palette colors = (colors % 255).numpy().astype("uint8") return colors
[ "def", "compute_colors_for_labels", "(", "labels", ",", "palette", "=", "torch", ".", "tensor", "(", "[", "2", "**", "25", "-", "1", ",", "2", "**", "15", "-", "1", ",", "2", "**", "21", "-", "1", "]", ")", ")", ":", "colors", "=", "labels", "[...
Simple function that adds fixed colors depending on the class
[ "Simple", "function", "that", "adds", "fixed", "colors", "depending", "on", "the", "class" ]
[ "\"\"\"\n Simple function that adds fixed colors depending on the class\n \"\"\"" ]
[ { "param": "labels", "type": null }, { "param": "palette", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "labels", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "palette", "type": null, "docstring": null, "docstring_token...
e978c8f82aa032c47ea58a96c176d2e21f0d221c
ksaur/DaskKubernetes
src/maskrcnn/model.py
[ "MIT" ]
Python
overlay_class_names
<not_specific>
def overlay_class_names(image, predictions): """ Adds detected class names and scores in the positions defined by the top-left corner of the predicted bounding box Arguments: image (np.ndarray): an image as returned by OpenCV predictions (BoxList): the result of the computation by the m...
Adds detected class names and scores in the positions defined by the top-left corner of the predicted bounding box Arguments: image (np.ndarray): an image as returned by OpenCV predictions (BoxList): the result of the computation by the model. It should contain the field `score...
Adds detected class names and scores in the positions defined by the top-left corner of the predicted bounding box
[ "Adds", "detected", "class", "names", "and", "scores", "in", "the", "positions", "defined", "by", "the", "top", "-", "left", "corner", "of", "the", "predicted", "bounding", "box" ]
def overlay_class_names(image, predictions): scores = predictions.get_field("scores").tolist() labels = predictions.get_field("labels").tolist() labels = [CATEGORIES[i] for i in labels] boxes = predictions.bbox template = "{}: {:.2f}" for box, score, label in zip(boxes, scores, labels): ...
[ "def", "overlay_class_names", "(", "image", ",", "predictions", ")", ":", "scores", "=", "predictions", ".", "get_field", "(", "\"scores\"", ")", ".", "tolist", "(", ")", "labels", "=", "predictions", ".", "get_field", "(", "\"labels\"", ")", ".", "tolist", ...
Adds detected class names and scores in the positions defined by the top-left corner of the predicted bounding box
[ "Adds", "detected", "class", "names", "and", "scores", "in", "the", "positions", "defined", "by", "the", "top", "-", "left", "corner", "of", "the", "predicted", "bounding", "box" ]
[ "\"\"\"\n Adds detected class names and scores in the positions defined by the\n top-left corner of the predicted bounding box\n\n Arguments:\n image (np.ndarray): an image as returned by OpenCV\n predictions (BoxList): the result of the computation by the model.\n It should contai...
[ { "param": "image", "type": null }, { "param": "predictions", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "image", "type": null, "docstring": "an image as returned by OpenCV", "docstring_tokens": [ "an", "image", "as", "returned", "by", "OpenCV" ], "default": null, "...
08a1fbb2fedf6ff6a6edaf3ce228ec2774d562ab
anuragvats/CrackingTheCodingInterview
Chapter1/ZeroMatrix.py
[ "MIT" ]
Python
ZeroMatrix
<not_specific>
def ZeroMatrix(size, data): '''To Zero the row and column if elment is zero''' row = [0]*size column = [0]*size for i in range(size): for j in range(size): if not data[i][j]: row[i]=column[j]=1 for i in range(size): if row[i]: data...
To Zero the row and column if elment is zero
To Zero the row and column if elment is zero
[ "To", "Zero", "the", "row", "and", "column", "if", "elment", "is", "zero" ]
def ZeroMatrix(size, data): row = [0]*size column = [0]*size for i in range(size): for j in range(size): if not data[i][j]: row[i]=column[j]=1 for i in range(size): if row[i]: data[i]=[0]*size continue for j in range(size): ...
[ "def", "ZeroMatrix", "(", "size", ",", "data", ")", ":", "row", "=", "[", "0", "]", "*", "size", "column", "=", "[", "0", "]", "*", "size", "for", "i", "in", "range", "(", "size", ")", ":", "for", "j", "in", "range", "(", "size", ")", ":", ...
To Zero the row and column if elment is zero
[ "To", "Zero", "the", "row", "and", "column", "if", "elment", "is", "zero" ]
[ "'''To Zero the row and column if elment is zero'''" ]
[ { "param": "size", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [...
7a956dda768573b76a54761c1c9b878a9ad0f7df
anuragvats/CrackingTheCodingInterview
Chapter1/IsOnePermutationOfOther.py
[ "MIT" ]
Python
isOnePermutationOfOther
<not_specific>
def isOnePermutationOfOther(s1, s2): '''To Check If One String IS Permutation Of Other in range of a-z''' a = [0]*26 b = [0]*26 for i in s1: a[ord(i)-97]+=1 for i in s2: b[ord(i)-97]+=1 return bool(a==b)
To Check If One String IS Permutation Of Other in range of a-z
To Check If One String IS Permutation Of Other in range of a-z
[ "To", "Check", "If", "One", "String", "IS", "Permutation", "Of", "Other", "in", "range", "of", "a", "-", "z" ]
def isOnePermutationOfOther(s1, s2): a = [0]*26 b = [0]*26 for i in s1: a[ord(i)-97]+=1 for i in s2: b[ord(i)-97]+=1 return bool(a==b)
[ "def", "isOnePermutationOfOther", "(", "s1", ",", "s2", ")", ":", "a", "=", "[", "0", "]", "*", "26", "b", "=", "[", "0", "]", "*", "26", "for", "i", "in", "s1", ":", "a", "[", "ord", "(", "i", ")", "-", "97", "]", "+=", "1", "for", "i", ...
To Check If One String IS Permutation Of Other in range of a-z
[ "To", "Check", "If", "One", "String", "IS", "Permutation", "Of", "Other", "in", "range", "of", "a", "-", "z" ]
[ "'''To Check If One String IS Permutation Of Other in range of a-z'''" ]
[ { "param": "s1", "type": null }, { "param": "s2", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "s1", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "s2", "type": null, "docstring": null, "docstring_tokens": [], ...
ee20c55744845b96e223a96c1c6dabd03423ec88
anuragvats/CrackingTheCodingInterview
Chapter1/InplaceRotateMatrixBy90Degree.py
[ "MIT" ]
Python
RotateMatrixBy90Degree
<not_specific>
def RotateMatrixBy90Degree(size, data): '''To Rotate Matrix By 90 Degree''' for i in range(size//2): data[i],data[size-i-1]=data[size-i-1],data[i] data = TransposeMatrix(size, data) return data
To Rotate Matrix By 90 Degree
To Rotate Matrix By 90 Degree
[ "To", "Rotate", "Matrix", "By", "90", "Degree" ]
def RotateMatrixBy90Degree(size, data): for i in range(size//2): data[i],data[size-i-1]=data[size-i-1],data[i] data = TransposeMatrix(size, data) return data
[ "def", "RotateMatrixBy90Degree", "(", "size", ",", "data", ")", ":", "for", "i", "in", "range", "(", "size", "//", "2", ")", ":", "data", "[", "i", "]", ",", "data", "[", "size", "-", "i", "-", "1", "]", "=", "data", "[", "size", "-", "i", "-...
To Rotate Matrix By 90 Degree
[ "To", "Rotate", "Matrix", "By", "90", "Degree" ]
[ "'''To Rotate Matrix By 90 Degree'''" ]
[ { "param": "size", "type": null }, { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "size", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [...
9c142692685e89b4af3073c123c170eb2417d66f
anuragvats/CrackingTheCodingInterview
Chapter1/IsStringUniqueWithoutAdditionalDataStructure.py
[ "MIT" ]
Python
isSrtingUnique
<not_specific>
def isSrtingUnique(data): '''To Check If String IS Unique Any Without AdditionalDataStructure''' data = sorted(data) for i in range(len(data)-1): if data[i]==data[i+1]: return False return True
To Check If String IS Unique Any Without AdditionalDataStructure
To Check If String IS Unique Any Without AdditionalDataStructure
[ "To", "Check", "If", "String", "IS", "Unique", "Any", "Without", "AdditionalDataStructure" ]
def isSrtingUnique(data): data = sorted(data) for i in range(len(data)-1): if data[i]==data[i+1]: return False return True
[ "def", "isSrtingUnique", "(", "data", ")", ":", "data", "=", "sorted", "(", "data", ")", "for", "i", "in", "range", "(", "len", "(", "data", ")", "-", "1", ")", ":", "if", "data", "[", "i", "]", "==", "data", "[", "i", "+", "1", "]", ":", "...
To Check If String IS Unique Any Without AdditionalDataStructure
[ "To", "Check", "If", "String", "IS", "Unique", "Any", "Without", "AdditionalDataStructure" ]
[ "'''To Check If String IS Unique Any Without AdditionalDataStructure'''" ]
[ { "param": "data", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "data", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d54c195280cd3114c27853ddbaed5e4ef9a975ac
RaptorMaps/raptormaps-api-examples
upload_files.py
[ "MIT" ]
Python
login
<not_specific>
def login(server_path, email, password): """Generic login function. Returns cookie and auth token for Raptor Maps Arguments: server_path (str): e.g. https://app.raptormaps.com email (str): e.g. gavinbelson@raptormaps.com password (str): e.g. 123456789 Returns: {session: (hash...
Generic login function. Returns cookie and auth token for Raptor Maps Arguments: server_path (str): e.g. https://app.raptormaps.com email (str): e.g. gavinbelson@raptormaps.com password (str): e.g. 123456789 Returns: {session: (hashed_session_string)}, <auth_token> (str)
Generic login function. Returns cookie and auth token for Raptor Maps
[ "Generic", "login", "function", ".", "Returns", "cookie", "and", "auth", "token", "for", "Raptor", "Maps" ]
def login(server_path, email, password): data = {"email":str(email),"password":str(password)} login_path = server_path + '/login' headers = {"Content-Type": "application/json"} r = requests.post(login_path, headers=headers, data=json.dumps(data)) for c in r.cookies: if c.name == 'session': ...
[ "def", "login", "(", "server_path", ",", "email", ",", "password", ")", ":", "data", "=", "{", "\"email\"", ":", "str", "(", "email", ")", ",", "\"password\"", ":", "str", "(", "password", ")", "}", "login_path", "=", "server_path", "+", "'/login'", "h...
Generic login function.
[ "Generic", "login", "function", "." ]
[ "\"\"\"Generic login function. Returns cookie and auth token for Raptor Maps\n Arguments:\n server_path (str): e.g. https://app.raptormaps.com\n email (str): e.g. gavinbelson@raptormaps.com\n password (str): e.g. 123456789\n Returns:\n {session: (hashed_session_string)}, <auth_toke...
[ { "param": "server_path", "type": null }, { "param": "email", "type": null }, { "param": "password", "type": null } ]
{ "returns": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": "{session" } ], "raises": [], "params": [ { "identifier": "server_path", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default":...
d54c195280cd3114c27853ddbaed5e4ef9a975ac
RaptorMaps/raptormaps-api-examples
upload_files.py
[ "MIT" ]
Python
upload_file
<not_specific>
def upload_file(self, filepath): """Uploads one file. First it asks the API for where to place the file on S3, then it uploads the file to S3. It then triggers the Raptor Maps system to ingest the file and peform post processing """ # Determine filename from filepath ...
Uploads one file. First it asks the API for where to place the file on S3, then it uploads the file to S3. It then triggers the Raptor Maps system to ingest the file and peform post processing
Uploads one file. First it asks the API for where to place the file on S3, then it uploads the file to S3. It then triggers the Raptor Maps system to ingest the file and peform post processing
[ "Uploads", "one", "file", ".", "First", "it", "asks", "the", "API", "for", "where", "to", "place", "the", "file", "on", "S3", "then", "it", "uploads", "the", "file", "to", "S3", ".", "It", "then", "triggers", "the", "Raptor", "Maps", "system", "to", ...
def upload_file(self, filepath): filename = os.path.basename(filepath) endpoint = "/api/v2/token/%s/get_s3_post_link" % (self.access_token) url = BASE_URL + endpoint payload = { 'upload_session_id': self.upload_session_id, 'filename': filename } r ...
[ "def", "upload_file", "(", "self", ",", "filepath", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "filepath", ")", "endpoint", "=", "\"/api/v2/token/%s/get_s3_post_link\"", "%", "(", "self", ".", "access_token", ")", "url", "=", "BASE_U...
Uploads one file.
[ "Uploads", "one", "file", "." ]
[ "\"\"\"Uploads one file.\n First it asks the API for where to place the file on S3, then it uploads\n the file to S3. It then triggers the Raptor Maps system to ingest the\n file and peform post processing\n \"\"\"", "# Determine filename from filepath", "# Get AWS S3 post url so we ...
[ { "param": "self", "type": null }, { "param": "filepath", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filepath", "type": null, "docstring": null, "docstring_tokens...
d54c195280cd3114c27853ddbaed5e4ef9a975ac
RaptorMaps/raptormaps-api-examples
upload_files.py
[ "MIT" ]
Python
post_file_to_s3
null
def post_file_to_s3(self, filepath, post, retry_period=10, retry_duration=7200): """Uploads a single file to AWS S3. If the post is unsuccessful it will retry every 10 seconds for 2 hours Args: filepath (str): filepath post (dict): post dictionary from S3 {url: (str), fi...
Uploads a single file to AWS S3. If the post is unsuccessful it will retry every 10 seconds for 2 hours Args: filepath (str): filepath post (dict): post dictionary from S3 {url: (str), fields: dict} retry_period: number of seconds to wait before each rety ...
Uploads a single file to AWS S3. If the post is unsuccessful it will retry every 10 seconds for 2 hours
[ "Uploads", "a", "single", "file", "to", "AWS", "S3", ".", "If", "the", "post", "is", "unsuccessful", "it", "will", "retry", "every", "10", "seconds", "for", "2", "hours" ]
def post_file_to_s3(self, filepath, post, retry_period=10, retry_duration=7200): url = post['url'] fields = post['fields'] files = {'file': open(filepath, 'rb')} for attempt in range(retry_duration): try: r_s3 = requests.post(url, data=fields, files=files) ...
[ "def", "post_file_to_s3", "(", "self", ",", "filepath", ",", "post", ",", "retry_period", "=", "10", ",", "retry_duration", "=", "7200", ")", ":", "url", "=", "post", "[", "'url'", "]", "fields", "=", "post", "[", "'fields'", "]", "files", "=", "{", ...
Uploads a single file to AWS S3.
[ "Uploads", "a", "single", "file", "to", "AWS", "S3", "." ]
[ "\"\"\"Uploads a single file to AWS S3. If the post is unsuccessful\n it will retry every 10 seconds for 2 hours\n\n Args:\n filepath (str): filepath\n post (dict): post dictionary from S3 {url: (str), fields: dict}\n retry_period: number of seconds to wait before each...
[ { "param": "self", "type": null }, { "param": "filepath", "type": null }, { "param": "post", "type": null }, { "param": "retry_period", "type": null }, { "param": "retry_duration", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "filepath", "type": null, "docstring": null, "docstring_tokens...
d54c195280cd3114c27853ddbaed5e4ef9a975ac
RaptorMaps/raptormaps-api-examples
upload_files.py
[ "MIT" ]
Python
upload_files
null
def upload_files(self): """Uploads many files using multi-threading by calling upload_file """ with concurrent.futures.ThreadPoolExecutor(max_workers=self.n_workers) as executor: # Start the load operations and mark each future with its URL future_to_url = { ...
Uploads many files using multi-threading by calling upload_file
Uploads many files using multi-threading by calling upload_file
[ "Uploads", "many", "files", "using", "multi", "-", "threading", "by", "calling", "upload_file" ]
def upload_files(self): with concurrent.futures.ThreadPoolExecutor(max_workers=self.n_workers) as executor: future_to_url = { executor.submit( self.upload_file, x): x for x in self.filepaths} for future in concurrent.futures.as_completed(future_to_url)...
[ "def", "upload_files", "(", "self", ")", ":", "with", "concurrent", ".", "futures", ".", "ThreadPoolExecutor", "(", "max_workers", "=", "self", ".", "n_workers", ")", "as", "executor", ":", "future_to_url", "=", "{", "executor", ".", "submit", "(", "self", ...
Uploads many files using multi-threading by calling upload_file
[ "Uploads", "many", "files", "using", "multi", "-", "threading", "by", "calling", "upload_file" ]
[ "\"\"\"Uploads many files using multi-threading by calling upload_file\n \"\"\"", "# Start the load operations and mark each future with its URL", "# object originally passed" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d54c195280cd3114c27853ddbaed5e4ef9a975ac
RaptorMaps/raptormaps-api-examples
upload_files.py
[ "MIT" ]
Python
create_upload_session
null
def create_upload_session(self): """Creates an upload session in Raptor Maps API First creates an upload session request for each upload session. The upload request contains a token to use for subsequent API calls """ # Create Upload Session endpoint = "/api/v2/token/%s/...
Creates an upload session in Raptor Maps API First creates an upload session request for each upload session. The upload request contains a token to use for subsequent API calls
Creates an upload session in Raptor Maps API First creates an upload session request for each upload session. The upload request contains a token to use for subsequent API calls
[ "Creates", "an", "upload", "session", "in", "Raptor", "Maps", "API", "First", "creates", "an", "upload", "session", "request", "for", "each", "upload", "session", ".", "The", "upload", "request", "contains", "a", "token", "to", "use", "for", "subsequent", "A...
def create_upload_session(self): endpoint = "/api/v2/token/%s/upload_sessions" % (self.access_token) url = BASE_URL + endpoint payload = { 'file_total': len(self.filepaths), 'name': self.session_name, } r = requests.post(url, data=json.dumps(payload), head...
[ "def", "create_upload_session", "(", "self", ")", ":", "endpoint", "=", "\"/api/v2/token/%s/upload_sessions\"", "%", "(", "self", ".", "access_token", ")", "url", "=", "BASE_URL", "+", "endpoint", "payload", "=", "{", "'file_total'", ":", "len", "(", "self", "...
Creates an upload session in Raptor Maps API First creates an upload session request for each upload session.
[ "Creates", "an", "upload", "session", "in", "Raptor", "Maps", "API", "First", "creates", "an", "upload", "session", "request", "for", "each", "upload", "session", "." ]
[ "\"\"\"Creates an upload session in Raptor Maps API\n First creates an upload session request for each upload session.\n The upload request contains a token to use for subsequent API calls\n \"\"\"", "# Create Upload Session", "# POST", "# Make two attempts to create an upload session", ...
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
d54c195280cd3114c27853ddbaed5e4ef9a975ac
RaptorMaps/raptormaps-api-examples
upload_files.py
[ "MIT" ]
Python
run
null
def run(self): """Convenience function to create upload session in Raptor Maps system and upload files to it """ print('---- Uploading: %s' % self.session_name) self.create_upload_session() self.upload_files()
Convenience function to create upload session in Raptor Maps system and upload files to it
Convenience function to create upload session in Raptor Maps system and upload files to it
[ "Convenience", "function", "to", "create", "upload", "session", "in", "Raptor", "Maps", "system", "and", "upload", "files", "to", "it" ]
def run(self): print('---- Uploading: %s' % self.session_name) self.create_upload_session() self.upload_files()
[ "def", "run", "(", "self", ")", ":", "print", "(", "'---- Uploading: %s'", "%", "self", ".", "session_name", ")", "self", ".", "create_upload_session", "(", ")", "self", ".", "upload_files", "(", ")" ]
Convenience function to create upload session in Raptor Maps system and upload files to it
[ "Convenience", "function", "to", "create", "upload", "session", "in", "Raptor", "Maps", "system", "and", "upload", "files", "to", "it" ]
[ "\"\"\"Convenience function to create upload session in Raptor Maps system\n and upload files to it\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
64011a4d7728fce5d24fcb746a56b08724a3fa18
AvivAbramovich/argreq
argreq/__init__.py
[ "Apache-2.0" ]
Python
requirement
<not_specific>
def requirement( expression : str, required : bool = True ): '''Test a general requirement for function argument(s) :param expression: a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc. :param required: bool, ...
Test a general requirement for function argument(s) :param expression: a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc. :param required: bool, Optional. If set to true and one the arguments mentioned in the expression i...
Test a general requirement for function argument(s)
[ "Test", "a", "general", "requirement", "for", "function", "argument", "(", "s", ")" ]
def requirement( expression : str, required : bool = True ): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): search_res = VAR_NAMES_NON_EMPTY_PATTERN.findall(expression) format_kwargs = {} should_eval = True for _, arg...
[ "def", "requirement", "(", "expression", ":", "str", ",", "required", ":", "bool", "=", "True", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "**", "k...
Test a general requirement for function argument(s)
[ "Test", "a", "general", "requirement", "for", "function", "argument", "(", "s", ")" ]
[ "'''Test a general requirement for function argument(s)\n :param expression: a valid python expression using `{arg_name}` to specify the function arguments to test, for example: `{a}>{b}`,`{item} in {a}.values()`, etc.\n :param required: bool, Optional. If set to true and one the arguments mentioned in the ex...
[ { "param": "expression", "type": "str" }, { "param": "required", "type": "bool" } ]
{ "returns": [], "raises": [ { "docstring": null, "docstring_tokens": [ "None" ], "type": null } ], "params": [ { "identifier": "expression", "type": "str", "docstring": "a valid python expression using `{arg_name}` to specify the function arguments ...
8dd599ff60ccf52ae832b25d9261dfef4b2d5fc6
Tran-Phillip/T-RPG
tools/text.py
[ "MIT" ]
Python
listen_for_space
null
def listen_for_space(self): ''' This is a threaded function that will be called by the 'display_text' method. It will listen for the user entering a space and will either continue to the next line of text or finish the scrolling effect on the current line of text ...
This is a threaded function that will be called by the 'display_text' method. It will listen for the user entering a space and will either continue to the next line of text or finish the scrolling effect on the current line of text
This is a threaded function that will be called by the 'display_text' method. It will listen for the user entering a space and will either continue to the next line of text or finish the scrolling effect on the current line of text
[ "This", "is", "a", "threaded", "function", "that", "will", "be", "called", "by", "the", "'", "display_text", "'", "method", ".", "It", "will", "listen", "for", "the", "user", "entering", "a", "space", "and", "will", "either", "continue", "to", "the", "ne...
def listen_for_space(self): with Input(keynames='curses') as input_generator: for e in input_generator: if(self.q.empty()): sys.exit(1) if(e == ' '): self.q.get()
[ "def", "listen_for_space", "(", "self", ")", ":", "with", "Input", "(", "keynames", "=", "'curses'", ")", "as", "input_generator", ":", "for", "e", "in", "input_generator", ":", "if", "(", "self", ".", "q", ".", "empty", "(", ")", ")", ":", "sys", "....
This is a threaded function that will be called by the 'display_text' method.
[ "This", "is", "a", "threaded", "function", "that", "will", "be", "called", "by", "the", "'", "display_text", "'", "method", "." ]
[ "'''\n This is a threaded function that will be called by\n the 'display_text' method. It will listen for the user\n entering a space and will either continue to the next\n line of text or finish the scrolling effect on the\n current line of text\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
8dd599ff60ccf52ae832b25d9261dfef4b2d5fc6
Tran-Phillip/T-RPG
tools/text.py
[ "MIT" ]
Python
display_text
null
def display_text(self,text:str): ''' Displays text on the screen and includes a little scrolling effect ''' listener = threading.Thread(target=self.listen_for_space) listener.start() c_count = range(1,len(text) + 1) for character, pos in zip(text, c_count): ...
Displays text on the screen and includes a little scrolling effect
Displays text on the screen and includes a little scrolling effect
[ "Displays", "text", "on", "the", "screen", "and", "includes", "a", "little", "scrolling", "effect" ]
def display_text(self,text:str): listener = threading.Thread(target=self.listen_for_space) listener.start() c_count = range(1,len(text) + 1) for character, pos in zip(text, c_count): sys.stdout.write(character) sys.stdout.flush() if(pos % 80 == 0):...
[ "def", "display_text", "(", "self", ",", "text", ":", "str", ")", ":", "listener", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "listen_for_space", ")", "listener", ".", "start", "(", ")", "c_count", "=", "range", "(", "1", ",", ...
Displays text on the screen and includes a little scrolling effect
[ "Displays", "text", "on", "the", "screen", "and", "includes", "a", "little", "scrolling", "effect" ]
[ "'''\n Displays text on the screen and includes a little scrolling effect\n '''", "# Having buffer issues when using print(..., end='')" ]
[ { "param": "self", "type": null }, { "param": "text", "type": "str" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "text", "type": "str", "docstring": null, "docstring_tokens": ...
4dd947ba5092e5a23ed31df2b3ccc9e6fd2d465f
Tran-Phillip/T-RPG
game_systems/battle_ui.py
[ "MIT" ]
Python
hover_on_attack
null
def hover_on_attack(self): ''' Display menu with cursor hovering on attack ''' print("---> Attack\n Skill\n Guard\n Item\n Flee\n",end="\r")
Display menu with cursor hovering on attack
Display menu with cursor hovering on attack
[ "Display", "menu", "with", "cursor", "hovering", "on", "attack" ]
def hover_on_attack(self): print("---> Attack\n Skill\n Guard\n Item\n Flee\n",end="\r")
[ "def", "hover_on_attack", "(", "self", ")", ":", "print", "(", "\"---> Attack\\n Skill\\n Guard\\n Item\\n Flee\\n\"", ",", "end", "=", "\"\\r\"", ")" ]
Display menu with cursor hovering on attack
[ "Display", "menu", "with", "cursor", "hovering", "on", "attack" ]
[ "'''\n Display menu with cursor hovering on attack\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4dd947ba5092e5a23ed31df2b3ccc9e6fd2d465f
Tran-Phillip/T-RPG
game_systems/battle_ui.py
[ "MIT" ]
Python
hover_on_skill
null
def hover_on_skill(self): ''' Display menu with cursor hovering on skill ''' print(" Attack\n---> Skill\n Guard\n Item\n Flee\n",end="\r")
Display menu with cursor hovering on skill
Display menu with cursor hovering on skill
[ "Display", "menu", "with", "cursor", "hovering", "on", "skill" ]
def hover_on_skill(self): print(" Attack\n---> Skill\n Guard\n Item\n Flee\n",end="\r")
[ "def", "hover_on_skill", "(", "self", ")", ":", "print", "(", "\" Attack\\n---> Skill\\n Guard\\n Item\\n Flee\\n\"", ",", "end", "=", "\"\\r\"", ")" ]
Display menu with cursor hovering on skill
[ "Display", "menu", "with", "cursor", "hovering", "on", "skill" ]
[ "'''\n Display menu with cursor hovering on skill\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4dd947ba5092e5a23ed31df2b3ccc9e6fd2d465f
Tran-Phillip/T-RPG
game_systems/battle_ui.py
[ "MIT" ]
Python
hover_on_guard
null
def hover_on_guard(self): ''' Display menu with cursor hovering on guard ''' print(" Attack\n Skill\n---> Guard\n Item\n Flee\n",end="\r")
Display menu with cursor hovering on guard
Display menu with cursor hovering on guard
[ "Display", "menu", "with", "cursor", "hovering", "on", "guard" ]
def hover_on_guard(self): print(" Attack\n Skill\n---> Guard\n Item\n Flee\n",end="\r")
[ "def", "hover_on_guard", "(", "self", ")", ":", "print", "(", "\" Attack\\n Skill\\n---> Guard\\n Item\\n Flee\\n\"", ",", "end", "=", "\"\\r\"", ")" ]
Display menu with cursor hovering on guard
[ "Display", "menu", "with", "cursor", "hovering", "on", "guard" ]
[ "'''\n Display menu with cursor hovering on guard\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4dd947ba5092e5a23ed31df2b3ccc9e6fd2d465f
Tran-Phillip/T-RPG
game_systems/battle_ui.py
[ "MIT" ]
Python
hover_on_item
null
def hover_on_item(self): ''' Display menu with cursor hovering on item ''' print(" Attack\n Skill\n Guard\n---> Item\n Flee\n",end="\r")
Display menu with cursor hovering on item
Display menu with cursor hovering on item
[ "Display", "menu", "with", "cursor", "hovering", "on", "item" ]
def hover_on_item(self): print(" Attack\n Skill\n Guard\n---> Item\n Flee\n",end="\r")
[ "def", "hover_on_item", "(", "self", ")", ":", "print", "(", "\" Attack\\n Skill\\n Guard\\n---> Item\\n Flee\\n\"", ",", "end", "=", "\"\\r\"", ")" ]
Display menu with cursor hovering on item
[ "Display", "menu", "with", "cursor", "hovering", "on", "item" ]
[ "'''\n Display menu with cursor hovering on item\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4dd947ba5092e5a23ed31df2b3ccc9e6fd2d465f
Tran-Phillip/T-RPG
game_systems/battle_ui.py
[ "MIT" ]
Python
hover_on_flee
null
def hover_on_flee(self): ''' Display menu with cursor hovering on flee ''' print(" Attack\n Skill\n Guard\n Item\n---> Flee\n",end="\r")
Display menu with cursor hovering on flee
Display menu with cursor hovering on flee
[ "Display", "menu", "with", "cursor", "hovering", "on", "flee" ]
def hover_on_flee(self): print(" Attack\n Skill\n Guard\n Item\n---> Flee\n",end="\r")
[ "def", "hover_on_flee", "(", "self", ")", ":", "print", "(", "\" Attack\\n Skill\\n Guard\\n Item\\n---> Flee\\n\"", ",", "end", "=", "\"\\r\"", ")" ]
Display menu with cursor hovering on flee
[ "Display", "menu", "with", "cursor", "hovering", "on", "flee" ]
[ "'''\n Display menu with cursor hovering on flee\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4dd947ba5092e5a23ed31df2b3ccc9e6fd2d465f
Tran-Phillip/T-RPG
game_systems/battle_ui.py
[ "MIT" ]
Python
listen_for_input_and_space
null
def listen_for_input_and_space(self): ''' This is a threaded function that will be called by the 'display_text' method. It will listen for the user entering a space and will either continue to the next line of text or finish the scrolling effect on the current line of tex...
This is a threaded function that will be called by the 'display_text' method. It will listen for the user entering a space and will either continue to the next line of text or finish the scrolling effect on the current line of text
This is a threaded function that will be called by the 'display_text' method. It will listen for the user entering a space and will either continue to the next line of text or finish the scrolling effect on the current line of text
[ "This", "is", "a", "threaded", "function", "that", "will", "be", "called", "by", "the", "'", "display_text", "'", "method", ".", "It", "will", "listen", "for", "the", "user", "entering", "a", "space", "and", "will", "either", "continue", "to", "the", "ne...
def listen_for_input_and_space(self): with Input(keynames='curses') as input_generator: for e in input_generator: if(e == 'KEY_UP'): self.q.put("UP") elif(e == 'KEY_DOWN'): self.q.put("DOWN") if(e == ' '): ...
[ "def", "listen_for_input_and_space", "(", "self", ")", ":", "with", "Input", "(", "keynames", "=", "'curses'", ")", "as", "input_generator", ":", "for", "e", "in", "input_generator", ":", "if", "(", "e", "==", "'KEY_UP'", ")", ":", "self", ".", "q", ".",...
This is a threaded function that will be called by the 'display_text' method.
[ "This", "is", "a", "threaded", "function", "that", "will", "be", "called", "by", "the", "'", "display_text", "'", "method", "." ]
[ "'''\n This is a threaded function that will be called by\n the 'display_text' method. It will listen for the user\n entering a space and will either continue to the next\n line of text or finish the scrolling effect on the\n current line of text\n '''" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
7d7e1fb8a026a4776ee1115e1ccb72f422129f29
lucasalvescm/api_zero
myapi/auth/views.py
[ "MIT" ]
Python
login
<not_specific>
def login(): """Authenticate user and return token --- tags: - Login """ # if not request.is_json: # return jsonify({"msg": "Missing JSON in request"}), 400 username = request.form.get('username', None) password = request.form.get('password', None) if not username ...
Authenticate user and return token --- tags: - Login
Authenticate user and return token tags: Login
[ "Authenticate", "user", "and", "return", "token", "tags", ":", "Login" ]
def login(): username = request.form.get('username', None) password = request.form.get('password', None) if not username or not password: return jsonify({"msg": "Missing username or password"}), 400 user = User.query.filter_by(username=username).first() if user is None or not pwd_context.ver...
[ "def", "login", "(", ")", ":", "username", "=", "request", ".", "form", ".", "get", "(", "'username'", ",", "None", ")", "password", "=", "request", ".", "form", ".", "get", "(", "'password'", ",", "None", ")", "if", "not", "username", "or", "not", ...
Authenticate user and return token tags: Login
[ "Authenticate", "user", "and", "return", "token", "tags", ":", "Login" ]
[ "\"\"\"Authenticate user and return token\n ---\n tags:\n - Login\n \"\"\"", "# if not request.is_json:", "# return jsonify({\"msg\": \"Missing JSON in request\"}), 400" ]
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
37d9b2e6e795f83bd49b085b4c112b1d2b32b2f4
DiFronzo/SnlData
snldata/client.py
[ "MIT" ]
Python
store_var
null
def store_var(self): """ Local storage for easy grabbing of data """ for key in self.json: if isinstance(self.json[key], dict): for key2 in self.json[key]: setattr(self, key2, self.json[key][key2]) else: setattr(...
Local storage for easy grabbing of data
Local storage for easy grabbing of data
[ "Local", "storage", "for", "easy", "grabbing", "of", "data" ]
def store_var(self): for key in self.json: if isinstance(self.json[key], dict): for key2 in self.json[key]: setattr(self, key2, self.json[key][key2]) else: setattr(self, key, self.json[key])
[ "def", "store_var", "(", "self", ")", ":", "for", "key", "in", "self", ".", "json", ":", "if", "isinstance", "(", "self", ".", "json", "[", "key", "]", ",", "dict", ")", ":", "for", "key2", "in", "self", ".", "json", "[", "key", "]", ":", "seta...
Local storage for easy grabbing of data
[ "Local", "storage", "for", "easy", "grabbing", "of", "data" ]
[ "\"\"\"\n Local storage for easy grabbing of data\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
doesClear
<not_specific>
def doesClear(self): """ Stochastically determines whether this virus particle is cleared from the patient's body at a time step. returns: True with probability self.getClearProb and otherwise returns False. """ if random.random() <= self.getClearProb(): retur...
Stochastically determines whether this virus particle is cleared from the patient's body at a time step. returns: True with probability self.getClearProb and otherwise returns False.
Stochastically determines whether this virus particle is cleared from the patient's body at a time step. returns: True with probability self.getClearProb and otherwise returns False.
[ "Stochastically", "determines", "whether", "this", "virus", "particle", "is", "cleared", "from", "the", "patient", "'", "s", "body", "at", "a", "time", "step", ".", "returns", ":", "True", "with", "probability", "self", ".", "getClearProb", "and", "otherwise",...
def doesClear(self): if random.random() <= self.getClearProb(): return True else: return False
[ "def", "doesClear", "(", "self", ")", ":", "if", "random", ".", "random", "(", ")", "<=", "self", ".", "getClearProb", "(", ")", ":", "return", "True", "else", ":", "return", "False" ]
Stochastically determines whether this virus particle is cleared from the patient's body at a time step.
[ "Stochastically", "determines", "whether", "this", "virus", "particle", "is", "cleared", "from", "the", "patient", "'", "s", "body", "at", "a", "time", "step", "." ]
[ "\"\"\" Stochastically determines whether this virus particle is cleared from the\n patient's body at a time step.\n returns: True with probability self.getClearProb and otherwise returns\n False.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
reproduce
<not_specific>
def reproduce(self, popDensity): """ Stochastically determines whether this virus particle reproduces at a time step. Called by the update() method in the Patient and TreatedPatient classes. The virus particle reproduces with probability self.maxBirthProb * (1 - popDensity). ...
Stochastically determines whether this virus particle reproduces at a time step. Called by the update() method in the Patient and TreatedPatient classes. The virus particle reproduces with probability self.maxBirthProb * (1 - popDensity). If this virus particle reproduces, then...
Stochastically determines whether this virus particle reproduces at a time step. Called by the update() method in the Patient and TreatedPatient classes. The virus particle reproduces with probability self.maxBirthProb * (1 - popDensity). If this virus particle reproduces, then reproduce() creates and returns the inst...
[ "Stochastically", "determines", "whether", "this", "virus", "particle", "reproduces", "at", "a", "time", "step", ".", "Called", "by", "the", "update", "()", "method", "in", "the", "Patient", "and", "TreatedPatient", "classes", ".", "The", "virus", "particle", ...
def reproduce(self, popDensity): if random.random() <= (self.maxBirthProb * (1 - popDensity)): return SimpleVirus(self.maxBirthProb, self.clearProb) else: raise NoChildException('NoChildException')
[ "def", "reproduce", "(", "self", ",", "popDensity", ")", ":", "if", "random", ".", "random", "(", ")", "<=", "(", "self", ".", "maxBirthProb", "*", "(", "1", "-", "popDensity", ")", ")", ":", "return", "SimpleVirus", "(", "self", ".", "maxBirthProb", ...
Stochastically determines whether this virus particle reproduces at a time step.
[ "Stochastically", "determines", "whether", "this", "virus", "particle", "reproduces", "at", "a", "time", "step", "." ]
[ "\"\"\"\n Stochastically determines whether this virus particle reproduces at a\n time step. Called by the update() method in the Patient and\n TreatedPatient classes. The virus particle reproduces with probability\n self.maxBirthProb * (1 - popDensity).\n\n If this virus particle...
[ { "param": "self", "type": null }, { "param": "popDensity", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "popDensity", "type": null, "docstring": null, "docstring_toke...
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
update
<not_specific>
def update(self): """ Update the state of the virus population in this patient for a single time step. returns: The total virus population at the end of the update (an integer) """ copyViruses = self.getViruses()[:] for virus in copyViruses: i...
Update the state of the virus population in this patient for a single time step. returns: The total virus population at the end of the update (an integer)
Update the state of the virus population in this patient for a single time step. The total virus population at the end of the update (an integer)
[ "Update", "the", "state", "of", "the", "virus", "population", "in", "this", "patient", "for", "a", "single", "time", "step", ".", "The", "total", "virus", "population", "at", "the", "end", "of", "the", "update", "(", "an", "integer", ")" ]
def update(self): copyViruses = self.getViruses()[:] for virus in copyViruses: if virus.doesClear(): self.viruses.remove(virus) if self.getPopDensity() < 1: copyViruses = self.getViruses()[:] for virus in copyViruses: try: ...
[ "def", "update", "(", "self", ")", ":", "copyViruses", "=", "self", ".", "getViruses", "(", ")", "[", ":", "]", "for", "virus", "in", "copyViruses", ":", "if", "virus", ".", "doesClear", "(", ")", ":", "self", ".", "viruses", ".", "remove", "(", "v...
Update the state of the virus population in this patient for a single time step.
[ "Update", "the", "state", "of", "the", "virus", "population", "in", "this", "patient", "for", "a", "single", "time", "step", "." ]
[ "\"\"\"\n Update the state of the virus population in this patient for a single\n time step.\n\n returns: The total virus population at the end of the update (an\n integer)\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
simulationWithoutDrug
null
def simulationWithoutDrug(numViruses, maxPop, maxBirthProb, clearProb, numTrials): """ Run the simulation and plot the graph when no drugs are used and viruses do not have any drug resistance. For each of numTrials trial, instantiates a patient, runs a simulation for 300 ti...
Run the simulation and plot the graph when no drugs are used and viruses do not have any drug resistance. For each of numTrials trial, instantiates a patient, runs a simulation for 300 timesteps, and plots the average virus population size as a function of time. numViruses: number of SimpleVir...
Run the simulation and plot the graph when no drugs are used and viruses do not have any drug resistance. For each of numTrials trial, instantiates a patient, runs a simulation for 300 timesteps, and plots the average virus population size as a function of time. number of SimpleVirus to create for patient (an integer)...
[ "Run", "the", "simulation", "and", "plot", "the", "graph", "when", "no", "drugs", "are", "used", "and", "viruses", "do", "not", "have", "any", "drug", "resistance", ".", "For", "each", "of", "numTrials", "trial", "instantiates", "a", "patient", "runs", "a"...
def simulationWithoutDrug(numViruses, maxPop, maxBirthProb, clearProb, numTrials): numTimesteps = 300 virusPopulationPerTrial = {x: () for x in range(numTimesteps)} for trial in range(numTrials): viruses = [SimpleVirus(maxBirthProb, clearProb) for x in ra...
[ "def", "simulationWithoutDrug", "(", "numViruses", ",", "maxPop", ",", "maxBirthProb", ",", "clearProb", ",", "numTrials", ")", ":", "numTimesteps", "=", "300", "virusPopulationPerTrial", "=", "{", "x", ":", "(", ")", "for", "x", "in", "range", "(", "numTime...
Run the simulation and plot the graph when no drugs are used and viruses do not have any drug resistance.
[ "Run", "the", "simulation", "and", "plot", "the", "graph", "when", "no", "drugs", "are", "used", "and", "viruses", "do", "not", "have", "any", "drug", "resistance", "." ]
[ "\"\"\"\n Run the simulation and plot the graph when no drugs are used and\n viruses do not have any drug resistance.\n For each of numTrials trial, instantiates a patient, runs a simulation\n for 300 timesteps, and plots the average virus population size as a\n function of time.\n\n numViruses: n...
[ { "param": "numViruses", "type": null }, { "param": "maxPop", "type": null }, { "param": "maxBirthProb", "type": null }, { "param": "clearProb", "type": null }, { "param": "numTrials", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "numViruses", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "maxPop", "type": null, "docstring": null, "docstring_to...
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
isResistantTo
<not_specific>
def isResistantTo(self, drug): """ Get the state of this virus particle's resistance to a drug. This method is called by getResistPop() in TreatedPatient to determine how many virus particles have resistance to a drug. drug: The drug (a string) returns: True if this vir...
Get the state of this virus particle's resistance to a drug. This method is called by getResistPop() in TreatedPatient to determine how many virus particles have resistance to a drug. drug: The drug (a string) returns: True if this virus instance is resistant to the drug, Fals...
Get the state of this virus particle's resistance to a drug. This method is called by getResistPop() in TreatedPatient to determine how many virus particles have resistance to a drug. The drug (a string) True if this virus instance is resistant to the drug, False otherwise.
[ "Get", "the", "state", "of", "this", "virus", "particle", "'", "s", "resistance", "to", "a", "drug", ".", "This", "method", "is", "called", "by", "getResistPop", "()", "in", "TreatedPatient", "to", "determine", "how", "many", "virus", "particles", "have", ...
def isResistantTo(self, drug): try: if self.getResistances()[drug]: return True else: return False except KeyError: return False
[ "def", "isResistantTo", "(", "self", ",", "drug", ")", ":", "try", ":", "if", "self", ".", "getResistances", "(", ")", "[", "drug", "]", ":", "return", "True", "else", ":", "return", "False", "except", "KeyError", ":", "return", "False" ]
Get the state of this virus particle's resistance to a drug.
[ "Get", "the", "state", "of", "this", "virus", "particle", "'", "s", "resistance", "to", "a", "drug", "." ]
[ "\"\"\"\n Get the state of this virus particle's resistance to a drug. This\n method is called by getResistPop() in TreatedPatient to determine\n how many virus particles have resistance to a drug.\n\n drug: The drug (a string)\n\n returns: True if this virus instance is resistant...
[ { "param": "self", "type": null }, { "param": "drug", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "drug", "type": null, "docstring": null, "docstring_tokens": [...
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
reproduce
<not_specific>
def reproduce(self, popDensity, activeDrugs): """ Stochastically determines whether this virus particle reproduces at a time step. Called by the update() method in the TreatedPatient class. popDensity: the population density (a float), defined as the current virus population div...
Stochastically determines whether this virus particle reproduces at a time step. Called by the update() method in the TreatedPatient class. popDensity: the population density (a float), defined as the current virus population divided by the maximum population. activeDrugs: a l...
Stochastically determines whether this virus particle reproduces at a time step. Called by the update() method in the TreatedPatient class. the population density (a float), defined as the current virus population divided by the maximum population. a list of the drug names acting on this virus particle (a list of str...
[ "Stochastically", "determines", "whether", "this", "virus", "particle", "reproduces", "at", "a", "time", "step", ".", "Called", "by", "the", "update", "()", "method", "in", "the", "TreatedPatient", "class", ".", "the", "population", "density", "(", "a", "float...
def reproduce(self, popDensity, activeDrugs): for drug in activeDrugs: if not self.isResistantTo(drug): raise NoChildException('NoChildException') inheritance = dict(self.getResistances()) for trait in inheritance: if random.random() <= self.getMutProb(): ...
[ "def", "reproduce", "(", "self", ",", "popDensity", ",", "activeDrugs", ")", ":", "for", "drug", "in", "activeDrugs", ":", "if", "not", "self", ".", "isResistantTo", "(", "drug", ")", ":", "raise", "NoChildException", "(", "'NoChildException'", ")", "inherit...
Stochastically determines whether this virus particle reproduces at a time step.
[ "Stochastically", "determines", "whether", "this", "virus", "particle", "reproduces", "at", "a", "time", "step", "." ]
[ "\"\"\"\n Stochastically determines whether this virus particle reproduces at a\n time step. Called by the update() method in the TreatedPatient class.\n\n popDensity: the population density (a float), defined as the current\n virus population divided by the maximum population.\n\n ...
[ { "param": "self", "type": null }, { "param": "popDensity", "type": null }, { "param": "activeDrugs", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "popDensity", "type": null, "docstring": null, "docstring_toke...
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
addPrescription
null
def addPrescription(self, newDrug): """ Administer a drug to this patient. After a prescription is added, the drug acts on the virus population for all subsequent time steps. If the newDrug is already prescribed to this patient, the method has no effect. newDrug: The nam...
Administer a drug to this patient. After a prescription is added, the drug acts on the virus population for all subsequent time steps. If the newDrug is already prescribed to this patient, the method has no effect. newDrug: The name of the drug to administer to the patient (a s...
Administer a drug to this patient. After a prescription is added, the drug acts on the virus population for all subsequent time steps. If the newDrug is already prescribed to this patient, the method has no effect. The name of the drug to administer to the patient (a string). The list of drugs being administered to a...
[ "Administer", "a", "drug", "to", "this", "patient", ".", "After", "a", "prescription", "is", "added", "the", "drug", "acts", "on", "the", "virus", "population", "for", "all", "subsequent", "time", "steps", ".", "If", "the", "newDrug", "is", "already", "pre...
def addPrescription(self, newDrug): if newDrug not in self.getPrescriptions(): self.prescriptions.append(newDrug)
[ "def", "addPrescription", "(", "self", ",", "newDrug", ")", ":", "if", "newDrug", "not", "in", "self", ".", "getPrescriptions", "(", ")", ":", "self", ".", "prescriptions", ".", "append", "(", "newDrug", ")" ]
Administer a drug to this patient.
[ "Administer", "a", "drug", "to", "this", "patient", "." ]
[ "\"\"\"\n Administer a drug to this patient. After a prescription is added, the\n drug acts on the virus population for all subsequent time steps. If the\n newDrug is already prescribed to this patient, the method has no\n effect.\n\n newDrug: The name of the drug to administer to...
[ { "param": "self", "type": null }, { "param": "newDrug", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "newDrug", "type": null, "docstring": null, "docstring_tokens"...
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
update
<not_specific>
def update(self): """ Update the state of the virus population in this patient for a single time step. returns: The total virus population at the end of the update (an integer) """ copyViruses = self.getViruses()[:] for virus in copyViruses: i...
Update the state of the virus population in this patient for a single time step. returns: The total virus population at the end of the update (an integer)
Update the state of the virus population in this patient for a single time step. The total virus population at the end of the update (an integer)
[ "Update", "the", "state", "of", "the", "virus", "population", "in", "this", "patient", "for", "a", "single", "time", "step", ".", "The", "total", "virus", "population", "at", "the", "end", "of", "the", "update", "(", "an", "integer", ")" ]
def update(self): copyViruses = self.getViruses()[:] for virus in copyViruses: if virus.doesClear(): self.viruses.remove(virus) if self.getPopDensity() < 1: copyViruses = self.getViruses()[:] for virus in copyViruses: try: ...
[ "def", "update", "(", "self", ")", ":", "copyViruses", "=", "self", ".", "getViruses", "(", ")", "[", ":", "]", "for", "virus", "in", "copyViruses", ":", "if", "virus", ".", "doesClear", "(", ")", ":", "self", ".", "viruses", ".", "remove", "(", "v...
Update the state of the virus population in this patient for a single time step.
[ "Update", "the", "state", "of", "the", "virus", "population", "in", "this", "patient", "for", "a", "single", "time", "step", "." ]
[ "\"\"\"\n Update the state of the virus population in this patient for a single\n time step.\n\n returns: The total virus population at the end of the update (an\n integer)\n \"\"\"", "# Line bellow broken to comply with pep8" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
60557fb72d492e205f686666c289051ff120ba3d
thiagork/MIT-6.00.2x
6.00.2x-pset3.py
[ "MIT" ]
Python
simulationWithDrug
null
def simulationWithDrug(numViruses, maxPop, maxBirthProb, clearProb, resistances, mutProb, numTrials): """ For each of numTrials trials, instantiates a patient, runs a simulation for 150 timesteps, adds guttagonol, and runs the simulation for an additional 150 timesteps. At the en...
For each of numTrials trials, instantiates a patient, runs a simulation for 150 timesteps, adds guttagonol, and runs the simulation for an additional 150 timesteps. At the end plots the average virus population size (for both the total virus population and the guttagonol-resistant virus population...
For each of numTrials trials, instantiates a patient, runs a simulation for 150 timesteps, adds guttagonol, and runs the simulation for an additional 150 timesteps. At the end plots the average virus population size (for both the total virus population and the guttagonol-resistant virus population) as a function of ti...
[ "For", "each", "of", "numTrials", "trials", "instantiates", "a", "patient", "runs", "a", "simulation", "for", "150", "timesteps", "adds", "guttagonol", "and", "runs", "the", "simulation", "for", "an", "additional", "150", "timesteps", ".", "At", "the", "end", ...
def simulationWithDrug(numViruses, maxPop, maxBirthProb, clearProb, resistances, mutProb, numTrials): numTimesteps = 300 virusPopulationPerTrial = {x: () for x in range(numTimesteps)} resistantVirusPopulationPerTrial = dict(virusPopulationPerTrial) for trial in range(numTrials): ...
[ "def", "simulationWithDrug", "(", "numViruses", ",", "maxPop", ",", "maxBirthProb", ",", "clearProb", ",", "resistances", ",", "mutProb", ",", "numTrials", ")", ":", "numTimesteps", "=", "300", "virusPopulationPerTrial", "=", "{", "x", ":", "(", ")", "for", ...
For each of numTrials trials, instantiates a patient, runs a simulation for 150 timesteps, adds guttagonol, and runs the simulation for an additional 150 timesteps.
[ "For", "each", "of", "numTrials", "trials", "instantiates", "a", "patient", "runs", "a", "simulation", "for", "150", "timesteps", "adds", "guttagonol", "and", "runs", "the", "simulation", "for", "an", "additional", "150", "timesteps", "." ]
[ "\"\"\"\n For each of numTrials trials, instantiates a patient, runs a simulation for\n 150 timesteps, adds guttagonol, and runs the simulation for an additional\n 150 timesteps. At the end plots the average virus population size\n (for both the total virus population and the guttagonol-resistant virus...
[ { "param": "numViruses", "type": null }, { "param": "maxPop", "type": null }, { "param": "maxBirthProb", "type": null }, { "param": "clearProb", "type": null }, { "param": "resistances", "type": null }, { "param": "mutProb", "type": null }, { ...
{ "returns": [], "raises": [], "params": [ { "identifier": "numViruses", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "maxPop", "type": null, "docstring": null, "docstring_to...
4431211d78545682b8423aba460f89b45c95d305
thiagork/MIT-6.00.2x
6.00.2x-pset2.py
[ "MIT" ]
Python
testRobotMovement
null
def testRobotMovement(robot_type, room_type, delay=0.4): """ Runs a simulation of a single robot of type robot_type in a 5x5 room. """ room = room_type(5, 5) robot = robot_type(room, 1) anim = ps2_visualize.RobotVisualization(1, 5, 5, delay) while room.getNumCleanedTiles() / room.getNumTiles...
Runs a simulation of a single robot of type robot_type in a 5x5 room.
Runs a simulation of a single robot of type robot_type in a 5x5 room.
[ "Runs", "a", "simulation", "of", "a", "single", "robot", "of", "type", "robot_type", "in", "a", "5x5", "room", "." ]
def testRobotMovement(robot_type, room_type, delay=0.4): room = room_type(5, 5) robot = robot_type(room, 1) anim = ps2_visualize.RobotVisualization(1, 5, 5, delay) while room.getNumCleanedTiles() / room.getNumTiles() < 1: robot.updatePositionAndClean() anim.update(room, [robot]) anim...
[ "def", "testRobotMovement", "(", "robot_type", ",", "room_type", ",", "delay", "=", "0.4", ")", ":", "room", "=", "room_type", "(", "5", ",", "5", ")", "robot", "=", "robot_type", "(", "room", ",", "1", ")", "anim", "=", "ps2_visualize", ".", "RobotVis...
Runs a simulation of a single robot of type robot_type in a 5x5 room.
[ "Runs", "a", "simulation", "of", "a", "single", "robot", "of", "type", "robot_type", "in", "a", "5x5", "room", "." ]
[ "\"\"\"\n Runs a simulation of a single robot of type robot_type in a 5x5 room.\n \"\"\"" ]
[ { "param": "robot_type", "type": null }, { "param": "room_type", "type": null }, { "param": "delay", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "robot_type", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "room_type", "type": null, "docstring": null, "docstring...
4431211d78545682b8423aba460f89b45c95d305
thiagork/MIT-6.00.2x
6.00.2x-pset2.py
[ "MIT" ]
Python
cleanTileAtPosition
null
def cleanTileAtPosition(self, pos): """ Mark the tile under the position POS as cleaned. Assumes that POS represents a valid position inside this room. pos: a Position """ self.room[math.floor(pos.getY())][math.floor(pos.getX())] = True
Mark the tile under the position POS as cleaned. Assumes that POS represents a valid position inside this room. pos: a Position
Mark the tile under the position POS as cleaned. Assumes that POS represents a valid position inside this room. a Position
[ "Mark", "the", "tile", "under", "the", "position", "POS", "as", "cleaned", ".", "Assumes", "that", "POS", "represents", "a", "valid", "position", "inside", "this", "room", ".", "a", "Position" ]
def cleanTileAtPosition(self, pos): self.room[math.floor(pos.getY())][math.floor(pos.getX())] = True
[ "def", "cleanTileAtPosition", "(", "self", ",", "pos", ")", ":", "self", ".", "room", "[", "math", ".", "floor", "(", "pos", ".", "getY", "(", ")", ")", "]", "[", "math", ".", "floor", "(", "pos", ".", "getX", "(", ")", ")", "]", "=", "True" ]
Mark the tile under the position POS as cleaned.
[ "Mark", "the", "tile", "under", "the", "position", "POS", "as", "cleaned", "." ]
[ "\"\"\"\n Mark the tile under the position POS as cleaned.\n\n Assumes that POS represents a valid position inside this room.\n\n pos: a Position\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "pos", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": null, "docstring": null, "docstring_tokens": []...
4431211d78545682b8423aba460f89b45c95d305
thiagork/MIT-6.00.2x
6.00.2x-pset2.py
[ "MIT" ]
Python
isPositionInRoom
<not_specific>
def isPositionInRoom(self, pos): """ Return True if pos is inside the room. pos: a Position object. returns: True if pos is in the room, False otherwise. """ if pos.getX() < 0 or pos.getY() < 0: return False return (pos.getX() < self.width and pos.get...
Return True if pos is inside the room. pos: a Position object. returns: True if pos is in the room, False otherwise.
Return True if pos is inside the room. pos: a Position object. returns: True if pos is in the room, False otherwise.
[ "Return", "True", "if", "pos", "is", "inside", "the", "room", ".", "pos", ":", "a", "Position", "object", ".", "returns", ":", "True", "if", "pos", "is", "in", "the", "room", "False", "otherwise", "." ]
def isPositionInRoom(self, pos): if pos.getX() < 0 or pos.getY() < 0: return False return (pos.getX() < self.width and pos.getY() < self.height)
[ "def", "isPositionInRoom", "(", "self", ",", "pos", ")", ":", "if", "pos", ".", "getX", "(", ")", "<", "0", "or", "pos", ".", "getY", "(", ")", "<", "0", ":", "return", "False", "return", "(", "pos", ".", "getX", "(", ")", "<", "self", ".", "...
Return True if pos is inside the room.
[ "Return", "True", "if", "pos", "is", "inside", "the", "room", "." ]
[ "\"\"\"\n Return True if pos is inside the room.\n\n pos: a Position object.\n returns: True if pos is in the room, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "pos", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "pos", "type": null, "docstring": null, "docstring_tokens": []...
4431211d78545682b8423aba460f89b45c95d305
thiagork/MIT-6.00.2x
6.00.2x-pset2.py
[ "MIT" ]
Python
updatePositionAndClean
null
def updatePositionAndClean(self): """ Simulate the passage of a single time-step. Move the robot to a new position and mark the tile it is on as having been cleaned. """ # Line bellow broken to comply with pep8 newPosition = self.currentPosition.getNewPosition( ...
Simulate the passage of a single time-step. Move the robot to a new position and mark the tile it is on as having been cleaned.
Simulate the passage of a single time-step. Move the robot to a new position and mark the tile it is on as having been cleaned.
[ "Simulate", "the", "passage", "of", "a", "single", "time", "-", "step", ".", "Move", "the", "robot", "to", "a", "new", "position", "and", "mark", "the", "tile", "it", "is", "on", "as", "having", "been", "cleaned", "." ]
def updatePositionAndClean(self): newPosition = self.currentPosition.getNewPosition( self.currentDirection, self.speed ) if self.room.isPositionInRoom(newPosition): self.currentPosition = newPosition self.room.cleanTileAtPosition(self.c...
[ "def", "updatePositionAndClean", "(", "self", ")", ":", "newPosition", "=", "self", ".", "currentPosition", ".", "getNewPosition", "(", "self", ".", "currentDirection", ",", "self", ".", "speed", ")", "if", "self", ".", "room", ".", "isPositionInRoom", "(", ...
Simulate the passage of a single time-step.
[ "Simulate", "the", "passage", "of", "a", "single", "time", "-", "step", "." ]
[ "\"\"\"\n Simulate the passage of a single time-step.\n\n Move the robot to a new position and mark the tile it is on as having\n been cleaned.\n \"\"\"", "# Line bellow broken to comply with pep8" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4431211d78545682b8423aba460f89b45c95d305
thiagork/MIT-6.00.2x
6.00.2x-pset2.py
[ "MIT" ]
Python
updatePositionAndClean
null
def updatePositionAndClean(self): """ Simulate the passage of a single time-step. Move the robot to a new position and mark the tile it is on as having been cleaned. """ newDirection = self.currentDirection while newDirection == self.currentDirection: ...
Simulate the passage of a single time-step. Move the robot to a new position and mark the tile it is on as having been cleaned.
Simulate the passage of a single time-step. Move the robot to a new position and mark the tile it is on as having been cleaned.
[ "Simulate", "the", "passage", "of", "a", "single", "time", "-", "step", ".", "Move", "the", "robot", "to", "a", "new", "position", "and", "mark", "the", "tile", "it", "is", "on", "as", "having", "been", "cleaned", "." ]
def updatePositionAndClean(self): newDirection = self.currentDirection while newDirection == self.currentDirection: newDirection = random.randrange(0, 360) self.currentDirection = newDirection newPosition = self.currentPosition.getNewPosition( newDirecti...
[ "def", "updatePositionAndClean", "(", "self", ")", ":", "newDirection", "=", "self", ".", "currentDirection", "while", "newDirection", "==", "self", ".", "currentDirection", ":", "newDirection", "=", "random", ".", "randrange", "(", "0", ",", "360", ")", "self...
Simulate the passage of a single time-step.
[ "Simulate", "the", "passage", "of", "a", "single", "time", "-", "step", "." ]
[ "\"\"\"\n Simulate the passage of a single time-step.\n\n Move the robot to a new position and mark the tile it is on as having\n been cleaned.\n \"\"\"", "# Line bellow broken to comply with pep8" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
4431211d78545682b8423aba460f89b45c95d305
thiagork/MIT-6.00.2x
6.00.2x-pset2.py
[ "MIT" ]
Python
runSimulation
<not_specific>
def runSimulation(num_robots, speed, width, height, min_coverage, num_trials, robot_type): """ Runs NUM_TRIALS trials of the simulation and returns the mean number of time-steps needed to clean the fraction MIN_COVERAGE of the room. The simulation is run with NUM_ROBOTS robots of type...
Runs NUM_TRIALS trials of the simulation and returns the mean number of time-steps needed to clean the fraction MIN_COVERAGE of the room. The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with speed SPEED, in a room of dimensions WIDTH x HEIGHT. num_robots: an int (num_robots ...
Runs NUM_TRIALS trials of the simulation and returns the mean number of time-steps needed to clean the fraction MIN_COVERAGE of the room. The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with speed SPEED, in a room of dimensions WIDTH x HEIGHT. Cleaning time in timesteps
[ "Runs", "NUM_TRIALS", "trials", "of", "the", "simulation", "and", "returns", "the", "mean", "number", "of", "time", "-", "steps", "needed", "to", "clean", "the", "fraction", "MIN_COVERAGE", "of", "the", "room", ".", "The", "simulation", "is", "run", "with", ...
def runSimulation(num_robots, speed, width, height, min_coverage, num_trials, robot_type): assert num_robots > 0 and type(num_robots) == int assert speed > 0 and type(speed) == float assert width > 0 and type(width) == int assert height > 0 and type(height) == int assert (min_cover...
[ "def", "runSimulation", "(", "num_robots", ",", "speed", ",", "width", ",", "height", ",", "min_coverage", ",", "num_trials", ",", "robot_type", ")", ":", "assert", "num_robots", ">", "0", "and", "type", "(", "num_robots", ")", "==", "int", "assert", "spee...
Runs NUM_TRIALS trials of the simulation and returns the mean number of time-steps needed to clean the fraction MIN_COVERAGE of the room.
[ "Runs", "NUM_TRIALS", "trials", "of", "the", "simulation", "and", "returns", "the", "mean", "number", "of", "time", "-", "steps", "needed", "to", "clean", "the", "fraction", "MIN_COVERAGE", "of", "the", "room", "." ]
[ "\"\"\"\n Runs NUM_TRIALS trials of the simulation and returns the mean number of\n time-steps needed to clean the fraction MIN_COVERAGE of the room.\n\n The simulation is run with NUM_ROBOTS robots of type ROBOT_TYPE, each with\n speed SPEED, in a room of dimensions WIDTH x HEIGHT.\n\n num_robots: a...
[ { "param": "num_robots", "type": null }, { "param": "speed", "type": null }, { "param": "width", "type": null }, { "param": "height", "type": null }, { "param": "min_coverage", "type": null }, { "param": "num_trials", "type": null }, { "par...
{ "returns": [], "raises": [], "params": [ { "identifier": "num_robots", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "speed", "type": null, "docstring": null, "docstring_tok...
c53e6c75b13a951e9451dc8bc7860603f02dc31a
thiagork/MIT-6.00.2x
6.00.2x-pset1.py
[ "MIT" ]
Python
greedy_cow_transport
<not_specific>
def greedy_cow_transport(cows, limit=10): """ Uses a greedy heuristic to determine an allocation of cows that attempts to minimize the number of spaceship trips needed to transport all the cows. The returned allocation of cows may or may not be optimal. The greedy heuristic follows the following met...
Uses a greedy heuristic to determine an allocation of cows that attempts to minimize the number of spaceship trips needed to transport all the cows. The returned allocation of cows may or may not be optimal. The greedy heuristic follows the following method: 1. As long as the current trip can fit ...
Uses a greedy heuristic to determine an allocation of cows that attempts to minimize the number of spaceship trips needed to transport all the cows. The returned allocation of cows may or may not be optimal. The greedy heuristic follows the following method. 1. As long as the current trip can fit another cow, add the ...
[ "Uses", "a", "greedy", "heuristic", "to", "determine", "an", "allocation", "of", "cows", "that", "attempts", "to", "minimize", "the", "number", "of", "spaceship", "trips", "needed", "to", "transport", "all", "the", "cows", ".", "The", "returned", "allocation",...
def greedy_cow_transport(cows, limit=10): cowsLeft = dict(cows) result = [] while cowsLeft != {}: trip = [] totalWeight = 0 for i in sorted(cowsLeft, key=cowsLeft.get)[::-1]: if (totalWeight + cowsLeft[i]) <= limit: trip.append(i) totalWeig...
[ "def", "greedy_cow_transport", "(", "cows", ",", "limit", "=", "10", ")", ":", "cowsLeft", "=", "dict", "(", "cows", ")", "result", "=", "[", "]", "while", "cowsLeft", "!=", "{", "}", ":", "trip", "=", "[", "]", "totalWeight", "=", "0", "for", "i",...
Uses a greedy heuristic to determine an allocation of cows that attempts to minimize the number of spaceship trips needed to transport all the cows.
[ "Uses", "a", "greedy", "heuristic", "to", "determine", "an", "allocation", "of", "cows", "that", "attempts", "to", "minimize", "the", "number", "of", "spaceship", "trips", "needed", "to", "transport", "all", "the", "cows", "." ]
[ "\"\"\"\n Uses a greedy heuristic to determine an allocation of cows that attempts to\n minimize the number of spaceship trips needed to transport all the cows.\n The returned allocation of cows may or may not be optimal.\n The greedy heuristic follows the following method:\n\n 1. As long as the curr...
[ { "param": "cows", "type": null }, { "param": "limit", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cows", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "limit", "type": null, "docstring": null, "docstring_tokens": ...
c53e6c75b13a951e9451dc8bc7860603f02dc31a
thiagork/MIT-6.00.2x
6.00.2x-pset1.py
[ "MIT" ]
Python
brute_force_cow_transport
<not_specific>
def brute_force_cow_transport(cows, limit=10): """ Finds the allocation of cows that minimizes the number of spaceship trips via brute force. The brute force algorithm follows the following method: 1. Enumerate all possible ways that the cows can be divided into separate trips. 2. Select the a...
Finds the allocation of cows that minimizes the number of spaceship trips via brute force. The brute force algorithm follows the following method: 1. Enumerate all possible ways that the cows can be divided into separate trips. 2. Select the allocation that minimizes the number of trips without m...
Finds the allocation of cows that minimizes the number of spaceship trips via brute force. The brute force algorithm follows the following method. 1. Enumerate all possible ways that the cows can be divided into separate trips. 2. Select the allocation that minimizes the number of trips without making any trip that d...
[ "Finds", "the", "allocation", "of", "cows", "that", "minimizes", "the", "number", "of", "spaceship", "trips", "via", "brute", "force", ".", "The", "brute", "force", "algorithm", "follows", "the", "following", "method", ".", "1", ".", "Enumerate", "all", "pos...
def brute_force_cow_transport(cows, limit=10): listCows = list(get_partitions(cows)) numberOfTrips = len(cows.keys()) + 1 result = [] for i in range(len(listCows)): if len(listCows[i]) < numberOfTrips: for j in range(len(listCows[i])): totalWeight = 0 ...
[ "def", "brute_force_cow_transport", "(", "cows", ",", "limit", "=", "10", ")", ":", "listCows", "=", "list", "(", "get_partitions", "(", "cows", ")", ")", "numberOfTrips", "=", "len", "(", "cows", ".", "keys", "(", ")", ")", "+", "1", "result", "=", ...
Finds the allocation of cows that minimizes the number of spaceship trips via brute force.
[ "Finds", "the", "allocation", "of", "cows", "that", "minimizes", "the", "number", "of", "spaceship", "trips", "via", "brute", "force", "." ]
[ "\"\"\"\n Finds the allocation of cows that minimizes the number of spaceship trips\n via brute force. The brute force algorithm follows the following method:\n\n 1. Enumerate all possible ways that the cows can be divided into separate\n trips.\n 2. Select the allocation that minimizes the number o...
[ { "param": "cows", "type": null }, { "param": "limit", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "cows", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "limit", "type": null, "docstring": null, "docstring_tokens": ...
f675d38371b5b049c31a6183dc60627d02aa4694
mhilmiasyrofi/cifar10_challenge
blob_rand_cifar.py
[ "MIT" ]
Python
perturb
<not_specific>
def perturb(self, x_nat, x_adv, y, sess): """Given a set of examples (x_nat, y), returns a set of adversarial examples within epsilon of x_nat in l_infinity norm.""" batch_size = x_adv.shape[0] for epoch in range(10): # x_adv = np.array(x_adv).reshape(x_adv.shape[0], 32,32,3) ...
Given a set of examples (x_nat, y), returns a set of adversarial examples within epsilon of x_nat in l_infinity norm.
Given a set of examples (x_nat, y), returns a set of adversarial examples within epsilon of x_nat in l_infinity norm.
[ "Given", "a", "set", "of", "examples", "(", "x_nat", "y", ")", "returns", "a", "set", "of", "adversarial", "examples", "within", "epsilon", "of", "x_nat", "in", "l_infinity", "norm", "." ]
def perturb(self, x_nat, x_adv, y, sess): batch_size = x_adv.shape[0] for epoch in range(10): grad = sess.run(self.grad, feed_dict={self.model.x_input: np.array(x_adv).reshape(x_adv.shape[0], 32,32,3), self.model.y_input: y}) grad = np.array(grad).reshape...
[ "def", "perturb", "(", "self", ",", "x_nat", ",", "x_adv", ",", "y", ",", "sess", ")", ":", "batch_size", "=", "x_adv", ".", "shape", "[", "0", "]", "for", "epoch", "in", "range", "(", "10", ")", ":", "grad", "=", "sess", ".", "run", "(", "self...
Given a set of examples (x_nat, y), returns a set of adversarial examples within epsilon of x_nat in l_infinity norm.
[ "Given", "a", "set", "of", "examples", "(", "x_nat", "y", ")", "returns", "a", "set", "of", "adversarial", "examples", "within", "epsilon", "of", "x_nat", "in", "l_infinity", "norm", "." ]
[ "\"\"\"Given a set of examples (x_nat, y), returns a set of adversarial\n examples within epsilon of x_nat in l_infinity norm.\"\"\"", "# x_adv = np.array(x_adv).reshape(x_adv.shape[0], 32,32,3)", "# kxy, dxkxy = self.svgd_kernel(np.array(x_adv).reshape(x_adv.shape[0], 32,32,3))", "# p...
[ { "param": "self", "type": null }, { "param": "x_nat", "type": null }, { "param": "x_adv", "type": null }, { "param": "y", "type": null }, { "param": "sess", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "x_nat", "type": null, "docstring": null, "docstring_tokens": ...
139ee686befd953effaaa732d959affd7b6bc870
pb-new-username/nba-sql
stats/play_by_play.py
[ "Apache-2.0" ]
Python
fetch_game
<not_specific>
def fetch_game(self, game_id): """ Build GET REST request to the NBA for a game, iterate over the results and return them. """ params = self.build_params(game_id) # Encode without safe '+', apparently the NBA likes unsafe url params. params_str = urllib.parse.url...
Build GET REST request to the NBA for a game, iterate over the results and return them.
Build GET REST request to the NBA for a game, iterate over the results and return them.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "game", "iterate", "over", "the", "results", "and", "return", "them", "." ]
def fetch_game(self, game_id): params = self.build_params(game_id) params_str = urllib.parse.urlencode(params, safe=':+') response = requests.get(url=self.url, headers=headers, params=params_str).json() player_info = response['resultSets'][0]['rowSet'] rows = [] for row i...
[ "def", "fetch_game", "(", "self", ",", "game_id", ")", ":", "params", "=", "self", ".", "build_params", "(", "game_id", ")", "params_str", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ",", "safe", "=", "':+'", ")", "response", "=", "re...
Build GET REST request to the NBA for a game, iterate over the results and return them.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "game", "iterate", "over", "the", "results", "and", "return", "them", "." ]
[ "\"\"\"\n Build GET REST request to the NBA for a game, iterate over\n the results and return them.\n \"\"\"", "# Encode without safe '+', apparently the NBA likes unsafe url params.", "# pulling just the data we want", "# looping over data to return." ]
[ { "param": "self", "type": null }, { "param": "game_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "game_id", "type": null, "docstring": null, "docstring_tokens"...
139ee686befd953effaaa732d959affd7b6bc870
pb-new-username/nba-sql
stats/play_by_play.py
[ "Apache-2.0" ]
Python
build_params
<not_specific>
def build_params(self, game_id): """ Create required parameters dict for the request. """ return { 'EndPeriod': 6, 'GameId': game_id, 'StartPeriod': 1 }
Create required parameters dict for the request.
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
def build_params(self, game_id): return { 'EndPeriod': 6, 'GameId': game_id, 'StartPeriod': 1 }
[ "def", "build_params", "(", "self", ",", "game_id", ")", ":", "return", "{", "'EndPeriod'", ":", "6", ",", "'GameId'", ":", "game_id", ",", "'StartPeriod'", ":", "1", "}" ]
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
[ "\"\"\"\n Create required parameters dict for the request.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "game_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "game_id", "type": null, "docstring": null, "docstring_tokens"...
0a44b672fb3fd1b3cff150f8f36dbb3f60a02d61
pb-new-username/nba-sql
stats/player_season.py
[ "Apache-2.0" ]
Python
populate_season
null
def populate_season(self, season_id): """ Build GET REST request to the NBA for a season, iterate over the results, store in the database. We cannot rely on the base table's generic method, due to the `season_id` field. """ params = self.build_params(season_id) #...
Build GET REST request to the NBA for a season, iterate over the results, store in the database. We cannot rely on the base table's generic method, due to the `season_id` field.
Build GET REST request to the NBA for a season, iterate over the results, store in the database. We cannot rely on the base table's generic method, due to the `season_id` field.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "iterate", "over", "the", "results", "store", "in", "the", "database", ".", "We", "cannot", "rely", "on", "the", "base", "table", "'", "s", "generic", "method", "due", "to", "...
def populate_season(self, season_id): params = self.build_params(season_id) params_str = urllib.parse.urlencode(params, safe=':+') response = requests.get(url=self.url, headers=headers, params=params_str).json() result_sets = response['resultSets'][0] rowset = result_sets['rowSet...
[ "def", "populate_season", "(", "self", ",", "season_id", ")", ":", "params", "=", "self", ".", "build_params", "(", "season_id", ")", "params_str", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ",", "safe", "=", "':+'", ")", "response", "...
Build GET REST request to the NBA for a season, iterate over the results, store in the database.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "iterate", "over", "the", "results", "store", "in", "the", "database", "." ]
[ "\"\"\"\n Build GET REST request to the NBA for a season, iterate over the\n results, store in the database.\n We cannot rely on the base table's generic method, due to the `season_id` field.\n \"\"\"", "# Encode without safe '+', apparently the NBA likes unsafe url params.", "# json...
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
0a44b672fb3fd1b3cff150f8f36dbb3f60a02d61
pb-new-username/nba-sql
stats/player_season.py
[ "Apache-2.0" ]
Python
build_params
<not_specific>
def build_params(self, season_id): """ Create required parameters dict for the request. """ return { 'College': '', 'Conference': '', 'Country': '', 'DateFrom': '', 'DateTo': '', 'Division': '', 'DraftPic...
Create required parameters dict for the request.
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
def build_params(self, season_id): return { 'College': '', 'Conference': '', 'Country': '', 'DateFrom': '', 'DateTo': '', 'Division': '', 'DraftPick': '', 'DraftYear': '', 'GameScope': '', 'Ga...
[ "def", "build_params", "(", "self", ",", "season_id", ")", ":", "return", "{", "'College'", ":", "''", ",", "'Conference'", ":", "''", ",", "'Country'", ":", "''", ",", "'DateFrom'", ":", "''", ",", "'DateTo'", ":", "''", ",", "'Division'", ":", "''", ...
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
[ "\"\"\"\n Create required parameters dict for the request.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
495f44ae65759a2610cf4905c29eb0c44b41b9c9
pb-new-username/nba-sql
stats/player.py
[ "Apache-2.0" ]
Python
generate_rows
null
def generate_rows(self, season_id): """ Build GET REST request to the NBA for a season. """ params = self.build_params(season_id) # Encode without safe '+', apparently the NBA likes unsafe url params. params_str = urllib.parse.urlencode(params, safe=':+') super()...
Build GET REST request to the NBA for a season.
Build GET REST request to the NBA for a season.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "." ]
def generate_rows(self, season_id): params = self.build_params(season_id) params_str = urllib.parse.urlencode(params, safe=':+') super().generate_rows(params_str)
[ "def", "generate_rows", "(", "self", ",", "season_id", ")", ":", "params", "=", "self", ".", "build_params", "(", "season_id", ")", "params_str", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ",", "safe", "=", "':+'", ")", "super", "(", ...
Build GET REST request to the NBA for a season.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "." ]
[ "\"\"\"\n Build GET REST request to the NBA for a season.\n \"\"\"", "# Encode without safe '+', apparently the NBA likes unsafe url params." ]
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
495f44ae65759a2610cf4905c29eb0c44b41b9c9
pb-new-username/nba-sql
stats/player.py
[ "Apache-2.0" ]
Python
populate
null
def populate(self): """ Store collected rows. Custom implementation for the on_conflict_ignore argument. """ insert_many_on_conflict_ignore(self.settings, Player, self.rows)
Store collected rows. Custom implementation for the on_conflict_ignore argument.
Store collected rows. Custom implementation for the on_conflict_ignore argument.
[ "Store", "collected", "rows", ".", "Custom", "implementation", "for", "the", "on_conflict_ignore", "argument", "." ]
def populate(self): insert_many_on_conflict_ignore(self.settings, Player, self.rows)
[ "def", "populate", "(", "self", ")", ":", "insert_many_on_conflict_ignore", "(", "self", ".", "settings", ",", "Player", ",", "self", ".", "rows", ")" ]
Store collected rows.
[ "Store", "collected", "rows", "." ]
[ "\"\"\"\n Store collected rows. Custom implementation for the on_conflict_ignore\n argument.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
77632fc038ec1e9cff92e2f49dd24db16e1323dd
pb-new-username/nba-sql
stats/player_game_log.py
[ "Apache-2.0" ]
Python
fetch_season
null
def fetch_season(self, season_id): """ Build GET REST request to the NBA for a season, iterate over the results, store in the database. """ params = self.build_params(season_id) # Encode without safe '+', apparently the NBA likes unsafe url params. params...
Build GET REST request to the NBA for a season, iterate over the results, store in the database.
Build GET REST request to the NBA for a season, iterate over the results, store in the database.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "iterate", "over", "the", "results", "store", "in", "the", "database", "." ]
def fetch_season(self, season_id): params = self.build_params(season_id) params_str = urllib.parse.urlencode(params, safe=':+') response = requests.get(url=self.url, headers=headers, params=params_str).json() result_sets = response['resultSets'][0] rowset = result_sets['rowSet'] ...
[ "def", "fetch_season", "(", "self", ",", "season_id", ")", ":", "params", "=", "self", ".", "build_params", "(", "season_id", ")", "params_str", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ",", "safe", "=", "':+'", ")", "response", "=",...
Build GET REST request to the NBA for a season, iterate over the results, store in the database.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "iterate", "over", "the", "results", "store", "in", "the", "database", "." ]
[ "\"\"\"\n Build GET REST request to the NBA for a season,\n iterate over the results,\n store in the database.\n \"\"\"", "# Encode without safe '+', apparently the NBA likes unsafe url params.", "# looping over data to insert into table", "# Checking matchup for home team." ]
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
77632fc038ec1e9cff92e2f49dd24db16e1323dd
pb-new-username/nba-sql
stats/player_game_log.py
[ "Apache-2.0" ]
Python
build_params
<not_specific>
def build_params(self, season_id): """ Create required parameters dict for the request. """ return { 'DateFrom': '', 'DateTo': '', 'GameSegment': '', 'LastNGames': '', 'LeagueID': '00', 'Location': '', 'M...
Create required parameters dict for the request.
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
def build_params(self, season_id): return { 'DateFrom': '', 'DateTo': '', 'GameSegment': '', 'LastNGames': '', 'LeagueID': '00', 'Location': '', 'MeasureType': '', 'Month': '', 'OppTeamID': '', ...
[ "def", "build_params", "(", "self", ",", "season_id", ")", ":", "return", "{", "'DateFrom'", ":", "''", ",", "'DateTo'", ":", "''", ",", "'GameSegment'", ":", "''", ",", "'LastNGames'", ":", "''", ",", "'LeagueID'", ":", "'00'", ",", "'Location'", ":", ...
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
[ "\"\"\"\n Create required parameters dict for the request.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
77632fc038ec1e9cff92e2f49dd24db16e1323dd
pb-new-username/nba-sql
stats/player_game_log.py
[ "Apache-2.0" ]
Python
local_resultset_rows
<not_specific>
def local_resultset_rows(self): """ Returns list of the specific rows that we want to pull from the request. """ return [ 'MATCHUP', 'WL', 'TEAM_ID', 'GAME_ID', 'GAME_DATE' ]
Returns list of the specific rows that we want to pull from the request.
Returns list of the specific rows that we want to pull from the request.
[ "Returns", "list", "of", "the", "specific", "rows", "that", "we", "want", "to", "pull", "from", "the", "request", "." ]
def local_resultset_rows(self): return [ 'MATCHUP', 'WL', 'TEAM_ID', 'GAME_ID', 'GAME_DATE' ]
[ "def", "local_resultset_rows", "(", "self", ")", ":", "return", "[", "'MATCHUP'", ",", "'WL'", ",", "'TEAM_ID'", ",", "'GAME_ID'", ",", "'GAME_DATE'", "]" ]
Returns list of the specific rows that we want to pull from the request.
[ "Returns", "list", "of", "the", "specific", "rows", "that", "we", "want", "to", "pull", "from", "the", "request", "." ]
[ "\"\"\"\n Returns list of the specific rows that we want to pull from the request.\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
ee361b742eadc4579d4f6921b31bdc1650d3c8f8
pb-new-username/nba-sql
stats/nba_sql.py
[ "Apache-2.0" ]
Python
main
null
def main(): """ Main driver for the nba_sql application. """ parser = GooeyParser(description="nba-sql") parser.add_argument( '--database_name', help="Database Name (Not Needed For SQLite)", default=None) parser.add_argument( '--database_host', help="...
Main driver for the nba_sql application.
Main driver for the nba_sql application.
[ "Main", "driver", "for", "the", "nba_sql", "application", "." ]
def main(): parser = GooeyParser(description="nba-sql") parser.add_argument( '--database_name', help="Database Name (Not Needed For SQLite)", default=None) parser.add_argument( '--database_host', help="Database Hostname (Not Needed For SQLite)", default=None...
[ "def", "main", "(", ")", ":", "parser", "=", "GooeyParser", "(", "description", "=", "\"nba-sql\"", ")", "parser", ".", "add_argument", "(", "'--database_name'", ",", "help", "=", "\"Database Name (Not Needed For SQLite)\"", ",", "default", "=", "None", ")", "pa...
Main driver for the nba_sql application.
[ "Main", "driver", "for", "the", "nba_sql", "application", "." ]
[ "\"\"\"\n Main driver for the nba_sql application.\n \"\"\"", "# CMD line args.", "# Base Objects", "# Dependent Objects", "# Fetch player_game_log and build game_id set.", "# Fetch ids from tuples.", "# First, load game specific data.", "# Load game dependent data.", "# Okay so this takes a r...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
ee361b742eadc4579d4f6921b31bdc1650d3c8f8
pb-new-username/nba-sql
stats/nba_sql.py
[ "Apache-2.0" ]
Python
do_create_schema
null
def do_create_schema(object_list): """ Function to initialize database schema. """ print("Initializing schema.") for obj in object_list: obj.create_ddl()
Function to initialize database schema.
Function to initialize database schema.
[ "Function", "to", "initialize", "database", "schema", "." ]
def do_create_schema(object_list): print("Initializing schema.") for obj in object_list: obj.create_ddl()
[ "def", "do_create_schema", "(", "object_list", ")", ":", "print", "(", "\"Initializing schema.\"", ")", "for", "obj", "in", "object_list", ":", "obj", ".", "create_ddl", "(", ")" ]
Function to initialize database schema.
[ "Function", "to", "initialize", "database", "schema", "." ]
[ "\"\"\"\n Function to initialize database schema.\n \"\"\"" ]
[ { "param": "object_list", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "object_list", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dbb6a652a31edc46db684d39e262f42623296882
pb-new-username/nba-sql
stats/player_general_traditional_total.py
[ "Apache-2.0" ]
Python
generate_rows
null
def generate_rows(self, season_id): """ Build GET REST request to the NBA for a season. Also populate this table. We cannot rely on the base table's generic method, due to the `season_id` field. """ params = self.build_params(season_id) # Encode without safe '+',...
Build GET REST request to the NBA for a season. Also populate this table. We cannot rely on the base table's generic method, due to the `season_id` field.
Build GET REST request to the NBA for a season. Also populate this table. We cannot rely on the base table's generic method, due to the `season_id` field.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", ".", "Also", "populate", "this", "table", ".", "We", "cannot", "rely", "on", "the", "base", "table", "'", "s", "generic", "method", "due", "to", "the", "`", "season_id", "`", ...
def generate_rows(self, season_id): params = self.build_params(season_id) params_str = urllib.parse.urlencode(params, safe=':+') response = requests.get(url=self.url, headers=headers, params=params_str).json() result_sets = response['resultSets'][0] rowset = result_sets['rowSet']...
[ "def", "generate_rows", "(", "self", ",", "season_id", ")", ":", "params", "=", "self", ".", "build_params", "(", "season_id", ")", "params_str", "=", "urllib", ".", "parse", ".", "urlencode", "(", "params", ",", "safe", "=", "':+'", ")", "response", "="...
Build GET REST request to the NBA for a season.
[ "Build", "GET", "REST", "request", "to", "the", "NBA", "for", "a", "season", "." ]
[ "\"\"\"\n Build GET REST request to the NBA for a season.\n Also populate this table.\n We cannot rely on the base table's generic method, due to the `season_id` field.\n \"\"\"", "# Encode without safe '+', apparently the NBA likes unsafe url params.", "# json response" ]
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
dbb6a652a31edc46db684d39e262f42623296882
pb-new-username/nba-sql
stats/player_general_traditional_total.py
[ "Apache-2.0" ]
Python
build_params
<not_specific>
def build_params(self, season_id): """ Create required parameters dict for the request. """ return { 'College': '', 'Conference': '', 'Country': '', 'DateFrom': '', 'DateTo': '', 'Division': '', 'DraftPic...
Create required parameters dict for the request.
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
def build_params(self, season_id): return { 'College': '', 'Conference': '', 'Country': '', 'DateFrom': '', 'DateTo': '', 'Division': '', 'DraftPick': '', 'DraftYear': '', 'GameScope': '', 'Ga...
[ "def", "build_params", "(", "self", ",", "season_id", ")", ":", "return", "{", "'College'", ":", "''", ",", "'Conference'", ":", "''", ",", "'Country'", ":", "''", ",", "'DateFrom'", ":", "''", ",", "'DateTo'", ":", "''", ",", "'Division'", ":", "''", ...
Create required parameters dict for the request.
[ "Create", "required", "parameters", "dict", "for", "the", "request", "." ]
[ "\"\"\"\n Create required parameters dict for the request.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "season_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "season_id", "type": null, "docstring": null, "docstring_token...
eb5b83f80abb2bc003e2cbce84dbff018fd40884
pb-new-username/nba-sql
stats/team.py
[ "Apache-2.0" ]
Python
generate_rows
null
def generate_rows(self, team_id): """ Build GET Request for the team id. """ params = {'TeamID': team_id} super().generate_rows(params)
Build GET Request for the team id.
Build GET Request for the team id.
[ "Build", "GET", "Request", "for", "the", "team", "id", "." ]
def generate_rows(self, team_id): params = {'TeamID': team_id} super().generate_rows(params)
[ "def", "generate_rows", "(", "self", ",", "team_id", ")", ":", "params", "=", "{", "'TeamID'", ":", "team_id", "}", "super", "(", ")", ".", "generate_rows", "(", "params", ")" ]
Build GET Request for the team id.
[ "Build", "GET", "Request", "for", "the", "team", "id", "." ]
[ "\"\"\"\n Build GET Request for the team id.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "team_id", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "team_id", "type": null, "docstring": null, "docstring_tokens"...
87e4c61af4dcdc4309e0bb8e0d93f2a2ce0dbbd0
pb-new-username/nba-sql
stats/general_requester.py
[ "Apache-2.0" ]
Python
generate_rows
null
def generate_rows(self, params): """ Build GET REST request and fill the table. """ # json response response = requests.get(url=self.url, headers=headers, params=params).json() result_sets = response['resultSets'][0] rowset = result_sets['rowSet'] colum...
Build GET REST request and fill the table.
Build GET REST request and fill the table.
[ "Build", "GET", "REST", "request", "and", "fill", "the", "table", "." ]
def generate_rows(self, params): response = requests.get(url=self.url, headers=headers, params=params).json() result_sets = response['resultSets'][0] rowset = result_sets['rowSet'] column_names = column_names_from_table(self.settings.db, self.table._meta.table_name) column_mappin...
[ "def", "generate_rows", "(", "self", ",", "params", ")", ":", "response", "=", "requests", ".", "get", "(", "url", "=", "self", ".", "url", ",", "headers", "=", "headers", ",", "params", "=", "params", ")", ".", "json", "(", ")", "result_sets", "=", ...
Build GET REST request and fill the table.
[ "Build", "GET", "REST", "request", "and", "fill", "the", "table", "." ]
[ "\"\"\"\n Build GET REST request and fill the table.\n \"\"\"", "# json response" ]
[ { "param": "self", "type": null }, { "param": "params", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "params", "type": null, "docstring": null, "docstring_tokens":...
d580eaa651da1dbf01eeea285f9de73d391fd496
thunderboltsid/sharedocs
transport/code.py
[ "MIT" ]
Python
receive
<not_specific>
def receive(self, message): """ To be called whenever a message is recevied """ # Check the message type try: tp = message["type"] except ValueError: return False if tp != "DATA": return False # Check the id ...
To be called whenever a message is recevied
To be called whenever a message is recevied
[ "To", "be", "called", "whenever", "a", "message", "is", "recevied" ]
def receive(self, message): try: tp = message["type"] except ValueError: return False if tp != "DATA": return False try: mid = message["id"] except ValueError: return False if mid == self.id: self.sen...
[ "def", "receive", "(", "self", ",", "message", ")", ":", "try", ":", "tp", "=", "message", "[", "\"type\"", "]", "except", "ValueError", ":", "return", "False", "if", "tp", "!=", "\"DATA\"", ":", "return", "False", "try", ":", "mid", "=", "message", ...
To be called whenever a message is recevied
[ "To", "be", "called", "whenever", "a", "message", "is", "recevied" ]
[ "\"\"\" To be called whenever a message is recevied \"\"\"", "# Check the message type", "# Check the id", "# message matches", "# send an ACK", "# increase the counter", "# handle the message ", "# future message, send an EXP" ]
[ { "param": "self", "type": null }, { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": null, "docstring": null, "docstring_tokens"...
d580eaa651da1dbf01eeea285f9de73d391fd496
thunderboltsid/sharedocs
transport/code.py
[ "MIT" ]
Python
handle
null
def handle(self, message): """ Handles a message, to be implemented by user """ self.cache[self.id] = message self.send({ 'type': 'DATA', 'id': self.id, 'data': message }) self.id += 1
Handles a message, to be implemented by user
Handles a message, to be implemented by user
[ "Handles", "a", "message", "to", "be", "implemented", "by", "user" ]
def handle(self, message): self.cache[self.id] = message self.send({ 'type': 'DATA', 'id': self.id, 'data': message }) self.id += 1
[ "def", "handle", "(", "self", ",", "message", ")", ":", "self", ".", "cache", "[", "self", ".", "id", "]", "=", "message", "self", ".", "send", "(", "{", "'type'", ":", "'DATA'", ",", "'id'", ":", "self", ".", "id", ",", "'data'", ":", "message",...
Handles a message, to be implemented by user
[ "Handles", "a", "message", "to", "be", "implemented", "by", "user" ]
[ "\"\"\" Handles a message, to be implemented by user \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": null, "docstring": null, "docstring_tokens"...
d580eaa651da1dbf01eeea285f9de73d391fd496
thunderboltsid/sharedocs
transport/code.py
[ "MIT" ]
Python
receive
null
def receive(self, message): """ To be called whenever a message is recevied """ # in case of an ACK, first check if the package is still there if message["type"] == "ACK": mid = message["id"] # if so, delete it if mid in self.cache: ...
To be called whenever a message is recevied
To be called whenever a message is recevied
[ "To", "be", "called", "whenever", "a", "message", "is", "recevied" ]
def receive(self, message): if message["type"] == "ACK": mid = message["id"] if mid in self.cache: del self.cache[mid] if mid+1 in self.cache: self.send({ 'type': 'DATA', 'id': mid + 1, ...
[ "def", "receive", "(", "self", ",", "message", ")", ":", "if", "message", "[", "\"type\"", "]", "==", "\"ACK\"", ":", "mid", "=", "message", "[", "\"id\"", "]", "if", "mid", "in", "self", ".", "cache", ":", "del", "self", ".", "cache", "[", "mid", ...
To be called whenever a message is recevied
[ "To", "be", "called", "whenever", "a", "message", "is", "recevied" ]
[ "\"\"\" To be called whenever a message is recevied \"\"\"", "# in case of an ACK, first check if the package is still there", "# if so, delete it", "# and try to send the next message", "# EXP -- send the message" ]
[ { "param": "self", "type": null }, { "param": "message", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "message", "type": null, "docstring": null, "docstring_tokens"...
fb3cc98ae01e8c5c4b11ccdab220b0ec86be5b67
snorrefo/REST-tutorial
web/flaskr/__init__.py
[ "MIT" ]
Python
create_app
<not_specific>
def create_app(): """Create and configure an instance of the Flask application.""" app = Flask(__name__) tasks = [ { 'id': 1, 'title': u'Buy groceries', 'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', 'done': False }, { ...
Create and configure an instance of the Flask application.
Create and configure an instance of the Flask application.
[ "Create", "and", "configure", "an", "instance", "of", "the", "Flask", "application", "." ]
def create_app(): app = Flask(__name__) tasks = [ { 'id': 1, 'title': u'Buy groceries', 'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', 'done': False }, { 'id': 2, 'title': u'Learn Python', 'descri...
[ "def", "create_app", "(", ")", ":", "app", "=", "Flask", "(", "__name__", ")", "tasks", "=", "[", "{", "'id'", ":", "1", ",", "'title'", ":", "u'Buy groceries'", ",", "'description'", ":", "u'Milk, Cheese, Pizza, Fruit, Tylenol'", ",", "'done'", ":", "False"...
Create and configure an instance of the Flask application.
[ "Create", "and", "configure", "an", "instance", "of", "the", "Flask", "application", "." ]
[ "\"\"\"Create and configure an instance of the Flask application.\"\"\"", "# curl -i http://localhost:5000/todo/api/v1.0/tasks", "# curl -i http://localhost:5000/todo/api/v1.0/tasks/3", "# curl -i -H \"Content-Type: application/json\" -X POST -d '{\"title\":\"Read a book\"}' http://192.168.99.100:5000/todo/ap...
[]
{ "returns": [], "raises": [], "params": [], "outlier_params": [], "others": [] }
9f8e2c01b632c99db68b220912daa490512ad357
JayJay-101/bot-heroku
bot.py
[ "MIT" ]
Python
_make_request
<not_specific>
def _make_request(token, method_name, params=None): """Makes a request to the Telegram API. :param token: The bot's API token. (Created with @BotFather) :param method_name: Name of the API method to be called. (E.g. 'getUpdates') :param method: HTTP method to be used. Defaults to '...
Makes a request to the Telegram API. :param token: The bot's API token. (Created with @BotFather) :param method_name: Name of the API method to be called. (E.g. 'getUpdates') :param method: HTTP method to be used. Defaults to 'get'. :return: The result parsed to a JSON dictionary. ...
Makes a request to the Telegram API.
[ "Makes", "a", "request", "to", "the", "Telegram", "API", "." ]
def _make_request(token, method_name, params=None): request_url = "https://api.telegram.org/bot{0}/{1}".format(token, method_name) try: result = requests.get(request_url,params=params) got_result = True except : logger.debug("Timeout Error on {0} method ".form...
[ "def", "_make_request", "(", "token", ",", "method_name", ",", "params", "=", "None", ")", ":", "request_url", "=", "\"https://api.telegram.org/bot{0}/{1}\"", ".", "format", "(", "token", ",", "method_name", ")", "try", ":", "result", "=", "requests", ".", "ge...
Makes a request to the Telegram API.
[ "Makes", "a", "request", "to", "the", "Telegram", "API", "." ]
[ "\"\"\"Makes a request to the Telegram API.\r\n :param token: The bot's API token. (Created with @BotFather)\r\n :param method_name: Name of the API method to be called. (E.g. 'getUpdates')\r\n :param method: HTTP method to be used. Defaults to 'get'.\r\n :return: The result parsed to a ...
[ { "param": "token", "type": null }, { "param": "method_name", "type": null }, { "param": "params", "type": null } ]
{ "returns": [ { "docstring": "The result parsed to a JSON dictionary.", "docstring_tokens": [ "The", "result", "parsed", "to", "a", "JSON", "dictionary", "." ], "type": null } ], "raises": [], "params": [ { ...
9f8e2c01b632c99db68b220912daa490512ad357
JayJay-101/bot-heroku
bot.py
[ "MIT" ]
Python
help
null
def help(update, context): """Send a message when the command /help is issued.""" a=''.join(context.args) update.message.reply_text(a+' Help!')
Send a message when the command /help is issued.
Send a message when the command /help is issued.
[ "Send", "a", "message", "when", "the", "command", "/", "help", "is", "issued", "." ]
def help(update, context): a=''.join(context.args) update.message.reply_text(a+' Help!')
[ "def", "help", "(", "update", ",", "context", ")", ":", "a", "=", "''", ".", "join", "(", "context", ".", "args", ")", "update", ".", "message", ".", "reply_text", "(", "a", "+", "' Help!'", ")" ]
Send a message when the command /help is issued.
[ "Send", "a", "message", "when", "the", "command", "/", "help", "is", "issued", "." ]
[ "\"\"\"Send a message when the command /help is issued.\"\"\"" ]
[ { "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...
1346b7ddf57debc85637e59c11158d77b9588c3d
bspa10/bktools
src/main/python/bktools/ext/python/collections.py
[ "MIT" ]
Python
chunks
null
def chunks(collection, size: int): """ Create sub-lists from the base collection with the desired size. Parameters: collection: The collection size: Number of items per sub-list """ for index in range(0, len(collection), size): yield collection[index: index + size]
Create sub-lists from the base collection with the desired size. Parameters: collection: The collection size: Number of items per sub-list
Create sub-lists from the base collection with the desired size.
[ "Create", "sub", "-", "lists", "from", "the", "base", "collection", "with", "the", "desired", "size", "." ]
def chunks(collection, size: int): for index in range(0, len(collection), size): yield collection[index: index + size]
[ "def", "chunks", "(", "collection", ",", "size", ":", "int", ")", ":", "for", "index", "in", "range", "(", "0", ",", "len", "(", "collection", ")", ",", "size", ")", ":", "yield", "collection", "[", "index", ":", "index", "+", "size", "]" ]
Create sub-lists from the base collection with the desired size.
[ "Create", "sub", "-", "lists", "from", "the", "base", "collection", "with", "the", "desired", "size", "." ]
[ "\"\"\"\n Create sub-lists from the base collection with the desired size.\n\n Parameters:\n collection: The collection\n size: Number of items per sub-list\n \"\"\"" ]
[ { "param": "collection", "type": null }, { "param": "size", "type": "int" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "collection", "type": null, "docstring": null, "docstring_tokens": [ "None" ], "default": null, "is_optional": null }, { "identifier": "size", "type": "int", "docstring": "Num...
4c9ea74f47e6e07d9836f8629eb7a11fbac9c9ce
bspa10/bktools
src/main/python/bktools/ext/python/module.py
[ "MIT" ]
Python
is_imported
bool
def is_imported(name: str) -> bool: """ Utility function to indicate if a module has been imported. Parameter: name: The module name Returns: True if the module has been imported, false otherwise. """ return name in sys.modules
Utility function to indicate if a module has been imported. Parameter: name: The module name Returns: True if the module has been imported, false otherwise.
Utility function to indicate if a module has been imported. Parameter: name: The module name
[ "Utility", "function", "to", "indicate", "if", "a", "module", "has", "been", "imported", ".", "Parameter", ":", "name", ":", "The", "module", "name" ]
def is_imported(name: str) -> bool: return name in sys.modules
[ "def", "is_imported", "(", "name", ":", "str", ")", "->", "bool", ":", "return", "name", "in", "sys", ".", "modules" ]
Utility function to indicate if a module has been imported.
[ "Utility", "function", "to", "indicate", "if", "a", "module", "has", "been", "imported", "." ]
[ "\"\"\"\n Utility function to indicate if a module has been imported.\n\n Parameter:\n name: The module name\n\n Returns:\n True if the module has been imported, false otherwise.\n \"\"\"" ]
[ { "param": "name", "type": "str" } ]
{ "returns": [ { "docstring": "True if the module has been imported, false otherwise.", "docstring_tokens": [ "True", "if", "the", "module", "has", "been", "imported", "false", "otherwise", "." ], "type": null ...
4c9ea74f47e6e07d9836f8629eb7a11fbac9c9ce
bspa10/bktools
src/main/python/bktools/ext/python/module.py
[ "MIT" ]
Python
exists
bool
def exists(name: str) -> bool: """ Check if a module exists in VENV. Parameter: name: The name of the module Returns: True if the module exists in venv, False otherwise. """ return util.find_spec(name) is not None
Check if a module exists in VENV. Parameter: name: The name of the module Returns: True if the module exists in venv, False otherwise.
Check if a module exists in VENV. Parameter: name: The name of the module
[ "Check", "if", "a", "module", "exists", "in", "VENV", ".", "Parameter", ":", "name", ":", "The", "name", "of", "the", "module" ]
def exists(name: str) -> bool: return util.find_spec(name) is not None
[ "def", "exists", "(", "name", ":", "str", ")", "->", "bool", ":", "return", "util", ".", "find_spec", "(", "name", ")", "is", "not", "None" ]
Check if a module exists in VENV.
[ "Check", "if", "a", "module", "exists", "in", "VENV", "." ]
[ "\"\"\"\n Check if a module exists in VENV.\n\n Parameter:\n name: The name of the module\n\n Returns:\n True if the module exists in venv, False otherwise.\n \"\"\"" ]
[ { "param": "name", "type": "str" } ]
{ "returns": [ { "docstring": "True if the module exists in venv, False otherwise.", "docstring_tokens": [ "True", "if", "the", "module", "exists", "in", "venv", "False", "otherwise", "." ], "type": null } ...
1eea1705ce7c6fe51704659059652a7d8d45bc82
bspa10/bktools
src/main/python/bktools/framework/feature/repository.py
[ "MIT" ]
Python
is_active
bool
def is_active(self, name: str) -> bool: """ Indicates if feature is active or not. Parameters: name: The identification name of the feature Returns: True if the feature is active, False otherwise. """ pass
Indicates if feature is active or not. Parameters: name: The identification name of the feature Returns: True if the feature is active, False otherwise.
Indicates if feature is active or not.
[ "Indicates", "if", "feature", "is", "active", "or", "not", "." ]
def is_active(self, name: str) -> bool: pass
[ "def", "is_active", "(", "self", ",", "name", ":", "str", ")", "->", "bool", ":", "pass" ]
Indicates if feature is active or not.
[ "Indicates", "if", "feature", "is", "active", "or", "not", "." ]
[ "\"\"\"\n Indicates if feature is active or not.\n\n Parameters:\n name: The identification name of the feature\n\n Returns:\n True if the feature is active, False otherwise.\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "name", "type": "str" } ]
{ "returns": [ { "docstring": "True if the feature is active, False otherwise.", "docstring_tokens": [ "True", "if", "the", "feature", "is", "active", "False", "otherwise", "." ], "type": null } ], "raises": []...
f26112ac7a6bd4853dcc97406de044f5431a8dae
bspa10/bktools
src/main/python/bktools/ext/python/generics.py
[ "MIT" ]
Python
fqdn
str
def fqdn(instance: Any) -> str: """ Retrieves the Fully Qualified Domain Name of the object's class. :param instance: Instance of a object :return: The Fully Qualified Domain Name """ return f"{instance.__class__.__module__}.{instance.__class__.__name__}"
Retrieves the Fully Qualified Domain Name of the object's class. :param instance: Instance of a object :return: The Fully Qualified Domain Name
Retrieves the Fully Qualified Domain Name of the object's class.
[ "Retrieves", "the", "Fully", "Qualified", "Domain", "Name", "of", "the", "object", "'", "s", "class", "." ]
def fqdn(instance: Any) -> str: return f"{instance.__class__.__module__}.{instance.__class__.__name__}"
[ "def", "fqdn", "(", "instance", ":", "Any", ")", "->", "str", ":", "return", "f\"{instance.__class__.__module__}.{instance.__class__.__name__}\"" ]
Retrieves the Fully Qualified Domain Name of the object's class.
[ "Retrieves", "the", "Fully", "Qualified", "Domain", "Name", "of", "the", "object", "'", "s", "class", "." ]
[ "\"\"\"\n Retrieves the Fully Qualified Domain Name of the object's class.\n\n :param instance: Instance of a object\n :return: The Fully Qualified Domain Name\n \"\"\"" ]
[ { "param": "instance", "type": "Any" } ]
{ "returns": [ { "docstring": "The Fully Qualified Domain Name", "docstring_tokens": [ "The", "Fully", "Qualified", "Domain", "Name" ], "type": null } ], "raises": [], "params": [ { "identifier": "instance", "type": "Any", ...
f26112ac7a6bd4853dcc97406de044f5431a8dae
bspa10/bktools
src/main/python/bktools/ext/python/generics.py
[ "MIT" ]
Python
parameters
List[Tuple[str, Type]]
def parameters(method: Callable) -> List[Tuple[str, Type]]: """ Inspect the desired method extracting a list of parameters needed to execute it. Parameters: method: The type.Callable that will be inspected Returns: A list of Tuples with the parameter name and its annotation """...
Inspect the desired method extracting a list of parameters needed to execute it. Parameters: method: The type.Callable that will be inspected Returns: A list of Tuples with the parameter name and its annotation
Inspect the desired method extracting a list of parameters needed to execute it.
[ "Inspect", "the", "desired", "method", "extracting", "a", "list", "of", "parameters", "needed", "to", "execute", "it", "." ]
def parameters(method: Callable) -> List[Tuple[str, Type]]: output: List[Tuple[str, Type]] = list() if callable(method): spec: inspect.FullArgSpec = inspect.getfullargspec(method) if spec.args: for index in range(0, len(spec.args)): arg: str = spec.args[index] ...
[ "def", "parameters", "(", "method", ":", "Callable", ")", "->", "List", "[", "Tuple", "[", "str", ",", "Type", "]", "]", ":", "output", ":", "List", "[", "Tuple", "[", "str", ",", "Type", "]", "]", "=", "list", "(", ")", "if", "callable", "(", ...
Inspect the desired method extracting a list of parameters needed to execute it.
[ "Inspect", "the", "desired", "method", "extracting", "a", "list", "of", "parameters", "needed", "to", "execute", "it", "." ]
[ "\"\"\"\n Inspect the desired method extracting a list of parameters needed\n to execute it.\n\n Parameters:\n method: The type.Callable that will be inspected\n\n Returns:\n A list of Tuples with the parameter name and its annotation\n \"\"\"" ]
[ { "param": "method", "type": "Callable" } ]
{ "returns": [ { "docstring": "A list of Tuples with the parameter name and its annotation", "docstring_tokens": [ "A", "list", "of", "Tuples", "with", "the", "parameter", "name", "and", "its", "annotation" ]...
5ad7aa89ea1a4955fc65f5920ba858a9b170876e
bspa10/bktools
src/main/python/bktools/ext/python/objects.py
[ "MIT" ]
Python
swap
NoReturn
def swap(source: object, destination: object, attribute: str, nullable: bool = False) -> NoReturn: """ Swap the value of a attribute between two objects. Parameters: source: The source object destination: The destination object attribute: The name of the desired attribute nu...
Swap the value of a attribute between two objects. Parameters: source: The source object destination: The destination object attribute: The name of the desired attribute nullable: Flag indicating if the destination accept a NULL value
Swap the value of a attribute between two objects.
[ "Swap", "the", "value", "of", "a", "attribute", "between", "two", "objects", "." ]
def swap(source: object, destination: object, attribute: str, nullable: bool = False) -> NoReturn: if source is None or destination is None or attribute is None: raise InvalidParameterException() attribute = attribute.strip() if len(attribute) <= 0: raise InvalidParameterException() if n...
[ "def", "swap", "(", "source", ":", "object", ",", "destination", ":", "object", ",", "attribute", ":", "str", ",", "nullable", ":", "bool", "=", "False", ")", "->", "NoReturn", ":", "if", "source", "is", "None", "or", "destination", "is", "None", "or",...
Swap the value of a attribute between two objects.
[ "Swap", "the", "value", "of", "a", "attribute", "between", "two", "objects", "." ]
[ "\"\"\"\n Swap the value of a attribute between two objects.\n\n Parameters:\n source: The source object\n destination: The destination object\n attribute: The name of the desired attribute\n nullable: Flag indicating if the destination accept a NULL value\n \"\"\"" ]
[ { "param": "source", "type": "object" }, { "param": "destination", "type": "object" }, { "param": "attribute", "type": "str" }, { "param": "nullable", "type": "bool" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "source", "type": "object", "docstring": "The source object", "docstring_tokens": [ "The", "source", "object" ], "default": null, "is_optional": null }, { "identifier": "d...
5ad7aa89ea1a4955fc65f5920ba858a9b170876e
bspa10/bktools
src/main/python/bktools/ext/python/objects.py
[ "MIT" ]
Python
sizeof
int
def sizeof(obj: Any, seen: Set[Any] = None) -> int: """ Recursively finds size of objects. Parameters: obj: The object that will be evaluated seen: Already visited objects Returns: The bytes of the object """ size = sys.getsizeof(obj) if seen is None: seen ...
Recursively finds size of objects. Parameters: obj: The object that will be evaluated seen: Already visited objects Returns: The bytes of the object
Recursively finds size of objects.
[ "Recursively", "finds", "size", "of", "objects", "." ]
def sizeof(obj: Any, seen: Set[Any] = None) -> int: size = sys.getsizeof(obj) if seen is None: seen = set() obj_id = id(obj) if obj_id in seen: return 0 seen.add(obj_id) if isinstance(obj, dict): size += sum([sizeof(v, seen) for v in obj.values()]) size += sum([si...
[ "def", "sizeof", "(", "obj", ":", "Any", ",", "seen", ":", "Set", "[", "Any", "]", "=", "None", ")", "->", "int", ":", "size", "=", "sys", ".", "getsizeof", "(", "obj", ")", "if", "seen", "is", "None", ":", "seen", "=", "set", "(", ")", "obj_...
Recursively finds size of objects.
[ "Recursively", "finds", "size", "of", "objects", "." ]
[ "\"\"\"\n Recursively finds size of objects.\n\n Parameters:\n obj: The object that will be evaluated\n seen: Already visited objects\n\n Returns:\n The bytes of the object\n \"\"\"", "# Important mark as seen *before* entering recursion to gracefully handle", "# self-referentia...
[ { "param": "obj", "type": "Any" }, { "param": "seen", "type": "Set[Any]" } ]
{ "returns": [ { "docstring": "The bytes of the object", "docstring_tokens": [ "The", "bytes", "of", "the", "object" ], "type": null } ], "raises": [], "params": [ { "identifier": "obj", "type": "Any", "docstring": "Th...
3cd8375d5dea7465c5253237889db106c353b42a
bspa10/bktools
src/main/python/bktools/framework/money/currency.py
[ "MIT" ]
Python
code
str
def code(self) -> str: """ The currency code which consist of 3 uppercase characters. e.g: USD, BRL """ return self.__code
The currency code which consist of 3 uppercase characters. e.g: USD, BRL
The currency code which consist of 3 uppercase characters.
[ "The", "currency", "code", "which", "consist", "of", "3", "uppercase", "characters", "." ]
def code(self) -> str: return self.__code
[ "def", "code", "(", "self", ")", "->", "str", ":", "return", "self", ".", "__code" ]
The currency code which consist of 3 uppercase characters.
[ "The", "currency", "code", "which", "consist", "of", "3", "uppercase", "characters", "." ]
[ "\"\"\"\n The currency code which consist of 3 uppercase characters.\n\n e.g: USD, BRL\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
3cd8375d5dea7465c5253237889db106c353b42a
bspa10/bktools
src/main/python/bktools/framework/money/currency.py
[ "MIT" ]
Python
code
Optional[Currency]
def code(cls, code: str) -> Optional[Currency]: """ Retrieve the Currency object by its code. e.g. BRL, USD Parameters: code: The currency code. e.g. BRL Returns: the Currency object """ code = code.upper() for entry in cls().__e...
Retrieve the Currency object by its code. e.g. BRL, USD Parameters: code: The currency code. e.g. BRL Returns: the Currency object
Retrieve the Currency object by its code.
[ "Retrieve", "the", "Currency", "object", "by", "its", "code", "." ]
def code(cls, code: str) -> Optional[Currency]: code = code.upper() for entry in cls().__entries: if entry.code == code: return entry return None
[ "def", "code", "(", "cls", ",", "code", ":", "str", ")", "->", "Optional", "[", "Currency", "]", ":", "code", "=", "code", ".", "upper", "(", ")", "for", "entry", "in", "cls", "(", ")", ".", "__entries", ":", "if", "entry", ".", "code", "==", "...
Retrieve the Currency object by its code.
[ "Retrieve", "the", "Currency", "object", "by", "its", "code", "." ]
[ "\"\"\"\n Retrieve the Currency object by its code.\n e.g. BRL, USD\n\n Parameters:\n code: The currency code. e.g. BRL\n\n Returns:\n the Currency object\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "code", "type": "str" } ]
{ "returns": [ { "docstring": "the Currency object", "docstring_tokens": [ "the", "Currency", "object" ], "type": null } ], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": []...
3cd8375d5dea7465c5253237889db106c353b42a
bspa10/bktools
src/main/python/bktools/framework/money/currency.py
[ "MIT" ]
Python
number
Optional[Currency]
def number(cls, number: int) -> Optional[Currency]: """ Retrieve the Currency object by its number. e.g. 986 (BRL), 840 (USD) Parameters: number: The currency number. e.g. 840 (USD) Returns: the Currency object """ for entry in cls().__en...
Retrieve the Currency object by its number. e.g. 986 (BRL), 840 (USD) Parameters: number: The currency number. e.g. 840 (USD) Returns: the Currency object
Retrieve the Currency object by its number.
[ "Retrieve", "the", "Currency", "object", "by", "its", "number", "." ]
def number(cls, number: int) -> Optional[Currency]: for entry in cls().__entries: if entry.number == number: return entry return None
[ "def", "number", "(", "cls", ",", "number", ":", "int", ")", "->", "Optional", "[", "Currency", "]", ":", "for", "entry", "in", "cls", "(", ")", ".", "__entries", ":", "if", "entry", ".", "number", "==", "number", ":", "return", "entry", "return", ...
Retrieve the Currency object by its number.
[ "Retrieve", "the", "Currency", "object", "by", "its", "number", "." ]
[ "\"\"\"\n Retrieve the Currency object by its number.\n e.g. 986 (BRL), 840 (USD)\n\n Parameters:\n number: The currency number. e.g. 840 (USD)\n\n Returns:\n the Currency object\n \"\"\"" ]
[ { "param": "cls", "type": null }, { "param": "number", "type": "int" } ]
{ "returns": [ { "docstring": "the Currency object", "docstring_tokens": [ "the", "Currency", "object" ], "type": null } ], "raises": [], "params": [ { "identifier": "cls", "type": null, "docstring": null, "docstring_tokens": []...
119d3a514cd77c1a71d7aff7b9ff916224f70c3a
JuanGGO/FastDSP
FastDSP/structures/arrays.py
[ "BSD-3-Clause" ]
Python
mean
<not_specific>
def mean(self, axis=-1): ''' Calculates the mean of the array around a given axis :param axis: axis to use to calculate the mean :return: mean of the array ''' if self.ndim < axis: raise ValueError("Can't find mean around axis {} on array of {} dimensions".f...
Calculates the mean of the array around a given axis :param axis: axis to use to calculate the mean :return: mean of the array
Calculates the mean of the array around a given axis
[ "Calculates", "the", "mean", "of", "the", "array", "around", "a", "given", "axis" ]
def mean(self, axis=-1): if self.ndim < axis: raise ValueError("Can't find mean around axis {} on array of {} dimensions".format(axis, self.ndim)) return reductions.mean(self, axis)
[ "def", "mean", "(", "self", ",", "axis", "=", "-", "1", ")", ":", "if", "self", ".", "ndim", "<", "axis", ":", "raise", "ValueError", "(", "\"Can't find mean around axis {} on array of {} dimensions\"", ".", "format", "(", "axis", ",", "self", ".", "ndim", ...
Calculates the mean of the array around a given axis
[ "Calculates", "the", "mean", "of", "the", "array", "around", "a", "given", "axis" ]
[ "'''\n Calculates the mean of the array around a given axis\n\n :param axis: axis to use to calculate the mean\n :return: mean of the array\n '''" ]
[ { "param": "self", "type": null }, { "param": "axis", "type": null } ]
{ "returns": [ { "docstring": "mean of the array", "docstring_tokens": [ "mean", "of", "the", "array" ], "type": null } ], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tok...
1713a9dbcf5fe63ecba0583c453a441a59264d76
JuanGGO/FastDSP
FastDSP/algorithms/reductions.py
[ "BSD-3-Clause" ]
Python
mean
<not_specific>
def mean(array, axis=-1): ''' Calculates the mean of a gpu array on a given axis :param array: Instance of a class with class memeber array :param axis: axis to use to take the mean :return: mean value of the array around axis >>> import FastDSP as fdsp >>> import numpy as np >>> gpu_a...
Calculates the mean of a gpu array on a given axis :param array: Instance of a class with class memeber array :param axis: axis to use to take the mean :return: mean value of the array around axis >>> import FastDSP as fdsp >>> import numpy as np >>> gpu_array = fdsp.GPUArray(np.random.ra...
Calculates the mean of a gpu array on a given axis
[ "Calculates", "the", "mean", "of", "a", "gpu", "array", "on", "a", "given", "axis" ]
def mean(array, axis=-1): if array.dtype == np.complex64 or array.dtype == np.complex128: out = _reductions.get_mean_complex(array.array, axis) else: out = _reductions.get_mean(array.array, axis) return out
[ "def", "mean", "(", "array", ",", "axis", "=", "-", "1", ")", ":", "if", "array", ".", "dtype", "==", "np", ".", "complex64", "or", "array", ".", "dtype", "==", "np", ".", "complex128", ":", "out", "=", "_reductions", ".", "get_mean_complex", "(", ...
Calculates the mean of a gpu array on a given axis
[ "Calculates", "the", "mean", "of", "a", "gpu", "array", "on", "a", "given", "axis" ]
[ "'''\n Calculates the mean of a gpu array on a given axis\n\n :param array: Instance of a class with class memeber array\n :param axis: axis to use to take the mean\n :return: mean value of the array around axis\n\n >>> import FastDSP as fdsp\n >>> import numpy as np\n >>> gpu_array = fdsp.GPUA...
[ { "param": "array", "type": null }, { "param": "axis", "type": null } ]
{ "returns": [ { "docstring": "mean value of the array around axis\n>>> import FastDSP as fdsp\n>>> import numpy as np\n>>> gpu_array = fdsp.GPUArray(np.random.randn(4, 4))\n>>> print(mean(gpu_array))", "docstring_tokens": [ "mean", "value", "of", "the", "array"...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
padr
<not_specific>
def padr(text, n, c): """ padr - right pad of text with character c """ text = str(text) return text + str(c) * (n - len(text))
padr - right pad of text with character c
right pad of text with character c
[ "right", "pad", "of", "text", "with", "character", "c" ]
def padr(text, n, c): text = str(text) return text + str(c) * (n - len(text))
[ "def", "padr", "(", "text", ",", "n", ",", "c", ")", ":", "text", "=", "str", "(", "text", ")", "return", "text", "+", "str", "(", "c", ")", "*", "(", "n", "-", "len", "(", "text", ")", ")" ]
padr - right pad of text with character c
[ "padr", "-", "right", "pad", "of", "text", "with", "character", "c" ]
[ "\"\"\"\n padr - right pad of text with character c\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "n", "type": null }, { "param": "c", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], ...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
padl
<not_specific>
def padl(text, n, c): """ left pad of text with character c """ text = str(text) return str(c) * (n - len(text)) + text
left pad of text with character c
left pad of text with character c
[ "left", "pad", "of", "text", "with", "character", "c" ]
def padl(text, n, c): text = str(text) return str(c) * (n - len(text)) + text
[ "def", "padl", "(", "text", ",", "n", ",", "c", ")", ":", "text", "=", "str", "(", "text", ")", "return", "str", "(", "c", ")", "*", "(", "n", "-", "len", "(", "text", ")", ")", "+", "text" ]
left pad of text with character c
[ "left", "pad", "of", "text", "with", "character", "c" ]
[ "\"\"\"\n left pad of text with character c\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "n", "type": null }, { "param": "c", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "n", "type": null, "docstring": null, "docstring_tokens": [], ...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
startswith
<not_specific>
def startswith(text, elenco, casesensitive=True): """ startswith - Returns True if the text starts with one of ... """ for item in listify(elenco, ","): if casesensitive: if text.startswith(item): return True else: if text.lower().startswith(item.l...
startswith - Returns True if the text starts with one of ...
Returns True if the text starts with one of
[ "Returns", "True", "if", "the", "text", "starts", "with", "one", "of" ]
def startswith(text, elenco, casesensitive=True): for item in listify(elenco, ","): if casesensitive: if text.startswith(item): return True else: if text.lower().startswith(item.lower()): return True return False
[ "def", "startswith", "(", "text", ",", "elenco", ",", "casesensitive", "=", "True", ")", ":", "for", "item", "in", "listify", "(", "elenco", ",", "\",\"", ")", ":", "if", "casesensitive", ":", "if", "text", ".", "startswith", "(", "item", ")", ":", "...
startswith - Returns True if the text starts with one of ...
[ "startswith", "-", "Returns", "True", "if", "the", "text", "starts", "with", "one", "of", "..." ]
[ "\"\"\"\n startswith - Returns True if the text starts with one of ...\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "elenco", "type": null }, { "param": "casesensitive", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "elenco", "type": null, "docstring": null, "docstring_tokens":...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
endswith
<not_specific>
def endswith(text, elenco, casesensitive=True): """ endswith - Returns True if the text ends with one of ... """ for item in listify(elenco, ","): if casesensitive: if text.endswith(item): return True else: if text.lower().endswith(item.lower()): ...
endswith - Returns True if the text ends with one of ...
Returns True if the text ends with one of
[ "Returns", "True", "if", "the", "text", "ends", "with", "one", "of" ]
def endswith(text, elenco, casesensitive=True): for item in listify(elenco, ","): if casesensitive: if text.endswith(item): return True else: if text.lower().endswith(item.lower()): return True return False
[ "def", "endswith", "(", "text", ",", "elenco", ",", "casesensitive", "=", "True", ")", ":", "for", "item", "in", "listify", "(", "elenco", ",", "\",\"", ")", ":", "if", "casesensitive", ":", "if", "text", ".", "endswith", "(", "item", ")", ":", "retu...
endswith - Returns True if the text ends with one of ...
[ "endswith", "-", "Returns", "True", "if", "the", "text", "ends", "with", "one", "of", "..." ]
[ "\"\"\"\n endswith - Returns True if the text ends with one of ...\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "elenco", "type": null }, { "param": "casesensitive", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "elenco", "type": null, "docstring": null, "docstring_tokens":...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
textin
<not_specific>
def textin(text, prefix, postfix, casesensitive=True): """ textin - return text between prefix and suffix excluded """ if casesensitive: g = re.search(r'(?<=' + prefix + ')(.*?)(?=' + postfix + ')', text) else: g = re.search(r'(?<=' + prefix + ')(.*?)(?=' + postfix + ')', text, re.IG...
textin - return text between prefix and suffix excluded
return text between prefix and suffix excluded
[ "return", "text", "between", "prefix", "and", "suffix", "excluded" ]
def textin(text, prefix, postfix, casesensitive=True): if casesensitive: g = re.search(r'(?<=' + prefix + ')(.*?)(?=' + postfix + ')', text) else: g = re.search(r'(?<=' + prefix + ')(.*?)(?=' + postfix + ')', text, re.IGNORECASE) return g.group() if g else ""
[ "def", "textin", "(", "text", ",", "prefix", ",", "postfix", ",", "casesensitive", "=", "True", ")", ":", "if", "casesensitive", ":", "g", "=", "re", ".", "search", "(", "r'(?<='", "+", "prefix", "+", "')(.*?)(?='", "+", "postfix", "+", "')'", ",", "...
textin - return text between prefix and suffix excluded
[ "textin", "-", "return", "text", "between", "prefix", "and", "suffix", "excluded" ]
[ "\"\"\"\n textin - return text between prefix and suffix excluded\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "prefix", "type": null }, { "param": "postfix", "type": null }, { "param": "casesensitive", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prefix", "type": null, "docstring": null, "docstring_tokens":...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
textbetween
<not_specific>
def textbetween(text, prefix, postfix, casesensitive=True): """ textin - return text between prefix and suffix excluded """ if casesensitive: g = re.search(r'' + prefix + '(.*?)' + postfix, text) else: g = re.search(r'' + prefix + '(.*?)' + postfix, text, re.IGNORECASE) return g...
textin - return text between prefix and suffix excluded
return text between prefix and suffix excluded
[ "return", "text", "between", "prefix", "and", "suffix", "excluded" ]
def textbetween(text, prefix, postfix, casesensitive=True): if casesensitive: g = re.search(r'' + prefix + '(.*?)' + postfix, text) else: g = re.search(r'' + prefix + '(.*?)' + postfix, text, re.IGNORECASE) return g.group() if g else ""
[ "def", "textbetween", "(", "text", ",", "prefix", ",", "postfix", ",", "casesensitive", "=", "True", ")", ":", "if", "casesensitive", ":", "g", "=", "re", ".", "search", "(", "r''", "+", "prefix", "+", "'(.*?)'", "+", "postfix", ",", "text", ")", "el...
textin - return text between prefix and suffix excluded
[ "textin", "-", "return", "text", "between", "prefix", "and", "suffix", "excluded" ]
[ "\"\"\"\n textin - return text between prefix and suffix excluded\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "prefix", "type": null }, { "param": "postfix", "type": null }, { "param": "casesensitive", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "prefix", "type": null, "docstring": null, "docstring_tokens":...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
split
<not_specific>
def split(text, sep=" ", glue="'", removeEmpty=False): """ split - a variant of split with glue characters """ res = [] word = "" dontsplit = False for j in range(0, len(text)): c = text[j] if c in glue: dontsplit = not dontsplit if c in sep and not dontsp...
split - a variant of split with glue characters
a variant of split with glue characters
[ "a", "variant", "of", "split", "with", "glue", "characters" ]
def split(text, sep=" ", glue="'", removeEmpty=False): res = [] word = "" dontsplit = False for j in range(0, len(text)): c = text[j] if c in glue: dontsplit = not dontsplit if c in sep and not dontsplit: res.append(word) word = "" else...
[ "def", "split", "(", "text", ",", "sep", "=", "\" \"", ",", "glue", "=", "\"'\"", ",", "removeEmpty", "=", "False", ")", ":", "res", "=", "[", "]", "word", "=", "\"\"", "dontsplit", "=", "False", "for", "j", "in", "range", "(", "0", ",", "len", ...
split - a variant of split with glue characters
[ "split", "-", "a", "variant", "of", "split", "with", "glue", "characters" ]
[ "\"\"\"\n split - a variant of split with glue characters\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "sep", "type": null }, { "param": "glue", "type": null }, { "param": "removeEmpty", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "sep", "type": null, "docstring": null, "docstring_tokens": []...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
density
<not_specific>
def density(text, chars=None): """ density Returns the list of char ordered by density """ dic = {} chars = set(text) & set(chars) if chars else set(text) for c in text: if c in chars: dic[c] = 1 if not dic.has_key(c) else dic[c] + 1 dic = (sorted(dic.items(), key=lam...
density Returns the list of char ordered by density
density Returns the list of char ordered by density
[ "density", "Returns", "the", "list", "of", "char", "ordered", "by", "density" ]
def density(text, chars=None): dic = {} chars = set(text) & set(chars) if chars else set(text) for c in text: if c in chars: dic[c] = 1 if not dic.has_key(c) else dic[c] + 1 dic = (sorted(dic.items(), key=lambda x: x[1], reverse=True)) dic = [key for (key, value) in dic] retu...
[ "def", "density", "(", "text", ",", "chars", "=", "None", ")", ":", "dic", "=", "{", "}", "chars", "=", "set", "(", "text", ")", "&", "set", "(", "chars", ")", "if", "chars", "else", "set", "(", "text", ")", "for", "c", "in", "text", ":", "if...
density Returns the list of char ordered by density
[ "density", "Returns", "the", "list", "of", "char", "ordered", "by", "density" ]
[ "\"\"\"\n density\n Returns the list of char ordered by density\n \"\"\"" ]
[ { "param": "text", "type": null }, { "param": "chars", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "chars", "type": null, "docstring": null, "docstring_tokens": ...
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
isstring
<not_specific>
def isstring(var): """ isstring - Returns True if the variable is a string """ return isinstance(var, (str, unicode))
isstring - Returns True if the variable is a string
Returns True if the variable is a string
[ "Returns", "True", "if", "the", "variable", "is", "a", "string" ]
def isstring(var): return isinstance(var, (str, unicode))
[ "def", "isstring", "(", "var", ")", ":", "return", "isinstance", "(", "var", ",", "(", "str", ",", "unicode", ")", ")" ]
isstring - Returns True if the variable is a string
[ "isstring", "-", "Returns", "True", "if", "the", "variable", "is", "a", "string" ]
[ "\"\"\"\n isstring - Returns True if the variable is a string\n \"\"\"" ]
[ { "param": "var", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "var", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
isarray
<not_specific>
def isarray(var): """ isarray - Returns True if the variable is a list """ return isinstance(var, (list, tuple))
isarray - Returns True if the variable is a list
Returns True if the variable is a list
[ "Returns", "True", "if", "the", "variable", "is", "a", "list" ]
def isarray(var): return isinstance(var, (list, tuple))
[ "def", "isarray", "(", "var", ")", ":", "return", "isinstance", "(", "var", ",", "(", "list", ",", "tuple", ")", ")" ]
isarray - Returns True if the variable is a list
[ "isarray", "-", "Returns", "True", "if", "the", "variable", "is", "a", "list" ]
[ "\"\"\"\n isarray - Returns True if the variable is a list\n \"\"\"" ]
[ { "param": "var", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "var", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
isnumeric
<not_specific>
def isnumeric(text): """ isnumeric - a simple implementation (TODO: numbers with exponent) """ text = text.strip() dot = False for i in range(0, len(text)): c = text[i] if i == 0 and c in "+-": continue if c == "." and not dot: dot = True ...
isnumeric - a simple implementation (TODO: numbers with exponent)
a simple implementation (TODO: numbers with exponent)
[ "a", "simple", "implementation", "(", "TODO", ":", "numbers", "with", "exponent", ")" ]
def isnumeric(text): text = text.strip() dot = False for i in range(0, len(text)): c = text[i] if i == 0 and c in "+-": continue if c == "." and not dot: dot = True continue if not c.isdigit(): return False return True
[ "def", "isnumeric", "(", "text", ")", ":", "text", "=", "text", ".", "strip", "(", ")", "dot", "=", "False", "for", "i", "in", "range", "(", "0", ",", "len", "(", "text", ")", ")", ":", "c", "=", "text", "[", "i", "]", "if", "i", "==", "0",...
isnumeric - a simple implementation (TODO: numbers with exponent)
[ "isnumeric", "-", "a", "simple", "implementation", "(", "TODO", ":", "numbers", "with", "exponent", ")" ]
[ "\"\"\"\n isnumeric - a simple implementation\n (TODO: numbers with exponent)\n \"\"\"" ]
[ { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
0dddf258200eb1d812542ab1ba5db9be66f55325
valluzzi/libcore
gecosistema_lite/strings.py
[ "MIT" ]
Python
md5text
<not_specific>
def md5text(text): """ md5text - Returns the md5 of the text """ ##print md5.new(text).hexdigest() hash = hashlib.md5() hash.update(text) return hash.hexdigest()
md5text - Returns the md5 of the text
Returns the md5 of the text
[ "Returns", "the", "md5", "of", "the", "text" ]
def md5text(text): hash = hashlib.md5() hash.update(text) return hash.hexdigest()
[ "def", "md5text", "(", "text", ")", ":", "hash", "=", "hashlib", ".", "md5", "(", ")", "hash", ".", "update", "(", "text", ")", "return", "hash", ".", "hexdigest", "(", ")" ]
md5text - Returns the md5 of the text
[ "md5text", "-", "Returns", "the", "md5", "of", "the", "text" ]
[ "\"\"\"\n md5text - Returns the md5 of the text\n \"\"\"", "##print md5.new(text).hexdigest()" ]
[ { "param": "text", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "text", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
f1415e856228d8c5ff4a37a2f366467e33be22cf
dentou/Deformable-DETR
models/deformable_detr.py
[ "Apache-2.0" ]
Python
forward
<not_specific>
def forward(self, samples: NestedTensor): """ The forward expects a NestedTensor, which consists of: - samples.tensor: batched images, of shape [batch_size x 3 x H x W] - samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels It return...
 The forward expects a NestedTensor, which consists of: - samples.tensor: batched images, of shape [batch_size x 3 x H x W] - samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels It returns a dict with the following elements: ...
The forward expects a NestedTensor, which consists of: samples.tensor: batched images, of shape [batch_size x 3 x H x W] samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels It returns a dict with the following elements: "pred_logits": the classification logits (including no-object)...
[ "The", "forward", "expects", "a", "NestedTensor", "which", "consists", "of", ":", "samples", ".", "tensor", ":", "batched", "images", "of", "shape", "[", "batch_size", "x", "3", "x", "H", "x", "W", "]", "samples", ".", "mask", ":", "a", "binary", "mask...
def forward(self, samples: NestedTensor): if not isinstance(samples, NestedTensor): samples = nested_tensor_from_tensor_list(samples) features, pos = self.backbone(samples) srcs = [] masks = [] for l, feat in enumerate(features): src, mask = feat.decompose...
[ "def", "forward", "(", "self", ",", "samples", ":", "NestedTensor", ")", ":", "if", "not", "isinstance", "(", "samples", ",", "NestedTensor", ")", ":", "samples", "=", "nested_tensor_from_tensor_list", "(", "samples", ")", "features", ",", "pos", "=", "self"...
The forward expects a NestedTensor, which consists of: samples.tensor: batched images, of shape [batch_size x 3 x H x W] samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels
[ "The", "forward", "expects", "a", "NestedTensor", "which", "consists", "of", ":", "samples", ".", "tensor", ":", "batched", "images", "of", "shape", "[", "batch_size", "x", "3", "x", "H", "x", "W", "]", "samples", ".", "mask", ":", "a", "binary", "mask...
[ "\"\"\" The forward expects a NestedTensor, which consists of:\n - samples.tensor: batched images, of shape [batch_size x 3 x H x W]\n - samples.mask: a binary mask of shape [batch_size x H x W], containing 1 on padded pixels\n\n It returns a dict with the following elements:\...
[ { "param": "self", "type": null }, { "param": "samples", "type": "NestedTensor" } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "samples", "type": "NestedTensor", "docstring": null, "docstri...
f1415e856228d8c5ff4a37a2f366467e33be22cf
dentou/Deformable-DETR
models/deformable_detr.py
[ "Apache-2.0" ]
Python
loss_labels
<not_specific>
def loss_labels(self, outputs, targets, indices, num_boxes, log=True): """Classification loss (NLL) targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes] """ assert 'pred_logits' in outputs src_logits = outputs['pred_logits'] idx = self...
Classification loss (NLL) targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
Classification loss (NLL) targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
[ "Classification", "loss", "(", "NLL", ")", "targets", "dicts", "must", "contain", "the", "key", "\"", "labels", "\"", "containing", "a", "tensor", "of", "dim", "[", "nb_target_boxes", "]" ]
def loss_labels(self, outputs, targets, indices, num_boxes, log=True): assert 'pred_logits' in outputs src_logits = outputs['pred_logits'] idx = self._get_src_permutation_idx(indices) target_classes_o = torch.cat([t["labels"][J] for t, (_, J) in zip(targets, indices)]) target_cla...
[ "def", "loss_labels", "(", "self", ",", "outputs", ",", "targets", ",", "indices", ",", "num_boxes", ",", "log", "=", "True", ")", ":", "assert", "'pred_logits'", "in", "outputs", "src_logits", "=", "outputs", "[", "'pred_logits'", "]", "idx", "=", "self",...
Classification loss (NLL) targets dicts must contain the key "labels" containing a tensor of dim [nb_target_boxes]
[ "Classification", "loss", "(", "NLL", ")", "targets", "dicts", "must", "contain", "the", "key", "\"", "labels", "\"", "containing", "a", "tensor", "of", "dim", "[", "nb_target_boxes", "]" ]
[ "\"\"\"Classification loss (NLL)\n targets dicts must contain the key \"labels\" containing a tensor of dim [nb_target_boxes]\n \"\"\"", "# TODO this should probably be a separate loss, not hacked in this one here" ]
[ { "param": "self", "type": null }, { "param": "outputs", "type": null }, { "param": "targets", "type": null }, { "param": "indices", "type": null }, { "param": "num_boxes", "type": null }, { "param": "log", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outputs", "type": null, "docstring": null, "docstring_tokens"...
f1415e856228d8c5ff4a37a2f366467e33be22cf
dentou/Deformable-DETR
models/deformable_detr.py
[ "Apache-2.0" ]
Python
loss_masks
<not_specific>
def loss_masks(self, outputs, targets, indices, num_boxes): """Compute the losses related to the masks: the focal loss and the dice loss. targets dicts must contain the key "masks" containing a tensor of dim [nb_target_boxes, h, w] """ assert "pred_masks" in outputs src_idx =...
Compute the losses related to the masks: the focal loss and the dice loss. targets dicts must contain the key "masks" containing a tensor of dim [nb_target_boxes, h, w]
Compute the losses related to the masks: the focal loss and the dice loss. targets dicts must contain the key "masks" containing a tensor of dim [nb_target_boxes, h, w]
[ "Compute", "the", "losses", "related", "to", "the", "masks", ":", "the", "focal", "loss", "and", "the", "dice", "loss", ".", "targets", "dicts", "must", "contain", "the", "key", "\"", "masks", "\"", "containing", "a", "tensor", "of", "dim", "[", "nb_targ...
def loss_masks(self, outputs, targets, indices, num_boxes): assert "pred_masks" in outputs src_idx = self._get_src_permutation_idx(indices) tgt_idx = self._get_tgt_permutation_idx(indices) src_masks = outputs["pred_masks"] target_masks, valid = nested_tensor_from_tensor_list([t["...
[ "def", "loss_masks", "(", "self", ",", "outputs", ",", "targets", ",", "indices", ",", "num_boxes", ")", ":", "assert", "\"pred_masks\"", "in", "outputs", "src_idx", "=", "self", ".", "_get_src_permutation_idx", "(", "indices", ")", "tgt_idx", "=", "self", "...
Compute the losses related to the masks: the focal loss and the dice loss.
[ "Compute", "the", "losses", "related", "to", "the", "masks", ":", "the", "focal", "loss", "and", "the", "dice", "loss", "." ]
[ "\"\"\"Compute the losses related to the masks: the focal loss and the dice loss.\n targets dicts must contain the key \"masks\" containing a tensor of dim [nb_target_boxes, h, w]\n \"\"\"", "# TODO use valid to mask invalid areas due to padding in loss", "# upsample predictions to the target s...
[ { "param": "self", "type": null }, { "param": "outputs", "type": null }, { "param": "targets", "type": null }, { "param": "indices", "type": null }, { "param": "num_boxes", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outputs", "type": null, "docstring": null, "docstring_tokens"...
f1415e856228d8c5ff4a37a2f366467e33be22cf
dentou/Deformable-DETR
models/deformable_detr.py
[ "Apache-2.0" ]
Python
forward
<not_specific>
def forward(self, outputs, targets): """ This performs the loss computation. Parameters: outputs: dict of tensors, see the output specification of the model for the format targets: list of dicts, such that len(targets) == batch_size. The expected keys in e...
This performs the loss computation. Parameters: outputs: dict of tensors, see the output specification of the model for the format targets: list of dicts, such that len(targets) == batch_size. The expected keys in each dict depends on the losses applied, see each...
This performs the loss computation.
[ "This", "performs", "the", "loss", "computation", "." ]
def forward(self, outputs, targets): outputs_without_aux = {k: v for k, v in outputs.items() if k != 'aux_outputs' and k != 'enc_outputs'} indices = self.matcher(outputs_without_aux, targets) num_boxes = sum(len(t["labels"]) for t in targets) num_boxes = torch.as_tensor([num_boxes], dtyp...
[ "def", "forward", "(", "self", ",", "outputs", ",", "targets", ")", ":", "outputs_without_aux", "=", "{", "k", ":", "v", "for", "k", ",", "v", "in", "outputs", ".", "items", "(", ")", "if", "k", "!=", "'aux_outputs'", "and", "k", "!=", "'enc_outputs'...
This performs the loss computation.
[ "This", "performs", "the", "loss", "computation", "." ]
[ "\"\"\" This performs the loss computation.\n Parameters:\n outputs: dict of tensors, see the output specification of the model for the format\n targets: list of dicts, such that len(targets) == batch_size.\n The expected keys in each dict depends on the losses ap...
[ { "param": "self", "type": null }, { "param": "outputs", "type": null }, { "param": "targets", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "outputs", "type": null, "docstring": "dict of tensors, see the outp...
e6faae3fcb24ae1673a468e327efc561f4d29077
tomuram/keras-yolo2
frontend.py
[ "MIT" ]
Python
evaluate
<not_specific>
def evaluate(self, generator, iou_threshold=0.3, score_threshold=0.3, max_detections=100, save_path=None): """ Evaluate a given dataset using a given model. code originally from https://github.com/fizyr/keras-retinanet ...
Evaluate a given dataset using a given model. code originally from https://github.com/fizyr/keras-retinanet # Arguments generator : The generator that represents the dataset to evaluate. model : The model to evaluate. iou_threshold : The threshold ...
Evaluate a given dataset using a given model. Arguments generator : The generator that represents the dataset to evaluate. model : The model to evaluate. iou_threshold : The threshold used to consider when a detection is positive or negative. score_threshold : The score confidence threshold to use fo...
[ "Evaluate", "a", "given", "dataset", "using", "a", "given", "model", ".", "Arguments", "generator", ":", "The", "generator", "that", "represents", "the", "dataset", "to", "evaluate", ".", "model", ":", "The", "model", "to", "evaluate", ".", "iou_threshold", ...
def evaluate(self, generator, iou_threshold=0.3, score_threshold=0.3, max_detections=100, save_path=None): all_detections = [[None for i in range(generator.num_classes)] for j in range(generator.size())] all_annotat...
[ "def", "evaluate", "(", "self", ",", "generator", ",", "iou_threshold", "=", "0.3", ",", "score_threshold", "=", "0.3", ",", "max_detections", "=", "100", ",", "save_path", "=", "None", ")", ":", "all_detections", "=", "[", "[", "None", "for", "i", "in",...
Evaluate a given dataset using a given model.
[ "Evaluate", "a", "given", "dataset", "using", "a", "given", "model", "." ]
[ "\"\"\" Evaluate a given dataset using a given model.\n code originally from https://github.com/fizyr/keras-retinanet\n\n # Arguments\n generator : The generator that represents the dataset to evaluate.\n model : The model to evaluate.\n iou_threshold ...
[ { "param": "self", "type": null }, { "param": "generator", "type": null }, { "param": "iou_threshold", "type": null }, { "param": "score_threshold", "type": null }, { "param": "max_detections", "type": null }, { "param": "save_path", "type": null ...
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "generator", "type": null, "docstring": null, "docstring_token...
fabc9dd70351949da9fe85aadcfcb6e956e2ddab
dinhnhobao/NUSBuy
src/products/views.py
[ "MIT" ]
Python
products_list
<not_specific>
def products_list(request): """ Renders the products/product_list.html template which lists all the currently available polls """ if not request.GET._mutable: request.GET._mutable = True products = Product.objects.get_queryset().order_by('id') EXCLUSIVE_QUERIES = [ 'titl...
Renders the products/product_list.html template which lists all the currently available polls
Renders the products/product_list.html template which lists all the currently available polls
[ "Renders", "the", "products", "/", "product_list", ".", "html", "template", "which", "lists", "all", "the", "currently", "available", "polls" ]
def products_list(request): if not request.GET._mutable: request.GET._mutable = True products = Product.objects.get_queryset().order_by('id') EXCLUSIVE_QUERIES = [ 'title', 'pub_date', 'view_count', 'price_increasing', 'price_descending', 'condition_us...
[ "def", "products_list", "(", "request", ")", ":", "if", "not", "request", ".", "GET", ".", "_mutable", ":", "request", ".", "GET", ".", "_mutable", "=", "True", "products", "=", "Product", ".", "objects", ".", "get_queryset", "(", ")", ".", "order_by", ...
Renders the products/product_list.html template which lists all the currently available polls
[ "Renders", "the", "products", "/", "product_list", ".", "html", "template", "which", "lists", "all", "the", "currently", "available", "polls" ]
[ "\"\"\"\n Renders the products/product_list.html template which lists all the\n currently available polls\n \"\"\"", "#sorting", "#used items", "#new items ", "###", "#search bar", "#pagination:", "#specific chunk of products", "###Preserving Query Parameters When Using Paginator", "###" ...
[ { "param": "request", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "request", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dbe5dc350559245d705834c57b9c3eeeb261b5d3
wbazant/humann
humann/store.py
[ "MIT" ]
Python
store_id_mapping
<not_specific>
def store_id_mapping(file): """ Store the id mapping data from the tab delimited file """ id_mapping={} # Check the file exists and is readable utilities.file_exists_readable(file) file_handle=open(file,"rt") line=file_handle.readline() while line: # Ign...
Store the id mapping data from the tab delimited file
Store the id mapping data from the tab delimited file
[ "Store", "the", "id", "mapping", "data", "from", "the", "tab", "delimited", "file" ]
def store_id_mapping(file): id_mapping={} utilities.file_exists_readable(file) file_handle=open(file,"rt") line=file_handle.readline() while line: if not re.search(config.id_mapping_comment_indicator,line): data=line.rstrip().split(config.id_mapping_delimiter) refere...
[ "def", "store_id_mapping", "(", "file", ")", ":", "id_mapping", "=", "{", "}", "utilities", ".", "file_exists_readable", "(", "file", ")", "file_handle", "=", "open", "(", "file", ",", "\"rt\"", ")", "line", "=", "file_handle", ".", "readline", "(", ")", ...
Store the id mapping data from the tab delimited file
[ "Store", "the", "id", "mapping", "data", "from", "the", "tab", "delimited", "file" ]
[ "\"\"\"\n Store the id mapping data from the tab delimited file\n \"\"\"", "# Check the file exists and is readable", "# Ignore comment lines", "# set the default values for the mapping", "# if the reference and gene are found, store the mapping" ]
[ { "param": "file", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "file", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dbe5dc350559245d705834c57b9c3eeeb261b5d3
wbazant/humann
humann/store.py
[ "MIT" ]
Python
normalized_gene_length
<not_specific>
def normalized_gene_length(gene_length, read_length): """ Compute the normalized gene length with the average read length if set Report in reads per kilobase """ # if read length is not provided, default to 1 if read_length < 1: read_length = 1 return (abs(gene_length - read_le...
Compute the normalized gene length with the average read length if set Report in reads per kilobase
Compute the normalized gene length with the average read length if set Report in reads per kilobase
[ "Compute", "the", "normalized", "gene", "length", "with", "the", "average", "read", "length", "if", "set", "Report", "in", "reads", "per", "kilobase" ]
def normalized_gene_length(gene_length, read_length): if read_length < 1: read_length = 1 return (abs(gene_length - read_length)+1)/1000.0
[ "def", "normalized_gene_length", "(", "gene_length", ",", "read_length", ")", ":", "if", "read_length", "<", "1", ":", "read_length", "=", "1", "return", "(", "abs", "(", "gene_length", "-", "read_length", ")", "+", "1", ")", "/", "1000.0" ]
Compute the normalized gene length with the average read length if set Report in reads per kilobase
[ "Compute", "the", "normalized", "gene", "length", "with", "the", "average", "read", "length", "if", "set", "Report", "in", "reads", "per", "kilobase" ]
[ "\"\"\"\n Compute the normalized gene length with the average read length if set\n Report in reads per kilobase\n \"\"\"", "# if read length is not provided, default to 1" ]
[ { "param": "gene_length", "type": null }, { "param": "read_length", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "gene_length", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "read_length", "type": null, "docstring": null, "docstr...
dbe5dc350559245d705834c57b9c3eeeb261b5d3
wbazant/humann
humann/store.py
[ "MIT" ]
Python
do
null
def do(self, *args): """ Run a stateful statement like add or delete If within a transaction, commit and reopen every 100k operations """ self.__conn.execute(*args) if self.__is_within_transaction: self.__stateful_ops_since_commit +=1 if self.__sta...
Run a stateful statement like add or delete If within a transaction, commit and reopen every 100k operations
Run a stateful statement like add or delete If within a transaction, commit and reopen every 100k operations
[ "Run", "a", "stateful", "statement", "like", "add", "or", "delete", "If", "within", "a", "transaction", "commit", "and", "reopen", "every", "100k", "operations" ]
def do(self, *args): self.__conn.execute(*args) if self.__is_within_transaction: self.__stateful_ops_since_commit +=1 if self.__stateful_ops_since_commit % 100000 == 0: self.__conn.execute("commit transaction") self.__conn.execute("begin transactio...
[ "def", "do", "(", "self", ",", "*", "args", ")", ":", "self", ".", "__conn", ".", "execute", "(", "*", "args", ")", "if", "self", ".", "__is_within_transaction", ":", "self", ".", "__stateful_ops_since_commit", "+=", "1", "if", "self", ".", "__stateful_o...
Run a stateful statement like add or delete If within a transaction, commit and reopen every 100k operations
[ "Run", "a", "stateful", "statement", "like", "add", "or", "delete", "If", "within", "a", "transaction", "commit", "and", "reopen", "every", "100k", "operations" ]
[ "\"\"\"\n Run a stateful statement like add or delete\n If within a transaction, commit and reopen every 100k operations\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dbe5dc350559245d705834c57b9c3eeeb261b5d3
wbazant/humann
humann/store.py
[ "MIT" ]
Python
clear
null
def clear(self): """ Clear all of the stored data """ self.__conn.close() self.__conn = None
Clear all of the stored data
Clear all of the stored data
[ "Clear", "all", "of", "the", "stored", "data" ]
def clear(self): self.__conn.close() self.__conn = None
[ "def", "clear", "(", "self", ")", ":", "self", ".", "__conn", ".", "close", "(", ")", "self", ".", "__conn", "=", "None" ]
Clear all of the stored data
[ "Clear", "all", "of", "the", "stored", "data" ]
[ "\"\"\"\n Clear all of the stored data\n \"\"\"" ]
[ { "param": "self", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null } ], "outlier_params": [], "others": [] }
dbe5dc350559245d705834c57b9c3eeeb261b5d3
wbazant/humann
humann/store.py
[ "MIT" ]
Python
process_chocophlan_length
<not_specific>
def process_chocophlan_length(self,location,gene): """ Return the length given the sequence location """ try: if config.chocophlan_multiple_location_delimiter in location: locations=location.split(config.chocophlan_multiple_location_delimiter) ...
Return the length given the sequence location
Return the length given the sequence location
[ "Return", "the", "length", "given", "the", "sequence", "location" ]
def process_chocophlan_length(self,location,gene): try: if config.chocophlan_multiple_location_delimiter in location: locations=location.split(config.chocophlan_multiple_location_delimiter) else: locations=[location] length=0 for lo...
[ "def", "process_chocophlan_length", "(", "self", ",", "location", ",", "gene", ")", ":", "try", ":", "if", "config", ".", "chocophlan_multiple_location_delimiter", "in", "location", ":", "locations", "=", "location", ".", "split", "(", "config", ".", "chocophlan...
Return the length given the sequence location
[ "Return", "the", "length", "given", "the", "sequence", "location" ]
[ "\"\"\"\n Return the length given the sequence location\n \"\"\"" ]
[ { "param": "self", "type": null }, { "param": "location", "type": null }, { "param": "gene", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "location", "type": null, "docstring": null, "docstring_tokens...
dbe5dc350559245d705834c57b9c3eeeb261b5d3
wbazant/humann
humann/store.py
[ "MIT" ]
Python
process_reference_annotation
<not_specific>
def process_reference_annotation(self,reference): """ Process the reference string for information on gene, gene length, and bug Allow for chocophlan annotations, gene|gene_length, gene_length|gene, and gene Also use id mapping if provided """ # if id mapping is ...
Process the reference string for information on gene, gene length, and bug Allow for chocophlan annotations, gene|gene_length, gene_length|gene, and gene Also use id mapping if provided
Process the reference string for information on gene, gene length, and bug Allow for chocophlan annotations, gene|gene_length, gene_length|gene, and gene Also use id mapping if provided
[ "Process", "the", "reference", "string", "for", "information", "on", "gene", "gene", "length", "and", "bug", "Allow", "for", "chocophlan", "annotations", "gene|gene_length", "gene_length|gene", "and", "gene", "Also", "use", "id", "mapping", "if", "provided" ]
def process_reference_annotation(self,reference): gene="" if self.__id_mapping: if reference in self.__id_mapping: [gene,length,bug]=self.__id_mapping[reference] if not gene: reference_info=reference.split(config.chocophlan_delimiter) length=0 ...
[ "def", "process_reference_annotation", "(", "self", ",", "reference", ")", ":", "gene", "=", "\"\"", "if", "self", ".", "__id_mapping", ":", "if", "reference", "in", "self", ".", "__id_mapping", ":", "[", "gene", ",", "length", ",", "bug", "]", "=", "sel...
Process the reference string for information on gene, gene length, and bug Allow for chocophlan annotations, gene|gene_length, gene_length|gene, and gene Also use id mapping if provided
[ "Process", "the", "reference", "string", "for", "information", "on", "gene", "gene", "length", "and", "bug", "Allow", "for", "chocophlan", "annotations", "gene|gene_length", "gene_length|gene", "and", "gene", "Also", "use", "id", "mapping", "if", "provided" ]
[ "\"\"\"\n Process the reference string for information on gene, gene length, and bug\n Allow for chocophlan annotations, gene|gene_length, gene_length|gene, and gene\n Also use id mapping if provided\n \"\"\"", "# if id mapping is provided first try to use it for the annotation data", ...
[ { "param": "self", "type": null }, { "param": "reference", "type": null } ]
{ "returns": [], "raises": [], "params": [ { "identifier": "self", "type": null, "docstring": null, "docstring_tokens": [], "default": null, "is_optional": null }, { "identifier": "reference", "type": null, "docstring": null, "docstring_token...