Skip to content

BUG: Cast 8-byte long double arrays to float64 - #958

Closed
shan3520 wants to merge 2 commits into
bashtage:mainfrom
shan3520:fix-longdouble-float64
Closed

shan3520 wants to merge 2 commits into
bashtage:mainfrom
shan3520:fix-longdouble-float64

Conversation

@shan3520

Copy link
Copy Markdown

On Windows and Apple Silicon np.longdouble is 8 bytes, dtype is float64 despite the types not matching. as_float64, to_array_1d, and _float64_pandas left it uncast, and numpy.linalg complained:

import numpy as np
from arch.unitroot import ADF
rng = np.random.default_rng(0)
ADF(np.cumsum(rng.standard_normal(200)).astype(np.longdouble))
# TypeError: array type float64 is unsupported in linalg

This impacts ADF, ZivotAndrews, engle_granger, phillips_ouliaris, DynamicOLS and FullyModifiedOLS (as well as 8.0), and x parameter of ARX classes (since #948).

Dtype checks are now done on dtype.type == np.float64. pandas astype(np.float64) does nothing to 8-byte long double, so it gets casted using NumPy.

Tests with the new check fail on Windows before this commit, but pass afterwards. Since on Linux long double is 16 bytes, these tests always pass there. There are currently 7 failed tests in test_covariance_dtypes.py that are already merged into main (#942 vs #948).

On Windows and Apple Silicon np.longdouble is 8 bytes, and its dtype compares
equal to float64 although it is a different type. as_float64, to_array_1d and
_float64_pandas returned such data unchanged, so numpy.linalg rejected it with
"array type float64 is unsupported in linalg" in ADF, ZivotAndrews,
engle_granger, phillips_ouliaris, DynamicOLS, FullyModifiedOLS and the exogenous
regressors of the ARX models. Compare the type of the dtype with np.float64, and
convert long double pandas data through NumPy, since pandas astype treats it as
float64 and does not convert it.
@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.01%. Comparing base (d921c35) to head (dc4c6b8).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #958   +/-   ##
=======================================
  Coverage   99.00%   99.01%           
=======================================
  Files         129      129           
  Lines       28773    28800   +27     
  Branches     2231     2234    +3     
=======================================
+ Hits        28488    28515   +27     
  Misses        233      233           
  Partials       52       52           
Flag Coverage Δ
adder 98.95% <100.00%> (+<0.01%) ⬆️
subtractor 98.95% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@shan3520

Copy link
Copy Markdown
Author

#957 handled this in the same manner (dtype.char == "d" and re-building pandas data structures which use long double columns). The dtype table in test_validation_dtypes.py for bashtage includes ADF, engle_granger, and ARX x with np.longdouble. Since the changes in this PR are duplicates of what is now in main after the merge, I am closing this PR.

@shan3520 shan3520 closed this Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant