repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
volafiled/python-volapi
volapi/volapi.py
Room.__get_config
def __get_config(self): """ Really connect """ if not self.name: room_resp = self.conn.get(BASE_URL + "/new") room_resp.raise_for_status() url = room_resp.url try: self.name = re.search(r"r/(.+?)$", url).group(1) except Excepti...
python
def __get_config(self): """ Really connect """ if not self.name: room_resp = self.conn.get(BASE_URL + "/new") room_resp.raise_for_status() url = room_resp.url try: self.name = re.search(r"r/(.+?)$", url).group(1) except Excepti...
[ "def", "__get_config", "(", "self", ")", ":", "if", "not", "self", ".", "name", ":", "room_resp", "=", "self", ".", "conn", ".", "get", "(", "BASE_URL", "+", "\"/new\"", ")", "room_resp", ".", "raise_for_status", "(", ")", "url", "=", "room_resp", ".",...
Really connect
[ "Really", "connect" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L442-L471
volafiled/python-volapi
volapi/volapi.py
Room.listen
def listen(self, once=False): """Listen for changes in all registered listeners. Use add_listener before calling this funcion to listen for desired events or set `once` to True to listen for initial room information """ if once: # we listen for time event and return false so...
python
def listen(self, once=False): """Listen for changes in all registered listeners. Use add_listener before calling this funcion to listen for desired events or set `once` to True to listen for initial room information """ if once: # we listen for time event and return false so...
[ "def", "listen", "(", "self", ",", "once", "=", "False", ")", ":", "if", "once", ":", "# we listen for time event and return false so our", "# run_queues function will be also falsy and break the loop", "self", ".", "add_listener", "(", "\"time\"", ",", "lambda", "_", "...
Listen for changes in all registered listeners. Use add_listener before calling this funcion to listen for desired events or set `once` to True to listen for initial room information
[ "Listen", "for", "changes", "in", "all", "registered", "listeners", ".", "Use", "add_listener", "before", "calling", "this", "funcion", "to", "listen", "for", "desired", "events", "or", "set", "once", "to", "True", "to", "listen", "for", "initial", "room", "...
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L497-L506
volafiled/python-volapi
volapi/volapi.py
Room.__expire_files
def __expire_files(self): """Because files are always unclean""" self.__files = OrderedDict( item for item in self.__files.items() if not item[1].expired )
python
def __expire_files(self): """Because files are always unclean""" self.__files = OrderedDict( item for item in self.__files.items() if not item[1].expired )
[ "def", "__expire_files", "(", "self", ")", ":", "self", ".", "__files", "=", "OrderedDict", "(", "item", "for", "item", "in", "self", ".", "__files", ".", "items", "(", ")", "if", "not", "item", "[", "1", "]", ".", "expired", ")" ]
Because files are always unclean
[ "Because", "files", "are", "always", "unclean" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L529-L534
volafiled/python-volapi
volapi/volapi.py
Room.filedict
def filedict(self, kv): """Updates filedict with single file entry or deletes given key if the value is False. Shouldn't be used by the user.""" k, v = kv if v is not None: self.__files.update({k: v}) else: with suppress(KeyError): del sel...
python
def filedict(self, kv): """Updates filedict with single file entry or deletes given key if the value is False. Shouldn't be used by the user.""" k, v = kv if v is not None: self.__files.update({k: v}) else: with suppress(KeyError): del sel...
[ "def", "filedict", "(", "self", ",", "kv", ")", ":", "k", ",", "v", "=", "kv", "if", "v", "is", "not", "None", ":", "self", ".", "__files", ".", "update", "(", "{", "k", ":", "v", "}", ")", "else", ":", "with", "suppress", "(", "KeyError", ")...
Updates filedict with single file entry or deletes given key if the value is False. Shouldn't be used by the user.
[ "Updates", "filedict", "with", "single", "file", "entry", "or", "deletes", "given", "key", "if", "the", "value", "is", "False", ".", "Shouldn", "t", "be", "used", "by", "the", "user", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L555-L564
volafiled/python-volapi
volapi/volapi.py
Room.get_user_stats
def get_user_stats(self, name): """Return data about the given user. Returns None if user does not exist.""" req = self.conn.get(BASE_URL + "/user/" + name) if req.status_code != 200 or not name: return None return self.conn.make_api_call("getUserInfo", {"name": nam...
python
def get_user_stats(self, name): """Return data about the given user. Returns None if user does not exist.""" req = self.conn.get(BASE_URL + "/user/" + name) if req.status_code != 200 or not name: return None return self.conn.make_api_call("getUserInfo", {"name": nam...
[ "def", "get_user_stats", "(", "self", ",", "name", ")", ":", "req", "=", "self", ".", "conn", ".", "get", "(", "BASE_URL", "+", "\"/user/\"", "+", "name", ")", "if", "req", ".", "status_code", "!=", "200", "or", "not", "name", ":", "return", "None", ...
Return data about the given user. Returns None if user does not exist.
[ "Return", "data", "about", "the", "given", "user", ".", "Returns", "None", "if", "user", "does", "not", "exist", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L566-L574
volafiled/python-volapi
volapi/volapi.py
Room.post_chat
def post_chat(self, msg, is_me=False, is_a=False): """Posts a msg to this room's chat. Set me=True if you want to /me""" if len(msg) > self.config.max_message: raise ValueError( f"Chat message must be at most {self.config.max_message} characters." ) while...
python
def post_chat(self, msg, is_me=False, is_a=False): """Posts a msg to this room's chat. Set me=True if you want to /me""" if len(msg) > self.config.max_message: raise ValueError( f"Chat message must be at most {self.config.max_message} characters." ) while...
[ "def", "post_chat", "(", "self", ",", "msg", ",", "is_me", "=", "False", ",", "is_a", "=", "False", ")", ":", "if", "len", "(", "msg", ")", ">", "self", ".", "config", ".", "max_message", ":", "raise", "ValueError", "(", "f\"Chat message must be at most ...
Posts a msg to this room's chat. Set me=True if you want to /me
[ "Posts", "a", "msg", "to", "this", "room", "s", "chat", ".", "Set", "me", "=", "True", "if", "you", "want", "to", "/", "me" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L576-L595
volafiled/python-volapi
volapi/volapi.py
Room.upload_file
def upload_file( self, filename, upload_as=None, blocksize=None, callback=None, information_callback=None, allow_timeout=False, ): """Uploads a file with given filename to this room. You may specify upload_as to change the name it is uploaded a...
python
def upload_file( self, filename, upload_as=None, blocksize=None, callback=None, information_callback=None, allow_timeout=False, ): """Uploads a file with given filename to this room. You may specify upload_as to change the name it is uploaded a...
[ "def", "upload_file", "(", "self", ",", "filename", ",", "upload_as", "=", "None", ",", "blocksize", "=", "None", ",", "callback", "=", "None", ",", "information_callback", "=", "None", ",", "allow_timeout", "=", "False", ",", ")", ":", "with", "delayed_cl...
Uploads a file with given filename to this room. You may specify upload_as to change the name it is uploaded as. You can also specify a blocksize and a callback if you wish. Returns the file's id on success and None on failure.
[ "Uploads", "a", "file", "with", "given", "filename", "to", "this", "room", ".", "You", "may", "specify", "upload_as", "to", "change", "the", "name", "it", "is", "uploaded", "as", ".", "You", "can", "also", "specify", "a", "blocksize", "and", "a", "callba...
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L597-L701
volafiled/python-volapi
volapi/volapi.py
Room.close
def close(self): """Close connection to this room""" if hasattr(self, "conn"): self.conn.close() del self.conn if hasattr(self, "user"): del self.user
python
def close(self): """Close connection to this room""" if hasattr(self, "conn"): self.conn.close() del self.conn if hasattr(self, "user"): del self.user
[ "def", "close", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"conn\"", ")", ":", "self", ".", "conn", ".", "close", "(", ")", "del", "self", ".", "conn", "if", "hasattr", "(", "self", ",", "\"user\"", ")", ":", "del", "self", ".", ...
Close connection to this room
[ "Close", "connection", "to", "this", "room" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L703-L710
volafiled/python-volapi
volapi/volapi.py
Room.user_info
def user_info(self, kv): """Sets user_info dict entry through a tuple.""" key, value = kv self.__user_info[key] = value
python
def user_info(self, kv): """Sets user_info dict entry through a tuple.""" key, value = kv self.__user_info[key] = value
[ "def", "user_info", "(", "self", ",", "kv", ")", ":", "key", ",", "value", "=", "kv", "self", ".", "__user_info", "[", "key", "]", "=", "value" ]
Sets user_info dict entry through a tuple.
[ "Sets", "user_info", "dict", "entry", "through", "a", "tuple", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L724-L728
volafiled/python-volapi
volapi/volapi.py
Room.fileinfo
def fileinfo(self, fid): """Ask lain about what he knows about given file. If the given file exists in the file dict, it will get updated.""" if not isinstance(fid, str): raise TypeError("Your file ID must be a string") try: info = self.conn.make_call_with_cb("ge...
python
def fileinfo(self, fid): """Ask lain about what he knows about given file. If the given file exists in the file dict, it will get updated.""" if not isinstance(fid, str): raise TypeError("Your file ID must be a string") try: info = self.conn.make_call_with_cb("ge...
[ "def", "fileinfo", "(", "self", ",", "fid", ")", ":", "if", "not", "isinstance", "(", "fid", ",", "str", ")", ":", "raise", "TypeError", "(", "\"Your file ID must be a string\"", ")", "try", ":", "info", "=", "self", ".", "conn", ".", "make_call_with_cb", ...
Ask lain about what he knows about given file. If the given file exists in the file dict, it will get updated.
[ "Ask", "lain", "about", "what", "he", "knows", "about", "given", "file", ".", "If", "the", "given", "file", "exists", "in", "the", "file", "dict", "it", "will", "get", "updated", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L749-L768
volafiled/python-volapi
volapi/volapi.py
Room._generate_upload_key
def _generate_upload_key(self, allow_timeout=False): """Generates a new upload key""" # Wait for server to set username if not set already. while not self.user.nick: with ARBITRATOR.condition: ARBITRATOR.condition.wait() while True: params = { ...
python
def _generate_upload_key(self, allow_timeout=False): """Generates a new upload key""" # Wait for server to set username if not set already. while not self.user.nick: with ARBITRATOR.condition: ARBITRATOR.condition.wait() while True: params = { ...
[ "def", "_generate_upload_key", "(", "self", ",", "allow_timeout", "=", "False", ")", ":", "# Wait for server to set username if not set already.", "while", "not", "self", ".", "user", ".", "nick", ":", "with", "ARBITRATOR", ".", "condition", ":", "ARBITRATOR", ".", ...
Generates a new upload key
[ "Generates", "a", "new", "upload", "key" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L770-L795
volafiled/python-volapi
volapi/volapi.py
Room.delete_files
def delete_files(self, ids): """Remove one or more files""" self.check_owner() if not isinstance(ids, list): raise TypeError("You must specify list of files to delete!") self.conn.make_call("deleteFiles", ids)
python
def delete_files(self, ids): """Remove one or more files""" self.check_owner() if not isinstance(ids, list): raise TypeError("You must specify list of files to delete!") self.conn.make_call("deleteFiles", ids)
[ "def", "delete_files", "(", "self", ",", "ids", ")", ":", "self", ".", "check_owner", "(", ")", "if", "not", "isinstance", "(", "ids", ",", "list", ")", ":", "raise", "TypeError", "(", "\"You must specify list of files to delete!\"", ")", "self", ".", "conn"...
Remove one or more files
[ "Remove", "one", "or", "more", "files" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L797-L803
volafiled/python-volapi
volapi/volapi.py
Room.transfer_owner
def transfer_owner(self, new_owner): """You had good run at it, it's time for someone else to get dirty""" if not self.owner and not self.admin: raise RuntimeError("You need more street creed to do this") new_owner = new_owner.strip().lower() if not new_owner: r...
python
def transfer_owner(self, new_owner): """You had good run at it, it's time for someone else to get dirty""" if not self.owner and not self.admin: raise RuntimeError("You need more street creed to do this") new_owner = new_owner.strip().lower() if not new_owner: r...
[ "def", "transfer_owner", "(", "self", ",", "new_owner", ")", ":", "if", "not", "self", ".", "owner", "and", "not", "self", ".", "admin", ":", "raise", "RuntimeError", "(", "\"You need more street creed to do this\"", ")", "new_owner", "=", "new_owner", ".", "s...
You had good run at it, it's time for someone else to get dirty
[ "You", "had", "good", "run", "at", "it", "it", "s", "time", "for", "someone", "else", "to", "get", "dirty" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L805-L815
volafiled/python-volapi
volapi/volapi.py
Room.add_janitor
def add_janitor(self, janitor): """Add janitor to the room""" if not self.owner and not self.admin: raise RuntimeError("Not enough street creed to do this") janitor = janitor.strip().lower() if not janitor: raise ValueError("Empty strings cannot be janitors") ...
python
def add_janitor(self, janitor): """Add janitor to the room""" if not self.owner and not self.admin: raise RuntimeError("Not enough street creed to do this") janitor = janitor.strip().lower() if not janitor: raise ValueError("Empty strings cannot be janitors") ...
[ "def", "add_janitor", "(", "self", ",", "janitor", ")", ":", "if", "not", "self", ".", "owner", "and", "not", "self", ".", "admin", ":", "raise", "RuntimeError", "(", "\"Not enough street creed to do this\"", ")", "janitor", "=", "janitor", ".", "strip", "("...
Add janitor to the room
[ "Add", "janitor", "to", "the", "room" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L817-L831
volafiled/python-volapi
volapi/volapi.py
Room.remove_janitor
def remove_janitor(self, janitor): """Remove janitor from the room""" if not self.owner and not self.admin: raise RuntimeError("Not enough street creed to do this") janitor = janitor.strip().lower() if not janitor: raise ValueError("Empty strings cannot be janit...
python
def remove_janitor(self, janitor): """Remove janitor from the room""" if not self.owner and not self.admin: raise RuntimeError("Not enough street creed to do this") janitor = janitor.strip().lower() if not janitor: raise ValueError("Empty strings cannot be janit...
[ "def", "remove_janitor", "(", "self", ",", "janitor", ")", ":", "if", "not", "self", ".", "owner", "and", "not", "self", ".", "admin", ":", "raise", "RuntimeError", "(", "\"Not enough street creed to do this\"", ")", "janitor", "=", "janitor", ".", "strip", ...
Remove janitor from the room
[ "Remove", "janitor", "from", "the", "room" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/volapi.py#L833-L847
guaix-ucm/pyemir
emirdrp/processing/wavecal/overplot_boundary_model.py
overplot_lines
def overplot_lines(ax, catlines_all_wave, list_valid_islitlets, rectwv_coeff, global_integer_offset_x_pix, global_integer_offset_y_pix, ds9_file, debugplot): """Overplot lines (arc/OH). Parameters ---------- ...
python
def overplot_lines(ax, catlines_all_wave, list_valid_islitlets, rectwv_coeff, global_integer_offset_x_pix, global_integer_offset_y_pix, ds9_file, debugplot): """Overplot lines (arc/OH). Parameters ---------- ...
[ "def", "overplot_lines", "(", "ax", ",", "catlines_all_wave", ",", "list_valid_islitlets", ",", "rectwv_coeff", ",", "global_integer_offset_x_pix", ",", "global_integer_offset_y_pix", ",", "ds9_file", ",", "debugplot", ")", ":", "for", "islitlet", "in", "list_valid_isli...
Overplot lines (arc/OH). Parameters ---------- ax : matplotlib axes Current plot axes. catlines_all_wave : numpy array Array with wavelengths of the lines to be overplotted. list_valid_islitlets : list of integers List with numbers of valid slitlets. rectwv_coeff : RectW...
[ "Overplot", "lines", "(", "arc", "/", "OH", ")", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/overplot_boundary_model.py#L54-L153
BeyondTheClouds/enoslib
enoslib/task.py
enostask
def enostask(new=False): """Decorator for an Enos Task. This decorator lets you define a new Enos task and helps you manage the environment. It injects the environment in the function called. Args: new (bool): indicates if a new environment must be created. Usually this is set on t...
python
def enostask(new=False): """Decorator for an Enos Task. This decorator lets you define a new Enos task and helps you manage the environment. It injects the environment in the function called. Args: new (bool): indicates if a new environment must be created. Usually this is set on t...
[ "def", "enostask", "(", "new", "=", "False", ")", ":", "def", "decorator", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "decorated", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Constructs the environment", "# --env or env are res...
Decorator for an Enos Task. This decorator lets you define a new Enos task and helps you manage the environment. It injects the environment in the function called. Args: new (bool): indicates if a new environment must be created. Usually this is set on the first task of the workflow. ...
[ "Decorator", "for", "an", "Enos", "Task", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/task.py#L20-L66
BeyondTheClouds/enoslib
enoslib/task.py
_make_env
def _make_env(resultdir=None): """Loads the env from `resultdir` if not `None` or makes a new one. An Enos environment handles all specific variables of an experiment. This function either generates a new environment or loads a previous one. If the value of `resultdir` is `None`, then this function...
python
def _make_env(resultdir=None): """Loads the env from `resultdir` if not `None` or makes a new one. An Enos environment handles all specific variables of an experiment. This function either generates a new environment or loads a previous one. If the value of `resultdir` is `None`, then this function...
[ "def", "_make_env", "(", "resultdir", "=", "None", ")", ":", "env", "=", "{", "\"config\"", ":", "{", "}", ",", "# The config", "\"resultdir\"", ":", "\"\"", ",", "# Path to the result directory", "\"config_file\"", ":", "\"\"", ",", "# The initial config file", ...
Loads the env from `resultdir` if not `None` or makes a new one. An Enos environment handles all specific variables of an experiment. This function either generates a new environment or loads a previous one. If the value of `resultdir` is `None`, then this function makes a new environment and return it...
[ "Loads", "the", "env", "from", "resultdir", "if", "not", "None", "or", "makes", "a", "new", "one", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/task.py#L69-L110
BeyondTheClouds/enoslib
enoslib/task.py
_save_env
def _save_env(env): """Saves one environment. Args: env (dict): the env dict to save. """ env_path = os.path.join(env["resultdir"], "env") if os.path.isdir(env["resultdir"]): with open(env_path, "w") as f: yaml.dump(env, f)
python
def _save_env(env): """Saves one environment. Args: env (dict): the env dict to save. """ env_path = os.path.join(env["resultdir"], "env") if os.path.isdir(env["resultdir"]): with open(env_path, "w") as f: yaml.dump(env, f)
[ "def", "_save_env", "(", "env", ")", ":", "env_path", "=", "os", ".", "path", ".", "join", "(", "env", "[", "\"resultdir\"", "]", ",", "\"env\"", ")", "if", "os", ".", "path", ".", "isdir", "(", "env", "[", "\"resultdir\"", "]", ")", ":", "with", ...
Saves one environment. Args: env (dict): the env dict to save.
[ "Saves", "one", "environment", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/task.py#L113-L123
BeyondTheClouds/enoslib
enoslib/task.py
_check_env
def _check_env(fn): """Decorator for an Enos Task. This decorator checks if an environment file exists. """ def decorator(*args, **kwargs): # If no directory is provided, set the default one resultdir = kwargs.get("--env", SYMLINK_NAME) # Check if the env file exists env...
python
def _check_env(fn): """Decorator for an Enos Task. This decorator checks if an environment file exists. """ def decorator(*args, **kwargs): # If no directory is provided, set the default one resultdir = kwargs.get("--env", SYMLINK_NAME) # Check if the env file exists env...
[ "def", "_check_env", "(", "fn", ")", ":", "def", "decorator", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# If no directory is provided, set the default one", "resultdir", "=", "kwargs", ".", "get", "(", "\"--env\"", ",", "SYMLINK_NAME", ")", "# Chec...
Decorator for an Enos Task. This decorator checks if an environment file exists.
[ "Decorator", "for", "an", "Enos", "Task", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/task.py#L126-L141
BeyondTheClouds/enoslib
enoslib/task.py
_set_resultdir
def _set_resultdir(name=None): """Set or get the directory to store experiment results. Looks at the `name` and create the directory if it doesn"t exist or returns it in other cases. If the name is `None`, then the function generates an unique name for the results directory. Finally, it links the ...
python
def _set_resultdir(name=None): """Set or get the directory to store experiment results. Looks at the `name` and create the directory if it doesn"t exist or returns it in other cases. If the name is `None`, then the function generates an unique name for the results directory. Finally, it links the ...
[ "def", "_set_resultdir", "(", "name", "=", "None", ")", ":", "# Compute file path of results directory", "resultdir_name", "=", "name", "or", "\"enos_\"", "+", "datetime", ".", "today", "(", ")", ".", "isoformat", "(", ")", "resultdir_path", "=", "os", ".", "p...
Set or get the directory to store experiment results. Looks at the `name` and create the directory if it doesn"t exist or returns it in other cases. If the name is `None`, then the function generates an unique name for the results directory. Finally, it links the directory to `SYMLINK_NAME`. Args...
[ "Set", "or", "get", "the", "directory", "to", "store", "experiment", "results", "." ]
train
https://github.com/BeyondTheClouds/enoslib/blob/fb00be58e56a7848cfe482187d659744919fe2f7/enoslib/task.py#L144-L189
BreakingBytes/simkit
simkit/core/data_sources.py
DataRegistry.register
def register(self, newdata, *args, **kwargs): """ Register data in registry. Meta for each data is specified by positional or keyword arguments after the new data and consists of the following: * ``uncertainty`` - Map of uncertainties in percent corresponding to new keys. The ...
python
def register(self, newdata, *args, **kwargs): """ Register data in registry. Meta for each data is specified by positional or keyword arguments after the new data and consists of the following: * ``uncertainty`` - Map of uncertainties in percent corresponding to new keys. The ...
[ "def", "register", "(", "self", ",", "newdata", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "zip", "(", "self", ".", "meta_names", ",", "args", ")", ")", "# check uncertainty has units of percent", "uncertainty", "=",...
Register data in registry. Meta for each data is specified by positional or keyword arguments after the new data and consists of the following: * ``uncertainty`` - Map of uncertainties in percent corresponding to new keys. The uncertainty keys must be a subset of the new data keys. * ...
[ "Register", "data", "in", "registry", ".", "Meta", "for", "each", "data", "is", "specified", "by", "positional", "or", "keyword", "arguments", "after", "the", "new", "data", "and", "consists", "of", "the", "following", ":" ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_sources.py#L49-L107
BreakingBytes/simkit
simkit/core/data_sources.py
DataSource._is_cached
def _is_cached(self, ext='.json'): """ Determine if ``filename`` is cached using extension ``ex`` a string. :param ext: extension used to cache ``filename``, default is '.json' :type ext: str :return: True if ``filename`` is cached using extensions ``ex`` :rtype: bool ...
python
def _is_cached(self, ext='.json'): """ Determine if ``filename`` is cached using extension ``ex`` a string. :param ext: extension used to cache ``filename``, default is '.json' :type ext: str :return: True if ``filename`` is cached using extensions ``ex`` :rtype: bool ...
[ "def", "_is_cached", "(", "self", ",", "ext", "=", "'.json'", ")", ":", "# extension must start with a dot", "if", "not", "ext", ".", "startswith", "(", "'.'", ")", ":", "# prepend extension with a dot", "ext", "=", "'.%s'", "%", "ext", "# cache file is filename w...
Determine if ``filename`` is cached using extension ``ex`` a string. :param ext: extension used to cache ``filename``, default is '.json' :type ext: str :return: True if ``filename`` is cached using extensions ``ex`` :rtype: bool
[ "Determine", "if", "filename", "is", "cached", "using", "extension", "ex", "a", "string", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_sources.py#L237-L254
BreakingBytes/simkit
simkit/core/data_sources.py
DataSource.saveas_json
def saveas_json(self, save_name): """ Save :attr:`data`, :attr:`param_file`, original :attr:`data_reader` and UTC modification time as keys in JSON file. If data is edited then it should be saved using this method. Non-JSON data files are also saved using this method. :p...
python
def saveas_json(self, save_name): """ Save :attr:`data`, :attr:`param_file`, original :attr:`data_reader` and UTC modification time as keys in JSON file. If data is edited then it should be saved using this method. Non-JSON data files are also saved using this method. :p...
[ "def", "saveas_json", "(", "self", ",", "save_name", ")", ":", "# make pycharm by defining inferred objects", "meta", "=", "getattr", "(", "self", ",", "DataSourceBase", ".", "_meta_attr", ")", "param_file", "=", "getattr", "(", "self", ",", "DataSourceBase", ".",...
Save :attr:`data`, :attr:`param_file`, original :attr:`data_reader` and UTC modification time as keys in JSON file. If data is edited then it should be saved using this method. Non-JSON data files are also saved using this method. :param save_name: Name to save JSON file as, ".json" is ...
[ "Save", ":", "attr", ":", "data", ":", "attr", ":", "param_file", "original", ":", "attr", ":", "data_reader", "and", "UTC", "modification", "time", "as", "keys", "in", "JSON", "file", ".", "If", "data", "is", "edited", "then", "it", "should", "be", "s...
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_sources.py#L260-L286
BreakingBytes/simkit
simkit/core/data_sources.py
DataSource.edit
def edit(self, edits, data_reg): """ Edit data in :class:`Data_Source`. Sets :attr:`issaved` to ``False``. """ data_reg.update(edits) self._is_saved = False
python
def edit(self, edits, data_reg): """ Edit data in :class:`Data_Source`. Sets :attr:`issaved` to ``False``. """ data_reg.update(edits) self._is_saved = False
[ "def", "edit", "(", "self", ",", "edits", ",", "data_reg", ")", ":", "data_reg", ".", "update", "(", "edits", ")", "self", ".", "_is_saved", "=", "False" ]
Edit data in :class:`Data_Source`. Sets :attr:`issaved` to ``False``.
[ "Edit", "data", "in", ":", "class", ":", "Data_Source", ".", "Sets", ":", "attr", ":", "issaved", "to", "False", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_sources.py#L288-L293
guaix-ucm/pyemir
emirdrp/tools/list_slitlets_from_string.py
list_slitlets_from_string
def list_slitlets_from_string(s, islitlet_min, islitlet_max): """Return list of slitlets from string specification. Parameters ---------- s : string String defining the slitlets. The slitlets must be specify as a set of n1[,n2[,step]] tuples. If only n1 is provided, the slitlet ...
python
def list_slitlets_from_string(s, islitlet_min, islitlet_max): """Return list of slitlets from string specification. Parameters ---------- s : string String defining the slitlets. The slitlets must be specify as a set of n1[,n2[,step]] tuples. If only n1 is provided, the slitlet ...
[ "def", "list_slitlets_from_string", "(", "s", ",", "islitlet_min", ",", "islitlet_max", ")", ":", "# protection", "if", "not", "isinstance", "(", "s", ",", "str", ")", ":", "print", "(", "'type(s): '", ",", "type", "(", "s", ")", ")", "print", "(", "'ERR...
Return list of slitlets from string specification. Parameters ---------- s : string String defining the slitlets. The slitlets must be specify as a set of n1[,n2[,step]] tuples. If only n1 is provided, the slitlet number n1 is considered. When n1 and n2 are given but step is...
[ "Return", "list", "of", "slitlets", "from", "string", "specification", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/list_slitlets_from_string.py#L26-L99
Jaymon/prom
prom/query.py
Query.ref
def ref(self, orm_classpath, cls_pk=None): """ takes a classpath to allow query-ing from another Orm class the reason why it takes string paths is to avoid infinite recursion import problems because an orm class from module A might have a ref from module B and sometimes it is h...
python
def ref(self, orm_classpath, cls_pk=None): """ takes a classpath to allow query-ing from another Orm class the reason why it takes string paths is to avoid infinite recursion import problems because an orm class from module A might have a ref from module B and sometimes it is h...
[ "def", "ref", "(", "self", ",", "orm_classpath", ",", "cls_pk", "=", "None", ")", ":", "# split orm from module path", "orm_module", ",", "orm_class", "=", "get_objects", "(", "orm_classpath", ")", "# if orm_classpath.startswith(\".\"):", "# # we handl...
takes a classpath to allow query-ing from another Orm class the reason why it takes string paths is to avoid infinite recursion import problems because an orm class from module A might have a ref from module B and sometimes it is handy to have module B be able to get the objects from m...
[ "takes", "a", "classpath", "to", "allow", "query", "-", "ing", "from", "another", "Orm", "class" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L638-L711
Jaymon/prom
prom/query.py
Query.unique_field
def unique_field(self, field_name): """set a unique field to be selected, this is automatically called when you do unique_FIELDNAME(...)""" self.fields_set.options["unique"] = True return self.select_field(field_name)
python
def unique_field(self, field_name): """set a unique field to be selected, this is automatically called when you do unique_FIELDNAME(...)""" self.fields_set.options["unique"] = True return self.select_field(field_name)
[ "def", "unique_field", "(", "self", ",", "field_name", ")", ":", "self", ".", "fields_set", ".", "options", "[", "\"unique\"", "]", "=", "True", "return", "self", ".", "select_field", "(", "field_name", ")" ]
set a unique field to be selected, this is automatically called when you do unique_FIELDNAME(...)
[ "set", "a", "unique", "field", "to", "be", "selected", "this", "is", "automatically", "called", "when", "you", "do", "unique_FIELDNAME", "(", "...", ")" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L721-L724
Jaymon/prom
prom/query.py
Query.select_fields
def select_fields(self, *fields): """set multiple fields to be selected""" if fields: if not isinstance(fields[0], basestring): fields = list(fields[0]) + list(fields)[1:] for field_name in fields: field_name = self._normalize_field_name(field_name) ...
python
def select_fields(self, *fields): """set multiple fields to be selected""" if fields: if not isinstance(fields[0], basestring): fields = list(fields[0]) + list(fields)[1:] for field_name in fields: field_name = self._normalize_field_name(field_name) ...
[ "def", "select_fields", "(", "self", ",", "*", "fields", ")", ":", "if", "fields", ":", "if", "not", "isinstance", "(", "fields", "[", "0", "]", ",", "basestring", ")", ":", "fields", "=", "list", "(", "fields", "[", "0", "]", ")", "+", "list", "...
set multiple fields to be selected
[ "set", "multiple", "fields", "to", "be", "selected" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L737-L746
Jaymon/prom
prom/query.py
Query.set_field
def set_field(self, field_name, field_val=None): """ set a field into .fields attribute n insert/update queries, these are the fields that will be inserted/updated into the db """ field_name = self._normalize_field_name(field_name) self.fields_set.append(field_name, [fie...
python
def set_field(self, field_name, field_val=None): """ set a field into .fields attribute n insert/update queries, these are the fields that will be inserted/updated into the db """ field_name = self._normalize_field_name(field_name) self.fields_set.append(field_name, [fie...
[ "def", "set_field", "(", "self", ",", "field_name", ",", "field_val", "=", "None", ")", ":", "field_name", "=", "self", ".", "_normalize_field_name", "(", "field_name", ")", "self", ".", "fields_set", ".", "append", "(", "field_name", ",", "[", "field_name",...
set a field into .fields attribute n insert/update queries, these are the fields that will be inserted/updated into the db
[ "set", "a", "field", "into", ".", "fields", "attribute" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L748-L756
Jaymon/prom
prom/query.py
Query.set_fields
def set_fields(self, fields=None, *fields_args, **fields_kwargs): """ completely replaces the current .fields with fields and fields_kwargs combined """ if fields_args: fields = [fields] fields.extend(fields_args) for field_name in fields: ...
python
def set_fields(self, fields=None, *fields_args, **fields_kwargs): """ completely replaces the current .fields with fields and fields_kwargs combined """ if fields_args: fields = [fields] fields.extend(fields_args) for field_name in fields: ...
[ "def", "set_fields", "(", "self", ",", "fields", "=", "None", ",", "*", "fields_args", ",", "*", "*", "fields_kwargs", ")", ":", "if", "fields_args", ":", "fields", "=", "[", "fields", "]", "fields", ".", "extend", "(", "fields_args", ")", "for", "fiel...
completely replaces the current .fields with fields and fields_kwargs combined
[ "completely", "replaces", "the", "current", ".", "fields", "with", "fields", "and", "fields_kwargs", "combined" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L762-L786
Jaymon/prom
prom/query.py
Query.in_field
def in_field(self, field_name, *field_vals, **field_kwargs): """ field_vals -- list -- a list of field_val values """ field_name = self._normalize_field_name(field_name) fv = make_list(field_vals[0]) if field_vals else None if field_kwargs: for k in field_kwar...
python
def in_field(self, field_name, *field_vals, **field_kwargs): """ field_vals -- list -- a list of field_val values """ field_name = self._normalize_field_name(field_name) fv = make_list(field_vals[0]) if field_vals else None if field_kwargs: for k in field_kwar...
[ "def", "in_field", "(", "self", ",", "field_name", ",", "*", "field_vals", ",", "*", "*", "field_kwargs", ")", ":", "field_name", "=", "self", ".", "_normalize_field_name", "(", "field_name", ")", "fv", "=", "make_list", "(", "field_vals", "[", "0", "]", ...
field_vals -- list -- a list of field_val values
[ "field_vals", "--", "list", "--", "a", "list", "of", "field_val", "values" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L829-L846
Jaymon/prom
prom/query.py
Query.nlike_field
def nlike_field(self, field_name, *field_val, **field_kwargs): """Perform a field_name NOT LIKE field_val query :param field_name: string, the field we are filtering on :param field_val: string, the like query: %val, %val%, val% :returns: self, for fluid interface """ if...
python
def nlike_field(self, field_name, *field_val, **field_kwargs): """Perform a field_name NOT LIKE field_val query :param field_name: string, the field we are filtering on :param field_val: string, the like query: %val, %val%, val% :returns: self, for fluid interface """ if...
[ "def", "nlike_field", "(", "self", ",", "field_name", ",", "*", "field_val", ",", "*", "*", "field_kwargs", ")", ":", "if", "not", "field_val", ":", "raise", "ValueError", "(", "\"Cannot NOT LIKE nothing\"", ")", "field_name", "=", "self", ".", "_normalize_fie...
Perform a field_name NOT LIKE field_val query :param field_name: string, the field we are filtering on :param field_val: string, the like query: %val, %val%, val% :returns: self, for fluid interface
[ "Perform", "a", "field_name", "NOT", "LIKE", "field_val", "query" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L890-L902
Jaymon/prom
prom/query.py
Query.sort_field
def sort_field(self, field_name, direction, field_vals=None): """ sort this query by field_name in directrion field_name -- string -- the field to sort on direction -- integer -- negative for DESC, positive for ASC field_vals -- list -- the order the rows should be returned in ...
python
def sort_field(self, field_name, direction, field_vals=None): """ sort this query by field_name in directrion field_name -- string -- the field to sort on direction -- integer -- negative for DESC, positive for ASC field_vals -- list -- the order the rows should be returned in ...
[ "def", "sort_field", "(", "self", ",", "field_name", ",", "direction", ",", "field_vals", "=", "None", ")", ":", "field_name", "=", "self", ".", "_normalize_field_name", "(", "field_name", ")", "if", "direction", ">", "0", ":", "direction", "=", "1", "elif...
sort this query by field_name in directrion field_name -- string -- the field to sort on direction -- integer -- negative for DESC, positive for ASC field_vals -- list -- the order the rows should be returned in
[ "sort", "this", "query", "by", "field_name", "in", "directrion" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L904-L921
Jaymon/prom
prom/query.py
Query.get
def get(self, limit=None, page=None): """ get results from the db return -- Iterator() """ has_more = False self.bounds.paginate = True limit_paginate, offset = self.bounds.get(limit, page) self.default_val = [] results = self._query('get') ...
python
def get(self, limit=None, page=None): """ get results from the db return -- Iterator() """ has_more = False self.bounds.paginate = True limit_paginate, offset = self.bounds.get(limit, page) self.default_val = [] results = self._query('get') ...
[ "def", "get", "(", "self", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "has_more", "=", "False", "self", ".", "bounds", ".", "paginate", "=", "True", "limit_paginate", ",", "offset", "=", "self", ".", "bounds", ".", "get", "(", "...
get results from the db return -- Iterator()
[ "get", "results", "from", "the", "db" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1013-L1032
Jaymon/prom
prom/query.py
Query.get_one
def get_one(self): """get one row from the db""" self.default_val = None o = self.default_val d = self._query('get_one') if d: o = self.orm_class(d, hydrate=True) return o
python
def get_one(self): """get one row from the db""" self.default_val = None o = self.default_val d = self._query('get_one') if d: o = self.orm_class(d, hydrate=True) return o
[ "def", "get_one", "(", "self", ")", ":", "self", ".", "default_val", "=", "None", "o", "=", "self", ".", "default_val", "d", "=", "self", ".", "_query", "(", "'get_one'", ")", "if", "d", ":", "o", "=", "self", ".", "orm_class", "(", "d", ",", "hy...
get one row from the db
[ "get", "one", "row", "from", "the", "db" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1048-L1055
Jaymon/prom
prom/query.py
Query.values
def values(self, limit=None, page=None): """ convenience method to get just the values from the query (same as get().values()) if you want to get all values, you can use: self.all().values() """ return self.get(limit=limit, page=page).values()
python
def values(self, limit=None, page=None): """ convenience method to get just the values from the query (same as get().values()) if you want to get all values, you can use: self.all().values() """ return self.get(limit=limit, page=page).values()
[ "def", "values", "(", "self", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "return", "self", ".", "get", "(", "limit", "=", "limit", ",", "page", "=", "page", ")", ".", "values", "(", ")" ]
convenience method to get just the values from the query (same as get().values()) if you want to get all values, you can use: self.all().values()
[ "convenience", "method", "to", "get", "just", "the", "values", "from", "the", "query", "(", "same", "as", "get", "()", ".", "values", "()", ")" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1057-L1063
Jaymon/prom
prom/query.py
Query.value
def value(self): """convenience method to just get one value or tuple of values for the query""" field_vals = None field_names = self.fields_select.names() fcount = len(field_names) if fcount: d = self._query('get_one') if d: field_vals = [...
python
def value(self): """convenience method to just get one value or tuple of values for the query""" field_vals = None field_names = self.fields_select.names() fcount = len(field_names) if fcount: d = self._query('get_one') if d: field_vals = [...
[ "def", "value", "(", "self", ")", ":", "field_vals", "=", "None", "field_names", "=", "self", ".", "fields_select", ".", "names", "(", ")", "fcount", "=", "len", "(", "field_names", ")", "if", "fcount", ":", "d", "=", "self", ".", "_query", "(", "'ge...
convenience method to just get one value or tuple of values for the query
[ "convenience", "method", "to", "just", "get", "one", "value", "or", "tuple", "of", "values", "for", "the", "query" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1065-L1080
Jaymon/prom
prom/query.py
Query.pks
def pks(self, limit=None, page=None): """convenience method for setting select_pk().values() since this is so common""" self.fields_set.reset() return self.select_pk().values(limit, page)
python
def pks(self, limit=None, page=None): """convenience method for setting select_pk().values() since this is so common""" self.fields_set.reset() return self.select_pk().values(limit, page)
[ "def", "pks", "(", "self", ",", "limit", "=", "None", ",", "page", "=", "None", ")", ":", "self", ".", "fields_set", ".", "reset", "(", ")", "return", "self", ".", "select_pk", "(", ")", ".", "values", "(", "limit", ",", "page", ")" ]
convenience method for setting select_pk().values() since this is so common
[ "convenience", "method", "for", "setting", "select_pk", "()", ".", "values", "()", "since", "this", "is", "so", "common" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1082-L1085
Jaymon/prom
prom/query.py
Query.get_pks
def get_pks(self, field_vals): """convenience method for running in__id([...]).get() since this is so common""" field_name = self.schema.pk.name return self.in_field(field_name, field_vals).get()
python
def get_pks(self, field_vals): """convenience method for running in__id([...]).get() since this is so common""" field_name = self.schema.pk.name return self.in_field(field_name, field_vals).get()
[ "def", "get_pks", "(", "self", ",", "field_vals", ")", ":", "field_name", "=", "self", ".", "schema", ".", "pk", ".", "name", "return", "self", ".", "in_field", "(", "field_name", ",", "field_vals", ")", ".", "get", "(", ")" ]
convenience method for running in__id([...]).get() since this is so common
[ "convenience", "method", "for", "running", "in__id", "(", "[", "...", "]", ")", ".", "get", "()", "since", "this", "is", "so", "common" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1092-L1095
Jaymon/prom
prom/query.py
Query.get_pk
def get_pk(self, field_val): """convenience method for running is_pk(_id).get_one() since this is so common""" field_name = self.schema.pk.name return self.is_field(field_name, field_val).get_one()
python
def get_pk(self, field_val): """convenience method for running is_pk(_id).get_one() since this is so common""" field_name = self.schema.pk.name return self.is_field(field_name, field_val).get_one()
[ "def", "get_pk", "(", "self", ",", "field_val", ")", ":", "field_name", "=", "self", ".", "schema", ".", "pk", ".", "name", "return", "self", ".", "is_field", "(", "field_name", ",", "field_val", ")", ".", "get_one", "(", ")" ]
convenience method for running is_pk(_id).get_one() since this is so common
[ "convenience", "method", "for", "running", "is_pk", "(", "_id", ")", ".", "get_one", "()", "since", "this", "is", "so", "common" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1097-L1100
Jaymon/prom
prom/query.py
Query.count
def count(self): """return the count of the criteria""" # count queries shouldn't care about sorting fields_sort = self.fields_sort self.fields_sort = self.fields_sort_class() self.default_val = 0 ret = self._query('count') # restore previous values now that co...
python
def count(self): """return the count of the criteria""" # count queries shouldn't care about sorting fields_sort = self.fields_sort self.fields_sort = self.fields_sort_class() self.default_val = 0 ret = self._query('count') # restore previous values now that co...
[ "def", "count", "(", "self", ")", ":", "# count queries shouldn't care about sorting", "fields_sort", "=", "self", ".", "fields_sort", "self", ".", "fields_sort", "=", "self", ".", "fields_sort_class", "(", ")", "self", ".", "default_val", "=", "0", "ret", "=", ...
return the count of the criteria
[ "return", "the", "count", "of", "the", "criteria" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1110-L1123
Jaymon/prom
prom/query.py
Query.insert
def insert(self): """persist the .fields""" self.default_val = 0 #fields = self.fields #fields = self.orm_class.depart(self.fields, is_update=False) #self.set_fields(fields) return self.interface.insert( self.schema, self.fields ) ...
python
def insert(self): """persist the .fields""" self.default_val = 0 #fields = self.fields #fields = self.orm_class.depart(self.fields, is_update=False) #self.set_fields(fields) return self.interface.insert( self.schema, self.fields ) ...
[ "def", "insert", "(", "self", ")", ":", "self", ".", "default_val", "=", "0", "#fields = self.fields", "#fields = self.orm_class.depart(self.fields, is_update=False)", "#self.set_fields(fields)", "return", "self", ".", "interface", ".", "insert", "(", "self", ".", "sche...
persist the .fields
[ "persist", "the", ".", "fields" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1130-L1141
Jaymon/prom
prom/query.py
Query.update
def update(self): """persist the .fields using .fields_where""" self.default_val = 0 #fields = self.fields #fields = self.orm_class.depart(self.fields, is_update=True) #self.set_fields(fields) return self.interface.update( self.schema, self.fields,...
python
def update(self): """persist the .fields using .fields_where""" self.default_val = 0 #fields = self.fields #fields = self.orm_class.depart(self.fields, is_update=True) #self.set_fields(fields) return self.interface.update( self.schema, self.fields,...
[ "def", "update", "(", "self", ")", ":", "self", ".", "default_val", "=", "0", "#fields = self.fields", "#fields = self.orm_class.depart(self.fields, is_update=True)", "#self.set_fields(fields)", "return", "self", ".", "interface", ".", "update", "(", "self", ".", "schem...
persist the .fields using .fields_where
[ "persist", "the", ".", "fields", "using", ".", "fields_where" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1143-L1153
Jaymon/prom
prom/query.py
Query.raw
def raw(self, query_str, *query_args, **query_options): """ use the interface.query() method to pass in your own raw query without any processing NOTE -- This will allow you to make any raw query and will usually return raw results, it won't wrap those results in a prom.Orm iter...
python
def raw(self, query_str, *query_args, **query_options): """ use the interface.query() method to pass in your own raw query without any processing NOTE -- This will allow you to make any raw query and will usually return raw results, it won't wrap those results in a prom.Orm iter...
[ "def", "raw", "(", "self", ",", "query_str", ",", "*", "query_args", ",", "*", "*", "query_options", ")", ":", "i", "=", "self", ".", "interface", "return", "i", ".", "query", "(", "query_str", ",", "*", "query_args", ",", "*", "*", "query_options", ...
use the interface.query() method to pass in your own raw query without any processing NOTE -- This will allow you to make any raw query and will usually return raw results, it won't wrap those results in a prom.Orm iterator instance like other methods like .all() and .get() que...
[ "use", "the", "interface", ".", "query", "()", "method", "to", "pass", "in", "your", "own", "raw", "query", "without", "any", "processing" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1161-L1176
Jaymon/prom
prom/query.py
Query.reduce
def reduce(self, target_map, target_reduce, threads=0): """map/reduce this query among a bunch of processes :param target_map: callable, this function will be called once for each row this query pulls out of the db, if you want something about the row to be seen by the target_r...
python
def reduce(self, target_map, target_reduce, threads=0): """map/reduce this query among a bunch of processes :param target_map: callable, this function will be called once for each row this query pulls out of the db, if you want something about the row to be seen by the target_r...
[ "def", "reduce", "(", "self", ",", "target_map", ",", "target_reduce", ",", "threads", "=", "0", ")", ":", "if", "not", "threads", ":", "threads", "=", "multiprocessing", ".", "cpu_count", "(", ")", "# we subtract one for the main process", "map_threads", "=", ...
map/reduce this query among a bunch of processes :param target_map: callable, this function will be called once for each row this query pulls out of the db, if you want something about the row to be seen by the target_reduce function return that value from this function and...
[ "map", "/", "reduce", "this", "query", "among", "a", "bunch", "of", "processes" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1178-L1245
Jaymon/prom
prom/query.py
BaseCacheQuery.cache_key
def cache_key(self, method_name): """decides if this query is cacheable, returns a key if it is, otherwise empty""" key = "" method = getattr(self, "cache_key_{}".format(method_name), None) if method: key = method() return key
python
def cache_key(self, method_name): """decides if this query is cacheable, returns a key if it is, otherwise empty""" key = "" method = getattr(self, "cache_key_{}".format(method_name), None) if method: key = method() return key
[ "def", "cache_key", "(", "self", ",", "method_name", ")", ":", "key", "=", "\"\"", "method", "=", "getattr", "(", "self", ",", "\"cache_key_{}\"", ".", "format", "(", "method_name", ")", ",", "None", ")", "if", "method", ":", "key", "=", "method", "(",...
decides if this query is cacheable, returns a key if it is, otherwise empty
[ "decides", "if", "this", "query", "is", "cacheable", "returns", "a", "key", "if", "it", "is", "otherwise", "empty" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1356-L1363
Jaymon/prom
prom/query.py
CacheNamespace.ttl
def ttl(self): """how long you should cache results for cacheable queries""" ret = 3600 cn = self.get_process() if "ttl" in cn: ret = cn["ttl"] return ret
python
def ttl(self): """how long you should cache results for cacheable queries""" ret = 3600 cn = self.get_process() if "ttl" in cn: ret = cn["ttl"] return ret
[ "def", "ttl", "(", "self", ")", ":", "ret", "=", "3600", "cn", "=", "self", ".", "get_process", "(", ")", "if", "\"ttl\"", "in", "cn", ":", "ret", "=", "cn", "[", "\"ttl\"", "]", "return", "ret" ]
how long you should cache results for cacheable queries
[ "how", "long", "you", "should", "cache", "results", "for", "cacheable", "queries" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/query.py#L1440-L1446
thombashi/tabledata
tabledata/normalizer.py
AbstractTableDataNormalizer.normalize
def normalize(self): """ :return: Sanitized table data. :rtype: tabledata.TableData """ logger.debug("normalize: {}".format(type(self).__name__)) normalize_headers = self._normalize_headers() return TableData( self.__normalize_table_name(), ...
python
def normalize(self): """ :return: Sanitized table data. :rtype: tabledata.TableData """ logger.debug("normalize: {}".format(type(self).__name__)) normalize_headers = self._normalize_headers() return TableData( self.__normalize_table_name(), ...
[ "def", "normalize", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"normalize: {}\"", ".", "format", "(", "type", "(", "self", ")", ".", "__name__", ")", ")", "normalize_headers", "=", "self", ".", "_normalize_headers", "(", ")", "return", "TableDat...
:return: Sanitized table data. :rtype: tabledata.TableData
[ ":", "return", ":", "Sanitized", "table", "data", ".", ":", "rtype", ":", "tabledata", ".", "TableData" ]
train
https://github.com/thombashi/tabledata/blob/03d623be30fc62381f1b7fb2aa0e17a0e26ad473/tabledata/normalizer.py#L51-L67
BreakingBytes/simkit
simkit/core/data_readers.py
_apply_units_to_numpy_data_readers
def _apply_units_to_numpy_data_readers(parameters, data): """ Apply units to data originally loaded by :class:`NumPyLoadTxtReader` or :class:`NumPyGenFromTxtReader`. :param parameters: Dictionary of data source parameters read from JSON file. :type parameters: dict :param data: Dictiona...
python
def _apply_units_to_numpy_data_readers(parameters, data): """ Apply units to data originally loaded by :class:`NumPyLoadTxtReader` or :class:`NumPyGenFromTxtReader`. :param parameters: Dictionary of data source parameters read from JSON file. :type parameters: dict :param data: Dictiona...
[ "def", "_apply_units_to_numpy_data_readers", "(", "parameters", ",", "data", ")", ":", "# apply header units", "header_param", "=", "parameters", ".", "get", "(", "'header'", ")", "# default is None", "# check for headers", "if", "header_param", ":", "fields", "=", "h...
Apply units to data originally loaded by :class:`NumPyLoadTxtReader` or :class:`NumPyGenFromTxtReader`. :param parameters: Dictionary of data source parameters read from JSON file. :type parameters: dict :param data: Dictionary of data read
[ "Apply", "units", "to", "data", "originally", "loaded", "by", ":", "class", ":", "NumPyLoadTxtReader", "or", ":", "class", ":", "NumPyGenFromTxtReader", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L506-L533
BreakingBytes/simkit
simkit/core/data_readers.py
_read_header
def _read_header(f, header_param): """ Read and parse data from 1st line of a file. :param f: :func:`file` or :class:`~StringIO.StringIO` object from which to read 1st line. :type f: file :param header_param: Parameters used to parse the data from the header. Contains "delimiter" an...
python
def _read_header(f, header_param): """ Read and parse data from 1st line of a file. :param f: :func:`file` or :class:`~StringIO.StringIO` object from which to read 1st line. :type f: file :param header_param: Parameters used to parse the data from the header. Contains "delimiter" an...
[ "def", "_read_header", "(", "f", ",", "header_param", ")", ":", "# default delimiter is a comma, can't be None", "header_delim", "=", "str", "(", "header_param", ".", "get", "(", "'delimiter'", ",", "','", ")", ")", "# don't allow unnamed fields", "if", "'fields'", ...
Read and parse data from 1st line of a file. :param f: :func:`file` or :class:`~StringIO.StringIO` object from which to read 1st line. :type f: file :param header_param: Parameters used to parse the data from the header. Contains "delimiter" and "fields". :type header_param: dict :r...
[ "Read", "and", "parse", "data", "from", "1st", "line", "of", "a", "file", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L536-L605
BreakingBytes/simkit
simkit/core/data_readers.py
_apply_units
def _apply_units(data_data, data_units, fname): """ Apply units to data. :param data_data: NumPy structured array with data from fname. :type data_data: :class:`numpy.ndarray` :param data_units: Units of fields in data_data. :type data_units: dict :param fname: Name of file from which data_...
python
def _apply_units(data_data, data_units, fname): """ Apply units to data. :param data_data: NumPy structured array with data from fname. :type data_data: :class:`numpy.ndarray` :param data_units: Units of fields in data_data. :type data_units: dict :param fname: Name of file from which data_...
[ "def", "_apply_units", "(", "data_data", ",", "data_units", ",", "fname", ")", ":", "data_names", "=", "data_data", ".", "dtype", ".", "names", "# raise error if NumPy data doesn't have names", "if", "not", "data_names", ":", "raise", "UnnamedDataError", "(", "fname...
Apply units to data. :param data_data: NumPy structured array with data from fname. :type data_data: :class:`numpy.ndarray` :param data_units: Units of fields in data_data. :type data_units: dict :param fname: Name of file from which data_data was read. :type fname: str :returns: Dictionary...
[ "Apply", "units", "to", "data", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L608-L638
BreakingBytes/simkit
simkit/core/data_readers.py
_utf8_list_to_ascii_tuple
def _utf8_list_to_ascii_tuple(utf8_list): """ Convert unicode strings in a list of lists to ascii in a list of tuples. :param utf8_list: A nested list of unicode strings. :type utf8_list: list """ for n, utf8 in enumerate(utf8_list): utf8_list[n][0] = str(utf8[0]) utf8_list[n][1...
python
def _utf8_list_to_ascii_tuple(utf8_list): """ Convert unicode strings in a list of lists to ascii in a list of tuples. :param utf8_list: A nested list of unicode strings. :type utf8_list: list """ for n, utf8 in enumerate(utf8_list): utf8_list[n][0] = str(utf8[0]) utf8_list[n][1...
[ "def", "_utf8_list_to_ascii_tuple", "(", "utf8_list", ")", ":", "for", "n", ",", "utf8", "in", "enumerate", "(", "utf8_list", ")", ":", "utf8_list", "[", "n", "]", "[", "0", "]", "=", "str", "(", "utf8", "[", "0", "]", ")", "utf8_list", "[", "n", "...
Convert unicode strings in a list of lists to ascii in a list of tuples. :param utf8_list: A nested list of unicode strings. :type utf8_list: list
[ "Convert", "unicode", "strings", "in", "a", "list", "of", "lists", "to", "ascii", "in", "a", "list", "of", "tuples", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L641-L651
BreakingBytes/simkit
simkit/core/data_readers.py
JSONReader.load_data
def load_data(self, filename, *args, **kwargs): """ Load JSON data. :param filename: name of JSON file with data :type filename: str :return: data :rtype: dict """ # append .json extension if needed if not filename.endswith('.json'): f...
python
def load_data(self, filename, *args, **kwargs): """ Load JSON data. :param filename: name of JSON file with data :type filename: str :return: data :rtype: dict """ # append .json extension if needed if not filename.endswith('.json'): f...
[ "def", "load_data", "(", "self", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# append .json extension if needed", "if", "not", "filename", ".", "endswith", "(", "'.json'", ")", ":", "filename", "+=", "'.json'", "# append \"json\" to ...
Load JSON data. :param filename: name of JSON file with data :type filename: str :return: data :rtype: dict
[ "Load", "JSON", "data", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L130-L163
BreakingBytes/simkit
simkit/core/data_readers.py
JSONReader.apply_units_to_cache
def apply_units_to_cache(self, data): """ Apply units to data read using :class:`JSONReader`. :param data: cached data :return: data with units applied :rtype: :class:`~pint.unit.Quantity` """ for k, val in self.parameters.iteritems(): if 'units' in v...
python
def apply_units_to_cache(self, data): """ Apply units to data read using :class:`JSONReader`. :param data: cached data :return: data with units applied :rtype: :class:`~pint.unit.Quantity` """ for k, val in self.parameters.iteritems(): if 'units' in v...
[ "def", "apply_units_to_cache", "(", "self", ",", "data", ")", ":", "for", "k", ",", "val", "in", "self", ".", "parameters", ".", "iteritems", "(", ")", ":", "if", "'units'", "in", "val", ":", "data", "[", "k", "]", "=", "Q_", "(", "data", "[", "k...
Apply units to data read using :class:`JSONReader`. :param data: cached data :return: data with units applied :rtype: :class:`~pint.unit.Quantity`
[ "Apply", "units", "to", "data", "read", "using", ":", "class", ":", "JSONReader", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L165-L176
BreakingBytes/simkit
simkit/core/data_readers.py
XLRDReader.load_data
def load_data(self, filename, *args, **kwargs): """ Load parameters from Excel spreadsheet. :param filename: Name of Excel workbook with data. :type filename: str :returns: Data read from Excel workbook. :rtype: dict """ # workbook read from file ...
python
def load_data(self, filename, *args, **kwargs): """ Load parameters from Excel spreadsheet. :param filename: Name of Excel workbook with data. :type filename: str :returns: Data read from Excel workbook. :rtype: dict """ # workbook read from file ...
[ "def", "load_data", "(", "self", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# workbook read from file", "workbook", "=", "open_workbook", "(", "filename", ",", "verbosity", "=", "True", ")", "data", "=", "{", "}", "# an empty di...
Load parameters from Excel spreadsheet. :param filename: Name of Excel workbook with data. :type filename: str :returns: Data read from Excel workbook. :rtype: dict
[ "Load", "parameters", "from", "Excel", "spreadsheet", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L243-L310
BreakingBytes/simkit
simkit/core/data_readers.py
XLRDReader.apply_units_to_cache
def apply_units_to_cache(self, data): """ Apply units to cached data read using :class:`JSONReader`. :param data: Cached data. :type data: dict :return: data with units """ # iterate through sheets in parameters # iterate through the parameters on each sh...
python
def apply_units_to_cache(self, data): """ Apply units to cached data read using :class:`JSONReader`. :param data: Cached data. :type data: dict :return: data with units """ # iterate through sheets in parameters # iterate through the parameters on each sh...
[ "def", "apply_units_to_cache", "(", "self", ",", "data", ")", ":", "# iterate through sheets in parameters", "# iterate through the parameters on each sheet", "for", "param", ",", "pval", "in", "self", ".", "parameters", ".", "iteritems", "(", ")", ":", "# try to apply ...
Apply units to cached data read using :class:`JSONReader`. :param data: Cached data. :type data: dict :return: data with units
[ "Apply", "units", "to", "cached", "data", "read", "using", ":", "class", ":", "JSONReader", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L312-L328
BreakingBytes/simkit
simkit/core/data_readers.py
NumPyLoadTxtReader.load_data
def load_data(self, filename, *args, **kwargs): """ load data from text file. :param filename: name of text file to read :type filename: str :returns: data read from file using :func:`numpy.loadtxt` :rtype: dict """ # header keys header_param = se...
python
def load_data(self, filename, *args, **kwargs): """ load data from text file. :param filename: name of text file to read :type filename: str :returns: data read from file using :func:`numpy.loadtxt` :rtype: dict """ # header keys header_param = se...
[ "def", "load_data", "(", "self", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# header keys", "header_param", "=", "self", ".", "parameters", ".", "get", "(", "'header'", ")", "# default is None", "# data keys", "data_param", "=", ...
load data from text file. :param filename: name of text file to read :type filename: str :returns: data read from file using :func:`numpy.loadtxt` :rtype: dict
[ "load", "data", "from", "text", "file", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L371-L402
BreakingBytes/simkit
simkit/core/data_readers.py
NumPyGenFromTxtReader.load_data
def load_data(self, filename, *args, **kwargs): """ load data from text file. :param filename: name of file to read :type filename: str :returns: data read from file using :func:`numpy.genfromtxt` :rtype: dict :raises: :exc:`~simkit.core.exceptions.UnnamedDataErr...
python
def load_data(self, filename, *args, **kwargs): """ load data from text file. :param filename: name of file to read :type filename: str :returns: data read from file using :func:`numpy.genfromtxt` :rtype: dict :raises: :exc:`~simkit.core.exceptions.UnnamedDataErr...
[ "def", "load_data", "(", "self", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# header keys", "header_param", "=", "self", ".", "parameters", ".", "get", "(", "'header'", ")", "# default is None", "# data keys", "data_param", "=", ...
load data from text file. :param filename: name of file to read :type filename: str :returns: data read from file using :func:`numpy.genfromtxt` :rtype: dict :raises: :exc:`~simkit.core.exceptions.UnnamedDataError`
[ "load", "data", "from", "text", "file", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L455-L497
BreakingBytes/simkit
simkit/core/data_readers.py
ParameterizedXLS.load_data
def load_data(self, filename, *args, **kwargs): """ Load parameterized data from different sheets. """ # load parameterized data data = super(ParameterizedXLS, self).load_data(filename) # add parameter to data parameter_name = self.parameterization['parameter']['n...
python
def load_data(self, filename, *args, **kwargs): """ Load parameterized data from different sheets. """ # load parameterized data data = super(ParameterizedXLS, self).load_data(filename) # add parameter to data parameter_name = self.parameterization['parameter']['n...
[ "def", "load_data", "(", "self", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# load parameterized data", "data", "=", "super", "(", "ParameterizedXLS", ",", "self", ")", ".", "load_data", "(", "filename", ")", "# add parameter to d...
Load parameterized data from different sheets.
[ "Load", "parameterized", "data", "from", "different", "sheets", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L674-L696
BreakingBytes/simkit
simkit/core/data_readers.py
ParameterizedXLS.apply_units_to_cache
def apply_units_to_cache(self, data): """ Apply units to :class:`ParameterizedXLS` data reader. """ # parameter parameter_name = self.parameters['parameter']['name'] parameter_units = str(self.parameters['parameter']['units']) data[parameter_name] *= UREG(paramete...
python
def apply_units_to_cache(self, data): """ Apply units to :class:`ParameterizedXLS` data reader. """ # parameter parameter_name = self.parameters['parameter']['name'] parameter_units = str(self.parameters['parameter']['units']) data[parameter_name] *= UREG(paramete...
[ "def", "apply_units_to_cache", "(", "self", ",", "data", ")", ":", "# parameter", "parameter_name", "=", "self", ".", "parameters", "[", "'parameter'", "]", "[", "'name'", "]", "parameter_units", "=", "str", "(", "self", ".", "parameters", "[", "'parameter'", ...
Apply units to :class:`ParameterizedXLS` data reader.
[ "Apply", "units", "to", ":", "class", ":", "ParameterizedXLS", "data", "reader", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L698-L708
BreakingBytes/simkit
simkit/core/data_readers.py
MixedTextXLS.load_data
def load_data(self, filename, *args, **kwargs): """ Load text data from different sheets. """ # load text data data = super(MixedTextXLS, self).load_data(filename) # iterate through sheets in parameters for sheet_params in self.parameters.itervalues(): ...
python
def load_data(self, filename, *args, **kwargs): """ Load text data from different sheets. """ # load text data data = super(MixedTextXLS, self).load_data(filename) # iterate through sheets in parameters for sheet_params in self.parameters.itervalues(): ...
[ "def", "load_data", "(", "self", ",", "filename", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# load text data", "data", "=", "super", "(", "MixedTextXLS", ",", "self", ")", ".", "load_data", "(", "filename", ")", "# iterate through sheets in param...
Load text data from different sheets.
[ "Load", "text", "data", "from", "different", "sheets", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/data_readers.py#L774-L805
Yelp/uwsgi_metrics
uwsgi_metrics/meter.py
Meter.mark
def mark(self, n=1): """Mark the occurrence of a given number of events.""" self.tick_if_necessary() self.count += n self.m1_rate.update(n) self.m5_rate.update(n) self.m15_rate.update(n)
python
def mark(self, n=1): """Mark the occurrence of a given number of events.""" self.tick_if_necessary() self.count += n self.m1_rate.update(n) self.m5_rate.update(n) self.m15_rate.update(n)
[ "def", "mark", "(", "self", ",", "n", "=", "1", ")", ":", "self", ".", "tick_if_necessary", "(", ")", "self", ".", "count", "+=", "n", "self", ".", "m1_rate", ".", "update", "(", "n", ")", "self", ".", "m5_rate", ".", "update", "(", "n", ")", "...
Mark the occurrence of a given number of events.
[ "Mark", "the", "occurrence", "of", "a", "given", "number", "of", "events", "." ]
train
https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/meter.py#L32-L38
BreakingBytes/simkit
simkit/core/models.py
Model._load
def _load(self, layer=None): """ Load or update all or part of :attr:`model`. :param layer: Optionally load only specified layer. :type layer: str """ # open model file for reading and convert JSON object to dictionary # read and load JSON parameter map file as "...
python
def _load(self, layer=None): """ Load or update all or part of :attr:`model`. :param layer: Optionally load only specified layer. :type layer: str """ # open model file for reading and convert JSON object to dictionary # read and load JSON parameter map file as "...
[ "def", "_load", "(", "self", ",", "layer", "=", "None", ")", ":", "# open model file for reading and convert JSON object to dictionary", "# read and load JSON parameter map file as \"parameters\"", "with", "open", "(", "self", ".", "param_file", ",", "'r'", ")", "as", "pa...
Load or update all or part of :attr:`model`. :param layer: Optionally load only specified layer. :type layer: str
[ "Load", "or", "update", "all", "or", "part", "of", ":", "attr", ":", "model", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L125-L149
BreakingBytes/simkit
simkit/core/models.py
Model._update
def _update(self, layer=None): """ Update layers in model. """ meta = getattr(self, ModelBase._meta_attr) if not layer: layers = self.layers else: # convert non-sequence to tuple layers = _listify(layer) for layer in layers: ...
python
def _update(self, layer=None): """ Update layers in model. """ meta = getattr(self, ModelBase._meta_attr) if not layer: layers = self.layers else: # convert non-sequence to tuple layers = _listify(layer) for layer in layers: ...
[ "def", "_update", "(", "self", ",", "layer", "=", "None", ")", ":", "meta", "=", "getattr", "(", "self", ",", "ModelBase", ".", "_meta_attr", ")", "if", "not", "layer", ":", "layers", "=", "self", ".", "layers", "else", ":", "# convert non-sequence to tu...
Update layers in model.
[ "Update", "layers", "in", "model", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L151-L164
BreakingBytes/simkit
simkit/core/models.py
Model._initialize
def _initialize(self): """ Initialize model and layers. """ meta = getattr(self, ModelBase._meta_attr) # read modelfile, convert JSON and load/update model if self.param_file is not None: self._load() LOGGER.debug('model:\n%r', self.model) # in...
python
def _initialize(self): """ Initialize model and layers. """ meta = getattr(self, ModelBase._meta_attr) # read modelfile, convert JSON and load/update model if self.param_file is not None: self._load() LOGGER.debug('model:\n%r', self.model) # in...
[ "def", "_initialize", "(", "self", ")", ":", "meta", "=", "getattr", "(", "self", ",", "ModelBase", ".", "_meta_attr", ")", "# read modelfile, convert JSON and load/update model", "if", "self", ".", "param_file", "is", "not", "None", ":", "self", ".", "_load", ...
Initialize model and layers.
[ "Initialize", "model", "and", "layers", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L166-L219
BreakingBytes/simkit
simkit/core/models.py
Model.load
def load(self, modelfile, layer=None): """ Load or update a model or layers in a model. :param modelfile: The name of the json file to load. :type modelfile: str :param layer: Optionally load only specified layer. :type layer: str """ # read modelfile, co...
python
def load(self, modelfile, layer=None): """ Load or update a model or layers in a model. :param modelfile: The name of the json file to load. :type modelfile: str :param layer: Optionally load only specified layer. :type layer: str """ # read modelfile, co...
[ "def", "load", "(", "self", ",", "modelfile", ",", "layer", "=", "None", ")", ":", "# read modelfile, convert JSON and load/update model", "self", ".", "param_file", "=", "modelfile", "self", ".", "_load", "(", "layer", ")", "self", ".", "_update", "(", "layer...
Load or update a model or layers in a model. :param modelfile: The name of the json file to load. :type modelfile: str :param layer: Optionally load only specified layer. :type layer: str
[ "Load", "or", "update", "a", "model", "or", "layers", "in", "a", "model", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L221-L233
BreakingBytes/simkit
simkit/core/models.py
Model.edit
def edit(self, layer, item, delete=False): """ Edit model. :param layer: Layer of model to edit :type layer: str :param item: Items to edit. :type item: dict :param delete: Flag to return :class:`~simkit.core.layers.Layer` to delete item. :typ...
python
def edit(self, layer, item, delete=False): """ Edit model. :param layer: Layer of model to edit :type layer: str :param item: Items to edit. :type item: dict :param delete: Flag to return :class:`~simkit.core.layers.Layer` to delete item. :typ...
[ "def", "edit", "(", "self", ",", "layer", ",", "item", ",", "delete", "=", "False", ")", ":", "# get layer attribute with model data", "if", "hasattr", "(", "self", ",", "layer", ")", ":", "layer_obj", "=", "getattr", "(", "self", ",", "layer", ")", "els...
Edit model. :param layer: Layer of model to edit :type layer: str :param item: Items to edit. :type item: dict :param delete: Flag to return :class:`~simkit.core.layers.Layer` to delete item. :type delete: bool
[ "Edit", "model", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L235-L264
BreakingBytes/simkit
simkit/core/models.py
Model.add
def add(self, layer, items): """ Add items in model. """ for k in items.iterkeys(): if k in self.model[layer]: raise Exception('item %s is already in layer %s' % (k, layer)) self.model[layer].update(items) # this should also update Layer.layer,...
python
def add(self, layer, items): """ Add items in model. """ for k in items.iterkeys(): if k in self.model[layer]: raise Exception('item %s is already in layer %s' % (k, layer)) self.model[layer].update(items) # this should also update Layer.layer,...
[ "def", "add", "(", "self", ",", "layer", ",", "items", ")", ":", "for", "k", "in", "items", ".", "iterkeys", "(", ")", ":", "if", "k", "in", "self", ".", "model", "[", "layer", "]", ":", "raise", "Exception", "(", "'item %s is already in layer %s'", ...
Add items in model.
[ "Add", "items", "in", "model", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L266-L278
BreakingBytes/simkit
simkit/core/models.py
Model.delete
def delete(self, layer, items): """ Delete items in model. """ # Use edit to get the layer obj containing item items = _listify(items) # make items a list if it's not layer_obj = self.edit(layer, dict.fromkeys(items), delete=True) for k in items: if k...
python
def delete(self, layer, items): """ Delete items in model. """ # Use edit to get the layer obj containing item items = _listify(items) # make items a list if it's not layer_obj = self.edit(layer, dict.fromkeys(items), delete=True) for k in items: if k...
[ "def", "delete", "(", "self", ",", "layer", ",", "items", ")", ":", "# Use edit to get the layer obj containing item", "items", "=", "_listify", "(", "items", ")", "# make items a list if it's not", "layer_obj", "=", "self", ".", "edit", "(", "layer", ",", "dict",...
Delete items in model.
[ "Delete", "items", "in", "model", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L280-L292
BreakingBytes/simkit
simkit/core/models.py
Model.save
def save(self, modelfile, layer=None): """ Save a model file. :param modelfile: The name of the json file to save. :type modelfile: str :param layer: Optionally save only specified layer. :type layer: str """ if layer: obj = {layer: self.model...
python
def save(self, modelfile, layer=None): """ Save a model file. :param modelfile: The name of the json file to save. :type modelfile: str :param layer: Optionally save only specified layer. :type layer: str """ if layer: obj = {layer: self.model...
[ "def", "save", "(", "self", ",", "modelfile", ",", "layer", "=", "None", ")", ":", "if", "layer", ":", "obj", "=", "{", "layer", ":", "self", ".", "model", "[", "layer", "]", "}", "else", ":", "obj", "=", "self", ".", "model", "with", "open", "...
Save a model file. :param modelfile: The name of the json file to save. :type modelfile: str :param layer: Optionally save only specified layer. :type layer: str
[ "Save", "a", "model", "file", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L301-L315
BreakingBytes/simkit
simkit/core/models.py
Model.command
def command(self, cmd, progress_hook=None, *args, **kwargs): """ Execute a model command. :param cmd: Name of the command. :param progress_hook: A function to which progress updates are passed. """ cmds = cmd.split(None, 1) # split commands and simulations sim_n...
python
def command(self, cmd, progress_hook=None, *args, **kwargs): """ Execute a model command. :param cmd: Name of the command. :param progress_hook: A function to which progress updates are passed. """ cmds = cmd.split(None, 1) # split commands and simulations sim_n...
[ "def", "command", "(", "self", ",", "cmd", ",", "progress_hook", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cmds", "=", "cmd", ".", "split", "(", "None", ",", "1", ")", "# split commands and simulations", "sim_names", "=", "cmds...
Execute a model command. :param cmd: Name of the command. :param progress_hook: A function to which progress updates are passed.
[ "Execute", "a", "model", "command", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/models.py#L331-L344
volafiled/python-volapi
volapi/user.py
User.login
def login(self, password): """Attempts to log in as the current user with given password""" if self.logged_in: raise RuntimeError("User already logged in!") params = {"name": self.nick, "password": password} resp = self.conn.make_api_call("login", params) if "error"...
python
def login(self, password): """Attempts to log in as the current user with given password""" if self.logged_in: raise RuntimeError("User already logged in!") params = {"name": self.nick, "password": password} resp = self.conn.make_api_call("login", params) if "error"...
[ "def", "login", "(", "self", ",", "password", ")", ":", "if", "self", ".", "logged_in", ":", "raise", "RuntimeError", "(", "\"User already logged in!\"", ")", "params", "=", "{", "\"name\"", ":", "self", ".", "nick", ",", "\"password\"", ":", "password", "...
Attempts to log in as the current user with given password
[ "Attempts", "to", "log", "in", "as", "the", "current", "user", "with", "given", "password" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L18-L34
volafiled/python-volapi
volapi/user.py
User.login_transplant
def login_transplant(self, other): """Attempts to carry over the login state from another room""" if not other.logged_in: raise ValueError("Other room is not logged in") cookie = other.session if not cookie: raise ValueError("Other room has no cookie") se...
python
def login_transplant(self, other): """Attempts to carry over the login state from another room""" if not other.logged_in: raise ValueError("Other room is not logged in") cookie = other.session if not cookie: raise ValueError("Other room has no cookie") se...
[ "def", "login_transplant", "(", "self", ",", "other", ")", ":", "if", "not", "other", ".", "logged_in", ":", "raise", "ValueError", "(", "\"Other room is not logged in\"", ")", "cookie", "=", "other", ".", "session", "if", "not", "cookie", ":", "raise", "Val...
Attempts to carry over the login state from another room
[ "Attempts", "to", "carry", "over", "the", "login", "state", "from", "another", "room" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L36-L47
volafiled/python-volapi
volapi/user.py
User.logout
def logout(self): """Logs your user out""" if not self.logged_in: raise RuntimeError("User is not logged in") if self.conn.connected: params = {"room": self.conn.room.room_id} resp = self.conn.make_api_call("logout", params) if not resp.get("succe...
python
def logout(self): """Logs your user out""" if not self.logged_in: raise RuntimeError("User is not logged in") if self.conn.connected: params = {"room": self.conn.room.room_id} resp = self.conn.make_api_call("logout", params) if not resp.get("succe...
[ "def", "logout", "(", "self", ")", ":", "if", "not", "self", ".", "logged_in", ":", "raise", "RuntimeError", "(", "\"User is not logged in\"", ")", "if", "self", ".", "conn", ".", "connected", ":", "params", "=", "{", "\"room\"", ":", "self", ".", "conn"...
Logs your user out
[ "Logs", "your", "user", "out" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L49-L64
volafiled/python-volapi
volapi/user.py
User.change_nick
def change_nick(self, new_nick): """Change the name of your user Note: Must be logged out to change nick""" if self.logged_in: raise RuntimeError("User must be logged out") self.__verify_username(new_nick) self.conn.make_call("command", self.nick, "nick", new_nick) ...
python
def change_nick(self, new_nick): """Change the name of your user Note: Must be logged out to change nick""" if self.logged_in: raise RuntimeError("User must be logged out") self.__verify_username(new_nick) self.conn.make_call("command", self.nick, "nick", new_nick) ...
[ "def", "change_nick", "(", "self", ",", "new_nick", ")", ":", "if", "self", ".", "logged_in", ":", "raise", "RuntimeError", "(", "\"User must be logged out\"", ")", "self", ".", "__verify_username", "(", "new_nick", ")", "self", ".", "conn", ".", "make_call", ...
Change the name of your user Note: Must be logged out to change nick
[ "Change", "the", "name", "of", "your", "user", "Note", ":", "Must", "be", "logged", "out", "to", "change", "nick" ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L66-L75
volafiled/python-volapi
volapi/user.py
User.register
def register(self, password): """Registers the current user with the given password.""" if len(password) < 8: raise ValueError("Password must be at least 8 characters.") params = {"name": self.nick, "password": password} resp = self.conn.make_api_call("register", params) ...
python
def register(self, password): """Registers the current user with the given password.""" if len(password) < 8: raise ValueError("Password must be at least 8 characters.") params = {"name": self.nick, "password": password} resp = self.conn.make_api_call("register", params) ...
[ "def", "register", "(", "self", ",", "password", ")", ":", "if", "len", "(", "password", ")", "<", "8", ":", "raise", "ValueError", "(", "\"Password must be at least 8 characters.\"", ")", "params", "=", "{", "\"name\"", ":", "self", ".", "nick", ",", "\"p...
Registers the current user with the given password.
[ "Registers", "the", "current", "user", "with", "the", "given", "password", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L77-L91
volafiled/python-volapi
volapi/user.py
User.__verify_username
def __verify_username(self, username): """Raises an exception if the given username is not valid.""" if len(username) > self.__max_length or len(username) < 3: raise ValueError( f"Username must be between 3 and {self.__max_length} characters." ) if any(c ...
python
def __verify_username(self, username): """Raises an exception if the given username is not valid.""" if len(username) > self.__max_length or len(username) < 3: raise ValueError( f"Username must be between 3 and {self.__max_length} characters." ) if any(c ...
[ "def", "__verify_username", "(", "self", ",", "username", ")", ":", "if", "len", "(", "username", ")", ">", "self", ".", "__max_length", "or", "len", "(", "username", ")", "<", "3", ":", "raise", "ValueError", "(", "f\"Username must be between 3 and {self.__ma...
Raises an exception if the given username is not valid.
[ "Raises", "an", "exception", "if", "the", "given", "username", "is", "not", "valid", "." ]
train
https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/user.py#L93-L101
Yelp/uwsgi_metrics
uwsgi_metrics/reservoir.py
Reservoir.update
def update(self, value, timestamp=None): """Add a value to the reservoir. :param value: the value to be added :param timestamp: the epoch timestamp of the value in seconds, defaults to the current timestamp if not specified. """ if timestamp is None: tim...
python
def update(self, value, timestamp=None): """Add a value to the reservoir. :param value: the value to be added :param timestamp: the epoch timestamp of the value in seconds, defaults to the current timestamp if not specified. """ if timestamp is None: tim...
[ "def", "update", "(", "self", ",", "value", ",", "timestamp", "=", "None", ")", ":", "if", "timestamp", "is", "None", ":", "timestamp", "=", "self", ".", "current_time_in_fractional_seconds", "(", ")", "self", ".", "rescale_if_needed", "(", ")", "priority", ...
Add a value to the reservoir. :param value: the value to be added :param timestamp: the epoch timestamp of the value in seconds, defaults to the current timestamp if not specified.
[ "Add", "a", "value", "to", "the", "reservoir", "." ]
train
https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/reservoir.py#L66-L80
Yelp/uwsgi_metrics
uwsgi_metrics/reservoir.py
Reservoir.rescale
def rescale(self, now): """ "A common feature of the above techniques—indeed, the key technique that allows us to track the decayed weights efficiently—is that they maintain counts and other quantities based on g(ti − L), and only scale by g(t − L) at query time. But while g(ti −L)/g(t−L...
python
def rescale(self, now): """ "A common feature of the above techniques—indeed, the key technique that allows us to track the decayed weights efficiently—is that they maintain counts and other quantities based on g(ti − L), and only scale by g(t − L) at query time. But while g(ti −L)/g(t−L...
[ "def", "rescale", "(", "self", ",", "now", ")", ":", "old_start_time", "=", "self", ".", "start_time", "self", ".", "start_time", "=", "self", ".", "current_time_in_fractional_seconds", "(", ")", "self", ".", "next_scale_time", "=", "now", "+", "RESCALE_THRESH...
"A common feature of the above techniques—indeed, the key technique that allows us to track the decayed weights efficiently—is that they maintain counts and other quantities based on g(ti − L), and only scale by g(t − L) at query time. But while g(ti −L)/g(t−L) is guaranteed to lie betwe...
[ "A", "common", "feature", "of", "the", "above", "techniques—indeed", "the", "key", "technique", "that", "allows", "us", "to", "track", "the", "decayed", "weights", "efficiently—is", "that", "they", "maintain", "counts", "and", "other", "quantities", "based", "on...
train
https://github.com/Yelp/uwsgi_metrics/blob/534966fd461ff711aecd1e3d4caaafdc23ac33f0/uwsgi_metrics/reservoir.py#L87-L117
Jaymon/prom
prom/utils.py
get_objects
def get_objects(classpath, calling_classpath=""): """ given a classpath like foo.bar.Baz return module foo.bar and class Baz objects .. seealso:: https://docs.python.org/2.5/whatsnew/pep-328.html https://www.python.org/dev/peps/pep-0328/ :param classpath: string, the full python cl...
python
def get_objects(classpath, calling_classpath=""): """ given a classpath like foo.bar.Baz return module foo.bar and class Baz objects .. seealso:: https://docs.python.org/2.5/whatsnew/pep-328.html https://www.python.org/dev/peps/pep-0328/ :param classpath: string, the full python cl...
[ "def", "get_objects", "(", "classpath", ",", "calling_classpath", "=", "\"\"", ")", ":", "# if classpath.startswith(\".\"):", "# rel_count = len(re.match(\"^\\.+\", classpath).group(0))", "# if calling_classpath:", "# calling_count = calling_classpath.count(...
given a classpath like foo.bar.Baz return module foo.bar and class Baz objects .. seealso:: https://docs.python.org/2.5/whatsnew/pep-328.html https://www.python.org/dev/peps/pep-0328/ :param classpath: string, the full python class path (includes modules), a classpath is something ...
[ "given", "a", "classpath", "like", "foo", ".", "bar", ".", "Baz", "return", "module", "foo", ".", "bar", "and", "class", "Baz", "objects" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L178-L224
Jaymon/prom
prom/utils.py
make_dict
def make_dict(fields, fields_kwargs): """lot's of methods take a dict or kwargs, this combines those Basically, we do a lot of def method(fields, **kwargs) and we want to merge those into one super dict with kwargs taking precedence, this does that fields -- dict -- a passed in dict fields_kwargs ...
python
def make_dict(fields, fields_kwargs): """lot's of methods take a dict or kwargs, this combines those Basically, we do a lot of def method(fields, **kwargs) and we want to merge those into one super dict with kwargs taking precedence, this does that fields -- dict -- a passed in dict fields_kwargs ...
[ "def", "make_dict", "(", "fields", ",", "fields_kwargs", ")", ":", "ret", "=", "{", "}", "if", "fields", ":", "ret", ".", "update", "(", "fields", ")", "if", "fields_kwargs", ":", "ret", ".", "update", "(", "fields_kwargs", ")", "return", "ret" ]
lot's of methods take a dict or kwargs, this combines those Basically, we do a lot of def method(fields, **kwargs) and we want to merge those into one super dict with kwargs taking precedence, this does that fields -- dict -- a passed in dict fields_kwargs -- dict -- usually a **kwargs dict from anoth...
[ "lot", "s", "of", "methods", "take", "a", "dict", "or", "kwargs", "this", "combines", "those" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L237-L255
Jaymon/prom
prom/utils.py
Stream.write_line
def write_line(self, line, count=1): """writes the line and count newlines after the line""" self.write(line) self.write_newlines(count)
python
def write_line(self, line, count=1): """writes the line and count newlines after the line""" self.write(line) self.write_newlines(count)
[ "def", "write_line", "(", "self", ",", "line", ",", "count", "=", "1", ")", ":", "self", ".", "write", "(", "line", ")", "self", ".", "write_newlines", "(", "count", ")" ]
writes the line and count newlines after the line
[ "writes", "the", "line", "and", "count", "newlines", "after", "the", "line" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L35-L38
Jaymon/prom
prom/utils.py
PriorityQueue.add
def add(self, key, val, priority=None): """add a value to the queue with priority, using the key to know uniqueness key -- str -- this is used to determine if val already exists in the queue, if key is already in the queue, then the val will be replaced in the queue with the new...
python
def add(self, key, val, priority=None): """add a value to the queue with priority, using the key to know uniqueness key -- str -- this is used to determine if val already exists in the queue, if key is already in the queue, then the val will be replaced in the queue with the new...
[ "def", "add", "(", "self", ",", "key", ",", "val", ",", "priority", "=", "None", ")", ":", "if", "key", "in", "self", ".", "item_finder", ":", "self", ".", "remove", "(", "key", ")", "else", ":", "# keep the queue contained", "if", "self", ".", "full...
add a value to the queue with priority, using the key to know uniqueness key -- str -- this is used to determine if val already exists in the queue, if key is already in the queue, then the val will be replaced in the queue with the new priority val -- mixed -- the value to add ...
[ "add", "a", "value", "to", "the", "queue", "with", "priority", "using", "the", "key", "to", "know", "uniqueness" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L111-L134
Jaymon/prom
prom/utils.py
PriorityQueue.remove
def remove(self, key): """remove the value found at key from the queue""" item = self.item_finder.pop(key) item[-1] = None self.removed_count += 1
python
def remove(self, key): """remove the value found at key from the queue""" item = self.item_finder.pop(key) item[-1] = None self.removed_count += 1
[ "def", "remove", "(", "self", ",", "key", ")", ":", "item", "=", "self", ".", "item_finder", ".", "pop", "(", "key", ")", "item", "[", "-", "1", "]", "=", "None", "self", ".", "removed_count", "+=", "1" ]
remove the value found at key from the queue
[ "remove", "the", "value", "found", "at", "key", "from", "the", "queue" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L136-L140
Jaymon/prom
prom/utils.py
PriorityQueue.popitem
def popitem(self): """remove the next prioritized [key, val, priority] and return it""" pq = self.pq while pq: priority, key, val = heapq.heappop(pq) if val is None: self.removed_count -= 1 else: del self.item_finder[key] ...
python
def popitem(self): """remove the next prioritized [key, val, priority] and return it""" pq = self.pq while pq: priority, key, val = heapq.heappop(pq) if val is None: self.removed_count -= 1 else: del self.item_finder[key] ...
[ "def", "popitem", "(", "self", ")", ":", "pq", "=", "self", ".", "pq", "while", "pq", ":", "priority", ",", "key", ",", "val", "=", "heapq", ".", "heappop", "(", "pq", ")", "if", "val", "is", "None", ":", "self", ".", "removed_count", "-=", "1", ...
remove the next prioritized [key, val, priority] and return it
[ "remove", "the", "next", "prioritized", "[", "key", "val", "priority", "]", "and", "return", "it" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L142-L154
Jaymon/prom
prom/utils.py
PriorityQueue.full
def full(self): """Return True if the queue is full""" if not self.size: return False return len(self.pq) == (self.size + self.removed_count)
python
def full(self): """Return True if the queue is full""" if not self.size: return False return len(self.pq) == (self.size + self.removed_count)
[ "def", "full", "(", "self", ")", ":", "if", "not", "self", ".", "size", ":", "return", "False", "return", "len", "(", "self", ".", "pq", ")", "==", "(", "self", ".", "size", "+", "self", ".", "removed_count", ")" ]
Return True if the queue is full
[ "Return", "True", "if", "the", "queue", "is", "full" ]
train
https://github.com/Jaymon/prom/blob/b7ad2c259eca198da03e1e4bc7d95014c168c361/prom/utils.py#L161-L164
guaix-ucm/pyemir
emirdrp/tools/slitlet_boundaries_from_continuum.py
extract_slitlet2d
def extract_slitlet2d(image_2k2k, sltlim): """Extract slitlet 2d image from image with original EMIR dimensions. Parameters ---------- image_2k2k : 2d numpy array, float Original image (dimensions NAXIS1 * NAXIS2) sltlim : instance of SlitLimits class Object containing relevant info...
python
def extract_slitlet2d(image_2k2k, sltlim): """Extract slitlet 2d image from image with original EMIR dimensions. Parameters ---------- image_2k2k : 2d numpy array, float Original image (dimensions NAXIS1 * NAXIS2) sltlim : instance of SlitLimits class Object containing relevant info...
[ "def", "extract_slitlet2d", "(", "image_2k2k", ",", "sltlim", ")", ":", "# extract slitlet region", "slitlet2d", "=", "image_2k2k", "[", "(", "sltlim", ".", "bb_ns1_orig", "-", "1", ")", ":", "sltlim", ".", "bb_ns2_orig", ",", "(", "sltlim", ".", "bb_nc1_orig"...
Extract slitlet 2d image from image with original EMIR dimensions. Parameters ---------- image_2k2k : 2d numpy array, float Original image (dimensions NAXIS1 * NAXIS2) sltlim : instance of SlitLimits class Object containing relevant information concerning the slitlet region to b...
[ "Extract", "slitlet", "2d", "image", "from", "image", "with", "original", "EMIR", "dimensions", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/slitlet_boundaries_from_continuum.py#L217-L244
guaix-ucm/pyemir
emirdrp/tools/slitlet_boundaries_from_continuum.py
compute_slitlet_boundaries
def compute_slitlet_boundaries( filename, grism, spfilter, list_slitlets, size_x_medfilt, size_y_savgol, times_sigma_threshold, bounddict, debugplot=0): """Compute slitlet boundaries using continuum lamp images. Parameters ---------- filename : string Input conti...
python
def compute_slitlet_boundaries( filename, grism, spfilter, list_slitlets, size_x_medfilt, size_y_savgol, times_sigma_threshold, bounddict, debugplot=0): """Compute slitlet boundaries using continuum lamp images. Parameters ---------- filename : string Input conti...
[ "def", "compute_slitlet_boundaries", "(", "filename", ",", "grism", ",", "spfilter", ",", "list_slitlets", ",", "size_x_medfilt", ",", "size_y_savgol", ",", "times_sigma_threshold", ",", "bounddict", ",", "debugplot", "=", "0", ")", ":", "# read 2D image", "hdulist"...
Compute slitlet boundaries using continuum lamp images. Parameters ---------- filename : string Input continumm lamp image. grism : string Grism name. It must be one in EMIR_VALID_GRISMS. spfilter : string Filter name. It must be one in EMIR_VALID_FILTERS. list_slitlets ...
[ "Compute", "slitlet", "boundaries", "using", "continuum", "lamp", "images", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/tools/slitlet_boundaries_from_continuum.py#L247-L563
BreakingBytes/simkit
simkit/core/calculators.py
index_registry
def index_registry(args, reg, ts=None, idx=None): """ Index into a :class:`~simkit.core.Registry` to return arguments from :class:`~simkit.core.data_sources.DataRegistry` and :class:`~simkit.core.outputs.OutputRegistry` based on the calculation parameter file. :param args: Arguments field from ...
python
def index_registry(args, reg, ts=None, idx=None): """ Index into a :class:`~simkit.core.Registry` to return arguments from :class:`~simkit.core.data_sources.DataRegistry` and :class:`~simkit.core.outputs.OutputRegistry` based on the calculation parameter file. :param args: Arguments field from ...
[ "def", "index_registry", "(", "args", ",", "reg", ",", "ts", "=", "None", ",", "idx", "=", "None", ")", ":", "# TODO: move this to new Registry method or __getitem__", "# TODO: replace idx with datetime object and use timeseries to interpolate", "# into data, not necessary ...
Index into a :class:`~simkit.core.Registry` to return arguments from :class:`~simkit.core.data_sources.DataRegistry` and :class:`~simkit.core.outputs.OutputRegistry` based on the calculation parameter file. :param args: Arguments field from the calculation parameter file. :param reg: Registry in wh...
[ "Index", "into", "a", ":", "class", ":", "~simkit", ".", "core", ".", "Registry", "to", "return", "arguments", "from", ":", "class", ":", "~simkit", ".", "core", ".", "data_sources", ".", "DataRegistry", "and", ":", "class", ":", "~simkit", ".", "core", ...
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/calculators.py#L11-L96
BreakingBytes/simkit
simkit/core/calculators.py
Calculator.get_covariance
def get_covariance(datargs, outargs, vargs, datvar, outvar): """ Get covariance matrix. :param datargs: data arguments :param outargs: output arguments :param vargs: variable arguments :param datvar: variance of data arguments :param outvar: variance of output ar...
python
def get_covariance(datargs, outargs, vargs, datvar, outvar): """ Get covariance matrix. :param datargs: data arguments :param outargs: output arguments :param vargs: variable arguments :param datvar: variance of data arguments :param outvar: variance of output ar...
[ "def", "get_covariance", "(", "datargs", ",", "outargs", ",", "vargs", ",", "datvar", ",", "outvar", ")", ":", "# number of formula arguments that are not constant", "argn", "=", "len", "(", "vargs", ")", "# number of observations must be the same for all vargs", "nobs", ...
Get covariance matrix. :param datargs: data arguments :param outargs: output arguments :param vargs: variable arguments :param datvar: variance of data arguments :param outvar: variance of output arguments :return: covariance
[ "Get", "covariance", "matrix", "." ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/calculators.py#L106-L163
BreakingBytes/simkit
simkit/core/calculators.py
Calculator.calculate
def calculate(cls, calc, formula_reg, data_reg, out_reg, timestep=None, idx=None): """ Execute calculation :param calc: calculation, with formula, args and return keys :type calc: dict :param formula_reg: Registry of formulas. :type formula_reg: :class:...
python
def calculate(cls, calc, formula_reg, data_reg, out_reg, timestep=None, idx=None): """ Execute calculation :param calc: calculation, with formula, args and return keys :type calc: dict :param formula_reg: Registry of formulas. :type formula_reg: :class:...
[ "def", "calculate", "(", "cls", ",", "calc", ",", "formula_reg", ",", "data_reg", ",", "out_reg", ",", "timestep", "=", "None", ",", "idx", "=", "None", ")", ":", "# get the formula-key from each static calc", "formula", "=", "calc", "[", "'formula'", "]", "...
Execute calculation :param calc: calculation, with formula, args and return keys :type calc: dict :param formula_reg: Registry of formulas. :type formula_reg: :class:`~simkit.core.FormulaRegistry` :param data_reg: Data registry. :type data_reg: :class:`~simkit.core.data_...
[ "Execute", "calculation" ]
train
https://github.com/BreakingBytes/simkit/blob/205163d879d3880b6c9ef609f1b723a58773026b/simkit/core/calculators.py#L166-L258
guaix-ucm/pyemir
emirdrp/recipes/image/checks.py
check_photometry_categorize
def check_photometry_categorize(x, y, levels, tags=None): '''Put every point in its category. levels must be sorted.''' x = numpy.asarray(x) y = numpy.asarray(y) ys = y.copy() ys.sort() # Mean of the upper half m = ys[len(ys) // 2:].mean() y /= m m = 1.0 s = ys[len(ys) // 2:...
python
def check_photometry_categorize(x, y, levels, tags=None): '''Put every point in its category. levels must be sorted.''' x = numpy.asarray(x) y = numpy.asarray(y) ys = y.copy() ys.sort() # Mean of the upper half m = ys[len(ys) // 2:].mean() y /= m m = 1.0 s = ys[len(ys) // 2:...
[ "def", "check_photometry_categorize", "(", "x", ",", "y", ",", "levels", ",", "tags", "=", "None", ")", ":", "x", "=", "numpy", ".", "asarray", "(", "x", ")", "y", "=", "numpy", ".", "asarray", "(", "y", ")", "ys", "=", "y", ".", "copy", "(", "...
Put every point in its category. levels must be sorted.
[ "Put", "every", "point", "in", "its", "category", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/recipes/image/checks.py#L173-L203
IdentityPython/oidcendpoint
src/oidcendpoint/endpoint.py
Endpoint.client_authentication
def client_authentication(self, request, auth=None, **kwargs): """ Do client authentication :param endpoint_context: A :py:class:`oidcendpoint.endpoint_context.SrvInfo` instance :param request: Parsed request, a self.request_cls class instance :param authn: Authoriza...
python
def client_authentication(self, request, auth=None, **kwargs): """ Do client authentication :param endpoint_context: A :py:class:`oidcendpoint.endpoint_context.SrvInfo` instance :param request: Parsed request, a self.request_cls class instance :param authn: Authoriza...
[ "def", "client_authentication", "(", "self", ",", "request", ",", "auth", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "verify_client", "(", "self", ".", "endpoint_context", ",", "request", ",", "auth", ")" ]
Do client authentication :param endpoint_context: A :py:class:`oidcendpoint.endpoint_context.SrvInfo` instance :param request: Parsed request, a self.request_cls class instance :param authn: Authorization info :return: client_id or raise and exception
[ "Do", "client", "authentication" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/endpoint.py#L146-L157
IdentityPython/oidcendpoint
src/oidcendpoint/endpoint.py
Endpoint.construct
def construct(self, response_args, request, **kwargs): """ Construct the response :param response_args: response arguments :param request: The parsed request, a self.request_cls class instance :param kwargs: Extra keyword arguments :return: An instance of the self.respon...
python
def construct(self, response_args, request, **kwargs): """ Construct the response :param response_args: response arguments :param request: The parsed request, a self.request_cls class instance :param kwargs: Extra keyword arguments :return: An instance of the self.respon...
[ "def", "construct", "(", "self", ",", "response_args", ",", "request", ",", "*", "*", "kwargs", ")", ":", "response_args", "=", "self", ".", "do_pre_construct", "(", "response_args", ",", "request", ",", "*", "*", "kwargs", ")", "# logger.debug(\"kwargs: %s\" ...
Construct the response :param response_args: response arguments :param request: The parsed request, a self.request_cls class instance :param kwargs: Extra keyword arguments :return: An instance of the self.response_cls class
[ "Construct", "the", "response" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/endpoint.py#L189-L203
guaix-ucm/pyemir
emirdrp/processing/wavecal/set_wv_parameters.py
set_wv_parameters
def set_wv_parameters(filter_name, grism_name): """Set wavelength calibration parameters for rectified images. Parameters ---------- filter_name : str Filter name. grism_name : str Grism name. Returns ------- wv_parameters : dictionary Python dictionary containi...
python
def set_wv_parameters(filter_name, grism_name): """Set wavelength calibration parameters for rectified images. Parameters ---------- filter_name : str Filter name. grism_name : str Grism name. Returns ------- wv_parameters : dictionary Python dictionary containi...
[ "def", "set_wv_parameters", "(", "filter_name", ",", "grism_name", ")", ":", "# protections", "if", "filter_name", "not", "in", "EMIR_VALID_FILTERS", ":", "raise", "ValueError", "(", "'Unexpected filter_name:'", ",", "filter_name", ")", "if", "grism_name", "not", "i...
Set wavelength calibration parameters for rectified images. Parameters ---------- filter_name : str Filter name. grism_name : str Grism name. Returns ------- wv_parameters : dictionary Python dictionary containing relevant wavelength calibration parameters: ...
[ "Set", "wavelength", "calibration", "parameters", "for", "rectified", "images", "." ]
train
https://github.com/guaix-ucm/pyemir/blob/fef6bbabcb13f80123cafd1800a0f508a3c21702/emirdrp/processing/wavecal/set_wv_parameters.py#L31-L186
IdentityPython/oidcendpoint
src/oidcendpoint/oidc/authorization.py
inputs
def inputs(form_args): """ Creates list of input elements """ element = [] for name, value in form_args.items(): element.append( '<input type="hidden" name="{}" value="{}"/>'.format(name, value)) return "\n".join(element)
python
def inputs(form_args): """ Creates list of input elements """ element = [] for name, value in form_args.items(): element.append( '<input type="hidden" name="{}" value="{}"/>'.format(name, value)) return "\n".join(element)
[ "def", "inputs", "(", "form_args", ")", ":", "element", "=", "[", "]", "for", "name", ",", "value", "in", "form_args", ".", "items", "(", ")", ":", "element", ".", "append", "(", "'<input type=\"hidden\" name=\"{}\" value=\"{}\"/>'", ".", "format", "(", "nam...
Creates list of input elements
[ "Creates", "list", "of", "input", "elements" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/authorization.py#L53-L61
IdentityPython/oidcendpoint
src/oidcendpoint/oidc/authorization.py
verify_uri
def verify_uri(endpoint_context, request, uri_type, client_id=None): """ A redirect URI MUST NOT contain a fragment MAY contain query component :param endpoint_context: :param request: :param uri_type: redirect_uri/post_logout_redirect_uri :return: An error response if the redirect URI ...
python
def verify_uri(endpoint_context, request, uri_type, client_id=None): """ A redirect URI MUST NOT contain a fragment MAY contain query component :param endpoint_context: :param request: :param uri_type: redirect_uri/post_logout_redirect_uri :return: An error response if the redirect URI ...
[ "def", "verify_uri", "(", "endpoint_context", ",", "request", ",", "uri_type", ",", "client_id", "=", "None", ")", ":", "try", ":", "_cid", "=", "request", "[", "\"client_id\"", "]", "except", "KeyError", ":", "_cid", "=", "client_id", "if", "not", "_cid",...
A redirect URI MUST NOT contain a fragment MAY contain query component :param endpoint_context: :param request: :param uri_type: redirect_uri/post_logout_redirect_uri :return: An error response if the redirect URI is faulty otherwise None
[ "A", "redirect", "URI", "MUST", "NOT", "contain", "a", "fragment", "MAY", "contain", "query", "component" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/authorization.py#L100-L168
IdentityPython/oidcendpoint
src/oidcendpoint/oidc/authorization.py
get_uri
def get_uri(endpoint_context, request, uri_type): """ verify that the redirect URI is reasonable :param endpoint_context: :param request: The Authorization request :param uri_type: 'redirect_uri' or 'post_logout_redirect_uri' :return: redirect_uri """ if uri_type in request: verify_...
python
def get_uri(endpoint_context, request, uri_type): """ verify that the redirect URI is reasonable :param endpoint_context: :param request: The Authorization request :param uri_type: 'redirect_uri' or 'post_logout_redirect_uri' :return: redirect_uri """ if uri_type in request: verify_...
[ "def", "get_uri", "(", "endpoint_context", ",", "request", ",", "uri_type", ")", ":", "if", "uri_type", "in", "request", ":", "verify_uri", "(", "endpoint_context", ",", "request", ",", "uri_type", ")", "uri", "=", "request", "[", "uri_type", "]", "else", ...
verify that the redirect URI is reasonable :param endpoint_context: :param request: The Authorization request :param uri_type: 'redirect_uri' or 'post_logout_redirect_uri' :return: redirect_uri
[ "verify", "that", "the", "redirect", "URI", "is", "reasonable" ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/authorization.py#L184-L209
IdentityPython/oidcendpoint
src/oidcendpoint/oidc/authorization.py
Authorization.post_authentication
def post_authentication(self, user, request, sid, **kwargs): """ Things that are done after a successful authentication. :param user: :param request: :param sid: :param kwargs: :return: A dictionary with 'response_args' """ response_info = {} ...
python
def post_authentication(self, user, request, sid, **kwargs): """ Things that are done after a successful authentication. :param user: :param request: :param sid: :param kwargs: :return: A dictionary with 'response_args' """ response_info = {} ...
[ "def", "post_authentication", "(", "self", ",", "user", ",", "request", ",", "sid", ",", "*", "*", "kwargs", ")", ":", "response_info", "=", "{", "}", "# Do the authorization", "try", ":", "permission", "=", "self", ".", "endpoint_context", ".", "authz", "...
Things that are done after a successful authentication. :param user: :param request: :param sid: :param kwargs: :return: A dictionary with 'response_args'
[ "Things", "that", "are", "done", "after", "a", "successful", "authentication", "." ]
train
https://github.com/IdentityPython/oidcendpoint/blob/6c1d729d51bfb6332816117fe476073df7a1d823/src/oidcendpoint/oidc/authorization.py#L568-L640