zamotivator

Untitled

May 7th, 2012
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. Source/Result? Chunks Sizes
  2.  
  3. Following cases should checked:
  4.  
  5. SAME:
  6. source_chunk_count == result_chunk_count - source and result chunks have same sizes (just change overlap, for example. See next article for details)
  7. ALIGNED-INCREASE:
  8. source_chunk_count > result_chunk_count
  9. exists whole positive number a (a < source_chunk_count) with (result_chunk_count * a == source_chunk_count)
  10. ALIGNED-DECREASE:
  11. source_chunk_count < result_chunk_count
  12. exists whole position number a (a < result_chunk_count) with (result_chunk_count == source_chunk_count * a)
  13. NOT-ALIGNED:
  14. source_chunk_count != result_chunk_count
  15. not exist whole positive numbers a (a < source_chunk_count) and b (b < result_chunk_count) with (result_chunk_count * a == source_chunk_count * b)
  16. PARTIALLY-ALIGNED':
  17. source_chunk_count != result_chunk_count
  18. not exists whole positive numbers a (a > 1 and a < source_chunk_count) and b (b > 1 and b < result_chunk_count) with (result_chunk_count * a == source_chunk_count) and (result_chunk_count == source_chunk_count * b)
  19. exists whole positive numbers c (c < source_chunk_count) and b (b < result_chunk_count) with (result_chunk_count * c == source_chunk_count * d)
  20.  
  21. Overlap
  22.  
  23. Following cases should be checked:
  24.  
  25. OVERLAP-NONE - no overlap in source and result.
  26. OVERLAP-SAME - source and result have same overlap.
  27. OVERLAP-ADD - source has not overlap, result has
  28. OVERLAP-REMOVE - source has overlap, result has not
  29. OVERLAP-INCREASE - result overlap bigger than source overlap
  30. OVERLAP-DECREASE - result overlap smaller than source overlap
  31.  
  32.  
  33.  
  34. def get_overlap(overlap):
  35. value= 1
  36. lesser= value * 2
  37. greater= value * 3
  38. d= {
  39. OVERLAP_NONE: { SOURCE: 0, RESULT: 0 },
  40. OVERLAP_SAME: { SOURCE: value, RESULT: value },
  41. OVERLAP_ADD: { SOURCE: 0, RESULT: value },
  42. OVERLAP_REMOVE: { SOURCE: value, RESULT: 0 },
  43. OVERLAP_INCREASE: { SOURCE: lesser, RESULT: greater },
  44. OVERLAP_DECREASE: { SOURCE: greater, RESULT: lesser }
  45. }
  46. return d[overlap]
  47.  
  48. # chunks sizes
  49. SAME='same'
  50. ALIGNED_INCREASE='aligned_increase'
  51. ALIGNED_DECREASE='aligned_decrease'
  52. NOT_ALIGNED='not_aligned'
  53. PARTIALLY_ALIGNED='partially_aligned'
  54.  
  55. CHUNK_SIZES_LIST=[SAME, ALIGNED_INCREASE, ALIGNED_DECREASE, NOT_ALIGNED, PARTIALLY_ALIGNED]
  56.  
  57. # overlap
  58. OVERLAP_SAME='overlap_same'
  59. OVERLAP_NONE='overlap_none'
  60. OVERLAP_ADD='overlap_add'
  61. OVERLAP_REMOVE='overlap_remove'
  62. OVERLAP_INCREASE='overlap_increase'
  63. OVERLAP_DECREASE='overlap_decrease'
  64.  
  65. OVERLAP_LIST=[OVERLAP_ADD, OVERLAP_REMOVE, OVERLAP_INCREASE, OVERLAP_DECREASE]
  66.  
  67. def get_chunk_settings(chunk_sizes):
  68. value= 2
  69. lesser= value
  70. greater= value * 2
  71. coprime_first= 2
  72. coprime_second= 3
  73. d= {
  74. SAME: { SIZE: { SOURCE: value, RESULT: value },
  75. COUNT: { SOURCE: value, RESULT: value } },
  76. ALIGNED_INCREASE: { SIZE: { SOURCE: lesser, RESULT: greater },
  77. COUNT: { SOURCE: greater, RESULT: lesser } },
  78. ALIGNED_DECREASE: { SIZE: { SOURCE: greater, RESULT: lesser },
  79. COUNT: { SOURCE: lesser, RESULT: greater } },
  80. NOT_ALIGNED: { SIZE: { SOURCE: coprime_first, RESULT: comprime_second },
  81. COUNT: { SOURCE: coprime_second, RESULT: comprime_first } },
  82. PARTIALLY_ALIGNED: { SIZE: { SOURCE: comprime_first*2, RESULT: coprime_second*2 },
  83. COUNT: { SOURCE: comprime_second*2, RESULT: comprime_first*2 } }
  84. }
  85. return d[overlap]
Advertisement
Add Comment
Please, Sign In to add comment