def TopNSummary(N, Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.series.insert_topN_into_series(N)
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    from transformations.utils.logger import logger
    
    #do not run if N too big.
    if (Matrix.Count < N):
        logger("Not enough rows in table to insert a Top " + str(N) + " series")
        return

    m = tr.MatrixManipulator(Matrix) 
    m.insert_topN_into_series(N)
    
    #v4.2 script inserted the row into a different position, 
    #This is placeing the inserted row at the end of the Matrix.
    newRow = Matrix.InsertBlankRowAfter(Matrix.SideAxis.DataMembers[Matrix.Count-1], "TopN", "Top " + str(N))
    Matrix.SwitchRows(0, Matrix.Count-1)
    Matrix.DeleteRow(0)
def make_matrix():
    """make a matrix either from test_matrix or by connecting to Slides."""

    # this imports category, category, data, text, pptx_data

    if use_test_data:
        # make a test matrix using create_test_matrix
        m = matrixfuncs.create_test_matrix()

    else:
        # make a matrix by connecting to Slides! and connecting to a data
        # table.
        import transformations.utils.slidesconf as slidesconf
        from Forgetdata.Matrix import ConnectionDefinition
        conn = ConnectionDefinition()
        conn.ConnectionString = mtd_filepath  # set at top of file
        conn.Name = "Test"
        conn.Provider = "SPSS MTD File"
        liveConnection = slidesconf.connect(conn.ConnectionString,
                                            name=conn.Name,
                                            provider_name=conn.Provider)

        m = liveConnection[table_selected]

    x = tr.MatrixManipulator(m)
    matrixfuncs.printMatrix(m)

    for c in m[0]:
        c.TopMember.Label = c.TopMember.Label.encode('ascii', 'ignore')

    return m, x
def InsertColumn(colIndex, name = "", label = "", Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.categories.insert_category()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    x = tr.MatrixManipulator(Matrix)
    x.insert_category(column_number = colIndex, label = label)    
def BaseSummaryToCategoryHeadings(Matrix=None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.categories.set_category_base_summary()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    x = tr.MatrixManipulator(Matrix)
    x.set_category_base_summary()
def NumberStatementsInMatrix(Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.series.number_series()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    x = tr.MatrixManipulator(Matrix)
    x.number_series(". ")
def MergeColumnsByLabel(Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.data.merge_categories_by_label()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    x = tr.MatrixManipulator(Matrix)
    x.merge_categories_by_label()
def UngroupRows(Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.data.make_series_from_grid_slices()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    x = tr.MatrixManipulator(Matrix)
    x.make_series_from_grid_slices()
def InsertRow(rowIndex, name = "", label = "", Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.series.insert_series()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    x = tr.MatrixManipulator(Matrix)
    x.insert_series(row_number = rowIndex, label = label)
def NumberDownbreaks(delimiter, Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.series.number_series()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    x = tr.MatrixManipulator(Matrix)
    x.number_series(delimiter)    
def RenumberSigTests(Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.data.renumber_sig_tests()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    m = tr.MatrixManipulator(Matrix)
    m.renumber_sig_tests() 
예제 #11
0
 def _do_sort(self, fill_rows):
     """Sort the values"""
     
     import transformations as tr
     myclass = tr.MatrixManipulator(self.matrix)
     if fill_rows:
         if self.query.SwitchRowsAndColumns == False:
             myclass.sort_columns()
         else:
             myclass.sort_rows()
     else:
         if self.query.SwitchRowsAndColumns == False:
             myclass.sort_rows()
         else:
             myclass.sort_columns()
def SortRows(byColumn = 0, usingCellValue = 0, descending = True, Matrix = None):
    """Adding Backwards compatibility support for v4.2 script
    
    Support for sorting rows using transformations.sorting.sort_rows()
    
    Note: after 4.2 sorting within Nets has been added, and therefore this will
    give a different result if nets are found.
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    cl = tr.MatrixManipulator(Matrix)
    cl.sort_rows(by_column = byColumn, using_cell_value = usingCellValue, descending = descending)
def ColumnDifference(x,y,Matrix=None):
    """Adding Backwards compatibility support for v4.2 script
    
    Use transformations.data.category_difference()
    
    """
    
    if Matrix == None:
        from globals import Matrix 
    import transformations as tr
    
    m = tr.MatrixManipulator(Matrix)
    m.category_difference(x,y)
    
    #4.2 script calculates diff as a number, not as percentage. 
    for r in Matrix:
        r[y+1][0].Value = str(r[y+1][0].GetNumericValue() * 100)