hcn 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hcn-0.0.1/.github/workflows/python-publish.yml +53 -0
- hcn-0.0.1/.gitignore +142 -0
- hcn-0.0.1/LICENSE +21 -0
- hcn-0.0.1/PKG-INFO +39 -0
- hcn-0.0.1/README.md +1 -0
- hcn-0.0.1/bak/__init__.py +30 -0
- hcn-0.0.1/bak/assets/mplstyle/draft.mplstyle +22 -0
- hcn-0.0.1/bak/assets/mplstyle/group_wiki_style.mplstyle +16 -0
- hcn-0.0.1/bak/assets/mplstyle/matlab_style.py +130 -0
- hcn-0.0.1/bak/assets/mplstyle/paper_matlablike.mplstyle +36 -0
- hcn-0.0.1/bak/decorators.py +129 -0
- hcn-0.0.1/bak/dev/__init__.py +0 -0
- hcn-0.0.1/bak/dev/io/DataWriter/DataWriter.py +0 -0
- hcn-0.0.1/bak/dev/io/DataWriter/__init__.py +0 -0
- hcn-0.0.1/bak/dev/io/FileLoader/FileLoader.py +99 -0
- hcn-0.0.1/bak/dev/io/FileLoader/__init__.py +13 -0
- hcn-0.0.1/bak/dev/io/__init__.py +2 -0
- hcn-0.0.1/bak/dev/plotter/__init__.py +0 -0
- hcn-0.0.1/bak/dev/plotter/core.py +0 -0
- hcn-0.0.1/bak/ezmail/__init__.py +1 -0
- hcn-0.0.1/bak/ezmail/core.py +75 -0
- hcn-0.0.1/bak/futils.py +137 -0
- hcn-0.0.1/bak/laser.py +92 -0
- hcn-0.0.1/bak/legacy/FreqEst.old/__init__.py +27 -0
- hcn-0.0.1/bak/legacy/FreqEst.old/bound.py +165 -0
- hcn-0.0.1/bak/legacy/FreqEst.old/common.py +151 -0
- hcn-0.0.1/bak/legacy/FreqEst.old/di.py +135 -0
- hcn-0.0.1/bak/legacy/FreqEst.old/spade.py +75 -0
- hcn-0.0.1/bak/legacy/_DataReader.py +75 -0
- hcn-0.0.1/bak/legacy/_FreqEst.py +112 -0
- hcn-0.0.1/bak/legacy/_TDEst.py +69 -0
- hcn-0.0.1/bak/legacy/cgh/__init__.py +38 -0
- hcn-0.0.1/bak/legacy/cgh/fx1.npy +0 -0
- hcn-0.0.1/bak/legacy/cgh/fx2.npy +0 -0
- hcn-0.0.1/bak/legacy/displacement_est/__init__.py +3 -0
- hcn-0.0.1/bak/legacy/displacement_est/di.py +151 -0
- hcn-0.0.1/bak/legacy/displacement_est/spade.py +48 -0
- hcn-0.0.1/bak/legacy/equipments.old/__init__.py +2 -0
- hcn-0.0.1/bak/legacy/equipments.old/dmd.py +3 -0
- hcn-0.0.1/bak/legacy/equipments.old/lamp.py +20 -0
- hcn-0.0.1/bak/legacy/equipments.old/qcmos.py +12 -0
- hcn-0.0.1/bak/legacy/equipments.old/qe.npy +0 -0
- hcn-0.0.1/bak/legacy/equipments.old/slm.py +3 -0
- hcn-0.0.1/bak/legacy/experiments.old/__init__.py +26 -0
- hcn-0.0.1/bak/legacy/experiments.old/core.py +242 -0
- hcn-0.0.1/bak/legacy/experiments.old/params.py +64 -0
- hcn-0.0.1/bak/legacy/experiments.old/utils.py +35 -0
- hcn-0.0.1/bak/legacy/lse.py +57 -0
- hcn-0.0.1/bak/legacy/simulations/__init__.py +105 -0
- hcn-0.0.1/bak/legacy/tk_gui/file converter.py +163 -0
- hcn-0.0.1/bak/legacy/tk_gui/file_selector.py +92 -0
- hcn-0.0.1/bak/legacy/utils.py +112 -0
- hcn-0.0.1/bak/macro.py +409 -0
- hcn-0.0.1/bak/photosutils.py +40 -0
- hcn-0.0.1/bak/plotter.py +180 -0
- hcn-0.0.1/bak/plotter.pyi +149 -0
- hcn-0.0.1/bak/style_example.ipynb +58 -0
- hcn-0.0.1/justfile +23 -0
- hcn-0.0.1/pyproject.toml +32 -0
- hcn-0.0.1/setup.cfg +4 -0
- hcn-0.0.1/src/hcn/__init__.py +51 -0
- hcn-0.0.1/src/hcn/assets/fonts/SourceHanSans.otf +0 -0
- hcn-0.0.1/src/hcn/assets/fonts/lmroman10.otf +0 -0
- hcn-0.0.1/src/hcn/assets/matlab_style.py +128 -0
- hcn-0.0.1/src/hcn/io/__init__.py +1 -0
- hcn-0.0.1/src/hcn/io/core.py +238 -0
- hcn-0.0.1/src/hcn/preamble.py +9 -0
- hcn-0.0.1/src/hcn/utils/__init__.py +0 -0
- hcn-0.0.1/src/hcn/utils/cache.py +143 -0
- hcn-0.0.1/src/hcn/utils/cpuid.py +29 -0
- hcn-0.0.1/src/hcn/utils/crypt.py +146 -0
- hcn-0.0.1/src/hcn/utils/ezmail.py +191 -0
- hcn-0.0.1/src/hcn/utils/parallelize.py +25 -0
- hcn-0.0.1/src/hcn.egg-info/PKG-INFO +39 -0
- hcn-0.0.1/src/hcn.egg-info/SOURCES.txt +78 -0
- hcn-0.0.1/src/hcn.egg-info/dependency_links.txt +1 -0
- hcn-0.0.1/src/hcn.egg-info/requires.txt +5 -0
- hcn-0.0.1/src/hcn.egg-info/top_level.txt +1 -0
- hcn-0.0.1/test/test.ipynb +24 -0
- hcn-0.0.1/trashbin +1694 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
name: Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
release-build:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
|
|
18
|
+
- uses: actions/setup-python@v5
|
|
19
|
+
with:
|
|
20
|
+
python-version: "3.x"
|
|
21
|
+
|
|
22
|
+
- name: Build release distributions
|
|
23
|
+
run: |
|
|
24
|
+
python -m pip install build
|
|
25
|
+
python -m build
|
|
26
|
+
|
|
27
|
+
- name: Upload distributions
|
|
28
|
+
uses: actions/upload-artifact@v4
|
|
29
|
+
with:
|
|
30
|
+
name: release-dists
|
|
31
|
+
path: dist/
|
|
32
|
+
|
|
33
|
+
pypi-publish:
|
|
34
|
+
runs-on: ubuntu-latest
|
|
35
|
+
needs:
|
|
36
|
+
- release-build
|
|
37
|
+
permissions:
|
|
38
|
+
id-token: write
|
|
39
|
+
|
|
40
|
+
environment:
|
|
41
|
+
name: pypi
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Retrieve release distributions
|
|
45
|
+
uses: actions/download-artifact@v4
|
|
46
|
+
with:
|
|
47
|
+
name: release-dists
|
|
48
|
+
path: dist/
|
|
49
|
+
|
|
50
|
+
- name: Publish release distributions to PyPI
|
|
51
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
52
|
+
with:
|
|
53
|
+
packages-dir: dist/
|
hcn-0.0.1/.gitignore
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py,cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
98
|
+
__pypackages__/
|
|
99
|
+
|
|
100
|
+
# Celery stuff
|
|
101
|
+
celerybeat-schedule
|
|
102
|
+
celerybeat.pid
|
|
103
|
+
|
|
104
|
+
# SageMath parsed files
|
|
105
|
+
*.sage.py
|
|
106
|
+
|
|
107
|
+
# Environments
|
|
108
|
+
.env
|
|
109
|
+
.venv
|
|
110
|
+
env/
|
|
111
|
+
venv/
|
|
112
|
+
ENV/
|
|
113
|
+
env.bak/
|
|
114
|
+
venv.bak/
|
|
115
|
+
|
|
116
|
+
# Spyder project settings
|
|
117
|
+
.spyderproject
|
|
118
|
+
.spyproject
|
|
119
|
+
|
|
120
|
+
# Rope project settings
|
|
121
|
+
.ropeproject
|
|
122
|
+
|
|
123
|
+
# mkdocs documentation
|
|
124
|
+
/site
|
|
125
|
+
|
|
126
|
+
# mypy
|
|
127
|
+
.mypy_cache/
|
|
128
|
+
.dmypy.json
|
|
129
|
+
dmypy.json
|
|
130
|
+
|
|
131
|
+
# Pyre type checker
|
|
132
|
+
.pyre/
|
|
133
|
+
|
|
134
|
+
# pytype static type analyzer
|
|
135
|
+
.pytype/
|
|
136
|
+
|
|
137
|
+
# Cython debug symbols
|
|
138
|
+
cython_debug/
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# Manually Added
|
|
142
|
+
.DS_Store
|
hcn-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Chao-Ning Hu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
hcn-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: hcn
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: HCN's Collections of Nonpareils (or Nonsense)
|
|
5
|
+
License: MIT License
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2023 Chao-Ning Hu
|
|
8
|
+
|
|
9
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
10
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
11
|
+
in the Software without restriction, including without limitation the rights
|
|
12
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
13
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
14
|
+
furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all
|
|
17
|
+
copies or substantial portions of the Software.
|
|
18
|
+
|
|
19
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
20
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
21
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
22
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
23
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
24
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
25
|
+
SOFTWARE.
|
|
26
|
+
|
|
27
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
28
|
+
Classifier: Programming Language :: Python :: 3
|
|
29
|
+
Classifier: Operating System :: OS Independent
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
Requires-Dist: numpy
|
|
33
|
+
Requires-Dist: scipy
|
|
34
|
+
Requires-Dist: matplotlib
|
|
35
|
+
Requires-Dist: gitpython
|
|
36
|
+
Requires-Dist: imageio[ffmpeg,tifffile]
|
|
37
|
+
Dynamic: license-file
|
|
38
|
+
|
|
39
|
+
Refactoring...
|
hcn-0.0.1/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Refactoring...
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from math import *
|
|
2
|
+
import numpy as np
|
|
3
|
+
import scipy as sp
|
|
4
|
+
import matplotlib.pyplot as plt
|
|
5
|
+
|
|
6
|
+
from PIL import Image as image
|
|
7
|
+
|
|
8
|
+
import os, shutil, timeit
|
|
9
|
+
from glob import glob
|
|
10
|
+
from time import sleep
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
from tqdm import tqdm
|
|
14
|
+
except ImportError:
|
|
15
|
+
pass
|
|
16
|
+
|
|
17
|
+
from .futils import *
|
|
18
|
+
from .macro import *
|
|
19
|
+
from .laser import *
|
|
20
|
+
from .decorators import *
|
|
21
|
+
|
|
22
|
+
from .ezmail import *
|
|
23
|
+
from .cryptutils import *
|
|
24
|
+
|
|
25
|
+
from .plotter import *
|
|
26
|
+
# inline_format()
|
|
27
|
+
|
|
28
|
+
from .cache import *
|
|
29
|
+
clean_expired_cache()
|
|
30
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
figure.figsize: 3.3, 2.5
|
|
2
|
+
figure.dpi: 150
|
|
3
|
+
|
|
4
|
+
font.size: 8
|
|
5
|
+
font.family: Latin Modern Roman, Source Han Sans SC
|
|
6
|
+
mathtext.fontset: cm
|
|
7
|
+
|
|
8
|
+
lines.linewidth: 1.5
|
|
9
|
+
lines.markersize: 4
|
|
10
|
+
|
|
11
|
+
axes.grid: True
|
|
12
|
+
axes.labelsize: large
|
|
13
|
+
axes.prop_cycle: cycler('color', 'bgmbgm') + cycler('linestyle', ['--', '-.', '--', '-.', '--', '-.'])
|
|
14
|
+
|
|
15
|
+
legend.fancybox: False
|
|
16
|
+
legend.frameon: True
|
|
17
|
+
legend.framealpha: None
|
|
18
|
+
legend.facecolor: inherit
|
|
19
|
+
legend.edgecolor: inherit
|
|
20
|
+
|
|
21
|
+
savefig.format: pdf
|
|
22
|
+
savefig.bbox: tight
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
figure.figsize: 3.3, 2.5
|
|
2
|
+
figure.dpi: 150
|
|
3
|
+
|
|
4
|
+
# text.usetex: true
|
|
5
|
+
|
|
6
|
+
font.size: 8
|
|
7
|
+
font.family: Source Han Sans SC
|
|
8
|
+
|
|
9
|
+
# font.sans-serif: Helvetica
|
|
10
|
+
# font.family: sans-serif
|
|
11
|
+
|
|
12
|
+
lines.linewidth: 1.5
|
|
13
|
+
lines.markersize: 4
|
|
14
|
+
|
|
15
|
+
savefig.format: pdf
|
|
16
|
+
savefig.bbox: tight
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import matplotlib.pyplot as plt
|
|
3
|
+
|
|
4
|
+
from matplotlib_inline import backend_inline
|
|
5
|
+
backend_inline.set_matplotlib_formats('retina')
|
|
6
|
+
del backend_inline
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from matplotlib.font_manager import fontManager
|
|
10
|
+
assets_dir = os.path.abspath(
|
|
11
|
+
os.path.join(os.path.dirname(__file__), '..')
|
|
12
|
+
)
|
|
13
|
+
fontManager.addfont(os.path.join(assets_dir, 'fonts/SourceHanSans.otf'))
|
|
14
|
+
del fontManager
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
plt.rcParams['font.size'] = 7
|
|
18
|
+
plt.rcParams['font.sans-serif'].append('Source Han Sans SC')
|
|
19
|
+
|
|
20
|
+
plt.rcParams['axes.linewidth'] = 0.334
|
|
21
|
+
plt.rcParams['xtick.major.width'] = 0.334
|
|
22
|
+
plt.rcParams['ytick.major.width'] = 0.334
|
|
23
|
+
plt.rcParams['figure.dpi'] = 150
|
|
24
|
+
plt.rcParams['figure.figsize'] = (3.3, 2.5)
|
|
25
|
+
plt.rcParams['lines.linewidth'] = 1
|
|
26
|
+
plt.rcParams['lines.markersize'] = 4
|
|
27
|
+
|
|
28
|
+
plt.rcParams['xtick.top'] = True
|
|
29
|
+
plt.rcParams['ytick.right'] = True
|
|
30
|
+
plt.rcParams['xtick.direction'] = 'in'
|
|
31
|
+
plt.rcParams['ytick.direction'] = 'in'
|
|
32
|
+
plt.rcParams['xtick.major.size'] = 2.3
|
|
33
|
+
plt.rcParams['ytick.major.size'] = 2.3
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
plt.rcParams['savefig.bbox'] = 'tight'
|
|
37
|
+
plt.rcParams['axes.prop_cycle'] = \
|
|
38
|
+
plt.cycler('color', ['#0072bd', '#d95319', '#edb120', '#7e2f8e', '#77ac30', '#4dbeee', '#a2142f'])
|
|
39
|
+
# plt.cycler('linestyle', ['-', '--', '-.', ':', '-', '--', '-.'])
|
|
40
|
+
|
|
41
|
+
plt.rcParams['legend.fancybox'] = False
|
|
42
|
+
plt.rcParams['legend.frameon'] = True
|
|
43
|
+
plt.rcParams['legend.framealpha'] = 1
|
|
44
|
+
plt.rcParams['legend.edgecolor'] = 'k'
|
|
45
|
+
plt.rcParams['legend.handlelength'] = 2.5
|
|
46
|
+
plt.rcParams['legend.borderpad'] = 0.3
|
|
47
|
+
plt.rcParams['legend.handletextpad'] = 0.3
|
|
48
|
+
plt.rcParams['patch.linewidth'] = 0.334
|
|
49
|
+
|
|
50
|
+
plt.rcParams['axes.unicode_minus'] = False
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
import matplotlib as mpl
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
cm_data = [
|
|
57
|
+
[0.2081, 0.1663, 0.5292],
|
|
58
|
+
[0.2116238095, 0.1897809524, 0.5776761905],
|
|
59
|
+
[0.212252381, 0.2137714286, 0.6269714286],
|
|
60
|
+
[0.2081, 0.2386, 0.6770857143],
|
|
61
|
+
[0.1959047619, 0.2644571429, 0.7279],
|
|
62
|
+
[0.1707285714, 0.2919380952, 0.779247619],
|
|
63
|
+
[0.1252714286, 0.3242428571, 0.8302714286],
|
|
64
|
+
[0.0591333333, 0.3598333333, 0.8683333333],
|
|
65
|
+
[0.0116952381, 0.3875095238, 0.8819571429],
|
|
66
|
+
[0.0059571429, 0.4086142857, 0.8828428571],
|
|
67
|
+
[0.0165142857, 0.4266, 0.8786333333],
|
|
68
|
+
[0.032852381, 0.4430428571, 0.8719571429],
|
|
69
|
+
[0.0498142857, 0.4585714286, 0.8640571429],
|
|
70
|
+
[0.0629333333, 0.4736904762, 0.8554380952],
|
|
71
|
+
[0.0722666667, 0.4886666667, 0.8467],
|
|
72
|
+
[0.0779428571, 0.5039857143, 0.8383714286],
|
|
73
|
+
[0.079347619, 0.5200238095, 0.8311809524],
|
|
74
|
+
[0.0749428571, 0.5375428571, 0.8262714286],
|
|
75
|
+
[0.0640571429, 0.5569857143, 0.8239571429],
|
|
76
|
+
[0.0487714286, 0.5772238095, 0.8228285714],
|
|
77
|
+
[0.0343428571, 0.5965809524, 0.819852381],
|
|
78
|
+
[0.0265, 0.6137, 0.8135],
|
|
79
|
+
[0.0238904762, 0.6286619048, 0.8037619048],
|
|
80
|
+
[0.0230904762, 0.6417857143, 0.7912666667],
|
|
81
|
+
[0.0227714286, 0.6534857143, 0.7767571429],
|
|
82
|
+
[0.0266619048, 0.6641952381, 0.7607190476],
|
|
83
|
+
[0.0383714286, 0.6742714286, 0.743552381],
|
|
84
|
+
[0.0589714286, 0.6837571429, 0.7253857143],
|
|
85
|
+
[0.0843, 0.6928333333, 0.7061666667],
|
|
86
|
+
[0.1132952381, 0.7015, 0.6858571429],
|
|
87
|
+
[0.1452714286, 0.7097571429, 0.6646285714],
|
|
88
|
+
[0.1801333333, 0.7176571429, 0.6424333333],
|
|
89
|
+
[0.2178285714, 0.7250428571, 0.6192619048],
|
|
90
|
+
[0.2586428571, 0.7317142857, 0.5954285714],
|
|
91
|
+
[0.3021714286, 0.7376047619, 0.5711857143],
|
|
92
|
+
[0.3481666667, 0.7424333333, 0.5472666667],
|
|
93
|
+
[0.3952571429, 0.7459, 0.5244428571],
|
|
94
|
+
[0.4420095238, 0.7480809524, 0.5033142857],
|
|
95
|
+
[0.4871238095, 0.7490619048, 0.4839761905],
|
|
96
|
+
[0.5300285714, 0.7491142857, 0.4661142857],
|
|
97
|
+
[0.5708571429, 0.7485190476, 0.4493904762],
|
|
98
|
+
[0.609852381, 0.7473142857, 0.4336857143],
|
|
99
|
+
[0.6473, 0.7456, 0.4188],
|
|
100
|
+
[0.6834190476, 0.7434761905, 0.4044333333],
|
|
101
|
+
[0.7184095238, 0.7411333333, 0.3904761905],
|
|
102
|
+
[0.7524857143, 0.7384, 0.3768142857],
|
|
103
|
+
[0.7858428571, 0.7355666667, 0.3632714286],
|
|
104
|
+
[0.8185047619, 0.7327333333, 0.3497904762],
|
|
105
|
+
[0.8506571429, 0.7299, 0.3360285714],
|
|
106
|
+
[0.8824333333, 0.7274333333, 0.3217],
|
|
107
|
+
[0.9139333333, 0.7257857143, 0.3062761905],
|
|
108
|
+
[0.9449571429, 0.7261142857, 0.2886428571],
|
|
109
|
+
[0.9738952381, 0.7313952381, 0.266647619],
|
|
110
|
+
[0.9937714286, 0.7454571429, 0.240347619],
|
|
111
|
+
[0.9990428571, 0.7653142857, 0.2164142857],
|
|
112
|
+
[0.9955333333, 0.7860571429, 0.196652381],
|
|
113
|
+
[0.988, 0.8066, 0.1793666667],
|
|
114
|
+
[0.9788571429, 0.8271428571, 0.1633142857],
|
|
115
|
+
[0.9697, 0.8481380952, 0.147452381],
|
|
116
|
+
[0.9625857143, 0.8705142857, 0.1309],
|
|
117
|
+
[0.9588714286, 0.8949, 0.1132428571],
|
|
118
|
+
[0.9598238095, 0.9218333333, 0.0948380952],
|
|
119
|
+
[0.9661, 0.9514428571, 0.0755333333],
|
|
120
|
+
[0.9763, 0.9831, 0.0538],
|
|
121
|
+
]
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
parula = mpl.colors.LinearSegmentedColormap.from_list('parula', cm_data)
|
|
125
|
+
mpl.colormaps.register(parula)
|
|
126
|
+
plt.rcParams['image.cmap'] = 'parula'
|
|
127
|
+
del mpl, parula, cm_data
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
__all__ = []
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Imitating 陆老师's PRX, cannot use Chinese fonts due to font
|
|
2
|
+
|
|
3
|
+
# Line thickness, image size, and font size
|
|
4
|
+
lines.linewidth: 2.5
|
|
5
|
+
figure.figsize: 6.4, 4.8 # Same as matplotlib default
|
|
6
|
+
font.size: 13
|
|
7
|
+
|
|
8
|
+
# Font settings
|
|
9
|
+
mathtext.fontset: cm
|
|
10
|
+
font.family: Times New Roman
|
|
11
|
+
|
|
12
|
+
# Axis ticks directed inward, with top and right ticks displayed
|
|
13
|
+
xtick.direction: in
|
|
14
|
+
ytick.direction: in
|
|
15
|
+
xtick.top: True
|
|
16
|
+
ytick.right: True
|
|
17
|
+
|
|
18
|
+
# Remove default whitespace
|
|
19
|
+
axes.xmargin: 0.0
|
|
20
|
+
axes.ymargin: 0.0
|
|
21
|
+
axes.zmargin: 0.0
|
|
22
|
+
|
|
23
|
+
# Display labels in larger font size and set color and linestyle cycle
|
|
24
|
+
# Colors are slightly modified from 'bmh' style
|
|
25
|
+
axes.labelsize: large
|
|
26
|
+
axes.prop_cycle: cycler('color', ['348ABD', 'A60628', '7A68A6', '467821', 'CC79A7', '56B4E9', '00C800', 'F0E442']) + cycler('linestyle', ['-', '--', '-.', ':', '-', '--', '-.', ':'])
|
|
27
|
+
|
|
28
|
+
# Set the style of the legend box; rectangular black border, opaque
|
|
29
|
+
legend.fancybox: False
|
|
30
|
+
legend.frameon: True
|
|
31
|
+
legend.framealpha: None
|
|
32
|
+
legend.facecolor: inherit
|
|
33
|
+
legend.edgecolor: inherit
|
|
34
|
+
|
|
35
|
+
# Display fonts in path format for better compatibility
|
|
36
|
+
svg.fonttype: path
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from matplotlib import pyplot as plt
|
|
3
|
+
import matplotlib.ticker as ticker
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
from functools import wraps
|
|
7
|
+
|
|
8
|
+
from .macro import hashsum, format_time
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
__all__ = [
|
|
12
|
+
'stopwatch',
|
|
13
|
+
'parallelize'
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def plotter_decorator(**kwargs):
|
|
18
|
+
default_params = {
|
|
19
|
+
'figsize': None,
|
|
20
|
+
'axis': True,
|
|
21
|
+
'grid': None,
|
|
22
|
+
'xlabel': None,
|
|
23
|
+
'ylabel': None,
|
|
24
|
+
'title': None,
|
|
25
|
+
'xlim': None,
|
|
26
|
+
'ylim': None,
|
|
27
|
+
'legend': True,
|
|
28
|
+
'label': None,
|
|
29
|
+
'save': None,
|
|
30
|
+
'override': False,
|
|
31
|
+
'show': False,
|
|
32
|
+
}
|
|
33
|
+
default_params = {**default_params, **kwargs}
|
|
34
|
+
def decorator(plotter_function):
|
|
35
|
+
from functools import wraps
|
|
36
|
+
@wraps(plotter_function)
|
|
37
|
+
def wrapper(*args, **kwargs):
|
|
38
|
+
params = {**default_params, **kwargs}
|
|
39
|
+
if params['figsize'] is not None:
|
|
40
|
+
old_figsize = plt.rcParams['figure.figsize']
|
|
41
|
+
plt.rcParams['figure.figsize'] = params['figsize']
|
|
42
|
+
if not params['axis']:
|
|
43
|
+
plt.xticks([])
|
|
44
|
+
plt.yticks([])
|
|
45
|
+
if params['grid'] is not None:
|
|
46
|
+
plt.grid(params['grid'])
|
|
47
|
+
if params['xlabel'] is not None:
|
|
48
|
+
plt.xlabel(params['xlabel'])
|
|
49
|
+
if params['ylabel'] is not None:
|
|
50
|
+
plt.ylabel(params['ylabel'])
|
|
51
|
+
if params['title'] is not None:
|
|
52
|
+
plt.title(params['title'])
|
|
53
|
+
|
|
54
|
+
plotter_function(*args, **kwargs)
|
|
55
|
+
|
|
56
|
+
# plt.gca().xaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=True))
|
|
57
|
+
# plt.gca().yaxis.set_major_formatter(ticker.ScalarFormatter(useMathText=True))
|
|
58
|
+
# plt.ticklabel_format(style='sci', axis='both')
|
|
59
|
+
|
|
60
|
+
if params['xlim'] is not None:
|
|
61
|
+
plt.xlim(params['xlim'])
|
|
62
|
+
if params['ylim'] is not None:
|
|
63
|
+
plt.ylim(params['ylim'])
|
|
64
|
+
if params['legend'] and params['label'] is not None:
|
|
65
|
+
plt.legend()
|
|
66
|
+
save = params['save']
|
|
67
|
+
if save is not None:
|
|
68
|
+
if type(save) is bool or type(save) is str:
|
|
69
|
+
if save == True:
|
|
70
|
+
while True:
|
|
71
|
+
temp_name = f'{np.random.randint(0, 1e8)}.svg'
|
|
72
|
+
if not os.path.exists(temp_name):
|
|
73
|
+
break
|
|
74
|
+
plt.savefig(temp_name)
|
|
75
|
+
save = hashsum(temp_name, algorithm='sha1')
|
|
76
|
+
os.rename(src=temp_name, dst=f'{save}.svg')
|
|
77
|
+
elif type(save) is str:
|
|
78
|
+
if os.path.exists(save) or os.path.exists(f'{save}.svg'):
|
|
79
|
+
if params['override']:
|
|
80
|
+
plt.savefig(save)
|
|
81
|
+
else:
|
|
82
|
+
raise FileExistsError('file already exists')
|
|
83
|
+
else:
|
|
84
|
+
plt.savefig(save)
|
|
85
|
+
else:
|
|
86
|
+
raise TypeError('type(save) must be bool or str')
|
|
87
|
+
if params['show']:
|
|
88
|
+
plt.show()
|
|
89
|
+
if params['figsize'] is not None:
|
|
90
|
+
plt.rcParams['figure.figsize'] = old_figsize
|
|
91
|
+
return wrapper
|
|
92
|
+
return decorator
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def stopwatch(func):
|
|
96
|
+
from time import time
|
|
97
|
+
@wraps(func)
|
|
98
|
+
def wrapper(*args, **kargs):
|
|
99
|
+
start = time()
|
|
100
|
+
result = func(*args, **kargs)
|
|
101
|
+
print(f'Function {func.__name__} took: {format_time(time() - start)}')
|
|
102
|
+
return result
|
|
103
|
+
return wrapper
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def parallelize(cores: int = 0):
|
|
108
|
+
from dask import delayed, compute
|
|
109
|
+
from dask.distributed import Client
|
|
110
|
+
|
|
111
|
+
if cores <= 0:
|
|
112
|
+
import psutil
|
|
113
|
+
cores = psutil.cpu_count(logical=False)
|
|
114
|
+
|
|
115
|
+
def decorator(func):
|
|
116
|
+
@wraps(func)
|
|
117
|
+
def wrapper(tasks, *args, **kwargs):
|
|
118
|
+
|
|
119
|
+
@delayed
|
|
120
|
+
def _delayed_func(*args, **kwargs):
|
|
121
|
+
return func(*args, **kwargs)
|
|
122
|
+
|
|
123
|
+
all_tasks = [_delayed_func(task, *args, **kwargs) for task in tasks]
|
|
124
|
+
with Client(n_workers=cores, threads_per_worker=1):
|
|
125
|
+
results = compute(*all_tasks)
|
|
126
|
+
|
|
127
|
+
return results
|
|
128
|
+
return wrapper
|
|
129
|
+
return decorator
|
|
File without changes
|
|
File without changes
|
|
File without changes
|