Skip to content

Commit

Permalink
Merge pull request #15 from SylvainCorlay/usage_example
Browse files Browse the repository at this point in the history
Improve Usage Example
  • Loading branch information
SylvainCorlay committed Sep 23, 2016
2 parents 4c8aed8 + 9494e14 commit f38a372
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
Usage
=====

The ``Array`` trait type provide an implementation of a trait type for the numpy array.
Example: Validating the Shape of a Numpy Array
----------------------------------------------

``Array`` overrides certain public methods from ``TraitType`` that are generally not
overloaded by custom trait types, in order to work around some limitations with
numpy array comparison.

``Array`` provides an API for adding custom validators to constained proposed values for the attribute.
We pass a validation function to the ``valid`` method of the ``Array`` trait type.

In this example, the validation function is returned by the ``shape`` closure which stores
the tuple in its closure.

.. code::
Expand All @@ -28,4 +27,3 @@ The ``Array`` trait type provide an implementation of a trait type for the numpy
foo = Foo()
foo.bar = [1, 2] # Should raise a TraitError

0 comments on commit f38a372

Please sign in to comment.