You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After talking this over with @mmcky and @thomassargent30 I have a quick suggestion / question.
Say we run
results = ddp.solve(method='policy_iteration')
Now I want to interact with results in IPython. Let's say I don't remember exactly what's returned, which is probably the most common scenario. Ideally I would be able to type results.[tab key] and see all its attributes, or at least the ones I'm interested in. At the moment I just get the attributes of a dict.
I think it's worth improving this because it saves people having to look up the docs when they want to interact with the results, particularly since results contains quiet a few objects of interest.
To me, first best would be that results.[tab key] shows exactly the objects we are trying to return to the user, as they are now specified, and little else (i.e., no miscellaneous methods or attributes that clutter the pop up menu).
How about returning a namedtuple populated with these objects? That would pretty much do the job, and namedtuples are in the standard library...
The text was updated successfully, but these errors were encountered:
I have never used namedtuple and am happy to learn about it. But before that, what about this solution from Stack Overflow?
def__dir__(self):
returnself.keys()
With the latest version of IPython, results.[tab key] will show only the keys (i.e., attributes) of results. (This seems to be a feature recently added; in older versions of IPython, this will show the methods or attributes of dict as well. See ipython/ipython#8330.)
@oyamad
After talking this over with @mmcky and @thomassargent30 I have a quick suggestion / question.
Say we run
results = ddp.solve(method='policy_iteration')
Now I want to interact with
results
in IPython. Let's say I don't remember exactly what's returned, which is probably the most common scenario. Ideally I would be able to typeresults.[tab key]
and see all its attributes, or at least the ones I'm interested in. At the moment I just get the attributes of a dict.I think it's worth improving this because it saves people having to look up the docs when they want to interact with the results, particularly since
results
contains quiet a few objects of interest.To me, first best would be that
results.[tab key]
shows exactly the objects we are trying to return to the user, as they are now specified, and little else (i.e., no miscellaneous methods or attributes that clutter the pop up menu).How about returning a namedtuple populated with these objects? That would pretty much do the job, and namedtuples are in the standard library...
The text was updated successfully, but these errors were encountered: