diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 0000000..b9b7397 --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,34 @@ +name: Publish qemcmc to PyPI + +on: + push: + tags: + - "v*" + +jobs: + publish: + runs-on: ubuntu-latest + + environment: + name: pypi + + permissions: + id-token: write # for trusted publishing + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.13" + + - name: Install build tool + run: pip install build + + - name: Build + run: python -m build + + - name: Publish + uses: pypa/gh-action-pypi-publish@release/v1 \ No newline at end of file diff --git a/docs/source/github.md b/docs/source/github.md new file mode 100644 index 0000000..eef9381 --- /dev/null +++ b/docs/source/github.md @@ -0,0 +1,3 @@ +# Github + +The source code for QeMCMC can be found at [https://github.com/Stuartferguson00/QeMCMC](https://github.com/Stuartferguson00/QeMCMC). Contributions are welcome, and you can submit issues or pull requests to help improve the project. Please refer to the repository's README and contribution guidelines for more information on how to get involved. diff --git a/docs/source/index.md b/docs/source/index.md index 5411733..e438eb0 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -32,6 +32,7 @@ api/index :maxdepth: 2 :caption: Development +github license authors ``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 94ff201..eee849d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,9 +1,11 @@ [project] name = "qemcmc" -version = "0.0.0" +# version = "0.0.0" +dynamic = ["version"] description = "Quantum enhanced Markov Chain Monte Carlo sampler simulated using PennyLane" readme = "README.md" authors = [{ name = "Stuart Ferguson" }, { name = "Feroz Hassan" }] +license = { text = "MIT" } requires-python = ">=3.13" dependencies = [ "joblib>=1.5.0", @@ -26,5 +28,10 @@ dependencies = [ qemcmc = "qemcmc:main" [build-system] -requires = ["setuptools>=61.0", "wheel"] +requires = ["setuptools>=61.0", "wheel", "setuptools-scm"] build-backend = "setuptools.build_meta" + +[tool.setuptools_scm] + +[tool.setuptools.packages.find] +where = ["src"] diff --git a/src/qemcmc/circuits.py b/src/qemcmc/circuits.py index d6944f0..ea76718 100644 --- a/src/qemcmc/circuits.py +++ b/src/qemcmc/circuits.py @@ -72,6 +72,7 @@ def get_problem_hamiltonian(self, couplings, sign=-1): if order == 0: continue spin_sign = (-1) ** order + non_zero_indices = np.transpose(np.nonzero(coupling_tensor)) for index_tuple in non_zero_indices: index_tuple = tuple(int(i) for i in index_tuple) @@ -102,14 +103,17 @@ def get_mixer_hamiltonian(self, num_wires: int = None): def get_state_vector(self, s: str) -> str: """Return the state vector.""" + num_wires = len(s) + dev = self._get_device(num_wires) + # Coefficients alpha = self.model.calculate_alpha(couplings=self.local_couplings) coeff_mixer = self.gamma coeff_problem = -(1 - self.gamma) * alpha - H_total = qml.Hamiltonian([coeff_mixer] + [1.0], [self.get_mixer_hamiltonian(), self.get_problem_hamiltonian(couplings=self.local_couplings, sign=coeff_problem)]) + H_total = qml.Hamiltonian([coeff_mixer] + [1.0], [self.get_mixer_hamiltonian(num_wires), self.get_problem_hamiltonian(couplings=self.local_couplings, sign=coeff_problem)]) - @qml.qnode(self.dev) + @qml.qnode(dev) def quantum_evolution(input_string): for i, bit in enumerate(input_string): if bit == "1":