pipeline_utils.py
def createDiffs(model1, model2, filename):
    """Takes two models and creates constraint variables out of their paths.

    Parameters
    ----------
    model1 : mplus model object

    model2 : mplus model object

    filename : string where to write diffs
    """

    if len(model1.model) != len(model2.model):
        raise Exception("Models not the same")

    no_lines = len(model1.model)
    not_diffs = 0

    for i in range(no_lines):
        if model1.labels[i] == model2.labels[i]:
            not_diffs = not_diffs + 1

    lines = []

    start_line = "new(diff0-diff{});".format(no_lines - not_diffs - 1)

    counter = 0
    for i in range(no_lines):

        if model1.labels[i] == model2.labels[i]:
            line = "diffX = {1} - {2};".format(i, model1.labels[i],
                                             model2.labels[i])
            line = "! " + line
        else:
            line = "diff{0} = {1} - {2};".format(counter, model1.labels[i],
                                             model2.labels[i])
            counter = counter + 1

        lines.append(line)

    with open(filename, 'a') as f:

        f.write("MODEL CONSTRAINT:\n")
        f.write(start_line + "\n")

        for line in lines:
            f.write(line + "\n")
Takes two models and creates constraint variables out of their paths.

    Parameters
    ----------
    model1 : mplus model object

    model2 : mplus model object

    filename : string where to write diffs
    
Takes two models and creates constraint variables out of their paths.
Parameters

model1 : mplus model object

model2 : mplus model object

filename : string where to write diffs
Takes two models and creates constraint variables out of their paths . Parameters model1 : mplus model object model2 : mplus model object filename : string where to write diffs
def createDiffs(model1, model2, filename):
    if len(model1.model) != len(model2.model):
        raise Exception("Models not the same")
    no_lines = len(model1.model)
    not_diffs = 0
    for i in range(no_lines):
        if model1.labels[i] == model2.labels[i]:
            not_diffs = not_diffs + 1
    lines = []
    start_line = "new(diff0-diff{});".format(no_lines - not_diffs - 1)
    counter = 0
    for i in range(no_lines):
        if model1.labels[i] == model2.labels[i]:
            line = "diffX = {1} - {2};".format(i, model1.labels[i],
                                             model2.labels[i])
            line = "! " + line
        else:
            line = "diff{0} = {1} - {2};".format(counter, model1.labels[i],
                                             model2.labels[i])
            counter = counter + 1
        lines.append(line)
    with open(filename, 'a') as f:
        f.write("MODEL CONSTRAINT:\n")
        f.write(start_line + "\n")
        for line in lines:
            f.write(line + "\n")
def createDiffs ( model1 , model2 , filename ) : if len ( model1 . model ) != len ( model2 . model ) : raise Exception ( "Models not the same" ) no_lines = len ( model1 . model ) not_diffs = 0 for i in range ( no_lines ) : if model1 . labels [ i ] == model2 . labels [ i ] : not_diffs = not_diffs + 1 lines = [ ] start_line = "new(diff0-diff{});" . format ( no_lines - not_diffs - 1 ) counter = 0 for i in range ( no_lines ) : if model1 . labels [ i ] == model2 . labels [ i ] : line = "diffX = {1} - {2};" . format ( i , model1 . labels [ i ] , model2 . labels [ i ] ) line = "! " + line else : line = "diff{0} = {1} - {2};" . format ( counter , model1 . labels [ i ] , model2 . labels [ i ] ) counter = counter + 1 lines . append ( line ) with open ( filename , 'a' ) as f : f . write ( "MODEL CONSTRAINT:\n" ) f . write ( start_line + "\n" ) for line in lines : f . write ( line + "\n" )
Takes two models and creates constraint variables out of their paths.
Takes two models and creates constraint variables out of their paths .
"""Takes two models and creates constraint variables out of their paths.

    Parameters
    ----------
    model1 : mplus model object

    model2 : mplus model object

    filename : string where to write diffs
    """
model1
model2
filename