Skip to content

Commit

Permalink
Remove biggus test skipper: fix pp field data (#2473)
Browse files Browse the repository at this point in the history
* pp save return field's data as masked array; fix test to check fill value of cube not data, and cube's dtype

* Fix bmdis of fields that were saved from global.pp test data
  • Loading branch information
lbdreyer authored and marqh committed Apr 6, 2017
1 parent 91eaef6 commit c0a77b7
Show file tree
Hide file tree
Showing 8 changed files with 147 additions and 133 deletions.
6 changes: 3 additions & 3 deletions lib/iris/etc/pp_save_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -761,12 +761,12 @@ THEN

#MDI
IF
ma.isMaskedArray(cm.data)
not cm.fill_value is None
THEN
pp.bmdi = cm.data.fill_value
pp.bmdi = cm.fill_value

IF
not ma.isMaskedArray(cm.data)
cm.fill_value is None
THEN
pp.bmdi = -1e30

Expand Down
2 changes: 1 addition & 1 deletion lib/iris/fileformats/pp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ def data(self):
self.bmdi = -9999
if is_lazy_data(self._data):
self._data = as_concrete_data(self._data,
nans_replacement=self.bmdi)
nans_replacement=ma.masked)
return self._data

@data.setter
Expand Down
250 changes: 130 additions & 120 deletions lib/iris/tests/results/cdm/masked_save_pp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,124 +51,134 @@
bdx: 1.0
bmdi: 123456.0
bmks: 1.0
data.data: [[ 0. 0. 0. 0. 0. 0.64589411
0.4375872 0.89177299 0.96366274 0.38344151 0.79172504 0.5288949
0.56804454 0.92559665 0.07103606 0.0871293 0.0202184 0.83261985
0.77815676 0.87001216]
[ 0. 0. 0. 0. 0. 0.63992101
0.14335328 0.94466889 0.52184832 0.41466194 0.2645556 0.7742337
0.45615032 0.56843394 0.0187898 0.61763549 0.61209571 0.616934
0.94374806 0.68182027]
[ 0. 0. 0. 0. 0. 0.67063785
0.21038257 0.12892629 0.31542835 0.36371076 0.57019675 0.43860152
0.98837382 0.10204481 0.20887676 0.16130951 0.6531083 0.25329161
0.46631077 0.24442559]
[ 0. 0. 0. 0. 0. 0.36872518
0.82099324 0.09710128 0.83794492 0.09609841 0.97645944 0.46865121
0.9767611 0.60484552 0.73926359 0.03918779 0.28280696 0.12019656
0.29614019 0.11872772]
[ 0. 0. 0. 0. 0. 0.2653895
0.52324808 0.09394051 0.57594651 0.9292962 0.31856894 0.66741037
0.13179787 0.71632719 0.28940609 0.18319136 0.58651292 0.02010755
0.82894003 0.00469548]
[ 0.67781651 0.27000797 0.73519403 0.96218854 0.24875315 0.57615733
0.59204191 0.57225192 0.22308163 0.95274901 0.44712538 0.84640867
0.69947928 0.29743695 0.81379783 0.39650574 0.88110322 0.5812729
0.88173538 0.69253159]
[ 0.7252543 0.50132436 0.95608366 0.64399022 0.42385504 0.60639322
0.0191932 0.30157483 0.66017354 0.2900776 0.61801541 0.42876869
0.13547407 0.29828233 0.56996489 0.59087276 0.57432526 0.65320081
0.65210325 0.43141845]
[ 0.8965466 0.36756188 0.43586493 0.89192337 0.80619401 0.7038886
0.10022689 0.91948259 0.71424133 0.99884701 0.14944831 0.86812603
0.16249293 0.61555958 0.12381998 0.84800822 0.80731899 0.56910074
0.40718329 0.069167 ]
[ 0.69742876 0.45354268 0.72205561 0.8663823 0.9755215 0.85580337
0.01171408 0.35997805 0.72999054 0.17162968 0.52103662 0.05433799
0.19999653 0.0185218 0.79369771 0.22392468 0.34535167 0.92808127
0.70441443 0.03183893]
[ 0.16469416 0.62147838 0.57722861 0.23789282 0.934214 0.61396593
0.53563279 0.58990997 0.73012203 0.31194499 0.39822108 0.20984375
0.186193 0.94437242 0.73955077 0.49045882 0.22741462 0.25435647
0.05802916 0.43441662]
[ 0.31179589 0.69634348 0.37775183 0.17960368 0.02467873 0.06724963
0.67939276 0.45369685 0.53657919 0.8966713 0.99033892 0.21689698
0.66307819 0.26332238 0.020651 0.75837862 0.32001716 0.38346389
0.5883171 0.83104843]
[ 0.62898183 0.87265068 0.27354205 0.79804683 0.18563594 0.95279163
0.68748826 0.21550767 0.94737059 0.73085582 0.25394166 0.21331197
0.5182007 0.02566272 0.20747007 0.42468548 0.37416998 0.46357542
0.27762872 0.58678436]
[ 0.8638556 0.11753186 0.51737911 0.13206811 0.7168597 0.39605969
0.56542128 0.18327984 0.14484777 0.48805627 0.35561273 0.94043195
0.76532525 0.7486636 0.90371972 0.08342244 0.55219245 0.58447605
0.96193635 0.29214752]
[ 0.24082878 0.10029394 0.01642963 0.92952931 0.66991657 0.78515291
0.28173012 0.58641016 0.06395527 0.48562759 0.97749513 0.87650526
0.33815897 0.96157014 0.23170163 0.94931883 0.9413777 0.79920256
0.63044792 0.87428796]
[ 0.29302028 0.84894353 0.61787671 0.01323686 0.3472335 0.14814086
0.9818294 0.47837031 0.49739137 0.63947254 0.3685846 0.13690028
0.82211775 0.18984792 0.51131898 0.22431703 0.09784448 0.8621915
0.97291946 0.96083468]
[ 0.90655547 0.77404732 0.33314514 0.08110139 0.40724117 0.23223414
0.13248764 0.05342718 0.72559434 0.01142746 0.77058077 0.14694664
0.07952208 0.08960304 0.67204779 0.24536721 0.42053947 0.55736881
0.86055118 0.72704428]
[ 0.2703279 0.13148279 0.05537432 0.30159864 0.26211816 0.45614058
0.68328136 0.69562542 0.28351885 0.37992695 0.18115096 0.78854549
0.05684808 0.69699723 0.7786954 0.77740759 0.25942257 0.37381315
0.58759964 0.2728219 ]
[ 0.3708528 0.19705428 0.45985588 0.0446123 0.79979587 0.07695644
0.51883513 0.30681011 0.57754296 0.95943332 0.64557022 0.03536244
0.43040243 0.51001686 0.53617752 0.68139249 0.27759609 0.12886056
0.39267567 0.9564057 ]
[ 0.1871309 0.90398395 0.54380596 0.45691141 0.88204139 0.45860395
0.72416764 0.39902532 0.90404439 0.69002503 0.69962204 0.3277204
0.75677866 0.63606107 0.24002028 0.16053882 0.79639149 0.95916659
0.45813882 0.59098417]
[ 0.85772264 0.45722345 0.95187449 0.57575119 0.8207671 0.9088437
0.8155238 0.15941447 0.62889844 0.39843425 0.06271295 0.42403224
0.25868407 0.8490383 0.03330463 0.95898271 0.35536885 0.35670689
0.0163285 0.18523233]]
data.mask: [[ True True True True True False False False False False False False
False False False False False False False False]
[ True True True True True False False False False False False False
False False False False False False False False]
[ True True True True True False False False False False False False
False False False False False False False False]
[ True True True True True False False False False False False False
False False False False False False False False]
[ True True True True True False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]
[False False False False False False False False False False False False
False False False False False False False False]]
data: [[-- -- -- -- -- 0.6458941102027893 0.4375872015953064 0.891772985458374
0.9636627435684204 0.3834415078163147 0.7917250394821167
0.5288949012756348 0.5680445432662964 0.9255966544151306
0.07103605568408966 0.08712930232286453 0.020218396559357643
0.832619845867157 0.7781567573547363 0.8700121641159058]
[-- -- -- -- -- 0.6399210095405579 0.14335328340530396 0.9446688890457153
0.5218483209609985 0.4146619439125061 0.26455560326576233
0.7742336988449097 0.4561503231525421 0.568433940410614
0.018789799883961678 0.6176354885101318 0.6120957136154175
0.6169340014457703 0.9437480568885803 0.681820273399353]
[-- -- -- -- -- 0.670637845993042 0.21038256585597992 0.12892629206180573
0.31542834639549255 0.36371076107025146 0.5701967477798462
0.4386015236377716 0.9883738160133362 0.10204481333494186
0.20887675881385803 0.16130951046943665 0.6531082987785339
0.25329160690307617 0.4663107693195343 0.24442559480667114]
[-- -- -- -- -- 0.3687251806259155 0.8209932446479797 0.09710127860307693
0.8379449248313904 0.0960984081029892 0.9764594435691833
0.4686512053012848 0.9767611026763916 0.6048455238342285
0.7392635941505432 0.03918779268860817 0.28280696272850037
0.12019655853509903 0.296140193939209 0.11872772127389908]
[-- -- -- -- -- 0.26538950204849243 0.5232480764389038 0.09394051134586334
0.5759465098381042 0.9292961955070496 0.3185689449310303
0.6674103736877441 0.13179786503314972 0.7163271903991699
0.28940609097480774 0.18319135904312134 0.5865129232406616
0.02010754682123661 0.8289400339126587 0.004695476032793522]
[0.6778165102005005 0.2700079679489136 0.7351940274238586
0.9621885418891907 0.2487531453371048 0.5761573314666748
0.5920419096946716 0.5722519159317017 0.22308163344860077
0.9527490139007568 0.4471253752708435 0.8464086651802063
0.6994792819023132 0.2974369525909424 0.8137978315353394
0.396505743265152 0.8811032176017761 0.5812729001045227
0.8817353844642639 0.6925315856933594]
[0.7252542972564697 0.5013243556022644 0.9560836553573608
0.6439902186393738 0.4238550364971161 0.6063932180404663
0.019193198531866074 0.30157482624053955 0.6601735353469849
0.2900775969028473 0.6180154085159302 0.42876869440078735
0.1354740709066391 0.29828232526779175 0.5699648857116699
0.5908727645874023 0.5743252635002136 0.6532008051872253
0.6521032452583313 0.43141844868659973]
[0.8965466022491455 0.36756187677383423 0.4358649253845215
0.8919233679771423 0.806194007396698 0.7038885951042175
0.10022688657045364 0.9194825887680054 0.7142413258552551
0.9988470077514648 0.14944830536842346 0.8681260347366333
0.16249293088912964 0.6155595779418945 0.1238199844956398
0.8480082154273987 0.8073189854621887 0.5691007375717163
0.40718328952789307 0.06916699558496475]
[0.6974287629127502 0.45354267954826355 0.7220556139945984
0.8663823008537292 0.9755215048789978 0.855803370475769
0.011714084073901176 0.359978049993515 0.729990541934967
0.17162968218326569 0.5210366249084473 0.054337989538908005
0.19999653100967407 0.01852179504930973 0.793697714805603
0.2239246815443039 0.3453516662120819 0.9280812740325928
0.704414427280426 0.031838931143283844]
[0.1646941602230072 0.6214783787727356 0.5772286057472229
0.23789282143115997 0.9342139959335327 0.6139659285545349
0.5356327891349792 0.5899099707603455 0.7301220297813416
0.31194499135017395 0.39822107553482056 0.20984375476837158
0.18619300425052643 0.9443724155426025 0.739550769329071
0.49045881628990173 0.22741462290287018 0.2543564736843109
0.058029159903526306 0.43441662192344666]
[0.3117958903312683 0.6963434815406799 0.37775182723999023
0.1796036809682846 0.024678727611899376 0.06724963337182999
0.6793927550315857 0.4536968469619751 0.5365791916847229
0.8966712951660156 0.990338921546936 0.21689698100090027
0.6630781888961792 0.2633223831653595 0.02065099962055683
0.7583786249160767 0.32001715898513794 0.38346388936042786
0.5883170962333679 0.8310484290122986]
[0.6289818286895752 0.872650682926178 0.27354204654693604
0.7980468273162842 0.18563593924045563 0.9527916312217712
0.6874882578849792 0.21550767123699188 0.9473705887794495
0.7308558225631714 0.2539416551589966 0.21331197023391724
0.518200695514679 0.02566271834075451 0.20747007429599762
0.4246854782104492 0.3741699755191803 0.46357542276382446
0.27762871980667114 0.5867843627929688]
[0.8638556003570557 0.11753185838460922 0.517379105091095
0.13206811249256134 0.7168596982955933 0.39605969190597534
0.5654212832450867 0.1832798421382904 0.14484776556491852
0.4880562722682953 0.35561272501945496 0.9404319524765015
0.7653252482414246 0.748663604259491 0.9037197232246399
0.08342243731021881 0.5521924495697021 0.5844760537147522
0.961936354637146 0.29214751720428467]
[0.24082878232002258 0.10029394179582596 0.016429629176855087
0.9295293092727661 0.669916570186615 0.7851529121398926
0.28173011541366577 0.5864101648330688 0.06395526975393295
0.48562759160995483 0.9774951338768005 0.8765052556991577
0.3381589651107788 0.961570143699646 0.23170162737369537
0.9493188261985779 0.9413776993751526 0.799202561378479
0.6304479241371155 0.8742879629135132]
[0.2930202782154083 0.8489435315132141 0.6178767085075378
0.013236857950687408 0.34723350405693054 0.14814086258411407
0.9818294048309326 0.4783703088760376 0.49739137291908264
0.6394725441932678 0.36858460307121277 0.13690027594566345
0.8221177458763123 0.1898479163646698 0.5113189816474915
0.2243170291185379 0.09784448146820068 0.8621914982795715
0.9729194641113281 0.9608346819877625]
[0.9065554738044739 0.774047315120697 0.3331451416015625
0.08110138773918152 0.40724116563796997 0.2322341352701187
0.13248763978481293 0.053427182137966156 0.7255943417549133
0.011427458375692368 0.7705807685852051 0.14694663882255554
0.07952208071947098 0.08960303664207458 0.6720477938652039
0.24536721408367157 0.4205394685268402 0.557368814945221
0.8605511784553528 0.7270442843437195]
[0.2703278958797455 0.131482794880867 0.05537432059645653
0.3015986382961273 0.2621181607246399 0.45614057779312134
0.6832813620567322 0.6956254243850708 0.28351885080337524
0.3799269497394562 0.18115095794200897 0.7885454893112183
0.05684807524085045 0.6969972252845764 0.7786954045295715
0.7774075865745544 0.25942257046699524 0.3738131523132324
0.5875996351242065 0.27282190322875977]
[0.3708527982234955 0.19705428183078766 0.4598558843135834
0.044612299650907516 0.7997958660125732 0.07695644348859787
0.5188351273536682 0.3068101108074188 0.5775429606437683
0.9594333171844482 0.6455702185630798 0.03536243736743927
0.4304024279117584 0.5100168585777283 0.5361775159835815 0.6813924908638
0.2775960862636566 0.12886056303977966 0.3926756680011749
0.9564056992530823]
[0.1871308982372284 0.9039839506149292 0.5438059568405151
0.4569114148616791 0.8820413947105408 0.45860394835472107
0.7241676449775696 0.3990253210067749 0.9040443897247314
0.6900250315666199 0.6996220350265503 0.32772040367126465
0.7567786574363708 0.6360610723495483 0.2400202751159668
0.16053882241249084 0.796391487121582 0.9591665863990784
0.4581388235092163 0.5909841656684875]
[0.8577226400375366 0.45722344517707825 0.9518744945526123
0.5757511854171753 0.8207671046257019 0.9088436961174011
0.8155238032341003 0.15941447019577026 0.6288984417915344
0.39843425154685974 0.06271295249462128 0.4240322411060333
0.25868406891822815 0.849038302898407 0.03330462798476219
0.9589827060699463 0.35536885261535645 0.3567068874835968
0.01632850244641304 0.18523232638835907]]
]
4 changes: 2 additions & 2 deletions lib/iris/tests/results/cube_to_pp/append_single.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
bdy: -2.5
bzx: -3.75
bdx: 3.75
bmdi: -1e+30
bmdi: 9999.0
bmks: 1.0
data: [[ 254.64399719 254.64399719 254.64399719 ..., 254.64399719
254.64399719 254.64399719]
Expand Down Expand Up @@ -115,7 +115,7 @@
bdy: -2.5
bzx: -3.75
bdx: 3.75
bmdi: -1e+30
bmdi: 9999.0
bmks: 1.0
data: [[ 254.64399719 254.64399719 254.64399719 ..., 254.64399719
254.64399719 254.64399719]
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/cube_to_pp/replace_single.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
bdy: -2.5
bzx: -3.75
bdx: 3.75
bmdi: -1e+30
bmdi: 9999.0
bmks: 1.0
data: [[ 254.64399719 254.64399719 254.64399719 ..., 254.64399719
254.64399719 254.64399719]
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/cube_to_pp/simple.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
bdy: -2.5
bzx: -3.75
bdx: 3.75
bmdi: -1e+30
bmdi: 9999.0
bmks: 1.0
data: [[ 254.64399719 254.64399719 254.64399719 ..., 254.64399719
254.64399719 254.64399719]
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/tests/results/cube_to_pp/user_rules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
bdy: -2.5
bzx: -3.75
bdx: 3.75
bmdi: -1e+30
bmdi: 9999.0
bmks: 1.0
data: [[ 254.64399719 254.64399719 254.64399719 ..., 254.64399719
254.64399719 254.64399719]
Expand Down
12 changes: 8 additions & 4 deletions lib/iris/tests/test_cdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,28 +1175,32 @@ def test_slicing(self):
self.assertIsInstance(partial_slice.data, ma.core.MaskedArray)
self.assertEqual(ma.count_masked(partial_slice.data), 25)

@tests.skip_biggus
def test_save_and_merge(self):
cube = self._load_3d_cube()
dtype = cube.dtype
fill_value = 123456

# extract the 2d field that has SOME missing values
masked_slice = cube[0]
masked_slice.data.fill_value = 123456
masked_slice.fill_value = fill_value

# test saving masked data
reference_txt_path = tests.get_result_path(('cdm', 'masked_save_pp.txt'))
with self.cube_save_test(reference_txt_path, reference_cubes=masked_slice) as temp_pp_path:
iris.save(masked_slice, temp_pp_path)

# test merge keeps the mdi we just saved
cube1 = iris.load_cube(temp_pp_path)
self.assertEqual(cube1.dtype, dtype)

cube2 = cube1.copy()
# make cube1 and cube2 differ on a scalar coord, to make them mergeable into a 3d cube
cube2.coord("pressure").points = [1001.0]
merged_cubes = iris.cube.CubeList([cube1, cube2]).merge()
self.assertEqual(len(merged_cubes), 1, "expected a single merged cube")
merged_cube = merged_cubes[0]
self.assertEqual(merged_cube.data.fill_value, 123456)
self.assertEqual(merged_cube.dtype, dtype)
self.assertEqual(merged_cube.fill_value, fill_value)


@tests.skip_data
Expand Down

0 comments on commit c0a77b7

Please sign in to comment.