-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
generate_matrices_list()
helper method
- add docstrings to ErrorDiffusers and OrderedDitherers dataclass fields - add `simple-parsing` as a runtime requirement - update READMEs and TODO - add keywords in `pyproject.toml`
- Loading branch information
Showing
9 changed files
with
251 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2023, tfuxu <https://github.com/tfuxu> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
from dataclasses import asdict | ||
from typing import List, Tuple | ||
|
||
from simple_parsing.docstring import get_attribute_docstring | ||
|
||
from dither_go import ErrorDiffusionMatrix, OrderedDitherMatrix | ||
from dither_go.matrices import ErrorDiffusers, OrderedDitherers | ||
|
||
|
||
class MatrixUtils: # pylint: disable=R0903 | ||
""" | ||
A class for error diffusion and ordered dithering matrices utility methods. | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def generate_matrices_list(self) -> Tuple[List[Tuple[str, ErrorDiffusionMatrix]], List[Tuple[str, OrderedDitherMatrix]]]: | ||
""" | ||
Generates a list of available matrices in library with human-readable names. | ||
:returns: Two lists consisting of error diffusion and ordered dithering matrices with their display names. | ||
:rtype: Tuple[List[Tuple[str, ErrorDiffusionMatrix]], List[Tuple[str, OrderedDitherMatrix]]] | ||
""" | ||
|
||
error_diffusers = asdict(ErrorDiffusers()) | ||
ordered_ditherers = asdict(OrderedDitherers()) | ||
|
||
error_matrices = [] | ||
for key in error_diffusers: | ||
field_docstring = get_attribute_docstring(ErrorDiffusers, key).docstring_below | ||
display_name = field_docstring.strip().partition("\n")[0] | ||
|
||
error_matrices.append((display_name, error_diffusers[key])) | ||
|
||
ordered_matrices = [] | ||
for key in ordered_ditherers: | ||
field_docstring = get_attribute_docstring(OrderedDitherers, key).docstring_below | ||
display_name = field_docstring.strip().partition("\n")[0] | ||
|
||
ordered_matrices.append((display_name, ordered_ditherers[key])) | ||
|
||
return error_matrices, ordered_matrices |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
pybindgen | ||
simple-parsing |