grid-strategy
grid-strategy copied to clipboard
Fix RectangularStrategy() results if get_grid() argument is prime
RectangularStrategy, if get_grid takes in prime N, creates a one-row by N cols plots grid. This poses an issue with larger prime numbers (N > 3)
@MorganHaworth I am not sure there's much that can be done about that, because the whole point of "RectangularStrategy" is "find me an arrangement of plots where each row has the same number of columns". For prime numbers, that always means you'll have one row, which is the risk you're running by using RectangularStrategy
.
That said, I think we can probably do some refactoring to make it clearer what the difference between a Rectangular and Square strategy. I would think that a Square strategy would be the same as a Rectangular strategy, but with a constrained aspect ratio, but the real difference is that RectangularStrategy
is strict about keeping the number of columns per row the same, and SquareStrategy
relaxes that contraint in favor of keeping the aspect ratio closer to 1:1.
I'll have to think more about how the API should work, but I'm wondering if maybe we can refactor this and have RectangularStrategy
take an aspect ratio parameter, but otherwise have the same behavior as SquareStrategy
has now, and SquareStrategy
can just be an alias for RectangularStrategy(1, 1)
.
We can then migrate RectangularStrategy
to a new class named more to focus on the fact that it is enforcing the constraint that all rows have the same number of columns. Unfortunately, my intuition for how that should be called is "GridStrategy" (since it lays everything out on a grid), in which case maybe we should be calling this project subplot-strategy
...