diff --git a/changelog/467.performance.rst b/changelog/467.performance.rst new file mode 100644 index 00000000..cae5f1e0 --- /dev/null +++ b/changelog/467.performance.rst @@ -0,0 +1 @@ +Improve the performance of the ``TiledDataset`` ``repr`` and ``str``. diff --git a/changelog/475.trivial.rst b/changelog/475.trivial.rst new file mode 100644 index 00000000..8aeee1fa --- /dev/null +++ b/changelog/475.trivial.rst @@ -0,0 +1 @@ +Fix small bug which caused `ds.flat` to break if not indexed. diff --git a/changelog/479.bugfix.rst b/changelog/479.bugfix.rst new file mode 100644 index 00000000..19d1eb1e --- /dev/null +++ b/changelog/479.bugfix.rst @@ -0,0 +1 @@ +Fix some small issues with `Dataset.__repr__`. diff --git a/changelog/README.rst b/changelog/README.rst index 766d10d9..14d82bfb 100644 --- a/changelog/README.rst +++ b/changelog/README.rst @@ -21,6 +21,7 @@ Each file should be named like ``..rst``, where ``" + return repr(array) + + def dataset_info_str(ds_in): - # Check for an attribute that only appears on TiledDataset - # Not using isinstance to avoid circular import - is_tiled = hasattr(ds_in, "combined_headers") + # Import here to remove circular import + from dkist.dataset import TiledDataset + is_tiled = isinstance(ds_in, TiledDataset) dstype = type(ds_in).__name__ if is_tiled: tile_shape = ds_in.shape - ds = ds_in[0, 0] + ds = ds_in.flat[0] else: ds = ds_in wcs = ds.wcs.low_level_wcs @@ -48,7 +59,7 @@ def dataset_info_str(ds_in): s += "\nThis " s += f"Dataset has {wcs.pixel_n_dim} pixel and {wcs.world_n_dim} world dimensions.\n\n" - s += f"The data are represented by a {type(ds.data)} object:\n{ds.data}\n\n" + s += f"The data are represented by a {type(ds.data)} object:\n{get_array_repr(ds.data)}\n\n" array_shape = wcs.array_shape or (0,) pixel_shape = wcs.pixel_shape or (None,) * wcs.pixel_n_dim @@ -139,7 +150,7 @@ def _get_pp_matrix(wcs): world.insert(0, "") mstr = np.insert(mstr, 0, world, axis=1) widths = [np.max([len(a) for a in col]) for col in mstr.T] - mstr = np.insert(mstr, 2, ["-"*wid for wid in widths], axis=0) + mstr = np.insert(mstr, header.shape[0], ["-"*wid for wid in widths], axis=0) for i, col in enumerate(mstr.T): if i == 0: mstr[:, i] = np.char.rjust(col, widths[i]) diff --git a/pyproject.toml b/pyproject.toml index c6a0812f..79a421da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -173,3 +173,8 @@ write_to = "dkist/_version.py" directory = "trivial" name = "Trivial/Internal Changes" showcontent = true + + [[tool.towncrier.type]] + directory = "performance" + name = "Performance Improvements" + showcontent = true