repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
costastf/toonlib
toonlib/toonlib.py
Toon.get_smokedetector_by_name
def get_smokedetector_by_name(self, name): """Retrieves a smokedetector object by its name :param name: The name of the smokedetector to return :return: A smokedetector object """ return next((smokedetector for smokedetector in self.smokedetectors if smokede...
python
def get_smokedetector_by_name(self, name): """Retrieves a smokedetector object by its name :param name: The name of the smokedetector to return :return: A smokedetector object """ return next((smokedetector for smokedetector in self.smokedetectors if smokede...
[ "def", "get_smokedetector_by_name", "(", "self", ",", "name", ")", ":", "return", "next", "(", "(", "smokedetector", "for", "smokedetector", "in", "self", ".", "smokedetectors", "if", "smokedetector", ".", "name", ".", "lower", "(", ")", "==", "name", ".", ...
Retrieves a smokedetector object by its name :param name: The name of the smokedetector to return :return: A smokedetector object
[ "Retrieves", "a", "smokedetector", "object", "by", "its", "name" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L236-L243
train
Retrieves a smokedetector object by its name
costastf/toonlib
toonlib/toonlib.py
Toon.lights
def lights(self): """:return: A list of light objects""" return [Light(self, light.get('name')) for light in self._state.get('deviceStatusInfo', {}).get('device', []) if light.get('rgbColor')]
python
def lights(self): """:return: A list of light objects""" return [Light(self, light.get('name')) for light in self._state.get('deviceStatusInfo', {}).get('device', []) if light.get('rgbColor')]
[ "def", "lights", "(", "self", ")", ":", "return", "[", "Light", "(", "self", ",", "light", ".", "get", "(", "'name'", ")", ")", "for", "light", "in", "self", ".", "_state", ".", "get", "(", "'deviceStatusInfo'", ",", "{", "}", ")", ".", "get", "(...
:return: A list of light objects
[ ":", "return", ":", "A", "list", "of", "light", "objects" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L246-L251
train
Returns a list of lights in the system
costastf/toonlib
toonlib/toonlib.py
Toon.get_light_by_name
def get_light_by_name(self, name): """Retrieves a light object by its name :param name: The name of the light to return :return: A light object """ return next((light for light in self.lights if light.name.lower() == name.lower()), None)
python
def get_light_by_name(self, name): """Retrieves a light object by its name :param name: The name of the light to return :return: A light object """ return next((light for light in self.lights if light.name.lower() == name.lower()), None)
[ "def", "get_light_by_name", "(", "self", ",", "name", ")", ":", "return", "next", "(", "(", "light", "for", "light", "in", "self", ".", "lights", "if", "light", ".", "name", ".", "lower", "(", ")", "==", "name", ".", "lower", "(", ")", ")", ",", ...
Retrieves a light object by its name :param name: The name of the light to return :return: A light object
[ "Retrieves", "a", "light", "object", "by", "its", "name" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L253-L260
train
Retrieves a light object by its name
costastf/toonlib
toonlib/toonlib.py
Toon.smartplugs
def smartplugs(self): """:return: A list of smartplug objects.""" return [SmartPlug(self, plug.get('name')) for plug in self._state.get('deviceStatusInfo', {}).get('device', []) if plug.get('networkHealthState')]
python
def smartplugs(self): """:return: A list of smartplug objects.""" return [SmartPlug(self, plug.get('name')) for plug in self._state.get('deviceStatusInfo', {}).get('device', []) if plug.get('networkHealthState')]
[ "def", "smartplugs", "(", "self", ")", ":", "return", "[", "SmartPlug", "(", "self", ",", "plug", ".", "get", "(", "'name'", ")", ")", "for", "plug", "in", "self", ".", "_state", ".", "get", "(", "'deviceStatusInfo'", ",", "{", "}", ")", ".", "get"...
:return: A list of smartplug objects.
[ ":", "return", ":", "A", "list", "of", "smartplug", "objects", "." ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L263-L268
train
A list of smartplug objects.
costastf/toonlib
toonlib/toonlib.py
Toon.get_smartplug_by_name
def get_smartplug_by_name(self, name): """Retrieves a smartplug object by its name :param name: The name of the smartplug to return :return: A smartplug object """ return next((plug for plug in self.smartplugs if plug.name.lower() == name.lower()), None)
python
def get_smartplug_by_name(self, name): """Retrieves a smartplug object by its name :param name: The name of the smartplug to return :return: A smartplug object """ return next((plug for plug in self.smartplugs if plug.name.lower() == name.lower()), None)
[ "def", "get_smartplug_by_name", "(", "self", ",", "name", ")", ":", "return", "next", "(", "(", "plug", "for", "plug", "in", "self", ".", "smartplugs", "if", "plug", ".", "name", ".", "lower", "(", ")", "==", "name", ".", "lower", "(", ")", ")", ",...
Retrieves a smartplug object by its name :param name: The name of the smartplug to return :return: A smartplug object
[ "Retrieves", "a", "smartplug", "object", "by", "its", "name" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L270-L277
train
Retrieves a smartplug object by its name
costastf/toonlib
toonlib/toonlib.py
Toon.gas
def gas(self): """:return: A gas object modeled as a named tuple""" usage = self._state['gasUsage'] return Usage(usage.get('avgDayValue'), usage.get('avgValue'), usage.get('dayCost'), usage.get('dayUsage'), usage...
python
def gas(self): """:return: A gas object modeled as a named tuple""" usage = self._state['gasUsage'] return Usage(usage.get('avgDayValue'), usage.get('avgValue'), usage.get('dayCost'), usage.get('dayUsage'), usage...
[ "def", "gas", "(", "self", ")", ":", "usage", "=", "self", ".", "_state", "[", "'gasUsage'", "]", "return", "Usage", "(", "usage", ".", "get", "(", "'avgDayValue'", ")", ",", "usage", ".", "get", "(", "'avgValue'", ")", ",", "usage", ".", "get", "(...
:return: A gas object modeled as a named tuple
[ ":", "return", ":", "A", "gas", "object", "modeled", "as", "a", "named", "tuple" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L280-L289
train
A gas object modeled as a named tuple
costastf/toonlib
toonlib/toonlib.py
Toon.power
def power(self): """:return: A power object modeled as a named tuple""" power = self._state['powerUsage'] return PowerUsage(power.get('avgDayValue'), power.get('avgValue'), power.get('dayCost'), power.get('dayUsage'), ...
python
def power(self): """:return: A power object modeled as a named tuple""" power = self._state['powerUsage'] return PowerUsage(power.get('avgDayValue'), power.get('avgValue'), power.get('dayCost'), power.get('dayUsage'), ...
[ "def", "power", "(", "self", ")", ":", "power", "=", "self", ".", "_state", "[", "'powerUsage'", "]", "return", "PowerUsage", "(", "power", ".", "get", "(", "'avgDayValue'", ")", ",", "power", ".", "get", "(", "'avgValue'", ")", ",", "power", ".", "g...
:return: A power object modeled as a named tuple
[ ":", "return", ":", "A", "power", "object", "modeled", "as", "a", "named", "tuple" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L292-L303
train
A power object modeled as a named tuple
costastf/toonlib
toonlib/toonlib.py
Toon.thermostat_info
def thermostat_info(self): """:return: A thermostatinfo object modeled as a named tuple""" info = self._state['thermostatInfo'] return ThermostatInfo(info.get('activeState'), info.get('boilerModuleConnected'), info.get('burnerInfo'), ...
python
def thermostat_info(self): """:return: A thermostatinfo object modeled as a named tuple""" info = self._state['thermostatInfo'] return ThermostatInfo(info.get('activeState'), info.get('boilerModuleConnected'), info.get('burnerInfo'), ...
[ "def", "thermostat_info", "(", "self", ")", ":", "info", "=", "self", ".", "_state", "[", "'thermostatInfo'", "]", "return", "ThermostatInfo", "(", "info", ".", "get", "(", "'activeState'", ")", ",", "info", ".", "get", "(", "'boilerModuleConnected'", ")", ...
:return: A thermostatinfo object modeled as a named tuple
[ ":", "return", ":", "A", "thermostatinfo", "object", "modeled", "as", "a", "named", "tuple" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L317-L336
train
A thermostatinfo object modeled as a named tuple
costastf/toonlib
toonlib/toonlib.py
Toon.thermostat_states
def thermostat_states(self): """:return: A list of thermostatstate object modeled as named tuples""" return [ThermostatState(STATES[state.get('id')], state.get('id'), state.get('tempValue'), state.get('dhw'))...
python
def thermostat_states(self): """:return: A list of thermostatstate object modeled as named tuples""" return [ThermostatState(STATES[state.get('id')], state.get('id'), state.get('tempValue'), state.get('dhw'))...
[ "def", "thermostat_states", "(", "self", ")", ":", "return", "[", "ThermostatState", "(", "STATES", "[", "state", ".", "get", "(", "'id'", ")", "]", ",", "state", ".", "get", "(", "'id'", ")", ",", "state", ".", "get", "(", "'tempValue'", ")", ",", ...
:return: A list of thermostatstate object modeled as named tuples
[ ":", "return", ":", "A", "list", "of", "thermostatstate", "object", "modeled", "as", "named", "tuples" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L339-L345
train
Returns a list of thermostatstate objects modeled as named tuples
costastf/toonlib
toonlib/toonlib.py
Toon.get_thermostat_state_by_name
def get_thermostat_state_by_name(self, name): """Retrieves a thermostat state object by its assigned name :param name: The name of the thermostat state :return: The thermostat state object """ self._validate_thermostat_state_name(name) return next((state for state in sel...
python
def get_thermostat_state_by_name(self, name): """Retrieves a thermostat state object by its assigned name :param name: The name of the thermostat state :return: The thermostat state object """ self._validate_thermostat_state_name(name) return next((state for state in sel...
[ "def", "get_thermostat_state_by_name", "(", "self", ",", "name", ")", ":", "self", ".", "_validate_thermostat_state_name", "(", "name", ")", "return", "next", "(", "(", "state", "for", "state", "in", "self", ".", "thermostat_states", "if", "state", ".", "name"...
Retrieves a thermostat state object by its assigned name :param name: The name of the thermostat state :return: The thermostat state object
[ "Retrieves", "a", "thermostat", "state", "object", "by", "its", "assigned", "name" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L347-L355
train
Retrieves a thermostat state object by its assigned name
costastf/toonlib
toonlib/toonlib.py
Toon.get_thermostat_state_by_id
def get_thermostat_state_by_id(self, id_): """Retrieves a thermostat state object by its id :param id_: The id of the thermostat state :return: The thermostat state object """ return next((state for state in self.thermostat_states if state.id == id_), None)
python
def get_thermostat_state_by_id(self, id_): """Retrieves a thermostat state object by its id :param id_: The id of the thermostat state :return: The thermostat state object """ return next((state for state in self.thermostat_states if state.id == id_), None)
[ "def", "get_thermostat_state_by_id", "(", "self", ",", "id_", ")", ":", "return", "next", "(", "(", "state", "for", "state", "in", "self", ".", "thermostat_states", "if", "state", ".", "id", "==", "id_", ")", ",", "None", ")" ]
Retrieves a thermostat state object by its id :param id_: The id of the thermostat state :return: The thermostat state object
[ "Retrieves", "a", "thermostat", "state", "object", "by", "its", "id" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L357-L364
train
Retrieves a thermostat state object by its id
costastf/toonlib
toonlib/toonlib.py
Toon.thermostat_state
def thermostat_state(self): """The state of the thermostat programming :return: A thermostat state object of the current setting """ current_state = self.thermostat_info.active_state state = self.get_thermostat_state_by_id(current_state) if not state: self._l...
python
def thermostat_state(self): """The state of the thermostat programming :return: A thermostat state object of the current setting """ current_state = self.thermostat_info.active_state state = self.get_thermostat_state_by_id(current_state) if not state: self._l...
[ "def", "thermostat_state", "(", "self", ")", ":", "current_state", "=", "self", ".", "thermostat_info", ".", "active_state", "state", "=", "self", ".", "get_thermostat_state_by_id", "(", "current_state", ")", "if", "not", "state", ":", "self", ".", "_logger", ...
The state of the thermostat programming :return: A thermostat state object of the current setting
[ "The", "state", "of", "the", "thermostat", "programming" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L377-L387
train
The state of the thermostat programming
costastf/toonlib
toonlib/toonlib.py
Toon.thermostat_state
def thermostat_state(self, name): """Changes the thermostat state to the one passed as an argument as name :param name: The name of the thermostat state to change to. """ self._validate_thermostat_state_name(name) id_ = next((key for key in STATES.keys() if S...
python
def thermostat_state(self, name): """Changes the thermostat state to the one passed as an argument as name :param name: The name of the thermostat state to change to. """ self._validate_thermostat_state_name(name) id_ = next((key for key in STATES.keys() if S...
[ "def", "thermostat_state", "(", "self", ",", "name", ")", ":", "self", ".", "_validate_thermostat_state_name", "(", "name", ")", "id_", "=", "next", "(", "(", "key", "for", "key", "in", "STATES", ".", "keys", "(", ")", "if", "STATES", "[", "key", "]", ...
Changes the thermostat state to the one passed as an argument as name :param name: The name of the thermostat state to change to.
[ "Changes", "the", "thermostat", "state", "to", "the", "one", "passed", "as", "an", "argument", "as", "name" ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L390-L403
train
Changes the thermostat state to the one passed as an argument as name
costastf/toonlib
toonlib/toonlib.py
Toon.thermostat
def thermostat(self, temperature): """A temperature to set the thermostat to. Requires a float. :param temperature: A float of the desired temperature to change to. """ target = int(temperature * 100) data = copy.copy(self._parameters) data.update({'value': target}) ...
python
def thermostat(self, temperature): """A temperature to set the thermostat to. Requires a float. :param temperature: A float of the desired temperature to change to. """ target = int(temperature * 100) data = copy.copy(self._parameters) data.update({'value': target}) ...
[ "def", "thermostat", "(", "self", ",", "temperature", ")", ":", "target", "=", "int", "(", "temperature", "*", "100", ")", "data", "=", "copy", ".", "copy", "(", "self", ".", "_parameters", ")", "data", ".", "update", "(", "{", "'value'", ":", "targe...
A temperature to set the thermostat to. Requires a float. :param temperature: A float of the desired temperature to change to.
[ "A", "temperature", "to", "set", "the", "thermostat", "to", ".", "Requires", "a", "float", "." ]
2fa95430240d1a1c2a85a8827aecfcb1ca41c18c
https://github.com/costastf/toonlib/blob/2fa95430240d1a1c2a85a8827aecfcb1ca41c18c/toonlib/toonlib.py#L415-L425
train
Sets the thermostat of the current system. Requires a float.
Xaroth/libzfs-python
libzfs/utils/recursivedict.py
RecursiveDictionary.rec_update
def rec_update(self, other, **third): """Recursively update the dictionary with the contents of other and third like dict.update() does - but don't overwrite sub-dictionaries. Example: >>> d = RecursiveDictionary({'foo': {'bar': 42}}) >>> d.rec_update({'foo': {'baz': 36}}) ...
python
def rec_update(self, other, **third): """Recursively update the dictionary with the contents of other and third like dict.update() does - but don't overwrite sub-dictionaries. Example: >>> d = RecursiveDictionary({'foo': {'bar': 42}}) >>> d.rec_update({'foo': {'baz': 36}}) ...
[ "def", "rec_update", "(", "self", ",", "other", ",", "*", "*", "third", ")", ":", "try", ":", "iterator", "=", "other", ".", "iteritems", "(", ")", "except", "AttributeError", ":", "iterator", "=", "other", "self", ".", "iter_rec_update", "(", "iterator"...
Recursively update the dictionary with the contents of other and third like dict.update() does - but don't overwrite sub-dictionaries. Example: >>> d = RecursiveDictionary({'foo': {'bar': 42}}) >>> d.rec_update({'foo': {'baz': 36}}) >>> d {'foo': {'baz': 36, 'bar': 42}}
[ "Recursively", "update", "the", "dictionary", "with", "the", "contents", "of", "other", "and", "third", "like", "dict", ".", "update", "()", "does", "-", "but", "don", "t", "overwrite", "sub", "-", "dictionaries", ".", "Example", ":", ">>>", "d", "=", "R...
146e5f28de5971bb6eb64fd82b098c5f302f0b33
https://github.com/Xaroth/libzfs-python/blob/146e5f28de5971bb6eb64fd82b098c5f302f0b33/libzfs/utils/recursivedict.py#L33-L47
train
Recursively update the dictionary with the contents of other and third like dict. update does - but don t overwrite sub - dictionaries.
Erotemic/utool
utool/experimental/dynamic_connectivity.py
euler_tour_dfs
def euler_tour_dfs(G, source=None): """ adaptation of networkx dfs """ if source is None: # produce edges for all components nodes = G else: # produce edges for components with source nodes = [source] yielder = [] visited = set() for start in nodes: if sta...
python
def euler_tour_dfs(G, source=None): """ adaptation of networkx dfs """ if source is None: # produce edges for all components nodes = G else: # produce edges for components with source nodes = [source] yielder = [] visited = set() for start in nodes: if sta...
[ "def", "euler_tour_dfs", "(", "G", ",", "source", "=", "None", ")", ":", "if", "source", "is", "None", ":", "# produce edges for all components", "nodes", "=", "G", "else", ":", "# produce edges for components with source", "nodes", "=", "[", "source", "]", "yie...
adaptation of networkx dfs
[ "adaptation", "of", "networkx", "dfs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L12-L41
train
adaptation of networkx dfs
Erotemic/utool
utool/experimental/dynamic_connectivity.py
comparison
def comparison(): r""" CommandLine: python -m utool.experimental.dynamic_connectivity comparison --profile python -m utool.experimental.dynamic_connectivity comparison """ n = 12 a, b = 9, 20 num = 3 import utool for timer in utool.Timerit(num, 'old bst version (PY)'): ...
python
def comparison(): r""" CommandLine: python -m utool.experimental.dynamic_connectivity comparison --profile python -m utool.experimental.dynamic_connectivity comparison """ n = 12 a, b = 9, 20 num = 3 import utool for timer in utool.Timerit(num, 'old bst version (PY)'): ...
[ "def", "comparison", "(", ")", ":", "n", "=", "12", "a", ",", "b", "=", "9", ",", "20", "num", "=", "3", "import", "utool", "for", "timer", "in", "utool", ".", "Timerit", "(", "num", ",", "'old bst version (PY)'", ")", ":", "g", "=", "nx", ".", ...
r""" CommandLine: python -m utool.experimental.dynamic_connectivity comparison --profile python -m utool.experimental.dynamic_connectivity comparison
[ "r", "CommandLine", ":", "python", "-", "m", "utool", ".", "experimental", ".", "dynamic_connectivity", "comparison", "--", "profile", "python", "-", "m", "utool", ".", "experimental", ".", "dynamic_connectivity", "comparison" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L45-L89
train
r Compare two sets of objects in a tree.
Erotemic/utool
utool/experimental/dynamic_connectivity.py
EulerTourList.join
def join(self, other): r""" Args: other (?): CommandLine: python -m sortedcontainers.sortedlist join2 Example: >>> from utool.experimental.dynamic_connectivity import * # NOQA >>> self = EulerTourList([1, 2, 3, 2, 4, 2, 1], load=3) ...
python
def join(self, other): r""" Args: other (?): CommandLine: python -m sortedcontainers.sortedlist join2 Example: >>> from utool.experimental.dynamic_connectivity import * # NOQA >>> self = EulerTourList([1, 2, 3, 2, 4, 2, 1], load=3) ...
[ "def", "join", "(", "self", ",", "other", ")", ":", "assert", "self", ".", "_load", "==", "other", ".", "_load", ",", "'loads must be the same'", "self", ".", "_lists", ".", "extend", "(", "other", ".", "_lists", ")", "self", ".", "_cumlen", ".", "exte...
r""" Args: other (?): CommandLine: python -m sortedcontainers.sortedlist join2 Example: >>> from utool.experimental.dynamic_connectivity import * # NOQA >>> self = EulerTourList([1, 2, 3, 2, 4, 2, 1], load=3) >>> other = EulerTourLis...
[ "r", "Args", ":", "other", "(", "?", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L341-L359
train
r Join two sortedcontainers. sortedlist objects.
Erotemic/utool
utool/experimental/dynamic_connectivity.py
EulerTourTree.cut
def cut(self, a, b, bstjoin=False): """ cuts edge (a, b) into two parts because this is a tree a, b = (2, 5) print(self.first_lookup[a] > self.first_lookup[b]) tree = self.tour_tree list(tree.item_slice(k1, k2)) """ if self.first_lookup[a] > self.last_loo...
python
def cut(self, a, b, bstjoin=False): """ cuts edge (a, b) into two parts because this is a tree a, b = (2, 5) print(self.first_lookup[a] > self.first_lookup[b]) tree = self.tour_tree list(tree.item_slice(k1, k2)) """ if self.first_lookup[a] > self.last_loo...
[ "def", "cut", "(", "self", ",", "a", ",", "b", ",", "bstjoin", "=", "False", ")", ":", "if", "self", ".", "first_lookup", "[", "a", "]", ">", "self", ".", "last_lookup", "[", "b", "]", ":", "a", ",", "b", "=", "b", ",", "a", "o_a1", "=", "s...
cuts edge (a, b) into two parts because this is a tree a, b = (2, 5) print(self.first_lookup[a] > self.first_lookup[b]) tree = self.tour_tree list(tree.item_slice(k1, k2))
[ "cuts", "edge", "(", "a", "b", ")", "into", "two", "parts", "because", "this", "is", "a", "tree" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L488-L519
train
cut edge a and b into two parts because this is a tree
Erotemic/utool
utool/experimental/dynamic_connectivity.py
EulerTourTree.reroot
def reroot(self, s): """ s = 3 s = 'B' Let os denote any occurrence of s. Splice out the first part of the sequence ending with the occurrence before os, remove its first occurrence (or), and tack this on to the end of the sequence which now begins with os. ...
python
def reroot(self, s): """ s = 3 s = 'B' Let os denote any occurrence of s. Splice out the first part of the sequence ending with the occurrence before os, remove its first occurrence (or), and tack this on to the end of the sequence which now begins with os. ...
[ "def", "reroot", "(", "self", ",", "s", ")", ":", "# Splice out the first part of the sequence ending with the occurrence before os", "# remove its first occurrence (or),", "o_s1", "=", "self", ".", "first_lookup", "[", "s", "]", "splice1", "=", "self", ".", "tour", "["...
s = 3 s = 'B' Let os denote any occurrence of s. Splice out the first part of the sequence ending with the occurrence before os, remove its first occurrence (or), and tack this on to the end of the sequence which now begins with os. Add a new occurrence os to the end.
[ "s", "=", "3", "s", "=", "B" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L521-L539
train
Return a new tree from the current tree.
Erotemic/utool
utool/experimental/dynamic_connectivity.py
EulerTourForest.add_edge
def add_edge(self, u, v): """ self = EulerTourForest() self.add_node(1) self.add_node(2) u, v = 1, 2 """ # ubin = self.find_root(u) ru = self.find_root(u) rv = self.find_root(v) ru = self.reroot(ru, u) rv = self.reroot(rv, v) ...
python
def add_edge(self, u, v): """ self = EulerTourForest() self.add_node(1) self.add_node(2) u, v = 1, 2 """ # ubin = self.find_root(u) ru = self.find_root(u) rv = self.find_root(v) ru = self.reroot(ru, u) rv = self.reroot(rv, v) ...
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ")", ":", "# ubin = self.find_root(u)", "ru", "=", "self", ".", "find_root", "(", "u", ")", "rv", "=", "self", ".", "find_root", "(", "v", ")", "ru", "=", "self", ".", "reroot", "(", "ru", ",", ...
self = EulerTourForest() self.add_node(1) self.add_node(2) u, v = 1, 2
[ "self", "=", "EulerTourForest", "()", "self", ".", "add_node", "(", "1", ")", "self", ".", "add_node", "(", "2", ")", "u", "v", "=", "1", "2" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L596-L611
train
add an edge between two nodes u and v
Erotemic/utool
utool/experimental/dynamic_connectivity.py
DynConnGraph.add_edge
def add_edge(self, u, v): """ O(log(n)) """ # print('add_edge u, v = %r, %r' % (u, v,)) if self.graph.has_edge(u, v): return for node in (u, v): if not self.graph.has_node(node): self.graph.add_node(node) for Fi in self....
python
def add_edge(self, u, v): """ O(log(n)) """ # print('add_edge u, v = %r, %r' % (u, v,)) if self.graph.has_edge(u, v): return for node in (u, v): if not self.graph.has_node(node): self.graph.add_node(node) for Fi in self....
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ")", ":", "# print('add_edge u, v = %r, %r' % (u, v,))", "if", "self", ".", "graph", ".", "has_edge", "(", "u", ",", "v", ")", ":", "return", "for", "node", "in", "(", "u", ",", "v", ")", ":", "if",...
O(log(n))
[ "O", "(", "log", "(", "n", "))" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L830-L851
train
Add an edge between nodes u and v.
Erotemic/utool
utool/experimental/dynamic_connectivity.py
DynConnGraph.remove_edge
def remove_edge(self, u, v): """ Using notation where 0 is top level Intuitively speaking, when the level of a nontree edge is increased, it is because we have discovered that its end points are close enough in F to fit in a smaller tree on a higher level. """ # ...
python
def remove_edge(self, u, v): """ Using notation where 0 is top level Intuitively speaking, when the level of a nontree edge is increased, it is because we have discovered that its end points are close enough in F to fit in a smaller tree on a higher level. """ # ...
[ "def", "remove_edge", "(", "self", ",", "u", ",", "v", ")", ":", "# Remove (u, v) from represented graph", "print", "(", "'Dynamically removing uv=(%r, %r)'", "%", "(", "u", ",", "v", ")", ")", "self", ".", "graph", ".", "remove_edge", "(", "u", ",", "v", ...
Using notation where 0 is top level Intuitively speaking, when the level of a nontree edge is increased, it is because we have discovered that its end points are close enough in F to fit in a smaller tree on a higher level.
[ "Using", "notation", "where", "0", "is", "top", "level" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L853-L923
train
Remove an edge from the nontree and return the F .
Erotemic/utool
utool/experimental/dynamic_connectivity.py
DynConnGraph.is_connected
def is_connected(self, u, v): """ Check if vertices u and v are connected. Query top level forest F[0] to see if u and v are in the same tree. This can be done by checking F_{log(n)} if Findroot(u) = Findroot(v). This costs O(log(n) / log(log(n))) using B-tree based Euler-Tour tr...
python
def is_connected(self, u, v): """ Check if vertices u and v are connected. Query top level forest F[0] to see if u and v are in the same tree. This can be done by checking F_{log(n)} if Findroot(u) = Findroot(v). This costs O(log(n) / log(log(n))) using B-tree based Euler-Tour tr...
[ "def", "is_connected", "(", "self", ",", "u", ",", "v", ")", ":", "ru", "=", "self", ".", "forests", "[", "0", "]", ".", "find_root", "(", "u", ")", "rv", "=", "self", ".", "forests", "[", "0", "]", ".", "find_root", "(", "v", ")", "return", ...
Check if vertices u and v are connected. Query top level forest F[0] to see if u and v are in the same tree. This can be done by checking F_{log(n)} if Findroot(u) = Findroot(v). This costs O(log(n) / log(log(n))) using B-tree based Euler-Tour trees. but this trades off with a O(log^2(n)...
[ "Check", "if", "vertices", "u", "and", "v", "are", "connected", ".", "Query", "top", "level", "forest", "F", "[", "0", "]", "to", "see", "if", "u", "and", "v", "are", "in", "the", "same", "tree", ".", "This", "can", "be", "done", "by", "checking", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/experimental/dynamic_connectivity.py#L925-L936
train
Check if vertices u and v are connected.
Erotemic/utool
utool/util_regex.py
convert_text_to_varname
def convert_text_to_varname(text): r""" Args: text (str): text that might not be a valid variablename Returns: str: varname CommandLine: python -m utool.util_regex --test-convert_text_to_varname Example: >>> # DISABLE_DOCTEST >>> from utool.util_regex impor...
python
def convert_text_to_varname(text): r""" Args: text (str): text that might not be a valid variablename Returns: str: varname CommandLine: python -m utool.util_regex --test-convert_text_to_varname Example: >>> # DISABLE_DOCTEST >>> from utool.util_regex impor...
[ "def", "convert_text_to_varname", "(", "text", ")", ":", "varname_pattern", "=", "'[^a-zA-Z0-9_]'", "varname", "=", "text", "# Convert spaces to underscores", "varname", "=", "varname", ".", "replace", "(", "' '", ",", "'_'", ")", "# Remove all other non-varname chars",...
r""" Args: text (str): text that might not be a valid variablename Returns: str: varname CommandLine: python -m utool.util_regex --test-convert_text_to_varname Example: >>> # DISABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> text = '0) View...
[ "r", "Args", ":", "text", "(", "str", ")", ":", "text", "that", "might", "not", "be", "a", "valid", "variablename" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L13-L43
train
r Convert text to a valid variablename
Erotemic/utool
utool/util_regex.py
extend_regex
def extend_regex(regexpr): r""" Extends the syntax of regular expressions by replacing convineince syntax with re friendly syntax. Nameely things that I use in vim like \<\> """ regex_map = { #r'\<': r'\b(?=\w)', #r'\>': r'\b(?!\w)', r'\<': r'\b' + positive_lookahead(r'\w')...
python
def extend_regex(regexpr): r""" Extends the syntax of regular expressions by replacing convineince syntax with re friendly syntax. Nameely things that I use in vim like \<\> """ regex_map = { #r'\<': r'\b(?=\w)', #r'\>': r'\b(?!\w)', r'\<': r'\b' + positive_lookahead(r'\w')...
[ "def", "extend_regex", "(", "regexpr", ")", ":", "regex_map", "=", "{", "#r'\\<': r'\\b(?=\\w)',", "#r'\\>': r'\\b(?!\\w)',", "r'\\<'", ":", "r'\\b'", "+", "positive_lookahead", "(", "r'\\w'", ")", ",", "r'\\>'", ":", "r'\\b'", "+", "negative_lookahead", "(", "r'\...
r""" Extends the syntax of regular expressions by replacing convineince syntax with re friendly syntax. Nameely things that I use in vim like \<\>
[ "r", "Extends", "the", "syntax", "of", "regular", "expressions", "by", "replacing", "convineince", "syntax", "with", "re", "friendly", "syntax", ".", "Nameely", "things", "that", "I", "use", "in", "vim", "like", "\\", "<", "\\", ">" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L55-L76
train
r Extends the syntax of regular expressions by replacing convineince syntax with re friendly syntax.
Erotemic/utool
utool/util_regex.py
extend_regex2
def extend_regex2(regexpr, reflags=0): """ also preprocesses flags """ regexpr = extend_regex(regexpr) IGNORE_CASE_PREF = '\\c' if regexpr.startswith(IGNORE_CASE_PREF): # hack for vim-like ignore case regexpr = regexpr[len(IGNORE_CASE_PREF):] reflags = reflags | re.IGNORE...
python
def extend_regex2(regexpr, reflags=0): """ also preprocesses flags """ regexpr = extend_regex(regexpr) IGNORE_CASE_PREF = '\\c' if regexpr.startswith(IGNORE_CASE_PREF): # hack for vim-like ignore case regexpr = regexpr[len(IGNORE_CASE_PREF):] reflags = reflags | re.IGNORE...
[ "def", "extend_regex2", "(", "regexpr", ",", "reflags", "=", "0", ")", ":", "regexpr", "=", "extend_regex", "(", "regexpr", ")", "IGNORE_CASE_PREF", "=", "'\\\\c'", "if", "regexpr", ".", "startswith", "(", "IGNORE_CASE_PREF", ")", ":", "# hack for vim-like ignor...
also preprocesses flags
[ "also", "preprocesses", "flags" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L91-L101
train
extend_regex2 - extend regexpr to include flags
Erotemic/utool
utool/util_regex.py
named_field
def named_field(key, regex, vim=False): """ Creates a named regex group that can be referend via a backref. If key is None the backref is referenced by number. References: https://docs.python.org/2/library/re.html#regular-expression-syntax """ if key is None: #return regex ...
python
def named_field(key, regex, vim=False): """ Creates a named regex group that can be referend via a backref. If key is None the backref is referenced by number. References: https://docs.python.org/2/library/re.html#regular-expression-syntax """ if key is None: #return regex ...
[ "def", "named_field", "(", "key", ",", "regex", ",", "vim", "=", "False", ")", ":", "if", "key", "is", "None", ":", "#return regex", "return", "r'(%s)'", "%", "(", "regex", ",", ")", "if", "vim", ":", "return", "r'\\(%s\\)'", "%", "(", "regex", ")", ...
Creates a named regex group that can be referend via a backref. If key is None the backref is referenced by number. References: https://docs.python.org/2/library/re.html#regular-expression-syntax
[ "Creates", "a", "named", "regex", "group", "that", "can", "be", "referend", "via", "a", "backref", ".", "If", "key", "is", "None", "the", "backref", "is", "referenced", "by", "number", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L124-L138
train
Creates a named regex group that can be used to match a field in a backref.
Erotemic/utool
utool/util_regex.py
regex_replace
def regex_replace(regex, repl, text): r""" thin wrapper around re.sub regex_replace MULTILINE and DOTALL are on by default in all util_regex functions Args: regex (str): pattern to find repl (str): replace pattern with this text (str): text to modify Returns: s...
python
def regex_replace(regex, repl, text): r""" thin wrapper around re.sub regex_replace MULTILINE and DOTALL are on by default in all util_regex functions Args: regex (str): pattern to find repl (str): replace pattern with this text (str): text to modify Returns: s...
[ "def", "regex_replace", "(", "regex", ",", "repl", ",", "text", ")", ":", "return", "re", ".", "sub", "(", "regex", ",", "repl", ",", "text", ",", "*", "*", "RE_KWARGS", ")" ]
r""" thin wrapper around re.sub regex_replace MULTILINE and DOTALL are on by default in all util_regex functions Args: regex (str): pattern to find repl (str): replace pattern with this text (str): text to modify Returns: str: modified text Example1: >...
[ "r", "thin", "wrapper", "around", "re", ".", "sub", "regex_replace" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L203-L243
train
r Replace pattern with this
Erotemic/utool
utool/util_regex.py
named_field_regex
def named_field_regex(keypat_tups): """ named_field_regex Args: keypat_tups (list): tuples of (name, pattern) or a string for an unnamed pattern Returns: str: regex Example: >>> # ENABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> keypat_...
python
def named_field_regex(keypat_tups): """ named_field_regex Args: keypat_tups (list): tuples of (name, pattern) or a string for an unnamed pattern Returns: str: regex Example: >>> # ENABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> keypat_...
[ "def", "named_field_regex", "(", "keypat_tups", ")", ":", "# Allow for unnamed patterns", "keypat_tups_", "=", "[", "(", "None", ",", "tup", ")", "if", "isinstance", "(", "tup", ",", "six", ".", "string_types", ")", "else", "tup", "for", "tup", "in", "keypat...
named_field_regex Args: keypat_tups (list): tuples of (name, pattern) or a string for an unnamed pattern Returns: str: regex Example: >>> # ENABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> keypat_tups = [ ... ('name', r'G\d+'), # ...
[ "named_field_regex" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L246-L277
train
Returns a regex for the named fields of a set of named patterns
Erotemic/utool
utool/util_regex.py
named_field_repl
def named_field_repl(field_list): r""" Args: field_list (list): list of either a tuples to denote a keyword, or a strings for relacement t3ext Returns: str: repl for regex Example: >>> # ENABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> f...
python
def named_field_repl(field_list): r""" Args: field_list (list): list of either a tuples to denote a keyword, or a strings for relacement t3ext Returns: str: repl for regex Example: >>> # ENABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> f...
[ "def", "named_field_repl", "(", "field_list", ")", ":", "# Allow for unnamed patterns", "bref_field_list", "=", "[", "backref_field", "(", "key", "[", "0", "]", ")", "if", "isinstance", "(", "key", ",", "tuple", ")", "else", "key", "for", "key", "in", "field...
r""" Args: field_list (list): list of either a tuples to denote a keyword, or a strings for relacement t3ext Returns: str: repl for regex Example: >>> # ENABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> field_list = [('key',), 'unspecial stri...
[ "r", "Args", ":", "field_list", "(", "list", ")", ":", "list", "of", "either", "a", "tuples", "to", "denote", "a", "keyword", "or", "a", "strings", "for", "relacement", "t3ext" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L280-L304
train
r Replaces all named keywords with unnamed patterns
Erotemic/utool
utool/util_regex.py
parse_docblock
def parse_docblock(func_code): """ #TODO: Finish me References: http://pyparsing.wikispaces.com/share/view/1264103 http://code.activestate.com/recipes/576704-python-code-minifier/ Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> import inspect >...
python
def parse_docblock(func_code): """ #TODO: Finish me References: http://pyparsing.wikispaces.com/share/view/1264103 http://code.activestate.com/recipes/576704-python-code-minifier/ Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> import inspect >...
[ "def", "parse_docblock", "(", "func_code", ")", ":", "import", "pyparsing", "doublequote_comment", "=", "pyparsing", ".", "QuotedString", "(", "quoteChar", "=", "'\"\"\"'", ",", "escChar", "=", "'\\\\'", ",", "multiline", "=", "True", ")", "singlequote_comment", ...
#TODO: Finish me References: http://pyparsing.wikispaces.com/share/view/1264103 http://code.activestate.com/recipes/576704-python-code-minifier/ Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> import inspect >>> func_code = inspect.getsource(ut.modify_...
[ "#TODO", ":", "Finish", "me" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L320-L339
train
Parse the docstring of the function.
Erotemic/utool
utool/util_regex.py
parse_python_syntax
def parse_python_syntax(text): """ step1: split lines step2: parse enclosure pairity for each line to find unended lines for each unending line, is there a valid merge line? (a line that could snytatically finish this runnon statement? If no then error. Else try to join the two lines. ste...
python
def parse_python_syntax(text): """ step1: split lines step2: parse enclosure pairity for each line to find unended lines for each unending line, is there a valid merge line? (a line that could snytatically finish this runnon statement? If no then error. Else try to join the two lines. ste...
[ "def", "parse_python_syntax", "(", "text", ")", ":", "import", "utool", "as", "ut", "def", "find_all", "(", "a_str", ",", "sub", ")", ":", "start", "=", "0", "while", "True", ":", "start", "=", "a_str", ".", "find", "(", "sub", ",", "start", ")", "...
step1: split lines step2: parse enclosure pairity for each line to find unended lines for each unending line, is there a valid merge line? (a line that could snytatically finish this runnon statement? If no then error. Else try to join the two lines. step3: perform context_sensitive_edit Exa...
[ "step1", ":", "split", "lines" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L342-L382
train
Parse the python syntax of the current language.
Erotemic/utool
utool/util_regex.py
regex_parse
def regex_parse(regex, text, fromstart=True): r""" regex_parse Args: regex (str): text (str): fromstart (bool): Returns: dict or None: Example: >>> # DISABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> regex = r'(?P<string>\'[^\']...
python
def regex_parse(regex, text, fromstart=True): r""" regex_parse Args: regex (str): text (str): fromstart (bool): Returns: dict or None: Example: >>> # DISABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> regex = r'(?P<string>\'[^\']...
[ "def", "regex_parse", "(", "regex", ",", "text", ",", "fromstart", "=", "True", ")", ":", "match", "=", "regex_get_match", "(", "regex", ",", "text", ",", "fromstart", "=", "fromstart", ")", "if", "match", "is", "not", "None", ":", "parse_dict", "=", "...
r""" regex_parse Args: regex (str): text (str): fromstart (bool): Returns: dict or None: Example: >>> # DISABLE_DOCTEST >>> from utool.util_regex import * # NOQA >>> regex = r'(?P<string>\'[^\']*\')' >>> text = " 'just' 'a' sentance wit...
[ "r", "regex_parse" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L443-L469
train
r This function parses a regex string into a dict
glormph/msstitch
src/app/drivers/peptable/merge.py
BuildPeptideTableDriver.parse_input
def parse_input(self, **kwargs): """Build peptide table has no input file (though it has a lookup), which is why we set it to outfile name so the infile fetching and outfile creating wont error.""" super().parse_input(**kwargs) self.fn = os.path.join(os.getcwd(), 'built_peptide_t...
python
def parse_input(self, **kwargs): """Build peptide table has no input file (though it has a lookup), which is why we set it to outfile name so the infile fetching and outfile creating wont error.""" super().parse_input(**kwargs) self.fn = os.path.join(os.getcwd(), 'built_peptide_t...
[ "def", "parse_input", "(", "self", ",", "*", "*", "kwargs", ")", ":", "super", "(", ")", ".", "parse_input", "(", "*", "*", "kwargs", ")", "self", ".", "fn", "=", "os", ".", "path", ".", "join", "(", "os", ".", "getcwd", "(", ")", ",", "'built_...
Build peptide table has no input file (though it has a lookup), which is why we set it to outfile name so the infile fetching and outfile creating wont error.
[ "Build", "peptide", "table", "has", "no", "input", "file", "(", "though", "it", "has", "a", "lookup", ")", "which", "is", "why", "we", "set", "it", "to", "outfile", "name", "so", "the", "infile", "fetching", "and", "outfile", "creating", "wont", "error",...
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/peptable/merge.py#L17-L27
train
This method is called when the build peptide table has no input file.
glormph/msstitch
src/app/drivers/peptable/merge.py
BuildPeptideTableDriver.set_feature_generator
def set_feature_generator(self): """Generates proteins with quant from the lookup table""" self.features = preparation.build_peptidetable(self.lookup, self.headerfields, self.isobaric, ...
python
def set_feature_generator(self): """Generates proteins with quant from the lookup table""" self.features = preparation.build_peptidetable(self.lookup, self.headerfields, self.isobaric, ...
[ "def", "set_feature_generator", "(", "self", ")", ":", "self", ".", "features", "=", "preparation", ".", "build_peptidetable", "(", "self", ".", "lookup", ",", "self", ".", "headerfields", ",", "self", ".", "isobaric", ",", "self", ".", "precursor", ",", "...
Generates proteins with quant from the lookup table
[ "Generates", "proteins", "with", "quant", "from", "the", "lookup", "table" ]
ded7e5cbd813d7797dc9d42805778266e59ff042
https://github.com/glormph/msstitch/blob/ded7e5cbd813d7797dc9d42805778266e59ff042/src/app/drivers/peptable/merge.py#L36-L43
train
Generates proteins with quant from the lookup table
timedata-org/loady
loady/library.py
clear
def clear(prompt=True, cache=None): """Clear loady's cache.""" cache = cache or config.cache() if prompt: answer = input( 'Clear library cache files in %s/? (yN) ' % cache) if not answer.startswith('y'): return False shutil.rmtree(cache, ignore_errors=True) re...
python
def clear(prompt=True, cache=None): """Clear loady's cache.""" cache = cache or config.cache() if prompt: answer = input( 'Clear library cache files in %s/? (yN) ' % cache) if not answer.startswith('y'): return False shutil.rmtree(cache, ignore_errors=True) re...
[ "def", "clear", "(", "prompt", "=", "True", ",", "cache", "=", "None", ")", ":", "cache", "=", "cache", "or", "config", ".", "cache", "(", ")", "if", "prompt", ":", "answer", "=", "input", "(", "'Clear library cache files in %s/? (yN) '", "%", "cache", "...
Clear loady's cache.
[ "Clear", "loady", "s", "cache", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/library.py#L10-L19
train
Clear loady s cache.
timedata-org/loady
loady/library.py
create
def create(gitpath, cache=None): """ Create a Library from a git path. """ if gitpath.startswith(config.LIBRARY_PREFIX): path = gitpath[len(config.LIBRARY_PREFIX):] return Library(*path.split('/'), cache=cache)
python
def create(gitpath, cache=None): """ Create a Library from a git path. """ if gitpath.startswith(config.LIBRARY_PREFIX): path = gitpath[len(config.LIBRARY_PREFIX):] return Library(*path.split('/'), cache=cache)
[ "def", "create", "(", "gitpath", ",", "cache", "=", "None", ")", ":", "if", "gitpath", ".", "startswith", "(", "config", ".", "LIBRARY_PREFIX", ")", ":", "path", "=", "gitpath", "[", "len", "(", "config", ".", "LIBRARY_PREFIX", ")", ":", "]", "return",...
Create a Library from a git path.
[ "Create", "a", "Library", "from", "a", "git", "path", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/library.py#L67-L74
train
Create a Library from a git path.
timedata-org/loady
loady/library.py
Library.pull
def pull(self): """ Pull the git repo from its origin. Can only be called after load() has been called. """ git.Repo(self.path).remote().pull(self.branch)
python
def pull(self): """ Pull the git repo from its origin. Can only be called after load() has been called. """ git.Repo(self.path).remote().pull(self.branch)
[ "def", "pull", "(", "self", ")", ":", "git", ".", "Repo", "(", "self", ".", "path", ")", ".", "remote", "(", ")", ".", "pull", "(", "self", ".", "branch", ")" ]
Pull the git repo from its origin. Can only be called after load() has been called.
[ "Pull", "the", "git", "repo", "from", "its", "origin", ".", "Can", "only", "be", "called", "after", "load", "()", "has", "been", "called", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/library.py#L42-L47
train
Pull the git repo from its origin.
timedata-org/loady
loady/library.py
Library.load
def load(self): """Load the library.""" if not git: raise EnvironmentError(MISSING_GIT_ERROR) if os.path.exists(self.path): if not config.CACHE_DISABLE: return shutil.rmtree(self.path, ignore_errors=True) with files.remove_on_exceptio...
python
def load(self): """Load the library.""" if not git: raise EnvironmentError(MISSING_GIT_ERROR) if os.path.exists(self.path): if not config.CACHE_DISABLE: return shutil.rmtree(self.path, ignore_errors=True) with files.remove_on_exceptio...
[ "def", "load", "(", "self", ")", ":", "if", "not", "git", ":", "raise", "EnvironmentError", "(", "MISSING_GIT_ERROR", ")", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "path", ")", ":", "if", "not", "config", ".", "CACHE_DISABLE", ":", "...
Load the library.
[ "Load", "the", "library", "." ]
94ffcdb92f15a28f3c85f77bd293a9cb59de4cad
https://github.com/timedata-org/loady/blob/94ffcdb92f15a28f3c85f77bd293a9cb59de4cad/loady/library.py#L49-L64
train
Load the library.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.check_existens_of_staging_tag_in_remote_repo
def check_existens_of_staging_tag_in_remote_repo(): """ This method will check, if the given tag exists as a staging tag in the remote repository. The intention is, that every tag, which should be deployed on a production envirnment, has to be deployed on a staging environment before. ...
python
def check_existens_of_staging_tag_in_remote_repo(): """ This method will check, if the given tag exists as a staging tag in the remote repository. The intention is, that every tag, which should be deployed on a production envirnment, has to be deployed on a staging environment before. ...
[ "def", "check_existens_of_staging_tag_in_remote_repo", "(", ")", ":", "staging_tag", "=", "Git", ".", "create_git_version_tag", "(", "APISettings", ".", "GIT_STAGING_PRE_TAG", ")", "command_git", "=", "'git ls-remote -t'", "command_awk", "=", "'awk \\'{print $2}\\''", "comm...
This method will check, if the given tag exists as a staging tag in the remote repository. The intention is, that every tag, which should be deployed on a production envirnment, has to be deployed on a staging environment before.
[ "This", "method", "will", "check", "if", "the", "given", "tag", "exists", "as", "a", "staging", "tag", "in", "the", "remote", "repository", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L40-L63
train
This method will check if the given tag exists as a staging tag in the remote repository.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.__debug
def __debug(command, dry=False): """ This method will be called, if the debug mode is on. """ if dry: command.append('--dry-run') Shell.debug(command) if dry: call(command) exit(1)
python
def __debug(command, dry=False): """ This method will be called, if the debug mode is on. """ if dry: command.append('--dry-run') Shell.debug(command) if dry: call(command) exit(1)
[ "def", "__debug", "(", "command", ",", "dry", "=", "False", ")", ":", "if", "dry", ":", "command", ".", "append", "(", "'--dry-run'", ")", "Shell", ".", "debug", "(", "command", ")", "if", "dry", ":", "call", "(", "command", ")", "exit", "(", "1", ...
This method will be called, if the debug mode is on.
[ "This", "method", "will", "be", "called", "if", "the", "debug", "mode", "is", "on", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L67-L78
train
This method will be called when debug mode is on.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.__git_add
def __git_add(args=''): """ Add files to staging. The function call will return 0 if the command success. """ command = ['git', 'add', '.'] Shell.msg('Adding files...') if APISettings.DEBUG: Git.__debug(command, True) for key in args: ...
python
def __git_add(args=''): """ Add files to staging. The function call will return 0 if the command success. """ command = ['git', 'add', '.'] Shell.msg('Adding files...') if APISettings.DEBUG: Git.__debug(command, True) for key in args: ...
[ "def", "__git_add", "(", "args", "=", "''", ")", ":", "command", "=", "[", "'git'", ",", "'add'", ",", "'.'", "]", "Shell", ".", "msg", "(", "'Adding files...'", ")", "if", "APISettings", ".", "DEBUG", ":", "Git", ".", "__debug", "(", "command", ",",...
Add files to staging. The function call will return 0 if the command success.
[ "Add", "files", "to", "staging", ".", "The", "function", "call", "will", "return", "0", "if", "the", "command", "success", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L83-L98
train
Add files to staging.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.__git_commit
def __git_commit(git_tag): """ Commit files to branch. The function call will return 0 if the command success. """ Shell.msg('Commit changes.') if APISettings.DEBUG: Shell.debug('Execute "git commit" in dry mode.') if not call(['git', 'commit', '-m...
python
def __git_commit(git_tag): """ Commit files to branch. The function call will return 0 if the command success. """ Shell.msg('Commit changes.') if APISettings.DEBUG: Shell.debug('Execute "git commit" in dry mode.') if not call(['git', 'commit', '-m...
[ "def", "__git_commit", "(", "git_tag", ")", ":", "Shell", ".", "msg", "(", "'Commit changes.'", ")", "if", "APISettings", ".", "DEBUG", ":", "Shell", ".", "debug", "(", "'Execute \"git commit\" in dry mode.'", ")", "if", "not", "call", "(", "[", "'git'", ","...
Commit files to branch. The function call will return 0 if the command success.
[ "Commit", "files", "to", "branch", ".", "The", "function", "call", "will", "return", "0", "if", "the", "command", "success", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L117-L131
train
Commit the changes to branch.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.__git_tag
def __git_tag(git_tag): """ Create new tag. The function call will return 0 if the command success. """ command = ['git', 'tag', '-a', git_tag, '-m', '\'' + git_tag + '\''] Shell.msg('Create tag from version ' + git_tag) if APISettings.DEBUG: Git.__de...
python
def __git_tag(git_tag): """ Create new tag. The function call will return 0 if the command success. """ command = ['git', 'tag', '-a', git_tag, '-m', '\'' + git_tag + '\''] Shell.msg('Create tag from version ' + git_tag) if APISettings.DEBUG: Git.__de...
[ "def", "__git_tag", "(", "git_tag", ")", ":", "command", "=", "[", "'git'", ",", "'tag'", ",", "'-a'", ",", "git_tag", ",", "'-m'", ",", "'\\''", "+", "git_tag", "+", "'\\''", "]", "Shell", ".", "msg", "(", "'Create tag from version '", "+", "git_tag", ...
Create new tag. The function call will return 0 if the command success.
[ "Create", "new", "tag", ".", "The", "function", "call", "will", "return", "0", "if", "the", "command", "success", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L135-L148
train
Create new tag.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.__git_tag_push
def __git_tag_push(): """ Push all tags. The function call will return 0 if the command success. """ command = ['git', 'push', 'origin', '--tags'] Shell.msg('Pushing tags...') if APISettings.DEBUG: Git.__debug(command, True) if not call(comma...
python
def __git_tag_push(): """ Push all tags. The function call will return 0 if the command success. """ command = ['git', 'push', 'origin', '--tags'] Shell.msg('Pushing tags...') if APISettings.DEBUG: Git.__debug(command, True) if not call(comma...
[ "def", "__git_tag_push", "(", ")", ":", "command", "=", "[", "'git'", ",", "'push'", ",", "'origin'", ",", "'--tags'", "]", "Shell", ".", "msg", "(", "'Pushing tags...'", ")", "if", "APISettings", ".", "DEBUG", ":", "Git", ".", "__debug", "(", "command",...
Push all tags. The function call will return 0 if the command success.
[ "Push", "all", "tags", ".", "The", "function", "call", "will", "return", "0", "if", "the", "command", "success", "." ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L169-L182
train
Push all tags.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.tag
def tag(self, deploy_tag=''): """ Function is public. Create a tag for current commit / branch. :param deploy_tag: :return: """ if APISettings.SECURE_TAGGING and deploy_tag == APISettings.GIT_ACTIVATE_PRE_TAG: if self.check_existens_of_staging_tag_in_r...
python
def tag(self, deploy_tag=''): """ Function is public. Create a tag for current commit / branch. :param deploy_tag: :return: """ if APISettings.SECURE_TAGGING and deploy_tag == APISettings.GIT_ACTIVATE_PRE_TAG: if self.check_existens_of_staging_tag_in_r...
[ "def", "tag", "(", "self", ",", "deploy_tag", "=", "''", ")", ":", "if", "APISettings", ".", "SECURE_TAGGING", "and", "deploy_tag", "==", "APISettings", ".", "GIT_ACTIVATE_PRE_TAG", ":", "if", "self", ".", "check_existens_of_staging_tag_in_remote_repo", "(", ")", ...
Function is public. Create a tag for current commit / branch. :param deploy_tag: :return:
[ "Function", "is", "public", ".", "Create", "a", "tag", "for", "current", "commit", "/", "branch", ".", ":", "param", "deploy_tag", ":", ":", "return", ":" ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L255-L271
train
Function is public. This function is public.
rhazdon/django-sonic-screwdriver
django_sonic_screwdriver/git/git.py
Git.tag_delete
def tag_delete(self, tag): """ Function is public. Push tags. :return: """ if tag: if self.__git_tag_delete(tag): return True return False if self.__git_tag_delete(self.get_latest_tag()): return True ret...
python
def tag_delete(self, tag): """ Function is public. Push tags. :return: """ if tag: if self.__git_tag_delete(tag): return True return False if self.__git_tag_delete(self.get_latest_tag()): return True ret...
[ "def", "tag_delete", "(", "self", ",", "tag", ")", ":", "if", "tag", ":", "if", "self", ".", "__git_tag_delete", "(", "tag", ")", ":", "return", "True", "return", "False", "if", "self", ".", "__git_tag_delete", "(", "self", ".", "get_latest_tag", "(", ...
Function is public. Push tags. :return:
[ "Function", "is", "public", ".", "Push", "tags", ".", ":", "return", ":" ]
89e885e8c1322fc5c3e0f79b03a55acdc6e63972
https://github.com/rhazdon/django-sonic-screwdriver/blob/89e885e8c1322fc5c3e0f79b03a55acdc6e63972/django_sonic_screwdriver/git/git.py#L283-L296
train
Function is public. Tag delete.
YuriyGuts/pygoose
pygoose/kg/jobs.py
split_into_batches
def split_into_batches(input_list, batch_size, batch_storage_dir, checkpoint=False): """ Break the input data into smaller batches, optionally saving each one to disk. Args: input_list: An input object that has a list-like interface (indexing and slicing). batch_size: The maximum number of ...
python
def split_into_batches(input_list, batch_size, batch_storage_dir, checkpoint=False): """ Break the input data into smaller batches, optionally saving each one to disk. Args: input_list: An input object that has a list-like interface (indexing and slicing). batch_size: The maximum number of ...
[ "def", "split_into_batches", "(", "input_list", ",", "batch_size", ",", "batch_storage_dir", ",", "checkpoint", "=", "False", ")", ":", "if", "checkpoint", "and", "not", "os", ".", "path", ".", "exists", "(", "batch_storage_dir", ")", ":", "os", ".", "mkdir"...
Break the input data into smaller batches, optionally saving each one to disk. Args: input_list: An input object that has a list-like interface (indexing and slicing). batch_size: The maximum number of input items in each batch. batch_storage_dir: The directory to save the checkpoints to. ...
[ "Break", "the", "input", "data", "into", "smaller", "batches", "optionally", "saving", "each", "one", "to", "disk", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/jobs.py#L16-L48
train
Splits the input data into smaller batches.
YuriyGuts/pygoose
pygoose/kg/jobs.py
map_embarrassingly_parallel
def map_embarrassingly_parallel(input_list, mapper, project, n_jobs=-1, batch_size=-1, checkpoint=False, cleanup=True, **kwargs): """ Process items in a list in parallel (optionally, one smaller batch at a time). Args: input_list: An input object that has a list-like...
python
def map_embarrassingly_parallel(input_list, mapper, project, n_jobs=-1, batch_size=-1, checkpoint=False, cleanup=True, **kwargs): """ Process items in a list in parallel (optionally, one smaller batch at a time). Args: input_list: An input object that has a list-like...
[ "def", "map_embarrassingly_parallel", "(", "input_list", ",", "mapper", ",", "project", ",", "n_jobs", "=", "-", "1", ",", "batch_size", "=", "-", "1", ",", "checkpoint", "=", "False", ",", "cleanup", "=", "True", ",", "*", "*", "kwargs", ")", ":", "if...
Process items in a list in parallel (optionally, one smaller batch at a time). Args: input_list: An input object that has a list-like interface (indexing and slicing). mapper: A function to apply to each item of the input list. project: An instance of pygoose project. n_jobs: The nu...
[ "Process", "items", "in", "a", "list", "in", "parallel", "(", "optionally", "one", "smaller", "batch", "at", "a", "time", ")", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/jobs.py#L51-L107
train
This function processes the items in a list in parallel and returns a list of the combined output.
YuriyGuts/pygoose
pygoose/kg/jobs.py
map_batch_parallel
def map_batch_parallel(input_list, batch_size, item_mapper=None, batch_mapper=None, flatten=True, n_jobs=-1, **kwargs): """ Split the data into batches and process each batch in its own thread. Args: input_list: An input object that has a list-like interface (indexing and slicing). item_map...
python
def map_batch_parallel(input_list, batch_size, item_mapper=None, batch_mapper=None, flatten=True, n_jobs=-1, **kwargs): """ Split the data into batches and process each batch in its own thread. Args: input_list: An input object that has a list-like interface (indexing and slicing). item_map...
[ "def", "map_batch_parallel", "(", "input_list", ",", "batch_size", ",", "item_mapper", "=", "None", ",", "batch_mapper", "=", "None", ",", "flatten", "=", "True", ",", "n_jobs", "=", "-", "1", ",", "*", "*", "kwargs", ")", ":", "# We must specify either how ...
Split the data into batches and process each batch in its own thread. Args: input_list: An input object that has a list-like interface (indexing and slicing). item_mapper: (optional) A function to apply to each item in the batch. batch_mapper: (optional) A function to apply to each batch. E...
[ "Split", "the", "data", "into", "batches", "and", "process", "each", "batch", "in", "its", "own", "thread", "." ]
4d9b8827c6d6c4b79949d1cd653393498c0bb3c2
https://github.com/YuriyGuts/pygoose/blob/4d9b8827c6d6c4b79949d1cd653393498c0bb3c2/pygoose/kg/jobs.py#L110-L153
train
Map a list of items into a single list of items in a single thread.
anayjoshi/platypus
platypus/cfg/ast_to_cfg.py
get_cfg
def get_cfg(ast_func): """ Traverses the AST and returns the corresponding CFG :param ast_func: The AST representation of function :type ast_func: ast.Function :returns: The CFG representation of the function :rtype: cfg.Function """ cfg_func = cfg.Function() for ast_var in ast_fun...
python
def get_cfg(ast_func): """ Traverses the AST and returns the corresponding CFG :param ast_func: The AST representation of function :type ast_func: ast.Function :returns: The CFG representation of the function :rtype: cfg.Function """ cfg_func = cfg.Function() for ast_var in ast_fun...
[ "def", "get_cfg", "(", "ast_func", ")", ":", "cfg_func", "=", "cfg", ".", "Function", "(", ")", "for", "ast_var", "in", "ast_func", ".", "input_variable_list", ":", "cfg_var", "=", "cfg_func", ".", "get_variable", "(", "ast_var", ".", "name", ")", "cfg_fun...
Traverses the AST and returns the corresponding CFG :param ast_func: The AST representation of function :type ast_func: ast.Function :returns: The CFG representation of the function :rtype: cfg.Function
[ "Traverses", "the", "AST", "and", "returns", "the", "corresponding", "CFG" ]
71712f58c99651efbd2e6dfd75a9b1228d42e9ef
https://github.com/anayjoshi/platypus/blob/71712f58c99651efbd2e6dfd75a9b1228d42e9ef/platypus/cfg/ast_to_cfg.py#L4-L28
train
This function traverses the AST and returns the corresponding CFG
Erotemic/utool
utool/util_dev.py
overrideable_partial
def overrideable_partial(func, *args, **default_kwargs): """ like partial, but given kwargs can be overrideden at calltime """ import functools @functools.wraps(func) def partial_wrapper(*given_args, **given_kwargs): kwargs = default_kwargs.copy() kwargs.update(given_kwargs) retu...
python
def overrideable_partial(func, *args, **default_kwargs): """ like partial, but given kwargs can be overrideden at calltime """ import functools @functools.wraps(func) def partial_wrapper(*given_args, **given_kwargs): kwargs = default_kwargs.copy() kwargs.update(given_kwargs) retu...
[ "def", "overrideable_partial", "(", "func", ",", "*", "args", ",", "*", "*", "default_kwargs", ")", ":", "import", "functools", "@", "functools", ".", "wraps", "(", "func", ")", "def", "partial_wrapper", "(", "*", "given_args", ",", "*", "*", "given_kwargs...
like partial, but given kwargs can be overrideden at calltime
[ "like", "partial", "but", "given", "kwargs", "can", "be", "overrideden", "at", "calltime" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L40-L48
train
like partial but given kwargs can be overrideden at calltime
Erotemic/utool
utool/util_dev.py
get_nonconflicting_string
def get_nonconflicting_string(base_fmtstr, conflict_set, offset=0): """ gets a new string that wont conflict with something that already exists Args: base_fmtstr (str): conflict_set (set): CommandLine: python -m utool.util_dev --test-get_nonconflicting_string Example: ...
python
def get_nonconflicting_string(base_fmtstr, conflict_set, offset=0): """ gets a new string that wont conflict with something that already exists Args: base_fmtstr (str): conflict_set (set): CommandLine: python -m utool.util_dev --test-get_nonconflicting_string Example: ...
[ "def", "get_nonconflicting_string", "(", "base_fmtstr", ",", "conflict_set", ",", "offset", "=", "0", ")", ":", "# Infinite loop until we find a non-conflict", "conflict_set_", "=", "set", "(", "conflict_set", ")", "for", "count", "in", "it", ".", "count", "(", "o...
gets a new string that wont conflict with something that already exists Args: base_fmtstr (str): conflict_set (set): CommandLine: python -m utool.util_dev --test-get_nonconflicting_string Example: >>> # ENABLE_DOCTEST >>> from utool.util_dev import * # NOQA ...
[ "gets", "a", "new", "string", "that", "wont", "conflict", "with", "something", "that", "already", "exists" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L147-L175
train
Get a new string that doesn t conflict with something that already exists in the set
Erotemic/utool
utool/util_dev.py
get_nonconflicting_path_old
def get_nonconflicting_path_old(base_fmtstr, dpath, offset=0): r""" base_fmtstr must have a %d in it """ import utool as ut from os.path import basename pattern = '*' dname_list = ut.glob(dpath, pattern, recursive=False, with_files=True, with_dirs=True) co...
python
def get_nonconflicting_path_old(base_fmtstr, dpath, offset=0): r""" base_fmtstr must have a %d in it """ import utool as ut from os.path import basename pattern = '*' dname_list = ut.glob(dpath, pattern, recursive=False, with_files=True, with_dirs=True) co...
[ "def", "get_nonconflicting_path_old", "(", "base_fmtstr", ",", "dpath", ",", "offset", "=", "0", ")", ":", "import", "utool", "as", "ut", "from", "os", ".", "path", "import", "basename", "pattern", "=", "'*'", "dname_list", "=", "ut", ".", "glob", "(", "...
r""" base_fmtstr must have a %d in it
[ "r", "base_fmtstr", "must", "have", "a", "%d", "in", "it" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L178-L193
train
r Returns the path to the non - conflicting file in the given base_fmtstr.
Erotemic/utool
utool/util_dev.py
input_timeout
def input_timeout(msg='Waiting for input...', timeout=30): """ FIXME: Function does not work quite right yet. Args: msg (str): timeout (int): Returns: ?: ans References: http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python http:/...
python
def input_timeout(msg='Waiting for input...', timeout=30): """ FIXME: Function does not work quite right yet. Args: msg (str): timeout (int): Returns: ?: ans References: http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python http:/...
[ "def", "input_timeout", "(", "msg", "=", "'Waiting for input...'", ",", "timeout", "=", "30", ")", ":", "import", "sys", "import", "select", "import", "time", "ans", "=", "None", "print", "(", "'You have %d seconds to answer!'", "%", "timeout", ")", "print", "...
FIXME: Function does not work quite right yet. Args: msg (str): timeout (int): Returns: ?: ans References: http://stackoverflow.com/questions/1335507/keyboard-input-with-timeout-in-python http://home.wlu.edu/~levys/software/kbhit.py http://stackoverflow.com...
[ "FIXME", ":", "Function", "does", "not", "work", "quite", "right", "yet", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L196-L248
train
Function to wait for input and return the next available keyboard key.
Erotemic/utool
utool/util_dev.py
timeit_grid
def timeit_grid(stmt_list, setup='', iterations=10000, input_sizes=None, verbose=True, show=False): """ Timeit:: import utool as ut setup = ut.codeblock( ''' import utool as ut from six.moves import range, zip import time ...
python
def timeit_grid(stmt_list, setup='', iterations=10000, input_sizes=None, verbose=True, show=False): """ Timeit:: import utool as ut setup = ut.codeblock( ''' import utool as ut from six.moves import range, zip import time ...
[ "def", "timeit_grid", "(", "stmt_list", ",", "setup", "=", "''", ",", "iterations", "=", "10000", ",", "input_sizes", "=", "None", ",", "verbose", "=", "True", ",", "show", "=", "False", ")", ":", "import", "timeit", "#iterations = timeit.default_number", "i...
Timeit:: import utool as ut setup = ut.codeblock( ''' import utool as ut from six.moves import range, zip import time def time_append(size): start_time = time.time() last_time = start_time ...
[ "Timeit", "::", "import", "utool", "as", "ut", "setup", "=", "ut", ".", "codeblock", "(", "import", "utool", "as", "ut", "from", "six", ".", "moves", "import", "range", "zip", "import", "time", "def", "time_append", "(", "size", ")", ":", "start_time", ...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L261-L335
train
Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit - > Timeit
Erotemic/utool
utool/util_dev.py
timeit_compare
def timeit_compare(stmt_list, setup='', iterations=100000, verbose=True, strict=False, assertsame=True): """ Compares several statments by timing them and also checks that they have the same return value Args: stmt_list (list) : list of statments to compare setup (str...
python
def timeit_compare(stmt_list, setup='', iterations=100000, verbose=True, strict=False, assertsame=True): """ Compares several statments by timing them and also checks that they have the same return value Args: stmt_list (list) : list of statments to compare setup (str...
[ "def", "timeit_compare", "(", "stmt_list", ",", "setup", "=", "''", ",", "iterations", "=", "100000", ",", "verbose", "=", "True", ",", "strict", "=", "False", ",", "assertsame", "=", "True", ")", ":", "import", "timeit", "import", "utool", "as", "ut", ...
Compares several statments by timing them and also checks that they have the same return value Args: stmt_list (list) : list of statments to compare setup (str) : iterations (int) : verbose (bool) : strict (bool) : Returns: tuple (bool, list, list) : (passed...
[ "Compares", "several", "statments", "by", "timing", "them", "and", "also", "checks", "that", "they", "have", "the", "same", "return", "value" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L360-L489
train
This function is used to compare several statments by timing them and then checking that they have the same value
Erotemic/utool
utool/util_dev.py
memory_dump
def memory_dump(): """ References: http://stackoverflow.com/questions/141351/how-do-i-find-what-is-using-memory-in-a-python-process-in-a-production-system """ import cPickle dump = open("memory.pickle", 'w') for obj in gc.get_objects(): i = id(obj) size = sys.getsizeof(obj...
python
def memory_dump(): """ References: http://stackoverflow.com/questions/141351/how-do-i-find-what-is-using-memory-in-a-python-process-in-a-production-system """ import cPickle dump = open("memory.pickle", 'w') for obj in gc.get_objects(): i = id(obj) size = sys.getsizeof(obj...
[ "def", "memory_dump", "(", ")", ":", "import", "cPickle", "dump", "=", "open", "(", "\"memory.pickle\"", ",", "'w'", ")", "for", "obj", "in", "gc", ".", "get_objects", "(", ")", ":", "i", "=", "id", "(", "obj", ")", "size", "=", "sys", ".", "getsiz...
References: http://stackoverflow.com/questions/141351/how-do-i-find-what-is-using-memory-in-a-python-process-in-a-production-system
[ "References", ":", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "141351", "/", "how", "-", "do", "-", "i", "-", "find", "-", "what", "-", "is", "-", "using", "-", "memory", "-", "in", "-", "a", "-", "python", "-", "proce...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L517-L531
train
Dump the memory of the objects in the .
Erotemic/utool
utool/util_dev.py
are_you_sure
def are_you_sure(msg=''): r""" Prompts user to accept or checks command line for -y Args: msg (str): Returns: bool: accept or not """ print(msg) from utool import util_arg from utool import util_str override = util_arg.get_argflag(('--yes', '--y', '-y')) if over...
python
def are_you_sure(msg=''): r""" Prompts user to accept or checks command line for -y Args: msg (str): Returns: bool: accept or not """ print(msg) from utool import util_arg from utool import util_str override = util_arg.get_argflag(('--yes', '--y', '-y')) if over...
[ "def", "are_you_sure", "(", "msg", "=", "''", ")", ":", "print", "(", "msg", ")", "from", "utool", "import", "util_arg", "from", "utool", "import", "util_str", "override", "=", "util_arg", ".", "get_argflag", "(", "(", "'--yes'", ",", "'--y'", ",", "'-y'...
r""" Prompts user to accept or checks command line for -y Args: msg (str): Returns: bool: accept or not
[ "r", "Prompts", "user", "to", "accept", "or", "checks", "command", "line", "for", "-", "y" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1170-L1190
train
r Prompts user to accept or checks command line for - y
Erotemic/utool
utool/util_dev.py
grace_period
def grace_period(msg='', seconds=10): """ Gives user a window to stop a process before it happens """ import time print(msg) override = util_arg.get_argflag(('--yes', '--y', '-y')) print('starting grace period') if override: print('ending based on command line flag') retu...
python
def grace_period(msg='', seconds=10): """ Gives user a window to stop a process before it happens """ import time print(msg) override = util_arg.get_argflag(('--yes', '--y', '-y')) print('starting grace period') if override: print('ending based on command line flag') retu...
[ "def", "grace_period", "(", "msg", "=", "''", ",", "seconds", "=", "10", ")", ":", "import", "time", "print", "(", "msg", ")", "override", "=", "util_arg", ".", "get_argflag", "(", "(", "'--yes'", ",", "'--y'", ",", "'-y'", ")", ")", "print", "(", ...
Gives user a window to stop a process before it happens
[ "Gives", "user", "a", "window", "to", "stop", "a", "process", "before", "it", "happens" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1193-L1209
train
Gives user a window to stop a process before it happens
Erotemic/utool
utool/util_dev.py
delayed_retry_gen
def delayed_retry_gen(delay_schedule=[.1, 1, 10], msg=None, timeout=None, raise_=True): """ template code for a infinte retry loop """ import utool as ut import time if not ut.isiterable(delay_schedule): delay_schedule = [delay_schedule] tt = ut.tic() # First attempt is immediate yi...
python
def delayed_retry_gen(delay_schedule=[.1, 1, 10], msg=None, timeout=None, raise_=True): """ template code for a infinte retry loop """ import utool as ut import time if not ut.isiterable(delay_schedule): delay_schedule = [delay_schedule] tt = ut.tic() # First attempt is immediate yi...
[ "def", "delayed_retry_gen", "(", "delay_schedule", "=", "[", ".1", ",", "1", ",", "10", "]", ",", "msg", "=", "None", ",", "timeout", "=", "None", ",", "raise_", "=", "True", ")", ":", "import", "utool", "as", "ut", "import", "time", "if", "not", "...
template code for a infinte retry loop
[ "template", "code", "for", "a", "infinte", "retry", "loop" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1212-L1233
train
generator function for delayed retry loop
Erotemic/utool
utool/util_dev.py
get_jagged_stats
def get_jagged_stats(arr_list, **kwargs): r""" Args: arr_list (list): Returns: dict: stats_dict CommandLine: python -m utool.util_dev --test-get_jagged_stats Example: >>> # DISABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> import utool as...
python
def get_jagged_stats(arr_list, **kwargs): r""" Args: arr_list (list): Returns: dict: stats_dict CommandLine: python -m utool.util_dev --test-get_jagged_stats Example: >>> # DISABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> import utool as...
[ "def", "get_jagged_stats", "(", "arr_list", ",", "*", "*", "kwargs", ")", ":", "import", "functools", "stats_dict_list", "=", "list", "(", "map", "(", "functools", ".", "partial", "(", "get_stats", ",", "*", "*", "kwargs", ")", ",", "arr_list", ")", ")",...
r""" Args: arr_list (list): Returns: dict: stats_dict CommandLine: python -m utool.util_dev --test-get_jagged_stats Example: >>> # DISABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> import utool as ut >>> kwargs = dict(use_nan=True) ...
[ "r", "Args", ":", "arr_list", "(", "list", ")", ":" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1248-L1285
train
r Returns a dictionary of stats for a list of jagged ones
Erotemic/utool
utool/util_dev.py
get_stats
def get_stats(list_, axis=None, use_nan=False, use_sum=False, use_median=False, size=False): """ Args: list_ (listlike): values to get statistics of axis (int): if `list_` is ndarray then this specifies the axis Returns: OrderedDict: stats: dictionary of common numpy s...
python
def get_stats(list_, axis=None, use_nan=False, use_sum=False, use_median=False, size=False): """ Args: list_ (listlike): values to get statistics of axis (int): if `list_` is ndarray then this specifies the axis Returns: OrderedDict: stats: dictionary of common numpy s...
[ "def", "get_stats", "(", "list_", ",", "axis", "=", "None", ",", "use_nan", "=", "False", ",", "use_sum", "=", "False", ",", "use_median", "=", "False", ",", "size", "=", "False", ")", ":", "datacast", "=", "np", ".", "float32", "# Assure input is in num...
Args: list_ (listlike): values to get statistics of axis (int): if `list_` is ndarray then this specifies the axis Returns: OrderedDict: stats: dictionary of common numpy statistics (min, max, mean, std, nMin, nMax, shape) SeeAlso: get_stats_str CommandLine: ...
[ "Args", ":", "list_", "(", "listlike", ")", ":", "values", "to", "get", "statistics", "of", "axis", "(", "int", ")", ":", "if", "list_", "is", "ndarray", "then", "this", "specifies", "the", "axis" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1288-L1387
train
Get statistics of a set of items in a single level of the tree
Erotemic/utool
utool/util_dev.py
get_stats_str
def get_stats_str(list_=None, newlines=False, keys=None, exclude_keys=[], lbl=None, precision=None, axis=0, stat_dict=None, use_nan=False, align=False, use_median=False, **kwargs): """ Returns the string version of get_stats DEPRICATE in favor of ut.repr3(ut.get_stats(.....
python
def get_stats_str(list_=None, newlines=False, keys=None, exclude_keys=[], lbl=None, precision=None, axis=0, stat_dict=None, use_nan=False, align=False, use_median=False, **kwargs): """ Returns the string version of get_stats DEPRICATE in favor of ut.repr3(ut.get_stats(.....
[ "def", "get_stats_str", "(", "list_", "=", "None", ",", "newlines", "=", "False", ",", "keys", "=", "None", ",", "exclude_keys", "=", "[", "]", ",", "lbl", "=", "None", ",", "precision", "=", "None", ",", "axis", "=", "0", ",", "stat_dict", "=", "N...
Returns the string version of get_stats DEPRICATE in favor of ut.repr3(ut.get_stats(...)) if keys is not None then it only displays chosen keys excluded keys are always removed CommandLine: python -m utool.util_dev --test-get_stats_str Example: >>> # ENABLE_DOCTEST >>> f...
[ "Returns", "the", "string", "version", "of", "get_stats" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1430-L1520
train
Returns a string version of get_stats_str
Erotemic/utool
utool/util_dev.py
make_call_graph
def make_call_graph(func, *args, **kwargs): """ profile with pycallgraph Example: pycallgraph graphviz -- ./mypythonscript.py References: http://pycallgraph.slowchop.com/en/master/ """ from pycallgraph import PyCallGraph from pycallgraph.output import GraphvizOutput with Py...
python
def make_call_graph(func, *args, **kwargs): """ profile with pycallgraph Example: pycallgraph graphviz -- ./mypythonscript.py References: http://pycallgraph.slowchop.com/en/master/ """ from pycallgraph import PyCallGraph from pycallgraph.output import GraphvizOutput with Py...
[ "def", "make_call_graph", "(", "func", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "from", "pycallgraph", "import", "PyCallGraph", "from", "pycallgraph", ".", "output", "import", "GraphvizOutput", "with", "PyCallGraph", "(", "output", "=", "GraphvizOu...
profile with pycallgraph Example: pycallgraph graphviz -- ./mypythonscript.py References: http://pycallgraph.slowchop.com/en/master/
[ "profile", "with", "pycallgraph" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1549-L1561
train
Profile with pycallgraph
Erotemic/utool
utool/util_dev.py
_memory_profile
def _memory_profile(with_gc=False): """ Helper for memory debugging. Mostly just a namespace where I experiment with guppy and heapy. References: http://stackoverflow.com/questions/2629680/deciding-between-subprocess-multiprocessing-and-thread-in-python Reset Numpy Memory:: %reset ...
python
def _memory_profile(with_gc=False): """ Helper for memory debugging. Mostly just a namespace where I experiment with guppy and heapy. References: http://stackoverflow.com/questions/2629680/deciding-between-subprocess-multiprocessing-and-thread-in-python Reset Numpy Memory:: %reset ...
[ "def", "_memory_profile", "(", "with_gc", "=", "False", ")", ":", "import", "utool", "as", "ut", "if", "with_gc", ":", "garbage_collect", "(", ")", "import", "guppy", "hp", "=", "guppy", ".", "hpy", "(", ")", "print", "(", "'[hpy] Waiting for heap output...'...
Helper for memory debugging. Mostly just a namespace where I experiment with guppy and heapy. References: http://stackoverflow.com/questions/2629680/deciding-between-subprocess-multiprocessing-and-thread-in-python Reset Numpy Memory:: %reset out %reset array
[ "Helper", "for", "memory", "debugging", ".", "Mostly", "just", "a", "namespace", "where", "I", "experiment", "with", "guppy", "and", "heapy", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1586-L1607
train
Helper for memory debugging.
Erotemic/utool
utool/util_dev.py
make_object_graph
def make_object_graph(obj, fpath='sample_graph.png'): """ memoryprofile with objgraph Examples: #import objgraph #objgraph.show_most_common_types() #objgraph.show_growth() #memtrack.report() #memtrack.report() #objgraph.show_growth() #import gc #g...
python
def make_object_graph(obj, fpath='sample_graph.png'): """ memoryprofile with objgraph Examples: #import objgraph #objgraph.show_most_common_types() #objgraph.show_growth() #memtrack.report() #memtrack.report() #objgraph.show_growth() #import gc #g...
[ "def", "make_object_graph", "(", "obj", ",", "fpath", "=", "'sample_graph.png'", ")", ":", "import", "objgraph", "objgraph", ".", "show_most_common_types", "(", ")", "#print(objgraph.by_type('ndarray'))", "#objgraph.find_backref_chain(", "# random.choice(objgraph.by_type('n...
memoryprofile with objgraph Examples: #import objgraph #objgraph.show_most_common_types() #objgraph.show_growth() #memtrack.report() #memtrack.report() #objgraph.show_growth() #import gc #gc.collect() #memtrack.report() #y = 0 ...
[ "memoryprofile", "with", "objgraph" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1612-L1640
train
Make a memoryprofile with objgraph.
Erotemic/utool
utool/util_dev.py
get_object_nbytes
def get_object_nbytes(obj, fallback_type=None, follow_pointers=False, exclude_modules=True, listoverhead=False): """ CommandLine: python -m utool.util_dev --test-get_object_nbytes python -m utool.util_dev --test-get_object_nbytes:1 Example: >>> # ENABLE_DOCTEST >>> from utoo...
python
def get_object_nbytes(obj, fallback_type=None, follow_pointers=False, exclude_modules=True, listoverhead=False): """ CommandLine: python -m utool.util_dev --test-get_object_nbytes python -m utool.util_dev --test-get_object_nbytes:1 Example: >>> # ENABLE_DOCTEST >>> from utoo...
[ "def", "get_object_nbytes", "(", "obj", ",", "fallback_type", "=", "None", ",", "follow_pointers", "=", "False", ",", "exclude_modules", "=", "True", ",", "listoverhead", "=", "False", ")", ":", "import", "utool", "as", "ut", "import", "types", "seen", "=", ...
CommandLine: python -m utool.util_dev --test-get_object_nbytes python -m utool.util_dev --test-get_object_nbytes:1 Example: >>> # ENABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> import numpy as np >>> import utool as ut >>> obj = [np.empty(1, dtyp...
[ "CommandLine", ":", "python", "-", "m", "utool", ".", "util_dev", "--", "test", "-", "get_object_nbytes", "python", "-", "m", "utool", ".", "util_dev", "--", "test", "-", "get_object_nbytes", ":", "1" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1655-L1771
train
Get the size of the object in a single page.
Erotemic/utool
utool/util_dev.py
print_object_size_tree
def print_object_size_tree(obj, lbl='obj', maxdepth=None): """ Needs work """ from utool import util_str from utool import util_type byte_str2 = util_str.byte_str2 def _get_object_size_tree(obj, depth=0, lbl='obj', seen=None): indent = ' ' * (depth * 4) if maxdepth is not None and ...
python
def print_object_size_tree(obj, lbl='obj', maxdepth=None): """ Needs work """ from utool import util_str from utool import util_type byte_str2 = util_str.byte_str2 def _get_object_size_tree(obj, depth=0, lbl='obj', seen=None): indent = ' ' * (depth * 4) if maxdepth is not None and ...
[ "def", "print_object_size_tree", "(", "obj", ",", "lbl", "=", "'obj'", ",", "maxdepth", "=", "None", ")", ":", "from", "utool", "import", "util_str", "from", "utool", "import", "util_type", "byte_str2", "=", "util_str", ".", "byte_str2", "def", "_get_object_si...
Needs work
[ "Needs", "work" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1774-L1828
train
Recursively print the size of the object in a tree
Erotemic/utool
utool/util_dev.py
compile_cython
def compile_cython(fpath, clean=True): r""" Compiles a cython pyx into a shared library This seems broken compiles pyx -> pyd/dylib/so Examples: REAL SETUP.PY OUTPUT cythoning vtool/linalg_cython.pyx to vtool\linalg_cython.c C:\MinGW\bin\gcc.exe -mdll -O -Wall ^ -IC:\Py...
python
def compile_cython(fpath, clean=True): r""" Compiles a cython pyx into a shared library This seems broken compiles pyx -> pyd/dylib/so Examples: REAL SETUP.PY OUTPUT cythoning vtool/linalg_cython.pyx to vtool\linalg_cython.c C:\MinGW\bin\gcc.exe -mdll -O -Wall ^ -IC:\Py...
[ "def", "compile_cython", "(", "fpath", ",", "clean", "=", "True", ")", ":", "from", "utool", "import", "util_cplat", "from", "utool", "import", "util_path", "import", "utool", "# Get autogenerated filenames", "fpath", "=", "util_path", ".", "truepath", "(", "fpa...
r""" Compiles a cython pyx into a shared library This seems broken compiles pyx -> pyd/dylib/so Examples: REAL SETUP.PY OUTPUT cythoning vtool/linalg_cython.pyx to vtool\linalg_cython.c C:\MinGW\bin\gcc.exe -mdll -O -Wall ^ -IC:\Python27\Lib\site-packages\numpy\core\include...
[ "r", "Compiles", "a", "cython", "pyx", "into", "a", "shared", "library" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1888-L2055
train
r Compiles a cython pyx into a shared library
Erotemic/utool
utool/util_dev.py
make_at_least_n_items_valid
def make_at_least_n_items_valid(flag_list, n): """ tries to make at least min(len(flag_list, n) items True in flag_list Args: flag_list (list): list of booleans n (int): number of items to ensure are True CommandLine: python -m utool.util_dev --test-make_at_least_n_items_valid ...
python
def make_at_least_n_items_valid(flag_list, n): """ tries to make at least min(len(flag_list, n) items True in flag_list Args: flag_list (list): list of booleans n (int): number of items to ensure are True CommandLine: python -m utool.util_dev --test-make_at_least_n_items_valid ...
[ "def", "make_at_least_n_items_valid", "(", "flag_list", ",", "n", ")", ":", "flag_list", "=", "np", ".", "array", "(", "flag_list", ")", "num_valid", "=", "flag_list", ".", "sum", "(", ")", "# Find how many places we need to make true", "num_extra", "=", "min", ...
tries to make at least min(len(flag_list, n) items True in flag_list Args: flag_list (list): list of booleans n (int): number of items to ensure are True CommandLine: python -m utool.util_dev --test-make_at_least_n_items_valid Example: >>> # ENABLE_DOCTEST >>> from...
[ "tries", "to", "make", "at", "least", "min", "(", "len", "(", "flag_list", "n", ")", "items", "True", "in", "flag_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2111-L2147
train
This function tries to make at least n items True in flag_list and returns a list of booleans that are True in flag_list
Erotemic/utool
utool/util_dev.py
inverable_unique_two_lists
def inverable_unique_two_lists(item1_list, item2_list): """ item1_list = aid1_list item2_list = aid2_list """ import utool as ut unique_list1, inverse1 = np.unique(item1_list, return_inverse=True) unique_list2, inverse2 = np.unique(item2_list, return_inverse=True) flat_stacked, cumsum =...
python
def inverable_unique_two_lists(item1_list, item2_list): """ item1_list = aid1_list item2_list = aid2_list """ import utool as ut unique_list1, inverse1 = np.unique(item1_list, return_inverse=True) unique_list2, inverse2 = np.unique(item2_list, return_inverse=True) flat_stacked, cumsum =...
[ "def", "inverable_unique_two_lists", "(", "item1_list", ",", "item2_list", ")", ":", "import", "utool", "as", "ut", "unique_list1", ",", "inverse1", "=", "np", ".", "unique", "(", "item1_list", ",", "return_inverse", "=", "True", ")", "unique_list2", ",", "inv...
item1_list = aid1_list item2_list = aid2_list
[ "item1_list", "=", "aid1_list", "item2_list", "=", "aid2_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2151-L2163
train
returns a tuple of unique items in the order of the items in the item1_list and item2_list
Erotemic/utool
utool/util_dev.py
uninvert_unique_two_lists
def uninvert_unique_two_lists(flat_list, reconstruct_tup): """ flat_list = thumb_list """ import utool as ut (inverse3, cumsum, inverse2, inverse1) = reconstruct_tup flat_stacked_ = ut.take(flat_list, inverse3) unique_list1_, unique_list2_ = ut.unflatten2(flat_stacked_, cumsum) res_list1...
python
def uninvert_unique_two_lists(flat_list, reconstruct_tup): """ flat_list = thumb_list """ import utool as ut (inverse3, cumsum, inverse2, inverse1) = reconstruct_tup flat_stacked_ = ut.take(flat_list, inverse3) unique_list1_, unique_list2_ = ut.unflatten2(flat_stacked_, cumsum) res_list1...
[ "def", "uninvert_unique_two_lists", "(", "flat_list", ",", "reconstruct_tup", ")", ":", "import", "utool", "as", "ut", "(", "inverse3", ",", "cumsum", ",", "inverse2", ",", "inverse1", ")", "=", "reconstruct_tup", "flat_stacked_", "=", "ut", ".", "take", "(", ...
flat_list = thumb_list
[ "flat_list", "=", "thumb_list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2166-L2176
train
uninvert unique two lists
Erotemic/utool
utool/util_dev.py
inverable_group_multi_list
def inverable_group_multi_list(item_lists): """ aid_list1 = np.array([1, 1, 2, 2, 3, 3]) aid2_list = np.array([4, 2, 1, 9, 8, 7]) item_lists = (np.array(aid1_list), np.array(aid2_list)) """ #unique_list1, inverse1 = np.unique(item1_list, return_index=True, return_inverse=True) import vtool a...
python
def inverable_group_multi_list(item_lists): """ aid_list1 = np.array([1, 1, 2, 2, 3, 3]) aid2_list = np.array([4, 2, 1, 9, 8, 7]) item_lists = (np.array(aid1_list), np.array(aid2_list)) """ #unique_list1, inverse1 = np.unique(item1_list, return_index=True, return_inverse=True) import vtool a...
[ "def", "inverable_group_multi_list", "(", "item_lists", ")", ":", "#unique_list1, inverse1 = np.unique(item1_list, return_index=True, return_inverse=True)", "import", "vtool", "as", "vt", "import", "utool", "as", "ut", "# Find uniques and groups in each individual list", "unique_list...
aid_list1 = np.array([1, 1, 2, 2, 3, 3]) aid2_list = np.array([4, 2, 1, 9, 8, 7]) item_lists = (np.array(aid1_list), np.array(aid2_list))
[ "aid_list1", "=", "np", ".", "array", "(", "[", "1", "1", "2", "2", "3", "3", "]", ")", "aid2_list", "=", "np", ".", "array", "(", "[", "4", "2", "1", "9", "8", "7", "]", ")", "item_lists", "=", "(", "np", ".", "array", "(", "aid1_list", ")...
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2179-L2206
train
This function takes a list of item lists and returns a list of unique items and group indices for each item in the list
Erotemic/utool
utool/util_dev.py
autopep8_diff
def autopep8_diff(fpath): r""" Args: fpath (str): file path string CommandLine: python -m utool.util_dev --test-autopep8_diff --fpath ingest_data.py Example: >>> # DISABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> fpath = ut.get_argval('--fpath', typ...
python
def autopep8_diff(fpath): r""" Args: fpath (str): file path string CommandLine: python -m utool.util_dev --test-autopep8_diff --fpath ingest_data.py Example: >>> # DISABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> fpath = ut.get_argval('--fpath', typ...
[ "def", "autopep8_diff", "(", "fpath", ")", ":", "import", "utool", "as", "ut", "args", "=", "(", "'autopep8'", ",", "fpath", ",", "'--diff'", ")", "res", "=", "ut", ".", "cmd", "(", "args", ",", "verbose", "=", "False", ")", "out", ",", "err", ",",...
r""" Args: fpath (str): file path string CommandLine: python -m utool.util_dev --test-autopep8_diff --fpath ingest_data.py Example: >>> # DISABLE_DOCTEST >>> from utool.util_dev import * # NOQA >>> fpath = ut.get_argval('--fpath', type_=str, default='ingest_data.p...
[ "r", "Args", ":", "fpath", "(", "str", ")", ":", "file", "path", "string" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2209-L2228
train
r Autopep8 diff of a single object
Erotemic/utool
utool/util_dev.py
search_module
def search_module(mod, pat, ignore_case=True, recursive=False, _seen=None): r""" Searches module functions, classes, and constants for members matching a pattern. Args: mod (module): live python module pat (str): regular expression Returns: list: found_list CommandLine...
python
def search_module(mod, pat, ignore_case=True, recursive=False, _seen=None): r""" Searches module functions, classes, and constants for members matching a pattern. Args: mod (module): live python module pat (str): regular expression Returns: list: found_list CommandLine...
[ "def", "search_module", "(", "mod", ",", "pat", ",", "ignore_case", "=", "True", ",", "recursive", "=", "False", ",", "_seen", "=", "None", ")", ":", "if", "_seen", "is", "not", "None", "and", "mod", "in", "_seen", ":", "return", "[", "]", "import", ...
r""" Searches module functions, classes, and constants for members matching a pattern. Args: mod (module): live python module pat (str): regular expression Returns: list: found_list CommandLine: python -m utool.util_dev --exec-search_module --mod=utool --pat=module...
[ "r", "Searches", "module", "functions", "classes", "and", "constants", "for", "members", "matching", "a", "pattern", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2268-L2325
train
r Searches a module for a regular expression pat.
Erotemic/utool
utool/util_dev.py
get_submodules_from_dpath
def get_submodules_from_dpath(dpath, only_packages=False, recursive=True): r""" Args: dpath (str): directory path only_packages (bool): if True returns only package directories, otherwise returns module files. (default = False) Returns: list: submod_fpaths CommandLi...
python
def get_submodules_from_dpath(dpath, only_packages=False, recursive=True): r""" Args: dpath (str): directory path only_packages (bool): if True returns only package directories, otherwise returns module files. (default = False) Returns: list: submod_fpaths CommandLi...
[ "def", "get_submodules_from_dpath", "(", "dpath", ",", "only_packages", "=", "False", ",", "recursive", "=", "True", ")", ":", "import", "utool", "as", "ut", "submod_dpaths", "=", "[", "d", "for", "d", "in", "ut", ".", "ls_dirs", "(", "dpath", ")", "if",...
r""" Args: dpath (str): directory path only_packages (bool): if True returns only package directories, otherwise returns module files. (default = False) Returns: list: submod_fpaths CommandLine: python -m utool.util_dev --exec-get_submodules_from_dpath --only_pa...
[ "r", "Args", ":", "dpath", "(", "str", ")", ":", "directory", "path", "only_packages", "(", "bool", ")", ":", "if", "True", "returns", "only", "package", "directories", "otherwise", "returns", "module", "files", ".", "(", "default", "=", "False", ")" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2328-L2364
train
r Get all submodules of a directory tree.
Erotemic/utool
utool/util_dev.py
execstr_funckw
def execstr_funckw(func): """ for doctests kwargs SeeAlso: ut.exec_func_src ut.argparse_funckw """ import utool as ut funckw = ut.get_func_kwargs(func) return ut.execstr_dict(funckw, explicit=True)
python
def execstr_funckw(func): """ for doctests kwargs SeeAlso: ut.exec_func_src ut.argparse_funckw """ import utool as ut funckw = ut.get_func_kwargs(func) return ut.execstr_dict(funckw, explicit=True)
[ "def", "execstr_funckw", "(", "func", ")", ":", "import", "utool", "as", "ut", "funckw", "=", "ut", ".", "get_func_kwargs", "(", "func", ")", "return", "ut", ".", "execstr_dict", "(", "funckw", ",", "explicit", "=", "True", ")" ]
for doctests kwargs SeeAlso: ut.exec_func_src ut.argparse_funckw
[ "for", "doctests", "kwargs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2499-L2509
train
execstr_dict for doctests kwargs
Erotemic/utool
utool/util_dev.py
exec_argparse_funckw
def exec_argparse_funckw(func, globals_=None, defaults={}, **kwargs): """ for doctests kwargs SeeAlso: ut.exec_func_src ut.argparse_funckw """ import utool as ut funckw = ut.get_func_kwargs(func) funckw.update(defaults) parsekw = ut.argparse_dict(funckw, **kwargs) if...
python
def exec_argparse_funckw(func, globals_=None, defaults={}, **kwargs): """ for doctests kwargs SeeAlso: ut.exec_func_src ut.argparse_funckw """ import utool as ut funckw = ut.get_func_kwargs(func) funckw.update(defaults) parsekw = ut.argparse_dict(funckw, **kwargs) if...
[ "def", "exec_argparse_funckw", "(", "func", ",", "globals_", "=", "None", ",", "defaults", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "import", "utool", "as", "ut", "funckw", "=", "ut", ".", "get_func_kwargs", "(", "func", ")", "funckw", ".", ...
for doctests kwargs SeeAlso: ut.exec_func_src ut.argparse_funckw
[ "for", "doctests", "kwargs" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2512-L2526
train
exec_argparse_funckw - executes a function and returns a dict of keyword arguments
Erotemic/utool
utool/util_dev.py
instancelist
def instancelist(obj_list, check=False, shared_attrs=None): """ Executes methods and attribute calls on a list of objects of the same type Bundles a list of object of the same type into a single object. The new object contains the same functions as each original object but applies them to each elem...
python
def instancelist(obj_list, check=False, shared_attrs=None): """ Executes methods and attribute calls on a list of objects of the same type Bundles a list of object of the same type into a single object. The new object contains the same functions as each original object but applies them to each elem...
[ "def", "instancelist", "(", "obj_list", ",", "check", "=", "False", ",", "shared_attrs", "=", "None", ")", ":", "class", "InstanceList_", "(", "object", ")", ":", "def", "__init__", "(", "self", ",", "obj_list", ",", "shared_attrs", "=", "None", ")", ":"...
Executes methods and attribute calls on a list of objects of the same type Bundles a list of object of the same type into a single object. The new object contains the same functions as each original object but applies them to each element of the list independantly when called. CommandLine: pyt...
[ "Executes", "methods", "and", "attribute", "calls", "on", "a", "list", "of", "objects", "of", "the", "same", "type" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2570-L2672
train
A wrapper for ut. instancelist that creates a new object of the same type and returns it.
Erotemic/utool
utool/util_dev.py
fix_super_reload
def fix_super_reload(this_class, self): """ Fixes an error where reload causes super(X, self) to raise an exception The problem is that reloading causes X to point to the wrong version of the class. This function fixes the problem by searching and returning the correct version of the class. See ex...
python
def fix_super_reload(this_class, self): """ Fixes an error where reload causes super(X, self) to raise an exception The problem is that reloading causes X to point to the wrong version of the class. This function fixes the problem by searching and returning the correct version of the class. See ex...
[ "def", "fix_super_reload", "(", "this_class", ",", "self", ")", ":", "if", "isinstance", "(", "self", ",", "this_class", ")", ":", "# Case where everything is ok", "this_class_now", "=", "this_class", "else", ":", "# Case where we need to search for the right class", "d...
Fixes an error where reload causes super(X, self) to raise an exception The problem is that reloading causes X to point to the wrong version of the class. This function fixes the problem by searching and returning the correct version of the class. See example for proper usage. USE `ut.super2` INSTEAD...
[ "Fixes", "an", "error", "where", "reload", "causes", "super", "(", "X", "self", ")", "to", "raise", "an", "exception" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L3117-L3181
train
This function fixes the problem where reloading causes super to point to the wrong version of the class X.
Erotemic/utool
utool/util_dev.py
_heappush_max
def _heappush_max(heap, item): """ why is this not in heapq """ heap.append(item) heapq._siftdown_max(heap, 0, len(heap) - 1)
python
def _heappush_max(heap, item): """ why is this not in heapq """ heap.append(item) heapq._siftdown_max(heap, 0, len(heap) - 1)
[ "def", "_heappush_max", "(", "heap", ",", "item", ")", ":", "heap", ".", "append", "(", "item", ")", "heapq", ".", "_siftdown_max", "(", "heap", ",", "0", ",", "len", "(", "heap", ")", "-", "1", ")" ]
why is this not in heapq
[ "why", "is", "this", "not", "in", "heapq" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L3235-L3238
train
Add item to heap and update heapq.
Erotemic/utool
utool/util_dev.py
InteractivePrompt.handle_ans
def handle_ans(self, ans_): """ preforms an actionm based on a user answer """ ans = ans_.strip(' ') def chack_if_answer_was(valid_keys): return any([ans == key or ans.startswith(key + ' ') for key in valid_keys]) # Custom interactions ...
python
def handle_ans(self, ans_): """ preforms an actionm based on a user answer """ ans = ans_.strip(' ') def chack_if_answer_was(valid_keys): return any([ans == key or ans.startswith(key + ' ') for key in valid_keys]) # Custom interactions ...
[ "def", "handle_ans", "(", "self", ",", "ans_", ")", ":", "ans", "=", "ans_", ".", "strip", "(", "' '", ")", "def", "chack_if_answer_was", "(", "valid_keys", ")", ":", "return", "any", "(", "[", "ans", "==", "key", "or", "ans", ".", "startswith", "(",...
preforms an actionm based on a user answer
[ "preforms", "an", "actionm", "based", "on", "a", "user", "answer" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L864-L876
train
Preforms an actionm based on a user answer
Erotemic/utool
utool/util_dev.py
InteractiveIter.eventloop
def eventloop(cls, custom_actions=[]): """ For use outside of iteration wrapping. Makes an interactive event loop custom_actions should be specified in format [dispname, keys, desc, func] """ iiter = cls([None], custom_actions=custom_actions, verbose=False) print(...
python
def eventloop(cls, custom_actions=[]): """ For use outside of iteration wrapping. Makes an interactive event loop custom_actions should be specified in format [dispname, keys, desc, func] """ iiter = cls([None], custom_actions=custom_actions, verbose=False) print(...
[ "def", "eventloop", "(", "cls", ",", "custom_actions", "=", "[", "]", ")", ":", "iiter", "=", "cls", "(", "[", "None", "]", ",", "custom_actions", "=", "custom_actions", ",", "verbose", "=", "False", ")", "print", "(", "'[IITER] Begining interactive main loo...
For use outside of iteration wrapping. Makes an interactive event loop custom_actions should be specified in format [dispname, keys, desc, func]
[ "For", "use", "outside", "of", "iteration", "wrapping", ".", "Makes", "an", "interactive", "event", "loop", "custom_actions", "should", "be", "specified", "in", "format", "[", "dispname", "keys", "desc", "func", "]" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L976-L986
train
A simple wrapper for the event loop that returns a new instance of the class cls.
Erotemic/utool
utool/util_dev.py
InteractiveIter.handle_ans
def handle_ans(iiter, ans_): """ preforms an actionm based on a user answer """ ans = ans_.strip(' ') def parse_str_value(ans): return ' '.join(ans.split(' ')[1:]) def chack_if_answer_was(valid_keys): return any([ans == key or ans.startswith(key + ...
python
def handle_ans(iiter, ans_): """ preforms an actionm based on a user answer """ ans = ans_.strip(' ') def parse_str_value(ans): return ' '.join(ans.split(' ')[1:]) def chack_if_answer_was(valid_keys): return any([ans == key or ans.startswith(key + ...
[ "def", "handle_ans", "(", "iiter", ",", "ans_", ")", ":", "ans", "=", "ans_", ".", "strip", "(", "' '", ")", "def", "parse_str_value", "(", "ans", ")", ":", "return", "' '", ".", "join", "(", "ans", ".", "split", "(", "' '", ")", "[", "1", ":", ...
preforms an actionm based on a user answer
[ "preforms", "an", "actionm", "based", "on", "a", "user", "answer" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L1052-L1101
train
Handle an answer from an actionm based on a user answer
Erotemic/utool
utool/util_dev.py
ColumnLists.take_column
def take_column(self, keys, *extra_keys): """ Takes a subset of columns """ import utool as ut keys = ut.ensure_iterable(keys) + list(extra_keys) key_to_list = ut.dict_subset(self._key_to_list, keys) newself = self.__class__(key_to_list, self._meta.copy()) return newself
python
def take_column(self, keys, *extra_keys): """ Takes a subset of columns """ import utool as ut keys = ut.ensure_iterable(keys) + list(extra_keys) key_to_list = ut.dict_subset(self._key_to_list, keys) newself = self.__class__(key_to_list, self._meta.copy()) return newself
[ "def", "take_column", "(", "self", ",", "keys", ",", "*", "extra_keys", ")", ":", "import", "utool", "as", "ut", "keys", "=", "ut", ".", "ensure_iterable", "(", "keys", ")", "+", "list", "(", "extra_keys", ")", "key_to_list", "=", "ut", ".", "dict_subs...
Takes a subset of columns
[ "Takes", "a", "subset", "of", "columns" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2830-L2836
train
Takes a subset of columns
Erotemic/utool
utool/util_dev.py
ColumnLists.take
def take(self, idxs): """ Takes a subset of rows """ import utool as ut if False: key_to_list = ut.odict([ (key, ut.take(val, idxs)) for key, val in six.iteritems(self._key_to_list) ]) else: import numpy as np ...
python
def take(self, idxs): """ Takes a subset of rows """ import utool as ut if False: key_to_list = ut.odict([ (key, ut.take(val, idxs)) for key, val in six.iteritems(self._key_to_list) ]) else: import numpy as np ...
[ "def", "take", "(", "self", ",", "idxs", ")", ":", "import", "utool", "as", "ut", "if", "False", ":", "key_to_list", "=", "ut", ".", "odict", "(", "[", "(", "key", ",", "ut", ".", "take", "(", "val", ",", "idxs", ")", ")", "for", "key", ",", ...
Takes a subset of rows
[ "Takes", "a", "subset", "of", "rows" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2838-L2855
train
Takes a subset of rows
Erotemic/utool
utool/util_dev.py
ColumnLists.remove
def remove(self, idxs): """ Returns a copy with idxs removed """ import utool as ut keep_idxs = ut.index_complement(idxs, len(self)) return self.take(keep_idxs)
python
def remove(self, idxs): """ Returns a copy with idxs removed """ import utool as ut keep_idxs = ut.index_complement(idxs, len(self)) return self.take(keep_idxs)
[ "def", "remove", "(", "self", ",", "idxs", ")", ":", "import", "utool", "as", "ut", "keep_idxs", "=", "ut", ".", "index_complement", "(", "idxs", ",", "len", "(", "self", ")", ")", "return", "self", ".", "take", "(", "keep_idxs", ")" ]
Returns a copy with idxs removed
[ "Returns", "a", "copy", "with", "idxs", "removed" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2857-L2861
train
Returns a copy with idxs removed
Erotemic/utool
utool/util_dev.py
ColumnLists.group_items
def group_items(self, labels): """ group as dict """ import utool as ut unique_labels, groups = self.group(labels) label_to_group = ut.odict(zip(unique_labels, groups)) return label_to_group
python
def group_items(self, labels): """ group as dict """ import utool as ut unique_labels, groups = self.group(labels) label_to_group = ut.odict(zip(unique_labels, groups)) return label_to_group
[ "def", "group_items", "(", "self", ",", "labels", ")", ":", "import", "utool", "as", "ut", "unique_labels", ",", "groups", "=", "self", ".", "group", "(", "labels", ")", "label_to_group", "=", "ut", ".", "odict", "(", "zip", "(", "unique_labels", ",", ...
group as dict
[ "group", "as", "dict" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2880-L2885
train
group as dict
Erotemic/utool
utool/util_dev.py
ColumnLists.group
def group(self, labels): """ group as list """ unique_labels, groupxs = self.group_indicies(labels) groups = [self.take(idxs) for idxs in groupxs] return unique_labels, groups
python
def group(self, labels): """ group as list """ unique_labels, groupxs = self.group_indicies(labels) groups = [self.take(idxs) for idxs in groupxs] return unique_labels, groups
[ "def", "group", "(", "self", ",", "labels", ")", ":", "unique_labels", ",", "groupxs", "=", "self", ".", "group_indicies", "(", "labels", ")", "groups", "=", "[", "self", ".", "take", "(", "idxs", ")", "for", "idxs", "in", "groupxs", "]", "return", "...
group as list
[ "group", "as", "list" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2887-L2891
train
group as list
Erotemic/utool
utool/util_dev.py
ColumnLists.cast_column
def cast_column(self, keys, func): """ like map column but applies values inplace """ import utool as ut for key in ut.ensure_iterable(keys): self[key] = [func(v) for v in self[key]]
python
def cast_column(self, keys, func): """ like map column but applies values inplace """ import utool as ut for key in ut.ensure_iterable(keys): self[key] = [func(v) for v in self[key]]
[ "def", "cast_column", "(", "self", ",", "keys", ",", "func", ")", ":", "import", "utool", "as", "ut", "for", "key", "in", "ut", ".", "ensure_iterable", "(", "keys", ")", ":", "self", "[", "key", "]", "=", "[", "func", "(", "v", ")", "for", "v", ...
like map column but applies values inplace
[ "like", "map", "column", "but", "applies", "values", "inplace" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2919-L2923
train
like map column but applies values inplace
Erotemic/utool
utool/util_dev.py
ColumnLists.map_column
def map_column(self, keys, func): """ Args: keys (list or str): the column name(s) to apply the `func` to func (callable): applied to each element in the specified columns """ return [[func(v) for v in self[key]] for key in keys]
python
def map_column(self, keys, func): """ Args: keys (list or str): the column name(s) to apply the `func` to func (callable): applied to each element in the specified columns """ return [[func(v) for v in self[key]] for key in keys]
[ "def", "map_column", "(", "self", ",", "keys", ",", "func", ")", ":", "return", "[", "[", "func", "(", "v", ")", "for", "v", "in", "self", "[", "key", "]", "]", "for", "key", "in", "keys", "]" ]
Args: keys (list or str): the column name(s) to apply the `func` to func (callable): applied to each element in the specified columns
[ "Args", ":", "keys", "(", "list", "or", "str", ")", ":", "the", "column", "name", "(", "s", ")", "to", "apply", "the", "func", "to", "func", "(", "callable", ")", ":", "applied", "to", "each", "element", "in", "the", "specified", "columns" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2926-L2932
train
Applies the func to each element in the specified columns.
Erotemic/utool
utool/util_dev.py
ColumnLists.merge_rows
def merge_rows(self, key, merge_scalars=True): """ Uses key as a unique index an merges all duplicates rows. Use cast_column to modify types of columns before merging to affect behavior of duplicate rectification. Args: key: row to merge on merge_scalars...
python
def merge_rows(self, key, merge_scalars=True): """ Uses key as a unique index an merges all duplicates rows. Use cast_column to modify types of columns before merging to affect behavior of duplicate rectification. Args: key: row to merge on merge_scalars...
[ "def", "merge_rows", "(", "self", ",", "key", ",", "merge_scalars", "=", "True", ")", ":", "import", "utool", "as", "ut", "unique_labels", ",", "groupxs", "=", "self", ".", "group_indicies", "(", "key", ")", "single_xs", "=", "[", "xs", "for", "xs", "i...
Uses key as a unique index an merges all duplicates rows. Use cast_column to modify types of columns before merging to affect behavior of duplicate rectification. Args: key: row to merge on merge_scalars: if True, scalar values become lists Example: ...
[ "Uses", "key", "as", "a", "unique", "index", "an", "merges", "all", "duplicates", "rows", ".", "Use", "cast_column", "to", "modify", "types", "of", "columns", "before", "merging", "to", "affect", "behavior", "of", "duplicate", "rectification", "." ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L2934-L3024
train
Merges all rows in the table into one table.
Erotemic/utool
utool/util_dev.py
PriorityQueue.peek
def peek(self): """ Peek at the next item in the queue """ # Ammortized O(1) _heap = self._heap _dict = self._dict val, key = _heap[0] # Remove items marked for lazy deletion as they are encountered while key not in _dict or _dict[key] != val: ...
python
def peek(self): """ Peek at the next item in the queue """ # Ammortized O(1) _heap = self._heap _dict = self._dict val, key = _heap[0] # Remove items marked for lazy deletion as they are encountered while key not in _dict or _dict[key] != val: ...
[ "def", "peek", "(", "self", ")", ":", "# Ammortized O(1)", "_heap", "=", "self", ".", "_heap", "_dict", "=", "self", ".", "_dict", "val", ",", "key", "=", "_heap", "[", "0", "]", "# Remove items marked for lazy deletion as they are encountered", "while", "key", ...
Peek at the next item in the queue
[ "Peek", "at", "the", "next", "item", "in", "the", "queue" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L3363-L3375
train
Peek at the next item in the queue.
Erotemic/utool
utool/util_dev.py
PriorityQueue.peek_many
def peek_many(self, n): """ Actually this can be quite inefficient Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> items = list(zip(range(256), range(256))) >>> n = 32 >>> ut.shuffle(items) >>> self = ut.PriorityQ...
python
def peek_many(self, n): """ Actually this can be quite inefficient Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> items = list(zip(range(256), range(256))) >>> n = 32 >>> ut.shuffle(items) >>> self = ut.PriorityQ...
[ "def", "peek_many", "(", "self", ",", "n", ")", ":", "if", "n", "==", "0", ":", "return", "[", "]", "elif", "n", "==", "1", ":", "return", "[", "self", ".", "peek", "(", ")", "]", "else", ":", "items", "=", "list", "(", "self", ".", "pop_many...
Actually this can be quite inefficient Example: >>> # DISABLE_DOCTEST >>> import utool as ut >>> items = list(zip(range(256), range(256))) >>> n = 32 >>> ut.shuffle(items) >>> self = ut.PriorityQueue(items, ascending=False) >>>...
[ "Actually", "this", "can", "be", "quite", "inefficient" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L3377-L3397
train
This function returns a list of n items from the priority queue.
Erotemic/utool
utool/util_dev.py
PriorityQueue.pop
def pop(self, key=util_const.NoParam, default=util_const.NoParam): """ Pop the next item off the queue """ # Dictionary pop if key is specified if key is not util_const.NoParam: if default is util_const.NoParam: return (key, self._dict.pop(key)) ...
python
def pop(self, key=util_const.NoParam, default=util_const.NoParam): """ Pop the next item off the queue """ # Dictionary pop if key is specified if key is not util_const.NoParam: if default is util_const.NoParam: return (key, self._dict.pop(key)) ...
[ "def", "pop", "(", "self", ",", "key", "=", "util_const", ".", "NoParam", ",", "default", "=", "util_const", ".", "NoParam", ")", ":", "# Dictionary pop if key is specified", "if", "key", "is", "not", "util_const", ".", "NoParam", ":", "if", "default", "is",...
Pop the next item off the queue
[ "Pop", "the", "next", "item", "off", "the", "queue" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_dev.py#L3405-L3430
train
Pop the next item off the queue and return it.
Erotemic/utool
utool/_internal/util_importer.py
__excecute_imports
def __excecute_imports(module, modname, imports, verbose=False): """ Module Imports """ # level: -1 is a the Python2 import strategy # level: 0 is a the Python3 absolute import if verbose: print('[UTIL_IMPORT] EXECUTING %d IMPORT TUPLES' % (len(imports),)) level = 0 for name in imports:...
python
def __excecute_imports(module, modname, imports, verbose=False): """ Module Imports """ # level: -1 is a the Python2 import strategy # level: 0 is a the Python3 absolute import if verbose: print('[UTIL_IMPORT] EXECUTING %d IMPORT TUPLES' % (len(imports),)) level = 0 for name in imports:...
[ "def", "__excecute_imports", "(", "module", ",", "modname", ",", "imports", ",", "verbose", "=", "False", ")", ":", "# level: -1 is a the Python2 import strategy", "# level: 0 is a the Python3 absolute import", "if", "verbose", ":", "print", "(", "'[UTIL_IMPORT] EXECUTING ...
Module Imports
[ "Module", "Imports" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L19-L31
train
Imports a module.
Erotemic/utool
utool/_internal/util_importer.py
__execute_fromimport
def __execute_fromimport(module, modname, import_tuples, verbose=False): """ Module From Imports """ if verbose: print('[UTIL_IMPORT] EXECUTING %d FROM IMPORT TUPLES' % (len(import_tuples),)) from_imports = __get_from_imports(import_tuples) for name, fromlist in from_imports: full_modnam...
python
def __execute_fromimport(module, modname, import_tuples, verbose=False): """ Module From Imports """ if verbose: print('[UTIL_IMPORT] EXECUTING %d FROM IMPORT TUPLES' % (len(import_tuples),)) from_imports = __get_from_imports(import_tuples) for name, fromlist in from_imports: full_modnam...
[ "def", "__execute_fromimport", "(", "module", ",", "modname", ",", "import_tuples", ",", "verbose", "=", "False", ")", ":", "if", "verbose", ":", "print", "(", "'[UTIL_IMPORT] EXECUTING %d FROM IMPORT TUPLES'", "%", "(", "len", "(", "import_tuples", ")", ",", ")...
Module From Imports
[ "Module", "From", "Imports" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L34-L44
train
Execute the fromimport function in the given module.
Erotemic/utool
utool/_internal/util_importer.py
__execute_fromimport_star
def __execute_fromimport_star(module, modname, import_tuples, ignore_list=[], ignore_startswith=[], ignore_endswith=[], check_not_imported=True, verbose=False, veryverbose=False): r""" Effectively import * statements ...
python
def __execute_fromimport_star(module, modname, import_tuples, ignore_list=[], ignore_startswith=[], ignore_endswith=[], check_not_imported=True, verbose=False, veryverbose=False): r""" Effectively import * statements ...
[ "def", "__execute_fromimport_star", "(", "module", ",", "modname", ",", "import_tuples", ",", "ignore_list", "=", "[", "]", ",", "ignore_startswith", "=", "[", "]", ",", "ignore_endswith", "=", "[", "]", ",", "check_not_imported", "=", "True", ",", "verbose", ...
r""" Effectively import * statements The dynamic_import must happen before any * imports otherwise it wont catch anything. Ignore: ignore_startswith = [] ignore_endswith = [] check_not_imported = False verbose = True veryverbose = True
[ "r", "Effectively", "import", "*", "statements" ]
3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a
https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/_internal/util_importer.py#L47-L133
train
r This function executes the fromimport star tupled statements.