LSST Applications  22.0.1,22.0.1+01bcf6a671,22.0.1+046ee49490,22.0.1+05c7de27da,22.0.1+0c6914dbf6,22.0.1+1220d50b50,22.0.1+12fd109e95,22.0.1+1a1dd69893,22.0.1+1c910dc348,22.0.1+1ef34551f5,22.0.1+30170c3d08,22.0.1+39153823fd,22.0.1+611137eacc,22.0.1+771eb1e3e8,22.0.1+94e66cc9ed,22.0.1+9a075d06e2,22.0.1+a5ff6e246e,22.0.1+a7db719c1a,22.0.1+ba0d97e778,22.0.1+bfe1ee9056,22.0.1+c4e1e0358a,22.0.1+cc34b8281e,22.0.1+d640e2c0fa,22.0.1+d72a2e677a,22.0.1+d9a6b571bd,22.0.1+e485e9761b,22.0.1+ebe8d3385e
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.pipe.base.argumentParser.IdValueAction Class Reference
Inheritance diagram for lsst.pipe.base.argumentParser.IdValueAction:

Public Member Functions

def __call__ (self, parser, namespace, values, option_string)
 

Detailed Description

argparse action callback to process a data ID into a dict.

Definition at line 1177 of file argumentParser.py.

Member Function Documentation

◆ __call__()

def lsst.pipe.base.argumentParser.IdValueAction.__call__ (   self,
  parser,
  namespace,
  values,
  option_string 
)
Parse ``--id`` data and append results to
``namespace.<argument>.idList``.

Parameters
----------
parser : `ArgumentParser`
    Argument parser.
namespace : `argparse.Namespace`
    Parsed command (an instance of argparse.Namespace).
    The following attributes are updated:

    - ``<idName>.idList``, where ``<idName>`` is the name of the
      ID argument, for instance ``"id"`` for ID argument ``--id``.
values : `list`
    A list of data IDs; see Notes below.
option_string : `str`
    Option value specified by the user.

Notes
-----
The data format is::

    key1=value1_1[^value1_2[^value1_3...]
    key2=value2_1[^value2_2[^value2_3...]...

The values (e.g. ``value1_1``) may either be a string,
or of the form ``"int..int"`` (e.g. ``"1..3"``) which is
interpreted as ``"1^2^3"`` (inclusive, unlike a python range).
So ``"0^2..4^7..9"`` is equivalent to ``"0^2^3^4^7^8^9"``.
You may also specify a stride: ``"1..5:2"`` is ``"1^3^5"``.

The cross product is computed for keys with multiple values.
For example::

    --id visit 1^2 ccd 1,1^2,2

results in the following data ID dicts being appended to
``namespace.<argument>.idList``:

    {"visit":1, "ccd":"1,1"}
    {"visit":2, "ccd":"1,1"}
    {"visit":1, "ccd":"2,2"}
    {"visit":2, "ccd":"2,2"}

Definition at line 1181 of file argumentParser.py.

1181  def __call__(self, parser, namespace, values, option_string):
1182  """Parse ``--id`` data and append results to
1183  ``namespace.<argument>.idList``.
1184 
1185  Parameters
1186  ----------
1187  parser : `ArgumentParser`
1188  Argument parser.
1189  namespace : `argparse.Namespace`
1190  Parsed command (an instance of argparse.Namespace).
1191  The following attributes are updated:
1192 
1193  - ``<idName>.idList``, where ``<idName>`` is the name of the
1194  ID argument, for instance ``"id"`` for ID argument ``--id``.
1195  values : `list`
1196  A list of data IDs; see Notes below.
1197  option_string : `str`
1198  Option value specified by the user.
1199 
1200  Notes
1201  -----
1202  The data format is::
1203 
1204  key1=value1_1[^value1_2[^value1_3...]
1205  key2=value2_1[^value2_2[^value2_3...]...
1206 
1207  The values (e.g. ``value1_1``) may either be a string,
1208  or of the form ``"int..int"`` (e.g. ``"1..3"``) which is
1209  interpreted as ``"1^2^3"`` (inclusive, unlike a python range).
1210  So ``"0^2..4^7..9"`` is equivalent to ``"0^2^3^4^7^8^9"``.
1211  You may also specify a stride: ``"1..5:2"`` is ``"1^3^5"``.
1212 
1213  The cross product is computed for keys with multiple values.
1214  For example::
1215 
1216  --id visit 1^2 ccd 1,1^2,2
1217 
1218  results in the following data ID dicts being appended to
1219  ``namespace.<argument>.idList``:
1220 
1221  {"visit":1, "ccd":"1,1"}
1222  {"visit":2, "ccd":"1,1"}
1223  {"visit":1, "ccd":"2,2"}
1224  {"visit":2, "ccd":"2,2"}
1225  """
1226  if namespace.config is None:
1227  return
1228  idDict = collections.OrderedDict()
1229  for nameValue in values:
1230  name, sep, valueStr = nameValue.partition("=")
1231  if name in idDict:
1232  parser.error(f"{name} appears multiple times in one ID argument: {option_string}")
1233  idDict[name] = []
1234  for v in valueStr.split("^"):
1235  mat = re.search(r"^(\d+)\.\.(\d+)(?::(\d+))?$", v)
1236  if mat:
1237  v1 = int(mat.group(1))
1238  v2 = int(mat.group(2))
1239  v3 = mat.group(3)
1240  v3 = int(v3) if v3 else 1
1241  for v in range(v1, v2 + 1, v3):
1242  idDict[name].append(str(v))
1243  else:
1244  idDict[name].append(v)
1245 
1246  iterList = [idDict[key] for key in idDict.keys()]
1247  idDictList = [collections.OrderedDict(zip(idDict.keys(), valList))
1248  for valList in itertools.product(*iterList)]
1249 
1250  argName = option_string.lstrip("-")
1251  ident = getattr(namespace, argName)
1252  ident.idList += idDictList
1253 
1254 
std::shared_ptr< FrameSet > append(FrameSet const &first, FrameSet const &second)
Construct a FrameSet that performs two transformations in series.
Definition: functional.cc:33

The documentation for this class was generated from the following file: