jk46820
jk46820

Reputation: 47

ST3 + Anaconda Python autocomplete useless suggestions

I am trying to configure ST3 as IDE for my Python development.

Here is a snippet of code:

from __future__ import division
from sklearn import datasets
import numpy as np
def main():
    ds = datasets.load_boston()
    x = ds.data
    y = ds.target
    x.ravel()
if __name__ == '__main__':
    main()

Here are my Preferences.sublime-settings settings:

{
"color_scheme": "Packages/Theme - Flatland/Flatland Dark.tmTheme",
"theme": "Flatland Dark.sublime-theme",
"flatland_sidebar_tree_xsmall": false,
"flatland_square_tabs": true,

"auto_complete_delay": 10,
"auto_complete_triggers":
[
    {
        "characters": ".",
        "selector": "source.python - string - comment - constant.numeric"
    }
],

"font_size": 12,
"tab_size": 4,
"translate_tabs_to_spaces": true,

"caret_extra_bottom": 1,
"caret_extra_top": 1,
"caret_extra_width": 1.2,
}

Here are my Anaconda.sublime-settings

{
"anaconda_linter_mark_style": "none",
"anaconda_linter_underlines": false,
"suppress_word_completions": true,
"suppress_explicit_completions": true,
"enable_signatures_tooltip": true,
"merge_signatures_and_doc": true,
"pep8_ignore":
[
    "E305",
    "E309",
    "E501",
    "E112",
    "W291"
]
}

Here is list of all my installed packages:

My issues are listed below:

1.) If I type ds. autocomplete does not suggest data or target, but they should be valid suggestions.

2.) If I type ds. autocomplete suggests suggestions like: from, if, def etc... I believe autocomplete scans through whole text file and adds suggestions from strings in it. Is there a way to disable that and make it suggest only relevant (functions, methods and member variables) suggestions?

3.) x is np.array type which has method ravel(). Once again, this method is not suggested. This is really not something I would expect from autocompletion.

Any help is much appreciated! Kind regards

Upvotes: 0

Views: 638

Answers (2)

jk46820
jk46820

Reputation: 47

I would just like to add that I found a workaround which is pretty ugly, but might be of some use for someone else.

For snippet of code:

from __future__ import division
from sklearn import datasets
import numpy as np
def main():
    ds = datasets.load_boston()
    x = ds.data
    y = ds.target
    assert isinstance(x, np.ndarray)
    x.ravel()         # Autocomplete for x now works.

if __name__ == '__main__':
    main()

Autocomplete for numpy works after assert statement.

Seems like Jedi needs a little hint.

Upvotes: 0

DamnWidget
DamnWidget

Reputation: 1457

There are known problems in Jedi (the library that anaconda uses to offer autocompletion) to complete NumPy and other scientific libraries. For example https://github.com/davidhalter/jedi/issues/372

Complete list of non resolved issues about NumPy (probably some of them are duplicates): https://github.com/davidhalter/jedi/search?q=numpy&state=open&type=Issues&utf8=%E2%9C%93

That is why you don't get completions for the NumPy arrays, to resume, currently anaconda can not offer you auto completion for NumPy because Jedi can not offer auto completion for it.

Upvotes: 1

Related Questions