Standard import hints
- Dominant language
- Python
- Stars
- 16.8k
- Forks
- 4.5k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 6
Description
The following are standard import conventions for scientific Python packages:
```
import numpy as np
import scipy as sp
import matplotlib as mpl
import matplotlib.pyplot as plt
import pandas as pd
import networkx as nx
```
Recently in https://github.com/scipy/scipy/issues/13049 the question arose whether to assume these import conventions in docstring examples made sense in a cut and paste scenario. Even if we make everything "self-contained" in the docstrings, it is still reasonable to think that there will be little code snippets online that will potentially assume these conventions.
Would it be reasonable to add a suggestion for these (and maybe a few others) so that you got a `Hint:` something like this:
```
(nx) [jarrod@x15 ~]$ ipython
Python 3.9.9 (main, Nov 19 2021, 00:00:00)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.4.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: sequence = nx.random_powerlaw_tree_sequence(100, tries=5000)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Input In [1], in ()
----> 1 sequence = nx.random_powerlaw_tree_sequence(100, tries=5000)
NameError: name 'nx' is not defined
Hint: If you are using NetworkX, try `import networkx as nx` first
In [2]:
```
Contributor guide
Assessment
This issue has not been assessed yet.