r.category: preserving raster title#7210
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
Hm, do you need the init then? Did you look how would the old categories that are read in interact with the new one? Wouldn't the old ones possibly stay in there? What if the counts are different? |
|
Hi @petrasovaa, Thanks for pointing it out, it helped me clarify the issue.
So it seems old cats are read in are interacting with new ones and getting merged instead of replacing. Regarding inti thing, it doesnt appear to fully clear prev read cats, If we avoid reading existings cats and start with clean structure we still need init to initializa the structure properly before applying new rules. so coming to the fix,
the first one seems more cleaner, does this approach align with the intended behaviour, if yes i will proceed and implement and then update this PR. |
|
One way or another, this needs a set of tests covering r.category and r.support title functionality. The test should make clear what is happening with the title and when. |
|
Hi @wenzeslaus , I worked on the tests by adding for the r.category,r.title functionality, in the tests env (simple dataset) everything works fine and cats are clearly replaced, so the issue is not reproduced there. But when teste manually where existing cats are present, the old cats still remains and get mixed with new ones, so it seems to depends on existing metadata. I tried a fix and tested it manually and this time the cats were properly reinitialized before applying new rules, and it seems to resolve the issue ! Right now the behaviour is not been able to reproduce inside pytest, should i still try to simulate that behavior or can i push that fix which corrects the behavior? |
|
I don't want to merge the change without a test which parallels the encountered issue. |
Fixes #7199
I was able to reproduce the issue locally where the raster title set using r.support gets removed after running r.category.
in code categories were initialized with empty title and was overwritten by existing raster title, fixed this issue by reading the existing metadata before modifying it, thus preserving the raster title.
I tested the fix locally multiple times with many scenarios to ensure title remains unchanged after applying categories