Coverage for tests/test_processing_data.py: 100%

114 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2024-02-28 12:51 +1100

1"""Test data for test_processing""" 

2import numpy as np 

3import xarray as xr 

4 

5DA_1 = xr.DataArray([[1, 2], [3, 4]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}) 

6DA_2 = xr.DataArray([[5, 6], [7, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}) 

7DA_3 = xr.DataArray([[np.nan, 8], [9, 10]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}) 

8DA_4 = xr.DataArray([11, 12], dims=["a"], coords={"a": [0, 1]}) 

9DA_5 = xr.DataArray([np.nan, 12], dims=["a"], coords={"a": [0, 1]}) 

10DA_6 = xr.DataArray([13], dims=["a"], coords={"a": [0]}) 

11DA_7 = xr.DataArray([14, np.nan, 15], dims=["a"], coords={"a": [0, 1, 2]}) 

12 

13EXPECTED_12 = ( 

14 xr.DataArray([[1, 2], [3, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

15 xr.DataArray([[5, 6], [7, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

16) 

17EXPECTED_21 = ( 

18 xr.DataArray([[5, 6], [7, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

19 xr.DataArray([[1, 2], [3, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

20) 

21EXPECTED_123 = ( 

22 xr.DataArray([[np.nan, 2], [3, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

23 xr.DataArray([[np.nan, 6], [7, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

24 xr.DataArray([[np.nan, 8], [9, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

25) 

26EXPECTED_24 = ( 

27 xr.DataArray([[5, 6], [7, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

28 xr.DataArray([[11, 11], [12, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

29) 

30EXPECTED_15 = ( 

31 xr.DataArray([[np.nan, np.nan], [3, 4]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

32 xr.DataArray([[np.nan, np.nan], [12, 12]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

33) 

34EXPECTED_26 = ( 

35 xr.DataArray([[5, 6]], dims=["a", "b"], coords={"a": [0], "b": [2, 3]}), 

36 xr.DataArray([[13, 13]], dims=["a", "b"], coords={"a": [0], "b": [2, 3]}), 

37) 

38EXPECTED_37 = ( 

39 xr.DataArray( 

40 [[np.nan, 8], [np.nan, np.nan]], 

41 dims=["a", "b"], 

42 coords={"a": [0, 1], "b": [2, 3]}, 

43 ), 

44 xr.DataArray( 

45 [[np.nan, 14], [np.nan, np.nan]], 

46 dims=["a", "b"], 

47 coords={"a": [0, 1], "b": [2, 3]}, 

48 ), 

49) 

50 

51DS_12 = xr.Dataset({"DA_1": DA_1, "DA_2": DA_2}) 

52DS_123 = xr.Dataset({"DA_1": DA_1, "DA_2": DA_2, "DA_3": DA_3}) 

53DS_3 = xr.Dataset({"DA_3": DA_3}) 

54DS_7 = xr.Dataset({"DA_7": DA_7}) 

55 

56EXPECTED_DS12 = ( 

57 xr.Dataset( 

58 { 

59 "DA_1": xr.DataArray( 

60 [[1, 2], [3, np.nan]], 

61 dims=["a", "b"], 

62 coords={"a": [0, 1], "b": [2, 3]}, 

63 ), 

64 "DA_2": xr.DataArray( 

65 [[5, 6], [7, np.nan]], 

66 dims=["a", "b"], 

67 coords={"a": [0, 1], "b": [2, 3]}, 

68 ), 

69 } 

70 ), 

71) 

72EXPECTED_DS123 = ( 

73 xr.Dataset( 

74 { 

75 "DA_1": xr.DataArray( 

76 [[np.nan, 2], [3, np.nan]], 

77 dims=["a", "b"], 

78 coords={"a": [0, 1], "b": [2, 3]}, 

79 ), 

80 "DA_2": xr.DataArray( 

81 [[np.nan, 6], [7, np.nan]], 

82 dims=["a", "b"], 

83 coords={"a": [0, 1], "b": [2, 3]}, 

84 ), 

85 "DA_3": xr.DataArray( 

86 [[np.nan, 8], [9, np.nan]], 

87 dims=["a", "b"], 

88 coords={"a": [0, 1], "b": [2, 3]}, 

89 ), 

90 } 

91 ), 

92) 

93EXPECTED_DS12_DS123 = ( 

94 xr.Dataset( 

95 { 

96 "DA_1": xr.DataArray( 

97 [[np.nan, 2], [3, np.nan]], 

98 dims=["a", "b"], 

99 coords={"a": [0, 1], "b": [2, 3]}, 

100 ), 

101 "DA_2": xr.DataArray( 

102 [[np.nan, 6], [7, np.nan]], 

103 dims=["a", "b"], 

104 coords={"a": [0, 1], "b": [2, 3]}, 

105 ), 

106 } 

107 ), 

108 xr.Dataset( 

109 { 

110 "DA_1": xr.DataArray( 

111 [[np.nan, 2], [3, np.nan]], 

112 dims=["a", "b"], 

113 coords={"a": [0, 1], "b": [2, 3]}, 

114 ), 

115 "DA_2": xr.DataArray( 

116 [[np.nan, 6], [7, np.nan]], 

117 dims=["a", "b"], 

118 coords={"a": [0, 1], "b": [2, 3]}, 

119 ), 

120 "DA_3": xr.DataArray( 

121 [[np.nan, 8], [9, np.nan]], 

122 dims=["a", "b"], 

123 coords={"a": [0, 1], "b": [2, 3]}, 

124 ), 

125 } 

126 ), 

127) 

128EXPECTED_DS12_DS3 = ( 

129 xr.Dataset( 

130 { 

131 "DA_1": xr.DataArray( 

132 [[np.nan, 2], [3, np.nan]], 

133 dims=["a", "b"], 

134 coords={"a": [0, 1], "b": [2, 3]}, 

135 ), 

136 "DA_2": xr.DataArray( 

137 [[np.nan, 6], [7, np.nan]], 

138 dims=["a", "b"], 

139 coords={"a": [0, 1], "b": [2, 3]}, 

140 ), 

141 } 

142 ), 

143 xr.Dataset( 

144 { 

145 "DA_3": xr.DataArray( 

146 [[np.nan, 8], [9, np.nan]], 

147 dims=["a", "b"], 

148 coords={"a": [0, 1], "b": [2, 3]}, 

149 ) 

150 } 

151 ), 

152) 

153EXPECTED_DS3_7 = ( 

154 xr.Dataset( 

155 { 

156 "DA_3": xr.DataArray( 

157 [[np.nan, 8], [np.nan, np.nan]], 

158 dims=["a", "b"], 

159 coords={"a": [0, 1], "b": [2, 3]}, 

160 ) 

161 } 

162 ), 

163 xr.DataArray( 

164 [[np.nan, 14], [np.nan, np.nan]], 

165 dims=["a", "b"], 

166 coords={"a": [0, 1], "b": [2, 3]}, 

167 ), 

168) 

169EXPECTED_DS7_3 = ( 

170 xr.Dataset( 

171 { 

172 "DA_7": xr.DataArray( 

173 [[np.nan, 14], [np.nan, np.nan]], 

174 dims=["a", "b"], 

175 coords={"a": [0, 1], "b": [2, 3]}, 

176 ) 

177 } 

178 ), 

179 xr.DataArray( 

180 [[np.nan, 8], [np.nan, np.nan]], 

181 dims=["a", "b"], 

182 coords={"a": [0, 1], "b": [2, 3]}, 

183 ), 

184) 

185EXPECTED_DS12_3 = ( 

186 xr.Dataset( 

187 { 

188 "DA_1": xr.DataArray( 

189 [[np.nan, 2], [3, np.nan]], 

190 dims=["a", "b"], 

191 coords={"a": [0, 1], "b": [2, 3]}, 

192 ), 

193 "DA_2": xr.DataArray( 

194 [[np.nan, 6], [7, np.nan]], 

195 dims=["a", "b"], 

196 coords={"a": [0, 1], "b": [2, 3]}, 

197 ), 

198 } 

199 ), 

200 xr.DataArray([[np.nan, 8], [9, np.nan]], dims=["a", "b"], coords={"a": [0, 1], "b": [2, 3]}), 

201) 

202 

203""" 

204Test data for comparative_discretise 

205""" 

206# input data 

207DA_1D = xr.DataArray([1, 2.4, 1.2, np.nan], coords=[("a", [0, 1, 2, 3])]) 

208DA_2D = xr.DataArray([[1, 2.4], [1.2, np.nan]], coords=[("a", [0, 1]), ("b", [2, 3])]) 

209DA_3D = xr.DataArray( 

210 [[[1, 2.4], [1.2, np.nan]], [[1, 1.1], [np.nan, 1.3]]], 

211 coords=[("a", [0, 2]), ("b", [2, 3]), ("c", [np.pi, 0])], 

212) 

213# input data for testing abs_tolerance 

214DATA_4X1 = xr.DataArray([0.39, 0.399999999, 0.2, 0.7], coords=[("day", [0, 1, 2, 3])]) 

215DATA_4X1_NAN = xr.DataArray([0.39, 0.399999999, 0.2, np.nan], coords=[("day", [0, 1, 2, 3])]) 

216DATA_4X1_2NAN = xr.DataArray([np.nan, 0.399999999, 0.2, np.nan], coords=[("day", [0, 1, 2, 3])]) 

217DATA_4X2_POINT4_POINT5_NAN = xr.DataArray( 

218 [[np.nan, -0.3], [0.399999999, 0.39], [0.499999999, 0.5]], 

219 coords=[("day", [0, 1, 2]), ("colour", [0, 1])], 

220) 

221DATA_5X1_POINT4 = xr.DataArray([0.39, 0.399999999, 0.4, 0.40000000001, 0.41], coords=[("day", [0, 1, 2, 3, 4])]) 

222 

223# 1-D comparison data with thresholds 

224THRESH_DA_0 = xr.DataArray([0.3], dims=["threshold"], coords={"threshold": [0.3]}) 

225THRESH_DA_1 = xr.DataArray([0.2, 0.3, 0.4], dims=["threshold"], coords={"threshold": [0.2, 0.3, 0.4]}) 

226THRESH_DA_2 = xr.DataArray([1, 5, 7], dims=["threshold"], coords={"threshold": [1, 5, 7]}) 

227THRESH_DA_3 = xr.DataArray([0.4, 0.5], dims=["threshold"], coords={"threshold": [0.4, 0.5]}) 

228THRESH_DA_4 = xr.DataArray([0.4], dims=["threshold"], coords={"threshold": [0.4]}) 

229THRESH_DA_5 = xr.DataArray([0.3, 0.8], dims=["threshold"], coords={"threshold": [0.3, 0.8]}) 

230 

231# n-D comparison data 

232COMP_1D = xr.DataArray([1.3, 1.1], dims=["banana"], coords={"banana": [2, 1]}) 

233COMP_1DA = xr.DataArray([1.1, 2.5, np.nan], dims=["a"], coords={"a": [2, 1, 0]}) 

234COMP_2D = xr.DataArray([[0, 4, 1], [2, np.nan, 1]], coords=[("banana", [2, 1]), ("apple", [np.pi, 3, 0])]) 

235COMP_2DA = xr.DataArray([[1.3, 1.1], [2.4, np.nan], [1, 4]], coords=[("a", [2, 1, 3]), ("banana", [2, 1])]) 

236 

237#################################################### 

238# Tests with 1-D comparison, testing abs_tolerance # 

239#################################################### 

240EXP_CDIS_0 = xr.DataArray( 

241 [1.0], 

242 dims=["threshold"], 

243 coords={"threshold": [0.3]}, 

244 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

245) 

246EXP_CDIS_1 = xr.DataArray( 

247 [1.0], 

248 dims=["threshold"], 

249 coords={"threshold": [0.3]}, 

250 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

251) 

252EXP_CDIS_2 = xr.DataArray( 

253 [0.0], 

254 dims=["threshold"], 

255 coords={"threshold": [0.3]}, 

256 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

257) 

258EXP_CDIS_3 = xr.DataArray( 

259 [1.0], 

260 dims=["threshold"], 

261 coords={"threshold": [0.3]}, 

262 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

263) 

264EXP_CDIS_4 = xr.DataArray( 

265 [0.0], 

266 dims=["threshold"], 

267 coords={"threshold": [0.3]}, 

268 attrs={"discretisation_tolerance": 1e-10, "discretisation_mode": ">="}, 

269) 

270EXP_CDIS_5 = xr.DataArray( 

271 [1, 1.0, 0], 

272 dims=["threshold"], 

273 coords={"threshold": [0.2, 0.3, 0.4]}, 

274 attrs={"discretisation_tolerance": 1e-10, "discretisation_mode": ">="}, 

275) 

276EXP_CDIS_6 = xr.DataArray( 

277 [1.0, 1.0, 0.0], 

278 dims=["threshold"], 

279 coords={"threshold": [1, 5, 7]}, 

280 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

281) 

282EXP_CDIS_7 = xr.DataArray( 

283 [np.nan, np.nan, np.nan], 

284 dims=["threshold"], 

285 coords={"threshold": [1, 5, 7]}, 

286 attrs={"discretisation_tolerance": 1e-10, "discretisation_mode": ">="}, 

287) 

288EXP_CDIS_8 = xr.DataArray( 

289 [[1.0], [0.0], [1.0]], 

290 coords=[("day", [0, 1, 2]), ("threshold", [0.4])], 

291 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

292) 

293EXP_CDIS_9 = xr.DataArray( 

294 [[1.0, 0.0], [0.0, 0.0], [1.0, 1.0]], 

295 coords=[("day", [0, 1, 2]), ("threshold", [0.4, 0.5])], 

296 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

297) 

298EXP_CDIS_10 = xr.DataArray( 

299 [[0.0, 0.0], [1.0, 0.0], [0.0, 0.0], [1.0, 1.0]], 

300 coords=[("day", [0, 1, 2, 3]), ("threshold", [0.4, 0.5])], 

301 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

302) 

303EXP_CDIS_11 = xr.DataArray( 

304 [[0.0, 0.0], [1.0, 0.0], [0.0, 0.0], [np.nan, np.nan]], 

305 coords=[("day", [0, 1, 2, 3]), ("threshold", [0.4, 0.5])], 

306 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

307) 

308EXP_CDIS_12 = xr.DataArray( 

309 [[np.nan, np.nan], [1.0, 0.0], [0.0, 0.0], [np.nan, np.nan]], 

310 coords=[("day", [0, 1, 2, 3]), ("threshold", [0.4, 0.5])], 

311 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

312) 

313EXP_CDIS_13 = xr.DataArray( 

314 [[0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [np.nan, np.nan]], 

315 coords=[("day", [0, 1, 2, 3]), ("threshold", [0.4, 0.5])], 

316 attrs={"discretisation_tolerance": 1e-10, "discretisation_mode": ">="}, 

317) 

318EXP_CDIS_14 = xr.DataArray( 

319 [[[np.nan, np.nan], [0, 0]], [[1, 0], [0, 0]], [[1, 1], [1, 1]]], 

320 coords=[("day", [0, 1, 2]), ("colour", [0, 1]), ("threshold", [0.4, 0.5])], 

321 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

322) 

323 

324############ 

325# Datasets # 

326############ 

327EXP_CDIS_DS_1D_1D = xr.Dataset( 

328 { 

329 "zero": xr.DataArray( 

330 [[0.0, 0.0], [1.0, 0.0], [0.0, 0.0], [1.0, 1.0]], 

331 coords=[("day", [0, 1, 2, 3]), ("threshold", [0.4, 0.5])], 

332 ), 

333 "one": xr.DataArray( 

334 [[0.0, 0.0], [1.0, 0.0], [0.0, 0.0], [np.nan, np.nan]], 

335 coords=[("day", [0, 1, 2, 3]), ("threshold", [0.4, 0.5])], 

336 ), 

337 }, 

338 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

339) 

340EXP_CDIS_DS_0D_1D = xr.Dataset( 

341 {"zero": xr.DataArray([1.0], dims=["threshold"], coords={"threshold": [0.3]})}, 

342 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

343) 

344 

345############################# 

346# Tests with n-D comparison # 

347############################# 

348EXP_CDIS_0D_1D = xr.DataArray( 

349 [0.0, 0.0], 

350 coords=[("banana", [2, 1])], 

351 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

352) 

353EXP_CDIS_1D_1DA = xr.DataArray( 

354 [np.nan, 0, 1], 

355 coords=[("a", [0, 1, 2])], 

356 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

357) 

358EXP_CDIS_1D_0D = xr.DataArray( 

359 [0, 1, 0, np.nan], 

360 dims=["a"], 

361 coords={"a": [0, 1, 2, 3]}, 

362 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

363) 

364EXP_CDIS_1D_2DA = xr.DataArray( 

365 [[1, np.nan], [0, 1], [np.nan, np.nan]], 

366 coords=[("a", [1, 2, 3]), ("banana", [2, 1])], 

367 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

368) 

369EXP_CDIS_1D_2D = xr.DataArray( 

370 [ 

371 [[1, 0, 0], [0, np.nan, 0]], 

372 [[1, 0, 1], [1, np.nan, 1]], 

373 [[1, 0, 1], [0, np.nan, 1]], 

374 [[np.nan, np.nan, np.nan], [np.nan, np.nan, np.nan]], 

375 ], 

376 coords=[("a", [0, 1, 2, 3]), ("banana", [2, 1]), ("apple", [np.pi, 3, 0])], 

377 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

378) 

379EXP_CDIS_2D_0D = xr.DataArray( 

380 [[0, 1], [0, np.nan]], 

381 coords=[("a", [0, 1]), ("b", [2, 3])], 

382 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

383) 

384EXP_CDIS_2D_1DA = xr.DataArray( 

385 [[np.nan, np.nan], [0, np.nan]], 

386 coords=[("a", [0, 1]), ("b", [2, 3])], 

387 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

388) 

389EXP_CDIS_2D_1D = xr.DataArray( 

390 [[[0, 0], [1, 1]], [[0, 1], [np.nan, np.nan]]], 

391 coords=[("a", [0, 1]), ("b", [2, 3]), ("banana", [2, 1])], 

392 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

393) 

394EXP_CDIS_3D_1DA = xr.DataArray( 

395 [[[np.nan, np.nan], [np.nan, np.nan]], [[0, 0], [np.nan, 1]]], 

396 coords=[("a", [0, 2]), ("b", [2, 3]), ("c", [np.pi, 0])], 

397 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

398) 

399EXP_CDIS_3D_3D = xr.DataArray( 

400 [[[0.0, 0.0], [0.0, np.nan]], [[0.0, 0.0], [np.nan, 0.0]]], 

401 coords=[("a", [0, 2]), ("b", [2, 3]), ("c", [np.pi, 0])], 

402 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

403) 

404################################################################ 

405# SMOKE TESTS FOR ALL MODES ['<', '>', '>=', '<=', '++', '!='] # 

406################################################################ 

407EXP_CDIS_GE0 = xr.DataArray( 

408 [0.0, 1.0, 1.0, 1.0, 1.0], 

409 dims=["day"], 

410 coords=[("day", [0, 1, 2, 3, 4])], 

411 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

412) 

413EXP_CDIS_GE1 = xr.DataArray( 

414 [0.0, 0.0, 1.0, 1.0, 1.0], 

415 dims=["day"], 

416 coords=[("day", [0, 1, 2, 3, 4])], 

417 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

418) 

419EXP_CDIS_GT0 = xr.DataArray( 

420 [0.0, 0.0, 0.0, 0.0, 1.0], 

421 dims=["day"], 

422 coords=[("day", [0, 1, 2, 3, 4])], 

423 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">"}, 

424) 

425EXP_CDIS_GT1 = xr.DataArray( 

426 [0.0, 0.0, 0.0, 1.0, 1.0], 

427 dims=["day"], 

428 coords=[("day", [0, 1, 2, 3, 4])], 

429 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

430) 

431EXP_CDIS_LE0 = xr.DataArray( 

432 [1.0, 1.0, 1.0, 1.0, 0.0], 

433 dims=["day"], 

434 coords=[("day", [0, 1, 2, 3, 4])], 

435 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "<="}, 

436) 

437EXP_CDIS_LE1 = xr.DataArray( 

438 [1.0, 1.0, 1.0, 0.0, 0.0], 

439 dims=["day"], 

440 coords=[("day", [0, 1, 2, 3, 4])], 

441 attrs={"discretisation_tolerance": 0, "discretisation_mode": "<="}, 

442) 

443EXP_CDIS_LT0 = xr.DataArray( 

444 [1.0, 0.0, 0.0, 0.0, 0.0], 

445 dims=["day"], 

446 coords=[("day", [0, 1, 2, 3, 4])], 

447 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "<"}, 

448) 

449EXP_CDIS_LT1 = xr.DataArray( 

450 [1.0, 1.0, 0.0, 0.0, 0.0], 

451 dims=["day"], 

452 coords=[("day", [0, 1, 2, 3, 4])], 

453 attrs={"discretisation_tolerance": 0, "discretisation_mode": "<"}, 

454) 

455EXP_CDIS_EQ0 = xr.DataArray( 

456 [0.0, 1.0, 1.0, 1.0, 0.0], 

457 dims=["day"], 

458 coords=[("day", [0, 1, 2, 3, 4])], 

459 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "=="}, 

460) 

461EXP_CDIS_EQ1 = xr.DataArray( 

462 [0.0, 0.0, 1.0, 0.0, 0.0], 

463 dims=["day"], 

464 coords=[("day", [0, 1, 2, 3, 4])], 

465 attrs={"discretisation_tolerance": 0, "discretisation_mode": "=="}, 

466) 

467EXP_CDIS_NE0 = xr.DataArray( 

468 [1.0, 0.0, 0.0, 0.0, 1.0], 

469 dims=["day"], 

470 coords=[("day", [0, 1, 2, 3, 4])], 

471 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "!="}, 

472) 

473EXP_CDIS_NE1 = xr.DataArray( 

474 [1.0, 1.0, 0.0, 1.0, 1.0], 

475 dims=["day"], 

476 coords=[("day", [0, 1, 2, 3, 4])], 

477 attrs={"discretisation_tolerance": 0, "discretisation_mode": "!="}, 

478) 

479 

480################################## 

481# 0-D Integer & float comparison # 

482################################## 

483EXP_CDIS_ONE = xr.DataArray( 

484 [1.0], 

485 coords=[("a", [0])], 

486 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">"}, 

487) 

488 

489""" 

490Testing data for binary_discretise 

491""" 

492EXP_DIS_0 = xr.DataArray( 

493 [1.0], 

494 dims=["threshold"], 

495 coords={"threshold": [0.3]}, 

496 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

497) 

498EXP_DIS_1 = xr.DataArray( 

499 1.0, 

500 coords={"threshold": 0.3}, 

501 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

502) 

503EXP_DIS_GE0 = xr.DataArray( 

504 [0.0, 1.0, 1.0, 1.0, 1.0], 

505 dims=["day"], 

506 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

507 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

508) 

509EXP_DIS_GE1 = xr.DataArray( 

510 [0.0, 0.0, 1.0, 1.0, 1.0], 

511 dims=["day"], 

512 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

513 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

514) 

515EXP_DIS_GT0 = xr.DataArray( 

516 [0.0, 0.0, 0.0, 0.0, 1.0], 

517 dims=["day"], 

518 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

519 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">"}, 

520) 

521EXP_DIS_GT1 = xr.DataArray( 

522 [0.0, 0.0, 0.0, 1.0, 1.0], 

523 dims=["day"], 

524 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

525 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">"}, 

526) 

527EXP_DIS_LE0 = xr.DataArray( 

528 [1.0, 1.0, 1.0, 1.0, 0.0], 

529 dims=["day"], 

530 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

531 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "<="}, 

532) 

533EXP_DIS_LE1 = xr.DataArray( 

534 [1.0, 1.0, 1.0, 0.0, 0.0], 

535 dims=["day"], 

536 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

537 attrs={"discretisation_tolerance": 0, "discretisation_mode": "<="}, 

538) 

539EXP_DIS_LT0 = xr.DataArray( 

540 [1.0, 0.0, 0.0, 0.0, 0.0], 

541 dims=["day"], 

542 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

543 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "<"}, 

544) 

545EXP_DIS_LT1 = xr.DataArray( 

546 [1.0, 1.0, 0.0, 0.0, 0.0], 

547 dims=["day"], 

548 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

549 attrs={"discretisation_tolerance": 0, "discretisation_mode": "<"}, 

550) 

551EXP_DIS_EQ0 = xr.DataArray( 

552 [0.0, 1.0, 1.0, 1.0, 0.0], 

553 dims=["day"], 

554 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

555 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "=="}, 

556) 

557EXP_DIS_EQ1 = xr.DataArray( 

558 [0.0, 0.0, 1.0, 0.0, 0.0], 

559 dims=["day"], 

560 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

561 attrs={"discretisation_tolerance": 0, "discretisation_mode": "=="}, 

562) 

563EXP_DIS_NE0 = xr.DataArray( 

564 [1.0, 0.0, 0.0, 0.0, 1.0], 

565 dims=["day"], 

566 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

567 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "!="}, 

568) 

569EXP_DIS_NE1 = xr.DataArray( 

570 [1.0, 1.0, 0.0, 1.0, 1.0], 

571 dims=["day"], 

572 coords={"day": [0, 1, 2, 3, 4], "threshold": 0.4}, 

573 attrs={"discretisation_tolerance": 0, "discretisation_mode": "!="}, 

574) 

575EXP_DIS_DS_1D = xr.Dataset( 

576 { 

577 "zero": xr.DataArray( 

578 [[0.0, 0.0], [1.0, 0.0], [0.0, 0.0], [1.0, 1.0]], 

579 dims=["day", "threshold"], 

580 coords={"day": [0, 1, 2, 3], "threshold": [0.4, 0.5]}, 

581 ), 

582 "one": xr.DataArray( 

583 [[0.0, 0.0], [1.0, 0.0], [0.0, 0.0], [np.nan, np.nan]], 

584 dims=["day", "threshold"], 

585 coords={"day": [0, 1, 2, 3], "threshold": [0.4, 0.5]}, 

586 ), 

587 }, 

588 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

589) 

590EXP_DIS_DS_0D = xr.Dataset( 

591 {"zero": xr.DataArray(1.0, coords={"threshold": 0.3})}, 

592 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

593) 

594 

595""" 

596Test data for _binary_discretise_proportion 

597""" 

598 

599EXP_BDP_0 = xr.DataArray( 

600 [1.0], 

601 dims=["threshold"], 

602 coords={"threshold": [0.3]}, 

603 attrs={"discretisation_tolerance": 0, "discretisation_mode": ">="}, 

604) 

605EXP_BDP_1 = xr.DataArray( 

606 [[[np.nan, np.nan], [0, 0]], [[1, 0], [0, 0]], [[1, 1], [1, 1]]], 

607 coords=[("day", [0, 1, 2]), ("colour", [0, 1]), ("threshold", [0.4, 0.5])], 

608 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

609) 

610EXP_BDP_2 = xr.DataArray( 

611 [[1, 0.5], [1 / 3, 1 / 3]], 

612 coords=[("colour", [0, 1]), ("threshold", [0.4, 0.5])], 

613 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

614) 

615EXP_BDP_3 = xr.DataArray( 

616 [0.6, 0.4], 

617 dims=["threshold"], 

618 coords=[("threshold", [0.4, 0.5])], 

619 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

620) 

621EXP_BDP_4 = xr.DataArray( 

622 0.2, 

623 coords={"threshold": 0.4}, 

624 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">"}, 

625) 

626EXP_BDP_5 = xr.DataArray( 

627 0.8, 

628 coords={"threshold": 0.4}, 

629 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "<="}, 

630) 

631EXP_BDP_6 = xr.DataArray( 

632 0.2, 

633 coords={"threshold": 0.4}, 

634 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "<"}, 

635) 

636EXP_BDP_7 = xr.DataArray( 

637 0.6, 

638 coords={"threshold": 0.4}, 

639 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "=="}, 

640) 

641EXP_BDP_8 = xr.DataArray( 

642 0.4, 

643 coords={"threshold": 0.4}, 

644 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": "!="}, 

645) 

646 

647EXP_BDP_9 = xr.Dataset( 

648 { 

649 "zero": xr.DataArray([0.5, 0.25], coords=[("threshold", [0.4, 0.5])]), 

650 "one": xr.DataArray([1 / 3, 0], coords=[("threshold", [0.4, 0.5])]), 

651 }, 

652 attrs={"discretisation_tolerance": 1e-8, "discretisation_mode": ">="}, 

653)