mirror of
https://github.com/wassname/greater_tables_project.git
synced 2026-06-27 16:15:38 +08:00
Fixed issue where widths were not integral, adding int() (kludgy)
This commit is contained in:
@@ -11,6 +11,10 @@ Versions and Change Log
|
||||
.. TODO
|
||||
* self.padl and r / 12 in make html width adj s/b elsewhere
|
||||
|
||||
5.4.1 and 5.4.1
|
||||
------------------
|
||||
* Minor bug fixes; tikz method no works for empty dataframe.
|
||||
|
||||
5.4
|
||||
----
|
||||
* Can now pass a namedtuple as df; it is converted to a dataframe.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
__project__ = 'greater_tables'
|
||||
__author__ = 'Stephen J Mildenhall'
|
||||
__version__ = '5.4.1'
|
||||
__version__ = '5.4.2'
|
||||
|
||||
from . core import GT
|
||||
from . fabrications import *
|
||||
|
||||
@@ -281,7 +281,8 @@ class GT(object):
|
||||
|
||||
if len(df) > self.config.large_warning and not self.config.large_ok:
|
||||
raise ValueError(
|
||||
'Large dataframe (>50 rows) and config.large_ok not set to true...do you know what you are doing?')
|
||||
f'Large dataframe (>{self.config.large_warning} rows) and config.large_ok not set to true. '
|
||||
'Set large_ok=True or increase value of large_warning.')
|
||||
|
||||
if not df.columns.is_unique:
|
||||
raise ValueError('df column names are not unique')
|
||||
@@ -1707,7 +1708,7 @@ class GT(object):
|
||||
matrix_name = self.df_id
|
||||
|
||||
# column and tikz display widths
|
||||
colw = self.tex_knowledge_df['tikz_colw'].map(lambda x: np.round(x, 3))
|
||||
colw = self.tex_knowledge_df['tikz_colw'].fillna(0).round(3)
|
||||
tabs = self.tex_knowledge_df['recommended'].map(lambda x: np.round(x, 3))
|
||||
# these are indexed with pre-TeX mangling names
|
||||
# colw.index = df.columns
|
||||
|
||||
@@ -774,6 +774,7 @@ class TextOutput:
|
||||
Formats a single cell, wrapping text and applying padding and alignment.
|
||||
Returns a list of strings, each representing a line of the cell.
|
||||
"""
|
||||
width = int(width)
|
||||
lines = wrap(str(text), width=width) or [""]
|
||||
padded_width = width + 2 * fmt.padding
|
||||
return [
|
||||
@@ -798,7 +799,14 @@ class TextOutput:
|
||||
parts.append(line_fmt.index_sep)
|
||||
elif i > 0:
|
||||
parts.append(line_fmt.sep)
|
||||
parts.append(line_fmt.hline * total)
|
||||
try:
|
||||
parts.append(line_fmt.hline * int(total))
|
||||
except:
|
||||
# print('ERROR')
|
||||
# print(w, fmt.padding)
|
||||
# print(total, type(total))
|
||||
# print(line_fmt.hline)
|
||||
raise
|
||||
return f"{line_fmt.begin}{''.join(parts)}{line_fmt.end}"
|
||||
|
||||
def _make_data_row(row_fmt: DataRow, line_cells: list[str]) -> str:
|
||||
@@ -821,7 +829,7 @@ class TextOutput:
|
||||
"""
|
||||
max_height = max(len(c) for c in wrapped_cells)
|
||||
padded_cells = [
|
||||
[" " * (w + 2 * fmt.padding)] * (max_height - len(cell)) + cell
|
||||
[" " * int(w + 2 * fmt.padding)] * (max_height - len(cell)) + cell
|
||||
for cell, w in zip(wrapped_cells, level_widths)
|
||||
]
|
||||
return [
|
||||
@@ -860,7 +868,7 @@ class TextOutput:
|
||||
]
|
||||
max_height = max(len(c) for c in data_cells)
|
||||
padded = [
|
||||
c + [" " * (w + 2 * fmt.padding)] * (max_height - len(c))
|
||||
c + [" " * int(w + 2 * fmt.padding)] * (max_height - len(c))
|
||||
for c, w in zip(data_cells, data_col_widths)
|
||||
]
|
||||
for i in range(max_height):
|
||||
|
||||
Reference in New Issue
Block a user