Skip to content

Handle several corner cases

Paal Kvamme requested to merge kvamme62/cornercases into master

Make several changes to better handle corner cases such as the whole ZGY file containing the same sample value. Make sure the histogram range gets set to a reasonable value.

The histogram range will in this case be set so that the single value is inside one of the bins. Which bin the samples end up in is unspecified. In general the OpenZGY library is free to choose any histogram range although there is an expectation that the range will approximately cover the sample values in the file. In the single-value case the choice is almost arbitrary.

For integral files there is now an explicit check on create that forbids a range with just one value i.e. min==max. If an application really wants to create a file with just one sample value it will need to supply a wider data range.

If the library encounters an old file with a bad coding range it will silently substitute (-128,+127) or (-32768,+32767) which makes the int to float conversion a no-op.

Merge request reports