@@ -118,8 +118,8 @@ def _hac_meat_loop(
118118 gamma_buffer .fill (0.0 )
119119 weight = weights [lag_value ]
120120
121- scores_current = scores [lag_value :time_periods ]
122- scores_lagged = scores [: time_periods - lag_value ]
121+ scores_current = np . ascontiguousarray ( scores [lag_value :time_periods , :])
122+ scores_lagged = np . ascontiguousarray ( scores [: time_periods - lag_value , :])
123123
124124 gamma_buffer [:, :] = scores_current .T @ scores_lagged
125125 meat += weight * (gamma_buffer + gamma_buffer .T )
@@ -142,10 +142,10 @@ def _get_bartlett_weights(lag: int):
142142@nb .njit (parallel = False )
143143def _nw_meat_time (scores : np .ndarray , time_arr : np .ndarray , lag : int ):
144144 if time_arr is None :
145- ordered_scores = scores
145+ ordered_scores = np . ascontiguousarray ( scores )
146146 else :
147147 order = np .argsort (time_arr )
148- ordered_scores = scores [order ]
148+ ordered_scores = np . ascontiguousarray ( scores [order ])
149149
150150 time_periods , k = ordered_scores .shape
151151 weights = _get_bartlett_weights (lag = lag )
@@ -191,7 +191,7 @@ def _get_panel_idx(
191191 return order , units , starts , counts , panel_arr_sorted , time_arr_sorted
192192
193193
194- # @nb.njit(parallel=False)
194+ @nb .njit (parallel = False )
195195def _nw_meat_panel (
196196 scores : np .ndarray ,
197197 time_arr : np .ndarray ,
@@ -229,6 +229,7 @@ def _nw_meat_panel(
229229
230230 weights = _get_bartlett_weights (lag = lag )
231231
232+ scores = np .ascontiguousarray (scores )
232233 k = scores .shape [1 ]
233234
234235 meat_nw_panel = np .zeros ((k , k ))
@@ -240,14 +241,14 @@ def _nw_meat_panel(
240241 for start , count in zip (starts , counts ):
241242 end = start + count
242243
243- score_i = scores [start :end , :]
244+ score_i = np . ascontiguousarray ( scores [start :end , :])
244245 gamma0 = score_i .T @ score_i
245246
246247 gamma_l_sum .fill (0.0 )
247248 Lmax = min (lag , count - 1 )
248249 for lag_value in range (1 , Lmax + 1 ):
249- score_curr = scores [start + lag_value : end , :]
250- score_prev = scores [start : end - lag_value , :]
250+ score_curr = np . ascontiguousarray ( scores [start + lag_value : end , :])
251+ score_prev = np . ascontiguousarray ( scores [start : end - lag_value , :])
251252 gamma_l = score_curr .T @ score_prev
252253 gamma_l_sum += weights [lag_value ] * (gamma_l + gamma_l .T )
253254
@@ -289,6 +290,7 @@ def _dk_meat_panel(
289290 time_periods , k = scores_time .shape
290291
291292 weights = _get_bartlett_weights (lag = lag )
293+ scores_time = np .ascontiguousarray (scores_time )
292294
293295 return _hac_meat_loop (
294296 scores = scores_time , weights = weights , time_periods = time_periods , k = k , lag = lag
0 commit comments