Skip to content

t.vect.univar: Add format option with plain, JSON and CSV output - #7630

Open
Valyrian-Code wants to merge 5 commits into
OSGeo:mainfrom
Valyrian-Code:t.vect.univar-format-option
Open

Valyrian-Code wants to merge 5 commits into
OSGeo:mainfrom
Valyrian-Code:t.vect.univar-format-option

Conversation

@Valyrian-Code

Copy link
Copy Markdown
Contributor

Adds a format option to t.vect.univar with plain (default), json and csv, following the same pattern as t.rast.univar (#7495) and t.rast3d.univar (#7582).

  • JSON output is a list with one record per registered map: id, start and end plus the statistics exactly as v.univar reports them in its own JSON output, with proper types.
  • CSV uses a comma by default and rejects separators longer than one character. Plain output is unchanged.
  • Option validation matches the two sibling tools (JSON rejects separator and the -u flag).
  • Replaces the old testsuite/test.t.vect.univar.sh smoke test with pytest tests using deterministic attribute values, as suggested in the issue.

Verified locally: plain, csv, json and extended json outputs on a two map STVDS, and all 8 new tests pass.

Fixes #7501.

Copilot AI review requested due to automatic review settings July 3, 2026 01:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added temporal Related to temporal data processing Python Related code is in Python HTML Related code is in HTML libraries module docs markdown Related to markdown, markdown files tests Related to Test Suite labels Jul 3, 2026

@saket0187 saket0187 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some small initial suggestions.

Comment thread temporal/t.vect.univar/tests/t_vect_univar_test.py Outdated
Comment thread temporal/t.vect.univar/tests/t_vect_univar_test.py Outdated
Comment thread temporal/t.vect.univar/tests/t_vect_univar_test.py Outdated
Comment thread temporal/t.vect.univar/t.vect.univar.html
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Thanks for the review, all applied:

  • Removed the needs_solo_run markers. I had copied them from the t.vect.list tests, but the fixture creates its own isolated project, so they are not needed.
  • Switched to result.text_split("\n") in both plain tests.
  • Chained .json directly in the JSON test.

And good to know about the .html files, I will skip them next time. I kept the change here since it is already written and in sync with the .md.

@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Gentle ping, this fixes #7501 and has been open since early July.

Rechecked against current main: still merges cleanly, and #7913 touched the same file but in compute_univar_stats, while this only changes print_vector_dataset_univar_statistics. CI is green. Happy to rebase or split it if that helps.

@wenzeslaus wenzeslaus left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the CSV part here is basically "current output format is CSV already just make sure it is valid"?

Comment thread temporal/t.vect.univar/t.vect.univar.py Outdated
Comment thread python/grass/temporal/univar_statistics.py Outdated
Comment thread python/grass/temporal/univar_statistics.py Outdated
Comment thread temporal/t.vect.univar/t.vect.univar.py Outdated
@Valyrian-Code Valyrian-Code changed the title t.vect.univar: add format option with plain, JSON and CSV output t.vect.univar: Add format option with plain, JSON and CSV output Oct 22, 2026
Use one v.univar call for all three formats. parse_command understands
format="json", so the plain and CSV paths now read the same parsed result
instead of a second call with the shell format.

The shell format named two keys differently and printed floats with %g, so
the plain and CSV paths map missing to nmissing and percentiles to
percentile_90, and format floats the same way. Checked that the plain and
CSV output is unchanged, basic and extended.

Drop the one character limit on the CSV separator, since arbitrary
separators are allowed elsewhere, and its test with it.

Pass the arguments to print_vector_dataset_univar_statistics by keyword.
@Valyrian-Code

Copy link
Copy Markdown
Contributor Author

Yes. The plain output with a comma was already CSV shaped, so the format option mostly makes it official, with comma as the default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs HTML Related code is in HTML libraries markdown Related to markdown, markdown files module Python Related code is in Python temporal Related to temporal data processing tests Related to Test Suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] Adding format option to t.vect.univar

4 participants