obspy/obspy — pull request #697 by markcwill (2013-12-18 19:11:03+00:00)
Title: Added BoundedValueType metaclass and tests

@krischer Here is the metaclass I was talking about, added and tested but not implemented into any types yet.

Implementation would be like this:
```python
# Takes the _minimum, _maximum
class Latitude(FloatWithUncertainties):
__metaclass__ = BoundedValueType
_maximum = 90.
_minimum = -90.

# or can set those from the metaclass itself
class Longitude(FloatWithUncertainties):
__metaclass__ = BoundedValueType.set_bounds(-180.,180.)
```
...and enforces on class construction.
```python
In [3]: Latitude(34)
Out[3]: 34.0

In [4]: Latitude(100)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
in ()
----> 1 Latitude(100)

/srv/net/home/markwill/Code/python/obspy/obspy/core/util/obspy_types.py in __call__(self, *args, **kwargs)
310 self._minimum,
311 self._maximum)
--> 312 raise ValueError(msg)
313 return obj
314

ValueError: Latitude must be in [-90.0, 90.0]
```
This would also work if you wanted to enforce positive values on `plusError` and `minusError` uncertainties or something in the future. @megies feel free to reject or kick down the road if you're getting too close to a release to refactor stuff.