File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 3
3
"""
4
4
__all__ = ['finfo' , 'iinfo' ]
5
5
6
+ import types
6
7
import warnings
7
8
8
9
from .._utils import set_module
@@ -487,6 +488,8 @@ class finfo:
487
488
488
489
_finfo_cache = {}
489
490
491
+ __class_getitem__ = classmethod (types .GenericAlias )
492
+
490
493
def __new__ (cls , dtype ):
491
494
try :
492
495
obj = cls ._finfo_cache .get (dtype ) # most common path
@@ -689,6 +692,8 @@ class iinfo:
689
692
_min_vals = {}
690
693
_max_vals = {}
691
694
695
+ __class_getitem__ = classmethod (types .GenericAlias )
696
+
692
697
def __init__ (self , int_type ):
693
698
try :
694
699
self .dtype = numeric .dtype (int_type )
Original file line number Diff line number Diff line change 1
1
""" Test functions for limits module.
2
2
3
3
"""
4
+ import types
4
5
import warnings
5
6
import numpy as np
6
7
import pytest
@@ -192,3 +193,11 @@ def test_plausible_finfo():
192
193
assert_ (info .nmant > 1 )
193
194
assert_ (info .minexp < - 1 )
194
195
assert_ (info .maxexp > 1 )
196
+
197
+
198
+ class TestRuntimeSubscriptable :
199
+ def test_finfo_generic (self ):
200
+ assert isinstance (np .finfo [np .float64 ], types .GenericAlias )
201
+
202
+ def test_iinfo_generic (self ):
203
+ assert isinstance (np .iinfo [np .int_ ], types .GenericAlias )
You can’t perform that action at this time.
0 commit comments