blaze / datashape

Language defining a data description protocol
BSD 2-Clause "Simplified" License
183 stars 65 forks source link

DataShape Pretty Printing #113

Closed mrocklin closed 9 years ago

mrocklin commented 9 years ago

A pretty print function

In [30]: ds = dshape('5000000000 * {a: (int, float32, real, string, datetime), b: {c: 5 * int, d: var * 100 * float32}}')

In [31]: print pprint(ds)
5000000000 * {
  a: (int32, float32, float64, string, datetime),
  b: {c: 5 * int32, d: var * 100 * float32}
  }

In [32]: print pprint(ds, width=30)
5000000000 * {
  a: (
    int32,
    float32,
    float64,
    string,
    datetime
    ),
  b: {
    c: 5 * int32,
    d: var * 100 * float32
    }
  }

This is also hooked up to __repr__

In [3]: ds
Out[3]: 
dshape("""5000000000 * {
  a: (int32, float32, float64, string, datetime),
  b: {c: 5 * int32, d: var * 100 * float32}
  }""")
cpcloud commented 9 years ago

+1