repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
sassoftware/epdb
epdb/__init__.py
matchFileOnDirPath
def matchFileOnDirPath(curpath, pathdir): """Find match for a file by slicing away its directory elements from the front and replacing them with pathdir. Assume that the end of curpath is right and but that the beginning may contain some garbage (or it may be short) Overlaps are allowed...
python
def matchFileOnDirPath(curpath, pathdir): """Find match for a file by slicing away its directory elements from the front and replacing them with pathdir. Assume that the end of curpath is right and but that the beginning may contain some garbage (or it may be short) Overlaps are allowed...
[ "def", "matchFileOnDirPath", "(", "curpath", ",", "pathdir", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "curpath", ")", ":", "return", "curpath", "filedirs", "=", "curpath", ".", "split", "(", "'/'", ")", "[", "1", ":", "]", "filename", "...
Find match for a file by slicing away its directory elements from the front and replacing them with pathdir. Assume that the end of curpath is right and but that the beginning may contain some garbage (or it may be short) Overlaps are allowed: e.g /tmp/fdjsklf/real/path/elements, /al...
[ "Find", "match", "for", "a", "file", "by", "slicing", "away", "its", "directory", "elements", "from", "the", "front", "and", "replacing", "them", "with", "pathdir", ".", "Assume", "that", "the", "end", "of", "curpath", "is", "right", "and", "but", "that", ...
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L1094-L1132
train
sassoftware/epdb
epdb/__init__.py
Epdb.lookupmodule
def lookupmodule(self, filename): """Helper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name. """ if os.path.isabs(filename) and os.path.exists(filename): return file...
python
def lookupmodule(self, filename): """Helper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name. """ if os.path.isabs(filename) and os.path.exists(filename): return file...
[ "def", "lookupmodule", "(", "self", ",", "filename", ")", ":", "if", "os", ".", "path", ".", "isabs", "(", "filename", ")", "and", "os", ".", "path", ".", "exists", "(", "filename", ")", ":", "return", "filename", "f", "=", "os", ".", "path", ".", ...
Helper function for break/clear parsing -- may be overridden. lookupmodule() translates (possibly incomplete) file or module name into an absolute file name.
[ "Helper", "function", "for", "break", "/", "clear", "parsing", "--", "may", "be", "overridden", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L359-L386
train
sassoftware/epdb
epdb/__init__.py
Epdb.set_trace_cond
def set_trace_cond(klass, marker='default', cond=None): """ Sets a condition for set_trace statements that have the specified marker. A condition can be either callable, in which case it should take one argument, which is the number of times set_trace(marker) has been called...
python
def set_trace_cond(klass, marker='default', cond=None): """ Sets a condition for set_trace statements that have the specified marker. A condition can be either callable, in which case it should take one argument, which is the number of times set_trace(marker) has been called...
[ "def", "set_trace_cond", "(", "klass", ",", "marker", "=", "'default'", ",", "cond", "=", "None", ")", ":", "tc", "=", "klass", ".", "trace_counts", "tc", "[", "marker", "]", "=", "[", "cond", ",", "0", "]" ]
Sets a condition for set_trace statements that have the specified marker. A condition can be either callable, in which case it should take one argument, which is the number of times set_trace(marker) has been called, or it can be a number, in which case the break will ...
[ "Sets", "a", "condition", "for", "set_trace", "statements", "that", "have", "the", "specified", "marker", ".", "A", "condition", "can", "be", "either", "callable", "in", "which", "case", "it", "should", "take", "one", "argument", "which", "is", "the", "numbe...
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L847-L856
train
sassoftware/epdb
epdb/__init__.py
Epdb._set_trace
def _set_trace(self, skip=0): """Start debugging from here.""" frame = sys._getframe().f_back # go up the specified number of frames for i in range(skip): frame = frame.f_back self.reset() while frame: frame.f_trace = self.trace_dispatch ...
python
def _set_trace(self, skip=0): """Start debugging from here.""" frame = sys._getframe().f_back # go up the specified number of frames for i in range(skip): frame = frame.f_back self.reset() while frame: frame.f_trace = self.trace_dispatch ...
[ "def", "_set_trace", "(", "self", ",", "skip", "=", "0", ")", ":", "frame", "=", "sys", ".", "_getframe", "(", ")", ".", "f_back", "# go up the specified number of frames", "for", "i", "in", "range", "(", "skip", ")", ":", "frame", "=", "frame", ".", "...
Start debugging from here.
[ "Start", "debugging", "from", "here", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L897-L909
train
sassoftware/epdb
epdb/__init__.py
Epdb.user_call
def user_call(self, frame, argument_list): """This method is called when there is the remote possibility that we ever need to stop in this function.""" if self.stop_here(frame): pdb.Pdb.user_call(self, frame, argument_list)
python
def user_call(self, frame, argument_list): """This method is called when there is the remote possibility that we ever need to stop in this function.""" if self.stop_here(frame): pdb.Pdb.user_call(self, frame, argument_list)
[ "def", "user_call", "(", "self", ",", "frame", ",", "argument_list", ")", ":", "if", "self", ".", "stop_here", "(", "frame", ")", ":", "pdb", ".", "Pdb", ".", "user_call", "(", "self", ",", "frame", ",", "argument_list", ")" ]
This method is called when there is the remote possibility that we ever need to stop in this function.
[ "This", "method", "is", "called", "when", "there", "is", "the", "remote", "possibility", "that", "we", "ever", "need", "to", "stop", "in", "this", "function", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L912-L916
train
sassoftware/epdb
epdb/__init__.py
Epdb.user_return
def user_return(self, frame, return_value): """This function is called when a return trap is set here.""" pdb.Pdb.user_return(self, frame, return_value)
python
def user_return(self, frame, return_value): """This function is called when a return trap is set here.""" pdb.Pdb.user_return(self, frame, return_value)
[ "def", "user_return", "(", "self", ",", "frame", ",", "return_value", ")", ":", "pdb", ".", "Pdb", ".", "user_return", "(", "self", ",", "frame", ",", "return_value", ")" ]
This function is called when a return trap is set here.
[ "This", "function", "is", "called", "when", "a", "return", "trap", "is", "set", "here", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L922-L924
train
sassoftware/epdb
epdb/__init__.py
Epdb.user_exception
def user_exception(self, frame, exc_info): """This function is called if an exception occurs, but only if we are to stop at or just below this level.""" pdb.Pdb.user_exception(self, frame, exc_info)
python
def user_exception(self, frame, exc_info): """This function is called if an exception occurs, but only if we are to stop at or just below this level.""" pdb.Pdb.user_exception(self, frame, exc_info)
[ "def", "user_exception", "(", "self", ",", "frame", ",", "exc_info", ")", ":", "pdb", ".", "Pdb", ".", "user_exception", "(", "self", ",", "frame", ",", "exc_info", ")" ]
This function is called if an exception occurs, but only if we are to stop at or just below this level.
[ "This", "function", "is", "called", "if", "an", "exception", "occurs", "but", "only", "if", "we", "are", "to", "stop", "at", "or", "just", "below", "this", "level", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L926-L929
train
sassoftware/epdb
epdb/formattrace.py
stackToList
def stackToList(stack): """ Convert a chain of traceback or frame objects into a list of frames. """ if isinstance(stack, types.TracebackType): while stack.tb_next: stack = stack.tb_next stack = stack.tb_frame out = [] while stack: out.append(stack) st...
python
def stackToList(stack): """ Convert a chain of traceback or frame objects into a list of frames. """ if isinstance(stack, types.TracebackType): while stack.tb_next: stack = stack.tb_next stack = stack.tb_frame out = [] while stack: out.append(stack) st...
[ "def", "stackToList", "(", "stack", ")", ":", "if", "isinstance", "(", "stack", ",", "types", ".", "TracebackType", ")", ":", "while", "stack", ".", "tb_next", ":", "stack", "=", "stack", ".", "tb_next", "stack", "=", "stack", ".", "tb_frame", "out", "...
Convert a chain of traceback or frame objects into a list of frames.
[ "Convert", "a", "chain", "of", "traceback", "or", "frame", "objects", "into", "a", "list", "of", "frames", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/formattrace.py#L211-L223
train
sassoftware/epdb
epdb/epdb_server.py
TelnetServerProtocolHandler.process_IAC
def process_IAC(self, sock, cmd, option): """ Read in and parse IAC commands as passed by telnetlib. SB/SE commands are stored in sbdataq, and passed in w/ a command of SE. """ if cmd == DO: if option == TM: # timing mark - send WI...
python
def process_IAC(self, sock, cmd, option): """ Read in and parse IAC commands as passed by telnetlib. SB/SE commands are stored in sbdataq, and passed in w/ a command of SE. """ if cmd == DO: if option == TM: # timing mark - send WI...
[ "def", "process_IAC", "(", "self", ",", "sock", ",", "cmd", ",", "option", ")", ":", "if", "cmd", "==", "DO", ":", "if", "option", "==", "TM", ":", "# timing mark - send WILL into outgoing stream", "os", ".", "write", "(", "self", ".", "remote", ",", "IA...
Read in and parse IAC commands as passed by telnetlib. SB/SE commands are stored in sbdataq, and passed in w/ a command of SE.
[ "Read", "in", "and", "parse", "IAC", "commands", "as", "passed", "by", "telnetlib", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L73-L102
train
sassoftware/epdb
epdb/epdb_server.py
TelnetServerProtocolHandler.handle
def handle(self): """ Performs endless processing of socket input/output, passing cooked information onto the local process. """ while True: toRead = select.select([self.local, self.remote], [], [], 0.1)[0] if self.local in toRead: ...
python
def handle(self): """ Performs endless processing of socket input/output, passing cooked information onto the local process. """ while True: toRead = select.select([self.local, self.remote], [], [], 0.1)[0] if self.local in toRead: ...
[ "def", "handle", "(", "self", ")", ":", "while", "True", ":", "toRead", "=", "select", ".", "select", "(", "[", "self", ".", "local", ",", "self", ".", "remote", "]", ",", "[", "]", ",", "[", "]", ",", "0.1", ")", "[", "0", "]", "if", "self",...
Performs endless processing of socket input/output, passing cooked information onto the local process.
[ "Performs", "endless", "processing", "of", "socket", "input", "/", "output", "passing", "cooked", "information", "onto", "the", "local", "process", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L104-L118
train
sassoftware/epdb
epdb/epdb_server.py
TelnetRequestHandler.handle
def handle(self): """ Creates a child process that is fully controlled by this request handler, and serves data to and from it via the protocol handler. """ pid, fd = pty.fork() if pid: protocol = TelnetServerProtocolHandler(self.request, f...
python
def handle(self): """ Creates a child process that is fully controlled by this request handler, and serves data to and from it via the protocol handler. """ pid, fd = pty.fork() if pid: protocol = TelnetServerProtocolHandler(self.request, f...
[ "def", "handle", "(", "self", ")", ":", "pid", ",", "fd", "=", "pty", ".", "fork", "(", ")", "if", "pid", ":", "protocol", "=", "TelnetServerProtocolHandler", "(", "self", ".", "request", ",", "fd", ")", "protocol", ".", "handle", "(", ")", "else", ...
Creates a child process that is fully controlled by this request handler, and serves data to and from it via the protocol handler.
[ "Creates", "a", "child", "process", "that", "is", "fully", "controlled", "by", "this", "request", "handler", "and", "serves", "data", "to", "and", "from", "it", "via", "the", "protocol", "handler", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L133-L144
train
sassoftware/epdb
epdb/epdb_server.py
InvertedTelnetServer.handle_request
def handle_request(self): """ Handle one request - serve current process to one connection. Use close_request() to disconnect this process. """ try: request, client_address = self.get_request() except socket.error: return if self.v...
python
def handle_request(self): """ Handle one request - serve current process to one connection. Use close_request() to disconnect this process. """ try: request, client_address = self.get_request() except socket.error: return if self.v...
[ "def", "handle_request", "(", "self", ")", ":", "try", ":", "request", ",", "client_address", "=", "self", ".", "get_request", "(", ")", "except", "socket", ".", "error", ":", "return", "if", "self", ".", "verify_request", "(", "request", ",", "client_addr...
Handle one request - serve current process to one connection. Use close_request() to disconnect this process.
[ "Handle", "one", "request", "-", "serve", "current", "process", "to", "one", "connection", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L221-L242
train
sassoftware/epdb
epdb/epdb_server.py
InvertedTelnetServer._serve_process
def _serve_process(self, slaveFd, serverPid): """ Serves a process by connecting its outputs/inputs to the pty slaveFd. serverPid is the process controlling the master fd that passes that output over the socket. """ self.serverPid = serverPid if sys.s...
python
def _serve_process(self, slaveFd, serverPid): """ Serves a process by connecting its outputs/inputs to the pty slaveFd. serverPid is the process controlling the master fd that passes that output over the socket. """ self.serverPid = serverPid if sys.s...
[ "def", "_serve_process", "(", "self", ",", "slaveFd", ",", "serverPid", ")", ":", "self", ".", "serverPid", "=", "serverPid", "if", "sys", ".", "stdin", ".", "isatty", "(", ")", ":", "self", ".", "oldTermios", "=", "termios", ".", "tcgetattr", "(", "sy...
Serves a process by connecting its outputs/inputs to the pty slaveFd. serverPid is the process controlling the master fd that passes that output over the socket.
[ "Serves", "a", "process", "by", "connecting", "its", "outputs", "/", "inputs", "to", "the", "pty", "slaveFd", ".", "serverPid", "is", "the", "process", "controlling", "the", "master", "fd", "that", "passes", "that", "output", "over", "the", "socket", "." ]
5a8375aa59862d787e6496810a508297a5522967
https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L244-L262
train
matthew-sochor/transfer
transfer/input.py
int_input
def int_input(message, low, high, show_range = True): ''' Ask a user for a int input between two values args: message (str): Prompt for user low (int): Low value, user entered value must be > this value to be accepted high (int): High value, user entered value must be < this value t...
python
def int_input(message, low, high, show_range = True): ''' Ask a user for a int input between two values args: message (str): Prompt for user low (int): Low value, user entered value must be > this value to be accepted high (int): High value, user entered value must be < this value t...
[ "def", "int_input", "(", "message", ",", "low", ",", "high", ",", "show_range", "=", "True", ")", ":", "int_in", "=", "low", "-", "1", "while", "(", "int_in", "<", "low", ")", "or", "(", "int_in", ">", "high", ")", ":", "if", "show_range", ":", "...
Ask a user for a int input between two values args: message (str): Prompt for user low (int): Low value, user entered value must be > this value to be accepted high (int): High value, user entered value must be < this value to be accepted show_range (boolean, Default True): Print hi...
[ "Ask", "a", "user", "for", "a", "int", "input", "between", "two", "values" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L7-L32
train
matthew-sochor/transfer
transfer/input.py
float_input
def float_input(message, low, high): ''' Ask a user for a float input between two values args: message (str): Prompt for user low (float): Low value, user entered value must be > this value to be accepted high (float): High value, user entered value must be < this value to be accept...
python
def float_input(message, low, high): ''' Ask a user for a float input between two values args: message (str): Prompt for user low (float): Low value, user entered value must be > this value to be accepted high (float): High value, user entered value must be < this value to be accept...
[ "def", "float_input", "(", "message", ",", "low", ",", "high", ")", ":", "float_in", "=", "low", "-", "1.0", "while", "(", "float_in", "<", "low", ")", "or", "(", "float_in", ">", "high", ")", ":", "inp", "=", "input", "(", "'Enter a '", "+", "mess...
Ask a user for a float input between two values args: message (str): Prompt for user low (float): Low value, user entered value must be > this value to be accepted high (float): High value, user entered value must be < this value to be accepted returns: float_in (int): Input fl...
[ "Ask", "a", "user", "for", "a", "float", "input", "between", "two", "values" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L35-L55
train
matthew-sochor/transfer
transfer/input.py
bool_input
def bool_input(message): ''' Ask a user for a boolean input args: message (str): Prompt for user returns: bool_in (boolean): Input boolean ''' while True: suffix = ' (true or false): ' inp = input(message + suffix) if inp.lower() == 'true': ...
python
def bool_input(message): ''' Ask a user for a boolean input args: message (str): Prompt for user returns: bool_in (boolean): Input boolean ''' while True: suffix = ' (true or false): ' inp = input(message + suffix) if inp.lower() == 'true': ...
[ "def", "bool_input", "(", "message", ")", ":", "while", "True", ":", "suffix", "=", "' (true or false): '", "inp", "=", "input", "(", "message", "+", "suffix", ")", "if", "inp", ".", "lower", "(", ")", "==", "'true'", ":", "return", "True", "elif", "in...
Ask a user for a boolean input args: message (str): Prompt for user returns: bool_in (boolean): Input boolean
[ "Ask", "a", "user", "for", "a", "boolean", "input" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L57-L76
train
matthew-sochor/transfer
transfer/__main__.py
main
def main(args = None): ''' Main entry point for transfer command line tool. This essentially will marshall the user to the functions they need. ''' parser = argparse.ArgumentParser(description = 'Tool to perform transfer learning') parser.add_argument('-c','--configure', ...
python
def main(args = None): ''' Main entry point for transfer command line tool. This essentially will marshall the user to the functions they need. ''' parser = argparse.ArgumentParser(description = 'Tool to perform transfer learning') parser.add_argument('-c','--configure', ...
[ "def", "main", "(", "args", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Tool to perform transfer learning'", ")", "parser", ".", "add_argument", "(", "'-c'", ",", "'--configure'", ",", "action", "=", "'st...
Main entry point for transfer command line tool. This essentially will marshall the user to the functions they need.
[ "Main", "entry", "point", "for", "transfer", "command", "line", "tool", "." ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/__main__.py#L36-L181
train
matthew-sochor/transfer
transfer/project.py
configure
def configure(): ''' Configure the transfer environment and store ''' completer = Completer() readline.set_completer_delims('\t') readline.parse_and_bind('tab: complete') readline.set_completer(completer.path_completer) home = os.path.expanduser('~') if os.path.isfile(os.path.join(h...
python
def configure(): ''' Configure the transfer environment and store ''' completer = Completer() readline.set_completer_delims('\t') readline.parse_and_bind('tab: complete') readline.set_completer(completer.path_completer) home = os.path.expanduser('~') if os.path.isfile(os.path.join(h...
[ "def", "configure", "(", ")", ":", "completer", "=", "Completer", "(", ")", "readline", ".", "set_completer_delims", "(", "'\\t'", ")", "readline", ".", "parse_and_bind", "(", "'tab: complete'", ")", "readline", ".", "set_completer", "(", "completer", ".", "pa...
Configure the transfer environment and store
[ "Configure", "the", "transfer", "environment", "and", "store" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L20-L143
train
matthew-sochor/transfer
transfer/project.py
configure_server
def configure_server(): ''' Configure the transfer environment and store ''' home = os.path.expanduser('~') if os.path.isfile(os.path.join(home, '.transfer', 'config.yaml')): with open(os.path.join(home, '.transfer', 'config.yaml'), 'r') as fp: config = yaml.load(fp.read()) ...
python
def configure_server(): ''' Configure the transfer environment and store ''' home = os.path.expanduser('~') if os.path.isfile(os.path.join(home, '.transfer', 'config.yaml')): with open(os.path.join(home, '.transfer', 'config.yaml'), 'r') as fp: config = yaml.load(fp.read()) ...
[ "def", "configure_server", "(", ")", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "home", ",", "'.transfer'", ",", "'config.yaml'", ")", "...
Configure the transfer environment and store
[ "Configure", "the", "transfer", "environment", "and", "store" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L146-L208
train
matthew-sochor/transfer
transfer/project.py
select_project
def select_project(user_provided_project): ''' Select a project from configuration to run transfer on args: user_provided_project (str): Project name that should match a project in the config returns: project (dict): Configuration settings for a user selected project ''' home...
python
def select_project(user_provided_project): ''' Select a project from configuration to run transfer on args: user_provided_project (str): Project name that should match a project in the config returns: project (dict): Configuration settings for a user selected project ''' home...
[ "def", "select_project", "(", "user_provided_project", ")", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "home", ",", "'.transfer'", ",", "'...
Select a project from configuration to run transfer on args: user_provided_project (str): Project name that should match a project in the config returns: project (dict): Configuration settings for a user selected project
[ "Select", "a", "project", "from", "configuration", "to", "run", "transfer", "on" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L262-L299
train
matthew-sochor/transfer
transfer/project.py
store_config
def store_config(config, suffix = None): ''' Store configuration args: config (list[dict]): configurations for each project ''' home = os.path.expanduser('~') if suffix is not None: config_path = os.path.join(home, '.transfer', suffix) else: config_path = os.path.joi...
python
def store_config(config, suffix = None): ''' Store configuration args: config (list[dict]): configurations for each project ''' home = os.path.expanduser('~') if suffix is not None: config_path = os.path.join(home, '.transfer', suffix) else: config_path = os.path.joi...
[ "def", "store_config", "(", "config", ",", "suffix", "=", "None", ")", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "if", "suffix", "is", "not", "None", ":", "config_path", "=", "os", ".", "path", ".", "join", "(", "home...
Store configuration args: config (list[dict]): configurations for each project
[ "Store", "configuration" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L492-L507
train
matthew-sochor/transfer
transfer/project.py
update_config
def update_config(updated_project): ''' Update project in configuration args: updated_project (dict): Updated project configuration values ''' home = os.path.expanduser('~') if os.path.isfile(os.path.join(home, '.transfer', 'config.yaml')): with open(os.path.join(home, '.trans...
python
def update_config(updated_project): ''' Update project in configuration args: updated_project (dict): Updated project configuration values ''' home = os.path.expanduser('~') if os.path.isfile(os.path.join(home, '.transfer', 'config.yaml')): with open(os.path.join(home, '.trans...
[ "def", "update_config", "(", "updated_project", ")", ":", "home", "=", "os", ".", "path", ".", "expanduser", "(", "'~'", ")", "if", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "home", ",", "'.transfer'", ",", "'config....
Update project in configuration args: updated_project (dict): Updated project configuration values
[ "Update", "project", "in", "configuration" ]
c1931a16459275faa7a5e9860fbed079a4848b80
https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L510-L540
train
molmod/molmod
molmod/molecular_graphs.py
atom_criteria
def atom_criteria(*params): """An auxiliary function to construct a dictionary of Criteria""" result = {} for index, param in enumerate(params): if param is None: continue elif isinstance(param, int): result[index] = HasAtomNumber(param) else: resu...
python
def atom_criteria(*params): """An auxiliary function to construct a dictionary of Criteria""" result = {} for index, param in enumerate(params): if param is None: continue elif isinstance(param, int): result[index] = HasAtomNumber(param) else: resu...
[ "def", "atom_criteria", "(", "*", "params", ")", ":", "result", "=", "{", "}", "for", "index", ",", "param", "in", "enumerate", "(", "params", ")", ":", "if", "param", "is", "None", ":", "continue", "elif", "isinstance", "(", "param", ",", "int", ")"...
An auxiliary function to construct a dictionary of Criteria
[ "An", "auxiliary", "function", "to", "construct", "a", "dictionary", "of", "Criteria" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L487-L497
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph._check_symbols
def _check_symbols(self, symbols): """the size must be the same as the length of the array numbers and all elements must be strings""" if len(symbols) != self.size: raise TypeError("The number of symbols in the graph does not " "match the length of the atomic numbers array.")...
python
def _check_symbols(self, symbols): """the size must be the same as the length of the array numbers and all elements must be strings""" if len(symbols) != self.size: raise TypeError("The number of symbols in the graph does not " "match the length of the atomic numbers array.")...
[ "def", "_check_symbols", "(", "self", ",", "symbols", ")", ":", "if", "len", "(", "symbols", ")", "!=", "self", ".", "size", ":", "raise", "TypeError", "(", "\"The number of symbols in the graph does not \"", "\"match the length of the atomic numbers array.\"", ")", "...
the size must be the same as the length of the array numbers and all elements must be strings
[ "the", "size", "must", "be", "the", "same", "as", "the", "length", "of", "the", "array", "numbers", "and", "all", "elements", "must", "be", "strings" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L66-L73
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.from_geometry
def from_geometry(cls, molecule, do_orders=False, scaling=1.0): """Construct a MolecularGraph object based on interatomic distances All short distances are computed with the binning module and compared with a database of bond lengths. Based on this comparison, bonded atoms are ...
python
def from_geometry(cls, molecule, do_orders=False, scaling=1.0): """Construct a MolecularGraph object based on interatomic distances All short distances are computed with the binning module and compared with a database of bond lengths. Based on this comparison, bonded atoms are ...
[ "def", "from_geometry", "(", "cls", ",", "molecule", ",", "do_orders", "=", "False", ",", "scaling", "=", "1.0", ")", ":", "from", "molmod", ".", "bonds", "import", "bonds", "unit_cell", "=", "molecule", ".", "unit_cell", "pair_search", "=", "PairSearchIntra...
Construct a MolecularGraph object based on interatomic distances All short distances are computed with the binning module and compared with a database of bond lengths. Based on this comparison, bonded atoms are detected. Before marking a pair of atoms A and B as bonded, it ...
[ "Construct", "a", "MolecularGraph", "object", "based", "on", "interatomic", "distances" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L85-L176
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.from_blob
def from_blob(cls, s): """Construct a molecular graph from the blob representation""" atom_str, edge_str = s.split() numbers = np.array([int(s) for s in atom_str.split(",")]) edges = [] orders = [] for s in edge_str.split(","): i, j, o = (int(w) for w in s.spl...
python
def from_blob(cls, s): """Construct a molecular graph from the blob representation""" atom_str, edge_str = s.split() numbers = np.array([int(s) for s in atom_str.split(",")]) edges = [] orders = [] for s in edge_str.split(","): i, j, o = (int(w) for w in s.spl...
[ "def", "from_blob", "(", "cls", ",", "s", ")", ":", "atom_str", ",", "edge_str", "=", "s", ".", "split", "(", ")", "numbers", "=", "np", ".", "array", "(", "[", "int", "(", "s", ")", "for", "s", "in", "atom_str", ".", "split", "(", "\",\"", ")"...
Construct a molecular graph from the blob representation
[ "Construct", "a", "molecular", "graph", "from", "the", "blob", "representation" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L179-L189
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.blob
def blob(self): """A compact text representation of the graph""" atom_str = ",".join(str(number) for number in self.numbers) edge_str = ",".join("%i_%i_%i" % (i, j, o) for (i, j), o in zip(self.edges, self.orders)) return "%s %s" % (atom_str, edge_str)
python
def blob(self): """A compact text representation of the graph""" atom_str = ",".join(str(number) for number in self.numbers) edge_str = ",".join("%i_%i_%i" % (i, j, o) for (i, j), o in zip(self.edges, self.orders)) return "%s %s" % (atom_str, edge_str)
[ "def", "blob", "(", "self", ")", ":", "atom_str", "=", "\",\"", ".", "join", "(", "str", "(", "number", ")", "for", "number", "in", "self", ".", "numbers", ")", "edge_str", "=", "\",\"", ".", "join", "(", "\"%i_%i_%i\"", "%", "(", "i", ",", "j", ...
A compact text representation of the graph
[ "A", "compact", "text", "representation", "of", "the", "graph" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L251-L255
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.get_vertex_string
def get_vertex_string(self, i): """Return a string based on the atom number""" number = self.numbers[i] if number == 0: return Graph.get_vertex_string(self, i) else: # pad with zeros to make sure that string sort is identical to number sort return "%03...
python
def get_vertex_string(self, i): """Return a string based on the atom number""" number = self.numbers[i] if number == 0: return Graph.get_vertex_string(self, i) else: # pad with zeros to make sure that string sort is identical to number sort return "%03...
[ "def", "get_vertex_string", "(", "self", ",", "i", ")", ":", "number", "=", "self", ".", "numbers", "[", "i", "]", "if", "number", "==", "0", ":", "return", "Graph", ".", "get_vertex_string", "(", "self", ",", "i", ")", "else", ":", "# pad with zeros t...
Return a string based on the atom number
[ "Return", "a", "string", "based", "on", "the", "atom", "number" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L257-L264
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.get_edge_string
def get_edge_string(self, i): """Return a string based on the bond order""" order = self.orders[i] if order == 0: return Graph.get_edge_string(self, i) else: # pad with zeros to make sure that string sort is identical to number sort return "%03i" % ord...
python
def get_edge_string(self, i): """Return a string based on the bond order""" order = self.orders[i] if order == 0: return Graph.get_edge_string(self, i) else: # pad with zeros to make sure that string sort is identical to number sort return "%03i" % ord...
[ "def", "get_edge_string", "(", "self", ",", "i", ")", ":", "order", "=", "self", ".", "orders", "[", "i", "]", "if", "order", "==", "0", ":", "return", "Graph", ".", "get_edge_string", "(", "self", ",", "i", ")", "else", ":", "# pad with zeros to make ...
Return a string based on the bond order
[ "Return", "a", "string", "based", "on", "the", "bond", "order" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L266-L273
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.get_subgraph
def get_subgraph(self, subvertices, normalize=False): """Creates a subgraph of the current graph See :meth:`molmod.graphs.Graph.get_subgraph` for more information. """ graph = Graph.get_subgraph(self, subvertices, normalize) if normalize: new_numbers = self.number...
python
def get_subgraph(self, subvertices, normalize=False): """Creates a subgraph of the current graph See :meth:`molmod.graphs.Graph.get_subgraph` for more information. """ graph = Graph.get_subgraph(self, subvertices, normalize) if normalize: new_numbers = self.number...
[ "def", "get_subgraph", "(", "self", ",", "subvertices", ",", "normalize", "=", "False", ")", ":", "graph", "=", "Graph", ".", "get_subgraph", "(", "self", ",", "subvertices", ",", "normalize", ")", "if", "normalize", ":", "new_numbers", "=", "self", ".", ...
Creates a subgraph of the current graph See :meth:`molmod.graphs.Graph.get_subgraph` for more information.
[ "Creates", "a", "subgraph", "of", "the", "current", "graph" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L275-L296
train
molmod/molmod
molmod/molecular_graphs.py
MolecularGraph.add_hydrogens
def add_hydrogens(self, formal_charges=None): """Returns a molecular graph where hydrogens are added explicitely When the bond order is unknown, it assumes bond order one. If the graph has an attribute formal_charges, this routine will take it into account when counting the nu...
python
def add_hydrogens(self, formal_charges=None): """Returns a molecular graph where hydrogens are added explicitely When the bond order is unknown, it assumes bond order one. If the graph has an attribute formal_charges, this routine will take it into account when counting the nu...
[ "def", "add_hydrogens", "(", "self", ",", "formal_charges", "=", "None", ")", ":", "new_edges", "=", "list", "(", "self", ".", "edges", ")", "counter", "=", "self", ".", "num_vertices", "for", "i", "in", "range", "(", "self", ".", "num_vertices", ")", ...
Returns a molecular graph where hydrogens are added explicitely When the bond order is unknown, it assumes bond order one. If the graph has an attribute formal_charges, this routine will take it into account when counting the number of hydrogens to be added. The returned gr...
[ "Returns", "a", "molecular", "graph", "where", "hydrogens", "are", "added", "explicitely" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L298-L341
train
molmod/molmod
molmod/molecular_graphs.py
NRingPattern.check_next_match
def check_next_match(self, match, new_relations, subject_graph, one_match): """Check if the (onset for a) match can be a valid (part of a) ring""" if not CustomPattern.check_next_match(self, match, new_relations, subject_graph, one_match): return False if self.strong: # c...
python
def check_next_match(self, match, new_relations, subject_graph, one_match): """Check if the (onset for a) match can be a valid (part of a) ring""" if not CustomPattern.check_next_match(self, match, new_relations, subject_graph, one_match): return False if self.strong: # c...
[ "def", "check_next_match", "(", "self", ",", "match", ",", "new_relations", ",", "subject_graph", ",", "one_match", ")", ":", "if", "not", "CustomPattern", ".", "check_next_match", "(", "self", ",", "match", ",", "new_relations", ",", "subject_graph", ",", "on...
Check if the (onset for a) match can be a valid (part of a) ring
[ "Check", "if", "the", "(", "onset", "for", "a", ")", "match", "can", "be", "a", "valid", "(", "part", "of", "a", ")", "ring" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L578-L603
train
molmod/molmod
molmod/molecular_graphs.py
NRingPattern.complete
def complete(self, match, subject_graph): """Check the completeness of the ring match""" if not CustomPattern.complete(self, match, subject_graph): return False if self.strong: # If the ring is not strong, return False if self.size % 2 == 0: # ...
python
def complete(self, match, subject_graph): """Check the completeness of the ring match""" if not CustomPattern.complete(self, match, subject_graph): return False if self.strong: # If the ring is not strong, return False if self.size % 2 == 0: # ...
[ "def", "complete", "(", "self", ",", "match", ",", "subject_graph", ")", ":", "if", "not", "CustomPattern", ".", "complete", "(", "self", ",", "match", ",", "subject_graph", ")", ":", "return", "False", "if", "self", ".", "strong", ":", "# If the ring is n...
Check the completeness of the ring match
[ "Check", "the", "completeness", "of", "the", "ring", "match" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L605-L640
train
molmod/molmod
molmod/io/number_state.py
ScalarAttr.get_kind
def get_kind(self, value): """Return the kind (type) of the attribute""" if isinstance(value, float): return 'f' elif isinstance(value, int): return 'i' else: raise ValueError("Only integer or floating point values can be stored.")
python
def get_kind(self, value): """Return the kind (type) of the attribute""" if isinstance(value, float): return 'f' elif isinstance(value, int): return 'i' else: raise ValueError("Only integer or floating point values can be stored.")
[ "def", "get_kind", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "float", ")", ":", "return", "'f'", "elif", "isinstance", "(", "value", ",", "int", ")", ":", "return", "'i'", "else", ":", "raise", "ValueError", "(", "\"...
Return the kind (type) of the attribute
[ "Return", "the", "kind", "(", "type", ")", "of", "the", "attribute" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L68-L75
train
molmod/molmod
molmod/io/number_state.py
ScalarAttr.dump
def dump(self, f, name): """Write the attribute to a file-like object""" # print the header line value = self.get() kind = self.get_kind(value) print("% 40s kind=%s value=%s" % (name, kind, value), file=f)
python
def dump(self, f, name): """Write the attribute to a file-like object""" # print the header line value = self.get() kind = self.get_kind(value) print("% 40s kind=%s value=%s" % (name, kind, value), file=f)
[ "def", "dump", "(", "self", ",", "f", ",", "name", ")", ":", "# print the header line", "value", "=", "self", ".", "get", "(", ")", "kind", "=", "self", ".", "get_kind", "(", "value", ")", "print", "(", "\"% 40s kind=%s value=%s\"", "%", "(", "name", ...
Write the attribute to a file-like object
[ "Write", "the", "attribute", "to", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L81-L86
train
molmod/molmod
molmod/io/number_state.py
ArrayAttr.get
def get(self, copy=False): """Return the value of the attribute""" array = getattr(self.owner, self.name) if copy: return array.copy() else: return array
python
def get(self, copy=False): """Return the value of the attribute""" array = getattr(self.owner, self.name) if copy: return array.copy() else: return array
[ "def", "get", "(", "self", ",", "copy", "=", "False", ")", ":", "array", "=", "getattr", "(", "self", ".", "owner", ",", "self", ".", "name", ")", "if", "copy", ":", "return", "array", ".", "copy", "(", ")", "else", ":", "return", "array" ]
Return the value of the attribute
[ "Return", "the", "value", "of", "the", "attribute" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L103-L109
train
molmod/molmod
molmod/io/number_state.py
ArrayAttr.dump
def dump(self, f, name): """Write the attribute to a file-like object""" array = self.get() # print the header line print("% 40s kind=%s shape=(%s)" % ( name, array.dtype.kind, ",".join([str(int(size_axis)) for size_axis in array.shape]), ), ...
python
def dump(self, f, name): """Write the attribute to a file-like object""" array = self.get() # print the header line print("% 40s kind=%s shape=(%s)" % ( name, array.dtype.kind, ",".join([str(int(size_axis)) for size_axis in array.shape]), ), ...
[ "def", "dump", "(", "self", ",", "f", ",", "name", ")", ":", "array", "=", "self", ".", "get", "(", ")", "# print the header line", "print", "(", "\"% 40s kind=%s shape=(%s)\"", "%", "(", "name", ",", "array", ".", "dtype", ".", "kind", ",", "\",\"", ...
Write the attribute to a file-like object
[ "Write", "the", "attribute", "to", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L120-L137
train
molmod/molmod
molmod/io/number_state.py
ArrayAttr.load
def load(self, f, skip): """Load the array data from a file-like object""" array = self.get() counter = 0 counter_limit = array.size convert = array.dtype.type while counter < counter_limit: line = f.readline() words = line.split() for ...
python
def load(self, f, skip): """Load the array data from a file-like object""" array = self.get() counter = 0 counter_limit = array.size convert = array.dtype.type while counter < counter_limit: line = f.readline() words = line.split() for ...
[ "def", "load", "(", "self", ",", "f", ",", "skip", ")", ":", "array", "=", "self", ".", "get", "(", ")", "counter", "=", "0", "counter_limit", "=", "array", ".", "size", "convert", "=", "array", ".", "dtype", ".", "type", "while", "counter", "<", ...
Load the array data from a file-like object
[ "Load", "the", "array", "data", "from", "a", "file", "-", "like", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L139-L153
train
molmod/molmod
molmod/io/number_state.py
NumberState._register
def _register(self, name, AttrCls): """Register a new attribute to take care of with dump and load Arguments: | ``name`` -- the name to be used in the dump file | ``AttrCls`` -- an attr class describing the attribute """ if not issubclass(AttrCls, StateAtt...
python
def _register(self, name, AttrCls): """Register a new attribute to take care of with dump and load Arguments: | ``name`` -- the name to be used in the dump file | ``AttrCls`` -- an attr class describing the attribute """ if not issubclass(AttrCls, StateAtt...
[ "def", "_register", "(", "self", ",", "name", ",", "AttrCls", ")", ":", "if", "not", "issubclass", "(", "AttrCls", ",", "StateAttr", ")", ":", "raise", "TypeError", "(", "\"The second argument must a StateAttr instance.\"", ")", "if", "len", "(", "name", ")", ...
Register a new attribute to take care of with dump and load Arguments: | ``name`` -- the name to be used in the dump file | ``AttrCls`` -- an attr class describing the attribute
[ "Register", "a", "new", "attribute", "to", "take", "care", "of", "with", "dump", "and", "load" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L198-L209
train
molmod/molmod
molmod/io/number_state.py
NumberState.get
def get(self, subset=None): """Return a dictionary object with the registered fields and their values Optional rgument: | ``subset`` -- a list of names to restrict the number of fields in the result """ if subset is None: return...
python
def get(self, subset=None): """Return a dictionary object with the registered fields and their values Optional rgument: | ``subset`` -- a list of names to restrict the number of fields in the result """ if subset is None: return...
[ "def", "get", "(", "self", ",", "subset", "=", "None", ")", ":", "if", "subset", "is", "None", ":", "return", "dict", "(", "(", "name", ",", "attr", ".", "get", "(", "copy", "=", "True", ")", ")", "for", "name", ",", "attr", "in", "self", ".", ...
Return a dictionary object with the registered fields and their values Optional rgument: | ``subset`` -- a list of names to restrict the number of fields in the result
[ "Return", "a", "dictionary", "object", "with", "the", "registered", "fields", "and", "their", "values" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L211-L221
train
molmod/molmod
molmod/io/number_state.py
NumberState.set
def set(self, new_fields, subset=None): """Assign the registered fields based on a dictionary Argument: | ``new_fields`` -- the dictionary with the data to be assigned to the attributes Optional argument: | ``subset`` -- a lis...
python
def set(self, new_fields, subset=None): """Assign the registered fields based on a dictionary Argument: | ``new_fields`` -- the dictionary with the data to be assigned to the attributes Optional argument: | ``subset`` -- a lis...
[ "def", "set", "(", "self", ",", "new_fields", ",", "subset", "=", "None", ")", ":", "for", "name", "in", "new_fields", ":", "if", "name", "not", "in", "self", ".", "_fields", "and", "(", "subset", "is", "None", "or", "name", "in", "subset", ")", ":...
Assign the registered fields based on a dictionary Argument: | ``new_fields`` -- the dictionary with the data to be assigned to the attributes Optional argument: | ``subset`` -- a list of names to restrict the fields that are ...
[ "Assign", "the", "registered", "fields", "based", "on", "a", "dictionary" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L223-L248
train
molmod/molmod
molmod/io/number_state.py
NumberState.dump
def dump(self, filename): """Dump the registered fields to a file Argument: | ``filename`` -- the file to write to """ with open(filename, "w") as f: for name in sorted(self._fields): self._fields[name].dump(f, name)
python
def dump(self, filename): """Dump the registered fields to a file Argument: | ``filename`` -- the file to write to """ with open(filename, "w") as f: for name in sorted(self._fields): self._fields[name].dump(f, name)
[ "def", "dump", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "\"w\"", ")", "as", "f", ":", "for", "name", "in", "sorted", "(", "self", ".", "_fields", ")", ":", "self", ".", "_fields", "[", "name", "]", ".", "dump"...
Dump the registered fields to a file Argument: | ``filename`` -- the file to write to
[ "Dump", "the", "registered", "fields", "to", "a", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L250-L258
train
molmod/molmod
molmod/io/number_state.py
NumberState.load
def load(self, filename, subset=None): """Load data into the registered fields Argument: | ``filename`` -- the filename to read from Optional argument: | ``subset`` -- a list of field names that are read from the file. If not give...
python
def load(self, filename, subset=None): """Load data into the registered fields Argument: | ``filename`` -- the filename to read from Optional argument: | ``subset`` -- a list of field names that are read from the file. If not give...
[ "def", "load", "(", "self", ",", "filename", ",", "subset", "=", "None", ")", ":", "with", "open", "(", "filename", ",", "\"r\"", ")", "as", "f", ":", "name", "=", "None", "num_names", "=", "0", "while", "True", ":", "# read a header line", "line", "...
Load data into the registered fields Argument: | ``filename`` -- the filename to read from Optional argument: | ``subset`` -- a list of field names that are read from the file. If not given, all data is read from the file.
[ "Load", "data", "into", "the", "registered", "fields" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L260-L325
train
molmod/molmod
molmod/bonds.py
BondData._load_bond_data
def _load_bond_data(self): """Load the bond data from the given file It's assumed that the uncommented lines in the data file have the following format: symbol1 symbol2 number1 number2 bond_length_single_a bond_length_double_a bond_length_triple_a bond_length_single_b bond_leng...
python
def _load_bond_data(self): """Load the bond data from the given file It's assumed that the uncommented lines in the data file have the following format: symbol1 symbol2 number1 number2 bond_length_single_a bond_length_double_a bond_length_triple_a bond_length_single_b bond_leng...
[ "def", "_load_bond_data", "(", "self", ")", ":", "def", "read_units", "(", "unit_names", ")", ":", "\"\"\"convert unit_names into conversion factors\"\"\"", "tmp", "=", "{", "\"A\"", ":", "units", ".", "angstrom", ",", "\"pm\"", ":", "units", ".", "picometer", "...
Load the bond data from the given file It's assumed that the uncommented lines in the data file have the following format: symbol1 symbol2 number1 number2 bond_length_single_a bond_length_double_a bond_length_triple_a bond_length_single_b bond_length_double_b bond_length_triple_b ..." ...
[ "Load", "the", "bond", "data", "from", "the", "given", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L89-L126
train
molmod/molmod
molmod/bonds.py
BondData._approximate_unkown_bond_lengths
def _approximate_unkown_bond_lengths(self): """Completes the bond length database with approximations based on VDW radii""" dataset = self.lengths[BOND_SINGLE] for n1 in periodic.iter_numbers(): for n2 in periodic.iter_numbers(): if n1 <= n2: pair ...
python
def _approximate_unkown_bond_lengths(self): """Completes the bond length database with approximations based on VDW radii""" dataset = self.lengths[BOND_SINGLE] for n1 in periodic.iter_numbers(): for n2 in periodic.iter_numbers(): if n1 <= n2: pair ...
[ "def", "_approximate_unkown_bond_lengths", "(", "self", ")", ":", "dataset", "=", "self", ".", "lengths", "[", "BOND_SINGLE", "]", "for", "n1", "in", "periodic", ".", "iter_numbers", "(", ")", ":", "for", "n2", "in", "periodic", ".", "iter_numbers", "(", "...
Completes the bond length database with approximations based on VDW radii
[ "Completes", "the", "bond", "length", "database", "with", "approximations", "based", "on", "VDW", "radii" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L128-L139
train
molmod/molmod
molmod/bonds.py
BondData.bonded
def bonded(self, n1, n2, distance): """Return the estimated bond type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond | ``distance`` -- the distance between the two atoms ...
python
def bonded(self, n1, n2, distance): """Return the estimated bond type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond | ``distance`` -- the distance between the two atoms ...
[ "def", "bonded", "(", "self", ",", "n1", ",", "n2", ",", "distance", ")", ":", "if", "distance", ">", "self", ".", "max_length", "*", "self", ".", "bond_tolerance", ":", "return", "None", "deviation", "=", "0.0", "pair", "=", "frozenset", "(", "[", "...
Return the estimated bond type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond | ``distance`` -- the distance between the two atoms This method checks whether for the given pair...
[ "Return", "the", "estimated", "bond", "type" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L142-L174
train
molmod/molmod
molmod/bonds.py
BondData.get_length
def get_length(self, n1, n2, bond_type=BOND_SINGLE): """Return the length of a bond between n1 and n2 of type bond_type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond Optional argume...
python
def get_length(self, n1, n2, bond_type=BOND_SINGLE): """Return the length of a bond between n1 and n2 of type bond_type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond Optional argume...
[ "def", "get_length", "(", "self", ",", "n1", ",", "n2", ",", "bond_type", "=", "BOND_SINGLE", ")", ":", "dataset", "=", "self", ".", "lengths", ".", "get", "(", "bond_type", ")", "if", "dataset", "==", "None", ":", "return", "None", "return", "dataset"...
Return the length of a bond between n1 and n2 of type bond_type Arguments: | ``n1`` -- the atom number of the first atom in the bond | ``n2`` -- the atom number of the second atom the bond Optional argument: | ``bond_type`` -- the type of bond [default=B...
[ "Return", "the", "length", "of", "a", "bond", "between", "n1", "and", "n2", "of", "type", "bond_type" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L176-L192
train
molmod/molmod
molmod/unit_cells.py
UnitCell.from_parameters3
def from_parameters3(cls, lengths, angles): """Construct a 3D unit cell with the given parameters The a vector is always parallel with the x-axis and they point in the same direction. The b vector is always in the xy plane and points towards the positive y-direction. The c vect...
python
def from_parameters3(cls, lengths, angles): """Construct a 3D unit cell with the given parameters The a vector is always parallel with the x-axis and they point in the same direction. The b vector is always in the xy plane and points towards the positive y-direction. The c vect...
[ "def", "from_parameters3", "(", "cls", ",", "lengths", ",", "angles", ")", ":", "for", "length", "in", "lengths", ":", "if", "length", "<=", "0", ":", "raise", "ValueError", "(", "\"The length parameters must be strictly positive.\"", ")", "for", "angle", "in", ...
Construct a 3D unit cell with the given parameters The a vector is always parallel with the x-axis and they point in the same direction. The b vector is always in the xy plane and points towards the positive y-direction. The c vector points towards the positive z-direction.
[ "Construct", "a", "3D", "unit", "cell", "with", "the", "given", "parameters" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L84-L125
train
molmod/molmod
molmod/unit_cells.py
UnitCell.volume
def volume(self): """The volume of the unit cell The actual definition of the volume depends on the number of active directions: * num_active == 0 -- always -1 * num_active == 1 -- length of the cell vector * num_active == 2 -- surface of the parall...
python
def volume(self): """The volume of the unit cell The actual definition of the volume depends on the number of active directions: * num_active == 0 -- always -1 * num_active == 1 -- length of the cell vector * num_active == 2 -- surface of the parall...
[ "def", "volume", "(", "self", ")", ":", "active", "=", "self", ".", "active_inactive", "[", "0", "]", "if", "len", "(", "active", ")", "==", "0", ":", "return", "-", "1", "elif", "len", "(", "active", ")", "==", "1", ":", "return", "np", ".", "...
The volume of the unit cell The actual definition of the volume depends on the number of active directions: * num_active == 0 -- always -1 * num_active == 1 -- length of the cell vector * num_active == 2 -- surface of the parallelogram * num_acti...
[ "The", "volume", "of", "the", "unit", "cell" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L128-L147
train
molmod/molmod
molmod/unit_cells.py
UnitCell.active_inactive
def active_inactive(self): """The indexes of the active and the inactive cell vectors""" active_indices = [] inactive_indices = [] for index, active in enumerate(self.active): if active: active_indices.append(index) else: inactive_i...
python
def active_inactive(self): """The indexes of the active and the inactive cell vectors""" active_indices = [] inactive_indices = [] for index, active in enumerate(self.active): if active: active_indices.append(index) else: inactive_i...
[ "def", "active_inactive", "(", "self", ")", ":", "active_indices", "=", "[", "]", "inactive_indices", "=", "[", "]", "for", "index", ",", "active", "in", "enumerate", "(", "self", ".", "active", ")", ":", "if", "active", ":", "active_indices", ".", "appe...
The indexes of the active and the inactive cell vectors
[ "The", "indexes", "of", "the", "active", "and", "the", "inactive", "cell", "vectors" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L150-L159
train
molmod/molmod
molmod/unit_cells.py
UnitCell.reciprocal
def reciprocal(self): """The reciprocal of the unit cell In case of a three-dimensional periodic system, this is trivially the transpose of the inverse of the cell matrix. This means that each column of the matrix corresponds to a reciprocal cell vector. In case of l...
python
def reciprocal(self): """The reciprocal of the unit cell In case of a three-dimensional periodic system, this is trivially the transpose of the inverse of the cell matrix. This means that each column of the matrix corresponds to a reciprocal cell vector. In case of l...
[ "def", "reciprocal", "(", "self", ")", ":", "U", ",", "S", ",", "Vt", "=", "np", ".", "linalg", ".", "svd", "(", "self", ".", "matrix", "*", "self", ".", "active", ")", "Sinv", "=", "np", ".", "zeros", "(", "S", ".", "shape", ",", "float", ")...
The reciprocal of the unit cell In case of a three-dimensional periodic system, this is trivially the transpose of the inverse of the cell matrix. This means that each column of the matrix corresponds to a reciprocal cell vector. In case of lower-dimensional periodicity, the...
[ "The", "reciprocal", "of", "the", "unit", "cell" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L162-L179
train
molmod/molmod
molmod/unit_cells.py
UnitCell.parameters
def parameters(self): """The cell parameters (lengths and angles)""" length_a = np.linalg.norm(self.matrix[:, 0]) length_b = np.linalg.norm(self.matrix[:, 1]) length_c = np.linalg.norm(self.matrix[:, 2]) alpha = np.arccos(np.dot(self.matrix[:, 1], self.matrix[:, 2]) / (length_b *...
python
def parameters(self): """The cell parameters (lengths and angles)""" length_a = np.linalg.norm(self.matrix[:, 0]) length_b = np.linalg.norm(self.matrix[:, 1]) length_c = np.linalg.norm(self.matrix[:, 2]) alpha = np.arccos(np.dot(self.matrix[:, 1], self.matrix[:, 2]) / (length_b *...
[ "def", "parameters", "(", "self", ")", ":", "length_a", "=", "np", ".", "linalg", ".", "norm", "(", "self", ".", "matrix", "[", ":", ",", "0", "]", ")", "length_b", "=", "np", ".", "linalg", ".", "norm", "(", "self", ".", "matrix", "[", ":", ",...
The cell parameters (lengths and angles)
[ "The", "cell", "parameters", "(", "lengths", "and", "angles", ")" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L182-L193
train
molmod/molmod
molmod/unit_cells.py
UnitCell.ordered
def ordered(self): """An equivalent unit cell with the active cell vectors coming first""" active, inactive = self.active_inactive order = active + inactive return UnitCell(self.matrix[:,order], self.active[order])
python
def ordered(self): """An equivalent unit cell with the active cell vectors coming first""" active, inactive = self.active_inactive order = active + inactive return UnitCell(self.matrix[:,order], self.active[order])
[ "def", "ordered", "(", "self", ")", ":", "active", ",", "inactive", "=", "self", ".", "active_inactive", "order", "=", "active", "+", "inactive", "return", "UnitCell", "(", "self", ".", "matrix", "[", ":", ",", "order", "]", ",", "self", ".", "active",...
An equivalent unit cell with the active cell vectors coming first
[ "An", "equivalent", "unit", "cell", "with", "the", "active", "cell", "vectors", "coming", "first" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L196-L200
train
molmod/molmod
molmod/unit_cells.py
UnitCell.alignment_a
def alignment_a(self): """Computes the rotation matrix that aligns the unit cell with the Cartesian axes, starting with cell vector a. * a parallel to x * b in xy-plane with b_y positive * c with c_z positive """ from molmod.transformations import Rot...
python
def alignment_a(self): """Computes the rotation matrix that aligns the unit cell with the Cartesian axes, starting with cell vector a. * a parallel to x * b in xy-plane with b_y positive * c with c_z positive """ from molmod.transformations import Rot...
[ "def", "alignment_a", "(", "self", ")", ":", "from", "molmod", ".", "transformations", "import", "Rotation", "new_x", "=", "self", ".", "matrix", "[", ":", ",", "0", "]", ".", "copy", "(", ")", "new_x", "/=", "np", ".", "linalg", ".", "norm", "(", ...
Computes the rotation matrix that aligns the unit cell with the Cartesian axes, starting with cell vector a. * a parallel to x * b in xy-plane with b_y positive * c with c_z positive
[ "Computes", "the", "rotation", "matrix", "that", "aligns", "the", "unit", "cell", "with", "the", "Cartesian", "axes", "starting", "with", "cell", "vector", "a", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L203-L218
train
molmod/molmod
molmod/unit_cells.py
UnitCell.spacings
def spacings(self): """Computes the distances between neighboring crystal planes""" result_invsq = (self.reciprocal**2).sum(axis=0) result = np.zeros(3, float) for i in range(3): if result_invsq[i] > 0: result[i] = result_invsq[i]**(-0.5) return result
python
def spacings(self): """Computes the distances between neighboring crystal planes""" result_invsq = (self.reciprocal**2).sum(axis=0) result = np.zeros(3, float) for i in range(3): if result_invsq[i] > 0: result[i] = result_invsq[i]**(-0.5) return result
[ "def", "spacings", "(", "self", ")", ":", "result_invsq", "=", "(", "self", ".", "reciprocal", "**", "2", ")", ".", "sum", "(", "axis", "=", "0", ")", "result", "=", "np", ".", "zeros", "(", "3", ",", "float", ")", "for", "i", "in", "range", "(...
Computes the distances between neighboring crystal planes
[ "Computes", "the", "distances", "between", "neighboring", "crystal", "planes" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L239-L246
train
molmod/molmod
molmod/unit_cells.py
UnitCell.add_cell_vector
def add_cell_vector(self, vector): """Returns a new unit cell with an additional cell vector""" act = self.active_inactive[0] if len(act) == 3: raise ValueError("The unit cell already has three active cell vectors.") matrix = np.zeros((3, 3), float) active = np.zeros(...
python
def add_cell_vector(self, vector): """Returns a new unit cell with an additional cell vector""" act = self.active_inactive[0] if len(act) == 3: raise ValueError("The unit cell already has three active cell vectors.") matrix = np.zeros((3, 3), float) active = np.zeros(...
[ "def", "add_cell_vector", "(", "self", ",", "vector", ")", ":", "act", "=", "self", ".", "active_inactive", "[", "0", "]", "if", "len", "(", "act", ")", "==", "3", ":", "raise", "ValueError", "(", "\"The unit cell already has three active cell vectors.\"", ")"...
Returns a new unit cell with an additional cell vector
[ "Returns", "a", "new", "unit", "cell", "with", "an", "additional", "cell", "vector" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L288-L317
train
molmod/molmod
molmod/unit_cells.py
UnitCell.get_radius_ranges
def get_radius_ranges(self, radius, mic=False): """Return ranges of indexes of the interacting neighboring unit cells Interacting neighboring unit cells have at least one point in their box volume that has a distance smaller or equal than radius to at least one point in the cen...
python
def get_radius_ranges(self, radius, mic=False): """Return ranges of indexes of the interacting neighboring unit cells Interacting neighboring unit cells have at least one point in their box volume that has a distance smaller or equal than radius to at least one point in the cen...
[ "def", "get_radius_ranges", "(", "self", ",", "radius", ",", "mic", "=", "False", ")", ":", "result", "=", "np", ".", "zeros", "(", "3", ",", "int", ")", "for", "i", "in", "range", "(", "3", ")", ":", "if", "self", ".", "spacings", "[", "i", "]...
Return ranges of indexes of the interacting neighboring unit cells Interacting neighboring unit cells have at least one point in their box volume that has a distance smaller or equal than radius to at least one point in the central cell. This concept is of importance when co...
[ "Return", "ranges", "of", "indexes", "of", "the", "interacting", "neighboring", "unit", "cells" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L319-L339
train
molmod/molmod
molmod/unit_cells.py
UnitCell.get_radius_indexes
def get_radius_indexes(self, radius, max_ranges=None): """Return the indexes of the interacting neighboring unit cells Interacting neighboring unit cells have at least one point in their box volume that has a distance smaller or equal than radius to at least one point in the ce...
python
def get_radius_indexes(self, radius, max_ranges=None): """Return the indexes of the interacting neighboring unit cells Interacting neighboring unit cells have at least one point in their box volume that has a distance smaller or equal than radius to at least one point in the ce...
[ "def", "get_radius_indexes", "(", "self", ",", "radius", ",", "max_ranges", "=", "None", ")", ":", "if", "max_ranges", "is", "None", ":", "max_ranges", "=", "np", ".", "array", "(", "[", "-", "1", ",", "-", "1", ",", "-", "1", "]", ")", "ranges", ...
Return the indexes of the interacting neighboring unit cells Interacting neighboring unit cells have at least one point in their box volume that has a distance smaller or equal than radius to at least one point in the central cell. This concept is of importance when computin...
[ "Return", "the", "indexes", "of", "the", "interacting", "neighboring", "unit", "cells" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L341-L376
train
molmod/molmod
molmod/toyff.py
guess_geometry
def guess_geometry(graph, unit_cell=None, verbose=False): """Construct a molecular geometry based on a molecular graph. This routine does not require initial coordinates and will give a very rough picture of the initial geometry. Do not expect all details to be in perfect condition. A subseque...
python
def guess_geometry(graph, unit_cell=None, verbose=False): """Construct a molecular geometry based on a molecular graph. This routine does not require initial coordinates and will give a very rough picture of the initial geometry. Do not expect all details to be in perfect condition. A subseque...
[ "def", "guess_geometry", "(", "graph", ",", "unit_cell", "=", "None", ",", "verbose", "=", "False", ")", ":", "N", "=", "len", "(", "graph", ".", "numbers", ")", "from", "molmod", ".", "minimizer", "import", "Minimizer", ",", "ConjugateGradient", ",", "N...
Construct a molecular geometry based on a molecular graph. This routine does not require initial coordinates and will give a very rough picture of the initial geometry. Do not expect all details to be in perfect condition. A subsequent optimization with a more accurate level of theory is at...
[ "Construct", "a", "molecular", "geometry", "based", "on", "a", "molecular", "graph", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/toyff.py#L43-L104
train
molmod/molmod
molmod/toyff.py
tune_geometry
def tune_geometry(graph, mol, unit_cell=None, verbose=False): """Fine tune a molecular geometry, starting from a (very) poor guess of the initial geometry. Do not expect all details to be in perfect condition. A subsequent optimization with a more accurate level of theory is at least advisable...
python
def tune_geometry(graph, mol, unit_cell=None, verbose=False): """Fine tune a molecular geometry, starting from a (very) poor guess of the initial geometry. Do not expect all details to be in perfect condition. A subsequent optimization with a more accurate level of theory is at least advisable...
[ "def", "tune_geometry", "(", "graph", ",", "mol", ",", "unit_cell", "=", "None", ",", "verbose", "=", "False", ")", ":", "N", "=", "len", "(", "graph", ".", "numbers", ")", "from", "molmod", ".", "minimizer", "import", "Minimizer", ",", "ConjugateGradien...
Fine tune a molecular geometry, starting from a (very) poor guess of the initial geometry. Do not expect all details to be in perfect condition. A subsequent optimization with a more accurate level of theory is at least advisable. Arguments: | ``graph`` -- The molecular graph of ...
[ "Fine", "tune", "a", "molecular", "geometry", "starting", "from", "a", "(", "very", ")", "poor", "guess", "of", "the", "initial", "geometry", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/toyff.py#L107-L154
train
molmod/molmod
molmod/pairff.py
PairFF.update_coordinates
def update_coordinates(self, coordinates=None): """Update the coordinates (and derived quantities) Argument: coordinates -- new Cartesian coordinates of the system """ if coordinates is not None: self.coordinates = coordinates self.numc = len(self.c...
python
def update_coordinates(self, coordinates=None): """Update the coordinates (and derived quantities) Argument: coordinates -- new Cartesian coordinates of the system """ if coordinates is not None: self.coordinates = coordinates self.numc = len(self.c...
[ "def", "update_coordinates", "(", "self", ",", "coordinates", "=", "None", ")", ":", "if", "coordinates", "is", "not", "None", ":", "self", ".", "coordinates", "=", "coordinates", "self", ".", "numc", "=", "len", "(", "self", ".", "coordinates", ")", "se...
Update the coordinates (and derived quantities) Argument: coordinates -- new Cartesian coordinates of the system
[ "Update", "the", "coordinates", "(", "and", "derived", "quantities", ")" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L67-L89
train
molmod/molmod
molmod/pairff.py
PairFF.energy
def energy(self): """Compute the energy of the system""" result = 0.0 for index1 in range(self.numc): for index2 in range(index1): if self.scaling[index1, index2] > 0: for se, ve in self.yield_pair_energies(index1, index2): ...
python
def energy(self): """Compute the energy of the system""" result = 0.0 for index1 in range(self.numc): for index2 in range(index1): if self.scaling[index1, index2] > 0: for se, ve in self.yield_pair_energies(index1, index2): ...
[ "def", "energy", "(", "self", ")", ":", "result", "=", "0.0", "for", "index1", "in", "range", "(", "self", ".", "numc", ")", ":", "for", "index2", "in", "range", "(", "index1", ")", ":", "if", "self", ".", "scaling", "[", "index1", ",", "index2", ...
Compute the energy of the system
[ "Compute", "the", "energy", "of", "the", "system" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L103-L111
train
molmod/molmod
molmod/pairff.py
PairFF.gradient_component
def gradient_component(self, index1): """Compute the gradient of the energy for one atom""" result = np.zeros(3, float) for index2 in range(self.numc): if self.scaling[index1, index2] > 0: for (se, ve), (sg, vg) in zip(self.yield_pair_energies(index1, index2), self.yi...
python
def gradient_component(self, index1): """Compute the gradient of the energy for one atom""" result = np.zeros(3, float) for index2 in range(self.numc): if self.scaling[index1, index2] > 0: for (se, ve), (sg, vg) in zip(self.yield_pair_energies(index1, index2), self.yi...
[ "def", "gradient_component", "(", "self", ",", "index1", ")", ":", "result", "=", "np", ".", "zeros", "(", "3", ",", "float", ")", "for", "index2", "in", "range", "(", "self", ".", "numc", ")", ":", "if", "self", ".", "scaling", "[", "index1", ",",...
Compute the gradient of the energy for one atom
[ "Compute", "the", "gradient", "of", "the", "energy", "for", "one", "atom" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L113-L120
train
molmod/molmod
molmod/pairff.py
PairFF.gradient
def gradient(self): """Compute the gradient of the energy for all atoms""" result = np.zeros((self.numc, 3), float) for index1 in range(self.numc): result[index1] = self.gradient_component(index1) return result
python
def gradient(self): """Compute the gradient of the energy for all atoms""" result = np.zeros((self.numc, 3), float) for index1 in range(self.numc): result[index1] = self.gradient_component(index1) return result
[ "def", "gradient", "(", "self", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "self", ".", "numc", ",", "3", ")", ",", "float", ")", "for", "index1", "in", "range", "(", "self", ".", "numc", ")", ":", "result", "[", "index1", "]", "=",...
Compute the gradient of the energy for all atoms
[ "Compute", "the", "gradient", "of", "the", "energy", "for", "all", "atoms" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L122-L127
train
molmod/molmod
molmod/pairff.py
PairFF.hessian_component
def hessian_component(self, index1, index2): """Compute the hessian of the energy for one atom pair""" result = np.zeros((3, 3), float) if index1 == index2: for index3 in range(self.numc): if self.scaling[index1, index3] > 0: d_1 = 1/self.distances...
python
def hessian_component(self, index1, index2): """Compute the hessian of the energy for one atom pair""" result = np.zeros((3, 3), float) if index1 == index2: for index3 in range(self.numc): if self.scaling[index1, index3] > 0: d_1 = 1/self.distances...
[ "def", "hessian_component", "(", "self", ",", "index1", ",", "index2", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "3", ",", "3", ")", ",", "float", ")", "if", "index1", "==", "index2", ":", "for", "index3", "in", "range", "(", "self", ...
Compute the hessian of the energy for one atom pair
[ "Compute", "the", "hessian", "of", "the", "energy", "for", "one", "atom", "pair" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L129-L162
train
molmod/molmod
molmod/pairff.py
PairFF.hessian
def hessian(self): """Compute the hessian of the energy""" result = np.zeros((self.numc, 3, self.numc, 3), float) for index1 in range(self.numc): for index2 in range(self.numc): result[index1, :, index2, :] = self.hessian_component(index1, index2) return resul...
python
def hessian(self): """Compute the hessian of the energy""" result = np.zeros((self.numc, 3, self.numc, 3), float) for index1 in range(self.numc): for index2 in range(self.numc): result[index1, :, index2, :] = self.hessian_component(index1, index2) return resul...
[ "def", "hessian", "(", "self", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "self", ".", "numc", ",", "3", ",", "self", ".", "numc", ",", "3", ")", ",", "float", ")", "for", "index1", "in", "range", "(", "self", ".", "numc", ")", ":...
Compute the hessian of the energy
[ "Compute", "the", "hessian", "of", "the", "energy" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L164-L170
train
molmod/molmod
molmod/pairff.py
CoulombFF.yield_pair_energies
def yield_pair_energies(self, index1, index2): """Yields pairs ((s(r_ij), v(bar{r}_ij))""" d_1 = 1/self.distances[index1, index2] if self.charges is not None: c1 = self.charges[index1] c2 = self.charges[index2] yield c1*c2*d_1, 1 if self.dipoles is not...
python
def yield_pair_energies(self, index1, index2): """Yields pairs ((s(r_ij), v(bar{r}_ij))""" d_1 = 1/self.distances[index1, index2] if self.charges is not None: c1 = self.charges[index1] c2 = self.charges[index2] yield c1*c2*d_1, 1 if self.dipoles is not...
[ "def", "yield_pair_energies", "(", "self", ",", "index1", ",", "index2", ")", ":", "d_1", "=", "1", "/", "self", ".", "distances", "[", "index1", ",", "index2", "]", "if", "self", ".", "charges", "is", "not", "None", ":", "c1", "=", "self", ".", "c...
Yields pairs ((s(r_ij), v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L202-L219
train
molmod/molmod
molmod/pairff.py
CoulombFF.yield_pair_gradients
def yield_pair_gradients(self, index1, index2): """Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))""" d_2 = 1/self.distances[index1, index2]**2 if self.charges is not None: c1 = self.charges[index1] c2 = self.charges[index2] yield -c1*c2*d_2, np.zeros(3) ...
python
def yield_pair_gradients(self, index1, index2): """Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))""" d_2 = 1/self.distances[index1, index2]**2 if self.charges is not None: c1 = self.charges[index1] c2 = self.charges[index2] yield -c1*c2*d_2, np.zeros(3) ...
[ "def", "yield_pair_gradients", "(", "self", ",", "index1", ",", "index2", ")", ":", "d_2", "=", "1", "/", "self", ".", "distances", "[", "index1", ",", "index2", "]", "**", "2", "if", "self", ".", "charges", "is", "not", "None", ":", "c1", "=", "se...
Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "grad_i", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L221-L238
train
molmod/molmod
molmod/pairff.py
CoulombFF.yield_pair_hessians
def yield_pair_hessians(self, index1, index2): """Yields pairs ((s''(r_ij), grad_i (x) grad_i v(bar{r}_ij))""" d_1 = 1/self.distances[index1, index2] d_3 = d_1**3 if self.charges is not None: c1 = self.charges[index1] c2 = self.charges[index2] yield 2*...
python
def yield_pair_hessians(self, index1, index2): """Yields pairs ((s''(r_ij), grad_i (x) grad_i v(bar{r}_ij))""" d_1 = 1/self.distances[index1, index2] d_3 = d_1**3 if self.charges is not None: c1 = self.charges[index1] c2 = self.charges[index2] yield 2*...
[ "def", "yield_pair_hessians", "(", "self", ",", "index1", ",", "index2", ")", ":", "d_1", "=", "1", "/", "self", ".", "distances", "[", "index1", ",", "index2", "]", "d_3", "=", "d_1", "**", "3", "if", "self", ".", "charges", "is", "not", "None", "...
Yields pairs ((s''(r_ij), grad_i (x) grad_i v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "grad_i", "(", "x", ")", "grad_i", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L240-L257
train
molmod/molmod
molmod/pairff.py
CoulombFF.esp
def esp(self): """Compute the electrostatic potential at each atom due to other atoms""" result = np.zeros(self.numc, float) for index1 in range(self.numc): result[index1] = self.esp_component(index1) return result
python
def esp(self): """Compute the electrostatic potential at each atom due to other atoms""" result = np.zeros(self.numc, float) for index1 in range(self.numc): result[index1] = self.esp_component(index1) return result
[ "def", "esp", "(", "self", ")", ":", "result", "=", "np", ".", "zeros", "(", "self", ".", "numc", ",", "float", ")", "for", "index1", "in", "range", "(", "self", ".", "numc", ")", ":", "result", "[", "index1", "]", "=", "self", ".", "esp_componen...
Compute the electrostatic potential at each atom due to other atoms
[ "Compute", "the", "electrostatic", "potential", "at", "each", "atom", "due", "to", "other", "atoms" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L282-L287
train
molmod/molmod
molmod/pairff.py
CoulombFF.efield
def efield(self): """Compute the electrostatic potential at each atom due to other atoms""" result = np.zeros((self.numc,3), float) for index1 in range(self.numc): result[index1] = self.efield_component(index1) return result
python
def efield(self): """Compute the electrostatic potential at each atom due to other atoms""" result = np.zeros((self.numc,3), float) for index1 in range(self.numc): result[index1] = self.efield_component(index1) return result
[ "def", "efield", "(", "self", ")", ":", "result", "=", "np", ".", "zeros", "(", "(", "self", ".", "numc", ",", "3", ")", ",", "float", ")", "for", "index1", "in", "range", "(", "self", ".", "numc", ")", ":", "result", "[", "index1", "]", "=", ...
Compute the electrostatic potential at each atom due to other atoms
[ "Compute", "the", "electrostatic", "potential", "at", "each", "atom", "due", "to", "other", "atoms" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L315-L320
train
molmod/molmod
molmod/pairff.py
DispersionFF.yield_pair_energies
def yield_pair_energies(self, index1, index2): """Yields pairs ((s(r_ij), v(bar{r}_ij))""" strength = self.strengths[index1, index2] distance = self.distances[index1, index2] yield strength*distance**(-6), 1
python
def yield_pair_energies(self, index1, index2): """Yields pairs ((s(r_ij), v(bar{r}_ij))""" strength = self.strengths[index1, index2] distance = self.distances[index1, index2] yield strength*distance**(-6), 1
[ "def", "yield_pair_energies", "(", "self", ",", "index1", ",", "index2", ")", ":", "strength", "=", "self", ".", "strengths", "[", "index1", ",", "index2", "]", "distance", "=", "self", ".", "distances", "[", "index1", ",", "index2", "]", "yield", "stren...
Yields pairs ((s(r_ij), v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L344-L348
train
molmod/molmod
molmod/pairff.py
DispersionFF.yield_pair_gradients
def yield_pair_gradients(self, index1, index2): """Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))""" strength = self.strengths[index1, index2] distance = self.distances[index1, index2] yield -6*strength*distance**(-7), np.zeros(3)
python
def yield_pair_gradients(self, index1, index2): """Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))""" strength = self.strengths[index1, index2] distance = self.distances[index1, index2] yield -6*strength*distance**(-7), np.zeros(3)
[ "def", "yield_pair_gradients", "(", "self", ",", "index1", ",", "index2", ")", ":", "strength", "=", "self", ".", "strengths", "[", "index1", ",", "index2", "]", "distance", "=", "self", ".", "distances", "[", "index1", ",", "index2", "]", "yield", "-", ...
Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "grad_i", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L350-L354
train
molmod/molmod
molmod/pairff.py
ExpRepFF.yield_pair_energies
def yield_pair_energies(self, index1, index2): """Yields pairs ((s(r_ij), v(bar{r}_ij))""" A = self.As[index1, index2] B = self.Bs[index1, index2] distance = self.distances[index1, index2] yield A*np.exp(-B*distance), 1
python
def yield_pair_energies(self, index1, index2): """Yields pairs ((s(r_ij), v(bar{r}_ij))""" A = self.As[index1, index2] B = self.Bs[index1, index2] distance = self.distances[index1, index2] yield A*np.exp(-B*distance), 1
[ "def", "yield_pair_energies", "(", "self", ",", "index1", ",", "index2", ")", ":", "A", "=", "self", ".", "As", "[", "index1", ",", "index2", "]", "B", "=", "self", ".", "Bs", "[", "index1", ",", "index2", "]", "distance", "=", "self", ".", "distan...
Yields pairs ((s(r_ij), v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L425-L430
train
molmod/molmod
molmod/pairff.py
ExpRepFF.yield_pair_gradients
def yield_pair_gradients(self, index1, index2): """Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))""" A = self.As[index1, index2] B = self.Bs[index1, index2] distance = self.distances[index1, index2] yield -B*A*np.exp(-B*distance), np.zeros(3)
python
def yield_pair_gradients(self, index1, index2): """Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))""" A = self.As[index1, index2] B = self.Bs[index1, index2] distance = self.distances[index1, index2] yield -B*A*np.exp(-B*distance), np.zeros(3)
[ "def", "yield_pair_gradients", "(", "self", ",", "index1", ",", "index2", ")", ":", "A", "=", "self", ".", "As", "[", "index1", ",", "index2", "]", "B", "=", "self", ".", "Bs", "[", "index1", ",", "index2", "]", "distance", "=", "self", ".", "dista...
Yields pairs ((s'(r_ij), grad_i v(bar{r}_ij))
[ "Yields", "pairs", "((", "s", "(", "r_ij", ")", "grad_i", "v", "(", "bar", "{", "r", "}", "_ij", "))" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L432-L437
train
molmod/molmod
molmod/io/cml.py
load_cml
def load_cml(cml_filename): """Load the molecules from a CML file Argument: | ``cml_filename`` -- The filename of a CML file. Returns a list of molecule objects with optional molecular graph attribute and extra attributes. """ parser = make_parser() parser.setFeature(fea...
python
def load_cml(cml_filename): """Load the molecules from a CML file Argument: | ``cml_filename`` -- The filename of a CML file. Returns a list of molecule objects with optional molecular graph attribute and extra attributes. """ parser = make_parser() parser.setFeature(fea...
[ "def", "load_cml", "(", "cml_filename", ")", ":", "parser", "=", "make_parser", "(", ")", "parser", ".", "setFeature", "(", "feature_namespaces", ",", "0", ")", "dh", "=", "CMLMoleculeLoader", "(", ")", "parser", ".", "setContentHandler", "(", "dh", ")", "...
Load the molecules from a CML file Argument: | ``cml_filename`` -- The filename of a CML file. Returns a list of molecule objects with optional molecular graph attribute and extra attributes.
[ "Load", "the", "molecules", "from", "a", "CML", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L149-L163
train
molmod/molmod
molmod/io/cml.py
_dump_cml_molecule
def _dump_cml_molecule(f, molecule): """Dump a single molecule to a CML file Arguments: | ``f`` -- a file-like object | ``molecule`` -- a Molecule instance """ extra = getattr(molecule, "extra", {}) attr_str = " ".join("%s='%s'" % (key, value) for key, value in extra.items())...
python
def _dump_cml_molecule(f, molecule): """Dump a single molecule to a CML file Arguments: | ``f`` -- a file-like object | ``molecule`` -- a Molecule instance """ extra = getattr(molecule, "extra", {}) attr_str = " ".join("%s='%s'" % (key, value) for key, value in extra.items())...
[ "def", "_dump_cml_molecule", "(", "f", ",", "molecule", ")", ":", "extra", "=", "getattr", "(", "molecule", ",", "\"extra\"", ",", "{", "}", ")", "attr_str", "=", "\" \"", ".", "join", "(", "\"%s='%s'\"", "%", "(", "key", ",", "value", ")", "for", "k...
Dump a single molecule to a CML file Arguments: | ``f`` -- a file-like object | ``molecule`` -- a Molecule instance
[ "Dump", "a", "single", "molecule", "to", "a", "CML", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L166-L195
train
molmod/molmod
molmod/io/cml.py
dump_cml
def dump_cml(f, molecules): """Write a list of molecules to a CML file Arguments: | ``f`` -- a filename of a CML file or a file-like object | ``molecules`` -- a list of molecule objects. """ if isinstance(f, str): f = open(f, "w") close = True else: cl...
python
def dump_cml(f, molecules): """Write a list of molecules to a CML file Arguments: | ``f`` -- a filename of a CML file or a file-like object | ``molecules`` -- a list of molecule objects. """ if isinstance(f, str): f = open(f, "w") close = True else: cl...
[ "def", "dump_cml", "(", "f", ",", "molecules", ")", ":", "if", "isinstance", "(", "f", ",", "str", ")", ":", "f", "=", "open", "(", "f", ",", "\"w\"", ")", "close", "=", "True", "else", ":", "close", "=", "False", "f", ".", "write", "(", "\"<?x...
Write a list of molecules to a CML file Arguments: | ``f`` -- a filename of a CML file or a file-like object | ``molecules`` -- a list of molecule objects.
[ "Write", "a", "list", "of", "molecules", "to", "a", "CML", "file" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L198-L216
train
molmod/molmod
molmod/io/cml.py
CMLMoleculeLoader._get_extra
def _get_extra(self, attrs, exclude): """Read the extra properties, taking into account an exclude list""" result = {} for key in attrs.getNames(): if key not in exclude: result[str(key)] = str(attrs[key]) return result
python
def _get_extra(self, attrs, exclude): """Read the extra properties, taking into account an exclude list""" result = {} for key in attrs.getNames(): if key not in exclude: result[str(key)] = str(attrs[key]) return result
[ "def", "_get_extra", "(", "self", ",", "attrs", ",", "exclude", ")", ":", "result", "=", "{", "}", "for", "key", "in", "attrs", ".", "getNames", "(", ")", ":", "if", "key", "not", "in", "exclude", ":", "result", "[", "str", "(", "key", ")", "]", ...
Read the extra properties, taking into account an exclude list
[ "Read", "the", "extra", "properties", "taking", "into", "account", "an", "exclude", "list" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L62-L68
train
molmod/molmod
molmod/io/fchk.py
FCHKFile._read
def _read(self, filename, field_labels=None): """Read all the requested fields Arguments: | ``filename`` -- the filename of the FCHK file | ``field_labels`` -- when given, only these fields are read """ # if fields is None, all fields are read def ...
python
def _read(self, filename, field_labels=None): """Read all the requested fields Arguments: | ``filename`` -- the filename of the FCHK file | ``field_labels`` -- when given, only these fields are read """ # if fields is None, all fields are read def ...
[ "def", "_read", "(", "self", ",", "filename", ",", "field_labels", "=", "None", ")", ":", "# if fields is None, all fields are read", "def", "read_field", "(", "f", ")", ":", "\"\"\"Read a single field\"\"\"", "datatype", "=", "None", "while", "datatype", "is", "N...
Read all the requested fields Arguments: | ``filename`` -- the filename of the FCHK file | ``field_labels`` -- when given, only these fields are read
[ "Read", "all", "the", "requested", "fields" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L73-L156
train
molmod/molmod
molmod/io/fchk.py
FCHKFile._analyze
def _analyze(self): """Convert a few elementary fields into a molecule object""" if ("Atomic numbers" in self.fields) and ("Current cartesian coordinates" in self.fields): self.molecule = Molecule( self.fields["Atomic numbers"], np.reshape(self.fields["Current...
python
def _analyze(self): """Convert a few elementary fields into a molecule object""" if ("Atomic numbers" in self.fields) and ("Current cartesian coordinates" in self.fields): self.molecule = Molecule( self.fields["Atomic numbers"], np.reshape(self.fields["Current...
[ "def", "_analyze", "(", "self", ")", ":", "if", "(", "\"Atomic numbers\"", "in", "self", ".", "fields", ")", "and", "(", "\"Current cartesian coordinates\"", "in", "self", ".", "fields", ")", ":", "self", ".", "molecule", "=", "Molecule", "(", "self", ".",...
Convert a few elementary fields into a molecule object
[ "Convert", "a", "few", "elementary", "fields", "into", "a", "molecule", "object" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L158-L165
train
molmod/molmod
molmod/io/fchk.py
FCHKFile.get_optimization_coordinates
def get_optimization_coordinates(self): """Return the coordinates of the geometries at each point in the optimization""" coor_array = self.fields.get("Opt point 1 Geometries") if coor_array is None: return [] else: return np.reshape(coor_array, (-1, len(self...
python
def get_optimization_coordinates(self): """Return the coordinates of the geometries at each point in the optimization""" coor_array = self.fields.get("Opt point 1 Geometries") if coor_array is None: return [] else: return np.reshape(coor_array, (-1, len(self...
[ "def", "get_optimization_coordinates", "(", "self", ")", ":", "coor_array", "=", "self", ".", "fields", ".", "get", "(", "\"Opt point 1 Geometries\"", ")", "if", "coor_array", "is", "None", ":", "return", "[", "]", "else", ":", "return", "np", ".", "re...
Return the coordinates of the geometries at each point in the optimization
[ "Return", "the", "coordinates", "of", "the", "geometries", "at", "each", "point", "in", "the", "optimization" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L179-L185
train
molmod/molmod
molmod/io/fchk.py
FCHKFile.get_optimized_molecule
def get_optimized_molecule(self): """Return a molecule object of the optimal geometry""" opt_coor = self.get_optimization_coordinates() if len(opt_coor) == 0: return None else: return Molecule( self.molecule.numbers, opt_coor[-1], ...
python
def get_optimized_molecule(self): """Return a molecule object of the optimal geometry""" opt_coor = self.get_optimization_coordinates() if len(opt_coor) == 0: return None else: return Molecule( self.molecule.numbers, opt_coor[-1], ...
[ "def", "get_optimized_molecule", "(", "self", ")", ":", "opt_coor", "=", "self", ".", "get_optimization_coordinates", "(", ")", "if", "len", "(", "opt_coor", ")", "==", "0", ":", "return", "None", "else", ":", "return", "Molecule", "(", "self", ".", "molec...
Return a molecule object of the optimal geometry
[ "Return", "a", "molecule", "object", "of", "the", "optimal", "geometry" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L187-L196
train
molmod/molmod
molmod/io/fchk.py
FCHKFile.get_optimization_gradients
def get_optimization_gradients(self): """Return the energy gradients of all geometries during an optimization""" grad_array = self.fields.get("Opt point 1 Gradient at each geome") if grad_array is None: return [] else: return np.reshape(grad_array, (-1, len(...
python
def get_optimization_gradients(self): """Return the energy gradients of all geometries during an optimization""" grad_array = self.fields.get("Opt point 1 Gradient at each geome") if grad_array is None: return [] else: return np.reshape(grad_array, (-1, len(...
[ "def", "get_optimization_gradients", "(", "self", ")", ":", "grad_array", "=", "self", ".", "fields", ".", "get", "(", "\"Opt point 1 Gradient at each geome\"", ")", "if", "grad_array", "is", "None", ":", "return", "[", "]", "else", ":", "return", "np", ...
Return the energy gradients of all geometries during an optimization
[ "Return", "the", "energy", "gradients", "of", "all", "geometries", "during", "an", "optimization" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L198-L204
train
molmod/molmod
molmod/io/fchk.py
FCHKFile.get_hessian
def get_hessian(self): """Return the hessian""" force_const = self.fields.get("Cartesian Force Constants") if force_const is None: return None N = len(self.molecule.numbers) result = np.zeros((3*N, 3*N), float) counter = 0 for row in range(3*N): ...
python
def get_hessian(self): """Return the hessian""" force_const = self.fields.get("Cartesian Force Constants") if force_const is None: return None N = len(self.molecule.numbers) result = np.zeros((3*N, 3*N), float) counter = 0 for row in range(3*N): ...
[ "def", "get_hessian", "(", "self", ")", ":", "force_const", "=", "self", ".", "fields", ".", "get", "(", "\"Cartesian Force Constants\"", ")", "if", "force_const", "is", "None", ":", "return", "None", "N", "=", "len", "(", "self", ".", "molecule", ".", "...
Return the hessian
[ "Return", "the", "hessian" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/fchk.py#L214-L226
train
molmod/molmod
molmod/utils.py
ReadOnly.copy_with
def copy_with(self, **kwargs): """Return a copy with (a few) changed attributes The keyword arguments are the attributes to be replaced by new values. All other attributes are copied (or referenced) from the original object. This only works if the constructor takes all ...
python
def copy_with(self, **kwargs): """Return a copy with (a few) changed attributes The keyword arguments are the attributes to be replaced by new values. All other attributes are copied (or referenced) from the original object. This only works if the constructor takes all ...
[ "def", "copy_with", "(", "self", ",", "*", "*", "kwargs", ")", ":", "attrs", "=", "{", "}", "for", "key", ",", "descriptor", "in", "self", ".", "__class__", ".", "__dict__", ".", "items", "(", ")", ":", "if", "isinstance", "(", "descriptor", ",", "...
Return a copy with (a few) changed attributes The keyword arguments are the attributes to be replaced by new values. All other attributes are copied (or referenced) from the original object. This only works if the constructor takes all (read-only) attributes as arguments.
[ "Return", "a", "copy", "with", "(", "a", "few", ")", "changed", "attributes" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/utils.py#L290-L306
train
molmod/molmod
molmod/io/gamess.py
PunchFile._read
def _read(self, filename): """Internal routine that reads all data from the punch file.""" data = {} parsers = [ FirstDataParser(), CoordinateParser(), EnergyGradParser(), SkipApproxHessian(), HessianParser(), MassParser(), ] with open(filename) as f: ...
python
def _read(self, filename): """Internal routine that reads all data from the punch file.""" data = {} parsers = [ FirstDataParser(), CoordinateParser(), EnergyGradParser(), SkipApproxHessian(), HessianParser(), MassParser(), ] with open(filename) as f: ...
[ "def", "_read", "(", "self", ",", "filename", ")", ":", "data", "=", "{", "}", "parsers", "=", "[", "FirstDataParser", "(", ")", ",", "CoordinateParser", "(", ")", ",", "EnergyGradParser", "(", ")", ",", "SkipApproxHessian", "(", ")", ",", "HessianParser...
Internal routine that reads all data from the punch file.
[ "Internal", "routine", "that", "reads", "all", "data", "from", "the", "punch", "file", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L55-L75
train
molmod/molmod
molmod/io/gamess.py
FirstDataParser.read
def read(self, line, f, data): """See :meth:`PunchParser.read`""" self.used = True data["title"] = f.readline().strip() data["symmetry"] = f.readline().split()[0] if data["symmetry"] != "C1": raise NotImplementedError("Only C1 symmetry is supported.") symbols ...
python
def read(self, line, f, data): """See :meth:`PunchParser.read`""" self.used = True data["title"] = f.readline().strip() data["symmetry"] = f.readline().split()[0] if data["symmetry"] != "C1": raise NotImplementedError("Only C1 symmetry is supported.") symbols ...
[ "def", "read", "(", "self", ",", "line", ",", "f", ",", "data", ")", ":", "self", ".", "used", "=", "True", "data", "[", "\"title\"", "]", "=", "f", ".", "readline", "(", ")", ".", "strip", "(", ")", "data", "[", "\"symmetry\"", "]", "=", "f", ...
See :meth:`PunchParser.read`
[ "See", ":", "meth", ":", "PunchParser", ".", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L117-L129
train
molmod/molmod
molmod/io/gamess.py
CoordinateParser.read
def read(self, line, f, data): """See :meth:`PunchParser.read`""" f.readline() f.readline() N = len(data["symbols"]) # if the data are already read before, just overwrite them numbers = data.get("numbers") if numbers is None: numbers = np.zeros(N, int)...
python
def read(self, line, f, data): """See :meth:`PunchParser.read`""" f.readline() f.readline() N = len(data["symbols"]) # if the data are already read before, just overwrite them numbers = data.get("numbers") if numbers is None: numbers = np.zeros(N, int)...
[ "def", "read", "(", "self", ",", "line", ",", "f", ",", "data", ")", ":", "f", ".", "readline", "(", ")", "f", ".", "readline", "(", ")", "N", "=", "len", "(", "data", "[", "\"symbols\"", "]", ")", "# if the data are already read before, just overwrite t...
See :meth:`PunchParser.read`
[ "See", ":", "meth", ":", "PunchParser", ".", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L140-L159
train
molmod/molmod
molmod/io/gamess.py
EnergyGradParser.read
def read(self, line, f, data): """See :meth:`PunchParser.read`""" data["energy"] = float(f.readline().split()[1]) N = len(data["symbols"]) # if the data are already read before, just overwrite them gradient = data.get("gradient") if gradient is None: gradient ...
python
def read(self, line, f, data): """See :meth:`PunchParser.read`""" data["energy"] = float(f.readline().split()[1]) N = len(data["symbols"]) # if the data are already read before, just overwrite them gradient = data.get("gradient") if gradient is None: gradient ...
[ "def", "read", "(", "self", ",", "line", ",", "f", ",", "data", ")", ":", "data", "[", "\"energy\"", "]", "=", "float", "(", "f", ".", "readline", "(", ")", ".", "split", "(", ")", "[", "1", "]", ")", "N", "=", "len", "(", "data", "[", "\"s...
See :meth:`PunchParser.read`
[ "See", ":", "meth", ":", "PunchParser", ".", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L169-L182
train
molmod/molmod
molmod/io/gamess.py
SkipApproxHessian.read
def read(self, line, f, data): """See :meth:`PunchParser.read`""" line = f.readline() assert(line == " $HESS\n") while line != " $END\n": line = f.readline()
python
def read(self, line, f, data): """See :meth:`PunchParser.read`""" line = f.readline() assert(line == " $HESS\n") while line != " $END\n": line = f.readline()
[ "def", "read", "(", "self", ",", "line", ",", "f", ",", "data", ")", ":", "line", "=", "f", ".", "readline", "(", ")", "assert", "(", "line", "==", "\" $HESS\\n\"", ")", "while", "line", "!=", "\" $END\\n\"", ":", "line", "=", "f", ".", "readline",...
See :meth:`PunchParser.read`
[ "See", ":", "meth", ":", "PunchParser", ".", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L192-L197
train
molmod/molmod
molmod/io/gamess.py
HessianParser.read
def read(self, line, f, data): """See :meth:`PunchParser.read`""" assert("hessian" not in data) f.readline() N = len(data["symbols"]) hessian = np.zeros((3*N, 3*N), float) tmp = hessian.ravel() counter = 0 while True: line = f.readline() ...
python
def read(self, line, f, data): """See :meth:`PunchParser.read`""" assert("hessian" not in data) f.readline() N = len(data["symbols"]) hessian = np.zeros((3*N, 3*N), float) tmp = hessian.ravel() counter = 0 while True: line = f.readline() ...
[ "def", "read", "(", "self", ",", "line", ",", "f", ",", "data", ")", ":", "assert", "(", "\"hessian\"", "not", "in", "data", ")", "f", ".", "readline", "(", ")", "N", "=", "len", "(", "data", "[", "\"symbols\"", "]", ")", "hessian", "=", "np", ...
See :meth:`PunchParser.read`
[ "See", ":", "meth", ":", "PunchParser", ".", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L207-L223
train
molmod/molmod
molmod/io/gamess.py
MassParser.read
def read(self, line, f, data): """See :meth:`PunchParser.read`""" N = len(data["symbols"]) masses = np.zeros(N, float) counter = 0 while counter < N: words = f.readline().split() for word in words: masses[counter] = float(word)*amu ...
python
def read(self, line, f, data): """See :meth:`PunchParser.read`""" N = len(data["symbols"]) masses = np.zeros(N, float) counter = 0 while counter < N: words = f.readline().split() for word in words: masses[counter] = float(word)*amu ...
[ "def", "read", "(", "self", ",", "line", ",", "f", ",", "data", ")", ":", "N", "=", "len", "(", "data", "[", "\"symbols\"", "]", ")", "masses", "=", "np", ".", "zeros", "(", "N", ",", "float", ")", "counter", "=", "0", "while", "counter", "<", ...
See :meth:`PunchParser.read`
[ "See", ":", "meth", ":", "PunchParser", ".", "read" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/gamess.py#L233-L243
train
molmod/molmod
molmod/examples/003_internal_coordinates/c_ff_hessian.py
setup_hydrocarbon_ff
def setup_hydrocarbon_ff(graph): """Create a simple ForceField object for hydrocarbons based on the graph.""" # A) Define parameters. # the bond parameters: bond_params = { (6, 1): 310*kcalmol/angstrom**2, (6, 6): 220*kcalmol/angstrom**2, } # for every (a, b), also add (b, a) ...
python
def setup_hydrocarbon_ff(graph): """Create a simple ForceField object for hydrocarbons based on the graph.""" # A) Define parameters. # the bond parameters: bond_params = { (6, 1): 310*kcalmol/angstrom**2, (6, 6): 220*kcalmol/angstrom**2, } # for every (a, b), also add (b, a) ...
[ "def", "setup_hydrocarbon_ff", "(", "graph", ")", ":", "# A) Define parameters.", "# the bond parameters:", "bond_params", "=", "{", "(", "6", ",", "1", ")", ":", "310", "*", "kcalmol", "/", "angstrom", "**", "2", ",", "(", "6", ",", "6", ")", ":", "220"...
Create a simple ForceField object for hydrocarbons based on the graph.
[ "Create", "a", "simple", "ForceField", "object", "for", "hydrocarbons", "based", "on", "the", "graph", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/c_ff_hessian.py#L106-L144
train
molmod/molmod
molmod/examples/003_internal_coordinates/c_ff_hessian.py
HarmonicEnergyTerm.add_to_hessian
def add_to_hessian(self, coordinates, hessian): """Add the contributions of this energy term to the Hessian Arguments: | ``coordinates`` -- A numpy array with 3N Cartesian coordinates. | ``hessian`` -- A matrix for the full Hessian to which this energy ...
python
def add_to_hessian(self, coordinates, hessian): """Add the contributions of this energy term to the Hessian Arguments: | ``coordinates`` -- A numpy array with 3N Cartesian coordinates. | ``hessian`` -- A matrix for the full Hessian to which this energy ...
[ "def", "add_to_hessian", "(", "self", ",", "coordinates", ",", "hessian", ")", ":", "# Compute the derivatives of the bond stretch towards the two cartesian", "# coordinates. The bond length is computed too, but not used.", "q", ",", "g", "=", "self", ".", "icfn", "(", "coord...
Add the contributions of this energy term to the Hessian Arguments: | ``coordinates`` -- A numpy array with 3N Cartesian coordinates. | ``hessian`` -- A matrix for the full Hessian to which this energy term has to add its contribution.
[ "Add", "the", "contributions", "of", "this", "energy", "term", "to", "the", "Hessian" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/c_ff_hessian.py#L26-L43
train
molmod/molmod
molmod/examples/003_internal_coordinates/c_ff_hessian.py
ForceField.hessian
def hessian(self, coordinates): """Compute the force-field Hessian for the given coordinates. Argument: | ``coordinates`` -- A numpy array with the Cartesian atom coordinates, with shape (N,3). Returns: | ``hessian`` -- A numpy arr...
python
def hessian(self, coordinates): """Compute the force-field Hessian for the given coordinates. Argument: | ``coordinates`` -- A numpy array with the Cartesian atom coordinates, with shape (N,3). Returns: | ``hessian`` -- A numpy arr...
[ "def", "hessian", "(", "self", ",", "coordinates", ")", ":", "# N3 is 3 times the number of atoms.", "N3", "=", "coordinates", ".", "size", "# Start with a zero hessian.", "hessian", "=", "numpy", ".", "zeros", "(", "(", "N3", ",", "N3", ")", ",", "float", ")"...
Compute the force-field Hessian for the given coordinates. Argument: | ``coordinates`` -- A numpy array with the Cartesian atom coordinates, with shape (N,3). Returns: | ``hessian`` -- A numpy array with the Hessian, with shape (3*N, ...
[ "Compute", "the", "force", "-", "field", "Hessian", "for", "the", "given", "coordinates", "." ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/examples/003_internal_coordinates/c_ff_hessian.py#L85-L103
train
molmod/molmod
molmod/symmetry.py
compute_rotsym
def compute_rotsym(molecule, graph, threshold=1e-3*angstrom): """Compute the rotational symmetry number Arguments: | ``molecule`` -- The molecule | ``graph`` -- The corresponding bond graph Optional argument: | ``threshold`` -- only when a rotation results in an rmsd be...
python
def compute_rotsym(molecule, graph, threshold=1e-3*angstrom): """Compute the rotational symmetry number Arguments: | ``molecule`` -- The molecule | ``graph`` -- The corresponding bond graph Optional argument: | ``threshold`` -- only when a rotation results in an rmsd be...
[ "def", "compute_rotsym", "(", "molecule", ",", "graph", ",", "threshold", "=", "1e-3", "*", "angstrom", ")", ":", "result", "=", "0", "for", "match", "in", "graph", ".", "symmetries", ":", "permutation", "=", "list", "(", "j", "for", "i", ",", "j", "...
Compute the rotational symmetry number Arguments: | ``molecule`` -- The molecule | ``graph`` -- The corresponding bond graph Optional argument: | ``threshold`` -- only when a rotation results in an rmsd below the given threshold, the rotation is...
[ "Compute", "the", "rotational", "symmetry", "number" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/symmetry.py#L33-L52
train
molmod/molmod
molmod/quaternions.py
quaternion_product
def quaternion_product(quat1, quat2): """Return the quaternion product of the two arguments""" return np.array([ quat1[0]*quat2[0] - np.dot(quat1[1:], quat2[1:]), quat1[0]*quat2[1] + quat2[0]*quat1[1] + quat1[2]*quat2[3] - quat1[3]*quat2[2], quat1[0]*quat2[2] + quat2[0]*quat1[2] + quat1[...
python
def quaternion_product(quat1, quat2): """Return the quaternion product of the two arguments""" return np.array([ quat1[0]*quat2[0] - np.dot(quat1[1:], quat2[1:]), quat1[0]*quat2[1] + quat2[0]*quat1[1] + quat1[2]*quat2[3] - quat1[3]*quat2[2], quat1[0]*quat2[2] + quat2[0]*quat1[2] + quat1[...
[ "def", "quaternion_product", "(", "quat1", ",", "quat2", ")", ":", "return", "np", ".", "array", "(", "[", "quat1", "[", "0", "]", "*", "quat2", "[", "0", "]", "-", "np", ".", "dot", "(", "quat1", "[", "1", ":", "]", ",", "quat2", "[", "1", "...
Return the quaternion product of the two arguments
[ "Return", "the", "quaternion", "product", "of", "the", "two", "arguments" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L40-L47
train
molmod/molmod
molmod/quaternions.py
quaternion_rotation
def quaternion_rotation(quat, vector): """Apply the rotation represented by the quaternion to the vector Warning: This only works correctly for normalized quaternions. """ dp = np.dot(quat[1:], vector) cos = (2*quat[0]*quat[0] - 1) return np.array([ 2 * (quat[0] * (quat[2] * vector[2...
python
def quaternion_rotation(quat, vector): """Apply the rotation represented by the quaternion to the vector Warning: This only works correctly for normalized quaternions. """ dp = np.dot(quat[1:], vector) cos = (2*quat[0]*quat[0] - 1) return np.array([ 2 * (quat[0] * (quat[2] * vector[2...
[ "def", "quaternion_rotation", "(", "quat", ",", "vector", ")", ":", "dp", "=", "np", ".", "dot", "(", "quat", "[", "1", ":", "]", ",", "vector", ")", "cos", "=", "(", "2", "*", "quat", "[", "0", "]", "*", "quat", "[", "0", "]", "-", "1", ")...
Apply the rotation represented by the quaternion to the vector Warning: This only works correctly for normalized quaternions.
[ "Apply", "the", "rotation", "represented", "by", "the", "quaternion", "to", "the", "vector" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L58-L69
train
molmod/molmod
molmod/quaternions.py
rotation_matrix_to_quaternion
def rotation_matrix_to_quaternion(rotation_matrix): """Compute the quaternion representing the rotation given by the matrix""" invert = (np.linalg.det(rotation_matrix) < 0) if invert: factor = -1 else: factor = 1 c2 = 0.25*(factor*np.trace(rotation_matrix) + 1) if c2 < 0: ...
python
def rotation_matrix_to_quaternion(rotation_matrix): """Compute the quaternion representing the rotation given by the matrix""" invert = (np.linalg.det(rotation_matrix) < 0) if invert: factor = -1 else: factor = 1 c2 = 0.25*(factor*np.trace(rotation_matrix) + 1) if c2 < 0: ...
[ "def", "rotation_matrix_to_quaternion", "(", "rotation_matrix", ")", ":", "invert", "=", "(", "np", ".", "linalg", ".", "det", "(", "rotation_matrix", ")", "<", "0", ")", "if", "invert", ":", "factor", "=", "-", "1", "else", ":", "factor", "=", "1", "c...
Compute the quaternion representing the rotation given by the matrix
[ "Compute", "the", "quaternion", "representing", "the", "rotation", "given", "by", "the", "matrix" ]
a7b5b4364ed514ad4c465856c05b5eda1cb561e0
https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/quaternions.py#L74-L98
train