File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
import builtins
2
- from typing import Any
2
+ import functools
3
+ import random
4
+ from collections .abc import Callable
5
+ from typing import Any , TypeVar , cast
3
6
4
7
import hypothesis .extra .numpy as npst
5
8
import hypothesis .strategies as st
34
37
35
38
MAX_BINARY_SIZE = 100
36
39
40
+ F = TypeVar ("F" , bound = Callable [..., Any ])
41
+
42
+
43
+ def with_frequency (frequency : float ) -> Callable [[F ], F ]:
44
+ def decorator (func : F ) -> F :
45
+ @functools .wraps (func )
46
+ def wrapper (* args : Any , ** kwargs : Any ) -> Any :
47
+ return func (* args , ** kwargs )
48
+
49
+ @precondition
50
+ def frequency_check (f : Any ) -> Any :
51
+ return random .random () < frequency
52
+
53
+ return cast (F , frequency_check (wrapper ))
54
+
55
+ return decorator
56
+
37
57
38
58
def split_prefix_name (path : str ) -> tuple [str , str ]:
39
59
split = path .rsplit ("/" , maxsplit = 1 )
@@ -129,6 +149,7 @@ def add_array(
129
149
self .all_arrays .add (path )
130
150
131
151
@rule ()
152
+ @with_frequency (0.25 )
132
153
def clear (self ) -> None :
133
154
note ("clearing" )
134
155
import zarr
You can’t perform that action at this time.
0 commit comments