44
55from  __future__ import  annotations 
66
7- from  numpy  import  empty , ndarray 
7+ import  numpy 
8+ from  numpy  import  empty 
89from  numpy .linalg  import  inv 
910
1011from  linearmodels .iv .covariance  import  (
1112    KERNEL_LOOKUP ,
1213    cov_kernel ,
1314    kernel_optimal_bandwidth ,
1415)
15- from  linearmodels .typing   import   Float64Array 
16+ import  linearmodels .typing . data 
1617
1718
1819class  _HACMixin :
1920    def  __init__ (self , kernel : str , bandwidth : float  |  None ) ->  None :
2021        self ._kernel : str  |  None  =  None 
2122        self ._bandwidth : float  |  None  =  None   # pragma: no cover 
22-         self ._moments : ndarray  =  empty ((0 ,))  # pragma: no cover 
23+         self ._moments : numpy . ndarray  =  empty ((0 ,))  # pragma: no cover 
2324        self ._check_kernel (kernel )
2425        self ._check_bandwidth (bandwidth )
2526
@@ -60,7 +61,9 @@ def _check_bandwidth(self, bandwidth: float | None) -> None:
6061            if  bandwidth  <  0 :
6162                raise  ValueError ("bandwidth must be non-negative." )
6263
63-     def  _kernel_cov (self , z : Float64Array ) ->  Float64Array :
64+     def  _kernel_cov (
65+         self , z : linearmodels .typing .data .Float64Array 
66+     ) ->  linearmodels .typing .data .Float64Array :
6467        nobs  =  z .shape [0 ]
6568        bw  =  self .bandwidth 
6669        kernel  =  self ._kernel 
@@ -96,10 +99,10 @@ class HeteroskedasticCovariance:
9699
97100    def  __init__ (
98101        self ,
99-         xe : Float64Array ,
102+         xe : linearmodels . typing . data . Float64Array ,
100103        * ,
101-         jacobian : ndarray  |  None  =  None ,
102-         inv_jacobian : ndarray  |  None  =  None ,
104+         jacobian : numpy . ndarray  |  None  =  None ,
105+         inv_jacobian : numpy . ndarray  |  None  =  None ,
103106        center : bool  =  True ,
104107        debiased : bool  =  False ,
105108        df : int  =  0 ,
@@ -131,7 +134,7 @@ def config(self) -> dict[str, str | float]:
131134        return  {"type" : self .__class__ .__name__ }
132135
133136    @property  
134-     def  s (self ) ->  Float64Array :
137+     def  s (self ) ->  linearmodels . typing . data . Float64Array :
135138        """ 
136139        Score/moment condition covariance 
137140
@@ -149,7 +152,7 @@ def s(self) -> Float64Array:
149152        return  (out  +  out .T ) /  2 
150153
151154    @property  
152-     def  jacobian (self ) ->  Float64Array :
155+     def  jacobian (self ) ->  linearmodels . typing . data . Float64Array :
153156        """The Jacobian""" 
154157        if  self ._jac  is  None :
155158            assert  self ._inv_jac  is  not   None 
@@ -158,7 +161,7 @@ def jacobian(self) -> Float64Array:
158161        return  self ._jac 
159162
160163    @property  
161-     def  inv_jacobian (self ) ->  Float64Array :
164+     def  inv_jacobian (self ) ->  linearmodels . typing . data . Float64Array :
162165        """Inverse Jacobian""" 
163166        if  self ._inv_jac  is  None :
164167            assert  self ._jac  is  not   None 
@@ -172,7 +175,7 @@ def square(self) -> bool:
172175        return  self ._square 
173176
174177    @property  
175-     def  cov (self ) ->  Float64Array :
178+     def  cov (self ) ->  linearmodels . typing . data . Float64Array :
176179        """ 
177180        Compute parameter covariance 
178181
@@ -229,10 +232,10 @@ class KernelCovariance(HeteroskedasticCovariance, _HACMixin):
229232
230233    def  __init__ (
231234        self ,
232-         xe : Float64Array ,
235+         xe : linearmodels . typing . data . Float64Array ,
233236        * ,
234-         jacobian : ndarray  |  None  =  None ,
235-         inv_jacobian : ndarray  |  None  =  None ,
237+         jacobian : numpy . ndarray  |  None  =  None ,
238+         inv_jacobian : numpy . ndarray  |  None  =  None ,
236239        kernel : str  |  None  =  None ,
237240        bandwidth : float  |  None  =  None ,
238241        center : bool  =  True ,
@@ -262,7 +265,7 @@ def config(self) -> dict[str, str | float]:
262265        return  out 
263266
264267    @property  
265-     def  s (self ) ->  Float64Array :
268+     def  s (self ) ->  linearmodels . typing . data . Float64Array :
266269        """ 
267270        Score/moment condition covariance 
268271
@@ -289,11 +292,15 @@ class HeteroskedasticWeight:
289292        Flag indicating to center the moments when computing the weights 
290293    """ 
291294
292-     def  __init__ (self , moments : Float64Array , center : bool  =  True ) ->  None :
295+     def  __init__ (
296+         self , moments : linearmodels .typing .data .Float64Array , center : bool  =  True 
297+     ) ->  None :
293298        self ._moments  =  moments 
294299        self ._center  =  center 
295300
296-     def  w (self , moments : Float64Array ) ->  Float64Array :
301+     def  w (
302+         self , moments : linearmodels .typing .data .Float64Array 
303+     ) ->  linearmodels .typing .data .Float64Array :
297304        """ 
298305        Score/moment condition weighting matrix 
299306
@@ -335,7 +342,7 @@ class KernelWeight(HeteroskedasticWeight, _HACMixin):
335342
336343    def  __init__ (
337344        self ,
338-         moments : Float64Array ,
345+         moments : linearmodels . typing . data . Float64Array ,
339346        center : bool  =  True ,
340347        kernel : str  |  None  =  None ,
341348        bandwidth : float  |  None  =  None ,
@@ -344,7 +351,9 @@ def __init__(
344351        _HACMixin .__init__ (self , kernel , bandwidth )
345352        super ().__init__ (moments , center = center )
346353
347-     def  w (self , moments : Float64Array ) ->  Float64Array :
354+     def  w (
355+         self , moments : linearmodels .typing .data .Float64Array 
356+     ) ->  linearmodels .typing .data .Float64Array :
348357        """ 
349358        Score/moment condition weighting matrix 
350359
0 commit comments