array-api icon indicating copy to clipboard operation
array-api copied to clipboard

Why `_types.finfo_object` and `_types.iinfo_object`, `_array_object._array` does not inherit `Protocol` ?

Open 34j opened this issue 1 year ago • 0 comments

https://github.com/data-apis/array-api/blob/6d205d72dde3db8fc8668ad6aef5d003cc8ef80f/src/array_api_stubs/_draft/_types.py#L60-L79

 class finfo_object(Protocol[dtype]): 
     """Dataclass returned by `finfo`.""" 
  
     bits: int 
     eps: float 
     max: float 
     min: float 
     smallest_normal: float 
     dtype: dtype 
  
  
 class iinfo_object(Protocol[dtype]): 
     """Dataclass returned by `iinfo`.""" 
  
     bits: int 
     max: int 
     min: int 
     dtype: dtype 

I wonder why they are defined as dataclass

https://github.com/data-apis/array-api/blob/6d205d72dde3db8fc8668ad6aef5d003cc8ef80f/src/array_api_stubs/_draft/array_object.py#L19-L20

array = TypeVar("array", bound="_array")

class _array(Protocol[Device, Dtype, PyCapsule, array])
	def __add__(self, other: Union[int, float, array], /) -> array:

34j avatar Nov 24 '24 06:11 34j