Skip to content

MNT: Replace OrderedDict with dict in utils - #10932

Closed
pllim wants to merge 9 commits into
astropy:mainfrom
pllim:rm-ordered-dict
Closed

pllim wants to merge 9 commits into
astropy:mainfrom
pllim:rm-ordered-dict

Conversation

@pllim

@pllim pllim commented Oct 23, 2020 •

Copy link
Copy Markdown
Member

Blocked by: #10932 (comment)

Description

This pull request is to address part of #10888 . I left timer.py alone because it is deprecated and removed in #10281 .

TODO

  • Get the rest of OrderedDict. Too much work. Just smaller focus here.
  • Make sure tests pass.
  • Get approval from subpackage maintainers.

Resolved

I see failures like this and not sure what to make of it. Maybe @taldcroft or @mhvk can advise.

__ TestMetaMaskedColumn.test_mapping_init[meta2] __

self = <astropy.table.tests.test_column.TestMetaMaskedColumn object at 0x7f0e559df7f0>, meta = {'a': 1}

    @pytest.mark.parametrize(('meta'), ([dict([('a', 1)]),
                                         dict([('a', 1)]),
                                         OrderedDictSubclass([('a', 1)])]))
    def test_mapping_init(self, meta):
        d = self.test_class(*self.args, meta=meta)
>       assert type(d.meta) == type(meta)
E       AssertionError: assert <class 'dict'> == <class 'astropy.utils.tests.test_metadata.OrderedDictSubclass'>
E        +  where <class 'dict'> = type({'a': 1})
E        +    where {'a': 1} = <MaskedColumn dtype='float64' length=0>\n.meta
E        +  and   <class 'astropy.utils.tests.test_metadata.OrderedDictSubclass'> = type({'a': 1})

astropy/utils/tests/test_metadata.py:30: AssertionError
__ TestMetaMaskedColumn.test_mapping_set[meta2] __
self = <astropy.table.tests.test_column.TestMetaMaskedColumn object at 0x7f0e5598c640>, meta = {'a': 1}

    @pytest.mark.parametrize(('meta'), ([dict([('a', 1)]),
                                         dict([('a', 1)]),
                                         OrderedDictSubclass([('a', 1)])]))
    def test_mapping_set(self, meta):
        d = self.test_class(*self.args, meta=meta)
>       assert type(d.meta) == type(meta)
E       AssertionError: assert <class 'dict'> == <class 'astropy.utils.tests.test_metadata.OrderedDictSubclass'>
E        +  where <class 'dict'> = type({'a': 1})
E        +    where {'a': 1} = <MaskedColumn dtype='float64' length=0>\n.meta
E        +  and   <class 'astropy.utils.tests.test_metadata.OrderedDictSubclass'> = type({'a': 1})

astropy/utils/tests/test_metadata.py:43: AssertionError

FAILED astropy/table/tests/test_column.py::TestMetaMaskedColumn::test_mapping_init[meta2] - AssertionError: assert <class 'dict'> == <class 'astropy.utils.tests.test_metadata.OrderedDictSubclass'>
FAILED astropy/table/tests/test_column.py::TestMetaMaskedColumn::test_mapping_set[meta2] - AssertionError: assert <class 'dict'> == <class 'astropy.utils.tests.test_metadata.OrderedDictSubclass'>

assert type(d.meta) == type(meta)

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pllim - looks mostly good, but in test_metadata, the OrderedDict stuff should be kept - it is specifically to test that the class (and a subclass) work, and that should remain the case. This should also solve the failure (I think...)

Comment thread astropy/utils/tests/test_metadata.py Outdated


class OrderedDictSubclass(OrderedDict):
class OrderedDictSubclass(dict):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one we should keep the same - it specifically tests what happens if someone subclasses OrderedDict (which should still be allowed)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. Thanks!

assert len(d.meta) == 0

@pytest.mark.parametrize(('meta'), ([dict([('a', 1)]),
OrderedDict([('a', 1)]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also still be tested.

self.test_class(*self.args, meta=meta)

@pytest.mark.parametrize(('meta'), ([dict([('a', 1)]),
OrderedDict([('a', 1)]),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also keep this one.

@bsipocz bsipocz linked an issue Oct 26, 2020 that may be closed by this pull request
5 of 13 tasks
@pllim

pllim commented Oct 28, 2020 •

Copy link
Copy Markdown
Member Author

I don't have enough Table metadata parsing with YAML expertise to fix this error:

     # %ECSV 0.9
     # ---
     # datatype:
     # - name: bool
     #   unit: m / s
     #   datatype: bool
     #   description: descr_bool
     #   meta: {meta bool: 1}
     # - name: int64
     #   unit: m / s
     #   datatype: int64
     #   description: descr_int64
     #   meta: {meta int64: 1}
     # - name: float64
     #   unit: m / s
     #   datatype: float64
     #   description: descr_float64
     #   meta: {meta float64: 1}
     # - name: str
     #   unit: m / s
     #   datatype: string
     #   description: descr_str
     #   meta: {meta str: 1}
  a> # meta: !!omap
  b> # meta:
  a> # - comments: [comment1, comment2]
   ?   ^
  b> #   comments: [comment1, comment2]
   ?   ^
     # schema: astropy-2.0
     bool int64 float64 str
     False 0 0.0 "ab 0"
     True 1 1.0 "ab, 1"
     False 2 2.0 ab2

Log: https://travis-ci.com/github/astropy/astropy/jobs/414455460#L1603

@mhvk

mhvk commented Oct 28, 2020

Copy link
Copy Markdown
Contributor

I think that change is expected - the yaml file effectively stored the fact that it was an ordered dict. But cc @taldcroft just in case...

Comment thread astropy/io/ascii/ecsv.py Outdated

try:
scs = self.header.table_meta['__serialized_columns__']
if isinstance(self.header.table_meta, (list, tuple)):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno... I have to make some weird patching to get the tests to pass...

Comment thread astropy/utils/metadata.py Outdated
instance._meta = dict()
return

if isinstance(value, (list, tuple)):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another weird patch here.

@pllim pllim changed the title MNT: Replace OrderedDict with dict in utils MNT: Replace OrderedDict with dict Oct 30, 2020
@pllim

pllim commented Oct 30, 2020

Copy link
Copy Markdown
Member Author

Update: Got the tests to pass, though I see many more occurrences of OrderedDict across different subpackages. This might take a while... Should we break the work up into a series of PRs instead? Should we be touching FITS?

coordinates

./astropy/coordinates/tests/test_representation.py:5:from collections import OrderedDict
./astropy/coordinates/tests/test_representation.py:1092:        attr_classes = OrderedDict([('lon', Longitude180),
./astropy/coordinates/tests/test_representation.py:1113:        attr_classes = OrderedDict([('lon', Longitude),
./astropy/coordinates/tests/test_representation.py:1161:            attr_classes = OrderedDict([('lon', Longitude),
./astropy/coordinates/tests/test_representation.py:1172:            attr_classes = OrderedDict([('lon', Longitude),
./astropy/coordinates/tests/test_representation.py:1527:        attr_classes = OrderedDict([('phi', Angle),
./astropy/coordinates/tests/test_representation.py:1556:            return OrderedDict(
./astropy/coordinates/tests/test_representation.py:1565:            return OrderedDict((('phi', sintheta),
./astropy/coordinates/tests/test_unit_representation.py:5:from collections import OrderedDict
./astropy/coordinates/tests/test_unit_representation.py:48:        attr_classes = OrderedDict([('lon', Longitude180),
./astropy/coordinates/tests/test_unit_representation.py:52:        attr_classes = OrderedDict([('lon', Longitude180),
./astropy/coordinates/transformations.py:24:from collections import defaultdict, OrderedDict
./astropy/coordinates/transformations.py:1430:trans_to_color = OrderedDict()
./astropy/coordinates/baseframe.py:13:from collections import namedtuple, OrderedDict, defaultdict
./astropy/coordinates/baseframe.py:412:    frame_attributes = OrderedDict()
./astropy/coordinates/baseframe.py:714:        return OrderedDict((name, getattr(cls, name))
./astropy/coordinates/baseframe.py:849:        out = OrderedDict()
./astropy/coordinates/baseframe.py:860:        out = OrderedDict()
./astropy/coordinates/baseframe.py:1896:        self.frame_attributes = OrderedDict()
./astropy/coordinates/representation.py:10:from collections import OrderedDict
./astropy/coordinates/representation.py:682:    and define an ``attr_classes`` attribute, an `~collections.OrderedDict`
./astropy/coordinates/representation.py:1256:    attr_classes = OrderedDict([('x', u.Quantity),
./astropy/coordinates/representation.py:1316:        return OrderedDict(
./astropy/coordinates/representation.py:1323:        return OrderedDict((('x', l), ('y', l), ('z', l)))
./astropy/coordinates/representation.py:1549:    attr_classes = OrderedDict([('lon', Longitude),
./astropy/coordinates/representation.py:1584:        return OrderedDict(
./astropy/coordinates/representation.py:1592:        return OrderedDict((('lon', sf_lon),
./astropy/coordinates/representation.py:1749:    attr_classes = OrderedDict([('distance', u.Quantity)])
./astropy/coordinates/representation.py:1768:        return OrderedDict((('distance', l),))
./astropy/coordinates/representation.py:1835:    attr_classes = OrderedDict([('lon', Longitude),
./astropy/coordinates/representation.py:1886:        return OrderedDict(
./astropy/coordinates/representation.py:1897:        return OrderedDict((('lon', sf_lon),
./astropy/coordinates/representation.py:1999:    attr_classes = OrderedDict([('phi', Angle),
./astropy/coordinates/representation.py:2045:        return OrderedDict(
./astropy/coordinates/representation.py:2057:        return OrderedDict((('phi', r * sintheta),
./astropy/coordinates/representation.py:2155:    attr_classes = OrderedDict([('rho', u.Quantity),
./astropy/coordinates/representation.py:2189:        return OrderedDict(
./astropy/coordinates/representation.py:2197:        return OrderedDict((('rho', l),
./astropy/coordinates/representation.py:2247:            cls.attr_classes = OrderedDict([('d_' + c, u.Quantity)
./astropy/coordinates/representation.py:2887:    attr_classes = OrderedDict([('d_lon_coslat', u.Quantity),
./astropy/coordinates/representation.py:2950:    attr_classes = OrderedDict([('d_lon_coslat', u.Quantity),
./astropy/coordinates/solar_system.py:8:from collections import OrderedDict
./astropy/coordinates/solar_system.py:33:BODY_NAME_TO_KERNEL_SPEC = OrderedDict([
./astropy/coordinates/solar_system.py:49:PLAN94_BODY_NAME_TO_PLANET_INDEX = OrderedDict(
./docs/coordinates/frames.rst:52:    OrderedDict([('equinox', <Time object: scale='tt' format='jyear_str' value=J2000.000>)])
./docs/coordinates/frames.rst:112:    OrderedDict([('ra', 'lon'), ('dec', 'lat'), ('distance', 'distance')])
./docs/coordinates/representations.rst:598:* ``attr_classes`` class attribute (``OrderedDict``):
./docs/coordinates/representations.rst:662:        attr_classes = OrderedDict([('comp1', ComponentClass1),
./docs/coordinates/inplace.rst:34:    OrderedDict([('ra', 'lon'), ('dec', 'lat'), ('distance', 'distance')])
./docs/coordinates/skycoord.rst:535:  OrderedDict([('l', 'lon'), ('b', 'lat'), ('distance', 'distance')])
./docs/coordinates/skycoord.rst:538:  OrderedDict([('l', Unit("deg")), ('b', Unit("deg"))])
./docs/coordinates/skycoord.rst:554:  OrderedDict([('equinox', <Time object: scale='tt' format='byear_str' value=B1950.000>), ('obstime', None)])
./docs/coordinates/skycoord.rst:840:    OrderedDict([('ra', 'lon'), ('dec', 'lat'), ('distance', 'distance')])

io.ascii

./astropy/io/ascii/tests/test_read.py:6:from collections import OrderedDict
./astropy/io/ascii/tests/test_read.py:570:    keywords = OrderedDict((('intval', 1),
./astropy/io/ascii/fastbasic.py:5:from collections import OrderedDict
./astropy/io/ascii/fastbasic.py:138:        meta = OrderedDict()
./astropy/io/ascii/fastbasic.py:266:        meta = OrderedDict()
./astropy/io/ascii/ecsv.py:8:from collections import OrderedDict
./astropy/io/ascii/ecsv.py:152:        header_cols = OrderedDict((x['name'], x) for x in header['datatype'])
./astropy/io/ascii/core.py:22:from collections import OrderedDict
./astropy/io/ascii/core.py:556:        the table ``lines`` and update the OrderedDict ``meta`` in place.  This base
./astropy/io/ascii/core.py:1214:        self.meta = OrderedDict(table=OrderedDict(),
./astropy/io/ascii/core.py:1215:                                cols=OrderedDict())
./astropy/io/ascii/daophot.py:15:from collections import defaultdict, OrderedDict
./astropy/io/ascii/daophot.py:120:                keywords = OrderedDict(map(self.extract_keyword_line, grouped_lines_dict['#K']))
./astropy/io/ascii/ipac.py:13:from collections import defaultdict, OrderedDict
./astropy/io/ascii/ipac.py:119:        table_meta['keywords'] = OrderedDict()

io.fits

./astropy/io/fits/tests/test_connect.py:614:        # Mixin info.meta can None instead of empty OrderedDict(), #6720 would
./astropy/io/fits/tests/test_header.py:61:    dict1 = collections.OrderedDict(list1)
./astropy/io/fits/_utils.pyx:2:from collections import OrderedDict
./astropy/io/fits/_utils.pyx:23:    cards = OrderedDict()
./astropy/io/fits/column.py:12:from collections import OrderedDict
./astropy/io/fits/column.py:146:KEYWORD_TO_ATTRIBUTE = OrderedDict(zip(KEYWORD_NAMES, KEYWORD_ATTRIBUTES))
./astropy/io/fits/column.py:148:ATTRIBUTE_TO_KEYWORD = OrderedDict(zip(KEYWORD_ATTRIBUTES, KEYWORD_NAMES))
./astropy/io/fits/fitstime.py:5:from collections import defaultdict, OrderedDict
./astropy/io/fits/fitstime.py:435:    time_columns = defaultdict(OrderedDict)
./astropy/io/fits/fitstime.py:523:    newtable.meta['__coordinate_columns__'] = defaultdict(OrderedDict)
./docs/io/fits/appendix/header_transition.rst:66:(or :class:`~collections.OrderedDict` in Python) for ease of use by new users
./docs/io/fits/appendix/header_transition.rst:103:similar to an :class:`~collections.OrderedDict` in that the order of insertions

io.misc

./astropy/io/misc/tests/test_hdf5.py:652:        # Mixin info.meta can None instead of empty OrderedDict(), #6720 would
./astropy/io/misc/asdf/tags/time/tests/test_time.py:5:from collections import OrderedDict
./astropy/io/misc/asdf/tags/time/tests/test_time.py:21:    newschema = OrderedDict()
./astropy/io/misc/asdf/tags/time/tests/test_time.py:34:                cursor = cursor.setdefault('items', OrderedDict())
./astropy/io/misc/asdf/tags/time/tests/test_time.py:36:                cursor = cursor.setdefault('properties', OrderedDict())
./astropy/io/misc/asdf/tags/time/tests/test_time.py:40:                    cursor = cursor.setdefault(part, OrderedDict())

io.registry

./astropy/io/registry.py:10:from collections import OrderedDict
./astropy/io/registry.py:23:_readers = OrderedDict()
./astropy/io/registry.py:24:_writers = OrderedDict()
./astropy/io/registry.py:25:_identifiers = OrderedDict()

modeling

./astropy/modeling/tests/test_models_quantities.py:3:from collections import OrderedDict
./astropy/modeling/tests/test_models_quantities.py:220:            kwargs = OrderedDict(zip(('x', 'y'), args))
./astropy/modeling/tests/test_models_quantities.py:222:            kwargs = OrderedDict(zip(('x', 'y', 'z'), args))
./astropy/modeling/utils.py:368:    storage, for example an `OrderedDict`.  However, even in this case
./astropy/modeling/core.py:25:from collections import defaultdict, OrderedDict, deque
./astropy/modeling/core.py:74:        return OrderedDict()
./astropy/modeling/core.py:137:        pdict = OrderedDict()
./astropy/modeling/core.py:3124:        self._parameters_ = OrderedDict()
./astropy/modeling/core.py:3712:    params = OrderedDict((param.name, Parameter(param.name,
./astropy/modeling/core.py:3721:    members = OrderedDict([

nddata

./astropy/nddata/tests/test_decorators.py:343:    # Meta is always set (OrderedDict) so it has a special case that it's
./astropy/nddata/tests/test_nddata.py:6:from collections import OrderedDict
./astropy/nddata/nddata.py:60:        an empty `collections.OrderedDict` is created.
./astropy/nddata/bitmask.py:8:from collections import OrderedDict
./astropy/nddata/bitmask.py:88:            cache = OrderedDict()
./astropy/nddata/flag_collection.py:4:from collections import OrderedDict
./astropy/nddata/flag_collection.py:13:class FlagCollection(OrderedDict):
./astropy/nddata/flag_collection.py:22:    `~collections.OrderedDict`, but with the addition of a ``shape=``
./astropy/nddata/flag_collection.py:37:        OrderedDict.__init__(self, *args, **kwargs)
./astropy/nddata/flag_collection.py:43:                OrderedDict.__setitem__(self, item, value, **kwargs)

table

./astropy/table/table.py:6:from collections import OrderedDict, defaultdict
./astropy/table/table.py:196:# be sure to change the OrderedDict ref(s) in Row and in __len__().
./astropy/table/table.py:198:class TableColumns(OrderedDict):
./astropy/table/table.py:199:    """OrderedDict subclass for a set of columns.
./astropy/table/table.py:239:            return OrderedDict.__getitem__(self, item)
./astropy/table/table.py:667:        columns = OrderedDict((key, col if isinstance(col, BaseColumn) else col_copy(col))
./astropy/table/table.py:1801:            return len(OrderedDict.__getitem__(self.columns, self._first_colname))
./astropy/table/table.py:3417:        out = OrderedDict()
./astropy/table/table.py:3507:        out = OrderedDict()
./astropy/table/tests/test_info.py:7:from collections import OrderedDict
./astropy/table/tests/test_info.py:135:        assert cinfo == OrderedDict([('name', 'name'),
./astropy/table/tests/test_info.py:162:        assert cinfo == OrderedDict([('name', 'name'),
./astropy/table/tests/test_info.py:180:        assert cinfo == OrderedDict([('dtype', 'int64'),
./astropy/table/tests/test_operations.py:3:from collections import OrderedDict
./astropy/table/tests/test_operations.py:52:        self.t1.meta.update(OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)]))
./astropy/table/tests/test_operations.py:53:        self.t2.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:54:        self.t3.meta.update(OrderedDict([('b', 3), ('c', [1, 2]), ('d', 2), ('a', 1)]))
./astropy/table/tests/test_operations.py:56:        self.meta_merge = OrderedDict([('b', [1, 2, 3, 4]),
./astropy/table/tests/test_operations.py:398:        meta1 = OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)])
./astropy/table/tests/test_operations.py:399:        meta2 = OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)])
./astropy/table/tests/test_operations.py:807:        self.t1.meta.update(OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)]))
./astropy/table/tests/test_operations.py:808:        self.t2.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:809:        self.t4.meta.update(OrderedDict([('b', [5, 6]), ('c', {'c': 1}), ('e', 1)]))
./astropy/table/tests/test_operations.py:810:        self.t5.meta.update(OrderedDict([('b', 3), ('c', 'k'), ('d', 1)]))
./astropy/table/tests/test_operations.py:811:        self.meta_merge = OrderedDict([('b', [1, 2, 3, 4, 5, 6]),
./astropy/table/tests/test_operations.py:1002:        t1['a'].info.meta.update(OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)]))
./astropy/table/tests/test_operations.py:1003:        t2['a'].info.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:1004:        t4['a'].info.meta.update(OrderedDict([('b', [5, 6]), ('c', {'c': 1}), ('e', 1)]))
./astropy/table/tests/test_operations.py:1007:        t2['b'].info.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:1049:        assert out['b'].info.meta == OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)])
./astropy/table/tests/test_operations.py:1076:        t1['a'].info.meta.update(OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)]))
./astropy/table/tests/test_operations.py:1077:        t2['a'].info.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:1078:        t4['a'].info.meta.update(OrderedDict([('b', [5, 6]), ('c', {'c': 1}), ('e', 1)]))
./astropy/table/tests/test_operations.py:1081:        t2['b'].info.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:1101:        assert out['b'].info.meta == OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)])
./astropy/table/tests/test_operations.py:1334:        self.t1.meta.update(OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)]))
./astropy/table/tests/test_operations.py:1335:        self.t2.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:1336:        self.t4.meta.update(OrderedDict([('b', [5, 6]), ('c', {'c': 1}), ('e', 1)]))
./astropy/table/tests/test_operations.py:1337:        self.t5.meta.update(OrderedDict([('b', 3), ('c', 'k'), ('d', 1)]))
./astropy/table/tests/test_operations.py:1338:        self.meta_merge = OrderedDict([('b', [1, 2, 3, 4, 5, 6]),
./astropy/table/tests/test_operations.py:1497:        meta1 = OrderedDict([('b', [1, 2]), ('c', {'a': 1}), ('d', 1)])
./astropy/table/tests/test_operations.py:1502:        t3['d'].info.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/test_operations.py:1503:        t4['g'].info.meta.update(OrderedDict([('b', [5, 6]), ('c', {'c': 1}), ('e', 1)]))
./astropy/table/tests/test_operations.py:1504:        t3['e'].info.meta.update(OrderedDict([('b', [3, 4]), ('c', {'b': 1}), ('a', 1)]))
./astropy/table/tests/conftest.py:13:from collections import OrderedDict
./astropy/table/tests/conftest.py:164:    cols = OrderedDict()
./astropy/table/tests/test_table.py:9:from collections import OrderedDict
./astropy/table/tests/test_table.py:2124:            self.meta = OrderedDict([('a', 1), ('b', 2)])
./astropy/table/tests/test_table.py:2165:        meta = OrderedDict([('c', 3)])
./astropy/table/tests/test_table.py:2197:    assert t2.meta is not t.meta  # NOT the same OrderedDict object but equal
./astropy/table/tests/test_table.py:2203:    assert t2.meta is not t.meta  # NOT the same OrderedDict object but equal
./astropy/table/tests/test_table.py:2209:    assert t2.meta is not t.meta  # NOT the same OrderedDict object but equal
./astropy/table/tests/test_table.py:2816:    assert isinstance(t.values(), type(OrderedDict().values()))
./astropy/table/tests/test_table.py:2817:    assert isinstance(t.columns.values(), type(OrderedDict().values()))
./astropy/table/tests/test_table.py:2818:    assert isinstance(t.columns.keys(), type(OrderedDict().keys()))
./astropy/table/tests/test_table.py:2829:    assert isinstance(t.items(), type(OrderedDict({}).items()))
./astropy/table/tests/test_init_table.py:3:from collections import OrderedDict, UserDict
./astropy/table/tests/test_init_table.py:300:class TestInitFromOrderedDict(BaseInitFromDictLike):
./astropy/table/tests/test_init_table.py:303:        self.data = OrderedDict([('a', Column(name='x', data=[1, 3])),
./astropy/table/tests/test_init_table.py:540:def test_init_from_row_OrderedDict(table_type):
./astropy/table/tests/test_init_table.py:541:    row1 = OrderedDict([('b', 1), ('a', 0)])
./astropy/table/np_utils.py:9:from collections import OrderedDict, Counter
./astropy/table/np_utils.py:72:    col_name_map = OrderedDict((name, col_name_map[name]) for name in col_name_list)
./astropy/table/row.py:4:from collections import OrderedDict
./astropy/table/row.py:51:            out = OrderedDict.__getitem__(self._table.columns, item)[self._index]
./astropy/table/serialize.py:4:from collections import OrderedDict
./astropy/table/serialize.py:254:class _TableLite(OrderedDict):
./astropy/table/info.py:29:    column as its single argument.  The function must return an OrderedDict
./astropy/table/soco.py:8:from collections import OrderedDict
./astropy/table/soco.py:132:        result = OrderedDict()
./astropy/table/operations.py:15:from collections import OrderedDict, Counter
./astropy/table/operations.py:382:    col_name_map = OrderedDict()
./astropy/table/operations.py:635:    col_name_map = OrderedDict()
./astropy/table/operations.py:706:    col_name_map = OrderedDict()
./astropy/table/operations.py:898:    col_name_map = OrderedDict((name, col_name_map[name]) for name in col_name_list)
./astropy/table/operations.py:1268:        col_name_map = OrderedDict((name, in_names) for name, in_names in col_name_map.items()

tests.runner

./astropy/tests/runner.py:12:from collections import OrderedDict
./astropy/tests/runner.py:108:        cls.keywords = OrderedDict()

time

./astropy/time/formats.py:10:from collections import OrderedDict, defaultdict
./astropy/time/formats.py:38:# Use an OrderedDict to fix the order in which formats are tried.
./astropy/time/formats.py:40:TIME_FORMATS = OrderedDict()
./astropy/time/formats.py:41:TIME_DELTA_FORMATS = OrderedDict()

utils

These are ignored on purpose:

./astropy/utils/tests/test_timer.py:52:    p.time_func(2.2)  # Test OrderedDict
./astropy/utils/tests/test_metadata.py:3:from collections import OrderedDict
./astropy/utils/tests/test_metadata.py:14:class OrderedDictSubclass(OrderedDict):
./astropy/utils/tests/test_metadata.py:28:                                         OrderedDict([('a', 1)]),
./astropy/utils/tests/test_metadata.py:29:                                         OrderedDictSubclass([('a', 1)])]))
./astropy/utils/tests/test_metadata.py:41:                                         OrderedDict([('a', 1)]),
./astropy/utils/tests/test_metadata.py:42:                                         OrderedDictSubclass([('a', 1)])]))
./astropy/utils/timer.py:7:from collections import OrderedDict
./astropy/utils/timer.py:156:        self._cache_good = OrderedDict()
./astropy/utils/timer.py:158:        self._cache_est = OrderedDict()
./astropy/utils/timer.py:159:        self._cache_out = OrderedDict()
./astropy/utils/timer.py:255:        self._cache_est = OrderedDict()

visualization.wcsaxes

./astropy/visualization/wcsaxes/coordinates_map.py:4:from collections import OrderedDict
./astropy/visualization/wcsaxes/coordinates_map.py:174:            row = OrderedDict([('index', icoord), ('aliases', ' '.join(aliases)),
./astropy/visualization/wcsaxes/frame.py:5:from collections import OrderedDict
./astropy/visualization/wcsaxes/frame.py:149:class BaseFrame(OrderedDict, metaclass=abc.ABCMeta):
./astropy/visualization/wcsaxes/frame.py:215:        spines = OrderedDict()

wcs.wcsapi

./astropy/wcs/wcsapi/high_level_api.py:2:from collections import defaultdict, OrderedDict
./astropy/wcs/wcsapi/high_level_api.py:138:        classes = OrderedDict()

Comment thread astropy/table/meta.py
@mhvk

mhvk commented Oct 31, 2020

Copy link
Copy Markdown
Contributor

I think spreading it over multiple PRs seems wise. That way test failures are easier to check/understand, and we also ensure everything gets properly looked at. Plus, we can share the load!

@pllim

pllim commented Oct 31, 2020

Copy link
Copy Markdown
Member Author

@mhvk , in that case, do you think the current state of the PR is atomic enough? Or should I include some other stuff so that the changes in utils make sense?

@mhvk

mhvk commented Nov 2, 2020

Copy link
Copy Markdown
Contributor

@pllim - I think this PR is quite nicely atomic, just focussing on meta data, so let's keep it as is. As you note, though, some of the changes seem a bit odd. @taldcroft - meta is a bit more up your alley, would you be able to have a look?

@pllim pllim changed the title MNT: Replace OrderedDict with dict MNT: Replace OrderedDict with dict in utils Nov 10, 2020
@pllim
pllim marked this pull request as ready for review November 10, 2020 19:18
@pllim
pllim requested a review from taldcroft November 10, 2020 19:18
@pllim

pllim commented Nov 10, 2020

Copy link
Copy Markdown
Member Author

Thanks, @mhvk ! I'm limiting the scope of this PR to utils and the things that directly affected and mark this as ready for review. Also rebased.

@pllim

pllim commented Nov 10, 2020

Copy link
Copy Markdown
Member Author

RTD timeout is unrelated.

@mhvk

mhvk commented Nov 10, 2020

Copy link
Copy Markdown
Contributor

@taldcroft - could you review this PR? I am not familiar enough with the test cases to be confident that we wouldn't accidentally break loading of old yaml files, etc.

@taldcroft

Copy link
Copy Markdown
Member

@pllim - we do still need to bump the min version of PyYAML. Where to do that?

@pllim

pllim commented Nov 18, 2020

Copy link
Copy Markdown
Member Author

@taldcroft , I identified the following files that needs updating from a global grep. There are multiple occurrences, so I recommend a careful search and replace in those files. Might have missed something but hopefully the tests will smoke them out. Will also need a change log entry for this.

./astropy/io/misc/yaml.py:.. note:: This module requires PyYaml version 3.13 or later.
./astropy/io/misc/yaml.py:    raise ImportError('The PyYAML package is required for astropy.io.misc.yaml and must be 3.13 or later')
./astropy/io/misc/yaml.py:        raise ImportError('The PyYAML package is required for astropy.io.misc.yaml and must be 3.13 or later')
./astropy/__init__.py:# PyYAML is an optional dependency, but this is the minimum version that is
./setup.cfg:    PyYAML>=3.13
./tox.ini:    oldestdeps: pyyaml==3.13

@pllim

This comment has been minimized.

@pllim

This comment has been minimized.

@pllim

pllim commented Jan 29, 2021 •

Copy link
Copy Markdown
Member Author

@taldcroft and @mhvk -- I removed conflicts, bumped PyYAML minversion, and addressed the remaining comments. Please review carefully one more time. And if it looks good, let's get this in before I get more conflicts. Thanks!

(I don't think test failures are related...)

@taldcroft

Copy link
Copy Markdown
Member

@pllim - sorry, but there is a real problem with the current implementation, see #10932 (comment) and #10932 (comment). It's been on my list of things to do but I haven't quite been looking forward to it. 😄

@pllim

pllim commented Feb 3, 2021

Copy link
Copy Markdown
Member Author

Re: #10932 (comment) -- Ah, sorry; I thought by bumping PyYAML minversion, that would be enough but I had not been following the convo very closely. I'll turn this PR back to draft then. Thanks for the update!

@pllim
pllim marked this pull request as draft February 3, 2021 15:39
@pllim

pllim commented Apr 19, 2021

Copy link
Copy Markdown
Member Author

I think this is still stuck without clear path forward, so moving milestone.

@pllim pllim modified the milestones: v4.3, v5.0 Apr 19, 2021
@github-actions

github-actions Bot commented Sep 3, 2021

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 7 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Sep 3, 2021
@github-actions

github-actions Bot commented Sep 4, 2021

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 7 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@pllim

pllim commented Sep 4, 2021

Copy link
Copy Markdown
Member Author

Ops, sorry for the double bot post. Hopefully I fixed the bug upstream.

@pllim

pllim commented Sep 4, 2021

Copy link
Copy Markdown
Member Author

Oh, wait this is my own PR. Hmm too many conflicts now. I am just going to abandon it.

@pllim pllim closed this Sep 4, 2021
@pllim
pllim deleted the rm-ordered-dict branch September 4, 2021 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Close? Tell stale bot that this issue/PR is stale io.ascii nddata Refactoring table utils

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove OrderedDict for astropy 4.3 or later

4 participants