Repository navigation
ENH: Accept 0 and 1 as flags, negative positions and the horizon alias of align - #956
Merged
Merged
Conversation
…s of align Flags (decision 66): check_bool accepts bool, np.bool_ and the Python and NumPy integers 0 and 1, and returns a Python bool. Other integers raise a ValueError; floats (including 1.0), strings, arrays and None (where it is not the default) raise a TypeError. fit(disp=...) keeps "off", "final" and bool, with 0 and 1 now bool. arch.test now checks its exit and append flags. Positions (decision 71): check_index, and so first_obs and last_obs of fit and fix and start of forecast and hedgehog_plot, accept negative integers counted from the end. first_obs and last_obs are slice bounds (last_obs=-1 drops the last observation) and start is the index of an observation (start=-1 is the last). The same applies to start of VolatilityProcess.forecast, cutoff_to_index and find_index. Positions outside [-nobs, nobs] raise a ValueError, and dates are unchanged. The docstrings say so. Alias (decision 75): align="horizon" is documented as an alias of "target" in every forecast docstring and ARCHModelForecast, listed in the error message, and accepted by the forecast method of the models, which rejected it. It is part of the new ForecastAlignment type. The contributing guide and the 9.0 release notes describe the three rules.
The message of check_bool is now "must be True, False, 0 or 1" ("True, False, 0, 1
or None" where None is allowed), since 0 and 1 are accepted.
The maintainer answered decisions 63 and 66-73, so the contributing guide and the validation module no longer call them provisional.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #956 +/- ##
========================================
Coverage 99.01% 99.02%
========================================
Files 134 135 +1
Lines 29563 29859 +296
Branches 2290 2303 +13
========================================
+ Hits 29271 29567 +296
Misses 239 239
Partials 53 53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch
a90-val2-bool-positions-alias, 2 commits ona90-fix-main-tests.Merge #953 first. It is independent of #955 (they merge cleanly). This PR
covers release decisions 66, 71 and 75.
(int, np.integer types). Anything else is not bool enough."
check_boolacceptsbool,np.bool_and Python or NumPy integers equal to0 or 1, and returns a Python
bool.ValueError. Floats (including 1.0), strings, arraysand
None(where it is not the documented default) raiseTypeError. Themessage is now "must be True, False, 0 or 1".
rescale,low_memory(both still acceptNone),disp(which also keeps "off" and"final") and
center.arch.test(exit=..., append=...)now checks its flags too. Before,exit=2ran the whole test suite.
superset of (a). Also document this in docstrings and make sure there is a
release note."
pmeansnobs + p, as in Python; positionsoutside
[-nobs, nobs]raiseValueError. Dates are unchanged.first_obsandlast_obsoffitandfix, andcutoff_to_index, act asslice bounds:
last_obs=-1drops the last observation andfirst_obs=-100uses the last 100.
startofforecast(model, results and volatility process),hedgehog_plotandfind_indexis an observation index:start=-1is thelast observation.
align="horizon"(decision 75). "Document it and make it an officialalias."
forecastwithalignand inARCHModelForecast.forecast, which used to reject it, now accepts it through ashared check.
ForecastAlignmentalias is added toarch._typing.The contributing guide and the release notes are updated: one entry for the
flags, and entries for negative positions and the alias in New features.
Tests:
arch/tests/univariate/test_positions_and_alias.py(46 tests) compares eachnegative position with the equivalent positive one, with Python slicing, and
with a hand-computed ARCH(1) forecast. 37 of them fail on the base.
rows fail on the base).
Fast suite 24,738 passed. The only failures are the 7 covariance dtype tests that
also fail on main; a separate PR fixes them. The golden battery is identical.
numpydoc lint 0; style clean.
🤖 Generated with Claude Code