-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_notebook.py
62 lines (51 loc) · 1.68 KB
/
init_notebook.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import numpy as np
import pandas as pd
import statsmodels.formula.api as smf
import pymc as pm
import xarray as xr
import arviz as az
import utils as utils
import seaborn as sns
from scipy import stats as stats
from matplotlib import pyplot as plt
# ---
__all__ = ['pd', 'np', 'smf', 'pm', 'xr', 'az', 'utils', 'sns', 'stats', 'plt']
# Print imports / aliases
with open(__file__) as f:
lines = f.readlines()
from colorama import Fore
def print_import(import_line):
if len(import_line.strip()) > 1:
parts = [p for p in import_line.split(" ") if p]
if parts[0] == 'import':
module = parts[1]
alias = parts[3]
msg = Fore.GREEN + 'import' \
+ Fore.BLUE + f" {module} " \
+ Fore.GREEN + "as" \
+ Fore.BLUE + f" {alias}"
elif parts[0] == 'from':
module = parts[1]
submodule = parts[3]
alias = parts[5]
msg = Fore.GREEN + 'from' \
+ Fore.BLUE + f" {module} "\
+ Fore.GREEN + 'import' \
+ Fore.BLUE + f" {submodule} " \
+ Fore.GREEN + "as" \
+ Fore.BLUE + f" {alias}"
print(msg)
print(Fore.RED + f"Module aliases imported by init_notebook.py:\n{'-'* 44}")
for l in lines:
if "# ---" in l:
break
print_import(l)
from watermark import watermark # noqa: E402
print(Fore.RED + f"Watermark:\n{'-'* 10}")
print(Fore.BLUE + watermark())
print(Fore.BLUE + watermark(iversions=True, globals_=globals()))
import warnings # noqa: E402
warnings.filterwarnings("ignore")
from matplotlib import style # noqa: E402
STYLE = "PlottingStyle.mplstyle"
style.use(STYLE)