IPython Notebook 摘要补全 -- 显示文档字符串
我刚刚升级到 IPython 2.0.0,发现按 TAB 键补全的行为似乎变了。(我在用 pyreadline 2.0,听说这可能有影响,具体可以参考这个问题。)
以前,当我在 function_name(
后按 TAB 键时,IPython 会显示这个函数的文档说明。
现在,我看到的只是一个下拉列表,里面有我猜测的所有命名空间中的内容,包括:
- 错误类型
- 目录中其他笔记本的名字
- IPython 的魔法函数
- 我自己定义的其他函数
- 等等。
以前的那种行为非常有帮助——我该怎么才能恢复它呢(除了降级到早期的 IPython 版本)?
2 个回答
1
关于自动补全,你可以在笔记本的任何地方使用这一行代码:
%config Completer.use_jedi = False
使用这一行代码后,你就可以通过按 tab 键来实现自动补全功能。
如果我想要打印文档——比如说,我想打印出 SVC
的文档,这样我就可以添加超参数变量。
from sklearn.svm import SVC
那么,
SVC?
输出结果是
Init signature:
SVC(
*,
C=1.0,
kernel='rbf',
degree=3,
gamma='scale',
coef0=0.0,
shrinking=True,
probability=False,
tol=0.001,
cache_size=200,
class_weight=None,
verbose=False,
max_iter=-1,
decision_function_shape='ovr',
break_ties=False,
random_state=None,
)
Docstring:
C-Support Vector Classification.
The implementation is based on libsvm. The fit time scales at least
quadratically with the number of samples and maybe impractical
beyond tens of thousands of samples. For large datasets
consider using :class:`sklearn.SVM.LinearSVC` or
:class:`sklearn.linear_model.SGDClassifier` instead, possibly after a
:class:`sklearn.kernel_approximation.Nystroem` transformer.
The multiclass support is handled according to a one-vs-one scheme.
For details on the precise mathematical formulation of the provided
kernel functions and how `gamma`, `coef0` and `degree` affect each
other, see the corresponding section in the narrative documentation:
:ref:`svm_kernels`.
...
关于查看文档,你可以按 Shift + Tab 来查看任何类或函数的文档,通常是在 ()
里面。
希望这些能帮到你
27
看来现在是按Shift和Tab键一起使用了。谢谢@Thomas K.