Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Orbit properties are not discoverable #435

Closed
Juanlu001 opened this Issue Aug 12, 2018 · 11 comments

Comments

3 participants
@Juanlu001
Copy link
Member

Juanlu001 commented Aug 12, 2018

馃悶 Problem

None of the delegated properties of Orbit appear in the documentation or the autocomplete, including all the classical elements.

馃幆 Goal

Clearly inform the user what are the possible operations with Orbit objects without having them figure out thanks to the notebooks, or investigating what a _BaseState object is.

馃挕 Possible solutions

  • Perhaps we should stop using magic delegation to a property, as suggested in #370.
  • Another option is to load all these properties on class creation to allow Sphinx to detect them while creating the docs

馃搵 Steps to solve the problem

  • Comment below about what you've started working on.
  • Add, commit, push your changes
  • Submit a pull request and add this in comments - Addresses #<put issue number here>
  • Ask for a review in comments section of pull request
  • Celebrate your contribution to this project 馃帀
@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Sep 4, 2018

From #442:

in the 'From classical orbital elements' section it says 'To see a complete list of properties, check out the poliastro.twobody.orbit.Orbit class on the API reference.'

Oops!

@Juanlu001 Juanlu001 added the bug label Sep 4, 2018

@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Sep 5, 2018

We have to fix this but it might be too late for this release. Retargetting this for the next milestone.

@Juanlu001 Juanlu001 added this to the 0.12 milestone Sep 5, 2018

@shreyasbapat

This comment has been minimized.

Copy link
Member

shreyasbapat commented Sep 17, 2018

Same issue with the plotting module

@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Sep 17, 2018

It's true that I'm missing some methods there, but we are not using introspection there so it has to be another issue.

@Juanlu001 Juanlu001 pinned this issue Dec 14, 2018

@shreyasbapat

This comment has been minimized.

Copy link
Member

shreyasbapat commented Dec 22, 2018

Clearly inform the user what are the possible operations with Orbit objects without having them figure out thanks to the notebooks, or investigating what a _BaseState object is.

What does this exactly mean?

Is it like we document the Orbit API somehow? Adding a file in the documentation regarding the Orbit module or some changes with the code are needed?

@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Dec 22, 2018

None of the delegated properties of Orbit appear in the documentation or the autocomplete, including all the classical elements.

Try to do

In [1]: from poliastro.examples import iss

In [2]: iss.<Tab>

There are some properties, but only a few of them.

Also, that's why Sphinx does not know about Orbit.a, Orbit.ecc...

@jorgepiloto

This comment has been minimized.

Copy link
Member

jorgepiloto commented Jan 27, 2019

I thought about:

.. autoclass:: Orbit
   :members:
   :inherited-members:
   :private-members:

However, it does not show anything new after making the html. I have also tried:

.. autoattribute:: Orbit.ecc

But it does not work also, since ecc is not a 'truth' attribute of Orbit. This were some options I found without modifying the _state or orbit files in some way. I will try to investigate more about this.

@Juanlu001 Juanlu001 added the 1 - Ready label Jan 27, 2019

@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Jan 27, 2019

It's not that simple:

# Delegated properties (syntactic sugar)
def __getattr__(self, item):
if hasattr(self.state, item):
def delegated_(self_):
return getattr(self_.state, item)
# Use class docstring to properly translate properties, see
# https://stackoverflow.com/a/38118315/554319
delegated_.__doc__ = getattr(self.state.__class__, item).__doc__
# Transform to a property
delegated = property(delegated_)
else:
raise AttributeError(
"'{}' object has no attribute '{}'".format(self.__class__, item)
)
# Bind the attribute
setattr(self.__class__, item, delegated)
# Return the newly bound attribute
return getattr(self, item)

Properties are automatically generated to avoid making the users type orbit.state.a, orbit.state.ecc... But it's clearly a bad design that causes a lot of problems.

@shreyasbapat

This comment has been minimized.

Copy link
Member

shreyasbapat commented Jan 27, 2019

Do you propose to change the design?

@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Jan 28, 2019

Details are in #370

@Juanlu001

This comment has been minimized.

Copy link
Member Author

Juanlu001 commented Jan 28, 2019

There might be a way to fix this issue without changing the design though, but I am not aware of it.

Juanlu001 added a commit to Juanlu001/poliastro that referenced this issue Jan 29, 2019

Juanlu001 added a commit to Juanlu001/poliastro that referenced this issue Jan 29, 2019

@wafflebot wafflebot bot removed the 2 - In Progress label Jan 29, 2019

@Juanlu001 Juanlu001 unpinned this issue Jan 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.