I need to concatenate an unknown number of InferenceData
objects. At runtime, the number is known, and can be used to construct all the filenames involved. If the number would be 10, then this code would do the job, but the number is a run-time parameter. Some version of reduce
came to my mind, but arviz.concat()
requires the object to be of the same format so that fails. How can I generalize this code to work for any number of files?
data = arviz.concat(arviz.from_netcdf("data_0.netcdf"), arviz.from_netcdf("data_1.netcdf"),
arviz.from_netcdf("data_2.netcdf"), arviz.from_netcdf("data_3.netcdf"),
arviz.from_netcdf("data_4.netcdf"), arviz.from_netcdf("data_5.netcdf"),
arviz.from_netcdf("data_6.netcdf"), arviz.from_netcdf("data_7.netcdf"),
arviz.from_netcdf("data_8.netcdf"), arviz.from_netcdf("data_9.netcdf"),
dim = "draw")