[pymvpa] little bugs in (Mapped)Dataset.selectFeatures ?

Emanuele Olivetti emanuele at relativita.com
Wed Mar 18 10:08:30 UTC 2009


Michael Hanke wrote:
> On Tue, Mar 17, 2009 at 05:45:28PM +0100, Emanuele Olivetti wrote:
>   
>> In line 130 of mvpa/datasets/mapped.py the MappedDataset.selectFeatutures()
>> calls "Dataset.selectFeatures(self, ids)" to do the actual selection.
>> Unfortunately the two methods has different default values for "sort":
>>  MappedDataset.selectFeatutures(self, ids, plain=False, sort=False)
>> while
>>  Dataset.selectFeatures(self, ids=None, sort=True, groups=None)
>> so the call in line 130 overrides MappedDataset with Dataset default value.
>> This means that whatever choice of "sort" is made in MappedDataset, it is
>> not considered when calling MappedDataset.selectFeatutures(). In other
>> words you get sorted features always, even if you say sort=False.
>>
>> I guess that line 130 should be simply:
>>     sdata = Dataset.selectFeatures(self, ids, sort)
>> But I'd like to ask your opinion on this since the Datasets architecture
>> and details are not fully clear to me yet.
>>     
>
> That sounds all sane to me (while the current behavior of that method is
> not ;-).
>
> I'd even say do 'selectFeatures(ids, sort=sort)'
>
>   

Done. See eo/master branch for the fix:
c48d4ead7b85535582c4d333d6b0dd455383a7b1

>> Another detail: if you choose to sort IDs (sort=True) then the vector of
>> IDs "ids" passed as argument to the selectFeatures() method is sorted as
>> well. When the user calls MappedDataset.selectFeatutures(ids) he/she
>> gets a new dataset and... unexpectedly "ids" is sorted. This caused a
>> bit of headache to me today. Is this unexpected side-effect necessary?
>>     
>
> No, this is also a bug.
>
>   

I worked on this bug and provided a fix. You can see in
under eo/master branch. Basically now Dataset.selectFeatures()
works on a copy of 'ids'.
(see abb019bbdca0218427e64a84d5295d5cf83f74b0)

I added a test to avoid regression in future.
(see 5ca4ddd398255670280c9bef573547624b8ba3ec)

WARNING: after the side-effect fix another test on
Dataset.selectFeatures() fails now. I'm not much able to understand
it, so please have a look and decide whether the fix is wrong or the
failing test is wrong.


Best,

Emanuele




More information about the Pkg-ExpPsy-PyMVPA mailing list