Skip to content

Issues with width of separator when using non-gridded table layout #11

@AnjoMan

Description

@AnjoMan

When i use SEPARATING_LINE in 'mixed_grid' or 'simple_outline', i get an extra row (according to the docs, this is how the separator is done for some styles. However, i noticed the extra row does not seem to adopt the width of the table, but just has a little empty string.

An MWE:

from tabulate import tabulate, SEPARATING_LINE
mse_table = tabulate(
    [
        ["Mean-Squared Current Error", "∑ΔI² / N",  "0.00000000000000000032486767"  + " A²"],
        ["Mean-Squared Voltage Error", "∑ΔV² / N",  "0.00000000000000000000000019092038" + " V p.u.²"],
        SEPARATING_LINE,
        ["Mean-Absolute Current Error", "∑|ΔI| / N", "0.00000000021306265" + " A"],
        ["Mean-Absolute Voltage Error", "∑|ΔV| / N", "0.000000000000341719" + " V p.u."]
    ],
    headers=["Summarizing Error", "Formula", "Value"],
    tablefmt="mixed_grid"
)

print(mse_table)

This produces the following table:


┌─────────────────────────────┬───────────┬────────────────────────────────────────────┐
│ Summarizing Error           │ Formula   │ Value                                      │
├─────────────────────────────┼───────────┼────────────────────────────────────────────┤
│ Mean-Squared Current Error  │ ∑ΔI² / N  │ 0.00000000000000000032486767 A²            │
│ Mean-Squared Voltage Error  │ ∑ΔV² / N  │ 0.00000000000000000000000019092038 V p.u.² │
│  │
│ Mean-Absolute Current Error │ ∑|ΔI| / N │ 0.00000000021306265 A                      │
│ Mean-Absolute Voltage Error │ ∑|ΔV| / N │ 0.000000000000341719 V p.u.                │
└─────────────────────────────┴───────────┴────────────────────────────────────────────┘

It seems to me like there should ideally be a step that computes the width of the row, or injects it a bit more formally in the table so its width is properly derived from whatever tabulate picks for trhe rest of the table.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions