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
astrojuanlu opened this issue Aug 12, 2018 · 11 comments 路 Fixed by #552
Closed

Orbit properties are not discoverable #435

astrojuanlu opened this issue Aug 12, 2018 · 11 comments 路 Fixed by #552

Comments

@astrojuanlu
Copy link
Member

@astrojuanlu astrojuanlu 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 馃帀
@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu 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!

@astrojuanlu astrojuanlu added the bug label Sep 4, 2018
@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu commented Sep 5, 2018

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

@astrojuanlu astrojuanlu added this to the 0.12 milestone Sep 5, 2018
@shreyasbapat
Copy link
Member

@shreyasbapat shreyasbapat commented Sep 17, 2018

Same issue with the plotting module

@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu 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.

@shreyasbapat
Copy link
Member

@shreyasbapat 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?

@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu 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
Copy link
Member

@jorgepiloto 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.

@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu 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
Copy link
Member

@shreyasbapat shreyasbapat commented Jan 27, 2019

Do you propose to change the design?

@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu commented Jan 28, 2019

Details are in #370

@astrojuanlu
Copy link
Member Author

@astrojuanlu astrojuanlu 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.

@ghost ghost removed the 2 - In Progress label Jan 29, 2019
@astrojuanlu astrojuanlu unpinned this issue Jan 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants