Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _full_single_property_comp_table(self, property: str = None) -> '_Table':
header_cells = []
for single in self.stats.singles:
_single = SingleProperty(single, single.rundata, property) if property is not None else single
modal_id = self._short_summary_modal(_single)
header_cells.append(_Cell(self, content=self._obj_description(single), color_class_obj=single,
modal_id=modal_id))
table = _Table(self, header_cells, header_cells, _Cell(self, "vs."))
for i in range(self.stats.number_of_singles()):
for j in range(self.stats.number_of_singles()):
if i == j:
table[i, j] = _Cell(self)
continue
popover = _Popover(self, "Explanation", content="")
cell = None
pair = self.stats.get_pair(i, j)
rel_diff = None
if property is None:
popover.content = r"""
Geometric mean of the first means relative to the second means:
\[\sqrt[\|properties\|]{
\prod_{p \in \text{properties}}
\frac{\overline{\text{first[p]}}}{
\overline{\text{second[p]}}}}\]
<p>Using the more widely known arithmetic mean would be like
<a href="http://ece.uprm.edu/~nayda/Courses/Icom6115F06/Papers/paper4.pdf?origin=publication_detail">
lying</a>.</p>
<p>The geometric standard deviation is <b>%s</b></p>.
def _full_single_property_comp_table(self, property: str = None) -> '_Table':
header_cells = []
for single in self.stats.singles:
_single = SingleProperty(single, single.rundata, property) if property is not None else single
modal_id = self._short_summary_modal(_single)
header_cells.append(_Cell(self, content=self._obj_description(single), color_class_obj=single,
modal_id=modal_id))
table = _Table(self, header_cells, header_cells, _Cell(self, "vs."))
for i in range(self.stats.number_of_singles()):
for j in range(self.stats.number_of_singles()):
if i == j:
table[i, j] = _Cell(self)
continue
popover = _Popover(self, "Explanation", content="")
cell = None
pair = self.stats.get_pair(i, j)
rel_diff = None
if property is None:
popover.content = r"""
Geometric mean of the first means relative to the second means:
\[\sqrt[\|properties\|]{
\prod_{p \in \text{properties}}
\frac{\overline{\text{first[p]}}}{
content = str(elem)
elif isinstance(elem, BaseStatObject):
content = parent._obj_description(elem)
else:
assert False
if isinstance(elem, BaseStatObject):
color_obj = elem
if header_color_obj_func:
color_obj = header_color_obj_func(elem, index, header_row)
modal_id = call(header_modal_func)
popover = call(header_popover_func)
link = None
if header_link_func and header_link_func(elem, index, header_row):
assert not modal_id # modal and link can't be used together in the same cell
link = header_link_func(elem, index, header_row)
return _Cell(parent, content, popover=popover, modal_id=modal_id, color_class_obj=color_obj, is_header_cell=True,
cell_scope="row" if header_row else None, link=link)
header_row = []
:param header_row: list of cells of the bold top header row
:param header_col: list of cells of the bold left header collumn
:param anchor_cell: the cell in the top left corner of the table
:param content_cells: a list of content rows
:return: resulting html
"""
self.parent = parent
self.header_row = header_row
self.header_col = header_col
for cell in itertools.chain(self.header_row, self.header_col):
cell.is_header_cell = True
for cell in self.header_col:
cell.cell_scope = "row"
assert len(header_row) > 0
self.orig_anchor_cell = _Cell(self.parent, "") if anchor_cell is None else _Cell(self.parent, anchor_cell.content)
self.anchor_cell = anchor_cell or _Cell(self.parent, "⍗ ")
self.anchor_cell.content += " ⍗"
self.anchor_cell.cell_class += " anchor_cell "
self.height = len(header_col)
""" Number of content (non header) rows """
self.width = len(header_row)
""" Number of content (non header) columns """
if content_cells:
assert len(content_cells) == self.height and len(content_cells[0]) == self.width \
and all(len(content_cells[0]) == len(row) for row in content_cells)
self.content_cells = content_cells
else:
self.content_cells = [[_Cell(self.parent) for i in range(self.width)] for j in range(self.height)]
cell.cell_scope = "row"
assert len(header_row) > 0
self.orig_anchor_cell = _Cell(self.parent, "") if anchor_cell is None else _Cell(self.parent, anchor_cell.content)
self.anchor_cell = anchor_cell or _Cell(self.parent, "⍗ ")
self.anchor_cell.content += " ⍗"
self.anchor_cell.cell_class += " anchor_cell "
self.height = len(header_col)
""" Number of content (non header) rows """
self.width = len(header_row)
""" Number of content (non header) columns """
if content_cells:
assert len(content_cells) == self.height and len(content_cells[0]) == self.width \
and all(len(content_cells[0]) == len(row) for row in content_cells)
self.content_cells = content_cells
else:
self.content_cells = [[_Cell(self.parent) for i in range(self.width)] for j in range(self.height)]
def convert_cc(row_header: T1, col_header: T2, row: int, col: int) -> _Cell:
def call(func: t.Optional[t.Callable[[T1, T2, int, int], t.T]]) -> t.T:
if func:
return func(row_header, col_header, row, col)
return None
content = str(content_func(row_header, col_header, row, col))
color_obj = call(content_color_obj_func)
modal_id = call(content_modal_func)
popover = call(content_popover_func)
link = call(content_link_func)
assert None in [link, modal_id]
return _Cell(parent, content, popover=popover, modal_id=modal_id, color_class_obj=color_obj, link=link)
content_cells = []
return obj_descrs[index]
return tested_per_prop[index]["title"]
func_titles = list(map(lambda d: d["title"], tested_per_prop))
rows = []
cols = []
if objs_in_cols:
cols = objs
rows = func_titles
else:
cols = func_titles
rows = objs
table = _Table.from_content_func(self, rows=rows,
cols=cols,
header_link_func=header_link_func,
content_func=content_func, anchor_cell=_Cell(self),
header_color_obj_func=header_color_obj,
header_content_func=header_content_func,
header_modal_func=header_modal_func,
header_popover_func=header_popover_func)
return str(table)