Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_build_valid_time():
forecast_reference_time = np.array(0)
forecast_period = np.array(0)
dims, data = cfmessage.build_valid_time(forecast_reference_time, forecast_period)
assert dims == ()
assert data.shape == ()
forecast_reference_time = np.array([0, 31536000])
forecast_period = np.array(0)
dims, data = cfmessage.build_valid_time(forecast_reference_time, forecast_period)
assert dims == ('time',)
assert data.shape == forecast_reference_time.shape + forecast_period.shape
forecast_reference_time = np.array(0)
forecast_period = np.array([0, 12, 24, 36])
dims, data = cfmessage.build_valid_time(forecast_reference_time, forecast_period)
for dim in header_dimensions:
header_value = header_values[index.index_keys.index(coord_name_key_map.get(dim, dim))]
header_indexes.append(coord_vars[dim].data.tolist().index(header_value))
offsets[tuple(header_indexes)] = offset
missing_value = data_var_attrs.get('missingValue', 9999)
data = OnDiskArray(
stream=index.filestream,
shape=shape,
offsets=offsets,
missing_value=missing_value,
geo_ndim=len(geo_dims),
)
if 'time' in coord_vars and 'step' in coord_vars:
# add the 'valid_time' secondary coordinate
dims, time_data = cfmessage.build_valid_time(
coord_vars['time'].data,
coord_vars['step'].data,
)
attrs = COORD_ATTRS['valid_time']
coord_vars['valid_time'] = Variable(dimensions=dims, data=time_data, attributes=attrs)
data_var_attrs['coordinates'] = ' '.join(coord_vars.keys())
data_var = Variable(dimensions=dimensions, data=data, attributes=data_var_attrs)
dims = collections.OrderedDict((d, s) for d, s in zip(dimensions, data_var.data.shape))
return dims, data_var, coord_vars