MCPcopy Index your code
hub / github.com/pydata/xarray / test_info

Method test_info

xarray/tests/test_dataset.py:437–473  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

435 assert expected == repr(dataset)
436
437 def test_info(self) -> None:
438 ds = create_test_data(seed=123)
439 ds = ds.drop_vars("dim3") # string type prints differently in PY2 vs PY3
440 ds.attrs["unicode_attr"] = "ba®"
441 ds.attrs["string_attr"] = "bar"
442
443 buf = StringIO()
444 ds.info(buf=buf)
445
446 expected = dedent(
447 """\
448 xarray.Dataset {
449 dimensions:
450 \tdim2 = 9 ;
451 \ttime = 20 ;
452 \tdim1 = 8 ;
453 \tdim3 = 10 ;
454
455 variables:
456 \tfloat64 dim2(dim2) ;
457 \tdatetime64[ns] time(time) ;
458 \tfloat64 var1(dim1, dim2) ;
459 \t\tvar1:foo = variable ;
460 \tfloat64 var2(dim1, dim2) ;
461 \t\tvar2:foo = variable ;
462 \tfloat64 var3(dim3, dim1) ;
463 \t\tvar3:foo = variable ;
464 \tint64 numbers(dim3) ;
465
466 // global attributes:
467 \t:unicode_attr = ba® ;
468 \t:string_attr = bar ;
469 }"""
470 )
471 actual = buf.getvalue()
472 assert expected == actual
473 buf.close()
474
475 def test_constructor(self) -> None:
476 x1 = ("x", 2 * np.arange(100))

Callers

nothing calls this directly

Calls 4

create_test_dataFunction · 0.90
infoMethod · 0.80
drop_varsMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected