Coverage for python/lsst/afw/typehandling/_SimpleGenericMap.py : 59%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
|
# This file is part of afw. # # Developed for the LSST Data Management System. # This product includes software developed by the LSST Project # (https://www.lsst.org). # See the COPYRIGHT file at the top-level directory of this distribution # for details of code ownership. # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>.
"""A `dict`-like `~collections.abc.MutableMapping` for use when sharing a map between C++ and Python.
For compatibility with C++, ``SimpleGenericMap`` has the following restrictions:
- all keys must be of the same type - values must be built-in types or subclasses of `lsst.afw.typehandling.Storable`. Almost any user-defined class in C++ or Python can have `~lsst.afw.typehandling.Storable` as a mixin.
As a safety precaution, `~lsst.afw.typehandling.Storable` objects that are added from C++ may be copied when you retrieve them from Python, making it impossible to modify them in-place. This issue does not affect objects that are added from Python, or objects that are always passed by :cpp:class:`shared_ptr` in C++.
Parameters ---------- mapping : `collections.abc.Mapping`, optional iterable : iterable, optional dtype : `type`, optional The type of key the map accepts. Not required if ``mapping`` or ``iterable`` is provided. **kwargs Aside from the ``dtype`` keyword, a ``SimpleGenericMap`` takes the same input arguments as `dict`. """ return cls({key: value for key in iterable})
# pybind11-generated constructor, can only create empty map
class SimpleGenericMapS: _oldInit(self) if source: self.update(source, **kwargs) else: self.update(**kwargs) |