#15151 closed defect (fixed)

In CmdDescs, Or(TupleOf(IntArg, 3), TupleOf(IntArg, 2)) only admits the first form

Reported by: Zach Pearson Owned by: Greg Couch
Priority: moderate Milestone: 1.9
Component: Command Line Version:
Keywords: Cc: Tom Goddard
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Even when reversed, this Or will only accept whichever TupleArg comes first. I was trying to add a consolidated 'center' parameter to the segmentations command. The center an either be the x,y coordinates of a point on a 2D slice or a 3D coordinate.

Change History (3)

comment:1 by Eric Pettersen, 18 months ago

Cc: Tom Goddard added
Milestone: 1.9
Owner: set to Greg Couch
Status: newassigned
Summary: In CmdDescs, Or(TupleArg(IntArg, 3), TupleArg(IntArg, 2)) only admits the first formIn CmdDescs, Or(TupleOf(IntArg, 3), TupleOf(IntArg, 2)) only admits the first form

It looks like that because Aggregate (which TupleOf inherits from) sets its 'offset' attribute, Or does not try the second alternative.

comment:2 by Greg Couch, 17 months ago

Status: assignedaccepted

Reproduce with:

from chimerax.core.commands import TupleOf, IntArg, Or
arg = Or(TupleOf(IntArg, 3), TupleOf(IntArg, 2))
arg.parse("1, 2, 3", session)  # works
arg.parse("1, 2", session)   # fails

comment:3 by Greg Couch, 17 months ago

Resolution: fixed
Status: acceptedclosed

The offset logic was the problem. Revise to use offset of the longest subparse if none succeed.

Note: See TracTickets for help on using tickets.