Skip to content

Improve YAML output formatting #1128

@ischoegl

Description

@ischoegl

Problem description

As observed in #1112 (and likely elsewhere), some of the human-readable output generated by YAML emitters could be improved.

Steps to reproduce

The YAML output below can be produced using the new save method proposed for 1D objects (#1112), but the underlying implementation predates this PR (goes back to #984).

Behavior

There are three formatting issues documented thus far:

(1) Scalars / Rounding

As already pointed out in #984 (where serialization was initially introduced), there are some "floating point rounding issues [that] result in kind of ugly values". For example:

    tolerances:
      steady-abstol: 1.0e-09
      steady-reltol: 1.0e-04
      transient-abstol: 9.999999999999999e-12 # <-- should be 1.0e-11
      transient-reltol: 1.0e-04

I have not looked into details, but at least for scalar values there may be a way to catch these items.

(2) Vectors / Efficient use of space

Number blocks don't use horizontal space efficiently; this may be addressed by changing:

    velocity: [0.7112641405849059, 0.7112641405822596, 0.7112641404451637,
    0.7112641377426332, 0.7112641104415781, 0.7112637339406135,
    0.7112617435453226, 0.7112560064702751, 0.7112322153842345,
    ...
    4.055246182368149, 4.055246182377726]

to

    velocity: [
      0.7112641405849059, 0.7112641405822596, 0.7112641404451637, 0.7112641377426332, 
      0.7112641104415781, 0.7112637339406135, 0.7112617435453226, 0.7112560064702751, 
      0.7112322153842345, 0.7111349509095231, 0.7109781680863129, 0.7106086071388092,
      ...
      4.055246182368149, 4.055246182377726]

which uses space more efficiently and also improves readability from a human perspective. Beyond, there is likely an optimized number of characters per line that prevents ragged output in most cases.

System information

  • Cantera version: 2.6
  • OS: any
  • Python/MATLAB/other software versions: any

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions