3
3
import numpy as np
4
4
5
5
6
- # vendored from xarray.core.formatting
7
- # https://github.com/pydata/xarray/blob/v0.16.0/xarray/core/formatting.py#L18-216
8
- def pretty_print (x , numchars : int ):
9
- """Given an object `x`, call `str(x)` and format the returned string so
10
- that it is numchars long, padding with trailing spaces or truncating with
11
- ellipses as necessary
12
- """
13
- s = maybe_truncate (x , numchars )
14
- return s + " " * max (numchars - len (s ), 0 )
15
-
16
-
17
6
# vendored from xarray.core.formatting
18
7
def maybe_truncate (obj , maxlen = 500 ):
19
8
s = str (obj )
@@ -22,14 +11,6 @@ def maybe_truncate(obj, maxlen=500):
22
11
return s
23
12
24
13
25
- # vendored from xarray.core.formatting
26
- def wrap_indent (text , start = "" , length = None ):
27
- if length is None :
28
- length = len (start )
29
- indent = "\n " + " " * length
30
- return start + indent .join (x for x in text .splitlines ())
31
-
32
-
33
14
# vendored from xarray.core.formatting
34
15
def _get_indexer_at_least_n_items (shape , n_desired , from_end ):
35
16
assert 0 < n_desired <= np .prod (shape )
@@ -80,17 +61,6 @@ def last_n_items(array, n_desired):
80
61
return np .asarray (array ).flat [- n_desired :]
81
62
82
63
83
- # vendored from xarray.core.formatting
84
- def last_item (array ):
85
- """Returns the last item of an array in a list or an empty list."""
86
- if array .size == 0 :
87
- # work around for https://github.com/numpy/numpy/issues/5195
88
- return []
89
-
90
- indexer = (slice (- 1 , None ),) * array .ndim
91
- return np .ravel (np .asarray (array [indexer ])).tolist ()
92
-
93
-
94
64
# based on xarray.core.formatting.format_item
95
65
def format_item (x , quote_strings = True ):
96
66
"""Returns a succinct summary of an object as a string"""
0 commit comments