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
1 value
svinota/mdns
mdns/zeroconf.py
DNSCache.remove
def remove(self, entry): """Removes an entry""" try: list = self.cache[entry.key] list.remove(entry) except: pass
python
def remove(self, entry): """Removes an entry""" try: list = self.cache[entry.key] list.remove(entry) except: pass
[ "def", "remove", "(", "self", ",", "entry", ")", ":", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "list", ".", "remove", "(", "entry", ")", "except", ":", "pass" ]
Removes an entry
[ "Removes", "an", "entry" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1079-L1085
train
svinota/mdns
mdns/zeroconf.py
DNSCache.get
def get(self, entry): """Gets an entry by key. Will return None if there is no matching entry.""" try: list = self.cache[entry.key] return list[list.index(entry)] except: return None
python
def get(self, entry): """Gets an entry by key. Will return None if there is no matching entry.""" try: list = self.cache[entry.key] return list[list.index(entry)] except: return None
[ "def", "get", "(", "self", ",", "entry", ")", ":", "try", ":", "list", "=", "self", ".", "cache", "[", "entry", ".", "key", "]", "return", "list", "[", "list", ".", "index", "(", "entry", ")", "]", "except", ":", "return", "None" ]
Gets an entry by key. Will return None if there is no matching entry.
[ "Gets", "an", "entry", "by", "key", ".", "Will", "return", "None", "if", "there", "is", "no", "matching", "entry", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1087-L1094
train
svinota/mdns
mdns/zeroconf.py
DNSCache.get_by_details
def get_by_details(self, name, type, clazz): """Gets an entry by details. Will return None if there is no matching entry.""" entry = DNSEntry(name, type, clazz) return self.get(entry)
python
def get_by_details(self, name, type, clazz): """Gets an entry by details. Will return None if there is no matching entry.""" entry = DNSEntry(name, type, clazz) return self.get(entry)
[ "def", "get_by_details", "(", "self", ",", "name", ",", "type", ",", "clazz", ")", ":", "entry", "=", "DNSEntry", "(", "name", ",", "type", ",", "clazz", ")", "return", "self", ".", "get", "(", "entry", ")" ]
Gets an entry by details. Will return None if there is no matching entry.
[ "Gets", "an", "entry", "by", "details", ".", "Will", "return", "None", "if", "there", "is", "no", "matching", "entry", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1096-L1100
train
svinota/mdns
mdns/zeroconf.py
DNSCache.entries
def entries(self): """Returns a list of all entries""" def add(x, y): return x + y try: return reduce(add, list(self.cache.values())) except: return []
python
def entries(self): """Returns a list of all entries""" def add(x, y): return x + y try: return reduce(add, list(self.cache.values())) except: return []
[ "def", "entries", "(", "self", ")", ":", "def", "add", "(", "x", ",", "y", ")", ":", "return", "x", "+", "y", "try", ":", "return", "reduce", "(", "add", ",", "list", "(", "self", ".", "cache", ".", "values", "(", ")", ")", ")", "except", ":"...
Returns a list of all entries
[ "Returns", "a", "list", "of", "all", "entries" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1109-L1116
train
svinota/mdns
mdns/zeroconf.py
ServiceBrowser.update_record
def update_record(self, zeroconf, now, record): """Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.""" if record.type == _TYPE_PTR and record.name == self.type: expired = record.is_expired(now) try:...
python
def update_record(self, zeroconf, now, record): """Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.""" if record.type == _TYPE_PTR and record.name == self.type: expired = record.is_expired(now) try:...
[ "def", "update_record", "(", "self", ",", "zeroconf", ",", "now", ",", "record", ")", ":", "if", "record", ".", "type", "==", "_TYPE_PTR", "and", "record", ".", "name", "==", "self", ".", "type", ":", "expired", "=", "record", ".", "is_expired", "(", ...
Callback invoked by Zeroconf when new information arrives. Updates information required by browser in the Zeroconf cache.
[ "Callback", "invoked", "by", "Zeroconf", "when", "new", "information", "arrives", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1273-L1298
train
svinota/mdns
mdns/zeroconf.py
ServiceInfo.set_properties
def set_properties(self, properties): """Sets properties and text of this info from a dictionary""" if isinstance(properties, dict): self.properties = properties self.sync_properties() else: self.text = properties
python
def set_properties(self, properties): """Sets properties and text of this info from a dictionary""" if isinstance(properties, dict): self.properties = properties self.sync_properties() else: self.text = properties
[ "def", "set_properties", "(", "self", ",", "properties", ")", ":", "if", "isinstance", "(", "properties", ",", "dict", ")", ":", "self", ".", "properties", "=", "properties", "self", ".", "sync_properties", "(", ")", "else", ":", "self", ".", "text", "="...
Sets properties and text of this info from a dictionary
[ "Sets", "properties", "and", "text", "of", "this", "info", "from", "a", "dictionary" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1399-L1405
train
svinota/mdns
mdns/zeroconf.py
ServiceInfo.set_text
def set_text(self, text): """Sets properties and text given a text field""" self.text = text try: self.properties = text_to_dict(text) except: traceback.print_exc() self.properties = None
python
def set_text(self, text): """Sets properties and text given a text field""" self.text = text try: self.properties = text_to_dict(text) except: traceback.print_exc() self.properties = None
[ "def", "set_text", "(", "self", ",", "text", ")", ":", "self", ".", "text", "=", "text", "try", ":", "self", ".", "properties", "=", "text_to_dict", "(", "text", ")", "except", ":", "traceback", ".", "print_exc", "(", ")", "self", ".", "properties", ...
Sets properties and text given a text field
[ "Sets", "properties", "and", "text", "given", "a", "text", "field" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1407-L1414
train
svinota/mdns
mdns/zeroconf.py
ServiceInfo.get_name
def get_name(self): """Name accessor""" if self.type is not None and self.name.endswith("." + self.type): return self.name[:len(self.name) - len(self.type) - 1] return self.name
python
def get_name(self): """Name accessor""" if self.type is not None and self.name.endswith("." + self.type): return self.name[:len(self.name) - len(self.type) - 1] return self.name
[ "def", "get_name", "(", "self", ")", ":", "if", "self", ".", "type", "is", "not", "None", "and", "self", ".", "name", ".", "endswith", "(", "\".\"", "+", "self", ".", "type", ")", ":", "return", "self", ".", "name", "[", ":", "len", "(", "self", ...
Name accessor
[ "Name", "accessor" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1420-L1424
train
svinota/mdns
mdns/zeroconf.py
ServiceInfo.update_record
def update_record(self, zeroconf, now, record): """Updates service information from a DNS record""" if record is not None and not record.is_expired(now): if record.type == _TYPE_A: if record.name == self.name: if not record.address in self.address: ...
python
def update_record(self, zeroconf, now, record): """Updates service information from a DNS record""" if record is not None and not record.is_expired(now): if record.type == _TYPE_A: if record.name == self.name: if not record.address in self.address: ...
[ "def", "update_record", "(", "self", ",", "zeroconf", ",", "now", ",", "record", ")", ":", "if", "record", "is", "not", "None", "and", "not", "record", ".", "is_expired", "(", "now", ")", ":", "if", "record", ".", "type", "==", "_TYPE_A", ":", "if", ...
Updates service information from a DNS record
[ "Updates", "service", "information", "from", "a", "DNS", "record" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1454-L1473
train
svinota/mdns
mdns/zeroconf.py
ServiceInfo.request
def request(self, zeroconf, timeout): """Returns true if the service could be discovered on the network, and updates this object with details discovered. """ now = current_time_millis() delay = _LISTENER_TIME next = now + delay last = now + timeout result ...
python
def request(self, zeroconf, timeout): """Returns true if the service could be discovered on the network, and updates this object with details discovered. """ now = current_time_millis() delay = _LISTENER_TIME next = now + delay last = now + timeout result ...
[ "def", "request", "(", "self", ",", "zeroconf", ",", "timeout", ")", ":", "now", "=", "current_time_millis", "(", ")", "delay", "=", "_LISTENER_TIME", "next", "=", "now", "+", "delay", "last", "=", "now", "+", "timeout", "result", "=", "0", "try", ":",...
Returns true if the service could be discovered on the network, and updates this object with details discovered.
[ "Returns", "true", "if", "the", "service", "could", "be", "discovered", "on", "the", "network", "and", "updates", "this", "object", "with", "details", "discovered", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1475-L1520
train
svinota/mdns
mdns/zeroconf.py
Heartbeat.wait
def wait(self, timeout): """Calling thread waits for a given number of milliseconds or until notified.""" self.condition.acquire() self.condition.wait(timeout // 1000) self.condition.release()
python
def wait(self, timeout): """Calling thread waits for a given number of milliseconds or until notified.""" self.condition.acquire() self.condition.wait(timeout // 1000) self.condition.release()
[ "def", "wait", "(", "self", ",", "timeout", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "self", ".", "condition", ".", "wait", "(", "timeout", "//", "1000", ")", "self", ".", "condition", ".", "release", "(", ")" ]
Calling thread waits for a given number of milliseconds or until notified.
[ "Calling", "thread", "waits", "for", "a", "given", "number", "of", "milliseconds", "or", "until", "notified", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1562-L1567
train
svinota/mdns
mdns/zeroconf.py
Heartbeat.notify_all
def notify_all(self): """Notifies all waiting threads""" self.condition.acquire() # python 3.x try: self.condition.notify_all() except: self.condition.notifyAll() self.condition.release()
python
def notify_all(self): """Notifies all waiting threads""" self.condition.acquire() # python 3.x try: self.condition.notify_all() except: self.condition.notifyAll() self.condition.release()
[ "def", "notify_all", "(", "self", ")", ":", "self", ".", "condition", ".", "acquire", "(", ")", "# python 3.x", "try", ":", "self", ".", "condition", ".", "notify_all", "(", ")", "except", ":", "self", ".", "condition", ".", "notifyAll", "(", ")", "sel...
Notifies all waiting threads
[ "Notifies", "all", "waiting", "threads" ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1569-L1577
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.get_service_info
def get_service_info(self, type, name, timeout=3000): """Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.""" info = ServiceInfo(type, name) if info.request(self, timeout): ...
python
def get_service_info(self, type, name, timeout=3000): """Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.""" info = ServiceInfo(type, name) if info.request(self, timeout): ...
[ "def", "get_service_info", "(", "self", ",", "type", ",", "name", ",", "timeout", "=", "3000", ")", ":", "info", "=", "ServiceInfo", "(", "type", ",", "name", ")", "if", "info", ".", "request", "(", "self", ",", "timeout", ")", ":", "return", "info",...
Returns network's service information for a particular name and type, or None if no service matches by the timeout, which defaults to 3 seconds.
[ "Returns", "network", "s", "service", "information", "for", "a", "particular", "name", "and", "type", "or", "None", "if", "no", "service", "matches", "by", "the", "timeout", "which", "defaults", "to", "3", "seconds", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1712-L1719
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.add_serviceListener
def add_serviceListener(self, type, listener): """Adds a listener for a particular service type. This object will then have its update_record method called when information arrives for that type.""" self.remove_service_listener(listener) self.browsers.append(ServiceBrowser(self,...
python
def add_serviceListener(self, type, listener): """Adds a listener for a particular service type. This object will then have its update_record method called when information arrives for that type.""" self.remove_service_listener(listener) self.browsers.append(ServiceBrowser(self,...
[ "def", "add_serviceListener", "(", "self", ",", "type", ",", "listener", ")", ":", "self", ".", "remove_service_listener", "(", "listener", ")", "self", ".", "browsers", ".", "append", "(", "ServiceBrowser", "(", "self", ",", "type", ",", "listener", ")", ...
Adds a listener for a particular service type. This object will then have its update_record method called when information arrives for that type.
[ "Adds", "a", "listener", "for", "a", "particular", "service", "type", ".", "This", "object", "will", "then", "have", "its", "update_record", "method", "called", "when", "information", "arrives", "for", "that", "type", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1721-L1726
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.remove_service_listener
def remove_service_listener(self, listener): """Removes a listener from the set that is currently listening.""" for browser in self.browsers: if browser.listener == listener: browser.cancel() del(browser)
python
def remove_service_listener(self, listener): """Removes a listener from the set that is currently listening.""" for browser in self.browsers: if browser.listener == listener: browser.cancel() del(browser)
[ "def", "remove_service_listener", "(", "self", ",", "listener", ")", ":", "for", "browser", "in", "self", ".", "browsers", ":", "if", "browser", ".", "listener", "==", "listener", ":", "browser", ".", "cancel", "(", ")", "del", "(", "browser", ")" ]
Removes a listener from the set that is currently listening.
[ "Removes", "a", "listener", "from", "the", "set", "that", "is", "currently", "listening", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1728-L1733
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.register_service
def register_service(self, info): """Registers service information to the network with a default TTL of 60 seconds. Zeroconf will then respond to requests for information for that service. The name of the service may be changed if needed to make it unique on the network.""" sel...
python
def register_service(self, info): """Registers service information to the network with a default TTL of 60 seconds. Zeroconf will then respond to requests for information for that service. The name of the service may be changed if needed to make it unique on the network.""" sel...
[ "def", "register_service", "(", "self", ",", "info", ")", ":", "self", ".", "check_service", "(", "info", ")", "self", ".", "services", "[", "info", ".", "name", ".", "lower", "(", ")", "]", "=", "info", "# zone transfer", "self", ".", "transfer_zone", ...
Registers service information to the network with a default TTL of 60 seconds. Zeroconf will then respond to requests for information for that service. The name of the service may be changed if needed to make it unique on the network.
[ "Registers", "service", "information", "to", "the", "network", "with", "a", "default", "TTL", "of", "60", "seconds", ".", "Zeroconf", "will", "then", "respond", "to", "requests", "for", "information", "for", "that", "service", ".", "The", "name", "of", "the"...
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1738-L1748
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.unregister_service
def unregister_service(self, info): """Unregister a service.""" try: del(self.services[info.name.lower()]) except: pass now = current_time_millis() next_time = now i = 0 while i < 3: if now < next_time: self.wait...
python
def unregister_service(self, info): """Unregister a service.""" try: del(self.services[info.name.lower()]) except: pass now = current_time_millis() next_time = now i = 0 while i < 3: if now < next_time: self.wait...
[ "def", "unregister_service", "(", "self", ",", "info", ")", ":", "try", ":", "del", "(", "self", ".", "services", "[", "info", ".", "name", ".", "lower", "(", ")", "]", ")", "except", ":", "pass", "now", "=", "current_time_millis", "(", ")", "next_ti...
Unregister a service.
[ "Unregister", "a", "service", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1806-L1835
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.check_service
def check_service(self, info): """Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.""" now = current_time_millis() next_time = now i = 0 while i < 3: for record in self.cache.entries_with_name(info.type): ...
python
def check_service(self, info): """Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.""" now = current_time_millis() next_time = now i = 0 while i < 3: for record in self.cache.entries_with_name(info.type): ...
[ "def", "check_service", "(", "self", ",", "info", ")", ":", "now", "=", "current_time_millis", "(", ")", "next_time", "=", "now", "i", "=", "0", "while", "i", "<", "3", ":", "for", "record", "in", "self", ".", "cache", ".", "entries_with_name", "(", ...
Checks the network for a unique service name, modifying the ServiceInfo passed in if it is not unique.
[ "Checks", "the", "network", "for", "a", "unique", "service", "name", "modifying", "the", "ServiceInfo", "passed", "in", "if", "it", "is", "not", "unique", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1868-L1900
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.add_listener
def add_listener(self, listener, question): """Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the question.""" now = current_time_millis() self.listeners.append(listener) if question is...
python
def add_listener(self, listener, question): """Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the question.""" now = current_time_millis() self.listeners.append(listener) if question is...
[ "def", "add_listener", "(", "self", ",", "listener", ",", "question", ")", ":", "now", "=", "current_time_millis", "(", ")", "self", ".", "listeners", ".", "append", "(", "listener", ")", "if", "question", "is", "not", "None", ":", "for", "record", "in",...
Adds a listener for a given question. The listener will have its update_record method called when information is available to answer the question.
[ "Adds", "a", "listener", "for", "a", "given", "question", ".", "The", "listener", "will", "have", "its", "update_record", "method", "called", "when", "information", "is", "available", "to", "answer", "the", "question", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1906-L1916
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.update_record
def update_record(self, now, rec): """Used to notify listeners of new information that has updated a record.""" for listener in self.listeners: listener.update_record(self, now, rec) self.notify_all()
python
def update_record(self, now, rec): """Used to notify listeners of new information that has updated a record.""" for listener in self.listeners: listener.update_record(self, now, rec) self.notify_all()
[ "def", "update_record", "(", "self", ",", "now", ",", "rec", ")", ":", "for", "listener", "in", "self", ".", "listeners", ":", "listener", ".", "update_record", "(", "self", ",", "now", ",", "rec", ")", "self", ".", "notify_all", "(", ")" ]
Used to notify listeners of new information that has updated a record.
[ "Used", "to", "notify", "listeners", "of", "new", "information", "that", "has", "updated", "a", "record", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1926-L1931
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.handle_response
def handle_response(self, msg, address): """Deal with incoming response packets. All answers are held in the cache, and listeners are notified.""" now = current_time_millis() sigs = [] precache = [] for record in msg.answers: if isinstance(record, DNSSignat...
python
def handle_response(self, msg, address): """Deal with incoming response packets. All answers are held in the cache, and listeners are notified.""" now = current_time_millis() sigs = [] precache = [] for record in msg.answers: if isinstance(record, DNSSignat...
[ "def", "handle_response", "(", "self", ",", "msg", ",", "address", ")", ":", "now", "=", "current_time_millis", "(", ")", "sigs", "=", "[", "]", "precache", "=", "[", "]", "for", "record", "in", "msg", ".", "answers", ":", "if", "isinstance", "(", "r...
Deal with incoming response packets. All answers are held in the cache, and listeners are notified.
[ "Deal", "with", "incoming", "response", "packets", ".", "All", "answers", "are", "held", "in", "the", "cache", "and", "listeners", "are", "notified", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L1952-L2036
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.handle_query
def handle_query(self, msg, addr, port, orig): """ Deal with incoming query packets. Provides a response if possible. msg - message to process addr - dst addr port - dst port orig - originating address (for adaptive records) """ out =...
python
def handle_query(self, msg, addr, port, orig): """ Deal with incoming query packets. Provides a response if possible. msg - message to process addr - dst addr port - dst port orig - originating address (for adaptive records) """ out =...
[ "def", "handle_query", "(", "self", ",", "msg", ",", "addr", ",", "port", ",", "orig", ")", ":", "out", "=", "None", "# Support unicast client responses", "#", "if", "port", "!=", "_MDNS_PORT", ":", "out", "=", "DNSOutgoing", "(", "_FLAGS_QR_RESPONSE", "|", ...
Deal with incoming query packets. Provides a response if possible. msg - message to process addr - dst addr port - dst port orig - originating address (for adaptive records)
[ "Deal", "with", "incoming", "query", "packets", ".", "Provides", "a", "response", "if", "possible", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2040-L2128
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.send
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT): """Sends an outgoing packet.""" # This is a quick test to see if we can parse the packets we generate #temp = DNSIncoming(out.packet()) for i in self.intf.values(): try: return i.sendto(out.packet(), 0, (a...
python
def send(self, out, addr=_MDNS_ADDR, port=_MDNS_PORT): """Sends an outgoing packet.""" # This is a quick test to see if we can parse the packets we generate #temp = DNSIncoming(out.packet()) for i in self.intf.values(): try: return i.sendto(out.packet(), 0, (a...
[ "def", "send", "(", "self", ",", "out", ",", "addr", "=", "_MDNS_ADDR", ",", "port", "=", "_MDNS_PORT", ")", ":", "# This is a quick test to see if we can parse the packets we generate", "#temp = DNSIncoming(out.packet())", "for", "i", "in", "self", ".", "intf", ".", ...
Sends an outgoing packet.
[ "Sends", "an", "outgoing", "packet", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2130-L2140
train
svinota/mdns
mdns/zeroconf.py
Zeroconf.close
def close(self): """Ends the background threads, and prevent this instance from servicing further queries.""" if globals()['_GLOBAL_DONE'] == 0: globals()['_GLOBAL_DONE'] = 1 self.notify_all() self.engine.notify() self.unregister_all_services() ...
python
def close(self): """Ends the background threads, and prevent this instance from servicing further queries.""" if globals()['_GLOBAL_DONE'] == 0: globals()['_GLOBAL_DONE'] = 1 self.notify_all() self.engine.notify() self.unregister_all_services() ...
[ "def", "close", "(", "self", ")", ":", "if", "globals", "(", ")", "[", "'_GLOBAL_DONE'", "]", "==", "0", ":", "globals", "(", ")", "[", "'_GLOBAL_DONE'", "]", "=", "1", "self", ".", "notify_all", "(", ")", "self", ".", "engine", ".", "notify", "(",...
Ends the background threads, and prevent this instance from servicing further queries.
[ "Ends", "the", "background", "threads", "and", "prevent", "this", "instance", "from", "servicing", "further", "queries", "." ]
295f6407132616a0ff7401124b9057d89555f91d
https://github.com/svinota/mdns/blob/295f6407132616a0ff7401124b9057d89555f91d/mdns/zeroconf.py#L2142-L2158
train
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.execute
def execute(self, identity_records: 'RDD', old_state_rdd: Optional['RDD'] = None) -> 'RDD': """ Executes Blurr BTS with the given records. old_state_rdd can be provided to load an older state from a previous run. :param identity_records: RDD of the form Tuple[Identity, List[TimeAndRecor...
python
def execute(self, identity_records: 'RDD', old_state_rdd: Optional['RDD'] = None) -> 'RDD': """ Executes Blurr BTS with the given records. old_state_rdd can be provided to load an older state from a previous run. :param identity_records: RDD of the form Tuple[Identity, List[TimeAndRecor...
[ "def", "execute", "(", "self", ",", "identity_records", ":", "'RDD'", ",", "old_state_rdd", ":", "Optional", "[", "'RDD'", "]", "=", "None", ")", "->", "'RDD'", ":", "identity_records_with_state", "=", "identity_records", "if", "old_state_rdd", ":", "identity_re...
Executes Blurr BTS with the given records. old_state_rdd can be provided to load an older state from a previous run. :param identity_records: RDD of the form Tuple[Identity, List[TimeAndRecord]] :param old_state_rdd: A previous streaming BTS state RDD as Tuple[Identity, Streaming BTS ...
[ "Executes", "Blurr", "BTS", "with", "the", "given", "records", ".", "old_state_rdd", "can", "be", "provided", "to", "load", "an", "older", "state", "from", "a", "previous", "run", "." ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L80-L93
train
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.get_record_rdd_from_json_files
def get_record_rdd_from_json_files(self, json_files: List[str], data_processor: DataProcessor = SimpleJsonDataProcessor(), spark_session: Optional['SparkSession'] = None) -> 'RDD': """ Re...
python
def get_record_rdd_from_json_files(self, json_files: List[str], data_processor: DataProcessor = SimpleJsonDataProcessor(), spark_session: Optional['SparkSession'] = None) -> 'RDD': """ Re...
[ "def", "get_record_rdd_from_json_files", "(", "self", ",", "json_files", ":", "List", "[", "str", "]", ",", "data_processor", ":", "DataProcessor", "=", "SimpleJsonDataProcessor", "(", ")", ",", "spark_session", ":", "Optional", "[", "'SparkSession'", "]", "=", ...
Reads the data from the given json_files path and converts them into the `Record`s format for processing. `data_processor` is used to process the per event data in those files to convert them into `Record`. :param json_files: List of json file paths. Regular Spark path wildcards are accepted. ...
[ "Reads", "the", "data", "from", "the", "given", "json_files", "path", "and", "converts", "them", "into", "the", "Record", "s", "format", "for", "processing", ".", "data_processor", "is", "used", "to", "process", "the", "per", "event", "data", "in", "those", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L95-L115
train
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.get_record_rdd_from_rdd
def get_record_rdd_from_rdd( self, rdd: 'RDD', data_processor: DataProcessor = SimpleDictionaryDataProcessor(), ) -> 'RDD': """ Converts a RDD of raw events into the `Record`s format for processing. `data_processor` is used to process the per row data to c...
python
def get_record_rdd_from_rdd( self, rdd: 'RDD', data_processor: DataProcessor = SimpleDictionaryDataProcessor(), ) -> 'RDD': """ Converts a RDD of raw events into the `Record`s format for processing. `data_processor` is used to process the per row data to c...
[ "def", "get_record_rdd_from_rdd", "(", "self", ",", "rdd", ":", "'RDD'", ",", "data_processor", ":", "DataProcessor", "=", "SimpleDictionaryDataProcessor", "(", ")", ",", ")", "->", "'RDD'", ":", "return", "rdd", ".", "mapPartitions", "(", "lambda", "x", ":", ...
Converts a RDD of raw events into the `Record`s format for processing. `data_processor` is used to process the per row data to convert them into `Record`. :param rdd: RDD containing the raw events. :param data_processor: `DataProcessor` to process each row in the given `rdd`. :return: R...
[ "Converts", "a", "RDD", "of", "raw", "events", "into", "the", "Record", "s", "format", "for", "processing", ".", "data_processor", "is", "used", "to", "process", "the", "per", "row", "data", "to", "convert", "them", "into", "Record", "." ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L117-L132
train
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.write_output_file
def write_output_file(self, path: str, per_identity_data: 'RDD', spark_session: Optional['SparkSession'] = None) -> None: """ Basic helper function to persist data to disk. If window BTS was provided then the window B...
python
def write_output_file(self, path: str, per_identity_data: 'RDD', spark_session: Optional['SparkSession'] = None) -> None: """ Basic helper function to persist data to disk. If window BTS was provided then the window B...
[ "def", "write_output_file", "(", "self", ",", "path", ":", "str", ",", "per_identity_data", ":", "'RDD'", ",", "spark_session", ":", "Optional", "[", "'SparkSession'", "]", "=", "None", ")", "->", "None", ":", "_spark_session_", "=", "get_spark_session", "(", ...
Basic helper function to persist data to disk. If window BTS was provided then the window BTS output to written in csv format, otherwise, the streaming BTS output is written in JSON format to the `path` provided :param path: Path where the output should be written. :param per_identity_...
[ "Basic", "helper", "function", "to", "persist", "data", "to", "disk", "." ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L134-L158
train
productml/blurr
blurr/runner/spark_runner.py
SparkRunner.print_output
def print_output(self, per_identity_data: 'RDD') -> None: """ Basic helper function to write data to stdout. If window BTS was provided then the window BTS output is written, otherwise, the streaming BTS output is written to stdout. WARNING - For large datasets this will be extremely sl...
python
def print_output(self, per_identity_data: 'RDD') -> None: """ Basic helper function to write data to stdout. If window BTS was provided then the window BTS output is written, otherwise, the streaming BTS output is written to stdout. WARNING - For large datasets this will be extremely sl...
[ "def", "print_output", "(", "self", ",", "per_identity_data", ":", "'RDD'", ")", "->", "None", ":", "if", "not", "self", ".", "_window_bts", ":", "data", "=", "per_identity_data", ".", "flatMap", "(", "lambda", "x", ":", "[", "json", ".", "dumps", "(", ...
Basic helper function to write data to stdout. If window BTS was provided then the window BTS output is written, otherwise, the streaming BTS output is written to stdout. WARNING - For large datasets this will be extremely slow. :param per_identity_data: Output of the `execute()` call.
[ "Basic", "helper", "function", "to", "write", "data", "to", "stdout", ".", "If", "window", "BTS", "was", "provided", "then", "the", "window", "BTS", "output", "is", "written", "otherwise", "the", "streaming", "BTS", "output", "is", "written", "to", "stdout",...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/runner/spark_runner.py#L160-L177
train
shin-/dockerpy-creds
dockerpycreds/utils.py
find_executable
def find_executable(executable, path=None): """ As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe` """ if sys.platform != 'win32': return distutils.spawn.find_executable(executable, path) if path is None: path =...
python
def find_executable(executable, path=None): """ As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe` """ if sys.platform != 'win32': return distutils.spawn.find_executable(executable, path) if path is None: path =...
[ "def", "find_executable", "(", "executable", ",", "path", "=", "None", ")", ":", "if", "sys", ".", "platform", "!=", "'win32'", ":", "return", "distutils", ".", "spawn", ".", "find_executable", "(", "executable", ",", "path", ")", "if", "path", "is", "No...
As distutils.spawn.find_executable, but on Windows, look up every extension declared in PATHEXT instead of just `.exe`
[ "As", "distutils", ".", "spawn", ".", "find_executable", "but", "on", "Windows", "look", "up", "every", "extension", "declared", "in", "PATHEXT", "instead", "of", "just", ".", "exe" ]
9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/utils.py#L6-L29
train
shin-/dockerpy-creds
dockerpycreds/utils.py
create_environment_dict
def create_environment_dict(overrides): """ Create and return a copy of os.environ with the specified overrides """ result = os.environ.copy() result.update(overrides or {}) return result
python
def create_environment_dict(overrides): """ Create and return a copy of os.environ with the specified overrides """ result = os.environ.copy() result.update(overrides or {}) return result
[ "def", "create_environment_dict", "(", "overrides", ")", ":", "result", "=", "os", ".", "environ", ".", "copy", "(", ")", "result", ".", "update", "(", "overrides", "or", "{", "}", ")", "return", "result" ]
Create and return a copy of os.environ with the specified overrides
[ "Create", "and", "return", "a", "copy", "of", "os", ".", "environ", "with", "the", "specified", "overrides" ]
9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/utils.py#L32-L38
train
shin-/dockerpy-creds
dockerpycreds/store.py
Store.get
def get(self, server): """ Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') data = self._execute('get', server) result = json.load...
python
def get(self, server): """ Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') data = self._execute('get', server) result = json.load...
[ "def", "get", "(", "self", ",", "server", ")", ":", "if", "not", "isinstance", "(", "server", ",", "six", ".", "binary_type", ")", ":", "server", "=", "server", ".", "encode", "(", "'utf-8'", ")", "data", "=", "self", ".", "_execute", "(", "'get'", ...
Retrieve credentials for `server`. If no credentials are found, a `StoreError` will be raised.
[ "Retrieve", "credentials", "for", "server", ".", "If", "no", "credentials", "are", "found", "a", "StoreError", "will", "be", "raised", "." ]
9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/store.py#L29-L47
train
shin-/dockerpy-creds
dockerpycreds/store.py
Store.store
def store(self, server, username, secret): """ Store credentials for `server`. Raises a `StoreError` if an error occurs. """ data_input = json.dumps({ 'ServerURL': server, 'Username': username, 'Secret': secret }).encode('utf-8') re...
python
def store(self, server, username, secret): """ Store credentials for `server`. Raises a `StoreError` if an error occurs. """ data_input = json.dumps({ 'ServerURL': server, 'Username': username, 'Secret': secret }).encode('utf-8') re...
[ "def", "store", "(", "self", ",", "server", ",", "username", ",", "secret", ")", ":", "data_input", "=", "json", ".", "dumps", "(", "{", "'ServerURL'", ":", "server", ",", "'Username'", ":", "username", ",", "'Secret'", ":", "secret", "}", ")", ".", ...
Store credentials for `server`. Raises a `StoreError` if an error occurs.
[ "Store", "credentials", "for", "server", ".", "Raises", "a", "StoreError", "if", "an", "error", "occurs", "." ]
9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/store.py#L49-L58
train
shin-/dockerpy-creds
dockerpycreds/store.py
Store.erase
def erase(self, server): """ Erase credentials for `server`. Raises a `StoreError` if an error occurs. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') self._execute('erase', server)
python
def erase(self, server): """ Erase credentials for `server`. Raises a `StoreError` if an error occurs. """ if not isinstance(server, six.binary_type): server = server.encode('utf-8') self._execute('erase', server)
[ "def", "erase", "(", "self", ",", "server", ")", ":", "if", "not", "isinstance", "(", "server", ",", "six", ".", "binary_type", ")", ":", "server", "=", "server", ".", "encode", "(", "'utf-8'", ")", "self", ".", "_execute", "(", "'erase'", ",", "serv...
Erase credentials for `server`. Raises a `StoreError` if an error occurs.
[ "Erase", "credentials", "for", "server", ".", "Raises", "a", "StoreError", "if", "an", "error", "occurs", "." ]
9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4
https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/store.py#L60-L66
train
productml/blurr
blurr/core/transformer_streaming.py
StreamingTransformerSchema.get_identity
def get_identity(self, record: Record) -> str: """ Evaluates and returns the identity as specified in the schema. :param record: Record which is used to determine the identity. :return: The evaluated identity :raises: IdentityError if identity cannot be determined. """ ...
python
def get_identity(self, record: Record) -> str: """ Evaluates and returns the identity as specified in the schema. :param record: Record which is used to determine the identity. :return: The evaluated identity :raises: IdentityError if identity cannot be determined. """ ...
[ "def", "get_identity", "(", "self", ",", "record", ":", "Record", ")", "->", "str", ":", "context", "=", "self", ".", "schema_context", ".", "context", "context", ".", "add_record", "(", "record", ")", "identity", "=", "self", ".", "identity", ".", "eval...
Evaluates and returns the identity as specified in the schema. :param record: Record which is used to determine the identity. :return: The evaluated identity :raises: IdentityError if identity cannot be determined.
[ "Evaluates", "and", "returns", "the", "identity", "as", "specified", "in", "the", "schema", ".", ":", "param", "record", ":", "Record", "which", "is", "used", "to", "determine", "the", "identity", ".", ":", "return", ":", "The", "evaluated", "identity", ":...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/transformer_streaming.py#L29-L43
train
productml/blurr
blurr/core/transformer_streaming.py
StreamingTransformer.run_evaluate
def run_evaluate(self, record: Record): """ Evaluates and updates data in the StreamingTransformer. :param record: The 'source' record used for the update. :raises: IdentityError if identity is different from the one used during initialization. """ record_identity...
python
def run_evaluate(self, record: Record): """ Evaluates and updates data in the StreamingTransformer. :param record: The 'source' record used for the update. :raises: IdentityError if identity is different from the one used during initialization. """ record_identity...
[ "def", "run_evaluate", "(", "self", ",", "record", ":", "Record", ")", ":", "record_identity", "=", "self", ".", "_schema", ".", "get_identity", "(", "record", ")", "if", "self", ".", "_identity", "!=", "record_identity", ":", "raise", "IdentityError", "(", ...
Evaluates and updates data in the StreamingTransformer. :param record: The 'source' record used for the update. :raises: IdentityError if identity is different from the one used during initialization.
[ "Evaluates", "and", "updates", "data", "in", "the", "StreamingTransformer", ".", ":", "param", "record", ":", "The", "source", "record", "used", "for", "the", "update", ".", ":", "raises", ":", "IdentityError", "if", "identity", "is", "different", "from", "t...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/transformer_streaming.py#L65-L88
train
productml/blurr
blurr/core/aggregate.py
AggregateSchema.extend_schema_spec
def extend_schema_spec(self) -> None: """ Injects the identity field """ super().extend_schema_spec() identity_field = { 'Name': '_identity', 'Type': BtsType.STRING, 'Value': 'identity', ATTRIBUTE_INTERNAL: True } if self.ATTRIBUT...
python
def extend_schema_spec(self) -> None: """ Injects the identity field """ super().extend_schema_spec() identity_field = { 'Name': '_identity', 'Type': BtsType.STRING, 'Value': 'identity', ATTRIBUTE_INTERNAL: True } if self.ATTRIBUT...
[ "def", "extend_schema_spec", "(", "self", ")", "->", "None", ":", "super", "(", ")", ".", "extend_schema_spec", "(", ")", "identity_field", "=", "{", "'Name'", ":", "'_identity'", ",", "'Type'", ":", "BtsType", ".", "STRING", ",", "'Value'", ":", "'identit...
Injects the identity field
[ "Injects", "the", "identity", "field" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate.py#L38-L51
train
productml/blurr
blurr/core/aggregate.py
Aggregate._persist
def _persist(self) -> None: """ Persists the current data group """ if self._store: self._store.save(self._key, self._snapshot)
python
def _persist(self) -> None: """ Persists the current data group """ if self._store: self._store.save(self._key, self._snapshot)
[ "def", "_persist", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_store", ":", "self", ".", "_store", ".", "save", "(", "self", ".", "_key", ",", "self", ".", "_snapshot", ")" ]
Persists the current data group
[ "Persists", "the", "current", "data", "group" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/aggregate.py#L97-L102
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.add_schema_spec
def add_schema_spec(self, spec: Dict[str, Any], fully_qualified_parent_name: str = None) -> Optional[str]: """ Add a schema dictionary to the schema loader. The given schema is stored against fully_qualified_parent_name + ITEM_SEPARATOR('.') + schema.name. :param ...
python
def add_schema_spec(self, spec: Dict[str, Any], fully_qualified_parent_name: str = None) -> Optional[str]: """ Add a schema dictionary to the schema loader. The given schema is stored against fully_qualified_parent_name + ITEM_SEPARATOR('.') + schema.name. :param ...
[ "def", "add_schema_spec", "(", "self", ",", "spec", ":", "Dict", "[", "str", ",", "Any", "]", ",", "fully_qualified_parent_name", ":", "str", "=", "None", ")", "->", "Optional", "[", "str", "]", ":", "if", "not", "isinstance", "(", "spec", ",", "dict",...
Add a schema dictionary to the schema loader. The given schema is stored against fully_qualified_parent_name + ITEM_SEPARATOR('.') + schema.name. :param spec: Schema specification. :param fully_qualified_parent_name: Full qualified name of the parent. If None is passed then the schema is...
[ "Add", "a", "schema", "dictionary", "to", "the", "schema", "loader", ".", "The", "given", "schema", "is", "stored", "against", "fully_qualified_parent_name", "+", "ITEM_SEPARATOR", "(", ".", ")", "+", "schema", ".", "name", ".", ":", "param", "spec", ":", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L22-L58
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.add_errors
def add_errors(self, *errors: Union[BaseSchemaError, SchemaErrorCollection]) -> None: """ Adds errors to the error store for the schema """ for error in errors: self._error_cache.add(error)
python
def add_errors(self, *errors: Union[BaseSchemaError, SchemaErrorCollection]) -> None: """ Adds errors to the error store for the schema """ for error in errors: self._error_cache.add(error)
[ "def", "add_errors", "(", "self", ",", "*", "errors", ":", "Union", "[", "BaseSchemaError", ",", "SchemaErrorCollection", "]", ")", "->", "None", ":", "for", "error", "in", "errors", ":", "self", ".", "_error_cache", ".", "add", "(", "error", ")" ]
Adds errors to the error store for the schema
[ "Adds", "errors", "to", "the", "error", "store", "for", "the", "schema" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L60-L63
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_schema_object
def get_schema_object(self, fully_qualified_name: str) -> 'BaseSchema': """ Used to generate a schema object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the object needed. :return: An initialized schema object """ if full...
python
def get_schema_object(self, fully_qualified_name: str) -> 'BaseSchema': """ Used to generate a schema object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the object needed. :return: An initialized schema object """ if full...
[ "def", "get_schema_object", "(", "self", ",", "fully_qualified_name", ":", "str", ")", "->", "'BaseSchema'", ":", "if", "fully_qualified_name", "not", "in", "self", ".", "_schema_cache", ":", "spec", "=", "self", ".", "get_schema_spec", "(", "fully_qualified_name"...
Used to generate a schema object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the object needed. :return: An initialized schema object
[ "Used", "to", "generate", "a", "schema", "object", "from", "the", "given", "fully_qualified_name", ".", ":", "param", "fully_qualified_name", ":", "The", "fully", "qualified", "name", "of", "the", "object", "needed", ".", ":", "return", ":", "An", "initialized...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L80-L100
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_store
def get_store(self, fully_qualified_name: str) -> Optional['Store']: """ Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object """ if ful...
python
def get_store(self, fully_qualified_name: str) -> Optional['Store']: """ Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object """ if ful...
[ "def", "get_store", "(", "self", ",", "fully_qualified_name", ":", "str", ")", "->", "Optional", "[", "'Store'", "]", ":", "if", "fully_qualified_name", "not", "in", "self", ".", "_store_cache", ":", "schema", "=", "self", ".", "get_schema_object", "(", "ful...
Used to generate a store object from the given fully_qualified_name. :param fully_qualified_name: The fully qualified name of the store object needed. :return: An initialized store object
[ "Used", "to", "generate", "a", "store", "object", "from", "the", "given", "fully_qualified_name", ".", ":", "param", "fully_qualified_name", ":", "The", "fully", "qualified", "name", "of", "the", "store", "object", "needed", ".", ":", "return", ":", "An", "i...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L102-L122
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_nested_schema_object
def get_nested_schema_object(self, fully_qualified_parent_name: str, nested_item_name: str) -> Optional['BaseSchema']: """ Used to generate a schema object from the given fully_qualified_parent_name and the nested_item_name. :param fully_qualified_parent_...
python
def get_nested_schema_object(self, fully_qualified_parent_name: str, nested_item_name: str) -> Optional['BaseSchema']: """ Used to generate a schema object from the given fully_qualified_parent_name and the nested_item_name. :param fully_qualified_parent_...
[ "def", "get_nested_schema_object", "(", "self", ",", "fully_qualified_parent_name", ":", "str", ",", "nested_item_name", ":", "str", ")", "->", "Optional", "[", "'BaseSchema'", "]", ":", "return", "self", ".", "get_schema_object", "(", "self", ".", "get_fully_qual...
Used to generate a schema object from the given fully_qualified_parent_name and the nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param nested_item_name: The nested item name. :return: An initialized schema object of the nested item.
[ "Used", "to", "generate", "a", "schema", "object", "from", "the", "given", "fully_qualified_parent_name", "and", "the", "nested_item_name", ".", ":", "param", "fully_qualified_parent_name", ":", "The", "fully", "qualified", "name", "of", "the", "parent", ".", ":",...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L130-L140
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_fully_qualified_name
def get_fully_qualified_name(fully_qualified_parent_name: str, nested_item_name: str) -> str: """ Returns the fully qualified name by combining the fully_qualified_parent_name and nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param...
python
def get_fully_qualified_name(fully_qualified_parent_name: str, nested_item_name: str) -> str: """ Returns the fully qualified name by combining the fully_qualified_parent_name and nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param...
[ "def", "get_fully_qualified_name", "(", "fully_qualified_parent_name", ":", "str", ",", "nested_item_name", ":", "str", ")", "->", "str", ":", "return", "fully_qualified_parent_name", "+", "SchemaLoader", ".", "ITEM_SEPARATOR", "+", "nested_item_name" ]
Returns the fully qualified name by combining the fully_qualified_parent_name and nested_item_name. :param fully_qualified_parent_name: The fully qualified name of the parent. :param nested_item_name: The nested item name. :return: The fully qualified name of the nested item.
[ "Returns", "the", "fully", "qualified", "name", "by", "combining", "the", "fully_qualified_parent_name", "and", "nested_item_name", ".", ":", "param", "fully_qualified_parent_name", ":", "The", "fully", "qualified", "name", "of", "the", "parent", ".", ":", "param", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L143-L151
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_schema_spec
def get_schema_spec(self, fully_qualified_name: str) -> Dict[str, Any]: """ Used to retrieve the specifications of the schema from the given fully_qualified_name of schema. :param fully_qualified_name: The fully qualified name of the schema needed. :return: Schema dictionary. ...
python
def get_schema_spec(self, fully_qualified_name: str) -> Dict[str, Any]: """ Used to retrieve the specifications of the schema from the given fully_qualified_name of schema. :param fully_qualified_name: The fully qualified name of the schema needed. :return: Schema dictionary. ...
[ "def", "get_schema_spec", "(", "self", ",", "fully_qualified_name", ":", "str", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "fully_qualified_name", "not", "in", "self", ".", "_spec_cache", ":", "self", ".", "add_errors", "(", "SpecNotFoundErro...
Used to retrieve the specifications of the schema from the given fully_qualified_name of schema. :param fully_qualified_name: The fully qualified name of the schema needed. :return: Schema dictionary.
[ "Used", "to", "retrieve", "the", "specifications", "of", "the", "schema", "from", "the", "given", "fully_qualified_name", "of", "schema", ".", ":", "param", "fully_qualified_name", ":", "The", "fully", "qualified", "name", "of", "the", "schema", "needed", ".", ...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L153-L164
train
productml/blurr
blurr/core/schema_loader.py
SchemaLoader.get_schema_specs_of_type
def get_schema_specs_of_type(self, *schema_types: Type) -> Dict[str, Dict[str, Any]]: """ Returns a list of fully qualified names and schema dictionary tuples for the schema types provided. :param schema_types: Schema types. :return: List of fully qualified names and schema dicti...
python
def get_schema_specs_of_type(self, *schema_types: Type) -> Dict[str, Dict[str, Any]]: """ Returns a list of fully qualified names and schema dictionary tuples for the schema types provided. :param schema_types: Schema types. :return: List of fully qualified names and schema dicti...
[ "def", "get_schema_specs_of_type", "(", "self", ",", "*", "schema_types", ":", "Type", ")", "->", "Dict", "[", "str", ",", "Dict", "[", "str", ",", "Any", "]", "]", ":", "return", "{", "fq_name", ":", "schema", "for", "fq_name", ",", "schema", "in", ...
Returns a list of fully qualified names and schema dictionary tuples for the schema types provided. :param schema_types: Schema types. :return: List of fully qualified names and schema dictionary tuples.
[ "Returns", "a", "list", "of", "fully", "qualified", "names", "and", "schema", "dictionary", "tuples", "for", "the", "schema", "types", "provided", ".", ":", "param", "schema_types", ":", "Schema", "types", ".", ":", "return", ":", "List", "of", "fully", "q...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/schema_loader.py#L175-L187
train
productml/blurr
blurr/core/evaluation.py
EvaluationContext.global_add
def global_add(self, key: str, value: Any) -> None: """ Adds a key and value to the global dictionary """ self.global_context[key] = value
python
def global_add(self, key: str, value: Any) -> None: """ Adds a key and value to the global dictionary """ self.global_context[key] = value
[ "def", "global_add", "(", "self", ",", "key", ":", "str", ",", "value", ":", "Any", ")", "->", "None", ":", "self", ".", "global_context", "[", "key", "]", "=", "value" ]
Adds a key and value to the global dictionary
[ "Adds", "a", "key", "and", "value", "to", "the", "global", "dictionary" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/evaluation.py#L68-L72
train
productml/blurr
blurr/core/evaluation.py
EvaluationContext.merge
def merge(self, evaluation_context: 'EvaluationContext') -> None: """ Merges the provided evaluation context to the current evaluation context. :param evaluation_context: Evaluation context to merge. """ self.global_context.merge(evaluation_context.global_context) self.lo...
python
def merge(self, evaluation_context: 'EvaluationContext') -> None: """ Merges the provided evaluation context to the current evaluation context. :param evaluation_context: Evaluation context to merge. """ self.global_context.merge(evaluation_context.global_context) self.lo...
[ "def", "merge", "(", "self", ",", "evaluation_context", ":", "'EvaluationContext'", ")", "->", "None", ":", "self", ".", "global_context", ".", "merge", "(", "evaluation_context", ".", "global_context", ")", "self", ".", "local_context", ".", "merge", "(", "ev...
Merges the provided evaluation context to the current evaluation context. :param evaluation_context: Evaluation context to merge.
[ "Merges", "the", "provided", "evaluation", "context", "to", "the", "current", "evaluation", "context", ".", ":", "param", "evaluation_context", ":", "Evaluation", "context", "to", "merge", "." ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/evaluation.py#L91-L97
train
productml/blurr
blurr/core/evaluation.py
Expression.evaluate
def evaluate(self, evaluation_context: EvaluationContext) -> Any: """ Evaluates the expression with the context provided. If the execution results in failure, an ExpressionEvaluationException encapsulating the underlying exception is raised. :param evaluation_context: Global and...
python
def evaluate(self, evaluation_context: EvaluationContext) -> Any: """ Evaluates the expression with the context provided. If the execution results in failure, an ExpressionEvaluationException encapsulating the underlying exception is raised. :param evaluation_context: Global and...
[ "def", "evaluate", "(", "self", ",", "evaluation_context", ":", "EvaluationContext", ")", "->", "Any", ":", "try", ":", "if", "self", ".", "type", "==", "ExpressionType", ".", "EVAL", ":", "return", "eval", "(", "self", ".", "code_object", ",", "evaluation...
Evaluates the expression with the context provided. If the execution results in failure, an ExpressionEvaluationException encapsulating the underlying exception is raised. :param evaluation_context: Global and local context dictionary to be passed for evaluation
[ "Evaluates", "the", "expression", "with", "the", "context", "provided", ".", "If", "the", "execution", "results", "in", "failure", "an", "ExpressionEvaluationException", "encapsulating", "the", "underlying", "exception", "is", "raised", ".", ":", "param", "evaluatio...
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/evaluation.py#L120-L149
train
openclimatedata/pymagicc
pymagicc/core.py
_copy_files
def _copy_files(source, target): """ Copy all the files in source directory to target. Ignores subdirectories. """ source_files = listdir(source) if not exists(target): makedirs(target) for filename in source_files: full_filename = join(source, filename) if isfile(fu...
python
def _copy_files(source, target): """ Copy all the files in source directory to target. Ignores subdirectories. """ source_files = listdir(source) if not exists(target): makedirs(target) for filename in source_files: full_filename = join(source, filename) if isfile(fu...
[ "def", "_copy_files", "(", "source", ",", "target", ")", ":", "source_files", "=", "listdir", "(", "source", ")", "if", "not", "exists", "(", "target", ")", ":", "makedirs", "(", "target", ")", "for", "filename", "in", "source_files", ":", "full_filename",...
Copy all the files in source directory to target. Ignores subdirectories.
[ "Copy", "all", "the", "files", "in", "source", "directory", "to", "target", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L35-L47
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.create_copy
def create_copy(self): """ Initialises a temporary directory structure and copy of MAGICC configuration files and binary. """ if self.executable is None or not isfile(self.executable): raise FileNotFoundError( "Could not find MAGICC{} executable: {}".f...
python
def create_copy(self): """ Initialises a temporary directory structure and copy of MAGICC configuration files and binary. """ if self.executable is None or not isfile(self.executable): raise FileNotFoundError( "Could not find MAGICC{} executable: {}".f...
[ "def", "create_copy", "(", "self", ")", ":", "if", "self", ".", "executable", "is", "None", "or", "not", "isfile", "(", "self", ".", "executable", ")", ":", "raise", "FileNotFoundError", "(", "\"Could not find MAGICC{} executable: {}\"", ".", "format", "(", "s...
Initialises a temporary directory structure and copy of MAGICC configuration files and binary.
[ "Initialises", "a", "temporary", "directory", "structure", "and", "copy", "of", "MAGICC", "configuration", "files", "and", "binary", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L105-L148
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.run
def run(self, scenario=None, only=None, **kwargs): """ Run MAGICC and parse the output. As a reminder, putting ``out_parameters=1`` will cause MAGICC to write out its parameters into ``out/PARAMETERS.OUT`` and they will then be read into ``output.metadata["parameters"]`` where `...
python
def run(self, scenario=None, only=None, **kwargs): """ Run MAGICC and parse the output. As a reminder, putting ``out_parameters=1`` will cause MAGICC to write out its parameters into ``out/PARAMETERS.OUT`` and they will then be read into ``output.metadata["parameters"]`` where `...
[ "def", "run", "(", "self", ",", "scenario", "=", "None", ",", "only", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "exists", "(", "self", ".", "root_dir", ")", ":", "raise", "FileNotFoundError", "(", "self", ".", "root_dir", ")", "i...
Run MAGICC and parse the output. As a reminder, putting ``out_parameters=1`` will cause MAGICC to write out its parameters into ``out/PARAMETERS.OUT`` and they will then be read into ``output.metadata["parameters"]`` where ``output`` is the returned object. Parameters ---------...
[ "Run", "MAGICC", "and", "parse", "the", "output", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L170-L274
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.check_config
def check_config(self): """Check that our MAGICC ``.CFG`` files are set to safely work with PYMAGICC For further detail about why this is required, please see :ref:`MAGICC flags`. Raises ------ ValueError If we are not certain that the config written by PYMAGICC wil...
python
def check_config(self): """Check that our MAGICC ``.CFG`` files are set to safely work with PYMAGICC For further detail about why this is required, please see :ref:`MAGICC flags`. Raises ------ ValueError If we are not certain that the config written by PYMAGICC wil...
[ "def", "check_config", "(", "self", ")", ":", "cfg_error_msg", "=", "(", "\"PYMAGICC is not the only tuning model that will be used by \"", "\"`MAGCFG_USER.CFG`: your run is likely to fail/do odd things\"", ")", "emisscen_error_msg", "=", "(", "\"You have more than one `FILE_EMISSCEN_X...
Check that our MAGICC ``.CFG`` files are set to safely work with PYMAGICC For further detail about why this is required, please see :ref:`MAGICC flags`. Raises ------ ValueError If we are not certain that the config written by PYMAGICC will overwrite all other c...
[ "Check", "that", "our", "MAGICC", ".", "CFG", "files", "are", "set", "to", "safely", "work", "with", "PYMAGICC" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L293-L331
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.write
def write(self, mdata, name): """Write an input file to disk Parameters ---------- mdata : :obj:`pymagicc.io.MAGICCData` A MAGICCData instance with the data to write name : str The name of the file to write. The file will be written to the MAGICC ...
python
def write(self, mdata, name): """Write an input file to disk Parameters ---------- mdata : :obj:`pymagicc.io.MAGICCData` A MAGICCData instance with the data to write name : str The name of the file to write. The file will be written to the MAGICC ...
[ "def", "write", "(", "self", ",", "mdata", ",", "name", ")", ":", "mdata", ".", "write", "(", "join", "(", "self", ".", "run_dir", ",", "name", ")", ",", "self", ".", "version", ")" ]
Write an input file to disk Parameters ---------- mdata : :obj:`pymagicc.io.MAGICCData` A MAGICCData instance with the data to write name : str The name of the file to write. The file will be written to the MAGICC instance's run directory i.e. ``self...
[ "Write", "an", "input", "file", "to", "disk" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L333-L345
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.read_parameters
def read_parameters(self): """ Read a parameters.out file Returns ------- dict A dictionary containing all the configuration used by MAGICC """ param_fname = join(self.out_dir, "PARAMETERS.OUT") if not exists(param_fname): raise F...
python
def read_parameters(self): """ Read a parameters.out file Returns ------- dict A dictionary containing all the configuration used by MAGICC """ param_fname = join(self.out_dir, "PARAMETERS.OUT") if not exists(param_fname): raise F...
[ "def", "read_parameters", "(", "self", ")", ":", "param_fname", "=", "join", "(", "self", ".", "out_dir", ",", "\"PARAMETERS.OUT\"", ")", "if", "not", "exists", "(", "param_fname", ")", ":", "raise", "FileNotFoundError", "(", "\"No PARAMETERS.OUT found\"", ")", ...
Read a parameters.out file Returns ------- dict A dictionary containing all the configuration used by MAGICC
[ "Read", "a", "parameters", ".", "out", "file" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L347-L369
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.remove_temp_copy
def remove_temp_copy(self): """ Removes a temporary copy of the MAGICC version shipped with Pymagicc. """ if self.is_temp and self.root_dir is not None: shutil.rmtree(self.root_dir) self.root_dir = None
python
def remove_temp_copy(self): """ Removes a temporary copy of the MAGICC version shipped with Pymagicc. """ if self.is_temp and self.root_dir is not None: shutil.rmtree(self.root_dir) self.root_dir = None
[ "def", "remove_temp_copy", "(", "self", ")", ":", "if", "self", ".", "is_temp", "and", "self", ".", "root_dir", "is", "not", "None", ":", "shutil", ".", "rmtree", "(", "self", ".", "root_dir", ")", "self", ".", "root_dir", "=", "None" ]
Removes a temporary copy of the MAGICC version shipped with Pymagicc.
[ "Removes", "a", "temporary", "copy", "of", "the", "MAGICC", "version", "shipped", "with", "Pymagicc", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L371-L377
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_config
def set_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """ Create a configuration file for MAGICC. Writes a fortran namelist in run_dir. Parameters ---------- filename : str Name of configuration file to w...
python
def set_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """ Create a configuration file for MAGICC. Writes a fortran namelist in run_dir. Parameters ---------- filename : str Name of configuration file to w...
[ "def", "set_config", "(", "self", ",", "filename", "=", "\"MAGTUNE_PYMAGICC.CFG\"", ",", "top_level_key", "=", "\"nml_allcfgs\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_format_config", "(", "kwargs", ")", "fname", "=", "join", "(", ...
Create a configuration file for MAGICC. Writes a fortran namelist in run_dir. Parameters ---------- filename : str Name of configuration file to write top_level_key : str Name of namelist to be written in the configuration file kwar...
[ "Create", "a", "configuration", "file", "for", "MAGICC", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L379-L411
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.update_config
def update_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """Updates a configuration file for MAGICC Updates the contents of a fortran namelist in the run directory, creating a new namelist if none exists. Parameters --------...
python
def update_config( self, filename="MAGTUNE_PYMAGICC.CFG", top_level_key="nml_allcfgs", **kwargs ): """Updates a configuration file for MAGICC Updates the contents of a fortran namelist in the run directory, creating a new namelist if none exists. Parameters --------...
[ "def", "update_config", "(", "self", ",", "filename", "=", "\"MAGTUNE_PYMAGICC.CFG\"", ",", "top_level_key", "=", "\"nml_allcfgs\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", "=", "self", ".", "_format_config", "(", "kwargs", ")", "fname", "=", "join", "(...
Updates a configuration file for MAGICC Updates the contents of a fortran namelist in the run directory, creating a new namelist if none exists. Parameters ---------- filename : str Name of configuration file to write top_level_key : str Name of...
[ "Updates", "a", "configuration", "file", "for", "MAGICC" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L413-L450
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_zero_config
def set_zero_config(self): """Set config such that radiative forcing and temperature output will be zero This method is intended as a convenience only, it does not handle everything in an obvious way. Adjusting the parameter settings still requires great care and may behave unepexctedly...
python
def set_zero_config(self): """Set config such that radiative forcing and temperature output will be zero This method is intended as a convenience only, it does not handle everything in an obvious way. Adjusting the parameter settings still requires great care and may behave unepexctedly...
[ "def", "set_zero_config", "(", "self", ")", ":", "# zero_emissions is imported from scenarios module", "zero_emissions", ".", "write", "(", "join", "(", "self", ".", "run_dir", ",", "self", ".", "_scen_file_name", ")", ",", "self", ".", "version", ")", "time", "...
Set config such that radiative forcing and temperature output will be zero This method is intended as a convenience only, it does not handle everything in an obvious way. Adjusting the parameter settings still requires great care and may behave unepexctedly.
[ "Set", "config", "such", "that", "radiative", "forcing", "and", "temperature", "output", "will", "be", "zero" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L452-L574
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_years
def set_years(self, startyear=1765, endyear=2100): """ Set the start and end dates of the simulations. Parameters ---------- startyear : int Start year of the simulation endyear : int End year of the simulation Returns ------- ...
python
def set_years(self, startyear=1765, endyear=2100): """ Set the start and end dates of the simulations. Parameters ---------- startyear : int Start year of the simulation endyear : int End year of the simulation Returns ------- ...
[ "def", "set_years", "(", "self", ",", "startyear", "=", "1765", ",", "endyear", "=", "2100", ")", ":", "# TODO: test altering stepsperyear, I think 1, 2 and 24 should all work", "return", "self", ".", "set_config", "(", "\"MAGCFG_NMLYEARS.CFG\"", ",", "\"nml_years\"", "...
Set the start and end dates of the simulations. Parameters ---------- startyear : int Start year of the simulation endyear : int End year of the simulation Returns ------- dict The contents of the namelist
[ "Set", "the", "start", "and", "end", "dates", "of", "the", "simulations", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L606-L630
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_output_variables
def set_output_variables(self, write_ascii=True, write_binary=False, **kwargs): """Set the output configuration, minimising output as much as possible There are a number of configuration parameters which control which variables are written to file and in which format. Limiting the variables tha...
python
def set_output_variables(self, write_ascii=True, write_binary=False, **kwargs): """Set the output configuration, minimising output as much as possible There are a number of configuration parameters which control which variables are written to file and in which format. Limiting the variables tha...
[ "def", "set_output_variables", "(", "self", ",", "write_ascii", "=", "True", ",", "write_binary", "=", "False", ",", "*", "*", "kwargs", ")", ":", "assert", "(", "write_ascii", "or", "write_binary", ")", ",", "\"write_binary and/or write_ascii must be configured\"",...
Set the output configuration, minimising output as much as possible There are a number of configuration parameters which control which variables are written to file and in which format. Limiting the variables that are written to file can greatly speed up the running of MAGICC. By default, ...
[ "Set", "the", "output", "configuration", "minimising", "output", "as", "much", "as", "possible" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L632-L735
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.diagnose_tcr_ecs
def diagnose_tcr_ecs(self, **kwargs): """Diagnose TCR and ECS The transient climate response (TCR), is the global-mean temperature response at time at which atmopsheric |CO2| concentrations double in a scenario where atmospheric |CO2| concentrations are increased at 1% per year from ...
python
def diagnose_tcr_ecs(self, **kwargs): """Diagnose TCR and ECS The transient climate response (TCR), is the global-mean temperature response at time at which atmopsheric |CO2| concentrations double in a scenario where atmospheric |CO2| concentrations are increased at 1% per year from ...
[ "def", "diagnose_tcr_ecs", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "version", "==", "7", ":", "raise", "NotImplementedError", "(", "\"MAGICC7 cannot yet diagnose ECS and TCR\"", ")", "self", ".", "_diagnose_tcr_ecs_config_setup", "(", "*...
Diagnose TCR and ECS The transient climate response (TCR), is the global-mean temperature response at time at which atmopsheric |CO2| concentrations double in a scenario where atmospheric |CO2| concentrations are increased at 1% per year from pre-industrial levels. The equilibr...
[ "Diagnose", "TCR", "and", "ECS" ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L740-L783
train
openclimatedata/pymagicc
pymagicc/core.py
MAGICCBase.set_emission_scenario_setup
def set_emission_scenario_setup(self, scenario, config_dict): """Set the emissions flags correctly. Parameters ---------- scenario : :obj:`pymagicc.io.MAGICCData` Scenario to run. config_dict : dict Dictionary with current input configurations which is t...
python
def set_emission_scenario_setup(self, scenario, config_dict): """Set the emissions flags correctly. Parameters ---------- scenario : :obj:`pymagicc.io.MAGICCData` Scenario to run. config_dict : dict Dictionary with current input configurations which is t...
[ "def", "set_emission_scenario_setup", "(", "self", ",", "scenario", ",", "config_dict", ")", ":", "self", ".", "write", "(", "scenario", ",", "self", ".", "_scen_file_name", ")", "# can be lazy in this line as fix backwards key handles errors for us", "config_dict", "[", ...
Set the emissions flags correctly. Parameters ---------- scenario : :obj:`pymagicc.io.MAGICCData` Scenario to run. config_dict : dict Dictionary with current input configurations which is to be validated and updated where necessary. Returns ...
[ "Set", "the", "emissions", "flags", "correctly", "." ]
d896014832cf458d1e95e5878fd6d5961f3e2e05
https://github.com/openclimatedata/pymagicc/blob/d896014832cf458d1e95e5878fd6d5961f3e2e05/pymagicc/core.py#L903-L925
train
productml/blurr
blurr/core/type.py
Type.contains
def contains(value: Union[str, 'Type']) -> bool: """ Checks if a type is defined """ if isinstance(value, str): return any(value.lower() == i.value for i in Type) return any(value == i for i in Type)
python
def contains(value: Union[str, 'Type']) -> bool: """ Checks if a type is defined """ if isinstance(value, str): return any(value.lower() == i.value for i in Type) return any(value == i for i in Type)
[ "def", "contains", "(", "value", ":", "Union", "[", "str", ",", "'Type'", "]", ")", "->", "bool", ":", "if", "isinstance", "(", "value", ",", "str", ")", ":", "return", "any", "(", "value", ".", "lower", "(", ")", "==", "i", ".", "value", "for", ...
Checks if a type is defined
[ "Checks", "if", "a", "type", "is", "defined" ]
1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa
https://github.com/productml/blurr/blob/1b688b2c4a9bbbb2139c58bf0682ddc05a6c24fa/blurr/core/type.py#L48-L53
train
hydpy-dev/hydpy
hydpy/exe/replacetools.py
xml_replace
def xml_replace(filename, **replacements): """Read the content of an XML template file (XMLT), apply the given `replacements` to its substitution markers, and write the result into an XML file with the same name but ending with `xml` instead of `xmlt`. First, we write an XMLT file, containing a regula...
python
def xml_replace(filename, **replacements): """Read the content of an XML template file (XMLT), apply the given `replacements` to its substitution markers, and write the result into an XML file with the same name but ending with `xml` instead of `xmlt`. First, we write an XMLT file, containing a regula...
[ "def", "xml_replace", "(", "filename", ",", "*", "*", "replacements", ")", ":", "keywords", "=", "set", "(", "replacements", ".", "keys", "(", ")", ")", "templatename", "=", "f'{filename}.xmlt'", "targetname", "=", "f'{filename}.xml'", "print", "(", "f'templat...
Read the content of an XML template file (XMLT), apply the given `replacements` to its substitution markers, and write the result into an XML file with the same name but ending with `xml` instead of `xmlt`. First, we write an XMLT file, containing a regular HTML comment, a readily defined element `e1`...
[ "Read", "the", "content", "of", "an", "XML", "template", "file", "(", "XMLT", ")", "apply", "the", "given", "replacements", "to", "its", "substitution", "markers", "and", "write", "the", "result", "into", "an", "XML", "file", "with", "the", "same", "name",...
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/exe/replacetools.py#L9-L211
train
hydpy-dev/hydpy
hydpy/core/indextools.py
IndexerProperty._calcidxs
def _calcidxs(func): """Return the required indexes based on the given lambda function and the |Timegrids| object handled by module |pub|. Raise a |RuntimeError| if the latter is not available. """ timegrids = hydpy.pub.get('timegrids') if timegrids is None: ...
python
def _calcidxs(func): """Return the required indexes based on the given lambda function and the |Timegrids| object handled by module |pub|. Raise a |RuntimeError| if the latter is not available. """ timegrids = hydpy.pub.get('timegrids') if timegrids is None: ...
[ "def", "_calcidxs", "(", "func", ")", ":", "timegrids", "=", "hydpy", ".", "pub", ".", "get", "(", "'timegrids'", ")", "if", "timegrids", "is", "None", ":", "raise", "RuntimeError", "(", "'An Indexer object has been asked for an %s array. Such an '", "'array has ne...
Return the required indexes based on the given lambda function and the |Timegrids| object handled by module |pub|. Raise a |RuntimeError| if the latter is not available.
[ "Return", "the", "required", "indexes", "based", "on", "the", "given", "lambda", "function", "and", "the", "|Timegrids|", "object", "handled", "by", "module", "|pub|", ".", "Raise", "a", "|RuntimeError|", "if", "the", "latter", "is", "not", "available", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/indextools.py#L132-L151
train
hydpy-dev/hydpy
hydpy/core/indextools.py
Indexer.dayofyear
def dayofyear(self): """Day of the year index (the first of January = 0...). For reasons of consistency between leap years and non-leap years, assuming a daily time step, index 59 is always associated with the 29th of February. Hence, it is missing in non-leap years: >>> from ...
python
def dayofyear(self): """Day of the year index (the first of January = 0...). For reasons of consistency between leap years and non-leap years, assuming a daily time step, index 59 is always associated with the 29th of February. Hence, it is missing in non-leap years: >>> from ...
[ "def", "dayofyear", "(", "self", ")", ":", "def", "_dayofyear", "(", "date", ")", ":", "return", "(", "date", ".", "dayofyear", "-", "1", "+", "(", "(", "date", ".", "month", ">", "2", ")", "and", "(", "not", "date", ".", "leapyear", ")", ")", ...
Day of the year index (the first of January = 0...). For reasons of consistency between leap years and non-leap years, assuming a daily time step, index 59 is always associated with the 29th of February. Hence, it is missing in non-leap years: >>> from hydpy import pub >>> fro...
[ "Day", "of", "the", "year", "index", "(", "the", "first", "of", "January", "=", "0", "...", ")", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/indextools.py#L188-L207
train
hydpy-dev/hydpy
hydpy/core/indextools.py
Indexer.timeofyear
def timeofyear(self): """Time of the year index (first simulation step of each year = 0...). The property |Indexer.timeofyear| is best explained through comparing it with property |Indexer.dayofyear|: Let us reconsider one of the examples of the documentation on property |Index...
python
def timeofyear(self): """Time of the year index (first simulation step of each year = 0...). The property |Indexer.timeofyear| is best explained through comparing it with property |Indexer.dayofyear|: Let us reconsider one of the examples of the documentation on property |Index...
[ "def", "timeofyear", "(", "self", ")", ":", "refgrid", "=", "timetools", ".", "Timegrid", "(", "timetools", ".", "Date", "(", "'2000.01.01'", ")", ",", "timetools", ".", "Date", "(", "'2001.01.01'", ")", ",", "hydpy", ".", "pub", ".", "timegrids", ".", ...
Time of the year index (first simulation step of each year = 0...). The property |Indexer.timeofyear| is best explained through comparing it with property |Indexer.dayofyear|: Let us reconsider one of the examples of the documentation on property |Indexer.dayofyear|: >>> from ...
[ "Time", "of", "the", "year", "index", "(", "first", "simulation", "step", "of", "each", "year", "=", "0", "...", ")", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/indextools.py#L210-L261
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
BaseProperty.set_doc
def set_doc(self, doc: str): """Assign the given docstring to the property instance and, if possible, to the `__test__` dictionary of the module of its owner class.""" self.__doc__ = doc if hasattr(self, 'module'): ref = f'{self.objtype.__name__}.{self.name}' ...
python
def set_doc(self, doc: str): """Assign the given docstring to the property instance and, if possible, to the `__test__` dictionary of the module of its owner class.""" self.__doc__ = doc if hasattr(self, 'module'): ref = f'{self.objtype.__name__}.{self.name}' ...
[ "def", "set_doc", "(", "self", ",", "doc", ":", "str", ")", ":", "self", ".", "__doc__", "=", "doc", "if", "hasattr", "(", "self", ",", "'module'", ")", ":", "ref", "=", "f'{self.objtype.__name__}.{self.name}'", "self", ".", "module", ".", "__dict__", "[...
Assign the given docstring to the property instance and, if possible, to the `__test__` dictionary of the module of its owner class.
[ "Assign", "the", "given", "docstring", "to", "the", "property", "instance", "and", "if", "possible", "to", "the", "__test__", "dictionary", "of", "the", "module", "of", "its", "owner", "class", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L139-L146
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
BaseProperty.getter_
def getter_(self, fget) -> 'BaseProperty': """Add the given getter function and its docstring to the property and return it.""" self.fget = fget self.set_doc(fget.__doc__) return self
python
def getter_(self, fget) -> 'BaseProperty': """Add the given getter function and its docstring to the property and return it.""" self.fget = fget self.set_doc(fget.__doc__) return self
[ "def", "getter_", "(", "self", ",", "fget", ")", "->", "'BaseProperty'", ":", "self", ".", "fget", "=", "fget", "self", ".", "set_doc", "(", "fget", ".", "__doc__", ")", "return", "self" ]
Add the given getter function and its docstring to the property and return it.
[ "Add", "the", "given", "getter", "function", "and", "its", "docstring", "to", "the", "property", "and", "return", "it", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L160-L165
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
ProtectedProperty.isready
def isready(self, obj) -> bool: """Return |True| or |False| to indicate if the protected property is ready for the given object. If the object is unknow, |ProtectedProperty| returns |False|.""" return vars(obj).get(self.name, False)
python
def isready(self, obj) -> bool: """Return |True| or |False| to indicate if the protected property is ready for the given object. If the object is unknow, |ProtectedProperty| returns |False|.""" return vars(obj).get(self.name, False)
[ "def", "isready", "(", "self", ",", "obj", ")", "->", "bool", ":", "return", "vars", "(", "obj", ")", ".", "get", "(", "self", ".", "name", ",", "False", ")" ]
Return |True| or |False| to indicate if the protected property is ready for the given object. If the object is unknow, |ProtectedProperty| returns |False|.
[ "Return", "|True|", "or", "|False|", "to", "indicate", "if", "the", "protected", "property", "is", "ready", "for", "the", "given", "object", ".", "If", "the", "object", "is", "unknow", "|ProtectedProperty|", "returns", "|False|", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L276-L280
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
ProtectedProperties.allready
def allready(self, obj) -> bool: """Return |True| or |False| to indicate whether all protected properties are ready or not.""" for prop in self.__properties: if not prop.isready(obj): return False return True
python
def allready(self, obj) -> bool: """Return |True| or |False| to indicate whether all protected properties are ready or not.""" for prop in self.__properties: if not prop.isready(obj): return False return True
[ "def", "allready", "(", "self", ",", "obj", ")", "->", "bool", ":", "for", "prop", "in", "self", ".", "__properties", ":", "if", "not", "prop", ".", "isready", "(", "obj", ")", ":", "return", "False", "return", "True" ]
Return |True| or |False| to indicate whether all protected properties are ready or not.
[ "Return", "|True|", "or", "|False|", "to", "indicate", "whether", "all", "protected", "properties", "are", "ready", "or", "not", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L324-L330
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
DefaultProperty.call_fget
def call_fget(self, obj) -> Any: """Return the predefined custom value when available, otherwise, the value defined by the getter function.""" custom = vars(obj).get(self.name) if custom is None: return self.fget(obj) return custom
python
def call_fget(self, obj) -> Any: """Return the predefined custom value when available, otherwise, the value defined by the getter function.""" custom = vars(obj).get(self.name) if custom is None: return self.fget(obj) return custom
[ "def", "call_fget", "(", "self", ",", "obj", ")", "->", "Any", ":", "custom", "=", "vars", "(", "obj", ")", ".", "get", "(", "self", ".", "name", ")", "if", "custom", "is", "None", ":", "return", "self", ".", "fget", "(", "obj", ")", "return", ...
Return the predefined custom value when available, otherwise, the value defined by the getter function.
[ "Return", "the", "predefined", "custom", "value", "when", "available", "otherwise", "the", "value", "defined", "by", "the", "getter", "function", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L528-L534
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
DefaultProperty.call_fset
def call_fset(self, obj, value) -> None: """Store the given custom value and call the setter function.""" vars(obj)[self.name] = self.fset(obj, value)
python
def call_fset(self, obj, value) -> None: """Store the given custom value and call the setter function.""" vars(obj)[self.name] = self.fset(obj, value)
[ "def", "call_fset", "(", "self", ",", "obj", ",", "value", ")", "->", "None", ":", "vars", "(", "obj", ")", "[", "self", ".", "name", "]", "=", "self", ".", "fset", "(", "obj", ",", "value", ")" ]
Store the given custom value and call the setter function.
[ "Store", "the", "given", "custom", "value", "and", "call", "the", "setter", "function", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L536-L538
train
hydpy-dev/hydpy
hydpy/core/propertytools.py
DefaultProperty.call_fdel
def call_fdel(self, obj) -> None: """Remove the predefined custom value and call the delete function.""" self.fdel(obj) try: del vars(obj)[self.name] except KeyError: pass
python
def call_fdel(self, obj) -> None: """Remove the predefined custom value and call the delete function.""" self.fdel(obj) try: del vars(obj)[self.name] except KeyError: pass
[ "def", "call_fdel", "(", "self", ",", "obj", ")", "->", "None", ":", "self", ".", "fdel", "(", "obj", ")", "try", ":", "del", "vars", "(", "obj", ")", "[", "self", ".", "name", "]", "except", "KeyError", ":", "pass" ]
Remove the predefined custom value and call the delete function.
[ "Remove", "the", "predefined", "custom", "value", "and", "call", "the", "delete", "function", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/propertytools.py#L540-L546
train
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
RelWZ.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwb.values = 0.5 >>> relwz(0.2, 0.5, 0.8) >>> relwz ...
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwb.values = 0.5 >>> relwz(0.2, 0.5, 0.8) >>> relwz ...
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "lower", "is", "None", ":", "lower", "=", "getattr", "(", "self", ".", "subpars", ".", "relwb", ",", "'value'", ",", "None", ")", "lland_parameters", ...
Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwb.values = 0.5 >>> relwz(0.2, 0.5, 0.8) >>> relwz relwz(0.5, 0.5, 0.8)
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "RelWB", "\\\\", "leq", "RelWZ", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L313-L327
train
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
RelWB.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwz.values = 0.5 >>> relwb(0.2, 0.5, 0.8) >>> relwb ...
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwz.values = 0.5 >>> relwb(0.2, 0.5, 0.8) >>> relwb ...
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "upper", "is", "None", ":", "upper", "=", "getattr", "(", "self", ".", "subpars", ".", "relwz", ",", "'value'", ",", "None", ")", "lland_parameters", ...
Trim upper values in accordance with :math:`RelWB \\leq RelWZ`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> nhru(3) >>> lnk(ACKER) >>> relwz.values = 0.5 >>> relwb(0.2, 0.5, 0.8) >>> relwb relwb(0.2, 0.5, 0.5)
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "RelWB", "\\\\", "leq", "RelWZ", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L336-L350
train
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
EQB.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqi1.value = 2.0 >>> eqb(1.0) >>> eqb eqb(2.0) >>> eqb(2.0) >>> eqb eq...
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqi1.value = 2.0 >>> eqb(1.0) >>> eqb eqb(2.0) >>> eqb(2.0) >>> eqb eq...
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "lower", "is", "None", ":", "lower", "=", "getattr", "(", "self", ".", "subpars", ".", "eqi1", ",", "'value'", ",", "None", ")", "super", "(", ")", ...
Trim upper values in accordance with :math:`EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqi1.value = 2.0 >>> eqb(1.0) >>> eqb eqb(2.0) >>> eqb(2.0) >>> eqb eqb(2.0) >>> eqb(3.0) >>> eqb ...
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "EQI1", "\\\\", "leq", "EQB", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L661-L679
train
hydpy-dev/hydpy
hydpy/models/lland/lland_control.py
EQI1.trim
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`EQI2 \\leq EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqb.value = 3.0 >>> eqi2.value = 1.0 >>> eqi1(0.0) >>> eqi1 eqi1(1....
python
def trim(self, lower=None, upper=None): """Trim upper values in accordance with :math:`EQI2 \\leq EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqb.value = 3.0 >>> eqi2.value = 1.0 >>> eqi1(0.0) >>> eqi1 eqi1(1....
[ "def", "trim", "(", "self", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "if", "lower", "is", "None", ":", "lower", "=", "getattr", "(", "self", ".", "subpars", ".", "eqi2", ",", "'value'", ",", "None", ")", "if", "upper", "is"...
Trim upper values in accordance with :math:`EQI2 \\leq EQI1 \\leq EQB`. >>> from hydpy.models.lland import * >>> parameterstep('1d') >>> eqb.value = 3.0 >>> eqi2.value = 1.0 >>> eqi1(0.0) >>> eqi1 eqi1(1.0) >>> eqi1(1.0) >>> eqi1 e...
[ "Trim", "upper", "values", "in", "accordance", "with", ":", "math", ":", "EQI2", "\\\\", "leq", "EQI1", "\\\\", "leq", "EQB", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/models/lland/lland_control.py#L689-L717
train
arteria/django-openinghours
openinghours/forms.py
time_choices
def time_choices(): """Return digital time choices every half hour from 00:00 to 23:30.""" hours = list(range(0, 24)) times = [] for h in hours: hour = str(h).zfill(2) times.append(hour+':00') times.append(hour+':30') return list(zip(times, times))
python
def time_choices(): """Return digital time choices every half hour from 00:00 to 23:30.""" hours = list(range(0, 24)) times = [] for h in hours: hour = str(h).zfill(2) times.append(hour+':00') times.append(hour+':30') return list(zip(times, times))
[ "def", "time_choices", "(", ")", ":", "hours", "=", "list", "(", "range", "(", "0", ",", "24", ")", ")", "times", "=", "[", "]", "for", "h", "in", "hours", ":", "hour", "=", "str", "(", "h", ")", ".", "zfill", "(", "2", ")", "times", ".", "...
Return digital time choices every half hour from 00:00 to 23:30.
[ "Return", "digital", "time", "choices", "every", "half", "hour", "from", "00", ":", "00", "to", "23", ":", "30", "." ]
6bad47509a14d65a3a5a08777455f4cc8b4961fa
https://github.com/arteria/django-openinghours/blob/6bad47509a14d65a3a5a08777455f4cc8b4961fa/openinghours/forms.py#L23-L31
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
_add_lines
def _add_lines(specification, module): """Return autodoc commands for a basemodels docstring. Note that `collection classes` (e.g. `Model`, `ControlParameters`, `InputSequences` are placed on top of the respective section and the `contained classes` (e.g. model methods, `ControlParameter` instances, ...
python
def _add_lines(specification, module): """Return autodoc commands for a basemodels docstring. Note that `collection classes` (e.g. `Model`, `ControlParameters`, `InputSequences` are placed on top of the respective section and the `contained classes` (e.g. model methods, `ControlParameter` instances, ...
[ "def", "_add_lines", "(", "specification", ",", "module", ")", ":", "caption", "=", "_all_spec2capt", ".", "get", "(", "specification", ",", "'dummy'", ")", "if", "caption", ".", "split", "(", ")", "[", "-", "1", "]", "in", "(", "'parameters'", ",", "'...
Return autodoc commands for a basemodels docstring. Note that `collection classes` (e.g. `Model`, `ControlParameters`, `InputSequences` are placed on top of the respective section and the `contained classes` (e.g. model methods, `ControlParameter` instances, `InputSequence` instances at the bottom. Th...
[ "Return", "autodoc", "commands", "for", "a", "basemodels", "docstring", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L79-L116
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
autodoc_basemodel
def autodoc_basemodel(module): """Add an exhaustive docstring to the given module of a basemodel. Works onlye when all modules of the basemodel are named in the standard way, e.g. `lland_model`, `lland_control`, `lland_inputs`. """ autodoc_tuple2doc(module) namespace = module.__dict__ doc =...
python
def autodoc_basemodel(module): """Add an exhaustive docstring to the given module of a basemodel. Works onlye when all modules of the basemodel are named in the standard way, e.g. `lland_model`, `lland_control`, `lland_inputs`. """ autodoc_tuple2doc(module) namespace = module.__dict__ doc =...
[ "def", "autodoc_basemodel", "(", "module", ")", ":", "autodoc_tuple2doc", "(", "module", ")", "namespace", "=", "module", ".", "__dict__", "doc", "=", "namespace", ".", "get", "(", "'__doc__'", ")", "if", "doc", "is", "None", ":", "doc", "=", "''", "base...
Add an exhaustive docstring to the given module of a basemodel. Works onlye when all modules of the basemodel are named in the standard way, e.g. `lland_model`, `lland_control`, `lland_inputs`.
[ "Add", "an", "exhaustive", "docstring", "to", "the", "given", "module", "of", "a", "basemodel", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L128-L172
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
autodoc_applicationmodel
def autodoc_applicationmodel(module): """Improves the docstrings of application models when called at the bottom of the respective module. |autodoc_applicationmodel| requires, similar to |autodoc_basemodel|, that both the application model and its base model are defined in the conventional way. ...
python
def autodoc_applicationmodel(module): """Improves the docstrings of application models when called at the bottom of the respective module. |autodoc_applicationmodel| requires, similar to |autodoc_basemodel|, that both the application model and its base model are defined in the conventional way. ...
[ "def", "autodoc_applicationmodel", "(", "module", ")", ":", "autodoc_tuple2doc", "(", "module", ")", "name_applicationmodel", "=", "module", ".", "__name__", "name_basemodel", "=", "name_applicationmodel", ".", "split", "(", "'_'", ")", "[", "0", "]", "module_base...
Improves the docstrings of application models when called at the bottom of the respective module. |autodoc_applicationmodel| requires, similar to |autodoc_basemodel|, that both the application model and its base model are defined in the conventional way.
[ "Improves", "the", "docstrings", "of", "application", "models", "when", "called", "at", "the", "bottom", "of", "the", "respective", "module", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L175-L190
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
prepare_mainsubstituter
def prepare_mainsubstituter(): """Prepare and return a |Substituter| object for the main `__init__` file of *HydPy*.""" substituter = Substituter() for module in (builtins, numpy, datetime, unittest, doctest, inspect, io, os, sys, time, collections, itertools, subprocess, scipy, ...
python
def prepare_mainsubstituter(): """Prepare and return a |Substituter| object for the main `__init__` file of *HydPy*.""" substituter = Substituter() for module in (builtins, numpy, datetime, unittest, doctest, inspect, io, os, sys, time, collections, itertools, subprocess, scipy, ...
[ "def", "prepare_mainsubstituter", "(", ")", ":", "substituter", "=", "Substituter", "(", ")", "for", "module", "in", "(", "builtins", ",", "numpy", ",", "datetime", ",", "unittest", ",", "doctest", ",", "inspect", ",", "io", ",", "os", ",", "sys", ",", ...
Prepare and return a |Substituter| object for the main `__init__` file of *HydPy*.
[ "Prepare", "and", "return", "a", "|Substituter|", "object", "for", "the", "main", "__init__", "file", "of", "*", "HydPy", "*", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L657-L674
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
_number_of_line
def _number_of_line(member_tuple): """Try to return the number of the first line of the definition of a member of a module.""" member = member_tuple[1] try: return member.__code__.co_firstlineno except AttributeError: pass try: return inspect.findsource(member)[1] exc...
python
def _number_of_line(member_tuple): """Try to return the number of the first line of the definition of a member of a module.""" member = member_tuple[1] try: return member.__code__.co_firstlineno except AttributeError: pass try: return inspect.findsource(member)[1] exc...
[ "def", "_number_of_line", "(", "member_tuple", ")", ":", "member", "=", "member_tuple", "[", "1", "]", "try", ":", "return", "member", ".", "__code__", ".", "co_firstlineno", "except", "AttributeError", ":", "pass", "try", ":", "return", "inspect", ".", "fin...
Try to return the number of the first line of the definition of a member of a module.
[ "Try", "to", "return", "the", "number", "of", "the", "first", "line", "of", "the", "definition", "of", "a", "member", "of", "a", "module", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L677-L694
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
autodoc_module
def autodoc_module(module): """Add a short summary of all implemented members to a modules docstring. """ doc = getattr(module, '__doc__') if doc is None: doc = '' members = [] for name, member in inspect.getmembers(module): if ((not name.startswith('_')) and (ins...
python
def autodoc_module(module): """Add a short summary of all implemented members to a modules docstring. """ doc = getattr(module, '__doc__') if doc is None: doc = '' members = [] for name, member in inspect.getmembers(module): if ((not name.startswith('_')) and (ins...
[ "def", "autodoc_module", "(", "module", ")", ":", "doc", "=", "getattr", "(", "module", ",", "'__doc__'", ")", "if", "doc", "is", "None", ":", "doc", "=", "''", "members", "=", "[", "]", "for", "name", ",", "member", "in", "inspect", ".", "getmembers...
Add a short summary of all implemented members to a modules docstring.
[ "Add", "a", "short", "summary", "of", "all", "implemented", "members", "to", "a", "modules", "docstring", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L697-L722
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
autodoc_tuple2doc
def autodoc_tuple2doc(module): """Include tuples as `CLASSES` of `ControlParameters` and `RUN_METHODS` of `Models` into the respective docstring.""" modulename = module.__name__ for membername, member in inspect.getmembers(module): for tuplename, descr in _name2descr.items(): tuple_ ...
python
def autodoc_tuple2doc(module): """Include tuples as `CLASSES` of `ControlParameters` and `RUN_METHODS` of `Models` into the respective docstring.""" modulename = module.__name__ for membername, member in inspect.getmembers(module): for tuplename, descr in _name2descr.items(): tuple_ ...
[ "def", "autodoc_tuple2doc", "(", "module", ")", ":", "modulename", "=", "module", ".", "__name__", "for", "membername", ",", "member", "in", "inspect", ".", "getmembers", "(", "module", ")", ":", "for", "tuplename", ",", "descr", "in", "_name2descr", ".", ...
Include tuples as `CLASSES` of `ControlParameters` and `RUN_METHODS` of `Models` into the respective docstring.
[ "Include", "tuples", "as", "CLASSES", "of", "ControlParameters", "and", "RUN_METHODS", "of", "Models", "into", "the", "respective", "docstring", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L756-L780
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.consider_member
def consider_member(name_member, member, module, class_=None): """Return |True| if the given member should be added to the substitutions. If not return |False|. Some examples based on the site-package |numpy|: >>> from hydpy.core.autodoctools import Substituter >>> import numpy...
python
def consider_member(name_member, member, module, class_=None): """Return |True| if the given member should be added to the substitutions. If not return |False|. Some examples based on the site-package |numpy|: >>> from hydpy.core.autodoctools import Substituter >>> import numpy...
[ "def", "consider_member", "(", "name_member", ",", "member", ",", "module", ",", "class_", "=", "None", ")", ":", "if", "name_member", ".", "startswith", "(", "'_'", ")", ":", "return", "False", "if", "inspect", ".", "ismodule", "(", "member", ")", ":", ...
Return |True| if the given member should be added to the substitutions. If not return |False|. Some examples based on the site-package |numpy|: >>> from hydpy.core.autodoctools import Substituter >>> import numpy A constant like |nan| should be added: >>> Substituter....
[ "Return", "|True|", "if", "the", "given", "member", "should", "be", "added", "to", "the", "substitutions", ".", "If", "not", "return", "|False|", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L210-L284
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.get_role
def get_role(member, cython=False): """Return the reStructuredText role `func`, `class`, or `const` best describing the given member. Some examples based on the site-package |numpy|. |numpy.clip| is a function: >>> from hydpy.core.autodoctools import Substituter >>> im...
python
def get_role(member, cython=False): """Return the reStructuredText role `func`, `class`, or `const` best describing the given member. Some examples based on the site-package |numpy|. |numpy.clip| is a function: >>> from hydpy.core.autodoctools import Substituter >>> im...
[ "def", "get_role", "(", "member", ",", "cython", "=", "False", ")", ":", "if", "inspect", ".", "isroutine", "(", "member", ")", "or", "isinstance", "(", "member", ",", "numpy", ".", "ufunc", ")", ":", "return", "'func'", "elif", "inspect", ".", "isclas...
Return the reStructuredText role `func`, `class`, or `const` best describing the given member. Some examples based on the site-package |numpy|. |numpy.clip| is a function: >>> from hydpy.core.autodoctools import Substituter >>> import numpy >>> Substituter.get_role(num...
[ "Return", "the", "reStructuredText", "role", "func", "class", "or", "const", "best", "describing", "the", "given", "member", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L287-L336
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.add_substitution
def add_substitution(self, short, medium, long, module): """Add the given substitutions both as a `short2long` and a `medium2long` mapping. Assume `variable1` is defined in the hydpy module `module1` and the short and medium descriptions are `var1` and `mod1.var1`: >>> import t...
python
def add_substitution(self, short, medium, long, module): """Add the given substitutions both as a `short2long` and a `medium2long` mapping. Assume `variable1` is defined in the hydpy module `module1` and the short and medium descriptions are `var1` and `mod1.var1`: >>> import t...
[ "def", "add_substitution", "(", "self", ",", "short", ",", "medium", ",", "long", ",", "module", ")", ":", "name", "=", "module", ".", "__name__", "if", "'builtin'", "in", "name", ":", "self", ".", "_short2long", "[", "short", "]", "=", "long", ".", ...
Add the given substitutions both as a `short2long` and a `medium2long` mapping. Assume `variable1` is defined in the hydpy module `module1` and the short and medium descriptions are `var1` and `mod1.var1`: >>> import types >>> module1 = types.ModuleType('hydpy.module1') ...
[ "Add", "the", "given", "substitutions", "both", "as", "a", "short2long", "and", "a", "medium2long", "mapping", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L338-L431
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.add_module
def add_module(self, module, cython=False): """Add the given module, its members, and their submembers. The first examples are based on the site-package |numpy|: which is passed to method |Substituter.add_module|: >>> from hydpy.core.autodoctools import Substituter >>> substitu...
python
def add_module(self, module, cython=False): """Add the given module, its members, and their submembers. The first examples are based on the site-package |numpy|: which is passed to method |Substituter.add_module|: >>> from hydpy.core.autodoctools import Substituter >>> substitu...
[ "def", "add_module", "(", "self", ",", "module", ",", "cython", "=", "False", ")", ":", "name_module", "=", "module", ".", "__name__", ".", "split", "(", "'.'", ")", "[", "-", "1", "]", "short", "=", "(", "'|%s|'", "%", "name_module", ")", "long", ...
Add the given module, its members, and their submembers. The first examples are based on the site-package |numpy|: which is passed to method |Substituter.add_module|: >>> from hydpy.core.autodoctools import Substituter >>> substituter = Substituter() >>> import numpy >>...
[ "Add", "the", "given", "module", "its", "members", "and", "their", "submembers", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L433-L511
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.add_modules
def add_modules(self, package): """Add the modules of the given package without their members.""" for name in os.listdir(package.__path__[0]): if name.startswith('_'): continue name = name.split('.')[0] short = '|%s|' % name long = ':mod:`~...
python
def add_modules(self, package): """Add the modules of the given package without their members.""" for name in os.listdir(package.__path__[0]): if name.startswith('_'): continue name = name.split('.')[0] short = '|%s|' % name long = ':mod:`~...
[ "def", "add_modules", "(", "self", ",", "package", ")", ":", "for", "name", "in", "os", ".", "listdir", "(", "package", ".", "__path__", "[", "0", "]", ")", ":", "if", "name", ".", "startswith", "(", "'_'", ")", ":", "continue", "name", "=", "name"...
Add the modules of the given package without their members.
[ "Add", "the", "modules", "of", "the", "given", "package", "without", "their", "members", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L513-L521
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.update_masters
def update_masters(self): """Update all `master` |Substituter| objects. If a |Substituter| object is passed to the constructor of another |Substituter| object, they become `master` and `slave`: >>> from hydpy.core.autodoctools import Substituter >>> sub1 = Substituter() ...
python
def update_masters(self): """Update all `master` |Substituter| objects. If a |Substituter| object is passed to the constructor of another |Substituter| object, they become `master` and `slave`: >>> from hydpy.core.autodoctools import Substituter >>> sub1 = Substituter() ...
[ "def", "update_masters", "(", "self", ")", ":", "if", "self", ".", "master", "is", "not", "None", ":", "self", ".", "master", ".", "_medium2long", ".", "update", "(", "self", ".", "_medium2long", ")", "self", ".", "master", ".", "update_masters", "(", ...
Update all `master` |Substituter| objects. If a |Substituter| object is passed to the constructor of another |Substituter| object, they become `master` and `slave`: >>> from hydpy.core.autodoctools import Substituter >>> sub1 = Substituter() >>> from hydpy.core import devicetoo...
[ "Update", "all", "master", "|Substituter|", "objects", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L523-L589
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.update_slaves
def update_slaves(self): """Update all `slave` |Substituter| objects. See method |Substituter.update_masters| for further information. """ for slave in self.slaves: slave._medium2long.update(self._medium2long) slave.update_slaves()
python
def update_slaves(self): """Update all `slave` |Substituter| objects. See method |Substituter.update_masters| for further information. """ for slave in self.slaves: slave._medium2long.update(self._medium2long) slave.update_slaves()
[ "def", "update_slaves", "(", "self", ")", ":", "for", "slave", "in", "self", ".", "slaves", ":", "slave", ".", "_medium2long", ".", "update", "(", "self", ".", "_medium2long", ")", "slave", ".", "update_slaves", "(", ")" ]
Update all `slave` |Substituter| objects. See method |Substituter.update_masters| for further information.
[ "Update", "all", "slave", "|Substituter|", "objects", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L591-L598
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.get_commands
def get_commands(self, source=None): """Return a string containing multiple `reStructuredText` replacements with the substitutions currently defined. Some examples based on the subpackage |optiontools|: >>> from hydpy.core.autodoctools import Substituter >>> substituter = Subst...
python
def get_commands(self, source=None): """Return a string containing multiple `reStructuredText` replacements with the substitutions currently defined. Some examples based on the subpackage |optiontools|: >>> from hydpy.core.autodoctools import Substituter >>> substituter = Subst...
[ "def", "get_commands", "(", "self", ",", "source", "=", "None", ")", ":", "commands", "=", "[", "]", "for", "key", ",", "value", "in", "self", ":", "if", "(", "source", "is", "None", ")", "or", "(", "key", "in", "source", ")", ":", "commands", "....
Return a string containing multiple `reStructuredText` replacements with the substitutions currently defined. Some examples based on the subpackage |optiontools|: >>> from hydpy.core.autodoctools import Substituter >>> substituter = Substituter() >>> from hydpy.core import opti...
[ "Return", "a", "string", "containing", "multiple", "reStructuredText", "replacements", "with", "the", "substitutions", "currently", "defined", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L600-L642
train
hydpy-dev/hydpy
hydpy/core/autodoctools.py
Substituter.find
def find(self, text): """Print all substitutions that include the given text string.""" for key, value in self: if (text in key) or (text in value): print(key, value)
python
def find(self, text): """Print all substitutions that include the given text string.""" for key, value in self: if (text in key) or (text in value): print(key, value)
[ "def", "find", "(", "self", ",", "text", ")", ":", "for", "key", ",", "value", "in", "self", ":", "if", "(", "text", "in", "key", ")", "or", "(", "text", "in", "value", ")", ":", "print", "(", "key", ",", "value", ")" ]
Print all substitutions that include the given text string.
[ "Print", "all", "substitutions", "that", "include", "the", "given", "text", "string", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/autodoctools.py#L644-L648
train
hydpy-dev/hydpy
hydpy/core/printtools.py
print_progress
def print_progress(wrapped, _=None, args=None, kwargs=None): """Add print commands time to the given function informing about execution time. To show how the |print_progress| decorator works, we need to modify the functions used by |print_progress| to gain system time information available in modu...
python
def print_progress(wrapped, _=None, args=None, kwargs=None): """Add print commands time to the given function informing about execution time. To show how the |print_progress| decorator works, we need to modify the functions used by |print_progress| to gain system time information available in modu...
[ "def", "print_progress", "(", "wrapped", ",", "_", "=", "None", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "global", "_printprogress_indentation", "_printprogress_indentation", "+=", "4", "try", ":", "if", "hydpy", ".", "pub", ".", "op...
Add print commands time to the given function informing about execution time. To show how the |print_progress| decorator works, we need to modify the functions used by |print_progress| to gain system time information available in module |time|. First, we mock the functions |time.strftime| and |ti...
[ "Add", "print", "commands", "time", "to", "the", "given", "function", "informing", "about", "execution", "time", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/printtools.py#L42-L136
train
hydpy-dev/hydpy
hydpy/core/printtools.py
progressbar
def progressbar(iterable, length=23): """Print a simple progress bar while processing the given iterable. Function |progressbar| does print the progress bar when option `printprogress` is activted: >>> from hydpy import pub >>> pub.options.printprogress = True You can pass an iterable object....
python
def progressbar(iterable, length=23): """Print a simple progress bar while processing the given iterable. Function |progressbar| does print the progress bar when option `printprogress` is activted: >>> from hydpy import pub >>> pub.options.printprogress = True You can pass an iterable object....
[ "def", "progressbar", "(", "iterable", ",", "length", "=", "23", ")", ":", "if", "hydpy", ".", "pub", ".", "options", ".", "printprogress", "and", "(", "len", "(", "iterable", ")", ">", "1", ")", ":", "temp_name", "=", "os", ".", "path", ".", "join...
Print a simple progress bar while processing the given iterable. Function |progressbar| does print the progress bar when option `printprogress` is activted: >>> from hydpy import pub >>> pub.options.printprogress = True You can pass an iterable object. Say you want to calculate the the sum o...
[ "Print", "a", "simple", "progress", "bar", "while", "processing", "the", "given", "iterable", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/core/printtools.py#L139-L248
train
hydpy-dev/hydpy
hydpy/exe/servertools.py
start_server
def start_server(socket, projectname, xmlfilename: str) -> None: """Start the *HydPy* server using the given socket. The folder with the given `projectname` must be available within the current working directory. The XML configuration file must be placed within the project folder unless `xmlfilename` ...
python
def start_server(socket, projectname, xmlfilename: str) -> None: """Start the *HydPy* server using the given socket. The folder with the given `projectname` must be available within the current working directory. The XML configuration file must be placed within the project folder unless `xmlfilename` ...
[ "def", "start_server", "(", "socket", ",", "projectname", ",", "xmlfilename", ":", "str", ")", "->", "None", ":", "state", ".", "initialise", "(", "projectname", ",", "xmlfilename", ")", "server", "=", "http", ".", "server", ".", "HTTPServer", "(", "(", ...
Start the *HydPy* server using the given socket. The folder with the given `projectname` must be available within the current working directory. The XML configuration file must be placed within the project folder unless `xmlfilename` is an absolute file path. The XML configuration file must be valid c...
[ "Start", "the", "*", "HydPy", "*", "server", "using", "the", "given", "socket", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/exe/servertools.py#L1147-L1159
train
hydpy-dev/hydpy
hydpy/exe/servertools.py
await_server
def await_server(port, seconds): """Block the current process until either the *HydPy* server is responding on the given `port` or the given number of `seconds` elapsed. >>> from hydpy import run_subprocess, TestIO >>> with TestIO(): # doctest: +ELLIPSIS ... run_subprocess('hyd.py await_serv...
python
def await_server(port, seconds): """Block the current process until either the *HydPy* server is responding on the given `port` or the given number of `seconds` elapsed. >>> from hydpy import run_subprocess, TestIO >>> with TestIO(): # doctest: +ELLIPSIS ... run_subprocess('hyd.py await_serv...
[ "def", "await_server", "(", "port", ",", "seconds", ")", ":", "now", "=", "time", ".", "perf_counter", "(", ")", "end", "=", "now", "+", "float", "(", "seconds", ")", "while", "now", "<=", "end", ":", "try", ":", "urllib", ".", "request", ".", "url...
Block the current process until either the *HydPy* server is responding on the given `port` or the given number of `seconds` elapsed. >>> from hydpy import run_subprocess, TestIO >>> with TestIO(): # doctest: +ELLIPSIS ... run_subprocess('hyd.py await_server 8080 0.1') Invoking hyd.py with a...
[ "Block", "the", "current", "process", "until", "either", "the", "*", "HydPy", "*", "server", "is", "responding", "on", "the", "given", "port", "or", "the", "given", "number", "of", "seconds", "elapsed", "." ]
1bc6a82cf30786521d86b36e27900c6717d3348d
https://github.com/hydpy-dev/hydpy/blob/1bc6a82cf30786521d86b36e27900c6717d3348d/hydpy/exe/servertools.py#L1162-L1198
train