Skip to content

Commit

Permalink
Fix unexpected loading after print (#1724)
Browse files Browse the repository at this point in the history
* Added test_ondisk_after_print in backend

* Remove an unintended change.

* remove conditional check. Use repr instead of print
  • Loading branch information
fujiisoup authored and shoyer committed Nov 17, 2017
1 parent 1a01208 commit 6463504
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/whats-new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ Bug fixes
``pandas.MultiIndex`` instead of a simple ``pandas.Index``
(:issue:`1722`). By `Benoit Bovy <https://github.com/benbovy>`_.

- Fixed unexpected memory loading of backend arrays after ``print``.
(:issue:`1720`). By `Keisuke Fujii <https://github.com/fujiisoup>`_.

v0.10.0 rc2 (13 November 2017)
------------------------------
Expand Down
2 changes: 1 addition & 1 deletion xarray/core/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def summarize_variable(name, var, col_width, show_values=True,
front_str = u'%s%s%s ' % (first_col, dims_str, var.dtype)
if show_values:
values_str = format_array_flat(var, max_width - len(front_str))
elif isinstance(var.data, dask_array_type):
elif isinstance(var._data, dask_array_type):
values_str = short_dask_repr(var, show_dtype=False)
else:
values_str = u'...'
Expand Down
7 changes: 7 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,13 @@ def test_dropna(self):
actual = on_disk.dropna(dim='x')
assert_identical(expected, actual)

def test_ondisk_after_print(self):
""" Make sure print does not load file into memory """
in_memory = create_test_data()
with self.roundtrip(in_memory) as on_disk:
repr(on_disk)
assert not on_disk['var1']._in_memory


class CFEncodedDataTest(DatasetIOTestCases):

Expand Down

0 comments on commit 6463504

Please sign in to comment.