Skip to content

Commit

Permalink
Merge branch 'dev' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-murray authored Jan 16, 2023
2 parents fcfd7e2 + 01d1eba commit 7545931
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 23 deletions.
18 changes: 5 additions & 13 deletions .github/workflows/publish-to-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: push
jobs:
build-n-publish:
name: Deploy
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@master
# https://github.com/ansible/pylibssh/blob/1e7b17f/.github/workflows/build-test-n-publish.yml#L146-L151
Expand All @@ -15,10 +15,10 @@ jobs:
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
git describe --tags
git describe --tags $(git rev-list --tags --max-count=1)
- name: Set up Python 3.7
uses: actions/setup-python@v1
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.10"
- name: Install pep517
run: |
python -m pip install pep517 --user
Expand All @@ -33,18 +33,10 @@ jobs:
echo "SETUPTOOLS_SCM_PRETEND_VERSION=$version" >> $GITHUB_ENV
- name: Build a binary wheel and a source tarball
run: python -m pep517.build --binary --source --out-dir dist .
# deploy to Test PyPI on any push except when merging to master, since that will
# already exist, and thus fail.
- name: Publish distribution 📦 to Test PyPI
if: ${{ !contains(github.ref, 'master') }}
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
# deploy to actual PyPI only when a tag is pushed (which should happen only
# automatically on master)
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@master
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.pypi_password }}
4 changes: 2 additions & 2 deletions .github/workflows/test_suite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.8, 3.9, "3.10"]
python-version: [3.8, 3.9, "3.10", "3.11"]
steps:
- uses: actions/checkout@master
with:
Expand All @@ -35,7 +35,7 @@ jobs:
with:
python-version: ${{ matrix.python-version }}
- name: Setup GNU Fortran
uses: modflowpy/install-gfortran-action@v1
uses: modflowpy/install-gfortran-action@v1.0.1
- name: Install
run: pip install .[dev]
- name: Run Tests
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
- flake8-comprehensions
- flake8-print
- repo: https://github.com/psf/black
rev: 22.8.0
rev: 22.10.0
hooks:
- id: black
- repo: https://github.com/pre-commit/pygrep-hooks
Expand All @@ -46,7 +46,7 @@ repos:
- id: isort

- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
rev: v3.2.0
hooks:
- id: pyupgrade
args: [--py38-plus]
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"esbonio.sphinx.confDir": ""
}
2 changes: 1 addition & 1 deletion requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ Sphinx==1.7.5
sphinx_rtd_theme
sympy==1.1.1
tox==3.0.0
wheel==0.31.0
wheel==0.38.1
9 changes: 4 additions & 5 deletions src/hmf/helpers/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ def _prepare_mf(log_mmin, **mf_kwargs):
return icdf, h


def _choose_halo_masses_num(N, icdf):
def _choose_halo_masses_num(N, icdf, xmin=0):
# Generate random variates from 0 to maxcum
x = np.random.random(int(N))
x = np.random.uniform(low=xmin, high=1.0, size=int(N))

# Generate halo masses from mf distribution
m = 10 ** icdf(x)
return m
return 10 ** icdf(x)


def sample_mf(N, log_mmin, sort=False, **mf_kwargs):
Expand Down Expand Up @@ -61,7 +60,7 @@ def sample_mf(N, log_mmin, sort=False, **mf_kwargs):
"""
icdf, h = _prepare_mf(log_mmin, **mf_kwargs)

m = _choose_halo_masses_num(N, icdf)
m = _choose_halo_masses_num(N, icdf, xmin=h.ngtm.min() / h.ngtm[0])

if sort:
m.sort()
Expand Down

0 comments on commit 7545931

Please sign in to comment.