Skip to content
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

Frontend improvements. #10

Merged
merged 9 commits into from
Mar 5, 2022
Merged

Frontend improvements. #10

merged 9 commits into from
Mar 5, 2022

Conversation

HexDecimal
Copy link
Contributor

This PR is a collection of refactors and changes I've made to make the library work better as a generic WFC library.

Waves are now resolved without a recursive call. The library no longer needs to mess with the Python recursion limit. These changes left a recursion-specific test to become unused, so I've removed that test.

I've replaced several print calls with the Python logging module. This will prevent excessive printing on the console without actually removing that logging capability. wfc_run.py still shows all of these logs.

Several type hints were updated, some because of bugs in the previous type hinting and others because the functions are more flexible than they were originally hinted. The hinting allowed me to refactor how the tile catalog was generated so that the output image will now have the same dtype as the input.

The execute_wfc function had several changes, the default parameters are better and the function can now take an image directly instead of a filename (not passing a filename will disable a lot of logging tools.) It also returns the visual image instead of the image tiles which were useless since the tile catalog wasn't returned with them. It now raises exceptions instead of returning None for failed runs which makes error handing easier.

The makeSearchLengthLimit constraint was mislabeled and caused bugs, so it's been removed. Right now there's no way to set a depth or iteration limit but there's nothing that seems to need one.

Closes #7, most of my issues are addressed by this PR, any remaining issues can later be raised as a separate issue.
Closes #8, this dev was trying to generate images without file I/O, which this PR supports.

The recursive test has been removed.

This library no longer messes with the Python recursion limit.
Hides excess output when this module is not being debugged.
execute_wfc can take an image instead of a filename.  It will now always
return the resolved image or raise an error.  The old return was not
useful since the tile catalog wasn't also returned.

No filename will disable most of the logging and disable writing image files.
Disable logging and visualization by default.

Heuristics now default to entropy/weighted for loc/choice.
The value of zero causes errors and was not a good default.

Pixel tile size is assumed to be common.
These are usually not expected, logging them at this level makes it
easier to track issues.
This named a depth limit, but it acts as an iteration limit.
The constraint also doesn't reset across attempts.

I've removed it for now.  There is a simpler way to implement this if needed.
I think it is not required for normal use.
Refactor code and update type hints to be more flexible.

Pixel data will stay compact when converted into a tile catalog.

Output image is now the same dtype as the input image.
@HexDecimal HexDecimal mentioned this pull request Mar 4, 2022
@ikarth ikarth marked this pull request as ready for review March 5, 2022 04:35
@ikarth ikarth merged commit 4921afb into ikarth:master Mar 5, 2022
@HexDecimal
Copy link
Contributor Author

I had this as a draft since I'm still making changes to it and wasn't sure about its current state. I'll likely make another PR with more updates related to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Weird generating bug?? Frontend improvements.
2 participants