Skip to content

Commit

Permalink
JP-2201: Fix test collection failure with astropy main branch (#6215)
Browse files Browse the repository at this point in the history
* Initial fixes for issue #6176.

* Added entry to change log.
  • Loading branch information
WilliamJamieson authored Jul 15, 2021
1 parent 8870bdc commit 8a8f148
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ assign_wcs
- Open the specwcs reference file for WFSS modes using the ``with`` context
manger. [#6160]

associations
------------

- Fix bug causing ``pytest`` to encounter an error in test collection when
running with recent commits to ``astropy`` main (``5.0.dev``). [#6176]

cube_build
----------

Expand Down
33 changes: 23 additions & 10 deletions jwst/associations/pool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""
Association Pools
"""

from pkg_resources import parse_version, get_distribution

from astropy.io.ascii import convert_numpy

from astropy.table import Table
Expand Down Expand Up @@ -50,7 +53,7 @@ def read(
table = super(AssociationPool, cls).read(
filename, delimiter=delimiter,
format=format,
converters=_ConvertToStr(), **kwargs
converters=convert_to_str, **kwargs
)

# If anything has been masked, just fill
Expand Down Expand Up @@ -101,17 +104,27 @@ def write(self, *args, **kwargs):
)


class _ConvertToStr(dict):
def __getitem__(self, k):
func, type_ = convert_numpy(str)
def _convert_to_str():
func, type_ = convert_numpy(str)

def convert_func(vals):
"""Lowercase the conversion"""
results = func(vals)
results = [result.lower() for result in results]
return results

def convert_func(vals):
"""Lowercase the conversion"""
results = func(vals)
results = [result.lower() for result in results]
return results
return [(convert_func, type_)]

return [(convert_func, type_)]

class _ConvertToStr(dict):
def __getitem__(self, k):
return _convert_to_str()

def get(self, k, default=None):
return self.__getitem__(k)


if parse_version(get_distribution('astropy').version) >= parse_version('5.0.dev'):
convert_to_str = {'*': _convert_to_str()}
else:
convert_to_str = _ConvertToStr()

0 comments on commit 8a8f148

Please sign in to comment.