0.0.163
This commit is contained in:
parent
0157ba9447
commit
4b8d0ff5a6
@ -290,19 +290,19 @@ x_array, y_array, matrix = guan.read_two_dimensional_data(filename='a', file_for
|
|||||||
|
|
||||||
x_array, y_array, matrix = guan.read_two_dimensional_complex_data(filename='a', file_format='.txt')
|
x_array, y_array, matrix = guan.read_two_dimensional_complex_data(filename='a', file_format='.txt')
|
||||||
|
|
||||||
guan.open_file(filename='a', file_format='.txt')
|
f = guan.open_file(filename='a', file_format='.txt')
|
||||||
|
|
||||||
guan.write_one_dimensional_data(x_array, y_array, filename='a', file_format='.txt')
|
guan.write_one_dimensional_data(x_array, y_array, filename='a', file_format='.txt')
|
||||||
|
|
||||||
guan.write_one_dimensional_data_without_opening_file(x_array, y_array, file)
|
guan.write_one_dimensional_data_without_opening_file(x_array, y_array, f)
|
||||||
|
|
||||||
guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', file_format='.txt')
|
guan.write_two_dimensional_data(x_array, y_array, matrix, filename='a', file_format='.txt')
|
||||||
|
|
||||||
guan.write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, file)
|
guan.write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, f)
|
||||||
|
|
||||||
guan.write_two_dimensional_data_without_xy_array(matrix, filename='a', file_format='.txt')
|
guan.write_two_dimensional_data_without_xy_array(matrix, filename='a', file_format='.txt')
|
||||||
|
|
||||||
guan.write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix, file)
|
guan.write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix, f)
|
||||||
|
|
||||||
guan.print_array_with_index(array, show_index=1, index_type=0)
|
guan.print_array_with_index(array, show_index=1, index_type=0)
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[metadata]
|
[metadata]
|
||||||
# replace with your username:
|
# replace with your username:
|
||||||
name = guan
|
name = guan
|
||||||
version = 0.0.162
|
version = 0.0.163
|
||||||
author = guanjihuan
|
author = guanjihuan
|
||||||
author_email = guanjihuan@163.com
|
author_email = guanjihuan@163.com
|
||||||
description = An open source python package
|
description = An open source python package
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
Metadata-Version: 2.1
|
Metadata-Version: 2.1
|
||||||
Name: guan
|
Name: guan
|
||||||
Version: 0.0.162
|
Version: 0.0.163
|
||||||
Summary: An open source python package
|
Summary: An open source python package
|
||||||
Home-page: https://py.guanjihuan.com
|
Home-page: https://py.guanjihuan.com
|
||||||
Author: guanjihuan
|
Author: guanjihuan
|
||||||
|
@ -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.
|
# 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.162, updated on February 20, 2023.
|
# The current version is guan-0.0.163, updated on February 21, 2023.
|
||||||
|
|
||||||
# Installation: pip install --upgrade guan
|
# Installation: pip install --upgrade guan
|
||||||
|
|
||||||
@ -2234,60 +2234,60 @@ def read_two_dimensional_complex_data(filename='a', file_format='.txt'):
|
|||||||
|
|
||||||
def open_file(filename='a', file_format='.txt'):
|
def open_file(filename='a', file_format='.txt'):
|
||||||
try:
|
try:
|
||||||
file = open(filename+file_format, 'a', encoding='UTF-8')
|
f = open(filename+file_format, 'a', encoding='UTF-8')
|
||||||
except:
|
except:
|
||||||
file = open(filename+file_format, 'w', encoding='UTF-8')
|
f = open(filename+file_format, 'w', encoding='UTF-8')
|
||||||
return file
|
return f
|
||||||
|
|
||||||
def write_one_dimensional_data(x_array, y_array, filename='a', file_format='.txt'):
|
def write_one_dimensional_data(x_array, y_array, filename='a', file_format='.txt'):
|
||||||
with open(filename+file_format, 'w') as file:
|
with open(filename+file_format, 'w', encoding='UTF-8') as f:
|
||||||
guan.write_one_dimensional_data_without_opening_file(x_array, y_array, file)
|
guan.write_one_dimensional_data_without_opening_file(x_array, y_array, f)
|
||||||
|
|
||||||
def write_one_dimensional_data_without_opening_file(x_array, y_array, file):
|
def write_one_dimensional_data_without_opening_file(x_array, y_array, f):
|
||||||
x_array = np.array(x_array)
|
x_array = np.array(x_array)
|
||||||
y_array = np.array(y_array)
|
y_array = np.array(y_array)
|
||||||
i0 = 0
|
i0 = 0
|
||||||
for x0 in x_array:
|
for x0 in x_array:
|
||||||
file.write(str(x0)+' ')
|
f.write(str(x0)+' ')
|
||||||
if len(y_array.shape) == 1:
|
if len(y_array.shape) == 1:
|
||||||
file.write(str(y_array[i0])+'\n')
|
f.write(str(y_array[i0])+'\n')
|
||||||
elif len(y_array.shape) == 2:
|
elif len(y_array.shape) == 2:
|
||||||
for j0 in range(y_array.shape[1]):
|
for j0 in range(y_array.shape[1]):
|
||||||
file.write(str(y_array[i0, j0])+' ')
|
f.write(str(y_array[i0, j0])+' ')
|
||||||
file.write('\n')
|
f.write('\n')
|
||||||
i0 += 1
|
i0 += 1
|
||||||
|
|
||||||
def write_two_dimensional_data(x_array, y_array, matrix, filename='a', file_format='.txt'):
|
def write_two_dimensional_data(x_array, y_array, matrix, filename='a', file_format='.txt'):
|
||||||
with open(filename+file_format, 'w') as file:
|
with open(filename+file_format, 'w', encoding='UTF-8') as f:
|
||||||
guan.write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, file)
|
guan.write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, f)
|
||||||
|
|
||||||
def write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, file):
|
def write_two_dimensional_data_without_opening_file(x_array, y_array, matrix, f):
|
||||||
x_array = np.array(x_array)
|
x_array = np.array(x_array)
|
||||||
y_array = np.array(y_array)
|
y_array = np.array(y_array)
|
||||||
matrix = np.array(matrix)
|
matrix = np.array(matrix)
|
||||||
file.write('0 ')
|
f.write('0 ')
|
||||||
for x0 in x_array:
|
for x0 in x_array:
|
||||||
file.write(str(x0)+' ')
|
f.write(str(x0)+' ')
|
||||||
file.write('\n')
|
f.write('\n')
|
||||||
i0 = 0
|
i0 = 0
|
||||||
for y0 in y_array:
|
for y0 in y_array:
|
||||||
file.write(str(y0))
|
f.write(str(y0))
|
||||||
j0 = 0
|
j0 = 0
|
||||||
for x0 in x_array:
|
for x0 in x_array:
|
||||||
file.write(' '+str(matrix[i0, j0])+' ')
|
f.write(' '+str(matrix[i0, j0])+' ')
|
||||||
j0 += 1
|
j0 += 1
|
||||||
file.write('\n')
|
f.write('\n')
|
||||||
i0 += 1
|
i0 += 1
|
||||||
|
|
||||||
def write_two_dimensional_data_without_xy_array(matrix, filename='a', file_format='.txt'):
|
def write_two_dimensional_data_without_xy_array(matrix, filename='a', file_format='.txt'):
|
||||||
with open(filename+file_format, 'w') as file:
|
with open(filename+file_format, 'w', encoding='UTF-8') as f:
|
||||||
guan.write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix, file)
|
guan.write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix, f)
|
||||||
|
|
||||||
def write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix, file):
|
def write_two_dimensional_data_without_xy_array_and_without_opening_file(matrix, f):
|
||||||
for row in matrix:
|
for row in matrix:
|
||||||
for element in row:
|
for element in row:
|
||||||
file.write(str(element)+' ')
|
f.write(str(element)+' ')
|
||||||
file.write('\n')
|
f.write('\n')
|
||||||
|
|
||||||
def print_array_with_index(array, show_index=1, index_type=0):
|
def print_array_with_index(array, show_index=1, index_type=0):
|
||||||
if show_index==0:
|
if show_index==0:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user