[Rivet] [Rivet-svn] r2974 - trunk/bin

Andy Buckley andy.buckley at ed.ac.uk
Sat Feb 26 00:35:44 GMT 2011


>>> analyses = ["MC_FOO_BAR", "CDF_2009_S6666", "D0_2005_S332"]
>>> sorted(analyses, key=anasort, reverse=True)
['MC_FOO_BAR', 'CDF_2009_S6666', 'D0_2005_S332']
>>> sorted(analyses, key=anasort, reverse=False)
['D0_2005_S332', 'CDF_2009_S6666', 'MC_FOO_BAR']

So yes, verified! Now

>>> [anasort(a) for a in analyses]
['0MC_FOO_BAR', ['2009', 'S6666'], ['2005', 'S332']]
>>> '0MC_FOO_BAR' < ['2009', 'S6666']
False
>>> '0MC_FOO_BAR' > ['2009', 'S6666']
True

So apparently strings are always greater than lists! Maybe 'return
"_".join(name.split("_")[1:])' or similar?

Andy


On 26/02/11 01:01, Frank Siegert wrote:
>> Author: fsiegert
>> Date: Fri Feb 25 22:18:33 2011
>> New Revision: 2974
>>
>> Log:
>> Re-instate original analysis sorting in rivet-mkhtml, but move MC_*
>> analyses to the back.
> 
> Moving MC_* analyses to the back doesn't seem to work here, and I don't
> understand why. Any Python guru have an idea?
> 
> Cheers,
> Frank
> 
>>
>> Modified:
>>     trunk/bin/rivet-mkhtml
>>
>> Modified: trunk/bin/rivet-mkhtml
>> ==============================================================================
>>
>> --- trunk/bin/rivet-mkhtml    Fri Feb 25 13:19:13 2011    (r2973)
>> +++ trunk/bin/rivet-mkhtml    Fri Feb 25 22:18:33 2011    (r2974)
>> @@ -124,10 +124,9 @@
>>               reffiles.append(reffile)
>>
>>   def anasort(name):
>> -    if len(name.split("_"))==3 and not name.startswith("MC"):
>> -        if name.split("_")[2].startswith("S"):
>> -            return name.split("_")[2][1:]
>> -    return "0"+name
>> +    if name.startswith("MC"):
>> +        return "0"+name
>> +    return name.split("_")[1:]
>>   analyses=sorted(analyses, key=anasort, reverse=True)
>>
>>
>> _______________________________________________
>> Rivet-svn mailing list
>> Rivet-svn at projects.hepforge.org
>> http://www.hepforge.org/lists/listinfo/rivet-svn
> _______________________________________________
> Rivet mailing list
> Rivet at projects.hepforge.org
> http://www.hepforge.org/lists/listinfo/rivet
> 


-- 
Dr Andy Buckley
SUPA Advanced Research Fellow
Particle Physics Experiment Group, University of Edinburgh

The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.



More information about the Rivet mailing list