From f0ea7750aaf3b6c3e2e95b485424fcc72f85d80b Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Sun, 7 May 2023 06:33:02 -0700 Subject: [PATCH] move colored printers into their own file --- thursday/utilities/__init__.py | 4 ++-- thursday/utilities/colors.py | 18 ++++++++++++++++++ thursday/utilities/utils.py | 19 ------------------- thursday/utilities/utils_np.py | 2 +- 4 files changed, 21 insertions(+), 22 deletions(-) create mode 100644 thursday/utilities/colors.py diff --git a/thursday/utilities/__init__.py b/thursday/utilities/__init__.py index 96161e7..79b9211 100644 --- a/thursday/utilities/__init__.py +++ b/thursday/utilities/__init__.py @@ -1,3 +1,5 @@ +from .colors import * +from .prog80 import prog from .utils import * try: @@ -6,5 +8,3 @@ except ModuleNotFoundError: pass else: from .utils_np import * - -from .prog80 import prog diff --git a/thursday/utilities/colors.py b/thursday/utilities/colors.py new file mode 100644 index 0000000..abfd9ac --- /dev/null +++ b/thursday/utilities/colors.py @@ -0,0 +1,18 @@ +color_factory = lambda color: lambda s: print(f"\033[{color}m{s}\033[m") +m1 = color_factory(1) +m30 = color_factory(30) +m31 = color_factory(31) +m32 = color_factory(32) +m33 = color_factory(33) +m34 = color_factory(34) +m35 = color_factory(35) +m36 = color_factory(36) +m37 = color_factory(37) +m90 = color_factory(90) +m91 = color_factory(91) +m92 = color_factory(92) +m93 = color_factory(93) +m94 = color_factory(94) +m95 = color_factory(95) +m96 = color_factory(96) +m97 = color_factory(97) diff --git a/thursday/utilities/utils.py b/thursday/utilities/utils.py index 0a308d2..f46fdc1 100644 --- a/thursday/utilities/utils.py +++ b/thursday/utilities/utils.py @@ -6,25 +6,6 @@ tiniest = 2.0**-1022.0 check = object() # secret "key" to pass to wrap_untrustworthy to extract feval_count final = object() # secret "key" to pass to wrap_untrustworthy to extract results -color_factory = lambda color: lambda s: print(f"\033[{color}m{s}\033[m") -m1 = color_factory(1) -m30 = color_factory(30) -m31 = color_factory(31) -m32 = color_factory(32) -m33 = color_factory(33) -m34 = color_factory(34) -m35 = color_factory(35) -m36 = color_factory(36) -m37 = color_factory(37) -m90 = color_factory(90) -m91 = color_factory(91) -m92 = color_factory(92) -m93 = color_factory(93) -m94 = color_factory(94) -m95 = color_factory(95) -m96 = color_factory(96) -m97 = color_factory(97) - class ExhaustedTrialsError(Exception): pass diff --git a/thursday/utilities/utils_np.py b/thursday/utilities/utils_np.py index 6491805..e8d7a70 100644 --- a/thursday/utilities/utils_np.py +++ b/thursday/utilities/utils_np.py @@ -1,6 +1,6 @@ # i've separated numpy-dependent methods from the rest of the utils. +from . import AcquireForWriting, merge_summaries, feps, m33, m34, m93 from time import time -from .utils import AcquireForWriting, merge_summaries, feps, m33, m34, m93 import numpy as np