awacke1 commited on
Commit
317e332
·
1 Parent(s): 093a98b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +128 -0
app.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+
4
+ st.sidebar.title("NumPy Demo")
5
+
6
+ # Array creation routines
7
+ st.sidebar.header("Array creation routines")
8
+ st.sidebar.write("np.zeros(5):", np.zeros(5))
9
+ st.sidebar.write("np.ones((2, 3)):", np.ones((2, 3)))
10
+ st.sidebar.write("np.arange(0, 10, 2):", np.arange(0, 10, 2))
11
+ st.sidebar.write("np.linspace(0, 1, 5):", np.linspace(0, 1, 5))
12
+ st.sidebar.write("np.eye(3):", np.eye(3))
13
+
14
+ # Array manipulation routines
15
+ st.sidebar.header("Array manipulation routines")
16
+ arr = np.array([[1, 2], [3, 4]])
17
+ st.sidebar.write("arr.flatten():", arr.flatten())
18
+ st.sidebar.write("np.transpose(arr):", np.transpose(arr))
19
+ st.sidebar.write("np.rot90(arr):", np.rot90(arr))
20
+
21
+ # Binary operations
22
+ st.sidebar.header("Binary operations")
23
+ x = np.array([1, 2, 3])
24
+ y = np.array([4, 5, 6])
25
+ st.sidebar.write("np.add(x, y):", np.add(x, y))
26
+ st.sidebar.write("np.subtract(x, y):", np.subtract(x, y))
27
+ st.sidebar.write("np.multiply(x, y):", np.multiply(x, y))
28
+
29
+ # String operations
30
+ st.sidebar.header("String operations")
31
+ st.sidebar.write("np.char.add(['hello', 'world'], ['!', '?']):", np.char.add(['hello', 'world'], ['!', '?']))
32
+ st.sidebar.write("np.char.upper('numpy'):", np.char.upper('numpy'))
33
+ st.sidebar.write("np.char.replace('numpy', 'py', 'ython'):", np.char.replace('numpy', 'py', 'ython'))
34
+
35
+ # C-Types Foreign Function Interface (numpy.ctypeslib)
36
+ st.sidebar.header("C-Types Foreign Function Interface (numpy.ctypeslib)")
37
+ # Omitted for simplicity
38
+
39
+ # Datetime Support Functions
40
+ st.sidebar.header("Datetime Support Functions")
41
+ st.sidebar.write("np.datetime64('2023-02-21'):", np.datetime64('2023-02-21'))
42
+ st.sidebar.write("np.datetime64('2023-02-21 12:00:00'):", np.datetime64('2023-02-21 12:00:00'))
43
+
44
+ # Data type routines
45
+ st.sidebar.header("Data type routines")
46
+ st.sidebar.write("np.dtype('float64'):", np.dtype('float64'))
47
+ st.sidebar.write("np.issubdtype(np.float64, np.number):", np.issubdtype(np.float64, np.number))
48
+
49
+ # Optionally SciPy-accelerated routines (numpy.dual)
50
+ st.sidebar.header("Optionally SciPy-accelerated routines (numpy.dual)")
51
+ # Omitted for simplicity
52
+
53
+ # Mathematical functions with automatic domain
54
+ st.sidebar.header("Mathematical functions with automatic domain")
55
+ st.sidebar.write("np.sqrt(-1):", np.sqrt(-1))
56
+ st.sidebar.write("np.log(0):", np.log(0))
57
+
58
+ # Functional programming
59
+ st.sidebar.header("Functional programming")
60
+ st.sidebar.write("np.vectorize(np.square)([1, 2, 3]):", np.vectorize(np.square)([1, 2, 3]))
61
+
62
+ # NumPy-specific help functions
63
+ st.sidebar.header("NumPy-specific help functions")
64
+ st.sidebar.write("np.info(np.add):", np.info(np.add))
65
+
66
+ # Linear algebra (numpy.linalg)
67
+ st.sidebar.header("Linear algebra (numpy.linalg)")
68
+ mat = np.array([[1, 2], [3, 4]])
69
+ st.sidebar.write("np.linalg.inv(mat):", np.linalg.inv(mat))
70
+ st.sidebar.write("np.linalg.eig(mat):", np.linalg.eig(mat))
71
+
72
+ # Logic functions
73
+ st.sidebar.header("Logic functions")
74
+ x = np.array([1, 2, 3])
75
+ y = np.array([2, 2, 2])
76
+ st.sidebar.write("np.logical_and(x > 1, y < 3):", np.logical_and(x > 1, y < 3))
77
+ st.sidebar.write("np.logical_or(x > 2, y < 2):", np.logical_or(x > 2, y < 2))
78
+ st.sidebar.write("np.logical_not(x > 2):", np.logical_not(x > 2))
79
+
80
+ # Mathematical functions
81
+ st.sidebar.header("Mathematical functions")
82
+ x = np.array([0, 1, 2])
83
+ st.sidebar.write("np.exp(x):", np.exp(x))
84
+ st.sidebar.write("np.sin(x):", np.sin(x))
85
+ st.sidebar.write("np.arctan(x):", np.arctan(x))
86
+
87
+ # Matrix library (numpy.matlib)
88
+ st.sidebar.header("Matrix library (numpy.matlib)")
89
+ st.sidebar.write("np.matlib.eye(2, 3):", np.matlib.eye(2, 3))
90
+ st.sidebar.write("np.matlib.zeros((2, 3)):", np.matlib.zeros((2, 3)))
91
+
92
+ # Miscellaneous routines
93
+ st.sidebar.header("Miscellaneous routines")
94
+ st.sidebar.write("np.percentile([1, 2, 3, 4, 5], 50):", np.percentile([1, 2, 3, 4, 5], 50))
95
+ st.sidebar.write("np.histogram([1, 2, 1], bins=[0, 1, 2, 3]):", np.histogram([1, 2, 1], bins=[0, 1, 2, 3]))
96
+
97
+ # Polynomials
98
+ st.sidebar.header("Polynomials")
99
+ st.sidebar.write("np.poly1d([1, 2, 3])(4):", np.poly1d([1, 2, 3])(4))
100
+
101
+ # Random sampling (numpy.random)
102
+ st.sidebar.header("Random sampling (numpy.random)")
103
+ st.sidebar.write("np.random.rand(3, 2):", np.random.rand(3, 2))
104
+ st.sidebar.write("np.random.normal(size=(2, 2)):", np.random.normal(size=(2, 2)))
105
+
106
+ #Set routines
107
+ st.sidebar.header("Set routines")
108
+ x = np.array([1, 2, 3, 4])
109
+ y = np.array([3, 4, 5, 6])
110
+ st.sidebar.write("np.intersect1d(x, y):", np.intersect1d(x, y))
111
+ st.sidebar.write("np.union1d(x, y):", np.union1d(x, y))
112
+ st.sidebar.write("np.setdiff1d(x, y):", np.setdiff1d(x, y))
113
+
114
+ #Sorting, searching, and counting
115
+ st.sidebar.header("Sorting, searching, and counting")
116
+ x = np.array([3, 1, 4, 1, 5, 9, 2, 6, 5, 3])
117
+ st.sidebar.write("np.sort(x):", np.sort(x))
118
+ st.sidebar.write("np.argsort(x):", np.argsort(x))
119
+ st.sidebar.write("np.where(x == 5):", np.where(x == 5))
120
+ st.sidebar.write("np.count_nonzero(x > 3):", np.count_nonzero(x > 3))
121
+
122
+ # Statistics
123
+ st.sidebar.header("Statistics")
124
+ x = np.array([3, 1, 4, 1, 5, 9, 2, 6, 5, 3])
125
+ st.sidebar.write("np.mean(x):", np.mean(x))
126
+ st.sidebar.write("np.std(x):", np.std(x))
127
+ st.sidebar.write("np.median(x):", np.median(x))
128
+