Commit c919ea11 authored by Ole Streicher's avatar Ole Streicher

New upstream version 0.10

parent 3843d22b
.. _gammapy_0p11_release:
0.11 (unreleased)
-----------------
Summary
+++++++
- The Gammapy v0.11 release is planned for March 2019.
Pull requests
+++++++++++++
This list is incomplete. Small improvements and bug fixes are not listed here.
See the complete `Gammapy 0.11 merged pull requests list on Github <https://github.com/gammapy/gammapy/pulls?q=is%3Apr+milestone%3A0.11+is%3Aclosed>`__.
.. _gammapy_0p10_release:
0.10 (2019-01-28)
-----------------
Summary
+++++++
- Released on Jan 28, 2019 (`Gammapy 0.10 on PyPI <https://pypi.org/project/gammapy/0.10>`__)
- 7 contributors
- 2 months of work
- 30 pull requests (not all listed below)
**What's new?**
Gammapy v0.10 is a small release. An option to have a background model with
parameters such as normalisation and spectral tilt was added. The curated
example datasets were improved, the ``gammapy download`` script and access of
example data from the tutorials via the ``GAMMAPY_DATA`` environment variable
were improved. A notebook ``image_analysis`` showing how to use Gammapy to make
and model 2D images for a given given energy band, as a special case of the
existing 3D map-based analysis was added.
A lot of the work recently went into planning the work ahead for 2019. See the
`Gammapy 1.0 roadmap`_ and the `PIG 7 - models`_ as well as `PIG 8 - datasets`_
and get in touch if you want to contribute. We plan to ship a first version of
the new datasets API in Gammapy v0.11 in March 2019.
Gammapy v0.10 is the last Gammapy release that supports Python 2 (see `PIG 3`_).
If you have any questions or need help to install Python 3, or to update your
scripts and notebooks to work in Python 3, please contact us any time on the
Gammapy mailing list or Slack. We apologise for the disruption and are happy to
help with this transition.
pyyaml is now a core dependency of Gammapy, i.e. will always be automatically
installed as a dependency. Instructions for installing Gammapy on Windows, and
continuous testing on Windows were improved.
.. _PIG 3: https://github.com/gammapy/gammapy/pull/1278
.. _PIG 7 - models: https://github.com/gammapy/gammapy/pull/1971
.. _PIG 8 - datasets: https://github.com/gammapy/gammapy/pull/1986
**Contributors:**
- Atreyee Sinha
- Axel Donath
- Christoph Deil
- David Fidalgo
- José Enrique Ruiz
- Lars Mohrmann
- Régis Terrier
Pull requests
+++++++++++++
This list is incomplete. Small improvements and bug fixes are not listed here.
See the complete `Gammapy 0.10 merged pull requests list on Github <https://github.com/gammapy/gammapy/pulls?q=is%3Apr+milestone%3A0.10+is%3Aclosed>`__.
- [#2001] Use GAMMAPY_DATA everywhere / remove GAMMAPY_EXTRA (José Enrique Ruiz)
- [#2000] Fix cta_simulation notebook, use CTA prod 3 IRFs (Régis Terrier)
- [#1998] Fix SensitivityEstimator after IRF API change (Régis Terrier)
- [#1995] Add pyyaml as core dependency (Christoph Deil)
- [#1994] Unify Fermi-LAT datasets used in Gammapy (Axel Donath)
- [#1991] Improve SourceCatalogObjectHGPS spatial model (Axel Donath)
- [#1990] Add background model for map fit (Atreyee Sinha)
- [#1989] Add tutorial notebook for 2D image analysis (Atreyee Sinha)
- [#1988] Improve gammapy download (José Enrique Ruiz)
- [#1979] Improve output units of spectral models (Axel Donath)
- [#1975] Improve EnergyDependentTablePSF evaluate methods (Axel Donath)
- [#1969] Improve ObservationStats (Lars Mohrmann)
- [#1966] Add ObservationFilter select methods (David Fidalgo)
- [#1962] Change data access in notebooks to GAMMAPY_DATA (José Enrique Ruiz)
- [#1951] Add keepdim option for maps (Atreyee Sinha)
.. _gammapy_0p9_release:
0.9 (2018-11-29)
......
Metadata-Version: 2.1
Name: gammapy
Version: 0.9
Version: 0.10
Summary: A Python package for gamma-ray astronomy
Home-page: https://github.com/gammapy/gammapy
Author: The Gammapy developers
......@@ -35,6 +35,6 @@ Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Astronomy
Classifier: Development Status :: 3 - Alpha
Provides-Extra: analysis
Provides-Extra: test
Provides-Extra: plotting
Provides-Extra: analysis
......@@ -12,7 +12,7 @@ A Python Package for Gamma-ray Astronomy.
:target: http://www.astropy.org/
.. image:: http://mybinder.org/badge.svg
:target: https://mybinder.org/v2/gh/gammapy/gammapy/11d0142234f8be6552466c2d2cf70b9dc5ce46af?urlpath=lab/tree/first_steps.ipynb
:target: https://mybinder.org/v2/gh/gammapy/gammapy/78c75d572e5d3e73fbd59d7c02296966d24eb00e?urlpath=lab/tree/first_steps.ipynb
Status shields
++++++++++++++
......@@ -27,10 +27,6 @@ Status shields
:target: https://travis-ci.org/gammapy/gammapy
:alt: Test Status Travis-CI
* .. image:: https://ci.appveyor.com/api/projects/status/duo8wgufg35b7cga?svg=true
:target: https://ci.appveyor.com/project/cdeil/gammapy/branch/master
:alt: Test Status Appveyor
* .. image:: https://img.shields.io/coveralls/gammapy/gammapy.svg
:target: https://coveralls.io/r/gammapy/gammapy
:alt: Code Coverage
......
......@@ -38,7 +38,6 @@ latest version of this module.
import contextlib
import errno
import imp
import io
import locale
import os
......@@ -46,6 +45,13 @@ import re
import subprocess as sp
import sys
__minimum_python_version__ = (2, 7)
if sys.version_info < __minimum_python_version__:
print("ERROR: Python {} or later is required by astropy-helpers".format(
__minimum_python_version__))
sys.exit(1)
try:
from ConfigParser import ConfigParser, RawConfigParser
except ImportError:
......@@ -66,35 +72,15 @@ else:
# issues with either missing or misbehaving pacakges (including making sure
# setuptools itself is installed):
# Check that setuptools 1.0 or later is present
from distutils.version import LooseVersion
# Some pre-setuptools checks to ensure that either distribute or setuptools >=
# 0.7 is used (over pre-distribute setuptools) if it is available on the path;
# otherwise the latest setuptools will be downloaded and bootstrapped with
# ``ez_setup.py``. This used to be included in a separate file called
# setuptools_bootstrap.py; but it was combined into ah_bootstrap.py
try:
import pkg_resources
_setuptools_req = pkg_resources.Requirement.parse('setuptools>=0.7')
# This may raise a DistributionNotFound in which case no version of
# setuptools or distribute is properly installed
_setuptools = pkg_resources.get_distribution('setuptools')
if _setuptools not in _setuptools_req:
# Older version of setuptools; check if we have distribute; again if
# this results in DistributionNotFound we want to give up
_distribute = pkg_resources.get_distribution('distribute')
if _setuptools != _distribute:
# It's possible on some pathological systems to have an old version
# of setuptools and distribute on sys.path simultaneously; make
# sure distribute is the one that's used
sys.path.insert(1, _distribute.location)
_distribute.activate()
imp.reload(pkg_resources)
except:
# There are several types of exceptions that can occur here; if all else
# fails bootstrap and use the bootstrapped version
from ez_setup import use_setuptools
use_setuptools()
import setuptools
assert LooseVersion(setuptools.__version__) >= LooseVersion('1.0')
except (ImportError, AssertionError):
print("ERROR: setuptools 1.0 or later is required by astropy-helpers")
sys.exit(1)
# typing as a dependency for 1.6.1+ Sphinx causes issues when imported after
# initializing submodule with ah_boostrap.py
......
......@@ -15,10 +15,12 @@ env:
- PYTHON_VERSION=2.7 EVENT_TYPE='push pull_request cron'
- PYTHON_VERSION=3.4 SETUPTOOLS_VERSION=20
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.6 SETUPTOOLS_VERSION=dev DEBUG=True
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.7 SETUPTOOLS_VERSION=dev DEBUG=True
CONDA_DEPENDENCIES='sphinx cython numpy six pytest-cov'
EVENT_TYPE='push pull_request cron'
global:
- CONDA_DEPENDENCIES="setuptools sphinx cython numpy"
- PIP_DEPENDENCIES="coveralls pytest-cov"
......@@ -39,6 +41,10 @@ matrix:
env: PYTHON_VERSION=3.5 SPHINX_VERSION='<1.5' SETUPTOOLS_VERSION=27
- os: linux
env: PYTHON_VERSION=3.6 SPHINX_VERSION='<1.6' SETUPTOOLS_VERSION=27
# Test without installing numpy beforehand to make sure everything works
# without assuming numpy is already installed
- os: linux
env: PYTHON_VERSION=3.6 CONDA_DEPENDENCIES='sphinx cython six pytest-cov'
# Uncomment the following if there are issues in setuptools that we
# can't work around quickly - otherwise leave uncommented so that
......@@ -49,6 +55,7 @@ matrix:
# CONDA_DEPENDENCIES='sphinx cython numpy six pytest-cov'
# EVENT_TYPE='push pull_request cron'
install:
- git clone git://github.com/astropy/ci-helpers.git
......
astropy-helpers Changelog
*************************
2.0.8 (2018-12-04)
------------------
- Fixed compatibility with Sphinx 1.8+. [#428]
- Fixed error that occurs when installing a package in an environment where
``numpy`` is not already installed. [#404]
- Updated bundled version of sphinx-automodapi to v0.9. [#422]
- Updated bundled version of numpydoc to v0.8.0. [#423]
2.0.7 (2018-06-01)
------------------
- Removing ez_setup.py file and requiring setuptools 1.0 or later. [#384]
2.0.6 (2018-02-24)
------------------
......
......@@ -3,7 +3,6 @@ include CHANGES.rst
include LICENSE.rst
recursive-include licenses *
include ez_setup.py
include ah_bootstrap.py
exclude *.pyc *.o
......
......@@ -38,7 +38,6 @@ latest version of this module.
import contextlib
import errno
import imp
import io
import locale
import os
......@@ -46,6 +45,13 @@ import re
import subprocess as sp
import sys
__minimum_python_version__ = (2, 7)
if sys.version_info < __minimum_python_version__:
print("ERROR: Python {} or later is required by astropy-helpers".format(
__minimum_python_version__))
sys.exit(1)
try:
from ConfigParser import ConfigParser, RawConfigParser
except ImportError:
......@@ -66,35 +72,15 @@ else:
# issues with either missing or misbehaving pacakges (including making sure
# setuptools itself is installed):
# Check that setuptools 1.0 or later is present
from distutils.version import LooseVersion
# Some pre-setuptools checks to ensure that either distribute or setuptools >=
# 0.7 is used (over pre-distribute setuptools) if it is available on the path;
# otherwise the latest setuptools will be downloaded and bootstrapped with
# ``ez_setup.py``. This used to be included in a separate file called
# setuptools_bootstrap.py; but it was combined into ah_bootstrap.py
try:
import pkg_resources
_setuptools_req = pkg_resources.Requirement.parse('setuptools>=0.7')
# This may raise a DistributionNotFound in which case no version of
# setuptools or distribute is properly installed
_setuptools = pkg_resources.get_distribution('setuptools')
if _setuptools not in _setuptools_req:
# Older version of setuptools; check if we have distribute; again if
# this results in DistributionNotFound we want to give up
_distribute = pkg_resources.get_distribution('distribute')
if _setuptools != _distribute:
# It's possible on some pathological systems to have an old version
# of setuptools and distribute on sys.path simultaneously; make
# sure distribute is the one that's used
sys.path.insert(1, _distribute.location)
_distribute.activate()
imp.reload(pkg_resources)
except:
# There are several types of exceptions that can occur here; if all else
# fails bootstrap and use the bootstrapped version
from ez_setup import use_setuptools
use_setuptools()
import setuptools
assert LooseVersion(setuptools.__version__) >= LooseVersion('1.0')
except (ImportError, AssertionError):
print("ERROR: setuptools 1.0 or later is required by astropy-helpers")
sys.exit(1)
# typing as a dependency for 1.6.1+ Sphinx causes issues when imported after
# initializing submodule with ah_boostrap.py
......
......@@ -20,6 +20,7 @@ environment:
- PYTHON_VERSION: "3.4"
- PYTHON_VERSION: "3.5"
- PYTHON_VERSION: "3.6"
- PYTHON_VERSION: "3.7"
platform:
-x64
......
......@@ -289,9 +289,11 @@ def generate_build_ext_command(packagename, release):
def run(self):
# For extensions that require 'numpy' in their include dirs,
# replace 'numpy' with the actual paths
np_include = get_numpy_include_path()
np_include = None
for extension in self.extensions:
if 'numpy' in extension.include_dirs:
if np_include is None:
np_include = get_numpy_include_path()
idx = extension.include_dirs.index('numpy')
extension.include_dirs.insert(idx, np_include)
extension.include_dirs.remove('numpy')
......
......@@ -71,6 +71,15 @@ class AstropyBuildDocs(SphinxBuildDoc):
def finalize_options(self):
# We need to make sure this is set before finalize_options otherwise
# the default is set to build/sphinx. We also need the absolute path
# as in some Sphinx versions, the path is otherwise interpreted as
# docs/docs/_build.
if self.build_dir is None:
self.build_dir = os.path.abspath('docs/_build')
else:
self.build_dir = os.path.abspath(self.build_dir)
SphinxBuildDoc.finalize_options(self)
# Clear out previous sphinx builds, if requested
......
......@@ -133,3 +133,6 @@ def setup(app):
app.add_autodocumenter(AttributeDocumenter)
finally:
app.config.suppress_warnings = suppress_warnigns_orig
return {'parallel_read_safe': True,
'parallel_write_safe': True}
......@@ -421,3 +421,6 @@ def setup(app):
app.add_config_value('automodapi_toctreedirnm', 'api', True)
app.add_config_value('automodapi_writereprocessed', False, True)
return {'parallel_read_safe': True,
'parallel_write_safe': True}
......@@ -83,6 +83,7 @@ package. It accepts no options.
.. _sphinx.ext.inheritance_diagram: http://sphinx-doc.org/latest/ext/inheritance.html
"""
import abc
import inspect
import os
import re
......@@ -96,6 +97,10 @@ from docutils.parsers.rst.directives import flag
from .utils import find_mod_objs, cleanup_whitespace
__all__ = ['Automoddiagram', 'Automodsumm', 'automodsumm_to_autosummary_lines',
'generate_automodsumm_docs', 'process_automodsumm_generation']
SPHINX_LT_16 = LooseVersion(__version__) < LooseVersion('1.6')
SPHINX_LT_17 = LooseVersion(__version__) < LooseVersion('1.7')
......@@ -266,7 +271,7 @@ def process_automodsumm_generation(app):
suffix = os.path.splitext(sfn)[1]
if len(lines) > 0:
generate_automodsumm_docs(
lines, sfn, app=app, builder=app.builder, warn=app.warn, info=app.info,
lines, sfn, app=app, builder=app.builder,
suffix=suffix, base_path=app.srcdir,
inherited_members=app.config.automodsumm_inherited_members)
......@@ -401,8 +406,8 @@ def automodsumm_to_autosummary_lines(fn, app):
return newlines
def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst', warn=None,
info=None, base_path=None, builder=None,
def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst',
base_path=None, builder=None,
template_dir=None,
inherited_members=False):
"""
......@@ -415,7 +420,6 @@ def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst', warn=None,
from sphinx.jinja2glue import BuiltinTemplateLoader
from sphinx.ext.autosummary import import_by_name, get_documenter
from sphinx.ext.autosummary.generate import (_simple_info, _simple_warn)
from sphinx.util.osutil import ensuredir
from sphinx.util.inspect import safe_getattr
from jinja2 import FileSystemLoader, TemplateNotFound
......@@ -423,10 +427,14 @@ def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst', warn=None,
from .utils import find_autosummary_in_lines_for_automodsumm as find_autosummary_in_lines
if info is None:
info = _simple_info
if warn is None:
warn = _simple_warn
if SPHINX_LT_16:
info = app.info
warn = app.warn
else:
from sphinx.util import logging
logger = logging.getLogger(__name__)
info = logger.info
warn = logger.warning
# info('[automodsumm] generating automodsumm for: ' + srcfn)
......@@ -544,7 +552,18 @@ def generate_automodsumm_docs(lines, srcfn, app=None, suffix='.rst', warn=None,
if include_base:
names = dir(obj)
else:
if hasattr(obj, '__slots__'):
# Classes deriving from an ABC using the `abc` module will
# have an empty `__slots__` attribute in Python 3, unless
# other slots were declared along the inheritance chain. If
# the ABC-derived class has empty slots, we'll use the
# class `__dict__` instead.
declares_slots = (
hasattr(obj, '__slots__') and
not (type(obj) is abc.ABCMeta and
len(obj.__slots__) == 0)
)
if declares_slots:
names = tuple(getattr(obj, '__slots__'))
else:
names = getattr(obj, '__dict__').keys()
......@@ -662,3 +681,6 @@ def setup(app):
app.add_config_value('automodsumm_writereprocessed', False, True)
app.add_config_value('automodsumm_inherited_members', False, 'env')
return {'parallel_read_safe': True,
'parallel_write_safe': True}
......@@ -25,10 +25,20 @@ def process_docstring(app, what, name, obj, options, lines):
mapping[obj.__module__ + '.' + obj.__name__] = name
def merge_mapping(app, env, docnames, env_other):
if not hasattr(env_other, 'class_name_mapping'):
return
if not hasattr(env, 'class_name_mapping'):
env.class_name_mapping = {}
env.class_name_mapping.update(env_other.class_name_mapping)
def missing_reference_handler(app, env, node, contnode):
if not hasattr(env, 'class_name_mapping'):
env.class_name_mapping = {}
mapping = env.class_name_mapping
reftype = node['reftype']
reftarget = node['reftarget']
if reftype in ('obj', 'class', 'exc', 'meth'):
......@@ -88,5 +98,10 @@ def missing_reference_handler(app, env, node, contnode):
def setup(app):
app.connect('autodoc-process-docstring', process_docstring)
app.connect('missing-reference', missing_reference_handler)
app.connect('env-merge-info', merge_mapping)
return {'parallel_read_safe': True,
'parallel_write_safe': True}
from __future__ import division, absolute_import, print_function
__version__ = '0.7.0'
__version__ = '0.8.0'
from .numpydoc import setup
def setup(app, *args, **kwargs):
from .numpydoc import setup
return setup(app, *args, **kwargs)
......@@ -13,6 +13,15 @@ import copy
import sys
def strip_blank_lines(l):
"Remove leading and trailing blank lines from a list of lines"
while l and not l[0].strip():
del l[0]
while l and not l[-1].strip():
del l[-1]
return l
class Reader(object):
"""A line-based string reader.
......@@ -98,6 +107,12 @@ class ParseError(Exception):
class NumpyDocString(collections.Mapping):
"""Parses a numpydoc string to an abstract representation
Instances define a mapping from section title to structured data.
"""
sections = {
'Signature': '',
'Summary': [''],
......@@ -136,7 +151,7 @@ class NumpyDocString(collections.Mapping):
def __setitem__(self, key, val):
if key not in self._parsed_data:
warn("Unknown section %s" % key)
self._error_location("Unknown section %s" % key, error=False)
else:
self._parsed_data[key] = val
......@@ -208,12 +223,14 @@ class NumpyDocString(collections.Mapping):
desc = r.read_to_next_unindented_line()
desc = dedent_lines(desc)
desc = strip_blank_lines(desc)
params.append((arg_name, arg_type, desc))
return params
_name_rgx = re.compile(r"^\s*(:(?P<role>\w+):`(?P<name>[a-zA-Z0-9_.-]+)`|"
_name_rgx = re.compile(r"^\s*(:(?P<role>\w+):"
r"`(?P<name>(?:~\w+\.)?[a-zA-Z0-9_.-]+)`|"
r" (?P<name2>[a-zA-Z0-9_.-]+))\s*", re.X)
def _parse_see_also(self, content):
......@@ -331,19 +348,8 @@ class NumpyDocString(collections.Mapping):
section = (s.capitalize() for s in section.split(' '))
section = ' '.join(section)
if self.get(section):
if hasattr(self, '_obj'):
# we know where the docs came from:
try:
filename = inspect.getsourcefile(self._obj)
except TypeError:
filename = None
msg = ("The section %s appears twice in "
"the docstring of %s in %s." %
(section, self._obj, filename))
raise ValueError(msg)
else:
msg = ("The section %s appears twice" % section)
raise ValueError(msg)
self._error_location("The section %s appears twice"
% section)
if section in ('Parameters', 'Returns', 'Yields', 'Raises',
'Warns', 'Other Parameters', 'Attributes',
......@@ -356,6 +362,20 @@ class NumpyDocString(collections.Mapping):
else:
self[section] = content
def _error_location(self, msg, error=True):
if hasattr(self, '_obj'):
# we know where the docs came from:
try:
filename = inspect.getsourcefile(self._obj)
except TypeError:
filename = None
msg = msg + (" in the docstring of %s in %s."
% (self._obj, filename))
if error:
raise ValueError(msg)
else:
warn(msg)
# string conversion routines
def _str_header(self, name, symbol='-'):
......@@ -394,7 +414,8 @@ class NumpyDocString(collections.Mapping):
out += ['%s : %s' % (param, param_type)]
else:
out += [param]
out += self._str_indent(desc)
if desc and ''.join(desc).strip():
out += self._str_indent(desc)
out += ['']
return out
......@@ -592,7 +613,7 @@ class ClassDoc(NumpyDocString):
return [name for name, func in inspect.getmembers(self._cls)
if (not name.startswith('_') and
(func is None or isinstance(func, property) or
inspect.isgetsetdescriptor(func))
inspect.isdatadescriptor(func))
and self._is_show_member(name))]
def _is_show_member(self, name):
......
......@@ -21,6 +21,9 @@ else:
sixu = lambda s: unicode(s, 'unicode_escape')
IMPORT_MATPLOTLIB_RE = r'\b(import +matplotlib|from +matplotlib +import)\b'
class SphinxDocString(NumpyDocString):
def __init__(self, docstring, config={}):
NumpyDocString.__init__(self, docstring, config=config)
......@@ -28,6 +31,7 @@ class SphinxDocString(NumpyDocString):
def load_config(self, config):
self.use_plots = config.get('use_plots', False)
self.use_blockquotes = config.get('use_blockquotes', False)
self.class_members_toctree = config.get('class_members_toctree', True)
self.template = config.get('template', None)
if self.template is None:
......@@ -63,37 +67,147 @@ class SphinxDocString(NumpyDocString):
return self['Extended Summary'] + ['']
def _str_returns(self, name='Returns'):
typed_fmt = '**%s** : %s'
untyped_fmt = '**%s**'