X-13ARIMA-SEATS wrapper (tsecon.x13)¶
A Python wrapper around the U.S. Census Bureau's X-13ARIMA-SEATS
seasonal-adjustment binary. Mirrors the Julia upstream's X13 module
(TimeSeriesEcon.jl/src/x13/)
API name-for-name where Python syntax allows.
The published wheels (M2.6 onward) vendor the X-13as binary inside
src/tsecon/x13/_binary/{x13as, x13as.exe} — pip install
TimeSeriesEconPy produces an immediately usable wrapper with no further
download step. Override the bundled binary by setting
setoption("x13path", ...) to the absolute path of a
locally installed x13as (useful for air-gapped sites, custom builds,
or debugging across versions).
Quick start¶
import numpy as np
import tsecon
n = 100
start = tsecon.MIT.from_yp(tsecon.Quarterly(), 2000, 1)
rng = tsecon.MITRange(start, start + (n - 1))
i = np.arange(n)
ts = tsecon.TSeries(rng, 100.0 + 0.5 * i + 5.0 * np.sin(2 * np.pi * i / 4))
# One-call deseasonalisation: default x11 spec with `save = "d11"`.
adj = tsecon.x13.deseasonalize(ts)
print(adj[:8])
# → [100.001…, 100.666…, 101.000…, …]
For finer control, build a full X13spec via
newspec and call
run directly; the result exposes every
parsed output table on result.series.* (and lazy proxies for tables
not in the load= set).
Running, deseasonalisation, and cleanup¶
tsecon.x13._x13 ¶
Module-level conveniences for :mod:tsecon.x13.
Mirrors the convenience block of TimeSeriesEcon.jl/src/x13/X13.jl
(X13.jl:42-98). The result-side types — :class:WorkspaceTable,
:class:X13ResultWorkspace, :class:X13lazy, :class:X13result,
:func:run, parsers — live in :mod:tsecon.x13._result. This sibling
hosts the three top-level convenience functions:
- :func:
cleanup— sweep stalex13_*temp folders that the per-result :func:weakref.finalizecallback missed (process hard kill, finalizer race at interpreter shutdown). Mirrors JuliacleanupatX13.jl:62-90. - :func:
deseasonalize— run a defaultx11spec on a TSeries and return a new TSeries with thed11(final seasonally adjusted series) values. Mirrors JuliadeseasonalizeatX13.jl:58. - :func:
deseasonalize_inplace— in-place flavour; replaces the values of the input TSeries in place. Mirrors Juliadeseasonalize!atX13.jl:52-57. The_inplacerename follows the existing TimeSeriesEconPy convention (Juliafoo!→ Pythonfoo_inplace) — see :func:tsecon.recursive.recand :func:tsecon.workspace.merge_inplacefor the parallel pattern.
The Julia upstream's module-level __init__ (X13.jl:92-98) prints
an @info warning at import time when 5+ stale x13_* folders are
found. Importing :mod:tsecon.x13 on every Python script start is
already slower than Julia's using (no in-process module cache); we
defer the leftover-folder count to the first :func:run call instead,
where it's emitted as a :class:UserWarning rather than as a print
statement.
get_cleanup_folders ¶
Return absolute paths of all x13_* folders in the system temp dir.
Mirrors Julia get_cleanup_folders at X13.jl:76-90. The Julia
version filters by current-user UID; on POSIX we keep that check
via :func:os.stat; on Windows we drop it (the system tempdir is
per-user by default).
Source code in src/tsecon/x13/_x13.py
cleanup ¶
Remove all stale x13_* folders from the system temp directory.
Mirrors Julia cleanup at X13.jl:62-74. Use this when a
previous Python process was hard-killed before the per-result
:func:weakref.finalize callbacks could fire, leaving X-13 temp
folders behind. Emits a :class:UserWarning summarising the count
removed (Julia prints to stdout; we use the warnings channel so
the message routes through the project's filterwarnings config).
Source code in src/tsecon/x13/_x13.py
deseasonalize_inplace ¶
Run a default x11 spec on ts and replace its values with the d11 series.
Mirrors Julia deseasonalize! at X13.jl:52-57. The default
seasonal-adjustment decomposition is multiplicative (mode="mult");
the seasonal filter defaults to the X-13 binary's automatic choice
unless seasonalma= is passed. kwargs are forwarded to
:func:tsecon.x13.x11 (the spec builder).
Returns ts for chaining (mirrors Julia's ts return).
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no X-13 binary is available — the bundled binary lands in
M2.6 (alongside the wheels matrix). Until then, point
|
Source code in src/tsecon/x13/_x13.py
deseasonalize ¶
Return a new TSeries with the X-11 seasonally adjusted values.
Mirrors Julia deseasonalize at X13.jl:58. Equivalent to
:func:deseasonalize_inplace on a copy of the input.
Source code in src/tsecon/x13/_x13.py
tsecon.x13._result.run ¶
run(
spec: X13spec | str,
freq: Frequency | None = None,
*,
verbose: bool = True,
allow_errors: bool = False,
load: str | Sequence[str] = "none",
) -> X13result
Run X-13ARIMA-SEATS on a :class:X13spec or raw spec string.
Mirrors Julia X13.run (two methods at x13result.jl:76-88):
run(spec, *, ...)— pass an :class:X13spec; the spec is serialised via :func:tsecon.x13.x13writeand written to<outfolder>/spec.spc.run(specstring, freq, *, ...)— pass a pre-formatted.spctext plus the frequency the binary should assume; the spec text is written verbatim.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
spec
|
X13spec | str
|
An :class: |
required |
freq
|
Frequency | None
|
Required when |
None
|
verbose
|
bool
|
Echo warnings / notes from the X-13 |
True
|
allow_errors
|
bool
|
If :data: |
False
|
load
|
str | Sequence[str]
|
Which output tables to eagerly parse. |
'none'
|
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.X13result ¶
Top-level container for one X-13 run's outputs.
Mirrors Julia X13result at x13result.jl:23-40. Construct via
:func:run; direct construction is documented but considered
internal.
Attributes:
| Name | Type | Description |
|---|---|---|
spec |
The :class: |
|
outfolder |
Absolute path to the temp directory the run produced.
Auto-removed when this :class: |
|
series |
:class: |
|
tables |
:class: |
|
text |
:class: |
|
other |
:class: |
|
stdout |
The captured stdout from the X-13 binary. |
|
errors / warnings / notes |
Lists of strings parsed from the |
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.X13ResultWorkspace ¶
Bases: Workspace
A :class:Workspace that materialises :class:X13lazy entries on first access.
Mirrors Julia X13ResultWorkspace at X13.jl:24-35 +
Base.getproperty(::X13ResultWorkspace) at x13result.jl:49-56.
Accessing an entry that is an :class:X13lazy triggers a call to
:func:loadresult; the parsed object is written back into the
underlying _c dict, so subsequent accesses skip the parse.
Both ws.foo (attribute) and ws["foo"] (key) access paths go
through the same materialisation. Subset access (ws[["a", "b"]])
returns a plain :class:Workspace per the parent contract; lazy
entries inside such a subset are not materialised eagerly.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.WorkspaceTable ¶
Bases: Workspace
A :class:Workspace whose entries are equal-length vectors.
Mirrors Julia WorkspaceTable at X13.jl:12-22. The X-13 binary
emits a number of multi-column tabular outputs (autocorrelation
plots, sliding-spans summaries, R/I/O tables, …) where the natural
Python representation is "a dict of equal-length lists". The
underlying storage is the inherited _c dict; what differs is
:meth:__repr__, which prints as a column-aligned table rather
than the keyed list :class:Workspace produces.
Construction mirrors the parent: WorkspaceTable(),
WorkspaceTable(a=[1, 2], b=[3, 4]),
WorkspaceTable({"a": [1, 2]}). No validation runs at construction
that columns have equal lengths — the X-13 readers always produce
balanced columns, and unbalanced columns simply render with blank
cells past their length (mirrors Julia).
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.X13lazy
dataclass
¶
A placeholder for an X-13 output that has not been parsed yet.
Mirrors Julia X13lazy at x13result.jl:43-47. Holds the path
to the output file, the file extension (which selects the parser),
and the data frequency (needed for :func:x13read_series /
:func:x13read_seatsseries). :class:X13ResultWorkspace swaps the
instance for the parsed object on first attribute / key access.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.loadresult ¶
Materialise an :class:X13lazy into the parsed object.
Mirrors Julia loadresult at x13result.jl:240-285. Two
calling conventions:
loadresult(X13lazy(file, ext, freq))— the usual shape, used by :class:X13ResultWorkspacewhen an attribute / key access hits a lazy entry.loadresult(file, ext, freq)— same as above but with the three arguments passed positionally. Mirrors Julia's two-arity overload.
Source code in src/tsecon/x13/_result.py
Spec construction¶
The aggregator (X13spec), the factory (newspec), and the validator
(validateX13spec) form the top-level spec API; the 19 builders below
populate the named subspec fields on an X13spec instance.
tsecon.x13._spec ¶
X-13ARIMA-SEATS spec types and spec builders.
Mirrors TimeSeriesEcon.jl/src/x13/x13spec.jl (4,137 LOC — the bulk of
M2). Lands across M2.1 / M2.2 / M2.3 / M2.4.
M2.1 — :class:X13var dataclasses + ARIMA-spec types (this session)¶
This module ships:
- :class:
X13defaultsentinel + module-private :data:_X13DEFAULTsingleton. - :class:
RegimeChange:class:~enum.StrEnumfor the trading-day / seasonal regime-change qualifier (both/zerobefore/zeroafter/neither). -
:class:
X13varabstract base + 26 concrete leaves the spec builders accept as outlier / regressor arguments. Each__str__produces the X13as.spc-grammar token; pickling and equality come from@dataclass(frozen=True, slots=True). -
Point outliers (
mit: MIT):ao(x13spec.jl:9-11),ls(20-22),tc(31-33),so(35-37). - Range outliers (
mit1, mit2: MIT; classmethod :meth:~aos.from_range):aos(12-18),lss(23-29),rp(39-45),qd(47-53),qi(54-60),tl(62-68). - Trading-day regressors with optional regime change
(
mit: MIT | None, regimechange: RegimeChange):td(96-103),tdnolpyear(104-111),td1coef(112-119),td1nolpyear(120-127). - Trading-day calendar (
n: int):tdstock(70-72),tdstock1coef(73-75). - Calendar regressors (
n: int):easter(76-78),labor(79-81),thank(82-84),sceaster(86-88),easterstock(89-91). - Calendar regressor (
n: tuple[int, ...]):sincos(92-94). - Length-of-period / leap-year (
mit: MIT | None, regimechange):lpyear(129-135),lom(137-143),loq(146-152). - Seasonal regressor (
mit, regimechange):seasonal(154-161).
The Julia upstream's :func:ao etc. are types whose lowercase names are
the X13as keywords. The Python port preserves the lowercase names (with
a per-file N801 lint ignore in pyproject.toml) because the
__str__ output uses type(self).__name__ — capitalising the
classes would break .spc serialization or require a parallel name map.
The Julia source has 26 X13var types.
- :class:
ArimaSpecand :class:ArimaModel— the generic(p, d, q)(P, D, Q)[period]ARIMA builders the :func:arima/ :func:pickmdlspec builders (M2.2 / M2.3) consume.
M2.2 — High-traffic spec builders (later session)¶
8 builders that every realistic spec uses: :func:series
(x13spec.jl:732); :func:x11 (3180), :func:seats (2478);
:func:arima (873), :func:automdl (1034); :func:transform
(2928), :func:regression (2219); :func:forecast (1409).
M2.3 — Rare spec builders (later session)¶
11 builders that round out parity: :func:outlier (1833),
:func:history (1602), :func:identify (1686), :func:check
(1149), :func:estimate (1228), :func:metadata (1721),
:func:pickmdl (1972), :func:force (1343), :func:slidingspans
(2666), :func:spectrum (2785), :func:x11regression
(3420).
M2.4 — :class:X13spec container + validation (later session)¶
:class:X13spec (x13spec.jl:4138) is the per-frequency typed
container the builders accumulate into. :func:newspec (578) /
:func:newspec_from_frequency (603) are the constructors;
:func:validateX13spec (3563) is the cross-builder invariant check
that runs before :func:run ships the spec to the binary.
Notes on Python idiom (M2.1)¶
The Julia upstream's dual-constructor for range outliers
(aos(::UnitRange{<:MIT}) vs aos(mit1::MIT, mit2::MIT)) ports as
the canonical two-argument constructor plus an :meth:~aos.from_range
:func:classmethod accepting an :class:~tsecon.mitrange.MITRange. This
keeps the frozen-slots dataclass shape uniform and matches how
:class:MIT itself surfaces alternate constructors (MIT.from_yp).
The Julia regimechange::Symbol field ports as a :class:RegimeChange
:class:~enum.StrEnum; users may pass either the enum member
(RegimeChange.BOTH) or the bare string ("both"), the
:meth:__post_init__ normalises to the enum. Members are equal to their
.value (RegimeChange.BOTH == "both" is :data:True) so equality
checks remain transparent.
The Julia td() / td(mit::MIT) / td(mit, rc) constructor trio
maps to a single Python dataclass with sentinel defaults
(mit=None, regimechange=None); :meth:__post_init__ resolves
(None, None) to regimechange=NEITHER (no-arg form) and
(mit, None) to regimechange=BOTH (mit-only form, matching
Julia's default). The same pattern applies to the seven other
regime-bearing types (tdnolpyear, td1coef, td1nolpyear,
lpyear, lom, loq, seasonal).
X13default ¶
Sentinel for spec-builder fields that should be left at the X-13 default.
Mirrors Julia's X13default struct (x13spec.jl:4). Spec builders
(M2.2 / M2.3) accept :class:X13default instances as default arguments;
the .spc writer (M2.4) skips fields whose value is _X13DEFAULT,
leaving the binary to apply its built-in default.
The class is a singleton — :data:_X13DEFAULT is the canonical instance,
and identity comparisons (arg is _X13DEFAULT) replace Julia's
isa X13default dispatch.
Source code in src/tsecon/x13/_spec.py
RegimeChange ¶
Bases: StrEnum
Regime-change qualifier for td*, lpyear, lom, loq, seasonal.
Maps to X-13ARIMA-SEATS .spc tokens:
- :attr:
NEITHER— no regime change; the MIT is unused in serialization. - :attr:
BOTH— break atmit, both halves estimated. Token:td/2020.jul/. - :attr:
ZEROBEFORE— break with zero coefficient beforemit. Token:td//2020.jul/. - :attr:
ZEROAFTER— break with zero coefficient aftermit. Token:td/2020.jul//.
:class:RegimeChange is a :class:~enum.StrEnum; members compare equal
to their underlying string (RegimeChange.BOTH == "both"). Spec
constructors normalise plain strings to enum members via
:meth:__post_init__.
Source code in src/tsecon/x13/_spec.py
X13var ¶
Abstract base class for X-13 outlier / regressor / calendar variables.
Each concrete subclass is a frozen-slotted dataclass that overrides
:meth:__str__ to produce the .spc-grammar token. Subclasses use
lowercase Julia-mirror names (ao, ls, …); the class name is
consumed by serialization via type(self).__name__ — capitalising
it would either break .spc output or require a parallel name map.
Source code in src/tsecon/x13/_spec.py
ao
dataclass
¶
Bases: X13var
Additive outlier at mit (regARIMA AO regressor).
Mirrors x13spec.jl:9-11. Serializes as ao<year>.<period>,
e.g. ao2020.jul for Monthly or ao2020.3 for Quarterly.
Source code in src/tsecon/x13/_spec.py
ls
dataclass
¶
Bases: X13var
Level-shift outlier at mit.
Mirrors x13spec.jl:20-22. Serializes as ls<year>.<period>.
Source code in src/tsecon/x13/_spec.py
tc
dataclass
¶
Bases: X13var
Temporary-change outlier at mit.
Mirrors x13spec.jl:31-33. Serializes as tc<year>.<period>.
Source code in src/tsecon/x13/_spec.py
so
dataclass
¶
Bases: X13var
Seasonal outlier at mit.
Mirrors x13spec.jl:35-37. Serializes as so<year>.<period>.
Source code in src/tsecon/x13/_spec.py
aos
dataclass
¶
Bases: X13var
Range additive-outlier from mit1 to mit2 (inclusive).
Mirrors x13spec.jl:12-18. Serializes as
aos<year1>.<period1>-<year2>.<period2>. Construct with
:meth:from_range to bridge an :class:~tsecon.mitrange.MITRange.
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
Construct from an :class:~tsecon.mitrange.MITRange.
Mirrors the Julia inner constructor
aos(x::UnitRange{<:MIT}) = new(first(x), last(x)). The Python
:class:~tsecon.mitrange.MITRange is inclusive, so its
:meth:~tsecon.mitrange.MITRange.first and
:meth:~tsecon.mitrange.MITRange.last match the Julia range
endpoints.
Source code in src/tsecon/x13/_spec.py
lss
dataclass
¶
Bases: X13var
Range level-shift outlier from mit1 to mit2.
Mirrors x13spec.jl:23-29.
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
rp
dataclass
¶
Bases: X13var
Ramp outlier from mit1 to mit2.
Mirrors x13spec.jl:39-45.
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
qd
dataclass
¶
Bases: X13var
Quadratic-decay outlier range from mit1 to mit2.
Mirrors x13spec.jl:47-53.
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
qi
dataclass
¶
Bases: X13var
Quadratic-incline outlier range from mit1 to mit2.
Mirrors x13spec.jl:54-60.
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
tl
dataclass
¶
Bases: X13var
Temporary-level-shift outlier range from mit1 to mit2.
Mirrors x13spec.jl:62-68.
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
tdstock
dataclass
¶
Bases: X13var
Trading-day stock regressor with calendar-day-of-month n.
Mirrors x13spec.jl:70-72. Serializes as tdstock[n].
Source code in src/tsecon/x13/_spec.py
tdstock1coef
dataclass
¶
Bases: X13var
One-coefficient trading-day stock regressor with day n.
Mirrors x13spec.jl:73-75.
Source code in src/tsecon/x13/_spec.py
easter
dataclass
¶
Bases: X13var
Easter holiday regressor with window length n days.
Mirrors x13spec.jl:76-78.
Source code in src/tsecon/x13/_spec.py
labor
dataclass
¶
Bases: X13var
U.S. Labor Day regressor with window length n days.
Mirrors x13spec.jl:79-81.
Source code in src/tsecon/x13/_spec.py
thank
dataclass
¶
Bases: X13var
U.S. Thanksgiving regressor with window length n days.
Mirrors x13spec.jl:82-84.
Source code in src/tsecon/x13/_spec.py
sceaster
dataclass
¶
Bases: X13var
Statistics-Canada Easter regressor with window length n days.
Mirrors x13spec.jl:86-88.
Source code in src/tsecon/x13/_spec.py
easterstock
dataclass
¶
Bases: X13var
Easter-stock regressor with window length n days.
Mirrors x13spec.jl:89-91.
Source code in src/tsecon/x13/_spec.py
sincos
dataclass
¶
Bases: X13var
Sine/cosine seasonal-frequency regressor with frequencies n.
Mirrors x13spec.jl:92-94. Julia uses n::Vector{Int64}; the
Python port uses tuple[int, ...] so the dataclass stays frozen.
Serializes as sincos[<space-separated frequencies>].
Source code in src/tsecon/x13/_spec.py
td
dataclass
¶
Bases: X13var
Trading-day regressor with optional regime change at mit.
Mirrors x13spec.jl:96-103. Three call shapes mirror the Julia
upstream:
td()— no regime change. .spc form:td.td(mit)— regime change atmit, both halves estimated. .spc form:td/<mit>/.td(mit, regimechange=...)— explicit regime-change qualifier.
Source code in src/tsecon/x13/_spec.py
tdnolpyear
dataclass
¶
Bases: X13var
Trading-day regressor (no leap-year term) with optional regime change.
Mirrors x13spec.jl:104-111.
Source code in src/tsecon/x13/_spec.py
td1coef
dataclass
¶
Bases: X13var
One-coefficient trading-day regressor with optional regime change.
Mirrors x13spec.jl:112-119.
Source code in src/tsecon/x13/_spec.py
td1nolpyear
dataclass
¶
Bases: X13var
One-coefficient trading-day regressor without leap-year term.
Mirrors x13spec.jl:120-127.
Source code in src/tsecon/x13/_spec.py
lpyear
dataclass
¶
Bases: X13var
Leap-year regressor with optional regime change.
Mirrors x13spec.jl:129-135.
Source code in src/tsecon/x13/_spec.py
lom
dataclass
¶
Bases: X13var
Length-of-month regressor with optional regime change.
Mirrors x13spec.jl:137-143.
Source code in src/tsecon/x13/_spec.py
loq
dataclass
¶
Bases: X13var
Length-of-quarter regressor with optional regime change.
Mirrors x13spec.jl:146-152.
Source code in src/tsecon/x13/_spec.py
seasonal
dataclass
¶
Bases: X13var
Seasonal regressor with optional regime change.
Mirrors x13spec.jl:154-161.
Source code in src/tsecon/x13/_spec.py
ArimaSpec
dataclass
¶
A single ARIMA(p, d, q) operator with optional period.
Mirrors x13spec.jl:216-228. p, d, q may be a non-negative
:class:int (e.g. ArimaSpec(1, 1, 1) for ARIMA(1,1,1)) or a
:class:tuple of ints to spell an operator with missing lags
(ArimaSpec((2, 3), 0, 0) →
:math:(1 - \Phi_2 B^2 - \Phi_3 B^3) z_t = a_t). period=0 (the
default) means "infer the period from spec ordering" — the ARIMA
builder (M2.2) uses position in the spec list to assign seasonal
periods when period=0.
Mutable to mirror Julia's mutable struct: spec builders re-assign
fields as they accumulate. Equality compares field-by-field.
Source code in src/tsecon/x13/_spec.py
two_seasonal
classmethod
¶
two_seasonal(
p: _OrderArg,
d: _OrderArg,
q: _OrderArg,
P: _OrderArg,
D: _OrderArg,
Q: _OrderArg,
) -> tuple[ArimaSpec, ArimaSpec]
Build the (p,d,q)(P,D,Q) pair, mirroring Julia's 6-arg form.
Returns a 2-tuple of :class:ArimaSpec — the nonseasonal then the
seasonal — both with period=0 (the ARIMA builder assigns the
actual seasonal period from spec ordering).
Mirrors x13spec.jl:227
(ArimaSpec(p,d,q,P,D,Q) = (new(p,d,q,0), new(P,D,Q,0))).
Source code in src/tsecon/x13/_spec.py
ArimaModel
dataclass
¶
A collection of :class:ArimaSpec operators with a default flag.
Mirrors x13spec.jl:232-242. The default flag marks the model as
the airline-default ((0,1,1)(0,1,1)) for automdl purposes; the
:func:automdl builder (M2.2) consults it to decide whether to
explicitly serialize the model in the .spc file or rely on the
binary's built-in default.
Use the :class:classmethod-style helpers below (mirroring Julia's
six positional-only constructors) for the common ARIMA(p,d,q)[period]
and ARIMA(p,d,q)(P,D,Q) call shapes; pass an explicit list of
:class:ArimaSpec for fully custom multi-operator models.
Source code in src/tsecon/x13/_spec.py
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | |
from_pdq
classmethod
¶
from_pdq(
p: _OrderArg,
d: _OrderArg,
q: _OrderArg,
period: int = 0,
*,
default: bool = False,
) -> ArimaModel
Build a single-operator (p, d, q)[period] model.
Mirrors Julia's ArimaModel(p, d, q; default=...) and
ArimaModel(p, d, q, period; default=...).
Source code in src/tsecon/x13/_spec.py
from_pdq_seasonal
classmethod
¶
from_pdq_seasonal(
p: _OrderArg,
d: _OrderArg,
q: _OrderArg,
P: _OrderArg,
D: _OrderArg,
Q: _OrderArg,
*,
default: bool = False,
) -> ArimaModel
Build a two-operator (p, d, q)(P, D, Q) model.
Mirrors Julia's six-positional-argument
ArimaModel(p, d, q, P, D, Q; default=...).
Source code in src/tsecon/x13/_spec.py
from_specs
classmethod
¶
Build from one or more pre-built :class:ArimaSpec instances.
Mirrors Julia's ArimaModel(specs::ArimaSpec...; default=...).
Source code in src/tsecon/x13/_spec.py
Span
dataclass
¶
A start/end MIT pair with optional open endpoints.
Mirrors x13spec.jl:163-171. Either endpoint may be :data:None
(Julia missing), meaning "use the underlying series' first or last
observation". Both endpoints together define an inclusive range.
The Julia upstream also accepts fuzzy end values such as M11 or
Q2 (resolved to the most recent occurrence in the series); the
Python port restricts b and e to :class:MIT or :data:None
in M2.2. Fuzzy endings land in a later session if a builder (e.g.
x11regression) requires them.
Construct from an :class:~tsecon.mitrange.MITRange via
:meth:from_range (mirrors Julia's
Span(x::UnitRange{<:MIT}) = new(first(x), last(x))).
Source code in src/tsecon/x13/_spec.py
from_range
classmethod
¶
X13series
dataclass
¶
The series spec block — the time series + its load-time options.
Mirrors x13spec.jl:175-199 (X13series{F<:Frequency}). The Julia
type-parameter F is dropped — the underlying :class:~tsecon.tseries.TSeries
already carries its own :class:~tsecon.frequencies.Frequency instance.
Constructed by :func:series; never construct directly outside the
spec-builder path (validation happens in :func:series, not in
__init__).
Source code in src/tsecon/x13/_spec.py
X13arima
dataclass
¶
The arima spec block — the ARIMA(p, d, q)(P, D, Q) component.
Mirrors x13spec.jl:245-252. The model field is an
:class:ArimaModel (one or more :class:ArimaSpec operators); the
AR / MA initial-value vectors (ar / ma) and their fixed-flag
counterparts (fixar / fixma) align position-by-position with
the model's coefficient sequence. Missing initial values default to
0.1 in the binary, encoded as :data:None here.
Source code in src/tsecon/x13/_spec.py
X13automdl
dataclass
¶
The automdl spec block — automatic ARIMA model selection.
Mirrors x13spec.jl:254-272. Auto-selects the ARIMA orders given
bounds on the regular/seasonal differencing and ARMA polynomial
degrees. Mutually exclusive with arima.
Source code in src/tsecon/x13/_spec.py
X13transform
dataclass
¶
The transform spec block — pre-modeling data transformation.
Mirrors x13spec.jl:467-486. Selects between log, Box-Cox-power,
or user-supplied prior-adjustment transformation modes.
Source code in src/tsecon/x13/_spec.py
X13regression
dataclass
¶
The regression spec block — regARIMA regressors / outliers.
Mirrors x13spec.jl:383-407. Carries the predefined regressor list
(variables), the user-supplied regressors (data / user),
initial coefficient values (b) and fix-flags (fixb), and the
AIC-comparison configuration (aictest / aicdiff).
Source code in src/tsecon/x13/_spec.py
X13forecast
dataclass
¶
The forecast spec block — out-of-sample forecast generation.
Mirrors x13spec.jl:310-318. maxlead controls how far ahead
point forecasts and their variances are produced; maxback does
the same for backcasts.
Source code in src/tsecon/x13/_spec.py
X13seats
dataclass
¶
The seats spec block — model-based signal-extraction adjustment.
Mirrors x13spec.jl:409-430. Activates the SEATS module for
seasonal decomposition based on the regARIMA model.
Source code in src/tsecon/x13/_spec.py
X13x11
dataclass
¶
The x11 spec block — X-11 (enhanced) seasonal adjustment.
Mirrors x13spec.jl:489-510. The traditional Census-Bureau X-11
method, with auto-selection or per-period seasonal-MA configuration
and Henderson trend-MA selection.
Source code in src/tsecon/x13/_spec.py
X13check
dataclass
¶
The check spec block — regARIMA residual diagnostics.
Mirrors x13spec.jl:274-282. Carries ACF / PACF lag limits and
significance thresholds used for residual-adequacy reporting.
Source code in src/tsecon/x13/_spec.py
X13estimate
dataclass
¶
The estimate spec block — regARIMA estimation controls.
Mirrors x13spec.jl:284-294. Selects exact-vs-conditional likelihood,
iteration limits, and optional preloaded .mdl file with fix-policy.
Source code in src/tsecon/x13/_spec.py
X13force
dataclass
¶
The force spec block — yearly-total forcing on seasonally adjusted output.
Mirrors x13spec.jl:296-308. Activates Denton or regression-based
benchmarking to make the SA series' yearly totals match the target.
Source code in src/tsecon/x13/_spec.py
X13history
dataclass
¶
The history spec block — revisions / forecast-error history analysis.
Mirrors x13spec.jl:321-340. Drives the truncated-series re-run
pipeline used to characterise revisions and out-of-sample forecast
errors at user-specified lags.
Source code in src/tsecon/x13/_spec.py
X13identify
dataclass
¶
The identify spec block — ACF / PACF plots for ARIMA identification.
Mirrors x13spec.jl:342-348. Sample ACFs and PACFs are produced
for every combination of nonseasonal-difference orders (diff) and
seasonal-difference orders (sdiff).
Source code in src/tsecon/x13/_spec.py
X13metadata
dataclass
¶
The metadata spec block — diagnostic-summary key/value entries.
Mirrors x13spec.jl:350-352. Stores a tuple of (key, value)
pairs that X-13 emits into the .udg diagnostic-summary file.
The Julia upstream's Pair{String,String} / Vector{Pair{...}}
ports as a tuple[tuple[str, str], ...] (frozen, order-preserving,
pickleable) — see :func:metadata for the user-facing input shapes.
Source code in src/tsecon/x13/_spec.py
X13outlier
dataclass
¶
The outlier spec block — automatic outlier identification.
Mirrors x13spec.jl:354-365. Triggers the iterative add-detection
loop for additive outliers, level shifts, and temporary changes.
Source code in src/tsecon/x13/_spec.py
X13pickmdl
dataclass
¶
The pickmdl spec block — X-11-ARIMA model selection from candidates.
Mirrors x13spec.jl:367-380. Picks the ARIMA part from either a
list of candidate :class:ArimaModel instances or a file containing
such a list.
Source code in src/tsecon/x13/_spec.py
X13slidingspans
dataclass
¶
The slidingspans spec block — stability analysis over moving spans.
Mirrors x13spec.jl:432-448. Compares seasonal-adjustment output
across overlapping subspans of the series for revisions stability.
Source code in src/tsecon/x13/_spec.py
X13spectrum
dataclass
¶
The spectrum spec block — frequency-domain seasonality diagnostics.
Mirrors x13spec.jl:450-465. Computes AR-spectrum or periodogram
estimates plus the QS statistic for both monthly and quarterly series.
Source code in src/tsecon/x13/_spec.py
X13x11regression
dataclass
¶
The x11regression spec block — calendar / outlier regression on irregulars.
Mirrors x13spec.jl:512-547. The X-11 sibling of the regARIMA
:class:X13regression block — applies calendar / trading-day
regressions to the X-11 irregular component.
Source code in src/tsecon/x13/_spec.py
X13spec
dataclass
¶
The X-13 spec aggregator — one series plus up to 18 sub-specs.
Mirrors x13spec.jl:552-575 (mutable struct X13spec{F<:Frequency}).
The Julia type-parameter F is dropped — the contained
:class:X13series already carries its :class:~tsecon.frequencies.Frequency
via its data field.
Construct via :func:newspec (passing either a :class:~tsecon.tseries.TSeries
or an already-built :class:X13series); the bang-suffixed Julia
setters (arima! / outlier! / …) port as plain attribute
assignment because this dataclass is intentionally mutable and
slotted — the surface mirrors Julia's spec.outlier = outlier(...)
ergonomics. Re-assignment is the only mutation the M2 surface
supports; the contained sub-spec dataclasses themselves remain
frozen.
The folder and string fields are populated by the M2.5 binary
runner: folder holds the temp dir the run created, string
holds the rendered .spc text (mirrors Julia's spec.string
side-effect inside x13write).
Source code in src/tsecon/x13/_spec.py
series ¶
series(
t: TSeries,
*,
appendbcst: bool | X13default = _X13DEFAULT,
appendfcst: bool | X13default = _X13DEFAULT,
comptype: str | X13default = _X13DEFAULT,
compwt: float | X13default = _X13DEFAULT,
decimals: int | X13default = _X13DEFAULT,
file: str | X13default = _X13DEFAULT,
format: str | X13default = _X13DEFAULT,
modelspan: MITRange | Span | X13default = _X13DEFAULT,
name: str | X13default = _X13DEFAULT,
period: int | X13default = _X13DEFAULT,
precision: int | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
span: MITRange | Span | X13default = _X13DEFAULT,
start: MIT | X13default = _X13DEFAULT,
title: str | X13default = _X13DEFAULT,
type: str | X13default = _X13DEFAULT,
divpower: int | X13default = _X13DEFAULT,
missingcode: float | X13default = _X13DEFAULT,
missingval: float | X13default = _X13DEFAULT,
saveprecision: int | X13default = _X13DEFAULT,
trimzero: bool | str | X13default = _X13DEFAULT,
) -> X13series
Build the series spec — required for every X-13 run.
Mirrors x13spec.jl:732-822. The t argument is the input
:class:~tsecon.tseries.TSeries; all other arguments are keyword-only
and mirror the Julia spec's named parameters one-for-one. Defaults are
the :data:_X13DEFAULT sentinel — fields holding the sentinel are
omitted by the M2.4 .spc writer, letting X-13 apply its built-in
default.
Validation performed:
nameandtitletruncated (with a :class:UserWarning) to 64 and 79 characters respectively, mirroring Julia.periodis auto-set toppy(t)for non-Monthly / non-Yearly frequencies (Quarterly defaults to 4, etc.).span(whether :class:~tsecon.mitrange.MITRangeor :class:Span) must be contained withint.range.- :class:
Spanspanendpoints must be :class:MITor :data:None— fuzzy endings (Julia'sM11/Q2) are rejected here per upstream. divpowermust be in[-9, 9].- If
t.valuescontainsNaN,missingcodemust be set; the output'sdatafield has NaN replaced withmissingcodein a fresh copy (inputtis not mutated). print="all"/save="all"expand to the upstream-defined "everything" lists.
Returns an :class:X13series carrying the (possibly cropped /
NaN-replaced) data and the validated field values.
Source code in src/tsecon/x13/_spec.py
1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 | |
arima ¶
arima(
model: ArimaModel | ArimaSpec | tuple[ArimaSpec, ...],
*,
title: str | X13default = _X13DEFAULT,
ar: _ArArg = _X13DEFAULT,
ma: _ArArg = _X13DEFAULT,
fixar: list[bool] | X13default = _X13DEFAULT,
fixma: list[bool] | X13default = _X13DEFAULT,
) -> X13arima
Build the arima spec — the ARIMA part of the regARIMA model.
Mirrors x13spec.jl:873-911. Accepts any of:
- an :class:
ArimaModel(the primary Julia overload), - a single :class:
ArimaSpec(wrapped via :meth:ArimaModel.from_specs), - a tuple of :class:
ArimaSpec(wrapped via :meth:ArimaModel.from_specs).
The two-positional-tuple form mirrors :meth:ArimaSpec.two_seasonal's
return shape, so arima(ArimaSpec.two_seasonal(1,1,1,0,1,1)) ports
Julia's arima(ArimaSpec(1,1,1,0,1,1)...) idiom.
Validation:
fixarlength must matcharlength (if both set).fixmalength must matchmalength (if both set).titletruncated to 79 chars with a :class:UserWarning.
Source code in src/tsecon/x13/_spec.py
1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 | |
automdl ¶
automdl(
*,
diff: list[int] | X13default = _X13DEFAULT,
acceptdefault: bool | X13default = _X13DEFAULT,
checkmu: bool | X13default = _X13DEFAULT,
ljungboxlimit: float | X13default = _X13DEFAULT,
maxorder: list[_IntOrNone] | X13default = _X13DEFAULT,
maxdiff: list[_IntOrNone] | X13default = _X13DEFAULT,
mixed: bool | X13default = _X13DEFAULT,
print: str | list[str] | X13default | None = None,
savelog: str | list[str] | X13default | None = None,
armalimit: float | X13default = _X13DEFAULT,
balanced: bool | X13default = _X13DEFAULT,
exactdiff: bool | str | X13default = _X13DEFAULT,
fcstlim: int | X13default = _X13DEFAULT,
hrinitial: bool | X13default = _X13DEFAULT,
reducecv: float | X13default = _X13DEFAULT,
rejectfcst: bool | X13default = _X13DEFAULT,
urfinal: float | X13default = _X13DEFAULT,
) -> X13automdl
Build the automdl spec — automatic ARIMA model selection.
Mirrors x13spec.jl:1034-1141. The print and savelog
arguments default (in upstream Julia) to specific multi-element lists,
not :data:_X13DEFAULT. In Python the None sentinel triggers the
same defaults (a non-:data:X13default default would otherwise be
serialized as the user's choice, masking that the binary's default
differs).
Validation:
diffmust be length 2; values∈ {0, 1, 2}(regular) and{0, 1}(seasonal).maxdiffmust be length 2; values∈ {1, 2}(regular) and{1}(seasonal). :data:Noneslots accepted.maxordermust be length 2; values∈ {1, 2, 3, 4}(regular) and{1, 2}(seasonal). :data:Noneslots accepted.diffis ignored if bothdiffandmaxdiffare set; a :class:UserWarningflags the redundancy (upstream Julia parity).
Source code in src/tsecon/x13/_spec.py
1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 | |
transform ¶
transform(
*,
adjust: str | X13default = _X13DEFAULT,
aicdiff: float | X13default = _X13DEFAULT,
data: TSeries | MVTSeries | X13default = _X13DEFAULT,
file: str | X13default = _X13DEFAULT,
format: str | X13default = _X13DEFAULT,
func: str | X13default = _X13DEFAULT,
mode: str | list[str] | X13default = _X13DEFAULT,
power: float | X13default = _X13DEFAULT,
precision: int | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
title: str | X13default = _X13DEFAULT,
type: str | list[str] | X13default = _X13DEFAULT,
constant: float | X13default = _X13DEFAULT,
trimzero: bool | str | X13default = _X13DEFAULT,
) -> X13transform
Build the transform spec — pre-modeling transformation selector.
Mirrors x13spec.jl:2928-3010. Derives start and name from
data when set (mirrors the Julia upstream's derivation block).
Validation:
powerandfuncare mutually exclusive.adjust="lpyear"is only valid with a log-transform (power=0.0orfunc="log").modeis at most two values;"diff"is incompatible with"ratio"/"percent"in the same list.titletruncated to 79 chars with a :class:UserWarning.typerequiresdataset;typelist length must match the number of provided series.
Source code in src/tsecon/x13/_spec.py
1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 | |
regression ¶
regression(
*,
aicdiff: list[_FloatOrNone]
| list[float]
| X13default = _X13DEFAULT,
aictest: str | list[str] | X13default = _X13DEFAULT,
chi2test: bool | X13default = _X13DEFAULT,
chi2testcv: float | X13default = _X13DEFAULT,
data: MVTSeries | X13default = _X13DEFAULT,
file: str | X13default = _X13DEFAULT,
format: str | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
pvaictest: float | X13default = _X13DEFAULT,
testalleaster: bool | X13default = _X13DEFAULT,
tlimit: float | X13default = _X13DEFAULT,
usertype: str | list[str] | X13default = _X13DEFAULT,
variables: _VariablesField = _X13DEFAULT,
b: list[float] | X13default = _X13DEFAULT,
fixb: list[bool] | X13default = _X13DEFAULT,
centeruser: str | X13default = _X13DEFAULT,
eastermeans: bool | X13default = _X13DEFAULT,
noapply: str | X13default = _X13DEFAULT,
tcrate: float | X13default = _X13DEFAULT,
) -> X13regression
Build the regression spec — regressors / outliers for regARIMA.
Mirrors x13spec.jl:2219-2354. The start and user fields
are derived from data (mirrors the Julia upstream's derivation;
no user-facing start= / user= kwargs are accepted because
Julia overrides them).
Validation:
aicdiffandpvaictestare mutually exclusive.usertype(when set) must be one of the documented X-13 effect types; vector form's length must match the number of user series.aictest(when set) must be in the documented set of testable effects.- Per-variable
nbounds checked fortdstock/easter/labor/thank/sceaster/easterstock. - Overlapping
aos/lssranges emit a :class:UserWarning.
Source code in src/tsecon/x13/_spec.py
1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 | |
forecast ¶
forecast(
*,
exclude: int | X13default = _X13DEFAULT,
lognormal: bool | X13default = _X13DEFAULT,
maxback: int | X13default = _X13DEFAULT,
maxlead: int | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
probability: float | X13default = _X13DEFAULT,
) -> X13forecast
Build the forecast spec — forecast / backcast options.
Mirrors x13spec.jl:1409-1429. Expands print="all" /
save="all" to the upstream-defined "everything" lists; otherwise
pass-through.
Source code in src/tsecon/x13/_spec.py
seats ¶
seats(
*,
appendfcst: bool | X13default = _X13DEFAULT,
finite: bool | X13default = _X13DEFAULT,
hpcycle: bool | X13default = _X13DEFAULT,
noadmiss: bool | X13default = _X13DEFAULT,
out: int | X13default = 0,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
printphtrf: bool | X13default = _X13DEFAULT,
qmax: int | X13default = _X13DEFAULT,
statseas: bool | X13default = _X13DEFAULT,
tabtables: list[str] | X13default = _X13DEFAULT,
bias: int | X13default = _X13DEFAULT,
epsiv: float | X13default = _X13DEFAULT,
epsphi: int | X13default = _X13DEFAULT,
hplan: int | X13default = _X13DEFAULT,
imean: bool | X13default = _X13DEFAULT,
maxit: int | X13default = _X13DEFAULT,
rmod: float | X13default = _X13DEFAULT,
xl: float | X13default = _X13DEFAULT,
) -> X13seats
Build the seats spec — SEATS signal-extraction options.
Mirrors x13spec.jl:2478-2527. The upstream's savelog default
is the empty list to keep the binary happy on writethrough (see the
savelog = _X13default line at x13spec.jl:2513); we honour
that and surface savelog as :data:_X13DEFAULT internally rather
than as a user-tunable kwarg.
Validation:
epsivmust be > 0.- Setting
hplanwhilehpcycle=Falseemits a warning (HP filters are applied regardless becausehplanis set). print="all"is rejected (upstream Julia warns + drops); we raise :exc:ValueErrorto surface the misuse explicitly under the project'serror::UserWarningfilter.save="all"expands to the SEATS-specific everything list AND forcesout=0(mirrors upstreamout=0reset).
Source code in src/tsecon/x13/_spec.py
2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 | |
x11 ¶
x11(
*,
appendbcst: bool | X13default = _X13DEFAULT,
appendfcst: bool | X13default = _X13DEFAULT,
final: str | list[str] | X13default = _X13DEFAULT,
mode: str | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
seasonalma: str | list[str] | X13default = _X13DEFAULT,
sigmalim: list[_FloatOrNone]
| list[float]
| X13default = _X13DEFAULT,
title: str | list[str] | X13default = _X13DEFAULT,
trendma: int | X13default = _X13DEFAULT,
type: str | X13default = _X13DEFAULT,
calendarsigma: str | X13default = _X13DEFAULT,
centerseasonal: bool | X13default = _X13DEFAULT,
keepholiday: bool | X13default = _X13DEFAULT,
print1stpass: bool | X13default = _X13DEFAULT,
sfshort: bool | X13default = _X13DEFAULT,
sigmavec: list[str] | X13default = _X13DEFAULT,
trendic: float | X13default = _X13DEFAULT,
true7term: bool | X13default = _X13DEFAULT,
) -> X13x11
Build the x11 spec — X-11 enhanced seasonal-adjustment options.
Mirrors x13spec.jl:3180-3228. The upstream's savelog default
is "alldiagnostics"; the Python port uses :data:None as the
sentinel that triggers that default (per the established pattern in
:func:automdl / :func:regression etc.).
Validation:
trendmamust be an odd integer in[3, 101].sigmavecrequirescalendarsigma="select"(other values raise :exc:ValueError).
Source code in src/tsecon/x13/_spec.py
2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 | |
check ¶
check(
*,
maxlag: int | X13default = _X13DEFAULT,
qtype: str | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
acflimit: float | X13default = _X13DEFAULT,
qlimit: float | X13default = _X13DEFAULT,
) -> X13check
Build the check spec — residual ACF / Ljung-Box diagnostics.
Mirrors x13spec.jl:1149-1169. Expands print="all" /
save="all" to the upstream-defined "everything" lists; otherwise
pass-through. No numeric range validation in the upstream — :exc:ValueError
surfaces from the writer if X-13 rejects the values.
Source code in src/tsecon/x13/_spec.py
estimate ¶
estimate(
*,
exact: str | X13default = _X13DEFAULT,
maxiter: int | X13default = _X13DEFAULT,
outofsample: bool | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
tol: float | X13default = _X13DEFAULT,
file: str | X13default = _X13DEFAULT,
fix: str | X13default = _X13DEFAULT,
) -> X13estimate
Build the estimate spec — regARIMA estimation options.
Mirrors x13spec.jl:1228-1251. Expands print="all" /
save="all" to the upstream-defined "everything" lists.
Source code in src/tsecon/x13/_spec.py
force ¶
force(
*,
lambda_: float | X13default = _X13DEFAULT,
mode: str | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
rho: float | X13default = _X13DEFAULT,
round: bool | X13default = _X13DEFAULT,
start: str | X13default = _X13DEFAULT,
target: str | X13default = _X13DEFAULT,
type: str | X13default = _X13DEFAULT,
usefcst: bool | X13default = _X13DEFAULT,
indforce: bool | X13default = _X13DEFAULT,
) -> X13force
Build the force spec — yearly-total forcing options.
Mirrors x13spec.jl:1343-1372. The Julia lambda keyword renames
to lambda_ (Python's reserved word); round and type keep
their X-13 names (not Python reserved words, only built-in shadows).
Validation:
rhomust be in[0.0, 1.0].
Source code in src/tsecon/x13/_spec.py
history ¶
history(
*,
endtable: MIT | X13default = _X13DEFAULT,
estimates: str | list[str] | X13default = _X13DEFAULT,
fixmdl: bool | X13default = _X13DEFAULT,
fixreg: bool | X13default = _X13DEFAULT,
fstep: int | list[int] | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
sadjlags: int | list[int] | X13default = _X13DEFAULT,
start: MIT | X13default = _X13DEFAULT,
target: str | X13default = _X13DEFAULT,
trendlags: int | list[int] | X13default = _X13DEFAULT,
fixx11reg: bool | X13default = _X13DEFAULT,
outlier: str | X13default = _X13DEFAULT,
outlierwin: int | X13default = _X13DEFAULT,
refresh: bool | X13default = _X13DEFAULT,
transformfcst: bool | X13default = _X13DEFAULT,
x11outlier: bool | X13default = _X13DEFAULT,
) -> X13history
Build the history spec — truncated-series revisions analysis.
Mirrors x13spec.jl:1602-1656.
Validation:
fstep(when a list) must have length ≤ 4 with every entry ≥ 1. Scalarfstepmust be ≥ 1.sadjlags(when a list) must have length ≤ 5 with every entry ≥ 1. Scalarsadjlagsmust be ≥ 1.
Source code in src/tsecon/x13/_spec.py
2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 | |
identify ¶
identify(
*,
diff: list[int] | X13default = _X13DEFAULT,
sdiff: list[int] | X13default = _X13DEFAULT,
maxlag: int | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
) -> X13identify
Build the identify spec — ARIMA-identification ACFs/PACFs.
Mirrors x13spec.jl:1686-1706. No range validation upstream — the
binary applies its own bounds.
Source code in src/tsecon/x13/_spec.py
metadata ¶
metadata(
entries: tuple[str, str]
| list[tuple[str, str]]
| tuple[tuple[str, str], ...]
| dict[str, str],
) -> X13metadata
Build the metadata spec — diagnostic-summary key/value entries.
Mirrors x13spec.jl:1721-1748. Accepts a single (key, value)
pair, an iterable of pairs, or a dict (the dict form is the
Python-idiomatic shape; iteration order preserved per PEP 468).
Validation (mirrors upstream):
- At most 20 entries.
- No single key or value exceeds 132 characters.
- Concatenated keys and concatenated values each ≤ 2000 characters.
Source code in src/tsecon/x13/_spec.py
3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 | |
outlier ¶
outlier(
*,
critical: float
| list[float | None]
| list[float]
| X13default = _X13DEFAULT,
lsrun: int | X13default = _X13DEFAULT,
method: str | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
span: MITRange | Span | X13default = _X13DEFAULT,
types: str | list[str] | X13default = _X13DEFAULT,
almost: float | X13default = _X13DEFAULT,
tcrate: float | X13default = _X13DEFAULT,
) -> X13outlier
Build the outlier spec — automatic outlier detection.
Mirrors x13spec.jl:1833-1881.
Validation:
critical(when a list) must have length ≤ 3.lsrunmust be in[0, 5].almostmust be > 0.tcratemust be in(0.0, 1.0).- :class:
Spanspanrejects fuzzye(M11/Q2) — mirrored as "endpoints must be MIT or None"; the builder accepts only :class:MITor :data:Nonealready, so the upstream check collapses to a no-op here.
Source code in src/tsecon/x13/_spec.py
3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 | |
pickmdl ¶
pickmdl(
*models: ArimaModel,
bcstlim: int | X13default = _X13DEFAULT,
fcstlim: int | X13default = _X13DEFAULT,
identify: str | X13default = _X13DEFAULT,
method: str | X13default = _X13DEFAULT,
mode: str | X13default = _X13DEFAULT,
outofsample: bool | X13default = _X13DEFAULT,
overdiff: float | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
qlim: int | X13default = _X13DEFAULT,
file: str | X13default = _X13DEFAULT,
) -> X13pickmdl
Build the pickmdl spec — automatic ARIMA model selection.
Mirrors x13spec.jl:1972-2030. The Julia pickmdl(models::Vector{ArimaModel})
and pickmdl(models::ArimaModel...) overloads collapse to a single
Python signature with a positional *models varargs — pass either
pickmdl(m1, m2) or pickmdl(*[m1, m2]).
The identify kwarg shadows the :func:identify spec builder at
module level; this is the X-13 grammar's name (identify=:first /
:all) and the per-kwarg A002 ignore preserves the surface.
Validation:
- Either
models(≥ 2 candidates) ORfile=must be supplied. - At most one candidate may have
default=True. bcstlim/fcstlim/qlim∈[0, 100].overdiff∈[0.9, 1.0].
Source code in src/tsecon/x13/_spec.py
3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 | |
slidingspans ¶
slidingspans(
*,
cutchng: float | X13default = _X13DEFAULT,
cutseas: float | X13default = _X13DEFAULT,
cuttd: float | X13default = _X13DEFAULT,
fixmdl: bool | str | X13default = _X13DEFAULT,
fixreg: list[str] | X13default = _X13DEFAULT,
length: int | X13default = _X13DEFAULT,
numspans: int | X13default = _X13DEFAULT,
outlier: str | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
start: MIT | X13default = _X13DEFAULT,
additivesa: str | X13default = _X13DEFAULT,
fixx11reg: bool | X13default = _X13DEFAULT,
x11outlier: bool | X13default = _X13DEFAULT,
) -> X13slidingspans
Build the slidingspans spec — stability analysis options.
Mirrors x13spec.jl:2666-2701. The Julia length field collides
with Python's :func:len built-in but is not a Python reserved word,
so the kwarg keeps its X-13 name with a per-line A002 ignore.
Validation:
- Setting both
fixmdl=Trueandfixreg=[...]warns (fixregis ignored by X-13 in that combination, mirroring the upstream@warn).
Source code in src/tsecon/x13/_spec.py
spectrum ¶
spectrum(
*,
logqs: bool | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
qcheck: bool | X13default = _X13DEFAULT,
start: MIT | X13default = _X13DEFAULT,
tukey120: bool | X13default = _X13DEFAULT,
decibel: bool | X13default = _X13DEFAULT,
difference: bool | str | X13default = _X13DEFAULT,
maxar: int | X13default = _X13DEFAULT,
peakwidth: int | X13default = _X13DEFAULT,
series: str | X13default = _X13DEFAULT,
siglevel: int | X13default = _X13DEFAULT,
type: str | X13default = _X13DEFAULT,
) -> X13spectrum
Build the spectrum spec — spectral-diagnostic options.
Mirrors x13spec.jl:2785-2816. No numeric validation upstream;
range checks happen in the X-13 binary.
The series kwarg shadows the :func:series spec builder at
module level; this is the X-13 grammar's name (series=:original
selects which series feeds the spectrum) and the per-kwarg A002
ignore preserves the surface.
Source code in src/tsecon/x13/_spec.py
x11regression ¶
x11regression(
*,
aicdiff: float | X13default = _X13DEFAULT,
aictest: str | list[str] | X13default = _X13DEFAULT,
critical: float | X13default = _X13DEFAULT,
data: MVTSeries | X13default = _X13DEFAULT,
file: str | X13default = _X13DEFAULT,
format: str | X13default = _X13DEFAULT,
outliermethod: str | X13default = _X13DEFAULT,
outlierspan: MITRange | Span | X13default = _X13DEFAULT,
print: str | list[str] | X13default = _X13DEFAULT,
save: str | list[str] | X13default = _X13DEFAULT,
savelog: str | list[str] | X13default | None = None,
prior: bool | X13default = _X13DEFAULT,
sigma: float | X13default = _X13DEFAULT,
span: MITRange | Span | X13default = _X13DEFAULT,
tdprior: list[float] | X13default = _X13DEFAULT,
usertype: str | list[str] | X13default = _X13DEFAULT,
variables: _VariablesField = _X13DEFAULT,
almost: float | X13default = _X13DEFAULT,
b: list[float] | X13default = _X13DEFAULT,
fixb: list[bool] | X13default = _X13DEFAULT,
centeruser: str | X13default = _X13DEFAULT,
eastermeans: bool | X13default = _X13DEFAULT,
forcecal: bool | X13default = _X13DEFAULT,
noapply: list[str] | X13default = _X13DEFAULT,
reweight: bool | X13default = _X13DEFAULT,
umdata: MVTSeries | X13default = _X13DEFAULT,
umfile: str | X13default = _X13DEFAULT,
umformat: str | X13default = _X13DEFAULT,
umprecision: int | X13default = _X13DEFAULT,
umtrimzero: bool | str | X13default = _X13DEFAULT,
) -> X13x11regression
Build the x11regression spec — calendar / outlier irregular-component regression.
Mirrors x13spec.jl:3420-3559. The start / user / umstart /
umname fields are derived from data / umdata (mirrors the
Julia upstream's derivation; no user-facing kwargs accepted).
Validation:
aictest(when set) restricted to{td, tdstock, td1coef, tdstock1coef, easter, user}. If both a TDaictestentry and a TDvariablesentry are present, the AIC-test set must be a subset of the variables-used set.sigmamust be > 0.tdpriormust have length 7 and all entries ≥ 0.usertype(when set) restricted to{td, holiday, user}. Vector form's length must match the number of user series.- :class:
Spanoutlierspanrejects fuzzye(the builder accepts only :class:MITor :data:Nonealready; the upstream check collapses to a no-op).
Source code in src/tsecon/x13/_spec.py
3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 | |
newspec ¶
newspec(
series: X13series | TSeries | X13default = _X13DEFAULT,
*,
arima: X13arima | X13default = _X13DEFAULT,
estimate: X13estimate | X13default = _X13DEFAULT,
transform: X13transform | X13default = _X13DEFAULT,
regression: X13regression | X13default = _X13DEFAULT,
automdl: X13automdl | X13default = _X13DEFAULT,
x11: X13x11 | X13default = _X13DEFAULT,
x11regression: X13x11regression
| X13default = _X13DEFAULT,
check: X13check | X13default = _X13DEFAULT,
forecast: X13forecast | X13default = _X13DEFAULT,
force: X13force | X13default = _X13DEFAULT,
pickmdl: X13pickmdl | X13default = _X13DEFAULT,
history: X13history | X13default = _X13DEFAULT,
metadata: X13metadata | X13default = _X13DEFAULT,
identify: X13identify | X13default = _X13DEFAULT,
outlier: X13outlier | X13default = _X13DEFAULT,
seats: X13seats | X13default = _X13DEFAULT,
slidingspans: X13slidingspans
| X13default = _X13DEFAULT,
spectrum: X13spectrum | X13default = _X13DEFAULT,
folder: str | X13default = _X13DEFAULT,
) -> X13spec
Build a new :class:X13spec aggregator.
Mirrors x13spec.jl:578-629. The Julia overloads
newspec(::X13series), newspec(::Type{<:Frequency}), and
newspec(::TSeries) collapse to a single Python signature: pass
either an :class:X13series (the usual shape) or a
:class:~tsecon.tseries.TSeries (the convenience shape — internally
wrapped via :func:series). The Julia newspec(::Type{<:Frequency})
overload, which builds a spec without series for the rare
composite-only flow, is intentionally not ported — the
composite spec is not supported (see x13spec.jl:563).
The string field is always initialised to :data:_X13DEFAULT —
it is populated only by :func:tsecon.x13._write.x13write as a
side-effect of serialization (mirrors the Julia upstream's
spec.string = ... mutation at x13write.jl:72).
Source code in src/tsecon/x13/_spec.py
4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 | |
validateX13spec ¶
Cross-spec invariant check — runs before the binary sees the spec.
Mirrors x13spec.jl:3563-4055 (validateX13spec). Branches that
Julia handles with ArgumentError raise :exc:ValueError; branches
that Julia logs via @warn emit :class:UserWarning through
:func:warnings.warn (the project's error::UserWarning filter at
pyproject.toml turns silent misuse into a test-failure, mirroring
the Julia upstream's @test_warn discipline).
Coverage spans:
- ARIMA-source mutual exclusion:
arima⊥automdl⊥pickmdl. estimate.fileoverrides: blocksarima.{model,ar,ma}andregression.{variables,user,b}.- Forecast / history overlap:
history.fstep ≤ forecast.maxlead. - Regression variable type compatibility (~16 raise sites): the
trading-day / leap-year / length-of-period / stock-vs-flow
compatibility matrix per
x13spec.jl:3621-3777. - AIC-test type compatibility (~12 raise sites): parallel to the
variables matrix but for the
aictest=argument. - Outlier-range containment:
ao/ls/so/tc/ range variants must lie within the series range. - Regression / x11regression data-range containment (with forecast backcast/maxlead expansion).
- Slidingspans length bounds (quarterly: 12 ≤ length ≤ 76; monthly: 36 ≤ length ≤ 228).
- Seats HP-filter sample-size warning.
- Modelspan-vs-span backcast warning.
- Transform/x11 mode compatibility (
adjustvsx11.mode). - X11regression-vs-forcecal warning.
Source code in src/tsecon/x13/_spec.py
4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 | |
Writer¶
tsecon.x13._write ¶
X-13ARIMA-SEATS spec serializer: :class:X13spec -> .spc text.
Mirrors TimeSeriesEcon.jl/src/x13/x13write.jl (294 LOC). Lands in
M2.4 alongside :func:tsecon.x13._spec.validateX13spec.
Surface:
- :func:
x13write(x13write.jl:50) — top-level emitter that walks the :class:~tsecon.x13._spec.X13specand emits each populated sub-spec's text block. - :func:
impose_line_length(x13write.jl:8) — line-wrap helper that splits long argument lines so the X-13as binary does not reject the spec on its 132-column line limit. Mutates the input list in place (mirrors Julia'simpose_line_length!!-suffixed name). - :func:
emit_block(private) — render one<name> { ... }block from a populated sub-spec dataclass; the writer's main per-block worker.
The Julia version writes a spec.spc text file directly to disk; the
Python port returns the text as a :class:str so that callers that do
not need the file (testing, dry-run validation) skip the I/O. The
X13.run entry (M2.5) calls :func:x13write then writes the
returned text to <tempdir>/spec.spc itself, mirroring Julia's
open(...) do f; println(f, spec.string); end block.
Line-wrap quirks (mirrors Julia x13write.jl:8-47):
_text_len(s)treats each\tas eight columns (Julia_length); the writer never emits tabs, but the wrapper handles them for round-trip fidelity with hand-edited spec strings." + "is preferred as a split point over plain spaces becauseprint=(table1 + table2 + …)lists are the most common long-argument shape (the Julia upstream'sx13write_plus(::Vector{Symbol})produces them).- When the leading whitespace-only fragment of a continuation line
cannot fit a single un-splittable token, raise :exc:
ValueErrorrather than recurse infinitely (JuliaArgumentError).
impose_line_length ¶
Wrap any over-limit lines in s in place.
Mirrors Julia impose_line_length! (x13write.jl:8-47). Walks
the list; for each line longer than limit columns, splits at
the last " + " (when present) or otherwise the last space that
keeps the prefix within budget, then inserts the suffix — prefixed
with 8 spaces of continuation indent — at the next position.
Recurses into "\n"-joined sub-lines when delve=True (so
embedded newlines, e.g. inside metadata blocks, get wrapped on
their own terms before being rejoined).
Raises :exc:ValueError when a continuation line cannot be split
further (single un-splittable token over budget) — surfaces the
Julia ArgumentError from x13write.jl:38-41.
Source code in src/tsecon/x13/_write.py
x13write ¶
Serialize an :class:X13spec to .spc text.
Mirrors Julia x13write(::X13spec) (x13write.jl:50-80). Runs
:func:validateX13spec first; on success, walks series followed
by each populated sub-spec field in declaration order, emits each
block, and joins them with newlines.
test=True skips the print / save / savelog fields
on each block — useful for round-trip and validation tests that
don't want to lock the per-binary output defaults.
The rendered text is stored on :attr:X13spec.string as a
side-effect (mirrors Julia spec.string = join(s, "\n")); the
function additionally returns the text so callers can pipe it to
a file or to the binary directly.
outfolder is the directory the M2.5 binary runner created;
used by the pickmdl block to emit a side-file (pickmdl.mdl)
rather than inline the model list. If :data:None, the model list
is inlined.
Source code in src/tsecon/x13/_write.py
Per-format readers¶
The nine x13read_* functions parse each output channel X-13 produces
(time series, workspace tables, UDG diagnostics, etc.). End users
rarely need them — the eager / lazy materialisation built into
X13ResultWorkspace handles dispatch — but the parsers are part of
the public surface for the same reason they are in the Julia upstream:
roundtripping captured X-13 output against fixtures is a common
port-validation workflow.
tsecon.x13._result.x13read_series ¶
Parse an X-13 tabular series output file.
Mirrors Julia x13read_series at x13result.jl:455-493. The
first line is a tab-separated header row beginning with a date
column; line 2 is dashes; lines 3+ are tab-separated rows where the
first column is the period token and the remainder are float
values.
Returns:
| Type | Description |
|---|---|
* :class:`MVTSeries` when there are 2+ data columns,
|
|
* :class:`TSeries` when there is exactly 1 data column,
|
|
* empty :class:`TSeries` over the inferred range when the header
|
row has no data columns past the date column (mirrors the Julia
|
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_seatsseries ¶
Parse a SEATS-format series file (whitespace-delimited, indented).
Mirrors Julia x13read_seatsseries at x13result.jl:495-530.
SEATS output uses \s\s+ as the column delimiter (two or more
consecutive whitespace chars) and offsets the header row by 1-2
lines depending on the layout.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_workspace_table ¶
Parse an X-13 multi-column tabular output into a :class:WorkspaceTable.
Mirrors Julia x13read_workspace_table at x13result.jl:398-453.
The first line is a tab-separated header row; subsequent lines are
tab-separated value rows. Two special-case extensions:
ext="acm"— the header row is missing the"lag"column; it's inserted at position 1 (0-indexed).ext="rog"— the rate-of-growth table uses a different header layout that is rebuilt from line 2.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_key_values ¶
x13read_key_values(
lines: Sequence[str],
separator: Pattern[str] | str = re.compile("[\\t:]"),
) -> Workspace
Parse an X-13 key/value output file into a :class:Workspace.
Mirrors Julia x13read_key_values at x13result.jl:316-390. The
key is the text before the first separator match; the value is the
stripped text after. Values are tried (in order) as: an X-13 date
(only for key == "date"), an integer, a float, a vector of
floats (whitespace-separated), the booleans "yes" / "no".
Otherwise the raw string is kept.
The default separator is the Julia upstream's r"[\t\:]" —
either a tab or a colon. The "udg" parser passes ": "
instead (mirrors the upstream regex / string switch).
After all keys are loaded, :func:_add_layers rewrites dotted keys
into nested workspaces.
Source code in src/tsecon/x13/_result.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 | |
tsecon.x13._result.x13read_udg ¶
Parse a UDG (Census-Bureau-defined diagnostic) output file.
Mirrors Julia x13read_udg at x13result.jl:392-395. Reads
the file as text, splits on newlines, and dispatches to
:func:x13read_key_values with separator ": ".
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_estimates ¶
Parse the X-13 .est (estimates) output file.
Mirrors Julia x13read_estimates at x13result.jl:532-560.
Walks the file looking for the section markers $arima:,
$regression:, $arima$estimates:, $regression$estimates:,
$variance:; dispatches each section to the right sub-parser.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_model ¶
Parse the X-13 .mdl (model) output file.
Mirrors Julia x13read_model at x13result.jl:579-613. The
file contains zero, one, or both of an arima{model=...} block
and a regression{...} block; each is dispatched to
:func:_x13read_model_block.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_identify ¶
Parse the X-13 .iac / .ipc (identify) output files.
Mirrors Julia x13read_identify at x13result.jl:562-577. The
file contains 1+ pages, each beginning with a $diff = N /
$sdiff = M pair followed by an autocorrelation /
partial-autocorrelation table.
Source code in src/tsecon/x13/_result.py
tsecon.x13._result.x13read_err ¶
x13read_err(
file: str | PathLike[str],
warnings_out: list[str],
notes_out: list[str],
errors_out: list[str],
) -> None
Parse the X-13 .err output file into warnings / notes / errors lists.
Mirrors Julia x13read_err at x13result.jl:287-313. Each
diagnostic begins with " WARNING:" / " ERROR:" / " NOTE:"
(note the leading space); continuation lines are appended to the
last diagnostic with \n separators. The three output lists are
mutated in place to mirror the Julia push! shape.
Source code in src/tsecon/x13/_result.py
License notice¶
The X-13ARIMA-SEATS binary vendored in the wheels is a U.S. Government
work and not subject to U.S. copyright (17 U.S.C. §105). The full
Census Bureau disclaimer
ships in the wheel at tsecon/x13/X13AS_LICENSE.txt and is reproduced
in the project LICENSE
file's third-party section. The Python wrapper code is MIT-licensed.