NetCDF.jl icon indicating copy to clipboard operation
NetCDF.jl copied to clipboard

readvar() vs putvar()?

Open petershintech opened this issue 3 years ago • 7 comments

While using NetCDF.jl, I found the package provides readvar() and putvar() for reading and writing a variable respectively. Not sure why the function names were designed in the way, rather than either getvar() and putvar() or readvar() and writevar(). For instance, MATLAB provides getvar() and putvar(), which makes more sense to me. Any reason to introduce the asymmetric function names?

petershintech avatar Dec 25 '22 20:12 petershintech

Not sure why it was originally called readvar. The C API uses nc_put_var and nc_get_var, to that would be more consistent with the C API, though most packages and Base use read and write more. It's a good observation though I'm not sure it worth changing at this point and break peoples code.

visr avatar Dec 28 '22 19:12 visr

@visr I understand your concern. Then, how about introducing a new function without deprecating an existing one? For instance, to be consistent with other packages, how about creating writevar() function and letting it just call the existing putvar()? Once you have introduced the symmetric interface, I can bet you will see more NetCDF.jl users begin to use writevar() along with readvar(), but I might be wrong.

petershintech avatar Dec 28 '22 20:12 petershintech

I just found NetCDF.jl also exports ncgetatt() and ncputatt() so maybe to be consistent with them, introducing getvar() rather than readvar() can be a better choice.

petershintech avatar Dec 28 '22 20:12 petershintech

I'm personally now only doing very light maintenance on this package, since I'm normally using NCDatasets.jl if I use netCDF files. There was discussion on the future of those packages in https://github.com/Alexander-Barth/NCDatasets.jl/issues/57 but it didn't quite conclude yet.

visr avatar Dec 28 '22 20:12 visr

I dug up NetCDF.jl first because I thought this simpler package is being maintained better than NCDatasets.jl but I might be wrong. When running tests, I could see none of NetCDF.jl tests is broken but some of NCDatasets.jl tests are broken. What is the future of NetCDF.jl? I know NCDatasets.jl provides more elegant interface than NetCDF.jl as netCDF4 is doing for Python users. If NetCDF.jl will be deprecated in the near future, then definitely there is no need to introduce any new functions.

petershintech avatar Dec 28 '22 20:12 petershintech

I can't really say what the future of this package is beyond the thread I linked. I don't think it will quickly be deprecated though. I'm not sure about broken tests in NCDatasets, on master I see CI is passing. Perhaps good to file an issue if you have local failures.

visr avatar Dec 28 '22 21:12 visr

@visr Thanks for your reply. Then, I will dig up NCDatasets.jl and try to find a way I can contribute something to the package. See you there.

petershintech avatar Dec 28 '22 21:12 petershintech