import pandas as pd
import numpy as np
import os
import sys

sys.path.insert(0, os.path.dirname(__file__))
from ListCommon import *

sumFile = open( sys.argv[1], 'w' )
detFile = open( sys.argv[2], 'w' )

# for mvmt+polarity effects, where lq-list doesn't support queue or inslast
noLqList = ['cfa-cfa', 'upp-upp', 'lq-tailq']

printHistos(
    tgtMovement = 'all',
    tgtPolarity = 'all',
    tgtAccessor = 'all',
    lateFilter = { 'machine': ['swift'],
                   'SizeZone': ['ML'] },
    drillOn=['machine', 'SizeZone', 'fx'],
    marginalizeOn=['SizeZone'],
    sumFile = sumFile,
    detFile = detFile )

printHistos(
    tgtMovement = 'all',
    tgtPolarity = 'all',
    tgtAccessor = 'all',
    lateFilter = { 'machine': ['java'],
                   'SizeZone': ['ML'] },
    drillOn=['machine', 'SizeZone', 'fx'],
    marginalizeOn=['SizeZone'],
    sumFile = sumFile,
    detFile = detFile )

printHistos(
    tgtMovement = 'all',
    tgtPolarity = 'all',
    tgtAccessor = 'all',
    lateFilter = { 'movement': ['queue'],
                   'fx': noLqList },
    drillOn=['movement', 'fx'],
    marginalizeOn=['movement'],
    sumFile = sumFile,
    detFile = detFile )

printHistos(
    tgtMovement = 'all',
    tgtPolarity = 'all',
    tgtAccessor = 'all',
    lateFilter = { 'polarity': ['inslast'],
                   'fx': noLqList },
    drillOn=['polarity', 'fx'],
    marginalizeOn=['polarity'],
    sumFile = sumFile,
    detFile = detFile )

printHistos(
    tgtMovement = 'all',
    tgtPolarity = 'all',
    tgtAccessor = 'all',
    earlyFilter = { 'accessor': ['allhead', 'inselem'] }, # set up head-to-head benchmarking
    lateFilter = { 'accessor': ['inselem'] }, # show one side of the mirror, as usual
    drillOn=['accessor', 'fx'],
    marginalizeOn=['accessor'],
    sumFile = sumFile,
    detFile = detFile )

printHistos(
    tgtMovement = 'all',
    tgtPolarity = 'all',
    tgtAccessor = 'all',
    earlyFilter = { 'accessor': ['allhead', 'remelem'] },
    lateFilter = { 'accessor': ['remelem'] },
    drillOn=['accessor', 'fx'],
    marginalizeOn=['accessor'],
    sumFile = sumFile,
    detFile = detFile )
