From 8b10e5e53ab6ffc8fe3326e445d522d06d814bb6 Mon Sep 17 00:00:00 2001 From: sambit-giri Date: Tue, 22 Oct 2024 15:15:36 +0200 Subject: [PATCH] publish on pypi from github --- .github/workflows/publish-to-pypi.yml | 36 ++++++++++++++++++++++++++ src/tools21cm/gaussian_random_field.py | 4 ++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/publish-to-pypi.yml diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml new file mode 100644 index 0000000..d89191a --- /dev/null +++ b/.github/workflows/publish-to-pypi.yml @@ -0,0 +1,36 @@ +name: Publish Python Package to PyPI + +on: + push: + tags: + - 'v*' # Trigger on version tags + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install build tools + run: | + python -m pip install --upgrade pip + pip install setuptools wheel twine + + - name: Build package + run: python setup.py sdist bdist_wheel + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload dist/* + + - name: Clean up + run: rm -rf dist build *.egg-info diff --git a/src/tools21cm/gaussian_random_field.py b/src/tools21cm/gaussian_random_field.py index cc11b74..99228c3 100644 --- a/src/tools21cm/gaussian_random_field.py +++ b/src/tools21cm/gaussian_random_field.py @@ -7,7 +7,7 @@ import numpy as np from scipy import fftpack from .power_spectrum import _get_dims, _get_k, power_spectrum_1d -from scipy.interpolate import interp1d +from scipy.interpolate import interp1d, splrep, splev def make_gaussian_random_field(dims, box_dims, power_spectrum, random_seed=None): ''' @@ -97,6 +97,8 @@ def _get_ps_func_for_field(input_field, box_dims, kbins=10): box_dims=box_dims, kbins=kbins, return_n_modes=True) ps_k = interp1d(k_input[n_modes>0], ps_input[n_modes>0], kind='linear', \ bounds_error=False, fill_value=0.) + # tckp = splrep(np.log10(k_input[n_modes>0]), np.log10(ps_input[n_modes>0]), k=1) + # ps_k = lambda k: 10**splev(np.log10(k), tckp) return ps_k