OCHA-DAP / hdx-signals

HDX Signals
https://un-ocha-centre-for-humanitarian.gitbook.io/hdx-signals/
GNU General Public License v3.0
6 stars 0 forks source link

func - random_spatial_sample #75

Closed zackarno closed 6 months ago

zackarno commented 6 months ago

add func to drop points in any poly. Can be used for to generate points for proportional bubble map. Right now it just takes an sf class poly as an argument.

https://github.com/OCHA-DAP/hdx-signals/issues/65#issue-2287988570

Curious if you also get this warning below when pushing. I don't know what I could have done to generate it because I THINK i just edited this map_test.R file

remote: Resolving deltas: 100% (652/652), done.
remote: warning: See https://gh.io/lfs for more information.
remote: warning: File e4cce236d9b86bd566656f9318638d78aa3639d8 is 93.86 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com
caldwellst commented 6 months ago

Lastly, I think the point generation should be added to the map_test() function.

zackarno commented 6 months ago

thanks for all the comments! working on integrating them and am sure will have various replies comments as I go, but real quick regarding the style comments - how do we run styler on this repo since it's not included as a dep in {renv} -- I'd like to just run that and have it take care of alot of the style inconsistencies you spotted

zackarno commented 6 months ago

Lastly, I think the point generation should be added to the map_test() function.

On this, I wasn't entirely sure what you would done so didn't want to disrupt the flow. But I was thinking it could be beneficial to unwrap some of the nested/wrapped functionality inside map_test to make it more modular and easier for little developments (i.e adding point generation to maps). I was thinking we shouldn't have the load_* functionality built into the geom() functions. As this means we have to load admin boundary once to map it and then load it again just sample it. Feel like it would be good to continue (as in the rest of repo) to have functions more split by processes... for example : 1. loading, 2. processing, 3. visualizing/plotting, 4. saving. That way it's easier to check each phase when developing or manually testing.

Idk if what I say here makes sense, but I didn't want to start deconstructing any functions too much until we chatted so lets discuss tomorrow and figure out what makes most sense

caldwellst commented 6 months ago

So, map_test() is a convenience function used to test mapping conventions in terms of legend placement and saving dimensions, so one of our manual testing implementations. So not as worried about some of the efficiency things since the utilities are designed for use in the runs as well.

was thinking we shouldn't have the load_* functionality built into the geom() functions.

So, I would agree if we were building for map_test() alone, but I think the convenience is that you can just have a single geom() call to add in the things you want in all maps: adm0 boundaries and cities, and we aren't going to be messing with those ideally. Otherwise, in each map function for the indicators, we have to individually load in then map those.

how do we run styler on this repo since it's not included as a dep in {renv}

Simply install.packages("renv")! You can install whatever you want, and since you aren't using it in a script, it won't be caught by snapshot() by default and won't be in the lock file. It's how I often use tools like {usethis} in repos that use {renv}. As well, #79 is discussing using pre-commit which can automatically lint and maybe even style the code.

zackarno commented 6 months ago
zackarno commented 6 months ago
caldwellst commented 6 months ago

For testing, feel free to add. Don't think is critical because this is a test function, though, just something we want to manually run to check maps are looking alright. Not sure what is causing the text differences to be honest!

zackarno commented 6 months ago

Thanks for the comments -- all super useful and simplifying! I think i've integrated them all so ready for another review.

re-testing, yeah it's not critical I was just curious on the overall plan for unit-tests because as everyone always says... its way easier if you just write them as you go. Although I've never been strict enough with myself to do this, I thought i'd give it a try since I basically had the test ready to go

zackarno commented 6 months ago

o woops let me move the files around to the new directory first tests/manual/maps first

zackarno commented 6 months ago

ok now should be good to go!

zackarno commented 6 months ago

Not sure what is causing the text differences to be honest!

This seems critical. Hope it's not the same issue I was getting into w/ tmap on nga flood pilot as that was never resolved and made visual testing much more difficult

caldwellst commented 6 months ago

lol we have complete differences in what is being generated on our machines... @hannahker can you run this code and output it to another folder on our Google Drive, next to tmp/seth_map_test and Zack's dated folder?

zackarno commented 6 months ago

lol we have complete differences in what is being generated on our machines... @hannahker can you run this code and output it to another folder on our Google Drive, next to tmp/seth_map_test and Zack's dated folder?

lol thats concerning!

@hannahker fyi its just the script in test/manual/maps/implement_map_test.R

hannahker commented 6 months ago

Just ran -- see outputs under hannah_map_test. My outputs look pretty similar to @caldwellst's. I think it would make sense to test on an Actions runner too, since this is where they'll be generated in production?

caldwellst commented 6 months ago

Yes, agreed, see #90 for my idea of how we get to where this is easily possible. Something for next week.