Skip to content

info routine to display info about the ObsSequence#133

Open
hkershaw-brown wants to merge 1 commit into
mainfrom
info
Open

info routine to display info about the ObsSequence#133
hkershaw-brown wants to merge 1 commit into
mainfrom
info

Conversation

@hkershaw-brown
Copy link
Copy Markdown
Member

repl and str also

fixes #92

Example:

>>> import pydartdiags.obs_sequence.obs_sequence as obsq
>>> obs_seq = obsq.ObsSequence(file=None)
>>> obs_seq
ObsSequence(file=None)
>>> print(obs_seq)
ObsSequence: None
  obs types : []
  copies    : []
  n_obs     : 0
>>> obs_seq.info()
Non-routines (data attributes):
  - all_obs: []
  - copie_names: []
  - default_composite_types: /Users/hkershaw/DART/siparcs/2026/pyDARTdiags/src/pydartdiags/obs_sequence/composite_types.yaml
  - df: DataFrame(0, 0)
  - file: None
  - loc_mod: None
  - n_copies: 0
  - n_non_qc: 0
  - n_qc: 0
  - non_qc_copie_names: []
  - qc_copie_names: []
  - reverse_types: {}
  - reversed_vert: {'undefined': -2, 'surface (m)': -1, 'model level': 1, 'pressure (Pa)': 2, 'height (m)': 3, 'scale height': 4}
  - seq: []
  - synonyms_for_obs: ['NCEP BUFR observation', 'AIRS observation', 'GTSPP observation', 'SST observation', 'observations', 'WOD observation']
  - types: {}
  - vert: {-2: 'undefined', -1: 'surface (m)', 1: 'model level', 2: 'pressure (Pa)', 3: 'height (m)', 4: 'scale height'}

Routines (methods/functions):
  - composite_types
  - create_header
  - create_header_from_dataframe
  - has_assimilation_info
  - has_posterior
  - info
  - join
  - possible_vs_used
  - select_by_dart_qc
  - select_used_qcs
  - update_attributes_from_df
  - write_obs_seq

This example is a black obs seq so boring.

@hkershaw-brown
Copy link
Copy Markdown
Member Author

hkershaw-brown commented Jun 2, 2026

in print(obs_seq) also want loc_mod?

edit added loc mod

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jun 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.85%. Comparing base (4f97859) to head (40dd517).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #133      +/-   ##
==========================================
+ Coverage   64.12%   64.85%   +0.72%     
==========================================
  Files           5        5              
  Lines        1115     1138      +23     
==========================================
+ Hits          715      738      +23     
  Misses        400      400              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

for r in routines:
print(f" - {r}")

def __repr__(self):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What does repr stand for? Might be obvious but I can't think of anything

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Read-Execute-Print Loop,

Believe it or not lfortran has a REPL for fortran (https://docs.lfortran.org/en/) so you can run fortran interactively (even in a Juypter notebook). Hours of fun.

str is what prints when you do print(obs_seq). So all the attributes of the object
repl is more like what you would use to recreate the object, which is the file.

assert "2" in result # n_obs
assert "loc3d" in result # loc_mod

def test_info(self, obs_seq, capsys):
Copy link
Copy Markdown
Collaborator

@mjs2369 mjs2369 Jun 4, 2026

Choose a reason for hiding this comment

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

Would it be worth it to test if more stuff than this is in the return from info()? Even in an empty obs_seq, as shown in the body text of this PR, there should be the full set of data attributes and routines

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

yes this is exactly what our intern Ira is hitting.
Right now, totally blank.
Should be the required columns. I was thinking it would be good to have Ira do the fix and pull request for a "from scratch" obs seq.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

hang on I am mixing up two issues

The test is using
obj = obsq.ObsSequence(file=None)
which is really minimal (i.e. no info). When really it should be the minimum columns (which is what it would be cool to have Ira add).

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.

inspect routine for ObsSequence object?

3 participants