Skip to content

Commit

Permalink
Merge pull request #62 from steven-murray/pypi
Browse files Browse the repository at this point in the history
Add workflow to publish to pypi
  • Loading branch information
steven-murray authored May 21, 2020
2 parents a218f2a + c0a796e commit 0333314
Show file tree
Hide file tree
Showing 49 changed files with 250 additions and 104 deletions.
1 change: 1 addition & 0 deletions .coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/__init__.py":[1,2,3,4,6,7,12,13,14,15,16,17],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/alternatives/__init__.py":[4],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/alternatives/wdm.py":[8,10,11,12,13,14,15,17,23,47,49,63,83,105,107,109,114,129,138,152,162,163,166,184,186,50,51,57,59,61,192,196,212,214,216,220,236,238,240,244,260,262,264,273,284,287,297,313,322,338,349,356,368,370,376,394,401],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/density_field/__init__.py":[4,5,6],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/density_field/transfer.py":[7,8,9,10,11,12,13,15,16,18,23,44,48,49,50,51,52,53,54,55,56,57,58,59,94,110,119,140,149,160,173,182,191,200,209,231,236,243,250,257,270,275,282,287,292,297,305,310,317,326],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/_internals/__init__.py":[3],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/_internals/_cache.py":[8,9,10,13,21,131,138,175,262,176,178,243,245,256,257,260,50,52,112,114,128,180,18,183,187,194,195,196,197,199,201,246,247,250,203,205,206,209,211,213,216,217,218,219,222,132,133,224,229,233,235,188,253,54,57,58,59,60,65,70,74,84,85,87,90,93,251,94,97,98,101,102,103,105,108,110,202,66,67,71,225,236,75,76,79,81],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/density_field/halofit.py":[8,9,10,11,12,13,14,17,106],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/cosmology/__init__.py":[3,4,5],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/cosmology/cosmo.py":[12,14,15,16,17,20,41,43,51,69,90,98,110,45,48,59,60,119,120,49,85,96,62,67,104,105],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/_internals/_framework.py":[3,4,5,11,23,25,27,41,56,74,88,90,93,106,112,113,133,141,152,158,184,185,29,37,38,91,98,99,100,101,103],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/cosmology/growth_factor.py":[8,10,11,12,13,14,15,17,18,20,25,28,30,35,55,56,58,66,106,122,149,165,189,190,205,207,209,216,225,271,298,299,316,318,320,337,354,380,382,383,389,391,430],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/_internals/_utils.py":[1,4,5,13],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/density_field/transfer_models.py":[6,7,8,9,11,12,13,14,16,17,19,23,26,39,41,43,47,64,82,84,86,112,139,141,157,159,161,206,233,320,326,344,346,348,380,393,395,399,478,482,494,541,554,556,564,594,620,621,623,661,684,685,687,712,713,715],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/density_field/filters.py":[4,6,7,8,9,10,11,14,57,59,65,79,95,118,141,159,193,206,220,257,272,273,299,301,305,308,311,314,322,323,349,351,354,357,360,363,367,368,399,400,402,406,409,412,417,422,425,451,452,459,461,463,477,483,489,496,503,512,515,522,528,534],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/mass_function/__init__.py":[3,4],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/mass_function/hmf.py":[6,8,9,10,11,12,13,15,16,17,18,19,20,22,25,66,70,71,72,73,74,75,76,77,78,79,100,109,118,127,141,150,169,185,194,210,219,224,232,246,251,256,261,266,271,284,289,296,328,333,349,356,407,414,421,465,479,493,514],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/mass_function/fitting_functions.py":[6,8,9,10,11,12,13,14,15,18,63,73,74,75,76,77,78,79,80,81,113,137,177,203,204,205,208,210,213,224,305,310,315,320,325,333,339,341,342,344,345,347,122,132,133,349,354,356,357,359,360,361,363,365,366,367,368,369,370,371,372,373,374,375,376,377,378,379,380,85,86,87,88,89,90,91,92,94,95,96,97,98,99,101,104,105,106,107,108,109,110,383,397,405,408,410,413,415,417,418,419,420,422,423,424,425,426,427,428,429,430,431,432,433,434,435,438,439,442,446,454,456,457,459,460,461,463,465,466,467,468,469,470,471,472,473,475,476,477,478,479,480,481,482,483,484,485,486,488,489,490,491,492,493,494,497,507,512,514,516,517,518,520,522,523,524,525,526,527,528,529,530,531,532,533,534,535,536,537,540,547,552,553,554,556,557,558,560,562,563,565,566,567,568,569,570,571,572,573,574,575,576,577,579,580,581,582,583,585,586,587,588,589,590,591,592,593,594,595,596,597,599,600,601,602,603,604,605,608,629,634,635,636,638,639,640,641,643,644,646,660,665,666,667,668,669,670,672,673,674,675,676,677,678,679,680,681,682,683,684,685,686,687,690,699,704,705,706,709,710,712,713,714,716,717,718,719,720,721,722,723,724,725,726,727,728,729,730,731,734,739,740,741,742,744,745,746,748,749,750,751,754,755,756,757,758,759,760,761,762,763,764,765,766,767,768,769,770,771,772,773,774,775,776,777,780,809,844,849,850,852,853,855,856,857,858,859,860,861,862,863,866,867,868,869,870,871,872,873,874,875,876,877,878,879,880,881,884,892,897,898,899,900,901,903,904,905,906,907,908,909,910,911,912,913,914,915,916,917,918,921,926,927,928,930,931,932,934,935,936,937,938,939,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,958,959,960,961,965,970,988,993,994,995,997,998,999,1001,1003,1004,1005,1006,1007,1008,1009,1010,1011,1012,1013,1014,1015,1016,1017,1018,1019,1020,1023,1024,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,1037,1038,1039,1040,1042,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1083,1084,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1105,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,1117,1118,1119,1120,1121,1122,1123,1124,1126,1127,1128,1129,1132,1133,1134,1135,1136,1137,1138,1139,1140,1141,1142,1143,1144,1145,1146,1147,1148,1149,1152,1153,1154,1155,1156,1157,1158,1159,1160,1161,1162,1163,1164,1165,1166,1167,1168,1169,1170,1173,1174,1175,1176,1177,1178,1179,1180,1181,1182,1183,1184,1185,1186,1187,1188,1189,1190,1193,1194,1195,1196,1197,1198,1199,1200,1201,1202,1203,1204,1205,1206,1207,1208,1209,1210,1216,1217,1218,1219,1220,1221,1222,1223,1224,1226,1227,1228,1229,1230,1231,1232,1233,1234,1236,1237,1238,1239,1240,1241,1242,1243,1244,1246,1247,1248,1249,1250,1251,1252,1253,1254,1256,1257,1260,1262,1307,1315,1327,1328,1329,1331,1332,1333,1335,1338,1339,1340,1341,1342,1343,1344,1345,1346,1348,1349,1350,1351,1352,1353,1354,1355,1356,1358,1359,1360,1361,1362,1363,1364,1365,1366,1368,1369,1370,1371,1372,1373,1374,1375,1376,1378,1379,1380,1381,1382,1383,1384,1385,1386,1388,1389,1390,1391,1392,1395,1396,1398,1483,1500,1510,1522,1523,1535,1536,1537,1540,1541,1542,1543,1544,1545,1546,1547,1548,1549,1550,1551,1552,1553,1554,1556,1557,1558,1559,1563,1584,1585,1586,1587,1589,1591,1592,1593,1594,1595,1596,1597,1598,1599,1600,1601,1602,1603,1604,1605,1607,1608,1610,1611,1616,1617,1618,1620,1622,1623,1624,1625,1626,1627,1628,1629,1630,1631,1632,1633,1634,1635,1636,1638,1639,1640,1641,1646,1647,1648,1649,1651,1653,1654,1655,1656,1657,1658,1659,1660,1661,1662,1663,1664,1665,1666,1667,1669,1670,1671,1672,1676],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/halos/__init__.py":[4],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/halos/mass_definitions.py":[5,6,7,8,9,10,13,14,15,16,17,18,19,23,36,38,55,66,86,106,110,199,200,202,205,206,208,210,216,217,219,221,227,231,233,241,242,244,246,265,326,327],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/mass_function/integrate_hmf.py":[3,4,5,6,9,10,13],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/helpers/__init__.py":[3,5],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/helpers/functional.py":[11,13,14,15,18,83,84,86,87,88,89,90,91,92,224],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/helpers/sample.py":[5,6,7,8,11,19,28,71],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/fitting/cli_tools.py":[],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/fitting/fit.py":[],"/home/steven/Documents/Projects/halos/HMF/hmf/src/hmf/fitting/__init__.py":[]}}
19 changes: 18 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,21 @@ exclude =
per-file-ignores =
scripts/hmf: F821
scripts/hmf-fit: F821
select = B,C,E,F,W,T4,B9
select = B,C,E,F,W,T4,B9,D
rst-roles =
class
func
mod
data
const
meth
attr
exc
obj
rst-directives =
note
warning
versionadded
versionchanged
deprecated
seealso
6 changes: 3 additions & 3 deletions .github/workflows/bump_version.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
name: Bump version
name: Bump Version and Deploy
on:
push:
branches:
- master
jobs:
build:
bump-version-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Bump version and push tag
uses: mathieudutour/github-tag-action@v4.2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
github_token: ${{ secrets.bump_version }}
default_bump: false
34 changes: 34 additions & 0 deletions .github/workflows/publish-to-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy

on:
push:
tags:
- v*

jobs:
build-n-publish:
name: To PyPI and TestPyPI
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
# https://github.com/ansible/pylibssh/blob/1e7b17f/.github/workflows/build-test-n-publish.yml#L146-L151
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
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
with:
python-version: 3.7
- name: Install pep517
run: |
python -m pip install pep517 --user
python setup.py --version
- name: Build a binary wheel and a source tarball
run: python -m pep517.build --binary --source --out-dir dist .
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
32 changes: 32 additions & 0 deletions .github/workflows/publish-to-test-pypi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Deploy to Test PyPI

on: push

jobs:
build-n-publish:
name: Deploy
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
# https://github.com/ansible/pylibssh/blob/1e7b17f/.github/workflows/build-test-n-publish.yml#L146-L151
- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
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
with:
python-version: 3.7
- name: Install pep517
run: |
python -m pip install pep517 --user
python setup.py --version
- name: Build a binary wheel and a source tarball
run: python -m pep517.build --binary --source --out-dir dist .
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ repos:
rev: '3.8.1' # pick a git hash / tag to point to
hooks:
- id: flake8
additional_dependencies:
- flake8-rst-docstrings
- repo: https://github.com/psf/black
rev: 19.10b0
hooks:
- id: black
- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.5.1
hooks:
- id: rst-backticks
17 changes: 9 additions & 8 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ of this.

- When using camb for the transfer function, some cosmologies would lead to a segfault (i.e. when Ob0 or Tcmb0 are not
set explicitly). This now raises a helpful error.
- Fixed bug in ordering of iterator in `get_hmf`.
- Fixed bug in ordering of iterator in ``get_hmf``.

**Internals**

Expand All @@ -40,7 +40,8 @@ v3.0.8 [26th March 2020]

**Enhancement**

- Added `get_dependencies` method to _Framework, to enable finding all parameters that a quantity depends on.
- Added ``get_dependencies`` method to _Framework, to enable finding all parameters that
a quantity depends on.
- Growth factor speed-up (thanks to @jlashner)
- Added use_splined_growth argument (thanks to @jlashner)

Expand All @@ -56,10 +57,10 @@ v3.0.5 [23rd April 2019]
------------------------
**Bugfixes**

- Fixed naming of WDM `alter_dndm` to `alter_model` to be consistent.
- Fixed naming of WDM ``alter_dndm`` to ``alter_model`` to be consistent.
- Fixed bug which made CAMB transfer function not pickleable or copyable.
NOTE: the fix is not perfect -- if you provide a custom CAMBparams class
to `transfer_params`, it is not certain that results will be consistent,
to ``transfer_params``, it is not certain that results will be consistent,
as a few of the attributes of this object are not pickleable, and thus
are ignored.

Expand Down Expand Up @@ -200,15 +201,15 @@ are buggy and untested. Don't use these until the next version unless you're cra
**Enhancments**

- Removed nz and z2 from MassFunction. They will return in a later version but better.
- Improved structure for FittingFunction Component, with `cutmask` property defining valid mass range. NOTE: the default
- Improved structure for FittingFunction Component, with ``cutmask`` property defining valid mass range. NOTE: the default
MassFunction is no longer to mask values outside the valid range. In fact, the parameter ``cut_fit`` no longer exists.
One can achieve the effect by accessing a relevant array as dndm[MassFunction.hmf.cutmask]
- Renamed some parameters/quantities for more consistency (esp. M --> m)
- No longer dependent on cosmolopy, but rather uses Astropy (v1.0+)
- `mean_dens` now `mean_density0`, as per Astropy
- ``mean_dens`` now ``mean_density0``, as per Astropy
- Added exception to catch when dndm has many NaN values in it.
- Many more tests
- Made the `cosmo` class pickleable by cutting out a method and using it as a function instead.
- Made the ``cosmo`` class pickleable by cutting out a method and using it as a function instead.
- Added normalise() to Transfer class.
- Updated fit.py extensively, and provided new example config files
- Send arbitrary kwargs to downhill solver
Expand Down Expand Up @@ -444,7 +445,7 @@ v1.8.0 [February 2, 2015]

- A few more documentation updates (especially tools.py)
- Removed new_k_bounds function from tools.py
- Added `w` parameter to cosmolopy dictionary in `cosmo.py`
- Added ``w`` parameter to cosmolopy dictionary in ``cosmo.py``
- Changed cosmography significantly to use cosmolopy in general
- Generally tidied up some of the update mechanisms.
- **API CHANGE**: cosmography.py no longer exists -- I've chosen to utilise
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ advice to help make your work on hmf more useful and rewarding.

* Use issue labels to guide you
- Unsure where to begin contributing to hmf? You can start by looking through issues
labeled `good first issue` and `help wanted` issues.
labeled ``good first issue`` and ``help wanted`` issues.
* Pick a subject area that you care about, that you are familiar with, or that you want
to learn about
- There are many aspects to hmf, from cosmography, through cosmological initial
Expand Down Expand Up @@ -95,9 +95,9 @@ Getting started
5. If you like the change and think the project could use it:
- If you're fixing a bug, include a new test that breaks as a result of the bug (if possible).
- Ensure that all your new code is covered by tests and that the existing tests pass.
Tests can be run by running `pytest` in the top level ``hmf`` directory.
Tests can be run by running ``pytest`` in the top level ``hmf`` directory.
- Ensure that you fully document any new features via docstrings, and potentially
as a new tutorial in the `docs/` directory.
as a new tutorial in the ``docs/`` directory.
6. Make a Pull Request from your fork/branch.

Code review process
Expand Down
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hmf
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black

`hmf` is a python application that provides a flexible and simple way to calculate the
``hmf`` is a python application that provides a flexible and simple way to calculate the
Halo Mass Function for a range of varying parameters. It is also the backend to
`HMFcalc <http://hmf.icrar.org>`_, the online HMF calculator.

Expand Down Expand Up @@ -55,7 +55,7 @@ From v3.1, ``hmf`` supports Python 3.6+, and has dropped support for Python 2.

Quickstart
----------
Once you have `hmf` installed, you can quickly generate a mass function
Once you have ``hmf`` installed, you can quickly generate a mass function
by opening an interpreter (e.g. IPython/Jupyter) and doing::

>>> from hmf import MassFunction
Expand All @@ -64,7 +64,7 @@ by opening an interpreter (e.g. IPython/Jupyter) and doing::

Note that all parameters have (what I consider reasonable) defaults. In particular,
this will return a Tinker (2008) mass function between
:math:`10^{10}-10^{15} M_\odot`, at :math:`z=0` for the default PLANCK15 cosmology.
10^10 and 10^15 solar masses, at z=0 for the default PLANCK15 cosmology.
Nevertheless, there are several parameters which can be input, either cosmological
or otherwise. The best way to see these is to do::

Expand All @@ -75,13 +75,13 @@ We can also check which parameters have been set in our "default" instance::
>>> hmf.parameter_values

To change the parameters (cosmological or otherwise), one should use the
`update()` method, if a MassFunction() object already exists. For example::
``update()`` method, if a MassFunction() object already exists. For example::

>>> hmf = MassFunction()
>>> hmf.update(cosmo_params={"Ob0": 0.05}, z=10) #update baryon density and redshift
>>> cumulative_mass_func = hmf.ngtm

For a more involved introduction to `hmf`, check out the `tutorials <tutorials.html>`_,
For a more involved introduction to ``hmf``, check out the `tutorials <tutorials.html>`_,
which are currently under construction, or the `API docs <api.html>`_.

Versioning
Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.. hmf documentation master file, created by
sphinx-quickstart on Mon Dec 2 10:40:08 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
contain the root "toctree" directive.
.. include:: ../README.rst

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
[build-system]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
local_scheme = "no-local-version"
4 changes: 2 additions & 2 deletions scripts/hmf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import sys
import os
import traceback

import hmf
from src import hmf
import numpy as np
from argparse import ArgumentParser
from argparse import RawDescriptionHelpFormatter
Expand Down Expand Up @@ -101,7 +101,7 @@ USAGE
help="the mass range and intervals, min max step [default: %s %s %s]" %
(np.log10(h.M[0]), np.log10(h.M[-1]), np.log10(h.M[1]) - np.log10(h.M[0])))
hmfargs.add_argument("--mf-fit", nargs="*", choices=hmf.Fits.mf_fits + ["all"],
help="fitting function(s) to use. 'all' uses all of them [default: %s]" % h.mf_fit)
help="fitting function(s) to use. 'all' uses all of them [default: %s]" % h.mf_fit)
hmfargs.add_argument("--delta-h", nargs="*", type=float,
help="overdensity of halo w.r.t delta_wrt [default %s]" % h.delta_wrt)
hmfargs.add_argument("--delta-wrt", choices=["mean", "crit"],
Expand Down
9 changes: 1 addition & 8 deletions scripts/hmf-fit
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@ from argparse import ArgumentParser
from argparse import RawDescriptionHelpFormatter
from ConfigParser import SafeConfigParser as cfg
cfg.optionxform = str
import time
import errno
from os.path import join
from numbers import Number
import pickle
from emcee import autocorr
from importlib import import_module
from hmf.fitting import cli_tools as cli
from fitting import cli_tools as cli

__all__ = []
__version__ = 0.5
Expand Down
Loading

0 comments on commit 0333314

Please sign in to comment.