diff --git a/API_Reference/API_Reference.py b/API_Reference/API_Reference.py index e4641c6..dac8657 100644 --- a/API_Reference/API_Reference.py +++ b/API_Reference/API_Reference.py @@ -381,6 +381,12 @@ wilson_loop_array = guan.calculate_wilson_loop(hamiltonian_function, k_min=-math # Module 10: read and write +# 将数据存到文件 +guan.dump_data(data, filename, file_format='.txt') + +# 从文件中恢复数据到变量 +data = guan.load_data(filename, file_format='.txt') + # 读取文件中的一维数据(每一行一组x和y) x_array, y_array = guan.read_one_dimensional_data(filename='a', file_format='.txt') diff --git a/Source_Code/PyPI/setup.cfg b/Source_Code/PyPI/setup.cfg index 1b864c3..3d3c5fc 100644 --- a/Source_Code/PyPI/setup.cfg +++ b/Source_Code/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.0.177 +version = 0.0.179 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/Source_Code/PyPI/src/guan.egg-info/PKG-INFO b/Source_Code/PyPI/src/guan.egg-info/PKG-INFO index e761696..13c1d30 100644 --- a/Source_Code/PyPI/src/guan.egg-info/PKG-INFO +++ b/Source_Code/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: guan -Version: 0.0.177 +Version: 0.0.179 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/Source_Code/PyPI/src/guan/__init__.py b/Source_Code/PyPI/src/guan/__init__.py index 94bae9f..3911090 100644 --- a/Source_Code/PyPI/src/guan/__init__.py +++ b/Source_Code/PyPI/src/guan/__init__.py @@ -2,7 +2,7 @@ # With this package, you can calculate band structures, density of states, quantum transport and topological invariant of tight-binding models by invoking the functions you need. Other frequently used functions are also integrated in this package, such as file reading/writing, figure plotting, data processing. -# The current version is guan-0.0.177, updated on September 29, 2023. +# The current version is guan-0.0.179, updated on September 29, 2023. # Installation: pip install --upgrade guan @@ -2229,6 +2229,19 @@ def calculate_wilson_loop(hamiltonian_function, k_min=-math.pi, k_max=math.pi, p # Module 10: read and write +# 将数据存到文件 +def dump_data(data, filename, file_format='.txt'): + import pickle + with open(filename+file_format, 'wb') as f: + pickle.dump(data, f) + +# 从文件中恢复数据到变量 +def load_data(filename, file_format='.txt'): + import pickle + with open(filename+file_format, 'rb') as f: + data = pickle.load(f) + return data + # 读取文件中的一维数据(每一行一组x和y) def read_one_dimensional_data(filename='a', file_format='.txt'): f = open(filename+file_format, 'r')