update
This commit is contained in:
parent
ca1bb0b8df
commit
7a049ccc5e
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/4536
|
||||||
|
"""
|
||||||
|
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
@ -14,12 +19,12 @@ def main(parameter_array, task_index):
|
|||||||
guan.write_one_dimensional_data(parameter_array, result_array, filename='task_index='+str(task_index))
|
guan.write_one_dimensional_data(parameter_array, result_array, filename='task_index='+str(task_index))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
cpus = 4
|
task_num = 4
|
||||||
parameter_array_all = np.arange(0, 17, 1)
|
parameter_array_all = np.arange(0, 17, 1)
|
||||||
start_time = time.perf_counter()
|
start_time = time.perf_counter()
|
||||||
process_array = []
|
process_array = []
|
||||||
for task_index in range(cpus):
|
for task_index in range(task_num):
|
||||||
parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, cpus, task_index)
|
parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, task_num, task_index)
|
||||||
process_array.append(Process(target=main, args=(parameter_array, task_index)))
|
process_array.append(Process(target=main, args=(parameter_array, task_index)))
|
||||||
for process in process_array: # 运行子进程
|
for process in process_array: # 运行子进程
|
||||||
process.start()
|
process.start()
|
||||||
@ -28,7 +33,7 @@ if __name__ == '__main__':
|
|||||||
end_time = time.perf_counter()
|
end_time = time.perf_counter()
|
||||||
print('运行时间=', (end_time-start_time), '\n')
|
print('运行时间=', (end_time-start_time), '\n')
|
||||||
f = open('result.txt', 'w')
|
f = open('result.txt', 'w')
|
||||||
for task_index in range(cpus):
|
for task_index in range(task_num):
|
||||||
with open('task_index='+str(task_index)+'.txt', 'r') as f0:
|
with open('task_index='+str(task_index)+'.txt', 'r') as f0:
|
||||||
text = f0.read()
|
text = f0.read()
|
||||||
f.write(text)
|
f.write(text)
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/4536
|
||||||
|
"""
|
||||||
|
|
||||||
from multiprocessing import Process
|
from multiprocessing import Process
|
||||||
import os
|
import os
|
||||||
import time
|
import time
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/4536
|
||||||
|
"""
|
||||||
|
|
||||||
from multiprocessing import Process, Value
|
from multiprocessing import Process, Value
|
||||||
|
|
||||||
def run_proc(name, a, num): # 要执行的代码
|
def run_proc(name, a, num): # 要执行的代码
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
# 数组分割示例
|
# 数组分割示例
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import guan
|
import guan
|
||||||
cpus = 4
|
task_num = 4
|
||||||
parameter_array_all = np.arange(0, 17, 1)
|
parameter_array_all = np.arange(0, 17, 1)
|
||||||
for task_index in range(cpus):
|
for task_index in range(task_num):
|
||||||
parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, cpus, task_index)
|
parameter_array = guan.preprocess_for_parallel_calculations(parameter_array_all, task_num, task_index)
|
||||||
print(parameter_array)
|
print(parameter_array)
|
||||||
print()
|
print()
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/38912
|
||||||
|
"""
|
||||||
|
|
||||||
import guan
|
import guan
|
||||||
|
|
||||||
stock_symbols_60, stock_symbols_00, stock_symbols_30, stock_symbols_68, \
|
stock_symbols_60, stock_symbols_00, stock_symbols_30, stock_symbols_68, \
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/38912
|
||||||
|
"""
|
||||||
|
|
||||||
import guan
|
import guan
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import datetime
|
import datetime
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/38912
|
||||||
|
"""
|
||||||
|
|
||||||
import guan
|
import guan
|
||||||
stock_symbols_60, stock_symbols_00, stock_symbols_30, stock_symbols_68, \
|
stock_symbols_60, stock_symbols_00, stock_symbols_30, stock_symbols_68, \
|
||||||
stock_symbols_8_4,stock_symbols_others = guan.stock_symbols_classification()
|
stock_symbols_8_4,stock_symbols_others = guan.stock_symbols_classification()
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/38912
|
||||||
|
"""
|
||||||
|
|
||||||
import guan
|
import guan
|
||||||
file_list_60 = guan.get_all_filenames_in_directory(directory='./2018_01_01_to_2024_03_07/stock_data_60', \
|
file_list_60 = guan.get_all_filenames_in_directory(directory='./2018_01_01_to_2024_03_07/stock_data_60', \
|
||||||
file_format=None, show_root_path=0, sort=1, include_subdirectory=1)
|
file_format=None, show_root_path=0, sort=1, include_subdirectory=1)
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/39020
|
||||||
|
"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.decomposition import PCA
|
from sklearn.decomposition import PCA
|
||||||
|
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
"""
|
||||||
|
This code is supported by the website: https://www.guanjihuan.com
|
||||||
|
The newest version of this code is on the web page: https://www.guanjihuan.com/archives/39020
|
||||||
|
"""
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from sklearn.decomposition import PCA
|
from sklearn.decomposition import PCA
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user