pymetrix-eviews¶
A plugin: a separate package
pymetrix-eviews is a first-party plugin, installed on its own:
EViews workfiles into pymetrix: a bundle written by an (experimental) export program, read with its metadata, equations and models. Not affiliated with or endorsed by the makers of EViews.
The names pymetrix_eviews exports (its __all__), with their full documentation. Import them from the plugin: from pymetrix_eviews import .... The plugin's README says more.
Public names¶
bundle_model
¶
A model of the page, read by read_eviews: its text, with the equations it links fitted to data by the
core reader (least squares, on each equation's sample) and the page's scalars that the text names as its
parameters. EViews's own estimates are not used; compare_estimates sets the two side by side.
bundle_pages
¶
The pages of a bundle, without reading their data: name, structure, frequency, how many series, and why the
page cannot be read with a time axis (refused; None when it can).
bundle_schema
¶
The JSON Schema of the manifest (format version 1).
compare_estimates
¶
Each least-squares equation of the page refitted in pymetrix, against EViews's own estimates: a Table with
a row per coefficient, saying matches (within tolerance, relative, for the estimate and its standard error)
or how much they differ. Equations by other methods, or with options (ls(cov=white)), are listed as not
compared, with the reason. The refit is the core reader's (read_eviews with the data), on each equation's
sample; a list specification's c is pymetrix's const.
eviews_objects
¶
The page's other EViews objects, as pymetrix's: groups as Selection (data.series(...); a group with a
member that is not a series of the page is left out), samples as Sample (where eviews_sample translates
them), scalars as numbers, strings as text, vectors and matrices as Matrix, and models as templates
(bundle_model; a model the core reader refuses is left out). What is left out is listed under "_left_out"
with the reason.
eviews_sample
¶
An EViews sample's text as a pymetrix Sample, or None when it does not translate: @all, and one pair
of ends (1980q1 2007q4, @first 2000q4, 1990:1 @last with the page's frequency, Q or M).
Conditions (if ...) and several pairs are not translated.
EViewsBundleNote
¶
Bases: UserWarning
Something about a bundle the user should know, which did not stop it being read: a file that was not UTF-8, a bundle from an older export program, keys this reader does not know, names changed to be valid Python names.
export_program
¶
The text of pymetrix_export.prg, the program that writes a bundle from EViews. EXPERIMENTAL: written from
EViews's documentation and never run in EViews (the project has no licence); every (verify) comment in it is
a point to check. Saving the workfile from EViews as CSV or Excel is the supported way in.
ProgramTranslation
dataclass
¶
ProgramTranslation(script: str, report: TranslationReport, program: str = '', ops: Sequence[Any] = (), functions: Sequence[Any] = (), objects: Mapping[str, Any] = dict(), arguments: Mapping[str, str] = dict(), sources: Mapping[str, str] = dict(), script_lines: Mapping[Any, int] = dict(), pages: Mapping[str, str] = dict())
Bases: Translation
An EViews program translated (translate_program): script, readable Python that uses pymetrix's public
API; report, a row per line; and run(session), the same work as recorded steps. All three come from one
representation, so the script and the steps give equal objects. pages are the workfile's pages, EViews name
-> the script's variable.
run
¶
run(session: Any = None, attach: bool = True, *, args: Any = None, while_cap: int | None = None, run: Any = None) -> dict[str, Any]
Run the translation as steps (steps mode) in session (a new Session when None): each data
statement a recorded call (make_call), so History and the session's script hold it as if typed or made
in a dialog; loops, if blocks and subroutines run in Python, a condition decided by the results made
before it; scalars, strings and matrices are Python values, not steps, and are returned (name -> value),
with the session under "session". With attach, the readable script and the report are kept in the
project (session.attachments["pymetrix-eviews"]["<program>.py"] and "<program>.txt"). Stops at the
first step that fails, raising its error with the line.
args replaces the program's arguments (%0, %1: strings, or one string of words); while_cap is
how many passes a while loop may make before it stops with an error (default 10,000); run runs each
step instead of session.run (the app's AppInterface.run, which records it and lets it be undone).
The objects given to the translation (objects=) are put in the session when it has none of that name.
read_bundle
¶
One page of an EViews bundle as a Dataset (Dataset.read(path, page=...) comes here for .evbundle).
page is the page's name, as in EViews (any case); it may be left out when the bundle has one page.
undated=True reads a dated page as undated (rows numbered from 1, the dates kept as the text series
date): for frequencies pandas has no period for, such as semi-annual.
Each series keeps its EViews metadata: the label (the display name, else the description), description, units
and source; the remarks, attributes, value map and EViews's own name, when changed, in Variable.extra.
meta.extra["eviews"] keeps the rest of the page: its frequency, range and sample, the groups, samples,
scalars, strings, matrices, equations (with EViews's estimates) and models, the objects the program skipped, and
the notes on the reading. eviews_objects(data) turns them into pymetrix objects.
ReportRow
dataclass
¶
Bases: ReportRow
One line of the program: its number (from 1), status (one of STATUSES), the EViews text (source,
also eviews), the Python it became (empty for a line left out, or a line that continues a statement), and the
reason, with pymetrix's equivalent where there is one.
save_export_program
¶
Save a copy of the export program (EXPERIMENTAL, untested in EViews) at path (a folder: as
pymetrix_export.prg in it), with Windows line ends, as EViews expects; returns where it was saved.
translate_program
¶
translate_program(source: Any, bundle: Any = None, *, read_options: dict[str, Any] | None = None, args: Any = (), objects: Any = None, folder: Any = None) -> ProgramTranslation
An EViews program translated: .script (readable Python), .report (a row per line: translated,
translated with a note, left out or error, with the reason) and .run(session) (steps mode).
source is the program's text, or the path of a .prg file. bundle is what its wfopen opens: the
bundle the export program wrote (.evbundle), or a CSV or Excel file the user saved from the workfile in
EViews; read_options are Dataset.read's options for that file (time="obs", freq="Q"). Without it,
wfopen is an error saying how to make one; a program that starts with wfcreate needs none.
args are the program's arguments (%0, %1, ...: what follows the program's name in exec prog.prg
us 2020q1), as strings or one string of words; they are the script's parameters (arg0 = "us" at its top).
objects are objects the program uses but does not make, by their EViews names: in EViews an add-in, a
database or another program makes them. A Model (or a model read, whose .model is one) is solved by the
program's model lines; a Dataset is a page. The script expects them under those names, and steps mode puts
them in the session. folder is where included programs are looked for (default: the program's own folder,
or the current one for text).
TranslationReport
dataclass
¶
TranslationReport(rows: tuple[ReportRow, ...], program: str = '', language: str = '')
One row per line of the program that has text (blank lines have none), in order; program is its name and
language the name of its language, the heading of the column of its text ("EViews", "R").
line
¶
line(number: int, file: str | None = None) -> ReportRow
The row of a line (from 1) of the program, or of an included one (file, as the report names it).
summary
¶
The report as a Table: line, status, the program's text (headed by its language), Python and reason,
with the counts as notes.
files
¶
The program's name and the included programs', in the order their rows come.
to_text
¶
The report (or some of its rows) as plain text, a line per row; an included program's rows under a
line naming it.
Plugin plumbing¶
What pymetrix's plugin loader reads (PLUGIN, register) and the plugin's version.
PLUGIN
module-attribute
¶
PLUGIN = PluginInfo(name='pymetrix-eviews', version=__version__, api='1.13', license='BSD-3-Clause', maintainer='Geoffrey Heenan', description='EViews workfiles into pymetrix through a bundle the (experimental) export program writes: pages, series with their labels, groups, samples, scalars, matrices, equations and models')
register
¶
The entry point (pymetrix.plugins, pymetrix.io, pymetrix.commands): .evbundle files read
through read_bundle, the File → Import EViews workfile… dialog and the help topic. Importing the package registers
them too; a second call does nothing.