From 9660bd6fc63cacc9ebc6348a01898e79bd0ef9e5 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Fri, 28 Feb 2025 02:38:46 +0800 Subject: [PATCH] 0.1.155 --- PyPI/setup.cfg | 2 +- PyPI/src/guan.egg-info/PKG-INFO | 2 +- PyPI/src/guan.egg-info/SOURCES.txt | 2 ++ PyPI/src/guan/__init__.py | 2 ++ PyPI/src/guan/custom_classes.py | 11 +++++++ PyPI/src/guan/figure_plotting.py | 32 +++++++++++++++++++ ...nctions_using_objects_of_custom_classes.py | 21 ++++++++++++ README.md | 4 ++- 8 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 PyPI/src/guan/custom_classes.py create mode 100644 PyPI/src/guan/functions_using_objects_of_custom_classes.py diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 3ad5bae..db1094b 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.1.154 +version = 0.1.155 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index 62cd361..0a284f2 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.2 Name: guan -Version: 0.1.154 +Version: 0.1.155 Summary: An open source python package Home-page: https://py.guanjihuan.com Author: guanjihuan diff --git a/PyPI/src/guan.egg-info/SOURCES.txt b/PyPI/src/guan.egg-info/SOURCES.txt index b3b31f3..4c42c8f 100644 --- a/PyPI/src/guan.egg-info/SOURCES.txt +++ b/PyPI/src/guan.egg-info/SOURCES.txt @@ -8,12 +8,14 @@ src/guan/Hamiltonian_of_examples.py src/guan/__init__.py src/guan/band_structures_and_wave_functions.py src/guan/basic_functions.py +src/guan/custom_classes.py src/guan/data_processing.py src/guan/decorators.py src/guan/density_of_states.py src/guan/deprecated.py src/guan/figure_plotting.py src/guan/file_reading_and_writing.py +src/guan/functions_using_objects_of_custom_classes.py src/guan/machine_learning.py src/guan/quantum_transport.py src/guan/topological_invariant.py diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index 25ded88..7d83bde 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -13,5 +13,7 @@ from .file_reading_and_writing import * from .figure_plotting import * from .data_processing import * from .decorators import * +from .custom_classes import * +from .functions_using_objects_of_custom_classes import * from .deprecated import * statistics_of_guan_package() \ No newline at end of file diff --git a/PyPI/src/guan/custom_classes.py b/PyPI/src/guan/custom_classes.py new file mode 100644 index 0000000..f12237a --- /dev/null +++ b/PyPI/src/guan/custom_classes.py @@ -0,0 +1,11 @@ +# Module: custom_classes + +# 原子类 +class Atom: + def __init__(self, name='atom', index=0, x=0, y=0, z=0, energy=0): + self.name = name + self.index = index + self.x = x + self.y = y + self.z = z + self.energy = energy \ No newline at end of file diff --git a/PyPI/src/guan/figure_plotting.py b/PyPI/src/guan/figure_plotting.py index 4fe5b89..c0ed853 100644 --- a/PyPI/src/guan/figure_plotting.py +++ b/PyPI/src/guan/figure_plotting.py @@ -12,6 +12,38 @@ def import_plt_and_start_fig_ax(adjust_bottom=0.2, adjust_left=0.2, labelsize=20 [label.set_fontname('Times New Roman') for label in labels] return plt, fig, ax +# 导入plt, fig, ax(不显示坐标) +def import_plt_and_start_fig_ax_without_axis(): + import matplotlib.pyplot as plt + fig, ax = plt.subplots() + plt.subplots_adjust(left=0, bottom=0, right=1, top=1) + plt.axis('off') + return plt, fig, ax + +# 保存图片为所有常见的格式 +def savefig_with_all_formats(plt, filename, more_dpi=1, tiff=0): + plt.savefig(filename+'.eps') + plt.savefig(filename+'.svg') + plt.savefig(filename+'.pdf') + plt.savefig(filename+'.jpg') + plt.savefig(filename+'.png') + if tiff: + plt.savefig(filename+'.tiff') + if more_dpi: + try: + plt.savefig(filename+'_dpi=300.jpg', dpi=300) + plt.savefig(filename+'_dpi=600.jpg', dpi=600) + plt.savefig(filename+'_dpi=1000.jpg', dpi=1000) + plt.savefig(filename+'_dpi=300.png', dpi=300) + plt.savefig(filename+'_dpi=600.png', dpi=600) + plt.savefig(filename+'_dpi=1000.png', dpi=1000) + if tiff: + plt.savefig(filename+'_dpi=300.tiff', dpi=300) + plt.savefig(filename+'_dpi=600.tiff', dpi=600) + plt.savefig(filename+'_dpi=1000.tiff', dpi=1000) + except: + pass + # 基于plt, fig, ax画图 def plot_without_starting_fig_ax(plt, fig, ax, x_array, y_array, xlabel='x', ylabel='y', title='', fontsize=20, style='', y_min=None, y_max=None, linewidth=None, markersize=None, color=None, fontfamily='Times New Roman'): if color==None: diff --git a/PyPI/src/guan/functions_using_objects_of_custom_classes.py b/PyPI/src/guan/functions_using_objects_of_custom_classes.py new file mode 100644 index 0000000..1df4c3f --- /dev/null +++ b/PyPI/src/guan/functions_using_objects_of_custom_classes.py @@ -0,0 +1,21 @@ +# functions_using_objects_of_custom_classes + +# 从原子对象列表中获取 (x, y) 坐标数组 +def get_coordinate_array_from_atom_object_list(atom_object_list): + coordinate_array = [] + for atom in atom_object_list: + x = atom.x + y = atom.y + coordinate_array.append([x, y]) + return coordinate_array + +# 根据原子对象列表来初始化哈密顿量 +def initialize_hamiltonian_from_atom_object_list(atom_object_list): + import numpy as np + import guan + dim = guan.dimension_of_array(atom_object_list[0].energy) + num = len(atom_object_list) + hamiltonian = np.zeros((dim*num, dim*num)) + for i0 in range(num): + hamiltonian[i0*dim+0:i0*dim+dim, i0*dim+0:i0*dim+dim] = atom_object_list[i0].energy + return hamiltonian \ No newline at end of file diff --git a/README.md b/README.md index 92749ce..996b3b5 100755 --- a/README.md +++ b/README.md @@ -26,12 +26,14 @@ import guan + file reading and writing + figure plotting + data processing ++ custom classes ++ functions using objects of custom classes + decorators ## About this package + The original motivation of this project is for self use. Based on this project, the frequent functions can be imported by “import guan” instead of repeated copies and pastes. You can also install and use this open-source package if some functions are helpful for you. If one function is not good enough, you can copy the Source Code and modify it. You can also feed back to guanjihuan@163.com. The modifications and supplements will be in the following updated version. -+ All realizations of this package are based on functions without any class, which are concise and convenient. The boring document is omitted and you have to read the Source Code for details if it is necessary. Nevertheless, you don’t have to be worried about the difficulty, because all functions are simple enough without too many prejudgments and the variable names are written commonly as far as possible for the easy reading. ++ Most realizations of this package are only based on functions, which are concise and convenient. The boring document is omitted and you have to read the Source Code for details if it is necessary. Nevertheless, you don’t have to be worried about the difficulty, because all functions are simple enough without too many prejudgments and the variable names are written commonly as far as possible for the easy reading. + Before the function calling in your project, you are recommended to briefly read the Source Code to know the specific formats of input and output about the function. Applying functions mechanically may cause errors. Notice that as the package is developed, the function names may be changed in the future version. Therefore, the latest API Reference is important and helpful. ## Citation