Skip to content

Error renameDimension / renameVariable #817

Closed
@pgamez

Description

@pgamez

Hello

When using renameVariable after renameDimension on a coordinate, all the values from the variable are removed.

Here is a code that could reproduce the problem (version 1.4.0):

#!/usr/bin/env python3

import netCDF4 as nc

with nc.Dataset('test.nc', 'w') as fp:
    fp.createDimension('x', 3)
    ncvar = fp.createVariable('x', float, ('x',))
    ncvar[:] = [1.1, 2.2, 3.3]

with nc.Dataset('test.nc', 'r+') as fp:
    fp.renameDimension('x', 'lon')
    fp.renameVariable('x', 'lon')

I expect a variable lon with values [1.1, 2.2, 3.3]. However, the result is this:

$ ncdump test.nc
netcdf test {
dimensions:
	lon = 3 ;
variables:
	double lon(lon) ;
data:

 lon = _, _, _ ;
}

This problem doesn't happens when executing first renameVariable and then renameDimension

Greetings,

Pedro

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions