Opened 13 years ago

Closed 13 years ago

#251 closed defect (fixed)

scantable.scale causes selection to fail

Reported by: Malte Marquarding Owned by: Kana Sugimoto
Priority: high Milestone: Unified development
Component: python Version: 2.0
Severity: blocker Keywords:
Cc: Kana Sugimoto

Description

The radio school tutorial script MMB_MX_Tutorial.py fails as follows

Traceback (most recent call last):
  File "MMB_MX_Tutorial.py", line 27, in <module>
    data.set_selection(beams=beam, pols=pol)
  File "/usr/local/lib/python2.6/dist-packages/asap-3.1.0_trunk-py2.6.egg/asap/scantable.py", line 581, in set_selection
    self._setselection(selection)
RuntimeError: Selection contains no data. Not applying it.

Change History (5)

comment:1 Changed 13 years ago by Malte Marquarding

Owner: changed from Malte Marquarding to Kana Sugimoto

This is due to a self.copy call in the arguments to stmath._unaryop.

I have no idea why it got put there as this completely bypasses the insitu and selection behaviour.

Changed in r2320.

Kana can you verify specifically the arrayop.

comment:2 Changed 13 years ago by Kana Sugimoto

Status: newassigned

Could someone point out the script and data which raises the error, or let me know the way to reproduce it?

comment:3 Changed 13 years ago by anonymous

the error has been fixed. However, I have changed code for scantable with non-scalar operands whcih casa has introduced. I don't have regression tests for this in standard asap (yet).

comment:4 Changed 13 years ago by Kana Sugimoto

I see. I'll take a look at the code. Is the fix 2320?

comment:5 Changed 13 years ago by Kana Sugimoto

Resolution: fixed
Status: assignedclosed

I tested array operations by scantable.scale and fixed a bug.
The bug comes from a "feature" of the selector.add function, i.e., the reference to one of the selector is returned when the other one is empty selection. For instance,

scan = scantable('myscan.asap')
basesel = scan.get_selection() # basesel is empty because no selection has been applied.
sel = selector() + basesel

The last operation returns a reference to basesel (since selector() is an empty selection) and, hence, basesel is modified when sel is modified. This causes an unexpected behavior when you try to restore the initial selection to scan by

sel.set_rows([0,2,4])       # basesel is also modified since sel is reference to basesel
scan.set_selection(sel)     # rows 0, 2, and 4 are selected
scan.set_selection(basesel) # won't discard selections by row number

Although you can force returning a new selector instance by adding basesel frist, i.e.,

sel = basesel + selector()

it's misleading. I believe selector.add() should always retrun a new selector instance.

Note: See TracTickets for help on using tickets.