Erster Schwung für Teil 22
This commit is contained in:
4
teil22/.gitignore
vendored
Normal file
4
teil22/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# created by virtualenv automatically
|
||||
__pycache__
|
||||
bin
|
||||
lib
|
18
teil22/StressFile.py
Normal file
18
teil22/StressFile.py
Normal file
@@ -0,0 +1,18 @@
|
||||
import io
|
||||
import numpy as np
|
||||
|
||||
class StressFile:
|
||||
def readOutFile(self,filename):
|
||||
result = {
|
||||
'frequency': [],
|
||||
'temperatures': []
|
||||
}
|
||||
with open(filename,'r') as f:
|
||||
content = f.readlines()
|
||||
print(f'conent= {content}')
|
||||
|
||||
|
||||
sf = StressFile()
|
||||
|
||||
sf.readOutFile('./kodos.out')
|
||||
|
42
teil22/calc_array.py
Normal file
42
teil22/calc_array.py
Normal file
@@ -0,0 +1,42 @@
|
||||
import numpy as np
|
||||
|
||||
# Array initialisieren
|
||||
org = np.array([1,2,3,4,5,6])
|
||||
|
||||
|
||||
# Kopiert das int64 Array in ein float64 Array
|
||||
def copy_to_float64(source):
|
||||
liste = []
|
||||
|
||||
for i in range(source.shape[1]):
|
||||
liste.append(float(source[i]))
|
||||
|
||||
return np.array(liste,dtype=float64)
|
||||
|
||||
|
||||
# Ein paar Kopien anlegen
|
||||
copy_sum = org.copy()
|
||||
copy_mult = org.copy()
|
||||
copy_diff = org.copy()
|
||||
copy_div = org.astype(np.float64).copy()
|
||||
|
||||
# Zu allen Elementen 2 dazuzählen
|
||||
copy_sum += 2
|
||||
|
||||
print(f'copy_sum={copy_sum}')
|
||||
|
||||
# Alle Elemente mit 2 multiplizieren
|
||||
copy_mult *= 2
|
||||
|
||||
print(f'copy_mult={copy_mult}')
|
||||
|
||||
|
||||
# Von allen Elementen 1 abziehen
|
||||
copy_diff -= 1
|
||||
|
||||
print(f'copy_diff={copy_diff}')
|
||||
|
||||
copy_div /=2
|
||||
|
||||
print(f'copy_div={copy_div}')
|
||||
|
20
teil22/copyarray.py
Normal file
20
teil22/copyarray.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import numpy as np
|
||||
|
||||
org = np.array([1,2,3,4,5,6])
|
||||
|
||||
copy = org
|
||||
|
||||
print(f'org= {org}')
|
||||
print(f'copy={copy}')
|
||||
|
||||
copy[2]= 7
|
||||
|
||||
print(f'org= {org}')
|
||||
print(f'copy={copy}')
|
||||
|
||||
copy2 = org.copy()
|
||||
|
||||
copy2[2]= 3
|
||||
|
||||
print(f'org= {org}')
|
||||
print(f'copy2={copy2}')
|
9
teil22/reshape.py
Normal file
9
teil22/reshape.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import numpy as np
|
||||
|
||||
a = np.array([1,2,3,4,5,6,7,8,9,10])
|
||||
|
||||
print(f'orignal {a}')
|
||||
|
||||
reshaped = a.reshape(2,5)
|
||||
|
||||
print(f'reshaped {reshaped}')
|
7
teil22/rndm.py
Normal file
7
teil22/rndm.py
Normal file
@@ -0,0 +1,7 @@
|
||||
import numpy as np
|
||||
|
||||
#Erzeuge 1 Mio Zufallszahlen
|
||||
random_np = np.random(100000)
|
||||
|
||||
random_list = list(random_np)
|
||||
|
6
teil22/shape.py
Normal file
6
teil22/shape.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import numpy as np
|
||||
|
||||
twodim_array = np.array([[1,2,3,4,5],[1,4,9,16,25]])
|
||||
|
||||
print(f'shape is {twodim_array.shape}')
|
||||
|
9
teil22/simplearray.py
Normal file
9
teil22/simplearray.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
simple_array = np.array([1,2,3,4,5,6])
|
||||
|
||||
print(f'simple_array={simple_array}')
|
||||
print(f'ndim={simple_array.ndim}')
|
||||
print(f'dtype={simple_array.dtype}')
|
||||
print(f'shape is {simple_array.shape}')
|
9
teil22/twodimarray.py
Normal file
9
teil22/twodimarray.py
Normal file
@@ -0,0 +1,9 @@
|
||||
import numpy as np
|
||||
|
||||
twodim_array = np.array([[1,2,3,4,5],[1,4,9,16,25]],dtype='int32')
|
||||
|
||||
print(f'twodim_array={twodim_array}')
|
||||
print(f'ndim={twodim_array.ndim}')
|
||||
print(f'dtype={twodim_array.dtype}')
|
||||
print(f'shape is {twodim_array.shape}')
|
||||
|
Reference in New Issue
Block a user