repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
PierreRust/apigpio
apigpio/apigpio.py
Pi.connect
def connect(self, address): """ Connect to a remote or local gpiod daemon. :param address: a pair (address, port), the address must be already resolved (for example an ip address) :return: """ self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self...
python
def connect(self, address): """ Connect to a remote or local gpiod daemon. :param address: a pair (address, port), the address must be already resolved (for example an ip address) :return: """ self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self...
[ "def", "connect", "(", "self", ",", "address", ")", ":", "self", ".", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "self", ".", "s", ".", "setblocking", "(", "False", ")", "# Disable the Nagl...
Connect to a remote or local gpiod daemon. :param address: a pair (address, port), the address must be already resolved (for example an ip address) :return:
[ "Connect", "to", "a", "remote", "or", "local", "gpiod", "daemon", ".", ":", "param", "address", ":", "a", "pair", "(", "address", "port", ")", "the", "address", "must", "be", "already", "resolved", "(", "for", "example", "an", "ip", "address", ")", ":"...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L559-L573
train
Connect to a remote or local gpiod daemon.
PierreRust/apigpio
apigpio/apigpio.py
Pi.store_script
def store_script(self, script): """ Store a script for later execution. script:= the script text as a series of bytes. Returns a >=0 script id if OK. ... sid = pi.store_script( b'tag 0 w 22 1 mils 100 w 22 0 mils 100 dcr p0 jp 0') ... """ ...
python
def store_script(self, script): """ Store a script for later execution. script:= the script text as a series of bytes. Returns a >=0 script id if OK. ... sid = pi.store_script( b'tag 0 w 22 1 mils 100 w 22 0 mils 100 dcr p0 jp 0') ... """ ...
[ "def", "store_script", "(", "self", ",", "script", ")", ":", "if", "len", "(", "script", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command_ext", "(", "_PI_CMD_PROC", ",", "0", ",", "0", ",", "len", "(", "script", ")", ",", "[",...
Store a script for later execution. script:= the script text as a series of bytes. Returns a >=0 script id if OK. ... sid = pi.store_script( b'tag 0 w 22 1 mils 100 w 22 0 mils 100 dcr p0 jp 0') ...
[ "Store", "a", "script", "for", "later", "execution", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L603-L622
train
Store a script for later execution.
PierreRust/apigpio
apigpio/apigpio.py
Pi.run_script
def run_script(self, script_id, params=None): """ Runs a stored script. script_id:= id of stored script. params:= up to 10 parameters required by the script. ... s = pi.run_script(sid, [par1, par2]) s = pi.run_script(sid) s = pi.run_script(sid, [1, 2,...
python
def run_script(self, script_id, params=None): """ Runs a stored script. script_id:= id of stored script. params:= up to 10 parameters required by the script. ... s = pi.run_script(sid, [par1, par2]) s = pi.run_script(sid) s = pi.run_script(sid, [1, 2,...
[ "def", "run_script", "(", "self", ",", "script_id", ",", "params", "=", "None", ")", ":", "# I p1 script id", "# I p2 0", "# I p3 params * 4 (0-10 params)", "# (optional) extension", "# I[] params", "if", "params", "is", "not", "None", ":", "ext", "=", "bytearray", ...
Runs a stored script. script_id:= id of stored script. params:= up to 10 parameters required by the script. ... s = pi.run_script(sid, [par1, par2]) s = pi.run_script(sid) s = pi.run_script(sid, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) ...
[ "Runs", "a", "stored", "script", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L625-L656
train
Runs a stored script.
PierreRust/apigpio
apigpio/apigpio.py
Pi.script_status
def script_status(self, script_id): """ Returns the run status of a stored script as well as the current values of parameters 0 to 9. script_id:= id of stored script. The run status may be . . PI_SCRIPT_INITING PI_SCRIPT_HALTED PI_SCRIPT_RUNNING...
python
def script_status(self, script_id): """ Returns the run status of a stored script as well as the current values of parameters 0 to 9. script_id:= id of stored script. The run status may be . . PI_SCRIPT_INITING PI_SCRIPT_HALTED PI_SCRIPT_RUNNING...
[ "def", "script_status", "(", "self", ",", "script_id", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_PROCP", ",", "script_id", ",", "0", ")", "bytes", "=", "u2i", "(", "res", ")", "if", "bytes", ">", "0", ":",...
Returns the run status of a stored script as well as the current values of parameters 0 to 9. script_id:= id of stored script. The run status may be . . PI_SCRIPT_INITING PI_SCRIPT_HALTED PI_SCRIPT_RUNNING PI_SCRIPT_WAITING PI_SCRIPT_FAILED ...
[ "Returns", "the", "run", "status", "of", "a", "stored", "script", "as", "well", "as", "the", "current", "values", "of", "parameters", "0", "to", "9", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L659-L702
train
Get the run status of a stored script.
PierreRust/apigpio
apigpio/apigpio.py
Pi.stop_script
def stop_script(self, script_id): """ Stops a running script. script_id:= id of stored script. ... status = pi.stop_script(sid) ... """ res = yield from self._pigpio_aio_command(_PI_CMD_PROCS, script_id, 0) return _u2i(res)
python
def stop_script(self, script_id): """ Stops a running script. script_id:= id of stored script. ... status = pi.stop_script(sid) ... """ res = yield from self._pigpio_aio_command(_PI_CMD_PROCS, script_id, 0) return _u2i(res)
[ "def", "stop_script", "(", "self", ",", "script_id", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_PROCS", ",", "script_id", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Stops a running script. script_id:= id of stored script. ... status = pi.stop_script(sid) ...
[ "Stops", "a", "running", "script", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L705-L716
train
Stops a running script.
PierreRust/apigpio
apigpio/apigpio.py
Pi.delete_script
def delete_script(self, script_id): """ Deletes a stored script. script_id:= id of stored script. ... status = pi.delete_script(sid) ... """ res = yield from self._pigpio_aio_command(_PI_CMD_PROCD, script_id, 0) return _u2i(res)
python
def delete_script(self, script_id): """ Deletes a stored script. script_id:= id of stored script. ... status = pi.delete_script(sid) ... """ res = yield from self._pigpio_aio_command(_PI_CMD_PROCD, script_id, 0) return _u2i(res)
[ "def", "delete_script", "(", "self", ",", "script_id", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_PROCD", ",", "script_id", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Deletes a stored script. script_id:= id of stored script. ... status = pi.delete_script(sid) ...
[ "Deletes", "a", "stored", "script", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L719-L730
train
Delete a stored script.
PierreRust/apigpio
apigpio/apigpio.py
Pi.clear_bank_1
def clear_bank_1(self, bits): """ Clears gpios 0-31 if the corresponding bit in bits is set. bits:= a 32 bit mask with 1 set if the corresponding gpio is to be cleared. A returned status of PI_SOME_PERMITTED indicates that the user is not allowed to write to one or...
python
def clear_bank_1(self, bits): """ Clears gpios 0-31 if the corresponding bit in bits is set. bits:= a 32 bit mask with 1 set if the corresponding gpio is to be cleared. A returned status of PI_SOME_PERMITTED indicates that the user is not allowed to write to one or...
[ "def", "clear_bank_1", "(", "self", ",", "bits", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_BC1", ",", "bits", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Clears gpios 0-31 if the corresponding bit in bits is set. bits:= a 32 bit mask with 1 set if the corresponding gpio is to be cleared. A returned status of PI_SOME_PERMITTED indicates that the user is not allowed to write to one or more of the gpios. ... pi.clear_...
[ "Clears", "gpios", "0", "-", "31", "if", "the", "corresponding", "bit", "in", "bits", "is", "set", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L749-L764
train
Clear the user - related user - related cache entries for the first gpio in bits.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_bank_1
def set_bank_1(self, bits): """ Sets gpios 0-31 if the corresponding bit in bits is set. bits:= a 32 bit mask with 1 set if the corresponding gpio is to be set. A returned status of PI_SOME_PERMITTED indicates that the user is not allowed to write to one or more of...
python
def set_bank_1(self, bits): """ Sets gpios 0-31 if the corresponding bit in bits is set. bits:= a 32 bit mask with 1 set if the corresponding gpio is to be set. A returned status of PI_SOME_PERMITTED indicates that the user is not allowed to write to one or more of...
[ "def", "set_bank_1", "(", "self", ",", "bits", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_BS1", ",", "bits", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Sets gpios 0-31 if the corresponding bit in bits is set. bits:= a 32 bit mask with 1 set if the corresponding gpio is to be set. A returned status of PI_SOME_PERMITTED indicates that the user is not allowed to write to one or more of the gpios. ... pi.set_bank_1(i...
[ "Sets", "gpios", "0", "-", "31", "if", "the", "corresponding", "bit", "in", "bits", "is", "set", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L767-L782
train
Sets the bit - mask of the user - related user - related log - store - level 1 - bit in bits.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_mode
def set_mode(self, gpio, mode): """ Sets the gpio mode. gpio:= 0-53. mode:= INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5. ... pi.set_mode( 4, apigpio.INPUT) # gpio 4 as input pi.set_mode(17, apigpio.OUTPUT) # gpio 17 as output pi.set_mode(24, apig...
python
def set_mode(self, gpio, mode): """ Sets the gpio mode. gpio:= 0-53. mode:= INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5. ... pi.set_mode( 4, apigpio.INPUT) # gpio 4 as input pi.set_mode(17, apigpio.OUTPUT) # gpio 17 as output pi.set_mode(24, apig...
[ "def", "set_mode", "(", "self", ",", "gpio", ",", "mode", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_MODES", ",", "gpio", ",", "mode", ")", "return", "_u2i", "(", "res", ")" ]
Sets the gpio mode. gpio:= 0-53. mode:= INPUT, OUTPUT, ALT0, ALT1, ALT2, ALT3, ALT4, ALT5. ... pi.set_mode( 4, apigpio.INPUT) # gpio 4 as input pi.set_mode(17, apigpio.OUTPUT) # gpio 17 as output pi.set_mode(24, apigpio.ALT2) # gpio 24 as ALT2 ...
[ "Sets", "the", "gpio", "mode", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L785-L799
train
Sets the mode of the specified gpio.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_pull_up_down
def set_pull_up_down(self, gpio, pud): """ Sets or clears the internal GPIO pull-up/down resistor. gpio:= 0-53. pud:= PUD_UP, PUD_DOWN, PUD_OFF. ... yield from pi.set_pull_up_down(17, apigpio.PUD_OFF) yield from pi.set_pull_up_down(23, apigpio.PUD_UP) yie...
python
def set_pull_up_down(self, gpio, pud): """ Sets or clears the internal GPIO pull-up/down resistor. gpio:= 0-53. pud:= PUD_UP, PUD_DOWN, PUD_OFF. ... yield from pi.set_pull_up_down(17, apigpio.PUD_OFF) yield from pi.set_pull_up_down(23, apigpio.PUD_UP) yie...
[ "def", "set_pull_up_down", "(", "self", ",", "gpio", ",", "pud", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_PUD", ",", "gpio", ",", "pud", ")", "return", "_u2i", "(", "res", ")" ]
Sets or clears the internal GPIO pull-up/down resistor. gpio:= 0-53. pud:= PUD_UP, PUD_DOWN, PUD_OFF. ... yield from pi.set_pull_up_down(17, apigpio.PUD_OFF) yield from pi.set_pull_up_down(23, apigpio.PUD_UP) yield from pi.set_pull_up_down(24, apigpio.PUD_DOWN) ....
[ "Sets", "or", "clears", "the", "internal", "GPIO", "pull", "-", "up", "/", "down", "resistor", ".", "gpio", ":", "=", "0", "-", "53", ".", "pud", ":", "=", "PUD_UP", "PUD_DOWN", "PUD_OFF", ".", "...", "yield", "from", "pi", ".", "set_pull_up_down", "...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L802-L814
train
Sets or clears the internal GPIO pull - up or down resistor.
PierreRust/apigpio
apigpio/apigpio.py
Pi.get_mode
def get_mode(self, gpio): """ Returns the gpio mode. gpio:= 0-53. Returns a value as follows . . 0 = INPUT 1 = OUTPUT 2 = ALT5 3 = ALT4 4 = ALT0 5 = ALT1 6 = ALT2 7 = ALT3 . . ... print(pi...
python
def get_mode(self, gpio): """ Returns the gpio mode. gpio:= 0-53. Returns a value as follows . . 0 = INPUT 1 = OUTPUT 2 = ALT5 3 = ALT4 4 = ALT0 5 = ALT1 6 = ALT2 7 = ALT3 . . ... print(pi...
[ "def", "get_mode", "(", "self", ",", "gpio", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_MODEG", ",", "gpio", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Returns the gpio mode. gpio:= 0-53. Returns a value as follows . . 0 = INPUT 1 = OUTPUT 2 = ALT5 3 = ALT4 4 = ALT0 5 = ALT1 6 = ALT2 7 = ALT3 . . ... print(pi.get_mode(0)) 4 ...
[ "Returns", "the", "gpio", "mode", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L817-L842
train
Get the mode of the specified gpio.
PierreRust/apigpio
apigpio/apigpio.py
Pi.write
def write(self, gpio, level): """ Sets the gpio level. gpio:= 0-53. level:= 0, 1. If PWM or servo pulses are active on the gpio they are switched off. ... pi.set_mode(17, pigpio.OUTPUT) pi.write(17,0) print(pi.read(17)) 0 ...
python
def write(self, gpio, level): """ Sets the gpio level. gpio:= 0-53. level:= 0, 1. If PWM or servo pulses are active on the gpio they are switched off. ... pi.set_mode(17, pigpio.OUTPUT) pi.write(17,0) print(pi.read(17)) 0 ...
[ "def", "write", "(", "self", ",", "gpio", ",", "level", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_WRITE", ",", "gpio", ",", "level", ")", "return", "_u2i", "(", "res", ")" ]
Sets the gpio level. gpio:= 0-53. level:= 0, 1. If PWM or servo pulses are active on the gpio they are switched off. ... pi.set_mode(17, pigpio.OUTPUT) pi.write(17,0) print(pi.read(17)) 0 pi.write(17,1) print(pi.read(17)) ...
[ "Sets", "the", "gpio", "level", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L845-L868
train
Write the level of a specific gpio.
PierreRust/apigpio
apigpio/apigpio.py
Pi.read
def read(self, gpio): """ Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) ...
python
def read(self, gpio): """ Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) ...
[ "def", "read", "(", "self", ",", "gpio", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_READ", ",", "gpio", ",", "0", ")", "return", "_u2i", "(", "res", ")" ]
Returns the GPIO level. gpio:= 0-53. ... yield from pi.set_mode(23, pigpio.INPUT) yield from pi.set_pull_up_down(23, pigpio.PUD_DOWN) print(yield from pi.read(23)) 0 yield from pi.set_pull_up_down(23, pigpio.PUD_UP) print(yield from pi.read(23)) 1 ...
[ "Returns", "the", "GPIO", "level", ".", "gpio", ":", "=", "0", "-", "53", ".", "...", "yield", "from", "pi", ".", "set_mode", "(", "23", "pigpio", ".", "INPUT", ")", "yield", "from", "pi", ".", "set_pull_up_down", "(", "23", "pigpio", ".", "PUD_DOWN"...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L871-L886
train
Read the GPIO level.
PierreRust/apigpio
apigpio/apigpio.py
Pi.gpio_trigger
def gpio_trigger(self, user_gpio, pulse_len=10, level=1): """ Send a trigger pulse to a GPIO. The GPIO is set to level for pulse_len microseconds and then reset to not level. user_gpio:= 0-31 pulse_len:= 1-100 level:= 0-1 ... pi.gpio_trigger(23, 10, 1...
python
def gpio_trigger(self, user_gpio, pulse_len=10, level=1): """ Send a trigger pulse to a GPIO. The GPIO is set to level for pulse_len microseconds and then reset to not level. user_gpio:= 0-31 pulse_len:= 1-100 level:= 0-1 ... pi.gpio_trigger(23, 10, 1...
[ "def", "gpio_trigger", "(", "self", ",", "user_gpio", ",", "pulse_len", "=", "10", ",", "level", "=", "1", ")", ":", "# pigpio message format", "# I p1 user_gpio", "# I p2 pulse_len", "# I p3 4", "## extension ##", "# I level", "extents", "=", "[", "struct", ".", ...
Send a trigger pulse to a GPIO. The GPIO is set to level for pulse_len microseconds and then reset to not level. user_gpio:= 0-31 pulse_len:= 1-100 level:= 0-1 ... pi.gpio_trigger(23, 10, 1) ...
[ "Send", "a", "trigger", "pulse", "to", "a", "GPIO", ".", "The", "GPIO", "is", "set", "to", "level", "for", "pulse_len", "microseconds", "and", "then", "reset", "to", "not", "level", ".", "user_gpio", ":", "=", "0", "-", "31", "pulse_len", ":", "=", "...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L889-L910
train
Send a trigger pulse to a GPIO.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_glitch_filter
def set_glitch_filter(self, user_gpio, steady): """ Sets a glitch filter on a GPIO. Level changes on the GPIO are not reported unless the level has been stable for at least [*steady*] microseconds. The level is then reported. Level changes of less than [*steady*] micros...
python
def set_glitch_filter(self, user_gpio, steady): """ Sets a glitch filter on a GPIO. Level changes on the GPIO are not reported unless the level has been stable for at least [*steady*] microseconds. The level is then reported. Level changes of less than [*steady*] micros...
[ "def", "set_glitch_filter", "(", "self", ",", "user_gpio", ",", "steady", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_FG", ",", "user_gpio", ",", "steady", ")", "return", "_u2i", "(", "res", ")" ]
Sets a glitch filter on a GPIO. Level changes on the GPIO are not reported unless the level has been stable for at least [*steady*] microseconds. The level is then reported. Level changes of less than [*steady*] microseconds are ignored. user_gpio:= 0-31 steady:= 0-3...
[ "Sets", "a", "glitch", "filter", "on", "a", "GPIO", ".", "Level", "changes", "on", "the", "GPIO", "are", "not", "reported", "unless", "the", "level", "has", "been", "stable", "for", "at", "least", "[", "*", "steady", "*", "]", "microseconds", ".", "The...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L913-L934
train
Sets a glitch filter on a GPIO.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_noise_filter
def set_noise_filter(self, user_gpio, steady, active): """ Sets a noise filter on a GPIO. Level changes on the GPIO are ignored until a level which has been stable for [*steady*] microseconds is detected. Level changes on the GPIO are then reported for [*active*] microse...
python
def set_noise_filter(self, user_gpio, steady, active): """ Sets a noise filter on a GPIO. Level changes on the GPIO are ignored until a level which has been stable for [*steady*] microseconds is detected. Level changes on the GPIO are then reported for [*active*] microse...
[ "def", "set_noise_filter", "(", "self", ",", "user_gpio", ",", "steady", ",", "active", ")", ":", "# pigpio message format", "# I p1 user_gpio", "# I p2 steady", "# I p3 4", "## extension ##", "# I active", "extents", "=", "[", "struct", ".", "pack", "(", "\"I\"", ...
Sets a noise filter on a GPIO. Level changes on the GPIO are ignored until a level which has been stable for [*steady*] microseconds is detected. Level changes on the GPIO are then reported for [*active*] microseconds after which the process repeats. user_gpio:= 0-31 ...
[ "Sets", "a", "noise", "filter", "on", "a", "GPIO", ".", "Level", "changes", "on", "the", "GPIO", "are", "ignored", "until", "a", "level", "which", "has", "been", "stable", "for", "[", "*", "steady", "*", "]", "microseconds", "is", "detected", ".", "Lev...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L937-L969
train
Set noise filter on a specific user GPIO.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_PWM_dutycycle
def set_PWM_dutycycle(self, user_gpio, dutycycle): """ Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO. user_gpio:= 0-31. dutycycle:= 0-range (range defaults to 255). The [*set_PWM_range*] function can change the default range of 255. ... pi.set_PW...
python
def set_PWM_dutycycle(self, user_gpio, dutycycle): """ Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO. user_gpio:= 0-31. dutycycle:= 0-range (range defaults to 255). The [*set_PWM_range*] function can change the default range of 255. ... pi.set_PW...
[ "def", "set_PWM_dutycycle", "(", "self", ",", "user_gpio", ",", "dutycycle", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_PWM", ",", "user_gpio", ",", "int", "(", "dutycycle", ")", ")", "return", "_u2i", "(", "re...
Starts (non-zero dutycycle) or stops (0) PWM pulses on the GPIO. user_gpio:= 0-31. dutycycle:= 0-range (range defaults to 255). The [*set_PWM_range*] function can change the default range of 255. ... pi.set_PWM_dutycycle(4, 0) # PWM off pi.set_PWM_dutycycle(4, 64) # PW...
[ "Starts", "(", "non", "-", "zero", "dutycycle", ")", "or", "stops", "(", "0", ")", "PWM", "pulses", "on", "the", "GPIO", ".", "user_gpio", ":", "=", "0", "-", "31", ".", "dutycycle", ":", "=", "0", "-", "range", "(", "range", "defaults", "to", "2...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L972-L987
train
Set the duty cycle of the PWM on the specified user GPIO.
PierreRust/apigpio
apigpio/apigpio.py
Pi.add_callback
def add_callback(self, user_gpio, edge=RISING_EDGE, func=None): """ Calls a user supplied function (a callback) whenever the specified gpio edge is detected. user_gpio:= 0-31. edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE. func:= user supplied callback...
python
def add_callback(self, user_gpio, edge=RISING_EDGE, func=None): """ Calls a user supplied function (a callback) whenever the specified gpio edge is detected. user_gpio:= 0-31. edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE. func:= user supplied callback...
[ "def", "add_callback", "(", "self", ",", "user_gpio", ",", "edge", "=", "RISING_EDGE", ",", "func", "=", "None", ")", ":", "cb", "=", "Callback", "(", "self", ".", "_notify", ",", "user_gpio", ",", "edge", ",", "func", ")", "yield", "from", "self", "...
Calls a user supplied function (a callback) whenever the specified gpio edge is detected. user_gpio:= 0-31. edge:= EITHER_EDGE, RISING_EDGE (default), or FALLING_EDGE. func:= user supplied callback function. The user supplied callback receives three parameters, the gpio, ...
[ "Calls", "a", "user", "supplied", "function", "(", "a", "callback", ")", "whenever", "the", "specified", "gpio", "edge", "is", "detected", "." ]
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L990-L1030
train
Add a callback to the list of callbacks that can be called when a specific gpio edge is detected.
PierreRust/apigpio
apigpio/apigpio.py
Pi.set_servo_pulsewidth
def set_servo_pulsewidth(self, user_gpio, pulsewidth): """ Starts (500-2500) or stops (0) servo pulses on the GPIO. user_gpio:= 0-31. pulsewidth:= 0 (off), 500 (most anti-clockwise) - 2500 (most clockwise). The selected pulsewidth will continue to be transmi...
python
def set_servo_pulsewidth(self, user_gpio, pulsewidth): """ Starts (500-2500) or stops (0) servo pulses on the GPIO. user_gpio:= 0-31. pulsewidth:= 0 (off), 500 (most anti-clockwise) - 2500 (most clockwise). The selected pulsewidth will continue to be transmi...
[ "def", "set_servo_pulsewidth", "(", "self", ",", "user_gpio", ",", "pulsewidth", ")", ":", "res", "=", "yield", "from", "self", ".", "_pigpio_aio_command", "(", "_PI_CMD_SERVO", ",", "user_gpio", ",", "int", "(", "pulsewidth", ")", ")", "return", "_u2i", "("...
Starts (500-2500) or stops (0) servo pulses on the GPIO. user_gpio:= 0-31. pulsewidth:= 0 (off), 500 (most anti-clockwise) - 2500 (most clockwise). The selected pulsewidth will continue to be transmitted until changed by a subsequent call to set_servo_pulsewidth. ...
[ "Starts", "(", "500", "-", "2500", ")", "or", "stops", "(", "0", ")", "servo", "pulses", "on", "the", "GPIO", ".", "user_gpio", ":", "=", "0", "-", "31", ".", "pulsewidth", ":", "=", "0", "(", "off", ")", "500", "(", "most", "anti", "-", "clock...
2b969f40e06219b43a43498d8baf87f5935ceab2
https://github.com/PierreRust/apigpio/blob/2b969f40e06219b43a43498d8baf87f5935ceab2/apigpio/apigpio.py#L1033-L1054
train
Set the pulsewidth of the servo pulses on the GPIO.
kyzima-spb/flask-pony
flask_pony/utils.py
camelcase2list
def camelcase2list(s, lower=False): """Converts a camelcase string to a list.""" s = re.findall(r'([A-Z][a-z0-9]+)', s) return [w.lower() for w in s] if lower else s
python
def camelcase2list(s, lower=False): """Converts a camelcase string to a list.""" s = re.findall(r'([A-Z][a-z0-9]+)', s) return [w.lower() for w in s] if lower else s
[ "def", "camelcase2list", "(", "s", ",", "lower", "=", "False", ")", ":", "s", "=", "re", ".", "findall", "(", "r'([A-Z][a-z0-9]+)'", ",", "s", ")", "return", "[", "w", ".", "lower", "(", ")", "for", "w", "in", "s", "]", "if", "lower", "else", "s"...
Converts a camelcase string to a list.
[ "Converts", "a", "camelcase", "string", "to", "a", "list", "." ]
6cf28d70b7ebf415d58fa138fcc70b8dd57432c7
https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/utils.py#L27-L30
train
Converts a camelcase string to a list.
kyzima-spb/flask-pony
flask_pony/utils.py
get_route_param_names
def get_route_param_names(endpoint): """Returns parameter names from the route.""" try: g = current_app.url_map.iter_rules(endpoint) return next(g).arguments except KeyError: return {}
python
def get_route_param_names(endpoint): """Returns parameter names from the route.""" try: g = current_app.url_map.iter_rules(endpoint) return next(g).arguments except KeyError: return {}
[ "def", "get_route_param_names", "(", "endpoint", ")", ":", "try", ":", "g", "=", "current_app", ".", "url_map", ".", "iter_rules", "(", "endpoint", ")", "return", "next", "(", "g", ")", ".", "arguments", "except", "KeyError", ":", "return", "{", "}" ]
Returns parameter names from the route.
[ "Returns", "parameter", "names", "from", "the", "route", "." ]
6cf28d70b7ebf415d58fa138fcc70b8dd57432c7
https://github.com/kyzima-spb/flask-pony/blob/6cf28d70b7ebf415d58fa138fcc70b8dd57432c7/flask_pony/utils.py#L33-L39
train
Returns parameter names from the route.
JoseAntFer/pyny3d
pyny3d/shadows.py
ShadowsManager.run
def run(self): """ Run the shadowing computation with the values stored in ``self.arg_``. Precomputed information is stored in: * **.diff_t** (*ndarray*): ``np.diff(t)`` * **.integral** (*ndarray*): Trapezoidal data integration over time. ...
python
def run(self): """ Run the shadowing computation with the values stored in ``self.arg_``. Precomputed information is stored in: * **.diff_t** (*ndarray*): ``np.diff(t)`` * **.integral** (*ndarray*): Trapezoidal data integration over time. ...
[ "def", "run", "(", "self", ")", ":", "# Adapt series\r", "## time\r", "if", "self", ".", "integral", "is", "None", ":", "if", "self", ".", "arg_t", "is", "not", "None", ":", "import", "datetime", "if", "type", "(", "self", ".", "arg_t", "[", "0", "]"...
Run the shadowing computation with the values stored in ``self.arg_``. Precomputed information is stored in: * **.diff_t** (*ndarray*): ``np.diff(t)`` * **.integral** (*ndarray*): Trapezoidal data integration over time. The steps are: ...
[ "Run", "the", "shadowing", "computation", "with", "the", "values", "stored", "in", "self", ".", "arg_", ".", "Precomputed", "information", "is", "stored", "in", ":", "*", "**", ".", "diff_t", "**", "(", "*", "ndarray", "*", ")", ":", "np", ".", "diff",...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L128-L178
train
Run the shadowing computation with the values stored in .
JoseAntFer/pyny3d
pyny3d/shadows.py
ShadowsManager.Vonoroi_SH
def Vonoroi_SH(self, mesh_size=0.1): """ Generates a equally spaced mesh on the Solar Horizont (SH). Computes the Voronoi diagram from a set of points given by pairs of (azimuth, zenit) values. This discretization completely covers all the Sun positions. ...
python
def Vonoroi_SH(self, mesh_size=0.1): """ Generates a equally spaced mesh on the Solar Horizont (SH). Computes the Voronoi diagram from a set of points given by pairs of (azimuth, zenit) values. This discretization completely covers all the Sun positions. ...
[ "def", "Vonoroi_SH", "(", "self", ",", "mesh_size", "=", "0.1", ")", ":", "from", "scipy", ".", "spatial", "import", "Voronoi", "from", "pyny3d", ".", "utils", "import", "sort_numpy", "state", "=", "pyny", ".", "Polygon", ".", "verify", "pyny", ".", "Pol...
Generates a equally spaced mesh on the Solar Horizont (SH). Computes the Voronoi diagram from a set of points given by pairs of (azimuth, zenit) values. This discretization completely covers all the Sun positions. The smaller mesh size, the better resolution obtai...
[ "Generates", "a", "equally", "spaced", "mesh", "on", "the", "Solar", "Horizont", "(", "SH", ")", ".", "Computes", "the", "Voronoi", "diagram", "from", "a", "set", "of", "points", "given", "by", "pairs", "of", "(", "azimuth", "zenit", ")", "values", ".", ...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L180-L255
train
Returns a new instance of the appropriate class based on the given set of Sun positions and the Voronoi diagrams.
JoseAntFer/pyny3d
pyny3d/shadows.py
ShadowsManager.get_sunpos
def get_sunpos(self, t, true_time=False): """ Computes the Sun positions for the *t* time vector. *t* have to be in absolute minutes (0 at 00:00 01 Jan). The and in Sun positions calculated are in solar time, that is, maximun solar zenit exactly at midday. ...
python
def get_sunpos(self, t, true_time=False): """ Computes the Sun positions for the *t* time vector. *t* have to be in absolute minutes (0 at 00:00 01 Jan). The and in Sun positions calculated are in solar time, that is, maximun solar zenit exactly at midday. ...
[ "def", "get_sunpos", "(", "self", ",", "t", ",", "true_time", "=", "False", ")", ":", "import", "numpy", "as", "np", "lat", "=", "self", ".", "arg_latitude", "long", "=", "self", ".", "arg_longitude", "alphamin", "=", "self", ".", "arg_zenitmin", "# Sola...
Computes the Sun positions for the *t* time vector. *t* have to be in absolute minutes (0 at 00:00 01 Jan). The and in Sun positions calculated are in solar time, that is, maximun solar zenit exactly at midday. The generated information is stored in: ...
[ "Computes", "the", "Sun", "positions", "for", "the", "*", "t", "*", "time", "vector", ".", "*", "t", "*", "have", "to", "be", "in", "absolute", "minutes", "(", "0", "at", "00", ":", "00", "01", "Jan", ")", ".", "The", "and", "in", "Sun", "positio...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L257-L332
train
Returns the sun positions for the given time vector.
JoseAntFer/pyny3d
pyny3d/shadows.py
ShadowsManager.compute_shadows
def compute_shadows(self): """ Computes the shadoing for the ``pyny.Space`` stored in ``.space`` for the time intervals and Sun positions stored in ``.arg_t`` and ``.sun_pos``, respectively. The generated information is stored in: * **.light_vor** (*...
python
def compute_shadows(self): """ Computes the shadoing for the ``pyny.Space`` stored in ``.space`` for the time intervals and Sun positions stored in ``.arg_t`` and ``.sun_pos``, respectively. The generated information is stored in: * **.light_vor** (*...
[ "def", "compute_shadows", "(", "self", ")", ":", "from", "pyny3d", ".", "utils", "import", "sort_numpy", ",", "bool2index", ",", "index2bool", "state", "=", "pyny", ".", "Polygon", ".", "verify", "pyny", ".", "Polygon", ".", "verify", "=", "False", "model"...
Computes the shadoing for the ``pyny.Space`` stored in ``.space`` for the time intervals and Sun positions stored in ``.arg_t`` and ``.sun_pos``, respectively. The generated information is stored in: * **.light_vor** (*ndarray (dtype=bool)*): Array with the ...
[ "Computes", "the", "shadoing", "for", "the", "pyny", ".", "Space", "stored", "in", ".", "space", "for", "the", "time", "intervals", "and", "Sun", "positions", "stored", "in", ".", "arg_t", "and", ".", "sun_pos", "respectively", ".", "The", "generated", "in...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L334-L404
train
Computes the shadoing for the given time intervals and Sun positions.
JoseAntFer/pyny3d
pyny3d/shadows.py
ShadowsManager.project_data
def project_data(self): ''' Assign the sum of ``.integral``\* to each sensible point in the ``pyny.Space`` for the intervals that the points are visible to the Sun. The generated information is stored in: * **.proj_vor** (*ndarray*): ``.integral`` projected t...
python
def project_data(self): ''' Assign the sum of ``.integral``\* to each sensible point in the ``pyny.Space`` for the intervals that the points are visible to the Sun. The generated information is stored in: * **.proj_vor** (*ndarray*): ``.integral`` projected t...
[ "def", "project_data", "(", "self", ")", ":", "from", "pyny3d", ".", "utils", "import", "sort_numpy", "proj", "=", "self", ".", "light_vor", ".", "astype", "(", "float", ")", "map_", "=", "np", ".", "vstack", "(", "(", "self", ".", "t2vor_map", ",", ...
Assign the sum of ``.integral``\* to each sensible point in the ``pyny.Space`` for the intervals that the points are visible to the Sun. The generated information is stored in: * **.proj_vor** (*ndarray*): ``.integral`` projected to the Voronoi diagram. ...
[ "Assign", "the", "sum", "of", ".", "integral", "\\", "*", "to", "each", "sensible", "point", "in", "the", "pyny", ".", "Space", "for", "the", "intervals", "that", "the", "points", "are", "visible", "to", "the", "Sun", ".", "The", "generated", "informatio...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L406-L436
train
Assign the sum of. integral to each sensible point in the Sun and the sum of. points to each sensible point in the Sun.
JoseAntFer/pyny3d
pyny3d/shadows.py
ShadowsManager.to_minutes
def to_minutes(time_obj = None, dt = None): ''' Converts ``datetime`` objects lists into absolute minutes vectors. It also can be used to generate absolute minutes vector from a time interval (in minutes). :param time_obj: ``datetime`` objects to convert into abso...
python
def to_minutes(time_obj = None, dt = None): ''' Converts ``datetime`` objects lists into absolute minutes vectors. It also can be used to generate absolute minutes vector from a time interval (in minutes). :param time_obj: ``datetime`` objects to convert into abso...
[ "def", "to_minutes", "(", "time_obj", "=", "None", ",", "dt", "=", "None", ")", ":", "import", "datetime", "if", "dt", "is", "not", "None", "and", "time_obj", "is", "None", ":", "return", "np", ".", "arange", "(", "0", ",", "365", "*", "24", "*", ...
Converts ``datetime`` objects lists into absolute minutes vectors. It also can be used to generate absolute minutes vector from a time interval (in minutes). :param time_obj: ``datetime`` objects to convert into absolute minutes. :type time_obj: list of ``dat...
[ "Converts", "datetime", "objects", "lists", "into", "absolute", "minutes", "vectors", ".", "It", "also", "can", "be", "used", "to", "generate", "absolute", "minutes", "vector", "from", "a", "time", "interval", "(", "in", "minutes", ")", ".", ":", "param", ...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L439-L480
train
Converts a list of datetime objects into a list of absolute minutes vectors.
JoseAntFer/pyny3d
pyny3d/shadows.py
Viz.vor_plot
def vor_plot(self, which='vor'): """ Voronoi diagram visualizations. There are three types: 1. **vor**: Voronoi diagram of the Solar Horizont. 2. **freq**: Frequency of Sun positions in t in the Voronoi diagram of the Solar Horizont. 3....
python
def vor_plot(self, which='vor'): """ Voronoi diagram visualizations. There are three types: 1. **vor**: Voronoi diagram of the Solar Horizont. 2. **freq**: Frequency of Sun positions in t in the Voronoi diagram of the Solar Horizont. 3....
[ "def", "vor_plot", "(", "self", ",", "which", "=", "'vor'", ")", ":", "import", "matplotlib", ".", "cm", "as", "cm", "import", "matplotlib", ".", "pyplot", "as", "plt", "sm", "=", "self", ".", "SM", "if", "sm", ".", "light_vor", "is", "None", ":", ...
Voronoi diagram visualizations. There are three types: 1. **vor**: Voronoi diagram of the Solar Horizont. 2. **freq**: Frequency of Sun positions in t in the Voronoi diagram of the Solar Horizont. 3. **data**: Accumulated time integral of the data projec...
[ "Voronoi", "diagram", "visualizations", ".", "There", "are", "three", "types", ":", "1", ".", "**", "vor", "**", ":", "Voronoi", "diagram", "of", "the", "Solar", "Horizont", ".", "2", ".", "**", "freq", "**", ":", "Frequency", "of", "Sun", "positions", ...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L495-L551
train
Plot the voronoi diagram of the current state of the object.
JoseAntFer/pyny3d
pyny3d/shadows.py
Viz.exposure_plot
def exposure_plot(self, places=-1, c_poly='default', c_holes='default', s_sop=25, extra_height=0.1): """ Plots the exposure of the sensible points in a space to the data and the Sun positions. It is required to previously compute the shadowing. ...
python
def exposure_plot(self, places=-1, c_poly='default', c_holes='default', s_sop=25, extra_height=0.1): """ Plots the exposure of the sensible points in a space to the data and the Sun positions. It is required to previously compute the shadowing. ...
[ "def", "exposure_plot", "(", "self", ",", "places", "=", "-", "1", ",", "c_poly", "=", "'default'", ",", "c_holes", "=", "'default'", ",", "s_sop", "=", "25", ",", "extra_height", "=", "0.1", ")", ":", "import", "matplotlib", ".", "pyplot", "as", "plt"...
Plots the exposure of the sensible points in a space to the data and the Sun positions. It is required to previously compute the shadowing. If the computation has been made with a data timeseries, the plot will have a colorbar. Units are accumulated kilounits*hour (for ...
[ "Plots", "the", "exposure", "of", "the", "sensible", "points", "in", "a", "space", "to", "the", "data", "and", "the", "Sun", "positions", ".", "It", "is", "required", "to", "previously", "compute", "the", "shadowing", ".", "If", "the", "computation", "has"...
fb81684935a24f7e50c975cb4383c81a63ab56df
https://github.com/JoseAntFer/pyny3d/blob/fb81684935a24f7e50c975cb4383c81a63ab56df/pyny3d/shadows.py#L553-L640
train
Plots the exposure of the sensible points in a space to the data.
guaix-ucm/numina
numina/types/structured.py
open
def open(name): """" name: str or file or file-like or pathlib.Path File to be opened """ with builtins.open(name, mode='r') as fd: data = json.load(fd) return loads(data)
python
def open(name): """" name: str or file or file-like or pathlib.Path File to be opened """ with builtins.open(name, mode='r') as fd: data = json.load(fd) return loads(data)
[ "def", "open", "(", "name", ")", ":", "with", "builtins", ".", "open", "(", "name", ",", "mode", "=", "'r'", ")", "as", "fd", ":", "data", "=", "json", ".", "load", "(", "fd", ")", "return", "loads", "(", "data", ")" ]
name: str or file or file-like or pathlib.Path File to be opened
[ "name", ":", "str", "or", "file", "or", "file", "-", "like", "or", "pathlib", ".", "Path", "File", "to", "be", "opened" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/structured.py#L30-L37
train
Returns a dict with the data from the given file.
guaix-ucm/numina
numina/types/structured.py
BaseStructuredCalibration.extract_db_info
def extract_db_info(self, obj, keys): """Extract metadata from serialized file""" objl = self.convert_in(obj) # FIXME: this is too complex if isinstance(objl, self.__class__): return objl.update_meta_info() try: with builtins.open(objl, mode='r') as fd:...
python
def extract_db_info(self, obj, keys): """Extract metadata from serialized file""" objl = self.convert_in(obj) # FIXME: this is too complex if isinstance(objl, self.__class__): return objl.update_meta_info() try: with builtins.open(objl, mode='r') as fd:...
[ "def", "extract_db_info", "(", "self", ",", "obj", ",", "keys", ")", ":", "objl", "=", "self", ".", "convert_in", "(", "obj", ")", "# FIXME: this is too complex", "if", "isinstance", "(", "objl", ",", "self", ".", "__class__", ")", ":", "return", "objl", ...
Extract metadata from serialized file
[ "Extract", "metadata", "from", "serialized", "file" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/structured.py#L162-L195
train
Extract metadata from serialized file
guaix-ucm/numina
numina/types/structured.py
BaseStructuredCalibration.update_meta_info
def update_meta_info(self): """Extract metadata from myself""" result = super(BaseStructuredCalibration, self).update_meta_info() result['instrument'] = self.instrument result['uuid'] = self.uuid result['tags'] = self.tags result['type'] = self.name() minfo = se...
python
def update_meta_info(self): """Extract metadata from myself""" result = super(BaseStructuredCalibration, self).update_meta_info() result['instrument'] = self.instrument result['uuid'] = self.uuid result['tags'] = self.tags result['type'] = self.name() minfo = se...
[ "def", "update_meta_info", "(", "self", ")", ":", "result", "=", "super", "(", "BaseStructuredCalibration", ",", "self", ")", ".", "update_meta_info", "(", ")", "result", "[", "'instrument'", "]", "=", "self", ".", "instrument", "result", "[", "'uuid'", "]",...
Extract metadata from myself
[ "Extract", "metadata", "from", "myself" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/structured.py#L197-L218
train
Extract metadata from myself
jtambasco/gnuplotpy
gnuplotpy/gnuplot.py
gnuplot
def gnuplot(script_name, args_dict={}, data=[], silent=True): ''' Call a Gnuplot script, passing it arguments and datasets. Args: scipt_name(str): The name of the Gnuplot script. args_dict(dict): A dictionary of parameters to pass to the script. The `key` is the name of the...
python
def gnuplot(script_name, args_dict={}, data=[], silent=True): ''' Call a Gnuplot script, passing it arguments and datasets. Args: scipt_name(str): The name of the Gnuplot script. args_dict(dict): A dictionary of parameters to pass to the script. The `key` is the name of the...
[ "def", "gnuplot", "(", "script_name", ",", "args_dict", "=", "{", "}", ",", "data", "=", "[", "]", ",", "silent", "=", "True", ")", ":", "gnuplot_command", "=", "'gnuplot'", "if", "data", ":", "assert", "'data'", "not", "in", "args_dict", ",", "'Can\\'...
Call a Gnuplot script, passing it arguments and datasets. Args: scipt_name(str): The name of the Gnuplot script. args_dict(dict): A dictionary of parameters to pass to the script. The `key` is the name of the variable that the `item` will be passed to the Gnuplot script...
[ "Call", "a", "Gnuplot", "script", "passing", "it", "arguments", "and", "datasets", "." ]
0e67fa0b839f94981f8e18dfd42c30f98b68f500
https://github.com/jtambasco/gnuplotpy/blob/0e67fa0b839f94981f8e18dfd42c30f98b68f500/gnuplotpy/gnuplot.py#L39-L96
train
This function calls a Gnuplot script and returns the command that can be used to run the variable in the Gnuplot script.
jtambasco/gnuplotpy
gnuplotpy/gnuplot.py
gnuplot_2d
def gnuplot_2d(x, y, filename, title='', x_label='', y_label=''): ''' Function to produce a general 2D plot. Args: x (list): x points. y (list): y points. filename (str): Filename of the output image. title (str): Title of the plot. Default is '' (no title). x_label...
python
def gnuplot_2d(x, y, filename, title='', x_label='', y_label=''): ''' Function to produce a general 2D plot. Args: x (list): x points. y (list): y points. filename (str): Filename of the output image. title (str): Title of the plot. Default is '' (no title). x_label...
[ "def", "gnuplot_2d", "(", "x", ",", "y", ",", "filename", ",", "title", "=", "''", ",", "x_label", "=", "''", ",", "y_label", "=", "''", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", "ext", "!="...
Function to produce a general 2D plot. Args: x (list): x points. y (list): y points. filename (str): Filename of the output image. title (str): Title of the plot. Default is '' (no title). x_label (str): x-axis label. y_label (str): y-axis label.
[ "Function", "to", "produce", "a", "general", "2D", "plot", "." ]
0e67fa0b839f94981f8e18dfd42c30f98b68f500
https://github.com/jtambasco/gnuplotpy/blob/0e67fa0b839f94981f8e18dfd42c30f98b68f500/gnuplotpy/gnuplot.py#L98-L140
train
Function to produce a general 2D plot.
jtambasco/gnuplotpy
gnuplotpy/gnuplot.py
gnuplot_3d_matrix
def gnuplot_3d_matrix(z_matrix, filename, title='', x_label='', y_label=''): ''' Function to produce a general 3D plot from a 2D matrix. Args: z_matrix (list): 2D matrix. filename (str): Filename of the output image. title (str): Title of the plot. Default is '' (no title). ...
python
def gnuplot_3d_matrix(z_matrix, filename, title='', x_label='', y_label=''): ''' Function to produce a general 3D plot from a 2D matrix. Args: z_matrix (list): 2D matrix. filename (str): Filename of the output image. title (str): Title of the plot. Default is '' (no title). ...
[ "def", "gnuplot_3d_matrix", "(", "z_matrix", ",", "filename", ",", "title", "=", "''", ",", "x_label", "=", "''", ",", "y_label", "=", "''", ")", ":", "_", ",", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "if", "ext", "!="...
Function to produce a general 3D plot from a 2D matrix. Args: z_matrix (list): 2D matrix. filename (str): Filename of the output image. title (str): Title of the plot. Default is '' (no title). x_label (str): x-axis label. y_label (str): y-axis label.
[ "Function", "to", "produce", "a", "general", "3D", "plot", "from", "a", "2D", "matrix", "." ]
0e67fa0b839f94981f8e18dfd42c30f98b68f500
https://github.com/jtambasco/gnuplotpy/blob/0e67fa0b839f94981f8e18dfd42c30f98b68f500/gnuplotpy/gnuplot.py#L190-L231
train
Function to produce a general 3D plot from a 2D matrix.
SUNCAT-Center/CatHub
cathub/folderreader.py
FolderReader.read
def read(self, skip=[], goto_metal=None, goto_reaction=None): """ Get reactions from folders. Parameters ---------- skip: list of str list of folders not to read goto_reaction: str Skip ahead to this metal goto_reaction: Skip a...
python
def read(self, skip=[], goto_metal=None, goto_reaction=None): """ Get reactions from folders. Parameters ---------- skip: list of str list of folders not to read goto_reaction: str Skip ahead to this metal goto_reaction: Skip a...
[ "def", "read", "(", "self", ",", "skip", "=", "[", "]", ",", "goto_metal", "=", "None", ",", "goto_reaction", "=", "None", ")", ":", "if", "len", "(", "skip", ")", ">", "0", ":", "for", "skip_f", "in", "skip", ":", "self", ".", "omit_folders", "....
Get reactions from folders. Parameters ---------- skip: list of str list of folders not to read goto_reaction: str Skip ahead to this metal goto_reaction: Skip ahead to this reacion
[ "Get", "reactions", "from", "folders", "." ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/folderreader.py#L79-L150
train
Reads all reactions from the user s data base folder.
SUNCAT-Center/CatHub
cathub/folderreader.py
FolderReader.read_reaction
def read_reaction(self, root): folder_name = os.path.basename(root) self.reaction, self.sites = ase_tools.get_reaction_from_folder( folder_name) # reaction dict self.stdout.write( '----------- REACTION: {} --> {} --------------\n' .format('+'.join(self.rea...
python
def read_reaction(self, root): folder_name = os.path.basename(root) self.reaction, self.sites = ase_tools.get_reaction_from_folder( folder_name) # reaction dict self.stdout.write( '----------- REACTION: {} --> {} --------------\n' .format('+'.join(self.rea...
[ "def", "read_reaction", "(", "self", ",", "root", ")", ":", "folder_name", "=", "os", ".", "path", ".", "basename", "(", "root", ")", "self", ".", "reaction", ",", "self", ".", "sites", "=", "ase_tools", ".", "get_reaction_from_folder", "(", "folder_name",...
Create empty dictionaries
[ "Create", "empty", "dictionaries" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/folderreader.py#L400-L441
train
Read reaction from folder root.
SUNCAT-Center/CatHub
cathub/folderreader.py
FolderReader.read_energies
def read_energies(self, root): self.key_value_pairs_reaction = None slab_structures = collect_structures(root) if len(slab_structures) == 0: self.raise_warning('No structure files in {root}: Skipping this folder' .format(root=root)) return...
python
def read_energies(self, root): self.key_value_pairs_reaction = None slab_structures = collect_structures(root) if len(slab_structures) == 0: self.raise_warning('No structure files in {root}: Skipping this folder' .format(root=root)) return...
[ "def", "read_energies", "(", "self", ",", "root", ")", ":", "self", ".", "key_value_pairs_reaction", "=", "None", "slab_structures", "=", "collect_structures", "(", "root", ")", "if", "len", "(", "slab_structures", ")", "==", "0", ":", "self", ".", "raise_wa...
Match adsorbate structures with reaction entries
[ "Match", "adsorbate", "structures", "with", "reaction", "entries" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/folderreader.py#L443-L802
train
Reads the energy of a root folder and returns the key - value pairs for each entry in the tree.
guaix-ucm/numina
numina/array/utils.py
slice_create
def slice_create(center, block, start=0, stop=None): '''Return an slice with a symmetric region around center.''' do = coor_to_pix_1d(center - block) up = coor_to_pix_1d(center + block) l = max(start, do) if stop is not None: h = min(up + 1, stop) else: h = up + 1 return ...
python
def slice_create(center, block, start=0, stop=None): '''Return an slice with a symmetric region around center.''' do = coor_to_pix_1d(center - block) up = coor_to_pix_1d(center + block) l = max(start, do) if stop is not None: h = min(up + 1, stop) else: h = up + 1 return ...
[ "def", "slice_create", "(", "center", ",", "block", ",", "start", "=", "0", ",", "stop", "=", "None", ")", ":", "do", "=", "coor_to_pix_1d", "(", "center", "-", "block", ")", "up", "=", "coor_to_pix_1d", "(", "center", "+", "block", ")", "l", "=", ...
Return an slice with a symmetric region around center.
[ "Return", "an", "slice", "with", "a", "symmetric", "region", "around", "center", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/utils.py#L40-L53
train
Return an slice with a symmetric region around center.
guaix-ucm/numina
numina/array/utils.py
image_box
def image_box(center, shape, box): '''Create a region of size box, around a center in a image of shape.''' return tuple(slice_create(c, b, stop=s) for c, s, b in zip(center, shape, box))
python
def image_box(center, shape, box): '''Create a region of size box, around a center in a image of shape.''' return tuple(slice_create(c, b, stop=s) for c, s, b in zip(center, shape, box))
[ "def", "image_box", "(", "center", ",", "shape", ",", "box", ")", ":", "return", "tuple", "(", "slice_create", "(", "c", ",", "b", ",", "stop", "=", "s", ")", "for", "c", ",", "s", ",", "b", "in", "zip", "(", "center", ",", "shape", ",", "box",...
Create a region of size box, around a center in a image of shape.
[ "Create", "a", "region", "of", "size", "box", "around", "a", "center", "in", "a", "image", "of", "shape", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/utils.py#L56-L59
train
Create a region of size box around a center in a image of shape.
guaix-ucm/numina
numina/array/utils.py
expand_slice
def expand_slice(s, a, b, start=0, stop=None): '''Expand a slice on the start/stop limits''' n1 = max(s.start - a, start) n2 = s.stop + b if stop is not None: n2 = min(n2, stop) return slice(n1, n2, 1)
python
def expand_slice(s, a, b, start=0, stop=None): '''Expand a slice on the start/stop limits''' n1 = max(s.start - a, start) n2 = s.stop + b if stop is not None: n2 = min(n2, stop) return slice(n1, n2, 1)
[ "def", "expand_slice", "(", "s", ",", "a", ",", "b", ",", "start", "=", "0", ",", "stop", "=", "None", ")", ":", "n1", "=", "max", "(", "s", ".", "start", "-", "a", ",", "start", ")", "n2", "=", "s", ".", "stop", "+", "b", "if", "stop", "...
Expand a slice on the start/stop limits
[ "Expand", "a", "slice", "on", "the", "start", "/", "stop", "limits" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/utils.py#L71-L78
train
Expand a slice on the start and stop limits
guaix-ucm/numina
numina/array/utils.py
expand_region
def expand_region(tuple_of_s, a, b, start=0, stop=None): '''Apply expend_slice on a tuple of slices''' return tuple(expand_slice(s, a, b, start=start, stop=stop) for s in tuple_of_s)
python
def expand_region(tuple_of_s, a, b, start=0, stop=None): '''Apply expend_slice on a tuple of slices''' return tuple(expand_slice(s, a, b, start=start, stop=stop) for s in tuple_of_s)
[ "def", "expand_region", "(", "tuple_of_s", ",", "a", ",", "b", ",", "start", "=", "0", ",", "stop", "=", "None", ")", ":", "return", "tuple", "(", "expand_slice", "(", "s", ",", "a", ",", "b", ",", "start", "=", "start", ",", "stop", "=", "stop",...
Apply expend_slice on a tuple of slices
[ "Apply", "expend_slice", "on", "a", "tuple", "of", "slices" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/utils.py#L81-L84
train
Apply expend_slice on a tuple of slices
guaix-ucm/numina
numina/user/helpers.py
BaseWorkEnvironment.adapt_obsres
def adapt_obsres(self, obsres): """Adapt obsres after file copy""" _logger.debug('adapt observation result for work dir') for f in obsres.images: # Remove path components f.filename = os.path.basename(f.filename) return obsres
python
def adapt_obsres(self, obsres): """Adapt obsres after file copy""" _logger.debug('adapt observation result for work dir') for f in obsres.images: # Remove path components f.filename = os.path.basename(f.filename) return obsres
[ "def", "adapt_obsres", "(", "self", ",", "obsres", ")", ":", "_logger", ".", "debug", "(", "'adapt observation result for work dir'", ")", "for", "f", "in", "obsres", ".", "images", ":", "# Remove path components", "f", ".", "filename", "=", "os", ".", "path",...
Adapt obsres after file copy
[ "Adapt", "obsres", "after", "file", "copy" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/helpers.py#L326-L333
train
Adapt obsres after file copy
guaix-ucm/numina
numina/user/helpers.py
DiskStorageBase.store
def store(self, completed_task, resultsdir): """Store the values of the completed task.""" with working_directory(resultsdir): _logger.info('storing result') return completed_task.store(self)
python
def store(self, completed_task, resultsdir): """Store the values of the completed task.""" with working_directory(resultsdir): _logger.info('storing result') return completed_task.store(self)
[ "def", "store", "(", "self", ",", "completed_task", ",", "resultsdir", ")", ":", "with", "working_directory", "(", "resultsdir", ")", ":", "_logger", ".", "info", "(", "'storing result'", ")", "return", "completed_task", ".", "store", "(", "self", ")" ]
Store the values of the completed task.
[ "Store", "the", "values", "of", "the", "completed", "task", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/helpers.py#L396-L401
train
Store the values of the completed task.
guaix-ucm/numina
numina/types/datatype.py
DataType.validate
def validate(self, obj): """Validate convertibility to internal representation Returns ------- bool True if 'obj' matches the data type Raises ------- ValidationError If the validation fails """ if not isinstance(obj, self....
python
def validate(self, obj): """Validate convertibility to internal representation Returns ------- bool True if 'obj' matches the data type Raises ------- ValidationError If the validation fails """ if not isinstance(obj, self....
[ "def", "validate", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ",", "self", ".", "internal_type", ")", ":", "raise", "ValidationError", "(", "obj", ",", "self", ".", "internal_type", ")", "return", "True" ]
Validate convertibility to internal representation Returns ------- bool True if 'obj' matches the data type Raises ------- ValidationError If the validation fails
[ "Validate", "convertibility", "to", "internal", "representation" ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/types/datatype.py#L50-L66
train
Validate that the object is of the correct type.
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.create_user
def create_user(self, user, table_privileges=['ALL PRIVILEGES'], schema_privileges=['ALL PRIVILEGES'], row_limit=50000): con = self.connection or self._connect() cur = con.cursor() cur.execute('CREATE SCHEMA {0};'.format(user)) # self._initialize(...
python
def create_user(self, user, table_privileges=['ALL PRIVILEGES'], schema_privileges=['ALL PRIVILEGES'], row_limit=50000): con = self.connection or self._connect() cur = con.cursor() cur.execute('CREATE SCHEMA {0};'.format(user)) # self._initialize(...
[ "def", "create_user", "(", "self", ",", "user", ",", "table_privileges", "=", "[", "'ALL PRIVILEGES'", "]", ",", "schema_privileges", "=", "[", "'ALL PRIVILEGES'", "]", ",", "row_limit", "=", "50000", ")", ":", "con", "=", "self", ".", "connection", "or", ...
Grant SELECT on public schema
[ "Grant", "SELECT", "on", "public", "schema" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L224-L318
train
Create a new user and set the search path to it.
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.delete_user
def delete_user(self, user): """ Delete user and all data""" assert self.user == 'catroot' or self.user == 'postgres' assert not user == 'public' con = self.connection or self._connect() cur = con.cursor() cur.execute('DROP SCHEMA {user} CASCADE;'.format(user=user)) ...
python
def delete_user(self, user): """ Delete user and all data""" assert self.user == 'catroot' or self.user == 'postgres' assert not user == 'public' con = self.connection or self._connect() cur = con.cursor() cur.execute('DROP SCHEMA {user} CASCADE;'.format(user=user)) ...
[ "def", "delete_user", "(", "self", ",", "user", ")", ":", "assert", "self", ".", "user", "==", "'catroot'", "or", "self", ".", "user", "==", "'postgres'", "assert", "not", "user", "==", "'public'", "con", "=", "self", ".", "connection", "or", "self", "...
Delete user and all data
[ "Delete", "user", "and", "all", "data" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L320-L341
train
Delete user and all data
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.release
def release(self, pub_ids=None, email=None, from_schema='upload', to_schema='public'): """ Transfer dataset from one schema to another""" assert pub_ids or email,\ "Specify either pub_ids or email" assert not (pub_ids and email),\ "Specify either pub_ids ...
python
def release(self, pub_ids=None, email=None, from_schema='upload', to_schema='public'): """ Transfer dataset from one schema to another""" assert pub_ids or email,\ "Specify either pub_ids or email" assert not (pub_ids and email),\ "Specify either pub_ids ...
[ "def", "release", "(", "self", ",", "pub_ids", "=", "None", ",", "email", "=", "None", ",", "from_schema", "=", "'upload'", ",", "to_schema", "=", "'public'", ")", ":", "assert", "pub_ids", "or", "email", ",", "\"Specify either pub_ids or email\"", "assert", ...
Transfer dataset from one schema to another
[ "Transfer", "dataset", "from", "one", "schema", "to", "another" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L343-L474
train
Transfer dataset from one schema to another
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.get_pub_id_owner
def get_pub_id_owner(self, pub_id): """Check if a user owns a publication""" con = self.connection or self._connect() cur = con.cursor() cur.execute( """SELECT distinct username from upload.reaction WHERE pub_id = '{pub_id}'""" .format(pub_id=pub_id))...
python
def get_pub_id_owner(self, pub_id): """Check if a user owns a publication""" con = self.connection or self._connect() cur = con.cursor() cur.execute( """SELECT distinct username from upload.reaction WHERE pub_id = '{pub_id}'""" .format(pub_id=pub_id))...
[ "def", "get_pub_id_owner", "(", "self", ",", "pub_id", ")", ":", "con", "=", "self", ".", "connection", "or", "self", ".", "_connect", "(", ")", "cur", "=", "con", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"\"\"SELECT distinct username from up...
Check if a user owns a publication
[ "Check", "if", "a", "user", "owns", "a", "publication" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L476-L488
train
Check if a user owns a publication
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.delete_publication
def delete_publication(self, pub_id, schema='upload'): """ Delete dataset from upload schema""" if schema == 'upload': user = 'upload_admin' elif schema == 'public': user = 'catroot' if not self.user == 'catroot': assert self.user == user, \ ...
python
def delete_publication(self, pub_id, schema='upload'): """ Delete dataset from upload schema""" if schema == 'upload': user = 'upload_admin' elif schema == 'public': user = 'catroot' if not self.user == 'catroot': assert self.user == user, \ ...
[ "def", "delete_publication", "(", "self", ",", "pub_id", ",", "schema", "=", "'upload'", ")", ":", "if", "schema", "==", "'upload'", ":", "user", "=", "'upload_admin'", "elif", "schema", "==", "'public'", ":", "user", "=", "'catroot'", "if", "not", "self",...
Delete dataset from upload schema
[ "Delete", "dataset", "from", "upload", "schema" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L490-L537
train
Delete a publication from the database
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.write_reaction
def write_reaction(self, value_dict): con = self.connection or self._connect() self._initialize(con) cur = con.cursor() ase_ids = value_dict['ase_ids'] energy_corrections = value_dict.get('energy_corrections', {}) key_list = get_key_list(start_index=1) values = ...
python
def write_reaction(self, value_dict): con = self.connection or self._connect() self._initialize(con) cur = con.cursor() ase_ids = value_dict['ase_ids'] energy_corrections = value_dict.get('energy_corrections', {}) key_list = get_key_list(start_index=1) values = ...
[ "def", "write_reaction", "(", "self", ",", "value_dict", ")", ":", "con", "=", "self", ".", "connection", "or", "self", ".", "_connect", "(", ")", "self", ".", "_initialize", "(", "con", ")", "cur", "=", "con", ".", "cursor", "(", ")", "ase_ids", "="...
Write to reaction_system tables
[ "Write", "to", "reaction_system", "tables" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L613-L658
train
Write a new entry to the database.
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.truncate_schema
def truncate_schema(self): """ Will delete all data in schema. Only for test use!""" assert self.server == 'localhost' con = self.connection or self._connect() self._initialize(con) cur = con.cursor() cur.execute('DELETE FROM publication;') cur.execute('TRUNCATE...
python
def truncate_schema(self): """ Will delete all data in schema. Only for test use!""" assert self.server == 'localhost' con = self.connection or self._connect() self._initialize(con) cur = con.cursor() cur.execute('DELETE FROM publication;') cur.execute('TRUNCATE...
[ "def", "truncate_schema", "(", "self", ")", ":", "assert", "self", ".", "server", "==", "'localhost'", "con", "=", "self", ".", "connection", "or", "self", ".", "_connect", "(", ")", "self", ".", "_initialize", "(", "con", ")", "cur", "=", "con", ".", ...
Will delete all data in schema. Only for test use!
[ "Will", "delete", "all", "data", "in", "schema", ".", "Only", "for", "test", "use!" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L772-L786
train
Will delete all data in schema. Only for test use!
SUNCAT-Center/CatHub
cathub/postgresql.py
CathubPostgreSQL.transfer
def transfer(self, filename_sqlite, block_size=1000, start_block=0, write_ase=True, write_publication=True, write_reaction=True, write_reaction_system=True, check=False): """ Transfer data from local sqlite3 .db file to the catalysis-hub postgreSQL serv...
python
def transfer(self, filename_sqlite, block_size=1000, start_block=0, write_ase=True, write_publication=True, write_reaction=True, write_reaction_system=True, check=False): """ Transfer data from local sqlite3 .db file to the catalysis-hub postgreSQL serv...
[ "def", "transfer", "(", "self", ",", "filename_sqlite", ",", "block_size", "=", "1000", ",", "start_block", "=", "0", ",", "write_ase", "=", "True", ",", "write_publication", "=", "True", ",", "write_reaction", "=", "True", ",", "write_reaction_system", "=", ...
Transfer data from local sqlite3 .db file to the catalysis-hub postgreSQL server Parameters: filename_sqlite: str name of .db file block_size: int (default 1000) Number of atomic structures and reactions to write together in each block. start_...
[ "Transfer", "data", "from", "local", "sqlite3", ".", "db", "file", "to", "the", "catalysis", "-", "hub", "postgreSQL", "server" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/postgresql.py#L788-L1016
train
Transfer data from local sqlite3. db file to the catalysis - hub server.
druids/django-chamber
chamber/commands/__init__.py
ProgressBarStream.write
def write(self, *args, **kwargs): """ Call the stream's write method without linebreaks at line endings. """ return self.stream.write(ending="", *args, **kwargs)
python
def write(self, *args, **kwargs): """ Call the stream's write method without linebreaks at line endings. """ return self.stream.write(ending="", *args, **kwargs)
[ "def", "write", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "stream", ".", "write", "(", "ending", "=", "\"\"", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Call the stream's write method without linebreaks at line endings.
[ "Call", "the", "stream", "s", "write", "method", "without", "linebreaks", "at", "line", "endings", "." ]
eef4169923557e96877a664fa254e8c0814f3f23
https://github.com/druids/django-chamber/blob/eef4169923557e96877a664fa254e8c0814f3f23/chamber/commands/__init__.py#L19-L23
train
Call the stream s write method without line breaks at line endings.
arkottke/pysra
pysra/site.py
NonlinearProperty._update
def _update(self): """Initialize the 1D interpolation.""" if self.strains.size and self.strains.size == self.values.size: x = np.log(self.strains) y = self.values if x.size < 4: self._interpolater = interp1d( x, ...
python
def _update(self): """Initialize the 1D interpolation.""" if self.strains.size and self.strains.size == self.values.size: x = np.log(self.strains) y = self.values if x.size < 4: self._interpolater = interp1d( x, ...
[ "def", "_update", "(", "self", ")", ":", "if", "self", ".", "strains", ".", "size", "and", "self", ".", "strains", ".", "size", "==", "self", ".", "values", ".", "size", ":", "x", "=", "np", ".", "log", "(", "self", ".", "strains", ")", "y", "=...
Initialize the 1D interpolation.
[ "Initialize", "the", "1D", "interpolation", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L129-L149
train
Initialize the 1D interpolation.
arkottke/pysra
pysra/site.py
SoilType.is_nonlinear
def is_nonlinear(self): """If nonlinear properties are specified.""" return any( isinstance(p, NonlinearProperty) for p in [self.mod_reduc, self.damping])
python
def is_nonlinear(self): """If nonlinear properties are specified.""" return any( isinstance(p, NonlinearProperty) for p in [self.mod_reduc, self.damping])
[ "def", "is_nonlinear", "(", "self", ")", ":", "return", "any", "(", "isinstance", "(", "p", ",", "NonlinearProperty", ")", "for", "p", "in", "[", "self", ".", "mod_reduc", ",", "self", ".", "damping", "]", ")" ]
If nonlinear properties are specified.
[ "If", "nonlinear", "properties", "are", "specified", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L194-L198
train
Return True if the properties of the class are nonlinear.
arkottke/pysra
pysra/site.py
DarendeliSoilType._calc_damping_min
def _calc_damping_min(self): """minimum damping [decimal]""" return ((0.8005 + 0.0129 * self._plas_index * self._ocr ** -0.1069) * (self._stress_mean * KPA_TO_ATM) ** -0.2889 * (1 + 0.2919 * np.log(self._freq))) / 100
python
def _calc_damping_min(self): """minimum damping [decimal]""" return ((0.8005 + 0.0129 * self._plas_index * self._ocr ** -0.1069) * (self._stress_mean * KPA_TO_ATM) ** -0.2889 * (1 + 0.2919 * np.log(self._freq))) / 100
[ "def", "_calc_damping_min", "(", "self", ")", ":", "return", "(", "(", "0.8005", "+", "0.0129", "*", "self", ".", "_plas_index", "*", "self", ".", "_ocr", "**", "-", "0.1069", ")", "*", "(", "self", ".", "_stress_mean", "*", "KPA_TO_ATM", ")", "**", ...
minimum damping [decimal]
[ "minimum", "damping", "[", "decimal", "]" ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L321-L325
train
calculate minimum damping
arkottke/pysra
pysra/site.py
KishidaSoilType._calc_strain_ref
def _calc_strain_ref(x_3, x_3_mean): """Compute the reference strain using Equation (6).""" b_9 = -1.41 b_10 = -0.950 return np.exp(b_9 + b_10 * (x_3 - x_3_mean)) / 100
python
def _calc_strain_ref(x_3, x_3_mean): """Compute the reference strain using Equation (6).""" b_9 = -1.41 b_10 = -0.950 return np.exp(b_9 + b_10 * (x_3 - x_3_mean)) / 100
[ "def", "_calc_strain_ref", "(", "x_3", ",", "x_3_mean", ")", ":", "b_9", "=", "-", "1.41", "b_10", "=", "-", "0.950", "return", "np", ".", "exp", "(", "b_9", "+", "b_10", "*", "(", "x_3", "-", "x_3_mean", ")", ")", "/", "100" ]
Compute the reference strain using Equation (6).
[ "Compute", "the", "reference", "strain", "using", "Equation", "(", "6", ")", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L485-L489
train
Compute the reference strain using Equation 6.
arkottke/pysra
pysra/site.py
KishidaSoilType._calc_mod_reduc
def _calc_mod_reduc(self, strains, strain_ref, x_1, x_1_mean, x_2, x_2_mean, x_3, x_3_mean): """Compute the shear modulus reduction using Equation (1).""" ones = np.ones_like(strains) # Predictor x_4 = np.log(self._lab_consol_ratio) * ones x = np.c_[ones,...
python
def _calc_mod_reduc(self, strains, strain_ref, x_1, x_1_mean, x_2, x_2_mean, x_3, x_3_mean): """Compute the shear modulus reduction using Equation (1).""" ones = np.ones_like(strains) # Predictor x_4 = np.log(self._lab_consol_ratio) * ones x = np.c_[ones,...
[ "def", "_calc_mod_reduc", "(", "self", ",", "strains", ",", "strain_ref", ",", "x_1", ",", "x_1_mean", ",", "x_2", ",", "x_2_mean", ",", "x_3", ",", "x_3_mean", ")", ":", "ones", "=", "np", ".", "ones_like", "(", "strains", ")", "# Predictor", "x_4", "...
Compute the shear modulus reduction using Equation (1).
[ "Compute", "the", "shear", "modulus", "reduction", "using", "Equation", "(", "1", ")", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L491-L511
train
Compute the shear modulus reduction using Equation ( 1 ).
arkottke/pysra
pysra/site.py
KishidaSoilType._calc_damping
def _calc_damping(mod_reducs, x_2, x_2_mean, x_3, x_3_mean): """Compute the damping ratio using Equation (16).""" # Mean values of the predictors x_1_mean = -1.0 x_1 = np.log(np.log(1 / mod_reducs) + 0.103) ones = np.ones_like(mod_reducs) x = np.c_[ones, x_1, x_2, x_3, (...
python
def _calc_damping(mod_reducs, x_2, x_2_mean, x_3, x_3_mean): """Compute the damping ratio using Equation (16).""" # Mean values of the predictors x_1_mean = -1.0 x_1 = np.log(np.log(1 / mod_reducs) + 0.103) ones = np.ones_like(mod_reducs) x = np.c_[ones, x_1, x_2, x_3, (...
[ "def", "_calc_damping", "(", "mod_reducs", ",", "x_2", ",", "x_2_mean", ",", "x_3", ",", "x_3_mean", ")", ":", "# Mean values of the predictors", "x_1_mean", "=", "-", "1.0", "x_1", "=", "np", ".", "log", "(", "np", ".", "log", "(", "1", "/", "mod_reducs...
Compute the damping ratio using Equation (16).
[ "Compute", "the", "damping", "ratio", "using", "Equation", "(", "16", ")", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L514-L526
train
Compute the damping ratio using Equation 16.
arkottke/pysra
pysra/site.py
IterativeValue.relative_error
def relative_error(self): """The relative error, in percent, between the two iterations. """ if self.previous is not None: # FIXME # Use the maximum strain value -- this is important for error # calculation with frequency dependent properties # pr...
python
def relative_error(self): """The relative error, in percent, between the two iterations. """ if self.previous is not None: # FIXME # Use the maximum strain value -- this is important for error # calculation with frequency dependent properties # pr...
[ "def", "relative_error", "(", "self", ")", ":", "if", "self", ".", "previous", "is", "not", "None", ":", "# FIXME", "# Use the maximum strain value -- this is important for error", "# calculation with frequency dependent properties", "# prev = np.max(self.previous)", "# value = ...
The relative error, in percent, between the two iterations.
[ "The", "relative", "error", "in", "percent", "between", "the", "two", "iterations", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L563-L578
train
The relative error between two iterations.
arkottke/pysra
pysra/site.py
Layer.duplicate
def duplicate(cls, other): """Create a copy of the layer.""" return cls(other.soil_type, other.thickness, other.shear_vel)
python
def duplicate(cls, other): """Create a copy of the layer.""" return cls(other.soil_type, other.thickness, other.shear_vel)
[ "def", "duplicate", "(", "cls", ",", "other", ")", ":", "return", "cls", "(", "other", ".", "soil_type", ",", "other", ".", "thickness", ",", "other", ".", "shear_vel", ")" ]
Create a copy of the layer.
[ "Create", "a", "copy", "of", "the", "layer", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L630-L632
train
Create a copy of the layer.
arkottke/pysra
pysra/site.py
Layer.damping
def damping(self): """Strain-compatible damping.""" try: value = self._damping.value except AttributeError: value = self._damping return value
python
def damping(self): """Strain-compatible damping.""" try: value = self._damping.value except AttributeError: value = self._damping return value
[ "def", "damping", "(", "self", ")", ":", "try", ":", "value", "=", "self", ".", "_damping", ".", "value", "except", "AttributeError", ":", "value", "=", "self", ".", "_damping", "return", "value" ]
Strain-compatible damping.
[ "Strain", "-", "compatible", "damping", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L640-L646
train
Strain - compatible damping.
arkottke/pysra
pysra/site.py
Layer.comp_shear_mod
def comp_shear_mod(self): """Strain-compatible complex shear modulus [kN/m²]. """ damping = self.damping if COMP_MODULUS_MODEL == 'seed': # Frequency independent model (Seed et al., 1970) # Correct dissipated energy # Incorrect shear modulus: G * \sqrt...
python
def comp_shear_mod(self): """Strain-compatible complex shear modulus [kN/m²]. """ damping = self.damping if COMP_MODULUS_MODEL == 'seed': # Frequency independent model (Seed et al., 1970) # Correct dissipated energy # Incorrect shear modulus: G * \sqrt...
[ "def", "comp_shear_mod", "(", "self", ")", ":", "damping", "=", "self", ".", "damping", "if", "COMP_MODULUS_MODEL", "==", "'seed'", ":", "# Frequency independent model (Seed et al., 1970)", "# Correct dissipated energy", "# Incorrect shear modulus: G * \\sqrt{1 + 4 \\beta^2 }", ...
Strain-compatible complex shear modulus [kN/m²].
[ "Strain", "-", "compatible", "complex", "shear", "modulus", "[", "kN", "/", "m²", "]", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L659-L681
train
Strain - compatible complex shear modulus [kN / m².
arkottke/pysra
pysra/site.py
Layer.shear_mod
def shear_mod(self): """Strain-compatible shear modulus [kN//m²].""" try: value = self._shear_mod.value except AttributeError: value = self._shear_mod return value
python
def shear_mod(self): """Strain-compatible shear modulus [kN//m²].""" try: value = self._shear_mod.value except AttributeError: value = self._shear_mod return value
[ "def", "shear_mod", "(", "self", ")", ":", "try", ":", "value", "=", "self", ".", "_shear_mod", ".", "value", "except", "AttributeError", ":", "value", "=", "self", ".", "_shear_mod", "return", "value" ]
Strain-compatible shear modulus [kN//m²].
[ "Strain", "-", "compatible", "shear", "modulus", "[", "kN", "//", "m²", "]", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L700-L706
train
Strain - compatible shear modulus [ kN//m² ].
arkottke/pysra
pysra/site.py
Layer.stress_vert
def stress_vert(self, depth_within=0, effective=False): """Vertical stress from the top of the layer [kN//m²].""" assert depth_within <= self.thickness stress_vert = self._stress_vert + depth_within * self.unit_wt if effective: pore_pressure = self._profile.pore_pressure(self...
python
def stress_vert(self, depth_within=0, effective=False): """Vertical stress from the top of the layer [kN//m²].""" assert depth_within <= self.thickness stress_vert = self._stress_vert + depth_within * self.unit_wt if effective: pore_pressure = self._profile.pore_pressure(self...
[ "def", "stress_vert", "(", "self", ",", "depth_within", "=", "0", ",", "effective", "=", "False", ")", ":", "assert", "depth_within", "<=", "self", ".", "thickness", "stress_vert", "=", "self", ".", "_stress_vert", "+", "depth_within", "*", "self", ".", "u...
Vertical stress from the top of the layer [kN//m²].
[ "Vertical", "stress", "from", "the", "top", "of", "the", "layer", "[", "kN", "//", "m²", "]", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L775-L783
train
Vertical stress from the top of the layer [ kN // m² ].
arkottke/pysra
pysra/site.py
Profile.auto_discretize
def auto_discretize(self, max_freq=50., wave_frac=0.2): """Subdivide the layers to capture strain variation. Parameters ---------- max_freq: float Maximum frequency of interest [Hz]. wave_frac: float Fraction of wavelength required. Typically 1/3 to 1/5. ...
python
def auto_discretize(self, max_freq=50., wave_frac=0.2): """Subdivide the layers to capture strain variation. Parameters ---------- max_freq: float Maximum frequency of interest [Hz]. wave_frac: float Fraction of wavelength required. Typically 1/3 to 1/5. ...
[ "def", "auto_discretize", "(", "self", ",", "max_freq", "=", "50.", ",", "wave_frac", "=", "0.2", ")", ":", "layers", "=", "[", "]", "for", "l", "in", "self", ":", "if", "l", ".", "soil_type", ".", "is_nonlinear", ":", "opt_thickness", "=", "l", ".",...
Subdivide the layers to capture strain variation. Parameters ---------- max_freq: float Maximum frequency of interest [Hz]. wave_frac: float Fraction of wavelength required. Typically 1/3 to 1/5. Returns ------- profile: Profile ...
[ "Subdivide", "the", "layers", "to", "capture", "strain", "variation", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L866-L892
train
Subdivide the layers to capture strain variation.
arkottke/pysra
pysra/site.py
Profile.location
def location(self, wave_field, depth=None, index=None): """Create a Location for a specific depth. Parameters ---------- wave_field: str Wave field. See :class:`Location` for possible values. depth: float, optional Depth corresponding to the :class`Locati...
python
def location(self, wave_field, depth=None, index=None): """Create a Location for a specific depth. Parameters ---------- wave_field: str Wave field. See :class:`Location` for possible values. depth: float, optional Depth corresponding to the :class`Locati...
[ "def", "location", "(", "self", ",", "wave_field", ",", "depth", "=", "None", ",", "index", "=", "None", ")", ":", "if", "not", "isinstance", "(", "wave_field", ",", "WaveField", ")", ":", "wave_field", "=", "WaveField", "[", "wave_field", "]", "if", "...
Create a Location for a specific depth. Parameters ---------- wave_field: str Wave field. See :class:`Location` for possible values. depth: float, optional Depth corresponding to the :class`Location` of interest. If provided, then index is ignored. ...
[ "Create", "a", "Location", "for", "a", "specific", "depth", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L910-L950
train
Create a Location object for a specific depth.
arkottke/pysra
pysra/site.py
Profile.time_average_vel
def time_average_vel(self, depth): """Calculate the time-average velocity. Parameters ---------- depth: float Depth over which the average velocity is computed. Returns ------- avg_vel: float Time averaged velocity. """ de...
python
def time_average_vel(self, depth): """Calculate the time-average velocity. Parameters ---------- depth: float Depth over which the average velocity is computed. Returns ------- avg_vel: float Time averaged velocity. """ de...
[ "def", "time_average_vel", "(", "self", ",", "depth", ")", ":", "depths", "=", "[", "l", ".", "depth", "for", "l", "in", "self", "]", "# Final layer is infinite and is treated separately", "travel_times", "=", "[", "0", "]", "+", "[", "l", ".", "travel_time"...
Calculate the time-average velocity. Parameters ---------- depth: float Depth over which the average velocity is computed. Returns ------- avg_vel: float Time averaged velocity.
[ "Calculate", "the", "time", "-", "average", "velocity", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L952-L976
train
Calculates the time - average velocity.
arkottke/pysra
pysra/site.py
Profile.simplified_rayliegh_vel
def simplified_rayliegh_vel(self): """Simplified Rayliegh velocity of the site. This follows the simplifications proposed by Urzua et al. (2017) Returns ------- rayleigh_vel : float Equivalent shear-wave velocity. """ # FIXME: What if last layer has ...
python
def simplified_rayliegh_vel(self): """Simplified Rayliegh velocity of the site. This follows the simplifications proposed by Urzua et al. (2017) Returns ------- rayleigh_vel : float Equivalent shear-wave velocity. """ # FIXME: What if last layer has ...
[ "def", "simplified_rayliegh_vel", "(", "self", ")", ":", "# FIXME: What if last layer has no thickness?", "thicks", "=", "np", ".", "array", "(", "[", "l", ".", "thickness", "for", "l", "in", "self", "]", ")", "depths_mid", "=", "np", ".", "array", "(", "[",...
Simplified Rayliegh velocity of the site. This follows the simplifications proposed by Urzua et al. (2017) Returns ------- rayleigh_vel : float Equivalent shear-wave velocity.
[ "Simplified", "Rayliegh", "velocity", "of", "the", "site", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/site.py#L978-L1008
train
Simplified Rayliegh velocity of the site.
arkottke/pysra
pysra/variation.py
ToroThicknessVariation.iter_thickness
def iter_thickness(self, depth_total): """Iterate over the varied thicknesses. The layering is generated using a non-homogenous Poisson process. The following routine is used to generate the layering. The rate function, :math:`\lambda(t)`, is integrated from 0 to t to generate c...
python
def iter_thickness(self, depth_total): """Iterate over the varied thicknesses. The layering is generated using a non-homogenous Poisson process. The following routine is used to generate the layering. The rate function, :math:`\lambda(t)`, is integrated from 0 to t to generate c...
[ "def", "iter_thickness", "(", "self", ",", "depth_total", ")", ":", "total", "=", "0", "depth_prev", "=", "0", "while", "depth_prev", "<", "depth_total", ":", "# Add a random exponential increment", "total", "+=", "np", ".", "random", ".", "exponential", "(", ...
Iterate over the varied thicknesses. The layering is generated using a non-homogenous Poisson process. The following routine is used to generate the layering. The rate function, :math:`\lambda(t)`, is integrated from 0 to t to generate cumulative rate function, :math:`\Lambda(t)`. This ...
[ "Iterate", "over", "the", "varied", "thicknesses", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L149-L194
train
Iterate over the varied thicknesses.
arkottke/pysra
pysra/variation.py
VelocityVariation._calc_covar_matrix
def _calc_covar_matrix(self, profile): """Calculate the covariance matrix. Parameters ---------- profile : site.Profile Input site profile Yields ------ covar : `class`:numpy.array Covariance matrix """ corr = self._calc_c...
python
def _calc_covar_matrix(self, profile): """Calculate the covariance matrix. Parameters ---------- profile : site.Profile Input site profile Yields ------ covar : `class`:numpy.array Covariance matrix """ corr = self._calc_c...
[ "def", "_calc_covar_matrix", "(", "self", ",", "profile", ")", ":", "corr", "=", "self", ".", "_calc_corr", "(", "profile", ")", "std", "=", "self", ".", "_calc_ln_std", "(", "profile", ")", "# Modify the standard deviation by the truncated norm scale", "std", "*=...
Calculate the covariance matrix. Parameters ---------- profile : site.Profile Input site profile Yields ------ covar : `class`:numpy.array Covariance matrix
[ "Calculate", "the", "covariance", "matrix", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L265-L289
train
Calculate the covariance matrix.
arkottke/pysra
pysra/variation.py
ToroVelocityVariation._calc_corr
def _calc_corr(self, profile): """Compute the adjacent-layer correlations Parameters ---------- profile : :class:`site.Profile` Input site profile Yields ------ corr : :class:`numpy.array` Adjacent-layer correlations """ d...
python
def _calc_corr(self, profile): """Compute the adjacent-layer correlations Parameters ---------- profile : :class:`site.Profile` Input site profile Yields ------ corr : :class:`numpy.array` Adjacent-layer correlations """ d...
[ "def", "_calc_corr", "(", "self", ",", "profile", ")", ":", "depth", "=", "np", ".", "array", "(", "[", "l", ".", "depth_mid", "for", "l", "in", "profile", "[", ":", "-", "1", "]", "]", ")", "thick", "=", "np", ".", "diff", "(", "depth", ")", ...
Compute the adjacent-layer correlations Parameters ---------- profile : :class:`site.Profile` Input site profile Yields ------ corr : :class:`numpy.array` Adjacent-layer correlations
[ "Compute", "the", "adjacent", "-", "layer", "correlations" ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L419-L451
train
Compute the adjacent - layer correlations of a given site profile.
arkottke/pysra
pysra/variation.py
ToroVelocityVariation.generic_model
def generic_model(cls, site_class, **kwds): """Use generic model parameters based on site class. Parameters ---------- site_class: str Site classification. Possible options are: * Geomatrix AB * Geomatrix CD * USGS AB * USG...
python
def generic_model(cls, site_class, **kwds): """Use generic model parameters based on site class. Parameters ---------- site_class: str Site classification. Possible options are: * Geomatrix AB * Geomatrix CD * USGS AB * USG...
[ "def", "generic_model", "(", "cls", ",", "site_class", ",", "*", "*", "kwds", ")", ":", "p", "=", "dict", "(", "cls", ".", "PARAMS", "[", "site_class", "]", ")", "p", ".", "update", "(", "kwds", ")", "return", "cls", "(", "*", "*", "p", ")" ]
Use generic model parameters based on site class. Parameters ---------- site_class: str Site classification. Possible options are: * Geomatrix AB * Geomatrix CD * USGS AB * USGS CD * USGS A * USGS B ...
[ "Use", "generic", "model", "parameters", "based", "on", "site", "class", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L486-L521
train
Use generic model parameters based on site class.
arkottke/pysra
pysra/variation.py
DarendeliVariation.calc_std_mod_reduc
def calc_std_mod_reduc(mod_reduc): """Calculate the standard deviation as a function of G/G_max. Equation 7.29 from Darendeli (2001). Parameters ---------- mod_reduc : array_like Modulus reduction values. Returns ------- std : :class:`numpy....
python
def calc_std_mod_reduc(mod_reduc): """Calculate the standard deviation as a function of G/G_max. Equation 7.29 from Darendeli (2001). Parameters ---------- mod_reduc : array_like Modulus reduction values. Returns ------- std : :class:`numpy....
[ "def", "calc_std_mod_reduc", "(", "mod_reduc", ")", ":", "mod_reduc", "=", "np", ".", "asarray", "(", "mod_reduc", ")", ".", "astype", "(", "float", ")", "std", "=", "(", "np", ".", "exp", "(", "-", "4.23", ")", "+", "np", ".", "sqrt", "(", "0.25",...
Calculate the standard deviation as a function of G/G_max. Equation 7.29 from Darendeli (2001). Parameters ---------- mod_reduc : array_like Modulus reduction values. Returns ------- std : :class:`numpy.ndarray` Standard deviation.
[ "Calculate", "the", "standard", "deviation", "as", "a", "function", "of", "G", "/", "G_max", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L594-L612
train
Calculates the standard deviation as a function of G / G_max.
arkottke/pysra
pysra/variation.py
DarendeliVariation.calc_std_damping
def calc_std_damping(damping): """Calculate the standard deviation as a function of damping in decimal. Equation 7.30 from Darendeli (2001). Parameters ---------- damping : array_like Material damping values in decimal. Returns ------- std :...
python
def calc_std_damping(damping): """Calculate the standard deviation as a function of damping in decimal. Equation 7.30 from Darendeli (2001). Parameters ---------- damping : array_like Material damping values in decimal. Returns ------- std :...
[ "def", "calc_std_damping", "(", "damping", ")", ":", "damping", "=", "np", ".", "asarray", "(", "damping", ")", ".", "astype", "(", "float", ")", "std", "=", "(", "np", ".", "exp", "(", "-", "5", ")", "+", "np", ".", "exp", "(", "-", "0.25", ")...
Calculate the standard deviation as a function of damping in decimal. Equation 7.30 from Darendeli (2001). Parameters ---------- damping : array_like Material damping values in decimal. Returns ------- std : :class:`numpy.ndarray` Standa...
[ "Calculate", "the", "standard", "deviation", "as", "a", "function", "of", "damping", "in", "decimal", "." ]
c72fd389d6c15203c0c00728ac00f101bae6369d
https://github.com/arkottke/pysra/blob/c72fd389d6c15203c0c00728ac00f101bae6369d/pysra/variation.py#L615-L632
train
Calculates the standard deviation of the log entry in the system.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder._append_to
def _append_to(self, field, element): """Append the ``element`` to the ``field`` of the record. This method is smart: it does nothing if ``element`` is empty and creates ``field`` if it does not exit yet. Args: :param field: the name of the field of the record to append to ...
python
def _append_to(self, field, element): """Append the ``element`` to the ``field`` of the record. This method is smart: it does nothing if ``element`` is empty and creates ``field`` if it does not exit yet. Args: :param field: the name of the field of the record to append to ...
[ "def", "_append_to", "(", "self", ",", "field", ",", "element", ")", ":", "if", "element", "not", "in", "EMPTIES", ":", "self", ".", "obj", ".", "setdefault", "(", "field", ",", "[", "]", ")", "self", ".", "obj", ".", "get", "(", "field", ")", "....
Append the ``element`` to the ``field`` of the record. This method is smart: it does nothing if ``element`` is empty and creates ``field`` if it does not exit yet. Args: :param field: the name of the field of the record to append to :type field: string :para...
[ "Append", "the", "element", "to", "the", "field", "of", "the", "record", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L64-L77
train
Append the element to the field of the record.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_name_variant
def add_name_variant(self, name): """Add name variant. Args: :param name: name variant for the current author. :type name: string """ self._ensure_field('name', {}) self.obj['name'].setdefault('name_variants', []).append(name)
python
def add_name_variant(self, name): """Add name variant. Args: :param name: name variant for the current author. :type name: string """ self._ensure_field('name', {}) self.obj['name'].setdefault('name_variants', []).append(name)
[ "def", "add_name_variant", "(", "self", ",", "name", ")", ":", "self", ".", "_ensure_field", "(", "'name'", ",", "{", "}", ")", "self", ".", "obj", "[", "'name'", "]", ".", "setdefault", "(", "'name_variants'", ",", "[", "]", ")", ".", "append", "(",...
Add name variant. Args: :param name: name variant for the current author. :type name: string
[ "Add", "name", "variant", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L102-L110
train
Add a name variant to the name_variants field.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_native_name
def add_native_name(self, name): """Add native name. Args: :param name: native name for the current author. :type name: string """ self._ensure_field('name', {}) self.obj['name'].setdefault('native_names', []).append(name)
python
def add_native_name(self, name): """Add native name. Args: :param name: native name for the current author. :type name: string """ self._ensure_field('name', {}) self.obj['name'].setdefault('native_names', []).append(name)
[ "def", "add_native_name", "(", "self", ",", "name", ")", ":", "self", ".", "_ensure_field", "(", "'name'", ",", "{", "}", ")", "self", ".", "obj", "[", "'name'", "]", ".", "setdefault", "(", "'native_names'", ",", "[", "]", ")", ".", "append", "(", ...
Add native name. Args: :param name: native name for the current author. :type name: string
[ "Add", "native", "name", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L113-L121
train
Add native name.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_previous_name
def add_previous_name(self, name): """Add previous name. Args: :param name: previous name for the current author. :type name: string """ self._ensure_field('name', {}) self.obj['name'].setdefault('previous_names', []).append(name)
python
def add_previous_name(self, name): """Add previous name. Args: :param name: previous name for the current author. :type name: string """ self._ensure_field('name', {}) self.obj['name'].setdefault('previous_names', []).append(name)
[ "def", "add_previous_name", "(", "self", ",", "name", ")", ":", "self", ".", "_ensure_field", "(", "'name'", ",", "{", "}", ")", "self", ".", "obj", "[", "'name'", "]", ".", "setdefault", "(", "'previous_names'", ",", "[", "]", ")", ".", "append", "(...
Add previous name. Args: :param name: previous name for the current author. :type name: string
[ "Add", "previous", "name", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L124-L132
train
Add previous name.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_email_address
def add_email_address(self, email, hidden=None): """Add email address. Args: :param email: email of the author. :type email: string :param hidden: if email is public or not. :type hidden: boolean """ existing_emails = get_value(self.obj, ...
python
def add_email_address(self, email, hidden=None): """Add email address. Args: :param email: email of the author. :type email: string :param hidden: if email is public or not. :type hidden: boolean """ existing_emails = get_value(self.obj, ...
[ "def", "add_email_address", "(", "self", ",", "email", ",", "hidden", "=", "None", ")", ":", "existing_emails", "=", "get_value", "(", "self", ".", "obj", ",", "'email_addresses'", ",", "[", "]", ")", "found_email", "=", "next", "(", "(", "existing_email",...
Add email address. Args: :param email: email of the author. :type email: string :param hidden: if email is public or not. :type hidden: boolean
[ "Add", "email", "address", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L135-L156
train
Adds an email address to the author s email_addresses field.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_url
def add_url(self, url, description=None): """Add a personal website. Args: :param url: url to the person's website. :type url: string :param description: short description of the website. :type description: string """ url = { ...
python
def add_url(self, url, description=None): """Add a personal website. Args: :param url: url to the person's website. :type url: string :param description: short description of the website. :type description: string """ url = { ...
[ "def", "add_url", "(", "self", ",", "url", ",", "description", "=", "None", ")", ":", "url", "=", "{", "'value'", ":", "url", ",", "}", "if", "description", ":", "url", "[", "'description'", "]", "=", "description", "self", ".", "_append_to", "(", "'...
Add a personal website. Args: :param url: url to the person's website. :type url: string :param description: short description of the website. :type description: string
[ "Add", "a", "personal", "website", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L169-L184
train
Add a personal website.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_institution
def add_institution(self, institution, start_date=None, end_date=None, rank=None, record=None, curated=False, current=False): """Add an institution where the person works/worked. Args: :param institution: name of the institution. :type institution: string :param sta...
python
def add_institution(self, institution, start_date=None, end_date=None, rank=None, record=None, curated=False, current=False): """Add an institution where the person works/worked. Args: :param institution: name of the institution. :type institution: string :param sta...
[ "def", "add_institution", "(", "self", ",", "institution", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "rank", "=", "None", ",", "record", "=", "None", ",", "curated", "=", "False", ",", "current", "=", "False", ")", ":", "new_in...
Add an institution where the person works/worked. Args: :param institution: name of the institution. :type institution: string :param start_date: the date when the person joined the institution, in any format. :type start_date: string :param end_dat...
[ "Add", "an", "institution", "where", "the", "person", "works", "/", "worked", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L259-L297
train
Adds an institution where the person works or worked.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_project
def add_project(self, name, record=None, start_date=None, end_date=None, curated=False, current=False): """Add an experiment that the person worked on. Args: :param name: name of the experiment. :type name: string :param start_date: the date when the person started ...
python
def add_project(self, name, record=None, start_date=None, end_date=None, curated=False, current=False): """Add an experiment that the person worked on. Args: :param name: name of the experiment. :type name: string :param start_date: the date when the person started ...
[ "def", "add_project", "(", "self", ",", "name", ",", "record", "=", "None", ",", "start_date", "=", "None", ",", "end_date", "=", "None", ",", "curated", "=", "False", ",", "current", "=", "False", ")", ":", "new_experiment", "=", "{", "}", "new_experi...
Add an experiment that the person worked on. Args: :param name: name of the experiment. :type name: string :param start_date: the date when the person started working on the experiment. :type start_date: string :param end_date: the date when the per...
[ "Add", "an", "experiment", "that", "the", "person", "worked", "on", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L306-L339
train
Add a new project to the experiment.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_advisor
def add_advisor(self, name, ids=None, degree_type=None, record=None, curated=False): """Add an advisor. Args: :param name: full name of the advisor. :type name: string :param ids: list with the IDs of the advisor. :type ids: list :param degr...
python
def add_advisor(self, name, ids=None, degree_type=None, record=None, curated=False): """Add an advisor. Args: :param name: full name of the advisor. :type name: string :param ids: list with the IDs of the advisor. :type ids: list :param degr...
[ "def", "add_advisor", "(", "self", ",", "name", ",", "ids", "=", "None", ",", "degree_type", "=", "None", ",", "record", "=", "None", ",", "curated", "=", "False", ")", ":", "new_advisor", "=", "{", "}", "new_advisor", "[", "'name'", "]", "=", "norma...
Add an advisor. Args: :param name: full name of the advisor. :type name: string :param ids: list with the IDs of the advisor. :type ids: list :param degree_type: one of the allowed types of degree the advisor helped with. :type degree_ty...
[ "Add", "an", "advisor", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L350-L378
train
Add an advisor.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_private_note
def add_private_note(self, note, source=None): """Add a private note. Args: :param comment: comment about the author. :type comment: string :param source: the source of the comment. :type source: string """ note = { 'value': n...
python
def add_private_note(self, note, source=None): """Add a private note. Args: :param comment: comment about the author. :type comment: string :param source: the source of the comment. :type source: string """ note = { 'value': n...
[ "def", "add_private_note", "(", "self", ",", "note", ",", "source", "=", "None", ")", ":", "note", "=", "{", "'value'", ":", "note", ",", "}", "if", "source", ":", "note", "[", "'source'", "]", "=", "source", "self", ".", "_append_to", "(", "'_privat...
Add a private note. Args: :param comment: comment about the author. :type comment: string :param source: the source of the comment. :type source: string
[ "Add", "a", "private", "note", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L381-L396
train
Add a private note.
inspirehep/inspire-schemas
inspire_schemas/builders/authors.py
AuthorBuilder.add_acquisition_source
def add_acquisition_source( self, method, submission_number=None, internal_uid=None, email=None, orcid=None, source=None, datetime=None, ): """Add acquisition source. :type submission_number: integer :type email: integer ...
python
def add_acquisition_source( self, method, submission_number=None, internal_uid=None, email=None, orcid=None, source=None, datetime=None, ): """Add acquisition source. :type submission_number: integer :type email: integer ...
[ "def", "add_acquisition_source", "(", "self", ",", "method", ",", "submission_number", "=", "None", ",", "internal_uid", "=", "None", ",", "email", "=", "None", ",", "orcid", "=", "None", ",", "source", "=", "None", ",", "datetime", "=", "None", ",", ")"...
Add acquisition source. :type submission_number: integer :type email: integer :type source: string :param method: method of acquisition for the suggested document :type method: string :param orcid: orcid of the user that is creating the record :type orcid: st...
[ "Add", "acquisition", "source", "." ]
34bc124b62fba565b6b40d1a3c15103a23a05edb
https://github.com/inspirehep/inspire-schemas/blob/34bc124b62fba565b6b40d1a3c15103a23a05edb/inspire_schemas/builders/authors.py#L399-L436
train
Add a new acquisition source to the object.
guaix-ucm/numina
numina/array/imsurfit.py
_compute_value
def _compute_value(power, wg): """Return the weight corresponding to single power.""" if power not in wg: p1, p2 = power # y power if p1 == 0: yy = wg[(0, -1)] wg[power] = numpy.power(yy, p2 / 2).sum() / len(yy) # x power else: xx = wg[...
python
def _compute_value(power, wg): """Return the weight corresponding to single power.""" if power not in wg: p1, p2 = power # y power if p1 == 0: yy = wg[(0, -1)] wg[power] = numpy.power(yy, p2 / 2).sum() / len(yy) # x power else: xx = wg[...
[ "def", "_compute_value", "(", "power", ",", "wg", ")", ":", "if", "power", "not", "in", "wg", ":", "p1", ",", "p2", "=", "power", "# y power", "if", "p1", "==", "0", ":", "yy", "=", "wg", "[", "(", "0", ",", "-", "1", ")", "]", "wg", "[", "...
Return the weight corresponding to single power.
[ "Return", "the", "weight", "corresponding", "to", "single", "power", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/imsurfit.py#L25-L37
train
Compute the value corresponding to single power.
guaix-ucm/numina
numina/array/imsurfit.py
_compute_weight
def _compute_weight(powers, wg): """Return the weight corresponding to given powers.""" # split pow1 = (powers[0], 0) pow2 = (0, powers[1]) cal1 = _compute_value(pow1, wg) cal2 = _compute_value(pow2, wg) return cal1 * cal2
python
def _compute_weight(powers, wg): """Return the weight corresponding to given powers.""" # split pow1 = (powers[0], 0) pow2 = (0, powers[1]) cal1 = _compute_value(pow1, wg) cal2 = _compute_value(pow2, wg) return cal1 * cal2
[ "def", "_compute_weight", "(", "powers", ",", "wg", ")", ":", "# split", "pow1", "=", "(", "powers", "[", "0", "]", ",", "0", ")", "pow2", "=", "(", "0", ",", "powers", "[", "1", "]", ")", "cal1", "=", "_compute_value", "(", "pow1", ",", "wg", ...
Return the weight corresponding to given powers.
[ "Return", "the", "weight", "corresponding", "to", "given", "powers", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/imsurfit.py#L40-L49
train
Compute the weight corresponding to given powers.
guaix-ucm/numina
numina/array/imsurfit.py
imsurfit
def imsurfit(data, order, output_fit=False): """Fit a bidimensional polynomial to an image. :param data: a bidimensional array :param integer order: order of the polynomial :param bool output_fit: return the fitted image :returns: a tuple with an array with the coefficients of the polynomial terms ...
python
def imsurfit(data, order, output_fit=False): """Fit a bidimensional polynomial to an image. :param data: a bidimensional array :param integer order: order of the polynomial :param bool output_fit: return the fitted image :returns: a tuple with an array with the coefficients of the polynomial terms ...
[ "def", "imsurfit", "(", "data", ",", "order", ",", "output_fit", "=", "False", ")", ":", "# we create a grid with the same number of points", "# between -1 and 1", "c0", "=", "complex", "(", "0", ",", "data", ".", "shape", "[", "0", "]", ")", "c1", "=", "com...
Fit a bidimensional polynomial to an image. :param data: a bidimensional array :param integer order: order of the polynomial :param bool output_fit: return the fitted image :returns: a tuple with an array with the coefficients of the polynomial terms >>> import numpy >>> xx, yy = numpy.mgrid[-...
[ "Fit", "a", "bidimensional", "polynomial", "to", "an", "image", "." ]
6c829495df8937f77c2de9383c1038ffb3e713e3
https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/array/imsurfit.py#L52-L125
train
Fit a bidimensional polynomial to an image.
pvizeli/yahooweather
yahooweather.py
_yql_query
def _yql_query(yql): """Fetch data from Yahoo! Return a dict if successfull or None.""" url = _YAHOO_BASE_URL.format(urlencode({'q': yql})) # send request _LOGGER.debug("Send request to url: %s", url) try: request = urlopen(url) rawData = request.read() # parse jason ...
python
def _yql_query(yql): """Fetch data from Yahoo! Return a dict if successfull or None.""" url = _YAHOO_BASE_URL.format(urlencode({'q': yql})) # send request _LOGGER.debug("Send request to url: %s", url) try: request = urlopen(url) rawData = request.read() # parse jason ...
[ "def", "_yql_query", "(", "yql", ")", ":", "url", "=", "_YAHOO_BASE_URL", ".", "format", "(", "urlencode", "(", "{", "'q'", ":", "yql", "}", ")", ")", "# send request", "_LOGGER", ".", "debug", "(", "\"Send request to url: %s\"", ",", "url", ")", "try", ...
Fetch data from Yahoo! Return a dict if successfull or None.
[ "Fetch", "data", "from", "Yahoo!", "Return", "a", "dict", "if", "successfull", "or", "None", "." ]
42e59510fc20b84afc8efadfbc3a30c15675b327
https://github.com/pvizeli/yahooweather/blob/42e59510fc20b84afc8efadfbc3a30c15675b327/yahooweather.py#L22-L41
train
Fetch data from Yahoo! Return a dict if successfull or None.
pvizeli/yahooweather
yahooweather.py
get_woeid
def get_woeid(lat, lon): """Ask Yahoo! who is the woeid from GPS position.""" yql = _YQL_WOEID.format(lat, lon) # send request tmpData = _yql_query(yql) if tmpData is None: _LOGGER.error("No woid is received!") return None # found woid? return tmpData.get("place", {}).get(...
python
def get_woeid(lat, lon): """Ask Yahoo! who is the woeid from GPS position.""" yql = _YQL_WOEID.format(lat, lon) # send request tmpData = _yql_query(yql) if tmpData is None: _LOGGER.error("No woid is received!") return None # found woid? return tmpData.get("place", {}).get(...
[ "def", "get_woeid", "(", "lat", ",", "lon", ")", ":", "yql", "=", "_YQL_WOEID", ".", "format", "(", "lat", ",", "lon", ")", "# send request", "tmpData", "=", "_yql_query", "(", "yql", ")", "if", "tmpData", "is", "None", ":", "_LOGGER", ".", "error", ...
Ask Yahoo! who is the woeid from GPS position.
[ "Ask", "Yahoo!", "who", "is", "the", "woeid", "from", "GPS", "position", "." ]
42e59510fc20b84afc8efadfbc3a30c15675b327
https://github.com/pvizeli/yahooweather/blob/42e59510fc20b84afc8efadfbc3a30c15675b327/yahooweather.py#L44-L56
train
Ask Yahoo! who is the woeid from GPS position.
pvizeli/yahooweather
yahooweather.py
YahooWeather.updateWeather
def updateWeather(self): """Fetch weather data from Yahoo! True if success.""" yql = _YQL_WEATHER.format(self._woeid, self._unit) # send request tmpData = _yql_query(yql) # data exists if tmpData is not None and "channel" in tmpData: self._data = tmpData["ch...
python
def updateWeather(self): """Fetch weather data from Yahoo! True if success.""" yql = _YQL_WEATHER.format(self._woeid, self._unit) # send request tmpData = _yql_query(yql) # data exists if tmpData is not None and "channel" in tmpData: self._data = tmpData["ch...
[ "def", "updateWeather", "(", "self", ")", ":", "yql", "=", "_YQL_WEATHER", ".", "format", "(", "self", ".", "_woeid", ",", "self", ".", "_unit", ")", "# send request", "tmpData", "=", "_yql_query", "(", "yql", ")", "# data exists", "if", "tmpData", "is", ...
Fetch weather data from Yahoo! True if success.
[ "Fetch", "weather", "data", "from", "Yahoo!", "True", "if", "success", "." ]
42e59510fc20b84afc8efadfbc3a30c15675b327
https://github.com/pvizeli/yahooweather/blob/42e59510fc20b84afc8efadfbc3a30c15675b327/yahooweather.py#L68-L82
train
Fetch weather data from Yahoo! True if success.
SUNCAT-Center/CatHub
cathub/ase_tools/__init__.py
get_chemical_formula
def get_chemical_formula(atoms, mode='metal'): """ Compatibility function, return mode=metal, when available, mode=hill, when not (ASE <= 3.13) """ try: return atoms.get_chemical_formula(mode=mode) except ValueError: return atoms.get_chemical_formula(mode='hill')
python
def get_chemical_formula(atoms, mode='metal'): """ Compatibility function, return mode=metal, when available, mode=hill, when not (ASE <= 3.13) """ try: return atoms.get_chemical_formula(mode=mode) except ValueError: return atoms.get_chemical_formula(mode='hill')
[ "def", "get_chemical_formula", "(", "atoms", ",", "mode", "=", "'metal'", ")", ":", "try", ":", "return", "atoms", ".", "get_chemical_formula", "(", "mode", "=", "mode", ")", "except", "ValueError", ":", "return", "atoms", ".", "get_chemical_formula", "(", "...
Compatibility function, return mode=metal, when available, mode=hill, when not (ASE <= 3.13)
[ "Compatibility", "function", "return", "mode", "=", "metal", "when", "available", "mode", "=", "hill", "when", "not", "(", "ASE", "<", "=", "3", ".", "13", ")" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/__init__.py#L72-L80
train
Returns the chemical formula for the current language.
SUNCAT-Center/CatHub
cathub/ase_tools/__init__.py
get_energies
def get_energies(atoms_list): """ Potential energy for a list of atoms objects""" if len(atoms_list) == 1: return atoms_list[0].get_potential_energy() elif len(atoms_list) > 1: energies = [] for atoms in atoms_list: energies.append(atoms.get_potential_energy()) re...
python
def get_energies(atoms_list): """ Potential energy for a list of atoms objects""" if len(atoms_list) == 1: return atoms_list[0].get_potential_energy() elif len(atoms_list) > 1: energies = [] for atoms in atoms_list: energies.append(atoms.get_potential_energy()) re...
[ "def", "get_energies", "(", "atoms_list", ")", ":", "if", "len", "(", "atoms_list", ")", "==", "1", ":", "return", "atoms_list", "[", "0", "]", ".", "get_potential_energy", "(", ")", "elif", "len", "(", "atoms_list", ")", ">", "1", ":", "energies", "="...
Potential energy for a list of atoms objects
[ "Potential", "energy", "for", "a", "list", "of", "atoms", "objects" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/__init__.py#L174-L182
train
Returns the potential energy for a list of atoms objects
SUNCAT-Center/CatHub
cathub/ase_tools/__init__.py
check_in_ase
def check_in_ase(atoms, ase_db, energy=None): """Check if entry is allready in ASE db""" db_ase = ase.db.connect(ase_db) if energy is None: energy = atoms.get_potential_energy() formula = get_chemical_formula(atoms) rows = db_ase.select(energy=energy) n = 0 ids = [] for row in r...
python
def check_in_ase(atoms, ase_db, energy=None): """Check if entry is allready in ASE db""" db_ase = ase.db.connect(ase_db) if energy is None: energy = atoms.get_potential_energy() formula = get_chemical_formula(atoms) rows = db_ase.select(energy=energy) n = 0 ids = [] for row in r...
[ "def", "check_in_ase", "(", "atoms", ",", "ase_db", ",", "energy", "=", "None", ")", ":", "db_ase", "=", "ase", ".", "db", ".", "connect", "(", "ase_db", ")", "if", "energy", "is", "None", ":", "energy", "=", "atoms", ".", "get_potential_energy", "(", ...
Check if entry is allready in ASE db
[ "Check", "if", "entry", "is", "allready", "in", "ASE", "db" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/__init__.py#L322-L341
train
Check if entry is allready in ASE db
SUNCAT-Center/CatHub
cathub/ase_tools/__init__.py
write_ase
def write_ase(atoms, db_file, stdout=sys.stdout, user=None, data=None, **key_value_pairs): """Connect to ASE db""" db_ase = ase.db.connect(db_file) _normalize_key_value_pairs_inplace(key_value_pairs) id = db_ase.write(atoms, data=data, **key_value_pairs) stdout.write(' writing atoms to ASE db row i...
python
def write_ase(atoms, db_file, stdout=sys.stdout, user=None, data=None, **key_value_pairs): """Connect to ASE db""" db_ase = ase.db.connect(db_file) _normalize_key_value_pairs_inplace(key_value_pairs) id = db_ase.write(atoms, data=data, **key_value_pairs) stdout.write(' writing atoms to ASE db row i...
[ "def", "write_ase", "(", "atoms", ",", "db_file", ",", "stdout", "=", "sys", ".", "stdout", ",", "user", "=", "None", ",", "data", "=", "None", ",", "*", "*", "key_value_pairs", ")", ":", "db_ase", "=", "ase", ".", "db", ".", "connect", "(", "db_fi...
Connect to ASE db
[ "Connect", "to", "ASE", "db" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/__init__.py#L350-L357
train
Write atoms to ASE db
SUNCAT-Center/CatHub
cathub/ase_tools/__init__.py
update_ase
def update_ase(db_file, identity, stdout, **key_value_pairs): """Connect to ASE db""" db_ase = ase.db.connect(db_file) _normalize_key_value_pairs_inplace(key_value_pairs) count = db_ase.update(identity, **key_value_pairs) stdout.write(' Updating {0} key value pairs in ASE db row id = {1}\n' ...
python
def update_ase(db_file, identity, stdout, **key_value_pairs): """Connect to ASE db""" db_ase = ase.db.connect(db_file) _normalize_key_value_pairs_inplace(key_value_pairs) count = db_ase.update(identity, **key_value_pairs) stdout.write(' Updating {0} key value pairs in ASE db row id = {1}\n' ...
[ "def", "update_ase", "(", "db_file", ",", "identity", ",", "stdout", ",", "*", "*", "key_value_pairs", ")", ":", "db_ase", "=", "ase", ".", "db", ".", "connect", "(", "db_file", ")", "_normalize_key_value_pairs_inplace", "(", "key_value_pairs", ")", "count", ...
Connect to ASE db
[ "Connect", "to", "ASE", "db" ]
324625d1d8e740673f139658b2de4c9e1059739e
https://github.com/SUNCAT-Center/CatHub/blob/324625d1d8e740673f139658b2de4c9e1059739e/cathub/ase_tools/__init__.py#L360-L368
train
Update the ASE database row with the given identity.
pylp/pylp
pylp/lib/tasks.py
task
def task(name, deps = None, fn = None): """Define a new task.""" if callable(deps): fn = deps deps = None if not deps and not fn: logger.log(logger.red("The task '%s' is empty" % name)) else: tasks[name] = [fn, deps]
python
def task(name, deps = None, fn = None): """Define a new task.""" if callable(deps): fn = deps deps = None if not deps and not fn: logger.log(logger.red("The task '%s' is empty" % name)) else: tasks[name] = [fn, deps]
[ "def", "task", "(", "name", ",", "deps", "=", "None", ",", "fn", "=", "None", ")", ":", "if", "callable", "(", "deps", ")", ":", "fn", "=", "deps", "deps", "=", "None", "if", "not", "deps", "and", "not", "fn", ":", "logger", ".", "log", "(", ...
Define a new task.
[ "Define", "a", "new", "task", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/tasks.py#L18-L27
train
Define a new task.
pylp/pylp
pylp/lib/tasks.py
start
def start(name, called = None): """Start a task.""" if name not in tasks: logger.log(logger.red("Task '%s' not in your pylpfile" % name)) else: task = tasks[name] runner = TaskRunner(name, task[0], task[1], called) running.append(runner) return runner
python
def start(name, called = None): """Start a task.""" if name not in tasks: logger.log(logger.red("Task '%s' not in your pylpfile" % name)) else: task = tasks[name] runner = TaskRunner(name, task[0], task[1], called) running.append(runner) return runner
[ "def", "start", "(", "name", ",", "called", "=", "None", ")", ":", "if", "name", "not", "in", "tasks", ":", "logger", ".", "log", "(", "logger", ".", "red", "(", "\"Task '%s' not in your pylpfile\"", "%", "name", ")", ")", "else", ":", "task", "=", "...
Start a task.
[ "Start", "a", "task", "." ]
7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4
https://github.com/pylp/pylp/blob/7ebaa55fbaf61cb8175f211dd41ef2928c22d4d4/pylp/lib/tasks.py#L34-L42
train
Start a task.