Skip to content

Commit

Permalink
Fixed events type management
Browse files Browse the repository at this point in the history
  • Loading branch information
cristian-mattarei committed Oct 25, 2017
1 parent 058f6b5 commit 0bb4aaf
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ext_tools/programs_generator.py
Expand Up @@ -50,14 +50,20 @@ def is_canonic(word):
return sorted(rep) == rep

def writes_count(word):
return len([el for el in word if el in [RIU,RIA,RF]])
return len([el for el in word if el[0] in [WIU,WIA,WF]])

def reads_count(word):
return len([el for el in word if el[0] in [RIU,RIA,RF]])

def read_or_modify_count(word):
return len(word) - writes_count(word)

def only_writes(word):
return len(word) == writes_count(word)

def only_reads(word):
return len(word) == reads_count(word)


def check_correctness(ev):
ty, size = ev[:2]
Expand Down Expand Up @@ -177,10 +183,10 @@ def generate_programs(params):
word = random.sample(possible_events, num_events)
picked.add(str(word))

if only_writes(word[0]):
if only_writes(word) or only_reads(word):
continue

if (max_roms != -1) and (read_or_modify_count(word[0]) > max_roms):
if (max_roms != -1) and (read_or_modify_count(word) > max_roms):
continue

iterops = itertools.product(operators, repeat=(num_events-1))
Expand Down

0 comments on commit 0bb4aaf

Please sign in to comment.