Skip to content

Commit

Permalink
Merge branch 'release/0.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
felixhekhorn committed Jun 30, 2020
2 parents 091e11f + 304b27b commit 15ca013
Show file tree
Hide file tree
Showing 12 changed files with 317 additions and 80 deletions.
40 changes: 40 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Reference docs at:
# https://docs.codecov.io/docs/codecovyml-reference

codecov:
require_ci_to_pass: yes

coverage:
precision: 2
round: down
range: "70...100"
status:
project:
default:
# check only master and branches that should be merged directly into
# master
branches:
- master
- develop
- "feature/*"
- "release/*"

parsers:
gcov:
branch_detection:
conditional: yes
loop: yes
method: no
macro: no

comment:
layout: "reach,diff,flags,tree"
behavior: default
require_changes: no
# comments in the pull request are not preventing the merge, and can be
# useful to detect dropping in unit and regression tests since they are
# individually reported [so keep the following option commented]
#branches:
#- master
#- "feature/*"
#- "release/*"
2 changes: 1 addition & 1 deletion .github/workflows/pub_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
# max-parallel: 2
matrix:
python-version: [3.7, 3.8]
python-version: [3.7]
fail-fast: false

steps:
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: deploy

on:
push:
tags:
- '*'

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI

strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]

#if: startsWith(github.event.ref, 'refs/tags')

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@master
- name: Setup Python 🐍
uses: actions/setup-python@master
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
pip install -e .
- name: Package the distribution
run: |
# package the source distribution
python setup.py sdist
# package the pure python wheel
python setup.py bdist_wheel
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_TOKEN }}
8 changes: 8 additions & 0 deletions .github/workflows/pythonapp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ jobs:
# until https://github.com/numba/numba/pull/5660 is confirmed we need to deactivate numba prior running
export NUMBA_DISABLE_JIT=1
pytest
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
flags: unittests
name: codecov-umbrella
fail_ci_if_error: true
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ redefining-builtins-modules=six.moves,future.builtins
expected-line-ending-format=

# Regexp for a line that is allowed to be longer than the limit.
ignore-long-lines=^\s*(# )?<?https?://\S+>?$
ignore-long-lines=^.*(# )?<?https?://\S+>?.*$

# Number of spaces of indent required inside a hanging or continued line.
indent-after-paren=4
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<p align="center">
<a href="https://github.com/N3PDF/eko/actions?query=workflow%3A%22eko%22"><img alt="Tests" src="https://github.com/N3PDF/eko/workflows/eko/badge.svg" /></a>
<a href="https://n3pdf.github.io/eko/"><img alt="Docs" src="https://github.com/N3PDF/eko/workflows/docs/badge.svg"></a>
<a href="https://codecov.io/gh/N3PDF/eko"><img src="https://codecov.io/gh/N3PDF/eko/branch/master/graph/badge.svg" /></a>
<a href="https://www.codefactor.io/repository/github/n3pdf/eko"><img src="https://www.codefactor.io/repository/github/n3pdf/eko/badge" alt="CodeFactor" /></a>
</p>

EKO is a Python module to solve the DGLAP equations in terms of Evolution Kernel Operators in x-space.
Expand Down Expand Up @@ -32,7 +34,7 @@ make html
```

## Citation policy
Please cite our DOI when using our code: <a href="https://doi.org/10.5281/zenodo.3874238"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.3874238.svg" alt="DOI"/></a>
Please cite our DOI when using our code: <a href="https://doi.org/10.5281/zenodo.3874237"><img src="https://zenodo.org/badge/DOI/10.5281/zenodo.3874237.svg" alt="DOI"/></a>

## Contributing
Your feedback is welcome! If you want to report a (possible) bug or want to ask for a new feature, please raise an issue: <a href="https://img.shields.io/github/issues/N3PDF/eko"><img alt="GitHub issues" src="https://img.shields.io/github/issues/N3PDF/eko"/></a>
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
author = 'N3PDF team'

# The short X.Y version
version = '0.3'
version = '0.4'
# The full version, including alpha/beta/rc tags
release = 'v0.3.0'
release = 'v0.4.0'


# -- General configuration ---------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
long_description = fh.read()

setup(name='eko',
version='0.3.0',
version='0.4.0',
description='Evolution Kernel Operator',
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
64 changes: 0 additions & 64 deletions src/eko/anomalous_dimensions/nlo.py

This file was deleted.

66 changes: 58 additions & 8 deletions src/eko/strong_coupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import numpy as np
import scipy
import numba as nb

from eko import t_float
Expand Down Expand Up @@ -145,7 +146,7 @@ class StrongCoupling:
An instance of :class:`~eko.thresholds.ThresholdsConfig`
order: int
Evaluated order of the beta function: ``0`` = LO, ...
method : ["analytic"]
method : ["expanded", "exact"]
Applied method to solve the beta function
Examples
Expand All @@ -161,7 +162,7 @@ class StrongCoupling:
"""

def __init__(
self, consts, alpha_s_ref, scale_ref, thresh, order=0, method="analytic",
self, consts, alpha_s_ref, scale_ref, thresh, order=0, method="expanded",
):
# Sanity checks
if not isinstance(consts, constants.Constants):
Expand All @@ -175,7 +176,7 @@ def __init__(
if order not in [0, 1, 2]:
raise NotImplementedError("a_s beyond NNLO is not implemented")
self._order = order
if method not in ["analytic"]:
if method not in ["expanded", "exact"]:
raise ValueError(f"Unknown method {method}")
self._method = method
self._constants = consts
Expand Down Expand Up @@ -226,9 +227,9 @@ def from_dict(cls, setup, constants, thresholds):
return cls(constants, alpha_ref, q2_alpha, thresholds, order)

# Hidden computation functions
def _compute_analytic(self, as_ref, nf, scale_from, scale_to):
def _compute_expanded(self, as_ref, nf, scale_from, scale_to):
"""
Compute via analytic expression.
Compute via expanded expression.
Parameters
----------
Expand Down Expand Up @@ -276,6 +277,51 @@ def _compute_analytic(self, as_ref, nf, scale_from, scale_to):

return res

def _compute_exact(self, as_ref, nf, scale_from, scale_to):
"""
Compute via RGE.
Parameters
----------
as_ref: t_float
reference alpha_s
nf: int
value of nf for computing alpha_s
scale_from: t_float
reference scale
scale_to : t_float
target scale
Returns
-------
a_s : t_float
strong coupling at target scale :math:`a_s(Q^2)`
"""
# u = beta0 * ln(scale_to/scale_from)
beta0 = beta_0(nf, self._constants.CA, self._constants.CF, self._constants.TF)
u = beta0 * np.log(scale_to / scale_from)
b_vec = [1]
# NLO
if self._order >= 1:
beta1 = beta_1(
nf, self._constants.CA, self._constants.CF, self._constants.TF
)
b1 = beta1 / beta0
b_vec.append(b1)
# NNLO
if self._order >= 2:
beta2 = beta_2(
nf, self._constants.CA, self._constants.CF, self._constants.TF
)
b2 = beta2 / beta0
b_vec.append(b2)

def rge(_t, a, b_vec):
return -(a ** 2) * np.sum([a ** k * b for k, b in enumerate(b_vec)])

res = scipy.integrate.solve_ivp(rge, (0, u), (as_ref,), args=[b_vec])
return res.y[0][-1]

def _compute(self, as_ref, nf, scale_from, scale_to):
"""
Wrapper in order to pass the computation to the corresponding
Expand All @@ -298,8 +344,12 @@ def _compute(self, as_ref, nf, scale_from, scale_to):
strong coupling at target scale :math:`a_s(Q^2)`
"""
# TODO set up a cache system here
# at the moment everything is analytic - and type has been checked in the constructor
return self._compute_analytic(as_ref, nf, scale_from, scale_to)
# at the moment everything is expanded - and type has been checked in the constructor
if self._method == "exact":
as_new = self._compute_exact(as_ref, nf, scale_from, scale_to)
else:
as_new = self._compute_expanded(as_ref, nf, scale_from, scale_to)
return as_new

def a_s(self, scale_to, fact_scale=None):
"""
Expand Down Expand Up @@ -332,7 +382,7 @@ def a_s(self, scale_to, fact_scale=None):
if k < len(area_path) - 1:
next_nf_is_down = area_path[k + 1].nf < area.nf
# q2_to is the threshold value
L = np.log(scale_to / fact_scale) # TODO why fact_scale instead of m2
L = np.log(scale_to / fact_scale)
if next_nf_is_down:
c1 = -4.0 / 3.0 * self._constants.TF * L
# TODO recover color constants
Expand Down
7 changes: 7 additions & 0 deletions tests/test_ekomath.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from numpy.testing import assert_almost_equal
import pytest

from eko import t_complex
from eko import ekomath
Expand Down Expand Up @@ -73,6 +74,12 @@ def test_cern_polygamma():
me = ekomath.cern_polygamma(z, k)
ref = fortran_ref[nk][nz]
assert_almost_equal(me, ref)
# errors
with pytest.raises(NotImplementedError):
_ = ekomath.cern_polygamma(1, 5)
with pytest.raises(ValueError):
_ = ekomath.cern_polygamma(0, 0)



def test_harmonic_S1():
Expand Down
Loading

0 comments on commit 15ca013

Please sign in to comment.