Ignore:
Timestamp:
Apr 28, 2012, 5:23:05 PM (7 years ago)
Author:
ksherdy
Message:

Added in log2 pablo statements. Updated Python demo.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/symbol_table/demo_strms.py

    r2055 r2065  
    22import marker_strms
    33import div2_group_strms
     4import log2_group_strms
    45import sys
    56
     
    1617def Demo_div2(u8data, basis_bits):
    1718
    18     lgth = 100 + 1
     19    lgth = len(u8data)
    1920
    2021    markers = marker_strms.Markers()
     
    3334        ('groups.starts', bitstream2string(groups.starts, lgth)),
    3435        ('groups.ends', bitstream2string(groups.ends, lgth)),
    35         ('groups.ends_1_2', bitstream2string(groups.ends_2, lgth)),
    36         ('groups.ends_3_4', bitstream2string(groups.ends_4, lgth)),
    37         ('groups.ends_5_6', bitstream2string(groups.ends_6, lgth)),
    38         ('groups.ends_7_8', bitstream2string(groups.ends_8, lgth)),
    39         ('groups.ends_9_10', bitstream2string(groups.ends_10, lgth)),
    40         ('groups.ends_11_12', bitstream2string(groups.ends_12, lgth)),
    41         ('groups.ends_13_14', bitstream2string(groups.ends_14, lgth)),
    42         ('groups.ends_15_16', bitstream2string(groups.ends_16, lgth)),
     36        ('groups.ends_2', bitstream2string(groups.ends_2, lgth)),
     37        ('groups.ends_4', bitstream2string(groups.ends_4, lgth)),
     38        ('groups.ends_6', bitstream2string(groups.ends_6, lgth)),
     39        ('groups.ends_8', bitstream2string(groups.ends_8, lgth)),
     40        ('groups.ends_10', bitstream2string(groups.ends_10, lgth)),
     41        ('groups.ends_12', bitstream2string(groups.ends_12, lgth)),
     42        ('groups.ends_14', bitstream2string(groups.ends_14, lgth)),
     43        ('groups.ends_16', bitstream2string(groups.ends_16, lgth)),
    4344        ('groups.ends_gte_17', bitstream2string(groups.ends_gte_17, lgth))])
     45
     46def Demo_log2(u8data, basis_bits):
     47
     48    lgth = len(u8data)
     49
     50    markers = marker_strms.Markers()
     51    marker_strms.Classify_markers(basis_bits, markers)
     52    marker_strms.Generate_markers(markers)
     53
     54    groups = log2_group_strms.Groups()
     55    groups.starts = markers.starts
     56    groups.ends = markers.ends
     57    log2_group_strms.Gen_lgth_groups(groups)
     58
     59    print_aligned_streams([('Input Data', u8data),
     60        ('markers.spans', bitstream2string(markers.spans, lgth)),
     61        ('markers.starts', bitstream2string(markers.starts, lgth)),
     62        ('markers.ends', bitstream2string(markers.ends, lgth)),
     63        ('groups.starts', bitstream2string(groups.starts, lgth)),
     64        ('groups.ends', bitstream2string(groups.ends, lgth)),
     65        ('groups.ends_1', bitstream2string(groups.ends_1, lgth)),
     66        ('groups.ends_2', bitstream2string(groups.ends_2, lgth)),
     67        ('groups.ends_4', bitstream2string(groups.ends_4, lgth)),
     68        ('groups.ends_8', bitstream2string(groups.ends_8, lgth)),
     69        ('groups.ends_16', bitstream2string(groups.ends_16, lgth)),
     70        ('groups.ends_gte_17', bitstream2string(groups.ends_gte_17, lgth))])
    4471
    4572if __name__ == "__main__":
    4673
    4774    if len(sys.argv) < 2:
    48         sys.stderr.write("Usage: python " + filename + " <filename>" "\n")
     75        sys.stderr.write("Usage: python " + filename + " <filename>\n")
    4976        sys.exit(2)
    5077
     
    6390    basis_bits.bit_7 = b[7]
    6491
    65     Demo_div2(u8data, basis_bits)
     92    # Demo_div2(u8data, basis_bits)
     93    Demo_log2(u8data, basis_bits)
    6694
Note: See TracChangeset for help on using the changeset viewer.