Coverage for python/lsst/afw/table/_source.py : 45%

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
1# This file is part of afw.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22__all__ = []
24from lsst.utils import continueClass
25from ._base import Catalog
26from ._table import SourceCatalog, SourceTable
28Catalog.register("Source", SourceCatalog)
31@continueClass # noqa: F811 (FIXME: remove for py 3.8+)
32class SourceCatalog: # noqa: F811
34 def getChildren(self, parent, *args):
35 """Return the subset of self for which the parent field equals the
36 given value.
38 In order for this method to return the correct result, it must be
39 sorted by parent (i.e. self.isSorted(SourceTable.getParentKey()) must
40 be True). This is naturally the case with SourceCatalogs produced by
41 the detection and deblending tasks, but it may not be true when
42 concatenating multiple such catalogs.
44 Additional Catalogs or sequences whose elements correspond in order to
45 the records of self (i.e. ``zip(self, *args)`` is valid) will be
46 subset using the same slice object used on self, and these subsets
47 will be returned along with the subset of self.
49 Parameters
50 ----------
51 parent : `int`
52 ID of the parent to get children for.
53 args : `~lsst.afw.table.Catalog`
54 Additional catalogs to subset for the childrens to return.
56 Returns
57 -------
58 children : iterable of `~lsst.afw.table.SourceRecord`
59 Children sources.
60 """
61 if not self.isSorted(SourceTable.getParentKey()):
62 raise AssertionError(
63 "The table is not sorted by parent, so cannot getChildren")
64 s = self.equal_range(parent, SourceTable.getParentKey())
65 if args:
66 return (self[s],) + tuple(arg[s] for arg in args)
67 else:
68 return self[s]