From 52cc0dd6d7e554d15470791ce36793c3b8ad73d4 Mon Sep 17 00:00:00 2001 From: Wolfgang Noichl Date: Thu, 30 Oct 2025 15:15:32 +0100 Subject: [PATCH] defined multiplication by integer and small bugfixes --- hexutil/__init__.py | 13 +++++++++++-- setup.py | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/hexutil/__init__.py b/hexutil/__init__.py index 09b3a33..5146d92 100644 --- a/hexutil/__init__.py +++ b/hexutil/__init__.py @@ -58,7 +58,16 @@ def __sub__(self, other): def __neg__(self): x, y = self return Hex(-x, -y) - + + def __mul__(self, other): + x, y = self + if type(other) == int: + return Hex(other*x, other*y) + raise NotImplementedError() + + def __rmul__(self, other): + return self * other + def distance(self, other): """Distance in number of hexagon steps. Direct neighbours of this hex have distance 1. @@ -186,7 +195,7 @@ class Rectangle(namedtuple("Rectangle", "x y width height")): pass def _tiled_range(lo, hi, tile_size): - return range(lo // tile_size, (hi + tile_size - 1) // tile_size) + return range(int(lo // tile_size), int((hi + tile_size - 1) // tile_size)) def _make_range(x, width, bloat, grid_size): return _tiled_range(x + grid_size - 1 - bloat, x + width + bloat, grid_size) diff --git a/setup.py b/setup.py index 8d47aac..1388f06 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the README file -with open(path.join(here, 'README'), encoding='utf-8') as f: +with open(path.join(here, 'README.md'), encoding='utf-8') as f: long_description = f.read() setup(