Skip to content

Commit 6463504

Browse files
fujiisoupshoyer
authored andcommitted
Fix unexpected loading after print (#1724)
* Added test_ondisk_after_print in backend * Remove an unintended change. * remove conditional check. Use repr instead of print
1 parent 1a01208 commit 6463504

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

doc/whats-new.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ Bug fixes
2727
``pandas.MultiIndex`` instead of a simple ``pandas.Index``
2828
(:issue:`1722`). By `Benoit Bovy <https://github.com/benbovy>`_.
2929

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

3133
v0.10.0 rc2 (13 November 2017)
3234
------------------------------

xarray/core/formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def summarize_variable(name, var, col_width, show_values=True,
209209
front_str = u'%s%s%s ' % (first_col, dims_str, var.dtype)
210210
if show_values:
211211
values_str = format_array_flat(var, max_width - len(front_str))
212-
elif isinstance(var.data, dask_array_type):
212+
elif isinstance(var._data, dask_array_type):
213213
values_str = short_dask_repr(var, show_dtype=False)
214214
else:
215215
values_str = u'...'

xarray/tests/test_backends.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,13 @@ def test_dropna(self):
492492
actual = on_disk.dropna(dim='x')
493493
assert_identical(expected, actual)
494494

495+
def test_ondisk_after_print(self):
496+
""" Make sure print does not load file into memory """
497+
in_memory = create_test_data()
498+
with self.roundtrip(in_memory) as on_disk:
499+
repr(on_disk)
500+
assert not on_disk['var1']._in_memory
501+
495502

496503
class CFEncodedDataTest(DatasetIOTestCases):
497504

0 commit comments

Comments
 (0)