diff --git a/setup.cfg b/setup.cfg index 27d9e1b..a806ea1 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,25 +1,33 @@ [metadata] -name = tensorhue, -author = epistoteles, -author_email = , -description = , -long_description_content_type = text/markdown, -long_description = , -install_requires = , -keywords = , +name = tensorhue +version = attr: tensorhue.__version__ +author = epistoteles +author_email = +description = +long_description_content_type = text/markdown +long_description = +install_requires = +keywords = classifiers= - "Development Status :: 1 - Planning", - "Intended Audience :: Developers", - "Programming Language :: Python :: 3", - "Operating System :: Unix", - "Operating System :: MacOS :: MacOS X", - "Operating System :: Microsoft :: Windows", + "Development Status :: 1 - Planning" + "Intended Audience :: Developers" + "Programming Language :: Python :: 3" + "Operating System :: Unix" + "Operating System :: MacOS :: MacOS X" + "Operating System :: Microsoft :: Windows" [options] package = tensorhue python_requires = >=3.9 zip_safe = no +[project] +name = "tensorhue" +dynamic = ["version"] + +[tool.setuptools.dynamic] +version = {attr = "tensorhue.__version__"} + [options.extras_require] testing = pre-commit diff --git a/setup.py b/setup.py index 800bdeb..1030e43 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,3 @@ from setuptools import setup, find_packages -from tensorhue.version import VERSION -DESCRIPTION = "" -LONG_DESCRIPTION = "" - -setup(version=VERSION) +setup() diff --git a/tensorhue/__init__.py b/tensorhue/__init__.py index 01ea41b..42ea1b6 100644 --- a/tensorhue/__init__.py +++ b/tensorhue/__init__.py @@ -1,10 +1,9 @@ import sys from rich.console import Console import numpy as np -from tensorhue.version import VERSION from tensorhue.colors import COLORS -__version__ = VERSION +__version__ = "0.0.2" # single source of version truth __all__ = [] @@ -50,12 +49,43 @@ def _viz_tensor(self, colors: tuple[tuple[int], tuple[int]] = None) -> None: f"[rgb({color[y, x, 0]},{color[y, x, 1]},{color[y, x, 2]}) on rgb({bgcolor[y, x, 0]},{bgcolor[y, x, 1]},{bgcolor[y, x, 2]})]▀[/]" ) result_parts.append("\n") + if shape[0] % 2 == 1: + for x in range(shape[1]): + result_parts.append(f"[rgb({color[-1, x, 0]},{color[-1, x, 1]},{color[-1, x, 2]})]▀[/]") c = Console(log_path=False, record=False) c.print("".join(result_parts)) + return "".join(result_parts) # automagically set up TensorHue if "torch" in sys.modules: torch = sys.modules["torch"] setattr(torch.Tensor, "viz", viz) + + +# def _viz_tensor_alt(self, colors: tuple[tuple[int], tuple[int]] = None) -> None: +# if colors is None: +# colors = COLORS["default_dark"], COLORS["default_bright"] +# data = self.data.numpy() +# shape = data.shape +# dim = data.ndim +# color_a = np.array(colors[0]) +# color_b = np.array(colors[1]) +# color = ((1 - data[::2, :, None]) * color_a + data[::2, :, None] * color_b).astype(int) +# bgcolor = ((1 - data[1::2, :, None]) * color_a + data[1::2, :, None] * color_b).astype(int) + +# result_parts = [] +# for y in range(shape[0] // 2): +# for x in range(shape[1]): +# result_parts.append( +# f"[rgb({color[y, x, 0]},{color[y, x, 1]},{color[y, x, 2]}) on rgb({bgcolor[y, x, 0]},{bgcolor[y, x, 1]},{bgcolor[y, x, 2]})]▀[/]" +# ) +# result_parts.append("\n") +# if shape[0] % 2 == 1: +# for x in range(shape[1]): +# result_parts.append(f"[rgb({color[-1, x, 0]},{color[-1, x, 1]},{color[-1, x, 2]})]▀[/]") + +# c = Console(log_path=False, record=False) +# c.print("".join(result_parts)) +# # return "".join(result_parts) diff --git a/tensorhue/version.py b/tensorhue/version.py deleted file mode 100644 index 901e511..0000000 --- a/tensorhue/version.py +++ /dev/null @@ -1 +0,0 @@ -VERSION = "0.0.1"