Skip to content

Commit

Permalink
Merge sherpa#696 (DougBurke) - Support python 3.8
Browse files Browse the repository at this point in the history
Support python 3.8
  • Loading branch information
wmclaugh committed Feb 18, 2020
2 parents 8072c77 + 9a488e1 commit 370241d
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 222 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ matrix:
# We need to use TEST=none to remove the test-data submodule.
# This used to be the Python 2.7 build (so used an old NumPy) but it has now
# been bumped to "nearly latest" versions
- env: INSTALL_TYPE=develop TEST=none NUMPYVER="1.17" TRAVIS_PYTHON_VERSION="3.7"
- env: INSTALL_TYPE=develop TEST=none NUMPYVER="1.17" TRAVIS_PYTHON_VERSION="3.8"
# Full build (including ds9 and xspec), Python 3.5, setup.py develop, astropy, matplotlib 2
- env: XSPECVER="12.10.1b" NUMPYVER="1.11" FITS="astropy" INSTALL_TYPE=develop TEST=submodule MATPLOTLIBVER=2 TRAVIS_PYTHON_VERSION="3.5"
sudo: required
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ documentation, and should be read if the following is not sufficient.
It is strongly recommended that some form of *virtual environment* is
used with Sherpa.

Sherpa is tested against Python versions 3.5, 3.6, and 3.7. It is
expected that it will work with Python 3.8 but testing has been
limited.

The last version of Sherpa which supported Python 2.7 is
[Sherpa 4.11.1](https://doi.org/10.5281/zenodo.3358134).

Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ Sherpa is released under the
`GNU General Public License v3.0
<https://github.com/sherpa/sherpa/blob/master/LICENSE>`_,
and is compatible with Python versions 3.5, 3.6, and 3.7.
It is expected that it will work with Python 3.8 but testing has been
limited.
Information on recent releases and citation information for
Sherpa is available using the Digital Object Identifier (DOI)
`10.5281/zenodo.593753 <https://doi.org/10.5281/zenodo.593753>`_.
Expand Down
3 changes: 2 additions & 1 deletion docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Requirements

Sherpa has the following requirements:

* Python 3.5, 3.6, or 3.7
* Python 3.5, 3.6, or 3.7 (there has been limited testing with
Python 3.8)
* NumPy (the exact lower limit has not been determined,
but it is likely to be 1.7.0 or later)
* Linux or OS-X (patches to add Windows support are welcome)
Expand Down
14 changes: 7 additions & 7 deletions sherpa/astro/data.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2008, 2015, 2016, 2017, 2018, 2019
# Copyright (C) 2008, 2015, 2016, 2017, 2018, 2019, 2020
# Smithsonian Astrophysical Observatory
#
#
Expand Down Expand Up @@ -2597,7 +2597,7 @@ def _world_to_physical(self, x0=None, x1=None):
def get_logical(self):
coord = self.coord
x0, x1 = self.get_indep()
if coord is not 'logical':
if coord != 'logical':
x0 = x0.copy()
x1 = x1.copy()
x0, x1 = getattr(self, '_' + coord + '_to_logical')(x0, x1)
Expand All @@ -2606,7 +2606,7 @@ def get_logical(self):
def get_physical(self):
coord = self.coord
x0, x1 = self.get_indep()
if coord is not 'physical':
if coord != 'physical':
x0 = x0.copy()
x1 = x1.copy()
x0, x1 = getattr(self, '_' + coord + '_to_physical')(x0, x1)
Expand All @@ -2615,7 +2615,7 @@ def get_physical(self):
def get_world(self):
coord = self.coord
x0, x1 = self.get_indep()
if coord is not 'world':
if coord != 'world':
x0 = x0.copy()
x1 = x1.copy()
x0, x1 = getattr(self, '_' + coord + '_to_world')(x0, x1)
Expand Down Expand Up @@ -2808,7 +2808,7 @@ def _init_data_space(self, filter, *data):
def get_logical(self):
coord = self.coord
x0lo, x1lo, x0hi, x1hi = self.get_indep()
if coord is not 'logical':
if coord != 'logical':
x0lo = x0lo.copy()
x1lo = x1lo.copy()
convert = getattr(self, '_' + coord + '_to_logical')
Expand All @@ -2823,7 +2823,7 @@ def get_logical(self):
def get_physical(self):
coord = self.coord
x0lo, x1lo, x0hi, x1hi = self.get_indep()
if coord is not 'physical':
if coord != 'physical':
x0lo = x0lo.copy()
x1lo = x1lo.copy()
convert = getattr(self, '_' + coord + '_to_physical')
Expand All @@ -2838,7 +2838,7 @@ def get_physical(self):
def get_world(self):
coord = self.coord
x0lo, x1lo, x0hi, x1hi = self.get_indep()
if coord is not 'world':
if coord != 'world':
x0lo = x0lo.copy()
x1lo = x1lo.copy()
convert = getattr(self, '_' + coord + '_to_world')
Expand Down
13 changes: 10 additions & 3 deletions sherpa/instrument.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import division
#
# Copyright (C) 2008, 2016, 2018, 2019 Smithsonian Astrophysical Observatory
# Copyright (C) 2008, 2016, 2018, 2019, 2020
# Smithsonian Astrophysical Observatory
#
#
# This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -296,14 +297,20 @@ def init_kernel(self, kernel):
# be centered on brightest pixel.
brightPixel = list(numpy.where(kernel == kernel.max())).pop()

origin = None
# if more than one pixel qualifies as brightest, such as const2D
# use the middle of subkernel -- assumes the user provided center at
# time of kernel extraction, so that should be middle of subkernel.
origin = None
if (not numpy.isscalar(brightPixel)) and len(brightPixel) != 1:
origin = set_origin(kshape)
else:
origin = set_origin(kshape, brightPixel)
# brightPixel is a NumPy index (int64) which - as of NumPy 1.18
# and Python 3.8 - causes a TypeError with the message
# "only integer scalar arrays can be converted to a scalar index"
# to be thrown here if sent directly to set_origin. So
# we convert to a Python integer type.
#
origin = set_origin(kshape, int(brightPixel))

if self.origin is None:
self.origin = origin
Expand Down

0 comments on commit 370241d

Please sign in to comment.