File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change
1
+ import hypothesis .strategies as st
2
+ import xarray .testing .strategies as xrst
3
+ from hypothesis import given
4
+
5
+
6
+ class CreationTests :
7
+ array_type : type
8
+
9
+ @staticmethod
10
+ def array_strategy_fn (* , shape , dtype ):
11
+ raise NotImplementedError
12
+
13
+ @given (st .data ())
14
+ def test_create_variable (self , data ):
15
+ variable = data .draw (xrst .variables (array_strategy_fn = self .array_strategy_fn ))
16
+
17
+ assert isinstance (variable .data , self .array_type )
Original file line number Diff line number Diff line change
1
+ import hypothesis .strategies as st
2
+ import numpy as np
3
+
4
+ from xarray_array_testing .creation import CreationTests
5
+
6
+
7
+ def create_numpy_array (* , shape , dtype ):
8
+ return st .builds (np .ones , shape = st .just (shape ), dtype = st .just (dtype ))
9
+
10
+
11
+ class TestCreationNumpy (CreationTests ):
12
+ array_type = np .ndarray
13
+ array_module = np
14
+
15
+ @staticmethod
16
+ def array_strategy_fn (* , shape , dtype ):
17
+ return create_numpy_array (shape = shape , dtype = dtype )
You can’t perform that action at this time.
0 commit comments