-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Domino Art #94
Comments
Sounds fun! Not sure I follow the reason for the What would the returned result be? Ideally we would not depend on matplotlib & pillow by default as these are far from the only image handling libraries out there. Maybe at first define the API with numpy arrays as the I/O format, and show how to ingest various image types in the docs? |
I can implement a function like so
but ideally I'd still allow users access to the Problem class. When a Problem object is instantiated there is a bit of work to do. For a 50 x 50 tile image with double-9 dominoes for example there are 270k domino/position combinations, and an objective coefficient must be calculated for each by computing the minimum of two squares. The whole thing takes about 8s on my machine - longer than the actual Gurobi solve time. This setup is invariant to the number of domino sets, so the above function would create unnecessary recomputation when users play around with the number of domino sets - which affects the quality of the image. A few options: i) keep the API as initially proposed
A dataclass with some basic stats about the solution, and an assignment of dominoes to positions. This can be then fed to a drawing function.
We're going to need conversion between images and numpy arrays on the front but also the back. Image -> array for reading, and array -> image for drawing solution. We also need the image library to resize and "posterize" for us. I think these details are best hid from the user, which means anchoring ourselves to some library - I don't mind which though. We could always include matplotlib and pillow as optional dependencies which get installed with |
Ok, makes sense to have the two step process in that situation.
I'm suggesting at a minimum the API should accept a numpy array as a (grayscale I presume?) bitmap. Then you aren't tied to a particular image format and the user can do e.g.:
If you also want to handle a pillow The same maybe true of the backend: matplotlib.imshow also expects a numpy array. |
Cool, I think I know what I need to do. Currently the pillow and matplotlib library is all under the hood - I should have renamed the Image class in my example to make it clear, it is a class that relies on pillow and matplotlib, but the user is never exposed to these libraries. Still thinking of rolling all functionality into one class that is presented to the user then just delegating methods under the hood, and handling the potential absence of matplotlib with exceptions à la
to |
Sure - although the CI jobs will not know to install the extras, so the jobs will always fail. While hacking away on your fork, just put pillow and matplotlib as regular dependencies to make sure they are installed, we can adjust later. |
Too easy, I'll look to sort it over the weekend. |
Why this Mod?
As seen in this article
Not everyone will have a but everyone has a picture. If you have a picture, you can approximate it with dominoes
What will the API be?
Very small. Something like:
It would ideally use matplotlib (for easy conversion of arrays to image) and Pillow (which is also a dependency of matplotlib)
The text was updated successfully, but these errors were encountered: