-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
No completions of the functions of SciPy, NumPy, Matplotlib, and PyLab #372
Comments
Doesn't work for me either. Don't know what it is exactly, but it's probably related to the kind of complicated array function, which Jedi basically should understand. |
I'm currently looking into making numpy completions fast. It's working pretty well, I've already got a speedup of >100ms (from 200ms originally). This is pretty cool. However, completions of numpy are mostly bad, because a lot of it are builtin functions. Understanding the return value of
While this could probably be enough to actually understand a lot of the numpy stuff, it creates the question of how many different docstring formats should we understand. @asmeurer While sympy makes the impression to be pure Python, you seem to have a good understanding of the numeric/scientific Python community. What are the conventions in the most popular libraries (Scipy, Numpy, Matplotlib, ...) regarding builtin returns? Are there even conventions and if so, are they helpful in a completion context? |
NumPy has a very standardized docstring format, which is used by many projects. See https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt. I would highly recommend just learning to understand it, because a lot of projects use it. |
It might be worth creating a fake builtin at least for |
Makes me wonder if there shouldn't be some general purpose way to provide helpers as extensions to jedi to hint return types. As it is, jedi's inference can often fail or take a very long time to figure out what type a particular object is as it gets passed through several calls. e.g. import pandas
import numpy
sims = 100
df = pandas.to_csv("data.csv") #returns a DataFrame
gr = df.groupby(['year']) #returns a DataFrameGroupBy object
df0 = gr.agg(numpy.sum)/sims #returns a DataFrame
df0. The type inference on |
The IPython Qt console appear to understand numpy, scipy and matplotlib. Maybe it would be instructive to look into how they did solve the problem. |
It's very easy for IPython to understand it, because you can just do a |
@davidhalter I found some links about tricky temporary solutions in Eclipse. Please refer to them if it can give you some inspiration. I tried it in emacs without any luck, however hope that it would help to you. and http://pydev.org/manual_adv_type_hints.html. But I am sure that this is not a common issue, because I used it very well in Windows Eclipse. The problem came after I changed my pc. |
@llcc What is not a common issue? Type hints work pretty well with Jedi (if you stick to the Jedi manual). |
FYI, you can get numpydoc return type hints with something like: In [32]: numpydoc.docscrape.NumpyDocString(inspect.getdoc(np.interp))._parsed_data['Returns']
Out[32]: [('y', '{float, ndarray}', ['The interpolated values, same shape as `x`.'])] |
@immerrr |
With the latest version (as of today), there are still some problems with detecting numpy. |
any updates on this? |
No. |
@davidhalter Does jedi currently support extracting the return types specified in numpydoc-style docs? @immerrr mentioned a solution at #372 (comment) , and you mentioned that this "is now a part of Jedi", but in https://github.com/davidhalter/jedi/blob/master/jedi/evaluate/docstrings.py (or https://github.com/davidhalter/jedi/blob/dev/jedi/evaluate/docstrings.py) I still don't see return type extraction out of numpydocs (there are only parameter extraction), and in real testing I found that jedi doesn't seem to be tracking the return types (e.g., of matplotlib). Am I missing something? |
@roxin Maybe it's working in the linter branch? |
@davidhalter I didn't seem to find it in the linter branch either. |
Why are you just not running a python shell in the background. I know that sounds ambiguous, because there are many cases which could go wrong. But having instead a complete autocompletion is something I would really like. You could also give the option to activate / deactivate it or something like that. |
Pull request #796 can help with this issue. This doesn't work for numpy.array() or numpy.zeros() but it does for numpy.asarray() Also plt.Figure() works. but the matplotlib docstrings often don't list returns. You can add them yourself though. It's handy for Figure().add_subplot to return Axes for example |
I have a similar problem (but different I think)
doesn't contains average method. Regards |
I cannot reproduce this on Anaconda 4.2
Versions
|
@bcolsen Yes! It seems that the bug has been fixed in newest |
@oracleyue this bug is about this code not completing:
This still doesn't work. Howerver, this is fixed by applying PR: #796 and PR: #818 If anyone is interested this issue is patched for Spider-IDE 3.1 |
Those are some good workarounds, but you would have to wrap all array creation routines in np.ndarray to get completions like
but this is fixed by applying PR: #796 and PR: #818 IPython has it easy...You are constantly executing your code.
|
AFAIK the numpydoc fixes have been applied. You need to install numpydoc to actually have completions. Just sayin'. :) If you still have an issues (I'm sure there are with this numpy beast), please open a new issue, this one is old and a lot of things have been fixed/changed. |
This issue is very similar to this.
I'm currently using Vim with YouCompleteMe. I found that Python's code completion went well except of the follow modules' functions: SciPy, NumPy, Matplotlib, and PyLab.
I traced the YouCompleteMe, finding it just pass the code completion job to Jedi, so then gave a quick try:
Got output: '[]'.
But
went well.
I also found that IPython completes both 'numpy.' and 'a.' well.
There is a test unit for NumPy in the file 'test/completion/thirdparty/pylab_.py' around the line containing 'na.shape', so I think the root cause may be the wrong configuration on my machine. But I cannot find it out from the documents.
I'm using Vim with +python flag and YouCompleteMe plug-in on Ubuntu 13.10. I also installed SciPy by apt-get:
And then upgrade them by pip (without virtualenv)
The text was updated successfully, but these errors were encountered: