-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3feef38
commit f95217d
Showing
1 changed file
with
16 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,18 @@ | ||
#from importlib import import_module | ||
# | ||
## module name: Optional[what to rename it] | ||
#packages = { | ||
# "matplotlib": None, | ||
# "matplotlib.pyplot": "plt", | ||
# "numpy": "np", | ||
# "pandas": "pd", | ||
# "scipy": "sp", | ||
# "sympy": "sym", | ||
#} | ||
# | ||
# print("Loading:", end="") | ||
#for name, rename in packages.items(): | ||
# if not rename: | ||
# rename = name | ||
# rename = import_module(package) | ||
# print(f" {name} -> {rename},", end="") | ||
from importlib import import_module | ||
|
||
import matplotlib | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
packages: dict[str, str | None] = { | ||
"matplotlib": None, | ||
"matplotlib.pyplot": "plt", | ||
"numpy": "np", | ||
"pandas": "pd", | ||
"scipy": "sp", | ||
"sympy": "sym", | ||
} | ||
|
||
try: | ||
pass | ||
import pandas as pd | ||
except NameError: | ||
pass | ||
try: | ||
pass | ||
import scipy as sp | ||
except NameError: | ||
pass | ||
|
||
try: | ||
import sympy as sym | ||
sympy.init_printing() | ||
except NameError: | ||
pass | ||
|
||
# Setup | ||
for name, rename in packages.items(): | ||
mod = import_module(name) | ||
globals()[rename or name] = mod | ||
if rename: | ||
print(f"{name} -> {rename}") | ||
else: | ||
print(f"{name}") |