Skip to content

add geqdsk_sign_convention and geometry_type as None in the ctx dict.#180

Merged
manauref merged 15 commits intomainfrom
metadata_retrocompatibility_fix
Feb 18, 2026
Merged

add geqdsk_sign_convention and geometry_type as None in the ctx dict.#180
manauref merged 15 commits intomainfrom
metadata_retrocompatibility_fix

Conversation

@Antoinehoff
Copy link
Copy Markdown
Collaborator

@Antoinehoff Antoinehoff commented Feb 10, 2026

related to #179.

We refactor the structure

ctx['a_field'] = None
...
if ctx['a_field'] is not None:

but simply do now

ctx = {}
...
if 'a_field' in ctx.keys():

Also, to print in a raw format all keys, present in the metadata, that were not printed yet, we store the key of all previously printed keys in a local list that will be the comparison point instead of having a manually written list, going from

    for key, val in self.ctx.items():
      if key not in ["time", "frame", "changeset", "builddate", "basis_type",
          "poly_order","is_modal", "lower", "upper", "cells", "num_comps",
          "grid_type", "num_cdim", "num_vdim","geometry_type","geqdsk_sign_convention"] and val is not None:
        output += f"\n├─ {key:s}: {val}"

to

    for key, val in self.ctx.items():
      if key not in printed_keys:
        output += f"\n├─ {key:s}: {val}"

We also remove the commented # end statements.

With this branch, the failing example presented in the issue is fixed:

pgkyl rt_gk_tcv_nt_iwl_adapt_src_3x2v_p1-ion_0.gkyl info
(default#0)
├─ Time: 0.000000e+00
├─ Frame: 0
├─ Number of components: 48
├─ Number of dimensions: 5
├─ Grid: (uniform)
│  ├─ Dim 0: Num. cells: 24; Lower: 0.000000e+00; Upper: 1.200000e-01
│  ├─ Dim 1: Num. cells: 16; Lower: -1.049232e-01; Upper: 1.049232e-01
│  ├─ Dim 2: Num. cells: 12; Lower: -3.141593e+00; Upper: 3.141593e+00
│  ├─ Dim 3: Num. cells: 12; Lower: -7.071068e-01; Upper: 7.071068e-01
│  └─ Dim 4: Num. cells: 8; Lower: 0.000000e+00; Upper: 1.000000e+00
├─ Maximum: 2.266065e-06 at (2, 6, 4, 6, 2) component 0
├─ Minimum: -3.585019e-07 at (3, 2, 4, 6, 3) component 5
├─ DG info:
│  ├─ Polynomial Order: 1
│  └─ Basis Type: gkhybrid (modal)
├─ Created with Gkeyll:
│  ├─ Changeset: 5506bbe9d39a
│  └─ Build Date: 2026-02-05 12:55:25 PST
├─ Geometry info:
│  ├─ Type: GKYL_GEOMETRY_MAPC2P

@Antoinehoff Antoinehoff requested a review from manauref February 10, 2026 14:07
@manauref
Copy link
Copy Markdown
Collaborator

I considered this when I made changes to meta, but I don't think it's the right approach. We need to move away from calling out specific meta in various places in the postgkyl, and instead making the code work with any meta (it doesn't yet). This means that:

  • All those specifications of None meta at the top of gdata.py should go away
  • The rest of the code should work regardless of what meta is in the file or not.
    See my suggestion in the issue, that improves things a bit I think. But we need to improve it further eventually so that some of those if-statements are replaced with something more abstract.

@Antoinehoff
Copy link
Copy Markdown
Collaborator Author

ok well, I am not against more global changes in the structure but here it is just a mistake to not set the dict entry as None as all of the other field of the dict are already set to None. This should be pushed to fix the retro compatibility issue that was introduced. Larger structural code changes can be done but are less urgent.

@manauref
Copy link
Copy Markdown
Collaborator

manauref commented Feb 10, 2026 via email

@Antoinehoff
Copy link
Copy Markdown
Collaborator Author

Antoinehoff commented Feb 10, 2026

It may work too yes but I think it is better to follow the existing structure, and change it globally later if we want to, so I am not favorable to the fix mentioned in the issue.

@manauref
Copy link
Copy Markdown
Collaborator

manauref commented Feb 10, 2026 via email

Copy link
Copy Markdown
Collaborator

@manauref manauref left a comment

Choose a reason for hiding this comment

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

unit tests failing

@manauref manauref merged commit 862318b into main Feb 18, 2026
3 checks passed
@manauref manauref deleted the metadata_retrocompatibility_fix branch February 18, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants