huizezhang-sherry / cubble

A tidy structure for spatio-temporal vector data
https://huizezhang-sherry.github.io/cubble/
Other
55 stars 9 forks source link

Add error handling for rescale01 function #29

Open maliny12 opened 4 months ago

maliny12 commented 4 months ago

This pull request addresses an issue in the rescale01 function where constant or non-varying input values (including a uniform xlim) led to a division by zero, causing errors in data scaling. I've introduced a safeguard mechanism that:

Checks for the scenario where the range (rng) derived from the input x or provided xlim is constant or non-varying. I've also implemented a fallback strategy by slightly modifying rng to introduce a minimal range, allowing the scaling operation to proceed without division by zero errors.