Skip to content

Commit

Permalink
single-source version in setup
Browse files Browse the repository at this point in the history
  • Loading branch information
epistoteles committed Jun 4, 2024
1 parent 90ba00e commit ea7ea45
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 22 deletions.
36 changes: 22 additions & 14 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
[metadata]
name = tensorhue,
author = epistoteles,
author_email = <[email protected]>,
description = ,
long_description_content_type = text/markdown,
long_description = ,
install_requires = ,
keywords = ,
name = tensorhue
version = attr: tensorhue.__version__
author = epistoteles
author_email = <[email protected]>
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
Expand Down
6 changes: 1 addition & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
from setuptools import setup, find_packages
from tensorhue.version import VERSION

DESCRIPTION = ""
LONG_DESCRIPTION = ""

setup(version=VERSION)
setup()
34 changes: 32 additions & 2 deletions tensorhue/__init__.py
Original file line number Diff line number Diff line change
@@ -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__ = []

Expand Down Expand Up @@ -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)
1 change: 0 additions & 1 deletion tensorhue/version.py

This file was deleted.

0 comments on commit ea7ea45

Please sign in to comment.