-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Implement ObjectDataProvider as a Provider #663
Conversation
It now sets its state on initialization and returns a Pydantic model via the prescribed method. Does not do much of the possible clean-ups within the base class.
rv = DerivedNamedStratigraphy( | ||
name=name if no_start_or_missing_name else strat[name].get("name", name), | ||
alias=[] if no_start_or_missing_name else strat[name].get("alias", []), | ||
stratigraphic=False | ||
if no_start_or_missing_name | ||
else strat[name].get("stratigraphic", False), | ||
stratigraphic_alias=[] | ||
if no_start_or_missing_name | ||
else strat[name].get("stratigraphic_alias"), | ||
offset=0.0 if no_start_or_missing_name else strat[name].get("offset", 0.0), | ||
top=None if no_start_or_missing_name else strat[name].get("top"), | ||
base=None if no_start_or_missing_name else strat[name].get("base"), | ||
name=name if no_stratigraphy_or_name else strat[name].get("name", name), | ||
alias=[] if no_stratigraphy_or_name else strat[name].get("alias", []), | ||
stratigraphic=( | ||
False | ||
if no_stratigraphy_or_name | ||
else strat[name].get("stratigraphic", False) | ||
), | ||
stratigraphic_alias=( | ||
[] | ||
if no_stratigraphy_or_name | ||
else strat[name].get("stratigraphic_alias") | ||
), | ||
offset=0.0 if no_stratigraphy_or_name else strat[name].get("offset", 0.0), | ||
top=None if no_stratigraphy_or_name else strat[name].get("top"), | ||
base=None if no_stratigraphy_or_name else strat[name].get("base"), | ||
) | ||
|
||
if not no_start_or_missing_name and rv.name != "name": | ||
if not no_stratigraphy_or_name and rv.name != "name": | ||
rv.alias.append(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this was not part of this PR but I have a feeling it would improve the readability to split this up.
if no_stratigraphy_or_name:
rv = DerivedNameStratigraphy(name=name, ...)
else:
rv = DerivedNameStratigraphy(name=strat["name"].get("name", name), ...)
if rv.name != "name":
rv.alias.append(name)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea. I cleaned it up with inspiration from your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
Also fixed an annotation error.
c69eb87
to
9292639
Compare
Resolves #564
It now sets its state on initialization and returns a Pydantic model via the prescribed method. Does not do much of the possible clean-ups within the base class.
There is still more work to be within the object data provider base class but this should have the inputs (spec, bbox, etc) and outputs (content) where they need to be.