Skip to content

Instantly share code, notes, and snippets.

View ixsluo's full-sized avatar

Xiaoshan Luo ixsluo

  • Jilin University
View GitHub Profile
@ixsluo
ixsluo / write_table.py
Created August 9, 2022 13:02
write dict to formated table
from itertools import chain
d = {'a1': [1, 2, 3, 4], 'a2': ['a', 'cxzs', 'as', 123]}
tmp = [list(map(lambda i: str(i), [k] + v)) for k, v in d.items()]
# print(tmp)
# [['a1', '1', ...], ['a2', ...]]
max_len = [max(map(lambda i: len(i), v)) for v in tmp]
for i in zip(*tmp):
fmt = tuple(chain.from_iterable((zip(max_len, i))))
@ixsluo
ixsluo / plt_config.py
Created July 8, 2021 12:41
plt config
import matplotlib.pyplot as plt
rcconfig = {
'figure.titlesize': 30,
'figure.titleweight': 'bold',
'xtick.direction': 'in',
'ytick.direction': 'in',
'xtick.major.width': 3,
'ytick.major.width': 3,
'xtick.major.size': 9,
@ixsluo
ixsluo / pool.py
Last active November 4, 2021 09:53
进程池
import multiprocessing as mp
from tqdm import tqdm
class MyProcessPool():
def __init__(self, processes, timeout=None, error_callback=None):
self.pool = mp.Pool(processes=processes)
self.timeout = timeout
self.error_callback = error_callback
def work(self, job, args_list):
@ixsluo
ixsluo / 2profess.py
Last active January 6, 2021 02:15
transform crystal structure file to castep profess file
#!/usr/bin/env python
# This program transfrom vasp, cif etc, structure file
# to castep profess file
# Usage:
# python 2profess *.vasp *.cif *.CHGCAR ...
# output: *.cell
# requirement: pymatgen
@ixsluo
ixsluo / periodic_table.py
Created July 3, 2020 03:23
[periodic table] #python
periodic_table = ('H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na',
'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc',
'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga',
'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb',
'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb',
'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm',
'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu',
'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl',
'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa',
'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md',