repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.click_field | def click_field(self, move_x, move_y):
"""Click one grid by given position."""
field_status = self.info_map[move_y, move_x]
# can only click blank region
if field_status == 11:
if self.mine_map[move_y, move_x] == 1:
self.info_map[move_y, move_x] = 12
... | python | def click_field(self, move_x, move_y):
"""Click one grid by given position."""
field_status = self.info_map[move_y, move_x]
# can only click blank region
if field_status == 11:
if self.mine_map[move_y, move_x] == 1:
self.info_map[move_y, move_x] = 12
... | [
"def",
"click_field",
"(",
"self",
",",
"move_x",
",",
"move_y",
")",
":",
"field_status",
"=",
"self",
".",
"info_map",
"[",
"move_y",
",",
"move_x",
"]",
"# can only click blank region",
"if",
"field_status",
"==",
"11",
":",
"if",
"self",
".",
"mine_map",... | Click one grid by given position. | [
"Click",
"one",
"grid",
"by",
"given",
"position",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L76-L86 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.discover_region | def discover_region(self, move_x, move_y):
"""Discover region from given location."""
field_list = deque([(move_y, move_x)])
while len(field_list) != 0:
field = field_list.popleft()
(tl_idx, br_idx, region_sum) = self.get_region(field[1], field[0])
if region... | python | def discover_region(self, move_x, move_y):
"""Discover region from given location."""
field_list = deque([(move_y, move_x)])
while len(field_list) != 0:
field = field_list.popleft()
(tl_idx, br_idx, region_sum) = self.get_region(field[1], field[0])
if region... | [
"def",
"discover_region",
"(",
"self",
",",
"move_x",
",",
"move_y",
")",
":",
"field_list",
"=",
"deque",
"(",
"[",
"(",
"move_y",
",",
"move_x",
")",
"]",
")",
"while",
"len",
"(",
"field_list",
")",
"!=",
"0",
":",
"field",
"=",
"field_list",
".",... | Discover region from given location. | [
"Discover",
"region",
"from",
"given",
"location",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L88-L109 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.get_region | def get_region(self, move_x, move_y):
"""Get region around a location."""
top_left = (max(move_y-1, 0), max(move_x-1, 0))
bottom_right = (min(move_y+1, self.board_height-1),
min(move_x+1, self.board_width-1))
region_sum = self.mine_map[top_left[0]:bottom_right[0]+... | python | def get_region(self, move_x, move_y):
"""Get region around a location."""
top_left = (max(move_y-1, 0), max(move_x-1, 0))
bottom_right = (min(move_y+1, self.board_height-1),
min(move_x+1, self.board_width-1))
region_sum = self.mine_map[top_left[0]:bottom_right[0]+... | [
"def",
"get_region",
"(",
"self",
",",
"move_x",
",",
"move_y",
")",
":",
"top_left",
"=",
"(",
"max",
"(",
"move_y",
"-",
"1",
",",
"0",
")",
",",
"max",
"(",
"move_x",
"-",
"1",
",",
"0",
")",
")",
"bottom_right",
"=",
"(",
"min",
"(",
"move_... | Get region around a location. | [
"Get",
"region",
"around",
"a",
"location",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L111-L119 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.flag_field | def flag_field(self, move_x, move_y):
"""Flag a grid by given position."""
field_status = self.info_map[move_y, move_x]
# a questioned or undiscovered field
if field_status != 9 and (field_status == 10 or field_status == 11):
self.info_map[move_y, move_x] = 9 | python | def flag_field(self, move_x, move_y):
"""Flag a grid by given position."""
field_status = self.info_map[move_y, move_x]
# a questioned or undiscovered field
if field_status != 9 and (field_status == 10 or field_status == 11):
self.info_map[move_y, move_x] = 9 | [
"def",
"flag_field",
"(",
"self",
",",
"move_x",
",",
"move_y",
")",
":",
"field_status",
"=",
"self",
".",
"info_map",
"[",
"move_y",
",",
"move_x",
"]",
"# a questioned or undiscovered field",
"if",
"field_status",
"!=",
"9",
"and",
"(",
"field_status",
"=="... | Flag a grid by given position. | [
"Flag",
"a",
"grid",
"by",
"given",
"position",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L121-L127 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.unflag_field | def unflag_field(self, move_x, move_y):
"""Unflag or unquestion a grid by given position."""
field_status = self.info_map[move_y, move_x]
if field_status == 9 or field_status == 10:
self.info_map[move_y, move_x] = 11 | python | def unflag_field(self, move_x, move_y):
"""Unflag or unquestion a grid by given position."""
field_status = self.info_map[move_y, move_x]
if field_status == 9 or field_status == 10:
self.info_map[move_y, move_x] = 11 | [
"def",
"unflag_field",
"(",
"self",
",",
"move_x",
",",
"move_y",
")",
":",
"field_status",
"=",
"self",
".",
"info_map",
"[",
"move_y",
",",
"move_x",
"]",
"if",
"field_status",
"==",
"9",
"or",
"field_status",
"==",
"10",
":",
"self",
".",
"info_map",
... | Unflag or unquestion a grid by given position. | [
"Unflag",
"or",
"unquestion",
"a",
"grid",
"by",
"given",
"position",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L129-L134 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.question_field | def question_field(self, move_x, move_y):
"""Question a grid by given position."""
field_status = self.info_map[move_y, move_x]
# a questioned or undiscovered field
if field_status != 10 and (field_status == 9 or field_status == 11):
self.info_map[move_y, move_x] = 10 | python | def question_field(self, move_x, move_y):
"""Question a grid by given position."""
field_status = self.info_map[move_y, move_x]
# a questioned or undiscovered field
if field_status != 10 and (field_status == 9 or field_status == 11):
self.info_map[move_y, move_x] = 10 | [
"def",
"question_field",
"(",
"self",
",",
"move_x",
",",
"move_y",
")",
":",
"field_status",
"=",
"self",
".",
"info_map",
"[",
"move_y",
",",
"move_x",
"]",
"# a questioned or undiscovered field",
"if",
"field_status",
"!=",
"10",
"and",
"(",
"field_status",
... | Question a grid by given position. | [
"Question",
"a",
"grid",
"by",
"given",
"position",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L136-L142 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.check_board | def check_board(self):
"""Check the board status and give feedback."""
num_mines = np.sum(self.info_map == 12)
num_undiscovered = np.sum(self.info_map == 11)
num_questioned = np.sum(self.info_map == 10)
if num_mines > 0:
return 0
elif np.array_equal(self.info... | python | def check_board(self):
"""Check the board status and give feedback."""
num_mines = np.sum(self.info_map == 12)
num_undiscovered = np.sum(self.info_map == 11)
num_questioned = np.sum(self.info_map == 10)
if num_mines > 0:
return 0
elif np.array_equal(self.info... | [
"def",
"check_board",
"(",
"self",
")",
":",
"num_mines",
"=",
"np",
".",
"sum",
"(",
"self",
".",
"info_map",
"==",
"12",
")",
"num_undiscovered",
"=",
"np",
".",
"sum",
"(",
"self",
".",
"info_map",
"==",
"11",
")",
"num_questioned",
"=",
"np",
"."... | Check the board status and give feedback. | [
"Check",
"the",
"board",
"status",
"and",
"give",
"feedback",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L144-L155 |
duguyue100/minesweeper | minesweeper/msboard.py | MSBoard.board_msg | def board_msg(self):
"""Structure a board as in print_board."""
board_str = "s\t\t"
for i in xrange(self.board_width):
board_str += str(i)+"\t"
board_str = board_str.expandtabs(4)+"\n\n"
for i in xrange(self.board_height):
temp_line = str(i)+"\t\t"
... | python | def board_msg(self):
"""Structure a board as in print_board."""
board_str = "s\t\t"
for i in xrange(self.board_width):
board_str += str(i)+"\t"
board_str = board_str.expandtabs(4)+"\n\n"
for i in xrange(self.board_height):
temp_line = str(i)+"\t\t"
... | [
"def",
"board_msg",
"(",
"self",
")",
":",
"board_str",
"=",
"\"s\\t\\t\"",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"board_width",
")",
":",
"board_str",
"+=",
"str",
"(",
"i",
")",
"+",
"\"\\t\"",
"board_str",
"=",
"board_str",
".",
"expandtabs",
... | Structure a board as in print_board. | [
"Structure",
"a",
"board",
"as",
"in",
"print_board",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/msboard.py#L161-L183 |
earlzo/hfut | hfut/log.py | report_response | def report_response(response,
request_headers=True, request_body=True,
response_headers=False, response_body=False,
redirection=False):
"""
生成响应报告
:param response: ``requests.models.Response`` 对象
:param request_headers: 是否加入请求头
:param requ... | python | def report_response(response,
request_headers=True, request_body=True,
response_headers=False, response_body=False,
redirection=False):
"""
生成响应报告
:param response: ``requests.models.Response`` 对象
:param request_headers: 是否加入请求头
:param requ... | [
"def",
"report_response",
"(",
"response",
",",
"request_headers",
"=",
"True",
",",
"request_body",
"=",
"True",
",",
"response_headers",
"=",
"False",
",",
"response_body",
"=",
"False",
",",
"redirection",
"=",
"False",
")",
":",
"# https://docs.python.org/3/li... | 生成响应报告
:param response: ``requests.models.Response`` 对象
:param request_headers: 是否加入请求头
:param request_body: 是否加入请求体
:param response_headers: 是否加入响应头
:param response_body: 是否加入响应体
:param redirection: 是否加入重定向响应
:return: str | [
"生成响应报告"
] | train | https://github.com/earlzo/hfut/blob/09270a9647fba79f26fd1a8a3c53c0678b5257a1/hfut/log.py#L20-L67 |
duguyue100/minesweeper | minesweeper/gui.py | ControlWidget.init_ui | def init_ui(self):
"""Setup control widget UI."""
self.control_layout = QHBoxLayout()
self.setLayout(self.control_layout)
self.reset_button = QPushButton()
self.reset_button.setFixedSize(40, 40)
self.reset_button.setIcon(QtGui.QIcon(WIN_PATH))
self.game_timer = QL... | python | def init_ui(self):
"""Setup control widget UI."""
self.control_layout = QHBoxLayout()
self.setLayout(self.control_layout)
self.reset_button = QPushButton()
self.reset_button.setFixedSize(40, 40)
self.reset_button.setIcon(QtGui.QIcon(WIN_PATH))
self.game_timer = QL... | [
"def",
"init_ui",
"(",
"self",
")",
":",
"self",
".",
"control_layout",
"=",
"QHBoxLayout",
"(",
")",
"self",
".",
"setLayout",
"(",
"self",
".",
"control_layout",
")",
"self",
".",
"reset_button",
"=",
"QPushButton",
"(",
")",
"self",
".",
"reset_button",... | Setup control widget UI. | [
"Setup",
"control",
"widget",
"UI",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L46-L62 |
duguyue100/minesweeper | minesweeper/gui.py | GameWidget.init_ui | def init_ui(self):
"""Init game interface."""
board_width = self.ms_game.board_width
board_height = self.ms_game.board_height
self.create_grid(board_width, board_height)
self.time = 0
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.timing_game)
... | python | def init_ui(self):
"""Init game interface."""
board_width = self.ms_game.board_width
board_height = self.ms_game.board_height
self.create_grid(board_width, board_height)
self.time = 0
self.timer = QtCore.QTimer()
self.timer.timeout.connect(self.timing_game)
... | [
"def",
"init_ui",
"(",
"self",
")",
":",
"board_width",
"=",
"self",
".",
"ms_game",
".",
"board_width",
"board_height",
"=",
"self",
".",
"ms_game",
".",
"board_height",
"self",
".",
"create_grid",
"(",
"board_width",
",",
"board_height",
")",
"self",
".",
... | Init game interface. | [
"Init",
"game",
"interface",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L76-L84 |
duguyue100/minesweeper | minesweeper/gui.py | GameWidget.create_grid | def create_grid(self, grid_width, grid_height):
"""Create a grid layout with stacked widgets.
Parameters
----------
grid_width : int
the width of the grid
grid_height : int
the height of the grid
"""
self.grid_layout = QGridLayout()
... | python | def create_grid(self, grid_width, grid_height):
"""Create a grid layout with stacked widgets.
Parameters
----------
grid_width : int
the width of the grid
grid_height : int
the height of the grid
"""
self.grid_layout = QGridLayout()
... | [
"def",
"create_grid",
"(",
"self",
",",
"grid_width",
",",
"grid_height",
")",
":",
"self",
".",
"grid_layout",
"=",
"QGridLayout",
"(",
")",
"self",
".",
"setLayout",
"(",
"self",
".",
"grid_layout",
")",
"self",
".",
"grid_layout",
".",
"setSpacing",
"("... | Create a grid layout with stacked widgets.
Parameters
----------
grid_width : int
the width of the grid
grid_height : int
the height of the grid | [
"Create",
"a",
"grid",
"layout",
"with",
"stacked",
"widgets",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L86-L103 |
duguyue100/minesweeper | minesweeper/gui.py | GameWidget.timing_game | def timing_game(self):
"""Timing game."""
self.ctrl_wg.game_timer.display(self.time)
self.time += 1 | python | def timing_game(self):
"""Timing game."""
self.ctrl_wg.game_timer.display(self.time)
self.time += 1 | [
"def",
"timing_game",
"(",
"self",
")",
":",
"self",
".",
"ctrl_wg",
".",
"game_timer",
".",
"display",
"(",
"self",
".",
"time",
")",
"self",
".",
"time",
"+=",
"1"
] | Timing game. | [
"Timing",
"game",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L105-L108 |
duguyue100/minesweeper | minesweeper/gui.py | GameWidget.reset_game | def reset_game(self):
"""Reset game board."""
self.ms_game.reset_game()
self.update_grid()
self.time = 0
self.timer.start(1000) | python | def reset_game(self):
"""Reset game board."""
self.ms_game.reset_game()
self.update_grid()
self.time = 0
self.timer.start(1000) | [
"def",
"reset_game",
"(",
"self",
")",
":",
"self",
".",
"ms_game",
".",
"reset_game",
"(",
")",
"self",
".",
"update_grid",
"(",
")",
"self",
".",
"time",
"=",
"0",
"self",
".",
"timer",
".",
"start",
"(",
"1000",
")"
] | Reset game board. | [
"Reset",
"game",
"board",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L110-L115 |
duguyue100/minesweeper | minesweeper/gui.py | GameWidget.update_grid | def update_grid(self):
"""Update grid according to info map."""
info_map = self.ms_game.get_info_map()
for i in xrange(self.ms_game.board_height):
for j in xrange(self.ms_game.board_width):
self.grid_wgs[(i, j)].info_label(info_map[i, j])
self.ctrl_wg.move_co... | python | def update_grid(self):
"""Update grid according to info map."""
info_map = self.ms_game.get_info_map()
for i in xrange(self.ms_game.board_height):
for j in xrange(self.ms_game.board_width):
self.grid_wgs[(i, j)].info_label(info_map[i, j])
self.ctrl_wg.move_co... | [
"def",
"update_grid",
"(",
"self",
")",
":",
"info_map",
"=",
"self",
".",
"ms_game",
".",
"get_info_map",
"(",
")",
"for",
"i",
"in",
"xrange",
"(",
"self",
".",
"ms_game",
".",
"board_height",
")",
":",
"for",
"j",
"in",
"xrange",
"(",
"self",
".",... | Update grid according to info map. | [
"Update",
"grid",
"according",
"to",
"info",
"map",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L117-L132 |
duguyue100/minesweeper | minesweeper/gui.py | FieldWidget.init_ui | def init_ui(self):
"""Init the ui."""
self.id = 11
self.setFixedSize(self.field_width, self.field_height)
self.setPixmap(QtGui.QPixmap(EMPTY_PATH).scaled(
self.field_width*3, self.field_height*3))
self.setStyleSheet("QLabel {background-color: blue;}") | python | def init_ui(self):
"""Init the ui."""
self.id = 11
self.setFixedSize(self.field_width, self.field_height)
self.setPixmap(QtGui.QPixmap(EMPTY_PATH).scaled(
self.field_width*3, self.field_height*3))
self.setStyleSheet("QLabel {background-color: blue;}") | [
"def",
"init_ui",
"(",
"self",
")",
":",
"self",
".",
"id",
"=",
"11",
"self",
".",
"setFixedSize",
"(",
"self",
".",
"field_width",
",",
"self",
".",
"field_height",
")",
"self",
".",
"setPixmap",
"(",
"QtGui",
".",
"QPixmap",
"(",
"EMPTY_PATH",
")",
... | Init the ui. | [
"Init",
"the",
"ui",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L147-L153 |
duguyue100/minesweeper | minesweeper/gui.py | FieldWidget.mousePressEvent | def mousePressEvent(self, event):
"""Define mouse press event."""
if event.button() == QtCore.Qt.LeftButton:
# get label position
p_wg = self.parent()
p_layout = p_wg.layout()
idx = p_layout.indexOf(self)
loc = p_layout.getItemPosition(idx)[:2]... | python | def mousePressEvent(self, event):
"""Define mouse press event."""
if event.button() == QtCore.Qt.LeftButton:
# get label position
p_wg = self.parent()
p_layout = p_wg.layout()
idx = p_layout.indexOf(self)
loc = p_layout.getItemPosition(idx)[:2]... | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"event",
".",
"button",
"(",
")",
"==",
"QtCore",
".",
"Qt",
".",
"LeftButton",
":",
"# get label position",
"p_wg",
"=",
"self",
".",
"parent",
"(",
")",
"p_layout",
"=",
"p_wg",
"."... | Define mouse press event. | [
"Define",
"mouse",
"press",
"event",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L155-L183 |
duguyue100/minesweeper | minesweeper/gui.py | FieldWidget.info_label | def info_label(self, indicator):
"""Set info label by given settings.
Parameters
----------
indicator : int
A number where
0-8 is number of mines in srrounding.
12 is a mine field.
"""
if indicator in xrange(1, 9):
self.id ... | python | def info_label(self, indicator):
"""Set info label by given settings.
Parameters
----------
indicator : int
A number where
0-8 is number of mines in srrounding.
12 is a mine field.
"""
if indicator in xrange(1, 9):
self.id ... | [
"def",
"info_label",
"(",
"self",
",",
"indicator",
")",
":",
"if",
"indicator",
"in",
"xrange",
"(",
"1",
",",
"9",
")",
":",
"self",
".",
"id",
"=",
"indicator",
"self",
".",
"setPixmap",
"(",
"QtGui",
".",
"QPixmap",
"(",
"NUMBER_PATHS",
"[",
"ind... | Set info label by given settings.
Parameters
----------
indicator : int
A number where
0-8 is number of mines in srrounding.
12 is a mine field. | [
"Set",
"info",
"label",
"by",
"given",
"settings",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L185-L222 |
duguyue100/minesweeper | minesweeper/gui.py | RemoteControlThread.run | def run(self):
"""Thread behavior."""
self.ms_game.tcp_accept()
while True:
data = self.ms_game.tcp_receive()
if data == "help\n":
self.ms_game.tcp_help()
self.ms_game.tcp_send("> ")
elif data == "exit\n":
self... | python | def run(self):
"""Thread behavior."""
self.ms_game.tcp_accept()
while True:
data = self.ms_game.tcp_receive()
if data == "help\n":
self.ms_game.tcp_help()
self.ms_game.tcp_send("> ")
elif data == "exit\n":
self... | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"ms_game",
".",
"tcp_accept",
"(",
")",
"while",
"True",
":",
"data",
"=",
"self",
".",
"ms_game",
".",
"tcp_receive",
"(",
")",
"if",
"data",
"==",
"\"help\\n\"",
":",
"self",
".",
"ms_game",
".",
... | Thread behavior. | [
"Thread",
"behavior",
"."
] | train | https://github.com/duguyue100/minesweeper/blob/38b1910f4c34d0275ac10a300285aba6f1d91d61/minesweeper/gui.py#L246-L272 |
sassoftware/epdb | epdb/epdb_nose.py | Epdb.options | def options(self, parser, env):
"""Register commandline options.
"""
parser.add_option(
"--epdb", action="store_true", dest="epdb_debugErrors",
default=env.get('NOSE_EPDB', False),
help="Drop into extended debugger on errors")
parser.add_option(
... | python | def options(self, parser, env):
"""Register commandline options.
"""
parser.add_option(
"--epdb", action="store_true", dest="epdb_debugErrors",
default=env.get('NOSE_EPDB', False),
help="Drop into extended debugger on errors")
parser.add_option(
... | [
"def",
"options",
"(",
"self",
",",
"parser",
",",
"env",
")",
":",
"parser",
".",
"add_option",
"(",
"\"--epdb\"",
",",
"action",
"=",
"\"store_true\"",
",",
"dest",
"=",
"\"epdb_debugErrors\"",
",",
"default",
"=",
"env",
".",
"get",
"(",
"'NOSE_EPDB'",
... | Register commandline options. | [
"Register",
"commandline",
"options",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_nose.py#L48-L59 |
sassoftware/epdb | epdb/epdb_nose.py | Epdb.configure | def configure(self, options, conf):
"""Configure which kinds of exceptions trigger plugin.
"""
self.conf = conf
self.enabled = options.epdb_debugErrors or options.epdb_debugFailures
self.enabled_for_errors = options.epdb_debugErrors
self.enabled_for_failures = options.epd... | python | def configure(self, options, conf):
"""Configure which kinds of exceptions trigger plugin.
"""
self.conf = conf
self.enabled = options.epdb_debugErrors or options.epdb_debugFailures
self.enabled_for_errors = options.epdb_debugErrors
self.enabled_for_failures = options.epd... | [
"def",
"configure",
"(",
"self",
",",
"options",
",",
"conf",
")",
":",
"self",
".",
"conf",
"=",
"conf",
"self",
".",
"enabled",
"=",
"options",
".",
"epdb_debugErrors",
"or",
"options",
".",
"epdb_debugFailures",
"self",
".",
"enabled_for_errors",
"=",
"... | Configure which kinds of exceptions trigger plugin. | [
"Configure",
"which",
"kinds",
"of",
"exceptions",
"trigger",
"plugin",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_nose.py#L61-L67 |
sassoftware/epdb | epdb/__init__.py | set_trace_cond | def set_trace_cond(*args, **kw):
""" Sets a condition for set_trace statements that have the
specified marker. A condition can 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 ... | python | def set_trace_cond(*args, **kw):
""" Sets a condition for set_trace statements that have the
specified marker. A condition can 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 ... | [
"def",
"set_trace_cond",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"for",
"key",
",",
"val",
"in",
"kw",
".",
"items",
"(",
")",
":",
"Epdb",
".",
"set_trace_cond",
"(",
"key",
",",
"val",
")",
"for",
"arg",
"in",
"args",
":",
"Epdb",
".... | Sets a condition for set_trace statements that have the
specified marker. A condition can 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
only be calle... | [
"Sets",
"a",
"condition",
"for",
"set_trace",
"statements",
"that",
"have",
"the",
"specified",
"marker",
".",
"A",
"condition",
"can",
"either",
"callable",
"in",
"which",
"case",
"it",
"should",
"take",
"one",
"argument",
"which",
"is",
"the",
"number",
"o... | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L1043-L1054 |
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",
... | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L1094-L1132 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L359-L386 |
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... | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L847-L856 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L897-L909 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L912-L916 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L922-L924 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/__init__.py#L926-L929 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/formattrace.py#L211-L223 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L73-L102 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L104-L118 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L133-L144 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L221-L242 |
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",
"."
] | train | https://github.com/sassoftware/epdb/blob/5a8375aa59862d787e6496810a508297a5522967/epdb/epdb_server.py#L244-L262 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L7-L32 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L35-L55 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/input.py#L57-L76 |
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",
"."
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/__main__.py#L36-L181 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L20-L143 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L146-L208 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L262-L299 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L492-L507 |
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"
] | train | https://github.com/matthew-sochor/transfer/blob/c1931a16459275faa7a5e9860fbed079a4848b80/transfer/project.py#L510-L540 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L487-L497 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L66-L73 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L85-L176 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L179-L189 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L251-L255 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L257-L264 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L266-L273 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L275-L296 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L298-L341 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L578-L603 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/molecular_graphs.py#L605-L640 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L68-L75 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L81-L86 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L103-L109 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L120-L137 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L139-L153 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L198-L209 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L211-L221 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L223-L248 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L250-L258 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/number_state.py#L260-L325 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L89-L126 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L128-L139 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L142-L174 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/bonds.py#L176-L192 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L84-L125 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L128-L147 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L150-L159 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L162-L179 |
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",
")"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L182-L193 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L196-L200 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L203-L218 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L239-L246 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L288-L317 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L319-L339 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/unit_cells.py#L341-L376 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/toyff.py#L43-L104 |
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",
"."
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/toyff.py#L107-L154 |
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",
")"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L67-L89 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L103-L111 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L113-L120 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L122-L127 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L129-L162 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L164-L170 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L202-L219 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L221-L238 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L240-L257 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L282-L287 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L315-L320 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L344-L348 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L350-L354 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L425-L430 |
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",
"))"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/pairff.py#L432-L437 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L149-L163 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L166-L195 |
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"
] | train | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/io/cml.py#L198-L216 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.