Skip to content

Commit

Permalink
try fix setup auto version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jue-Xu committed Jul 29, 2024
1 parent c062f05 commit 8e9f094
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 30 deletions.
1 change: 1 addition & 0 deletions quantum_simulation_recipe/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.1.6
6 changes: 4 additions & 2 deletions quantum_simulation_recipe/plot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,22 @@ def set_color_cycle(color_cycle, alpha=0.3, mfc=True):
mpl.rc('axes', prop_cycle=colors)

default_color_cycle = ["#B65655FF", "#5471abFF", "#6aa66eFF", "#A66E6AFF"]
set_color_cycle(default_color_cycle)
# set_color_cycle(default_color_cycle)
# mpl.rc('axes', grid=True, edgecolor='k', prop_cycle=colors)
# mpl.rcParams['axes.prop_cycle'] = colors
# mpl.rcParams['lines.markeredgecolor'] = 'C'

from colorspace import sequential_hcl
class GradColors:
def __init__(self, rate_num):
self.rate_num = rate_num
# https://colorspace.r-forge.r-project.org/reference/hcl_palettes.html
self.purple = mpl.colors.ListedColormap(sequential_hcl("Purples")(rate_num+1)[:-1][::-1], name='from_list', N=None)
self.red = mpl.colors.ListedColormap(sequential_hcl("Reds")(rate_num+1)[:-1][::-1], name='from_list', N=None)
self.green = mpl.colors.ListedColormap(sequential_hcl("Greens")(rate_num+1)[:-1][::-1], name='from_list', N=None)
self.blue = mpl.colors.ListedColormap(sequential_hcl("Blues")(rate_num+1)[:-1][::-1], name='from_list', N=None)
self.orange = mpl.colors.ListedColormap(sequential_hcl("Oranges")(rate_num+1)[:-1][::-1], name='from_list', N=None)
self.mint = mpl.colors.ListedColormap(sequential_hcl("Mint")(rate_num+1)[:-1][::-1], name='from_list', N=None)
# self.return_colors()

def get_colors(self, c: str):
Expand Down Expand Up @@ -165,7 +167,7 @@ def ax_set_text(ax, x_label, y_label, title=None, legend='best', xticks=None, yt
# else:
# plt.plot(x, y, marker, label=label, linewidth=linewidth, markeredgecolor=markeredgecolor, markeredgewidth=0.5, alpha=alpha)

def plot_evo(ax, t_list, y_list, marker, color='', title='', xlabel='', ylabel='', label='', markersize=5, markeredgewidth=1, inset=False):
def plot_evo(ax, t_list, y_list, marker, color='', title='', xlabel='', ylabel='', label='', markersize=8, markeredgewidth=1, inset=False):
if color == '':
ax.plot(t_list, y_list, marker, label=label, markersize=markersize, markeredgewidth=markeredgewidth)
# ax.plot(t_list, y_list, '-', markersize=5)
Expand Down
29 changes: 20 additions & 9 deletions quantum_simulation_recipe/test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "8c03d3e4",
"metadata": {},
"outputs": [],
Expand All @@ -37,7 +37,7 @@
},
{
"cell_type": "code",
"execution_count": 31,
"execution_count": 4,
"id": "6ae552ff",
"metadata": {},
"outputs": [
Expand All @@ -50,7 +50,7 @@
" coeffs=[1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 1. +0.j, 0.2+0.j, 0.2+0.j])]"
]
},
"execution_count": 31,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -306,27 +306,38 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "85dc8331",
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/scipy/sparse/linalg/_dsolve/linsolve.py:602: SparseEfficiencyWarning: splu converted its input to CSC format\n",
" return splu(A).solve\n",
"/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/scipy/sparse/linalg/_matfuncs.py:707: SparseEfficiencyWarning: spsolve is more efficient when sparse b is in the CSC matrix format\n",
" return spsolve(Q, P)\n"
]
},
{
"data": {
"text/plain": [
"<16x16 sparse matrix of type '<class 'numpy.complex128'>'\n",
"\twith 70 stored elements in Compressed Sparse Row format>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "display_data"
"output_type": "execute_result"
}
],
"source": [
"from trotter import pf_r\n",
"from trotter import pf\n",
"\n",
"pf_r(nnh.ham_par, 2, 100, order=2)\n",
"pf_r(nnh.ham_par, 2, 100, order=2, use_jax=True)\n",
"pf_r([term.to_matrix(True) for term in nnh.ham_par], 2, 100, order=2)"
"pf(nnh.ham_par, 2, 100, order=2)\n",
"pf(nnh.ham_par, 2, 100, order=2, use_jax=True)\n",
"pf([term.to_matrix(True) for term in nnh.ham_par], 2, 100, order=2)"
]
},
{
Expand Down
46 changes: 27 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@
import subprocess
import os

# package_version = (
# subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE)
# .stdout.decode("utf-8")
# .strip()
# )
package_version = (
subprocess.run(["git", "describe", "--tags"], stdout=subprocess.PIPE)
.stdout.decode("utf-8")
.strip()
)
print(package_version)

# if "-" in package_version:
# # when not on tag, git describe outputs: "1.3.3-22-gdf81228"
# # pip has gotten strict with version numbers
# # so change it to: "1.3.3+22.git.gdf81228"
# # See: https://peps.python.org/pep-0440/#local-version-segments
# v,i,s = package_version.split("-")
# package_version = v + "+" + i + ".git." + s
if "-" in package_version:
# when not on tag, git describe outputs: "1.3.3-22-gdf81228"
# pip has gotten strict with version numbers
# so change it to: "1.3.3+22.git.gdf81228"
# See: https://peps.python.org/pep-0440/#local-version-segments
v,i,s = package_version.split("-")
package_version = v + "+" + i + ".git." + s

# assert "-" not in package_version
# assert "." in package_version
v_strs = package_version.split(".")
print(v_strs)
package_version = ".".join(v_strs[:-1]) + '.' + str(int(v_strs[-1])+1)
assert "-" not in package_version
assert "." in package_version

# assert os.path.isfile("quantum_simulation_recipe/version.py")
# with open("quantum_simulation_recipe/VERSION", "w", encoding="utf-8") as fh:
# fh.write("%s\n" % package_version)
assert os.path.isfile("quantum_simulation_recipe/version.py")
with open("quantum_simulation_recipe/VERSION", "w", encoding="utf-8") as fh:
fh.write("%s\n" % package_version)

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()

setuptools.setup(
name="quantum-simulation-recipe",
version='0.1.5',
# version=package_version,
# version='0.1.6',
version=package_version,
# setuptools_git_versioning={
# "enabled": True,
# },
# setup_requires=["setuptools-git-versioning>=2.0,<3"],
# author="Jue XU",
author_email="[email protected]",
description="Recipe for quantum simulation",
Expand Down

0 comments on commit 8e9f094

Please sign in to comment.