Generates an arbitrary mapping from dimension names to lengths. Requires the hypothesis package to be installed. Parameters ---------- dim_names: strategy generating strings, optional Strategy for generating dimension names. Defaults to the `names` strategy.
(
*,
dim_names: st.SearchStrategy[Hashable] = names(), # noqa: B008
min_dims: int = 0,
max_dims: int = 3,
min_side: int = 1,
max_side: int | None = None,
)
| 164 | |
| 165 | |
| 166 | def dimension_sizes( |
| 167 | *, |
| 168 | dim_names: st.SearchStrategy[Hashable] = names(), # noqa: B008 |
| 169 | min_dims: int = 0, |
| 170 | max_dims: int = 3, |
| 171 | min_side: int = 1, |
| 172 | max_side: int | None = None, |
| 173 | ) -> st.SearchStrategy[Mapping[Hashable, int]]: |
| 174 | """ |
| 175 | Generates an arbitrary mapping from dimension names to lengths. |
| 176 | |
| 177 | Requires the hypothesis package to be installed. |
| 178 | |
| 179 | Parameters |
| 180 | ---------- |
| 181 | dim_names: strategy generating strings, optional |
| 182 | Strategy for generating dimension names. |
| 183 | Defaults to the `names` strategy. |
| 184 | min_dims: int, optional |
| 185 | Minimum number of dimensions in generated list. |
| 186 | Default is 1. |
| 187 | max_dims: int, optional |
| 188 | Maximum number of dimensions in generated list. |
| 189 | Default is 3. |
| 190 | min_side: int, optional |
| 191 | Minimum size of a dimension. |
| 192 | Default is 1. |
| 193 | max_side: int, optional |
| 194 | Minimum size of a dimension. |
| 195 | Default is `min_length` + 5. |
| 196 | |
| 197 | See Also |
| 198 | -------- |
| 199 | :ref:`testing.hypothesis`_ |
| 200 | """ |
| 201 | |
| 202 | if max_side is None: |
| 203 | max_side = min_side + 3 |
| 204 | |
| 205 | return st.dictionaries( |
| 206 | keys=dim_names, |
| 207 | values=st.integers(min_value=min_side, max_value=max_side), |
| 208 | min_size=min_dims, |
| 209 | max_size=max_dims, |
| 210 | ) |
| 211 | |
| 212 | |
| 213 | _readable_strings = st.text( |
searching dependent graphs…