-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_venv.py
executable file
·95 lines (65 loc) · 1.94 KB
/
test_venv.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python
print("\nENVIRONMENT SETUP TEST\n")
#-------------------------------------------------
# MySQL
print("Connecting to the database and exercising MySQL...")
import pymysql as db
import configparser
try:
config = configparser.ConfigParser()
config.read('./config.txt')
conn = db.connect(
host=config.get('database','host'),
user=config.get('database','user'),
password=config.get('database','password'),
db=config.get('database','db'),)
c = conn.cursor()
c.execute("SELECT VERSION()")
data = c.fetchone()
print("Database version : {}".format(data))
conn.close()
except:
print("Couldn't connect to DB")
print("\n\n")
#-------------------------------------------------
# Pandas
print("Exercising Pandas...")
import pandas as pd
df = pd.DataFrame.from_dict({'name':'bob', 'age':56}, orient='index')
print(df)
print("\n\n")
#-------------------------------------------------
# NumPy and SciPy
print("Exercising NumPy and SciPy")
import numpy as np
from scipy import special, optimize
f = lambda x: -special.jv(3, x)
sol = optimize.minimize(f, 1.0)
x = np.linspace(0, 10, 5000)
print(x)
print("\n\n")
#-------------------------------------------------
# Matplotlib
print("Exercising Matplotlib...")
import matplotlib
matplotlib.use('Agg') # use Agg backend (*before* pyplot) to fix issues when running in virtual environment
import matplotlib.pyplot as plt
p = plt.plot(x, special.jv(3, x), '-', sol.x, -sol.fun, 'o')
print(p)
# plt.show()
print("\n\n")
#-------------------------------------------------
# scikit-learn
print("Exercising scikit-learn...")
from sklearn import datasets
iris = datasets.load_iris()
print(iris.target_names)
print("\n\n")
#-------------------------------------------------
# TensorFlow
print("Exercising TensorFlow")
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
print("\n\n")