This commit is contained in:
guanjihuan 2023-09-29 09:10:17 +08:00
parent 76ab237717
commit b372baebfc
4 changed files with 22 additions and 3 deletions

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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')