Yh cyber windowed blending sampler - #53
Conversation
Coverage Report for CI Build 32536161368Coverage increased (+1.2%) to 97.921%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
KurbyDoo
left a comment
There was a problem hiding this comment.
overall the structure looks good, just some things to clean up function boundaries and make testing easier
| column_distance = np.abs(columns - center_column) | ||
|
|
||
| # weight: apply formula. multiplied 0.9 so values stay above 0 | ||
| row_weight = 1 - 0.9 * row_distance / (height / 2) |
There was a problem hiding this comment.
should this be (height - 1) / 2 and (width - 1) / 2? If so reuse center_row and center_column
| ) -> list[tuple[int, int]]: | ||
| """Takes a region height and width, a window size, and a step size, and returns the list of top left positions to place windows at. | ||
| The step is smaller than the window, which is what makes them overlap. | ||
| If step does not divide evenly (extends), push last window to row/column of region_cl/row - window_size, so that no window hangs over the edge.""" |
There was a problem hiding this comment.
Lets change this to assert that the region is divisible by the window size, this will simplify the function body
There was a problem hiding this comment.
so throw an error if the window is not divisible
| return positions | ||
|
|
||
|
|
||
| def weight_grid(height: int, width: int) -> np.ndarray: |
There was a problem hiding this comment.
if the window size is always going to be square, lets change the parameters to only take in an edge length
There was a problem hiding this comment.
then we can simplify the body below to not compute separately for columns and rows
| seed: int, height: int, width: int, window_size: int, step: int, pipeline, store | ||
| ) -> np.ndarray: | ||
| """Make noise canvas of given dimensions. Make noise and weight grid. | ||
| For each window position, cut the window out of the noise canvas, send it to pipeline (#23), add the processed output and its weight to Terrain Store (at that position). |
There was a problem hiding this comment.
can you clean up the comments to avoid referencing the issue numbers
|
|
||
| processed_patch = pipeline.generate( | ||
| window | ||
| ) # based on unmerged commit i believe this will be pipeline.generate(window) |
There was a problem hiding this comment.
should be merged now, could you rebase to verify?
sorry nevermind it isn't merged and similar to the store, I think we want to change this to not take in a pipeline object, see the comment on the header of this function
| window | ||
| ) # based on unmerged commit i believe this will be pipeline.generate(window) | ||
|
|
||
| store.add(processed_patch, row, column, weights) |
There was a problem hiding this comment.
I think the interface for store might be a bit different, but this is fine for now
| def test_greater_zero(self): | ||
| "Assert every value is greater than zero" | ||
| weights = weight_grid(10, 20) | ||
| assert np.all(weights > 0) |
There was a problem hiding this comment.
Can you add a test with concrete values, pick a 9x9 region with 3x3 window size and assert the window matches to a deterministic 9x9 grid
| return weights | ||
|
|
||
|
|
||
| def starting_noise(seed: int, height: int, width: int) -> np.ndarray: |
There was a problem hiding this comment.
can you rename to something general to what the function does? like generate_noise_from_seed or something
| assert noise.shape == (height, width) | ||
|
|
||
|
|
||
| class FakePipeline: |
There was a problem hiding this comment.
nit: you can call objects "Mocks" if they are fake representations of a object to be built later
There was a problem hiding this comment.
actually, can you look into the mocker pytest fixture to generate mocks for these objects instead of creating new classes?
| return generator.random((height, width)) | ||
|
|
||
|
|
||
| def produce_region( |
There was a problem hiding this comment.
lets not pass the store into this function, instead make the function return the weight and weighted sum grid. the caller of this method should be responsible for caching in the terrain store afterwards, this way we can avoid making mocks for the store in this change
There was a problem hiding this comment.
~~and same with the pipeline, this function looks like its trying to do what generation orchestration does ~~
for now lets keep the pipeline but remove the store, we can change this later
|
I have a fix for the script error? Could you take a look #54 |
Summary
Validation
scripts/quality-check.shpasses locally/testcommands were run and are passing (e.g./test gpu)Checklist
Additional Comments
I think there might be something wrong with scripts/quality-check.sh for me.
This is what I got when I ran scripts/quality-check.sh