Skip to content

Commit fe92b19

Browse files
committed
fix typing of tutorial
1 parent 9704822 commit fe92b19

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎examples/tutorial.py‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from typing import Literal
12
from netCDF4 import Dataset
23

34
# code from tutorial.
@@ -68,7 +69,8 @@ def walktree(top):
6869
levels.units = 'hPa'
6970
temp.units = 'K'
7071
times.units = 'hours since 0001-01-01 00:00:00.0'
71-
times.calendar = 'gregorian'
72+
calendar: Literal['gregorian'] = 'gregorian'
73+
times.calendar = calendar
7274

7375
for name in rootgrp.ncattrs():
7476
print('Global attr', name, '=', getattr(rootgrp,name))
@@ -111,8 +113,8 @@ def walktree(top):
111113
dates = [datetime(2001,3,1)+n*timedelta(hours=12) for n in range(temp.shape[0])]
112114
times[:] = date2num(dates,units=times.units,calendar=times.calendar)
113115
print("time values (in units {}):\n{}".format(times.units, times[:]))
114-
dates = num2date(times[:],units=times.units,calendar=times.calendar)
115-
print("dates corresponding to time values:\n{}".format(dates))
116+
dates_array = num2date(times[:],units=times.units,calendar=times.calendar)
117+
print("dates corresponding to time values:\n{}".format(dates_array))
116118

117119
rootgrp.close()
118120

0 commit comments

Comments
 (0)