Skip to content

MivotInstance update#747

Merged
tomdonaldson merged 5 commits into
astropy:mainfrom
lmichel:fix-mivot-instance
May 21, 2026
Merged

MivotInstance update#747
tomdonaldson merged 5 commits into
astropy:mainfrom
lmichel:fix-mivot-instance

Conversation

@lmichel
Copy link
Copy Markdown
Contributor

@lmichel lmichel commented Apr 17, 2026

  • FEATURE: Return None when accessing missing attributes, e.g. not mapped model field
  • BUG FIX: Support unit strings with a DOT, e.g. ms.year-1

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.79%. Comparing base (6f677f7) to head (828ea43).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #747      +/-   ##
==========================================
- Coverage   79.80%   79.79%   -0.01%     
==========================================
  Files          91       91              
  Lines       10297    10297              
==========================================
- Hits         8218     8217       -1     
- Misses       2079     2080       +1     

☔ 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.

@msdemlei
Copy link
Copy Markdown
Contributor

msdemlei commented Apr 17, 2026 via email

@lmichel
Copy link
Copy Markdown
Contributor Author

lmichel commented Apr 21, 2026

@msdemlei,

Thank you for your comments.

  • The mivot module does not parse the units, as you said this is the job of Astropy which will take place later. The purpose of this PR is just to ensure that units are read correctly regardless of their values.
  • The tested units (mas.year-1) come from TAP simbad. Whether they are valid or not, the API must be able to read them.

I took this opportunity to simplify the code in question a bit and expand the tests.

@bsipocz bsipocz added this to the v1.9 milestone Apr 21, 2026
Copy link
Copy Markdown
Contributor

@tomdonaldson tomdonaldson left a comment

Choose a reason for hiding this comment

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

Thanks @lmichel ,this looks good to me. I had one minor question, but will approve.

There is also a minor merge conflict. I can resolve that if it's helpful.

mivot_object = MivotInstance(**mydict)
assert mivot_object.longitude.unit == "mas.year-1"
mydict["dmid"] = "a.b.c"
mivot_object = MivotInstance(**mydict)
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.

Should there be an assert for this object or is it just ensuring that no exceptions are thrown on the instantiation?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It just to check that no exceptions are thrown

@lmichel
Copy link
Copy Markdown
Contributor Author

lmichel commented May 21, 2026

Conflict in change log fixed

Comment thread CHANGES.rst

- Improve ``pyvo.mivot.viewer.%ivotInstance`` (API to allow users to access the mapped data
attributes directly as properties of the instance); [#747]
- Access to not exiting attribute, e.g. not mappped, returns ``None``
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.

Suggested change
- Access to not exiting attribute, e.g. not mappped, returns ``None``
- Access to non-existent attribute, e.g. not mapped, returns ``None``

Comment thread CHANGES.rst
- Improve ``pyvo.mivot.viewer.%ivotInstance`` (API to allow users to access the mapped data
attributes directly as properties of the instance); [#747]
- Access to not exiting attribute, e.g. not mappped, returns ``None``
- Support DOTS in unit string, e.g. "mas.year-1"
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.

Not obvious how this was achieved? By removing code?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

by implementing a __getattr__(self, item) method. Should the change log give this detail?

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.

nope, no need for these internal details in the changelog. If you want you can leave some comments in the source code; but I'm not sure how much clearer it would make things.

Copy link
Copy Markdown
Contributor Author

@lmichel lmichel May 21, 2026

Choose a reason for hiding this comment

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

There is a long comment telling what this method is for

@tomdonaldson tomdonaldson merged commit 24b77e5 into astropy:main May 21, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants