Skip to content

Commit

Permalink
changed Number
Browse files Browse the repository at this point in the history
  • Loading branch information
lfarv committed Dec 29, 2023
1 parent d2fe15d commit b5661c7
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pyat/at/lattice/variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,10 @@ def _getfun(self, **kwargs):
from __future__ import annotations
import numpy as np
import abc
from numbers import Number
from operator import add, sub, mul, truediv, pos, neg
from collections import deque
from collections.abc import Iterable, Sequence, Callable
from typing import Any
from typing import Any, Union

__all__ = [
"VariableBase",
Expand All @@ -98,6 +97,8 @@ def _getfun(self, **kwargs):
"VariableList",
]

Number = Union[int, float]


def _nop(value):
return value
Expand All @@ -116,7 +117,7 @@ class _Scalar(_Evaluate):
__slots__ = "value"

def __init__(self, value):
if not isinstance(value, Number):
if not isinstance(value, (int, float)):
raise TypeError("The parameter value must be a scalar")
self.value = value

Expand All @@ -129,7 +130,7 @@ class _BinaryOp(_Evaluate):

@staticmethod
def _set_type(value):
if isinstance(value, Number):
if isinstance(value, (int, float)):
return _Scalar(value)
elif isinstance(value, VariableBase):
return value
Expand Down Expand Up @@ -504,8 +505,8 @@ def __init__(
*,
name: str = "",
conversion: Callable[[Any], Number] = _nop,
bounds: tuple[float, float] = (-np.inf, np.inf),
delta: float = 1.0,
bounds: tuple[Number, Number] = (-np.inf, np.inf),
delta: Number = 1.0,
):
"""
Expand Down

0 comments on commit b5661c7

Please sign in to comment.