diff --git a/matrepr/__init__.py b/matrepr/__init__.py index 49253a3..0e6edf3 100644 --- a/matrepr/__init__.py +++ b/matrepr/__init__.py @@ -19,10 +19,16 @@ @dataclass class MatReprParams: max_rows: int = 11 - """Maximum number of rows in output.""" + """ + Maximum number of rows in output. + Set to None for unlimited. + """ max_cols: int = 15 - """Maximum number of columns in output.""" + """ + Maximum number of columns in output. + Set to None for unlimited. + """ width_str: int = None """ @@ -140,18 +146,22 @@ def get(self, **kwargs): ret.floatfmt_str = fmt_str ret.floatfmt = lambda f: format(f, fmt_str) - # validate - ret._assert_one_of("cell_align", ['center', 'left', 'right']) - ret.max_rows = max(1, ret.max_rows) - ret.max_cols = max(1, ret.max_cols) - # Apply some default rules + if ret.max_rows is None: + ret.max_rows = 999_999_999 + if ret.max_cols is None: + ret.max_cols = 999_999_999 if ret.title_latex is None: ret.title_latex = ret.title if ret.floatfmt_latex is None: ret.floatfmt_latex = lambda f: python_scientific_to_latex_times10(ret.floatfmt(f)) + # validate + ret._assert_one_of("cell_align", ['center', 'left', 'right']) + ret.max_rows = max(1, ret.max_rows) + ret.max_cols = max(1, ret.max_cols) + # compute automatic values if kwargs.get("auto_width_str", False): if "max_cols" not in kwargs and ret.width_str is None: diff --git a/tests/test_numpy.py b/tests/test_numpy.py index 8588080..65e4df1 100644 --- a/tests/test_numpy.py +++ b/tests/test_numpy.py @@ -47,6 +47,22 @@ def test_contents_html(self): for value in np.nditer(mat): self.assertIn(f">{value}", res) + def test_large_size(self): + mats = [ + np.arange(1000), + np.arange(1000).reshape(25, 40), + ] + + for mat in mats: + res = to_str(mat, max_rows=None, max_cols=None) + self.assertNotIn("...", res) + + res = to_html(mat, max_rows=None, max_cols=None) + self.assertNotIn("dot;", res) + + res = to_latex(mat, max_rows=None, max_cols=None) + self.assertNotIn("dots", res) + if __name__ == '__main__': unittest.main()