The extent submodule
The extent submodule defines the Extent class to track the extent of a particular variable across a dataset. It is designed to track the extents required by GEMINI 2: latitude, longitude and date, but the implementation is general. Values are fed to a class instance using the update method, which adjusts the extent as necessary.
Typical usage:
```python
ext = Extent('latitude', (int, float), hard_bounds=(-90, 90))
ext.update([1,2,3,4,5,6])
```
Extent
Track the extent of data.
An Extent instance is created by providing a datatype and optionally any hard and soft bounds to be applied. When an Extent instance is updated, values outside hard bounds will generate an error in logging and values outside soft bounds will log a warning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
A label for the extent, used in reporting |
required |
datatype
|
tuple[type, ...]
|
A type or tuple of types for input checking |
required |
hard_bounds
|
tuple | None
|
A 2 tuple of hard bounds |
None
|
soft_bounds
|
tuple | None
|
A 2 tuple of soft bounds |
None
|
Source code in safedata_validator/extent.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
__repr__()
Provide a simple representation of the class.
Source code in safedata_validator/extent.py
72 73 74 | |
datatype
property
Returns the data types accepted by the Extent object.
extent
property
Returns a tuple showing the current extent.
hard_bounds
property
Returns a tuple showing the hard bounds of the Extent object.
populated
property
Returns a boolean showing if the extent has been populated.
soft_bounds
property
Returns a tuple showing the hard bounds of the Extent object.
update(values)
Update extent of instance based on values contained in an iterable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Iterable
|
An iterable of values, which should all be of the datatype(s) specified when creating the Extent instance. |
required |
Source code in safedata_validator/extent.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |