diff --git a/setup.cfg b/setup.cfg index c1060e5..b24a570 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,7 +26,6 @@ packages = find: package_dir = = src install_requires = - numba numpy colorama tqdm @@ -41,6 +40,7 @@ console_scripts = [options.extras_require] decision = graphviz + numba dev = black diff --git a/src/doddle/cli.py b/src/doddle/cli.py index 24d3f11..d7cb61a 100644 --- a/src/doddle/cli.py +++ b/src/doddle/cli.py @@ -91,7 +91,7 @@ def main() -> None: def parse_args(args: Sequence[str]) -> None: parser = ArgumentParser() - subparsers = parser.add_subparsers() + subparsers = parser.add_subparsers(required=True) run_parser = subparsers.add_parser("run") run_parser.add_argument("--answer", required=True, type=Word) @@ -124,4 +124,8 @@ def parse_args(args: Sequence[str]) -> None: benchmark_parser.set_defaults(func=benchmark_performance) namespace = parser.parse_args(args) + if not hasattr(namespace, "func"): + parser.print_help() + return + namespace.func(namespace) diff --git a/src/doddle/histogram.py b/src/doddle/histogram.py index 8937595..5364ddb 100644 --- a/src/doddle/histogram.py +++ b/src/doddle/histogram.py @@ -5,7 +5,6 @@ from typing import Callable, Iterator, TypeVar import numpy as np -from numba import njit # type: ignore from .guess import Guess from .scoring import Scorer @@ -134,7 +133,6 @@ def to_histogram(solns_by_score: dict[int, WordSeries]) -> np.ndarray: return vector -@njit def _populate_histogram(matrix: np.ndarray, row: int, hist: np.ndarray) -> bool: """Aggressive optimisation of the histogram creation. diff --git a/src/doddle/scoring.py b/src/doddle/scoring.py index 4b63610..e0e8ca3 100644 --- a/src/doddle/scoring.py +++ b/src/doddle/scoring.py @@ -1,5 +1,4 @@ import numpy as np -from numba import int8, int32, jit # type: ignore from .words import Word @@ -72,7 +71,6 @@ def score_word(self, solution: Word, guess: Word) -> int: return _score_word_jit(solution.vector, guess.vector, self._powers) -@jit(int32(int8[:], int8[:], int32[:]), nopython=True) def _score_word_jit(solution_array: np.ndarray, guess_array: np.ndarray, powers: np.ndarray) -> int: """Optimised internal call to score a word. See Solver.score_word(...) for details.""" diff --git a/src/doddle/words.py b/src/doddle/words.py index 6091a0a..772d6ef 100644 --- a/src/doddle/words.py +++ b/src/doddle/words.py @@ -153,7 +153,7 @@ def __find_index(self, value: str | Word) -> int: def __getitem__(self, s: slice | np.ndarray) -> WordSeries: is_slice = isinstance(s, slice) - is_mask = isinstance(s, np.ndarray) and s.dtype == np.bool8 + is_mask = isinstance(s, np.ndarray) and s.dtype == np.bool_ is_index = isinstance(s, np.ndarray) and s.dtype == np.int_ can_index = is_slice or is_mask or is_index