Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions xarray/tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,14 @@ 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:
if not on_disk['var1']._in_memory:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we write this without the conditional check? It's usually best to avoid control flow in tests -- it makes it more obvious what is going on.

print(on_disk)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just call repr(on_disk) to avoid actually printing to stdout.

assert not on_disk['var1']._in_memory


class CFEncodedDataTest(DatasetIOTestCases):

Expand Down