LSST Applications  21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
Public Member Functions | List of all members
lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand Class Reference
Inheritance diagram for lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand:

Public Member Functions

def __init__ (self)
 
def invoke (self, args, fromTty)
 

Detailed Description

Print an eigen Matrix or Vector
Usage: show eigen <matrix> [x0 y0 [nx ny]]
   show eigen <vector> [x0 [nx]]

Definition at line 194 of file printers.py.

Constructor & Destructor Documentation

◆ __init__()

def lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand.__init__ (   self)

Definition at line 200 of file printers.py.

200  def __init__(self):
201  super(PrintEigenCommand, self).__init__("show eigen",
202  gdb.COMMAND_DATA,
203  gdb.COMPLETE_SYMBOL)
204 

Member Function Documentation

◆ invoke()

def lsst.gdb.afw.printers.GdbOptionParser.PrintEigenCommand.invoke (   self,
  args,
  fromTty 
)

Definition at line 211 of file printers.py.

211  def invoke(self, args, fromTty):
212  self.dont_repeat()
213 
214  parser = GdbOptionParser("show eigen")
215  parser.add_option("-d", "--dataFmt", default="%.2f",
216  help="Format for values")
217  parser.add_option("-f", "--formatWidth", type="int",
218  default=8, help="Field width for values")
219  parser.add_option("-o", "--origin", type="str", nargs="+",
220  help="Origin of the part of the object to print")
221  if False:
222  parser.add_option(
223  "eigenObject", help="Expression giving Eigen::Matrix/Vector to show")
224  parser.add_option(
225  "nx", help="Width of patch to print", type="int", default=0, nargs="?")
226  parser.add_option(
227  "ny", help="Height of patch to print", type="int", default=0, nargs="?")
228 
229  opts = parser.parse_args(args)
230  if opts.help:
231  return
232  else:
233  (opts, args) = parser.parse_args(args)
234  if opts.help:
235  return
236 
237  if not args:
238  raise gdb.GdbError("Please specify an object")
239  opts.eigenObject = args.pop(0)
240 
241  opts.nx, opts.ny = 0, 0
242  if args:
243  opts.nx = int(args.pop(0))
244  if args:
245  opts.ny = int(args.pop(0))
246 
247  if args:
248  raise gdb.GdbError(
249  "Unrecognised trailing arguments: %s" % " ".join(args))
250 
251  var = gdb.parse_and_eval(opts.eigenObject)
252 
253  if not re.search(r"(Eigen|LinearTransform)::(Matrix|Vector)", str(var.type)):
254  raise gdb.GdbError(
255  "Please specify an eigen matrix or vector, not %s" % var.type)
256 
257  if re.search(r"shared_ptr<", str(var.type)):
258  var = var["px"].dereference()
259 
260  if var.type.code == gdb.TYPE_CODE_PTR:
261  var = var.dereference() # be nice
262 
263  isMatrix = re.search(r"Matrix", str(var.type))
264  if isMatrix:
265  NX, NY = getEigenMatrixDimensions(var)
266 
267  if opts.origin:
268  if len(opts.origin) != 2:
269  raise gdb.GdbError("Please specify both x0 and y0")
270 
271  x0 = gdb.parse_and_eval(opts.origin[0])
272  y0 = gdb.parse_and_eval(opts.origin[1])
273  else:
274  x0, y0 = 0, 0
275 
276  nx = opts.nx
277  ny = opts.ny
278  if nx == 0:
279  nx = NX
280  if ny == 0:
281  ny = NY
282 
283  if nx == 1 and ny == 1:
284  print("%g" % self._vget(var, x0))
285  return
286  else:
287  NX = 0, var["m_storage"]["n"]
288 
289  if opts.origin:
290  if len(opts.origin) != 1:
291  raise gdb.GdbError("Please only specify x0")
292 
293  x0 = gdb.parse_and_eval(opts.origin[0])
294  else:
295  x0 = 0
296 
297  nx = opts.nx
298  if nx == 0:
299  nx = NX
300 
301  if nx == 1:
302  print("%g" % self._vget(var, x0))
303  return
304  #
305  # OK, finally time to print
306  #
307  if isMatrix:
308  print("%-4s" % "", end=' ')
309  for x in range(x0, min(NX, x0 + nx)):
310  print("%*d" % (opts.formatWidth, x), end=' ')
311  print("")
312 
313  for y in range(y0, min(NY, y0 + ny)):
314  print("%-4d" % y, end=' ')
315  for x in range(x0, min(NX, x0 + nx)):
316  print("%*s" % (opts.formatWidth, (opts.dataFmt %
317  self._mget(var, x, y))), end=' ')
318  print("")
319  else:
320  for x in range(x0, min(NX, x0 + nx)):
321  print("%*s" % (opts.formatWidth, (opts.dataFmt %
322  self._vget(var, x))), end=' ')
323  print("")
324 
325  PrintEigenCommand()
int min

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