diff --git a/thursday/hipsterplot.py b/thursday/external/hipsterplot.py similarity index 100% rename from thursday/hipsterplot.py rename to thursday/external/hipsterplot.py diff --git a/thursday/internal/__main__.py b/thursday/internal/__main__.py new file mode 100644 index 0000000..7015191 --- /dev/null +++ b/thursday/internal/__main__.py @@ -0,0 +1,7 @@ +from .birect import main as birect_main +from .hg import main as hg_main +from .soo import main as soo_main + +birect_main() +hg_main() +soo_main() diff --git a/thursday/internal/birect.py b/thursday/internal/birect.py index 568f7f1..494bc03 100644 --- a/thursday/internal/birect.py +++ b/thursday/internal/birect.py @@ -329,7 +329,7 @@ def birect( return argmin, fmin -if __name__ == "__main__": +def main(): import numpy as np def objective2210(x): @@ -358,3 +358,7 @@ if __name__ == "__main__": ) print("", "birect result:", *res, sep="\n") print("", "double checked:", objective2210(np.array(res[0], F)), sep="\n") + + +if __name__ == "__main__": + main() diff --git a/thursday/internal/hg.py b/thursday/internal/hg.py index 67e5ed2..8d6fa11 100644 --- a/thursday/internal/hg.py +++ b/thursday/internal/hg.py @@ -109,9 +109,9 @@ def minimize( return center, history -if __name__ == "__main__": +def main(): # get this here: https://github.com/imh/hipsterplot/blob/master/hipsterplot.py - from hipsterplot import plot + from thursday.external.hipsterplot import plot prng = np.random.default_rng(42070) @@ -150,3 +150,7 @@ if __name__ == "__main__": print("loss, before optimization: {:9.6f}".format(true_objective(init))) print("loss, after optimization: {:9.6f}".format(true_objective(optimized))) + + +if __name__ == "__main__": + main() diff --git a/thursday/internal/soo.py b/thursday/internal/soo.py index 73136c3..437abc2 100644 --- a/thursday/internal/soo.py +++ b/thursday/internal/soo.py @@ -110,9 +110,9 @@ def soo(obj, origin, sigma, evals, K=3, h_max=None, iters=None, _adapt=None): return coords(h, p) + origin, history -if __name__ == "__main__": +def main(): # get this here: https://github.com/imh/hipsterplot/blob/master/hipsterplot.py - from hipsterplot import plot + from thursday.external.hipsterplot import plot import numpy as np def objective2210(x): @@ -143,3 +143,7 @@ if __name__ == "__main__": plot(np.log10(history), num_y_chars=23) print("", "soo result:", list(optimized), history[-1], sep="\n") print("", "double checked:", objective2210(optimized), sep="\n") + + +if __name__ == "__main__": + main()