@@ -385,7 +385,7 @@ def test_dump_and_open_encodings(self):
385
385
386
386
with open_dataset (tmp_file ) as xray_dataset :
387
387
with create_tmp_file () as tmp_file2 :
388
- xray_dataset .dump (tmp_file2 )
388
+ xray_dataset .to_netcdf (tmp_file2 )
389
389
with nc4 .Dataset (tmp_file2 , 'r' ) as ds :
390
390
self .assertEqual (ds .variables ['time' ].getncattr ('units' ), units )
391
391
self .assertArrayEqual (ds .variables ['time' ], np .arange (10 ) + 4 )
@@ -495,53 +495,6 @@ def test_default_to_char_arrays(self):
495
495
self .assertDatasetIdentical (data , actual )
496
496
self .assertEqual (actual ['x' ].dtype , np .dtype ('S4' ))
497
497
498
- def test_open_encodings (self ):
499
- # Create a netCDF file with explicit time units
500
- # and make sure it makes it into the encodings
501
- # and survives a round trip
502
- with create_tmp_file () as tmp_file :
503
- with nc4 .Dataset (tmp_file , 'w' ) as ds :
504
- ds .createDimension ('time' , size = 10 )
505
- ds .createVariable ('time' , np .int32 , dimensions = ('time' ,))
506
- units = 'days since 1999-01-01'
507
- ds .variables ['time' ].setncattr ('units' , units )
508
- ds .variables ['time' ][:] = np .arange (10 ) + 4
509
-
510
- expected = Dataset ()
511
-
512
- time = pd .date_range ('1999-01-05' , periods = 10 )
513
- encoding = {'units' : units , 'dtype' : np .dtype ('int32' )}
514
- expected ['time' ] = ('time' , time , {}, encoding )
515
-
516
- with open_dataset (tmp_file ) as actual :
517
- self .assertVariableEqual (actual ['time' ], expected ['time' ])
518
- actual_encoding = dict ((k , v ) for k , v
519
- in iteritems (actual ['time' ].encoding )
520
- if k in expected ['time' ].encoding )
521
- self .assertDictEqual (actual_encoding ,
522
- expected ['time' ].encoding )
523
-
524
- def test_dump_and_open_encodings (self ):
525
- # Create a netCDF file with explicit time units
526
- # and make sure it makes it into the encodings
527
- # and survives a round trip
528
- with create_tmp_file () as tmp_file :
529
- with nc4 .Dataset (tmp_file , 'w' ) as ds :
530
- ds .createDimension ('time' , size = 10 )
531
- ds .createVariable ('time' , np .int32 , dimensions = ('time' ,))
532
- units = 'days since 1999-01-01'
533
- ds .variables ['time' ].setncattr ('units' , units )
534
- ds .variables ['time' ][:] = np .arange (10 ) + 4
535
-
536
- xray_dataset = open_dataset (tmp_file )
537
-
538
- with create_tmp_file () as tmp_file2 :
539
- xray_dataset .to_netcdf (tmp_file2 )
540
-
541
- with nc4 .Dataset (tmp_file2 , 'r' ) as ds :
542
- self .assertEqual (ds .variables ['time' ].getncattr ('units' ), units )
543
- self .assertArrayEqual (ds .variables ['time' ], np .arange (10 ) + 4 )
544
-
545
498
def test_coordinates_encoding (self ):
546
499
def equals_latlon (obj ):
547
500
return obj == 'lat lon' or obj == 'lon lat'
0 commit comments