ContinuumIO/datashape — pull request #44 by mrocklin (2014-04-15 14:25:50+00:00)
Title: Validate

Builds on #43

This adds abstract operations `validate` and `issubschema`. It builds these using [`multipledispatch`](github.com/mrocklin/multipledispatch).

```Python

In [1]: from datashape import *

In [2]: validate('2 * int', [1, 2])
Out[2]: True

In [3]: validate('3 * int', (1, 2))
Out[3]: False

In [4]: validate('2 * float32', (1, 2))
Out[4]: False

In [5]: from datetime import date
In [6]: validate('{name: string, arrived: date}', {'name': 'Alice', 'arrived': date(2012, 01, 05)})
Out[6]: True

In [7]: import numpy as np
In [8]: validate('2 * 2 * float64', np.array([[1, 1], [2, 2]], dtype=np.float64) ...: )
Out[8]: True
```

The use of `multipledispatch` is controversial. It's a small library maintained by me that, while it has some excitement around it, isn't used by the community. It is a great match for this problem though. If we do this then I'll want to extend the `validate` operation to dynd and blaze arrays/ddescs in those codebases.