Skip to content

Commit

Permalink
numpy cannot handle derived int classes
Browse files Browse the repository at this point in the history
  • Loading branch information
huettenhain committed Dec 8, 2024
1 parent 2cbcf1f commit d6f3513
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
11 changes: 1 addition & 10 deletions refinery/lib/argformats.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@

from refinery.lib.frame import Chunk
from refinery.lib.tools import isbuffer, infinitize, one, normalize_to_identifier
from refinery.lib.types import NoMask
from refinery.lib.types import NoMask, RepeatedInteger
from refinery.lib.meta import is_valid_variable_name, metavars, Percentage

if TYPE_CHECKING:
Expand Down Expand Up @@ -145,15 +145,6 @@ class ParserVariableMissing(ParserError):
pass


class RepeatedInteger(int):
"""
This class serves as a dual-purpose result for `refinery.lib.argformats.numseq`
types. It is an integer, but can be infinitely iterated.
"""
def __iter__(self): return self
def __next__(self): return self


class LazyEvaluation:
"""
Empty parent class for any unit that throws `refinery.lib.argformats.TooLazy`.
Expand Down
9 changes: 9 additions & 0 deletions refinery/lib/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,12 @@ def __and__(self, other):
The value of `NoMask & X` and `X & NoMask` is always equal to `X`. This singleton serves as a
mock bitmask when the value `X` should not be masked at all.
"""


class RepeatedInteger(int):
"""
This class serves as a dual-purpose result for `refinery.lib.argformats.numseq` types. It
is an integer, but can be infinitely iterated.
"""
def __iter__(self): return self
def __next__(self): return self
2 changes: 1 addition & 1 deletion refinery/units/blockwise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ def _fastblock(self, data):
if isinstance(it, int):
if not masked:
it &= self.fmask
npa = it
npa = int(it)
elif self.precision is INF:
npa = numpy.array(list(itertools.islice(na, blocks)), dtype=dtype)
else:
Expand Down

0 comments on commit d6f3513

Please sign in to comment.