Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use defaults args for range() #1613

Merged
merged 1 commit into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion base/src/acton/rts.act
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ actor WThreadMonitor(env: Env, arg_wthread_id: int):
actor Monitor(env: Env):
tms: dict[int, WThreadMonitor] = {}

for wthread_id in range(1, env.nr_wthreads+1, 1):
for wthread_id in range(1, env.nr_wthreads+1):
tm = WThreadMonitor(env, wthread_id)
tms[wthread_id] = tm

Expand Down
4 changes: 2 additions & 2 deletions base/src/argparse.act
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class Parser(object):

posargs = []
skip = 0
for i in range(0, len(argv), 1):
for i in range(len(argv)):
p = i + skip
if p >= len(argv):
break
Expand Down Expand Up @@ -254,7 +254,7 @@ class Parser(object):
else:
posargs.append(arg)

for i in range(0, len(posargs), 1):
for i in range(len(posargs)):
arg = posargs[i]
if len(self.args) == 0:
rest.append(arg)
Expand Down
2 changes: 1 addition & 1 deletion base/src/http.act
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def hex_to_decimal(hex_str: str) -> int:
'8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}
decimal_value = 0
try:
for i in range(0, len(hex_str), 1):
for i in range(len(hex_str)):
j = len(hex_str)-i
digit = hex_str[j-1].upper()
decimal_value += hex_map[digit] * (16 ** i)
Expand Down
6 changes: 3 additions & 3 deletions base/src/random.act
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def sample[T](population: list[T], k: int) -> list[T]:
raise ValueError("Sample larger than population or is negative")

result = []
indices = list(range(0, len(population), 1))
for _ in range(0, k, 1):
indices = list(range(len(population)))
for _ in range(k):
idx_to_pop = choice(indices)
idx = 0
for i in range(0, len(indices), 1):
for i in range(len(indices)):
if indices[i] == idx_to_pop:
idx = i
break
Expand Down
2 changes: 1 addition & 1 deletion base/src/re.act
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# def __str__(self):
# res = "("
# l = len(self.p)
# for i in range(0, l, 1):
# for i in range(l):
# res += str(self.p[i])
# if i < l-1:
# res += "|"
Expand Down
4 changes: 2 additions & 2 deletions base/src/testing.act
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ actor test_runner(env: Env, unit_tests: dict[str, UnitTest], sync_actor_tests: d
print()
env.exit(0)

for i in range(0, env.nr_wthreads, 1):
for i in range(env.nr_wthreads):
unit_test_runner(i, get_test, report_result)

proc def _run_sync_actor_tests(args):
Expand Down Expand Up @@ -583,7 +583,7 @@ actor test_runner(env: Env, unit_tests: dict[str, UnitTest], sync_actor_tests: d
for ut in unit_tests.values():
test_res = []
try:
for iteration in range(0, args.get_int("iterations"), 1):
for iteration in range(args.get_int("iterations")):
acton.rts.gc(env.syscap) # explicit GC collection
mem_before = acton.rts.get_mem_usage(env.syscap)
sw = time.Stopwatch()
Expand Down
2 changes: 1 addition & 1 deletion examples/reprtest.act
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ actor main(env):
s.add("def")
print(s)
d = {}
for i in range(0,10,1):
for i in range(10):
d[i] = str(i)
print(d)
env.exit(0)
Expand Down
4 changes: 2 additions & 2 deletions examples/sieve.act
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import math
def sieve(n):
isPrime = [True] * n
isPrime[0] = False; isPrime[1] = False
for i in range(2,int(math.sqrt(float(n)))+1,1):
for i in range(2, int(math.sqrt(float(n)))+1):
if isPrime[i]:
for k in range(i*i,n,i): isPrime[k] = False

Expand All @@ -20,7 +20,7 @@ def count(bs):
def primesTo(n):
res = []
isPrime = sieve(n)
for i in range(2,n,1):
for i in range(2, n):
if isPrime[i]: res.append(i)
return res

Expand Down
2 changes: 1 addition & 1 deletion examples/sumto2.act
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import numpy
import math

def sumto(n):
a = numpy.arange(0,n,1)
a = numpy.arange(0, n)
return numpy.sum(a,None)

actor main(env):
Expand Down
2 changes: 1 addition & 1 deletion test/builtins_auto/builtin_functions_test.act
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
lst = list(range(10, 15, 1))
lst = list(range(10, 15))

def even(n):
return n % 2 == 0
Expand Down
8 changes: 4 additions & 4 deletions test/builtins_auto/bytearray_test.act
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ actor main(env):
# TODO: fix all this?
# b = bytearray(lst0)
# print(b.center(25,None))
# lst2 = list(range(65,91,1))
# lst2 = list(range(65, 91))
# b2 = bytearray(lst2)
# print(b2)
# b3 = bytearray(list(range(75,77,1)))
# b3 = bytearray(list(range(75, 77)))
# n = b2.find(b3,0,-1);
# print(b3,"occurs in",b2,"at pos",n)
# b4 = bytearray(10)
# print("bytearray(10) gives",b4)
# b4 = b.center(20,None)
# print(b.lstrip(b4))
# sep = bytearray(list(range(70,72,1)))
# sep = bytearray(list(range(70, 72)))
# print(b2.split(sep,None))
# b5 = bytearray("line 1\nline 2\r\n\nBjörn")
# print(b5)
# print(b5.splitlines(None))
# print(b5.splitlines(True))
# lst = list(b2)
# print(lst[1:20:2])
# for i in range(0,1000,1):
# for i in range(1000):
# b2.append(65+i%26) #add repeated copies of upper case alphabet
# for i in range(26,1,-1):
# del b2[0:10000:i] # delete everything except the Z's
Expand Down
2 changes: 1 addition & 1 deletion test/builtins_auto/container_test.act
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
actor main(env):
lst = list(range(1,100,1))
lst = list(range(1, 100))
if 17 not in lst or 171 in lst or 100 in lst:
env.exit(1)
env.exit(0)
Expand Down
6 changes: 3 additions & 3 deletions test/builtins_auto/dict_test2.act
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
actor main(env):
dict = {}
other = {}
for i in range(1,1000,1):
for i in range(1, 1000):
dict[str(i)] = str(i+1)
r = 17
s = 0
for j in range(1,200,1):
for j in range(1, 200):
r = r*r % 1000
s += int(dict[str(r)])
if s != 99446:
env.exit(1)
if str(678) not in dict:
env.exit(1)
for i in range(1,1000,1):
for i in range(1, 1000):
if i%10 > 0:
del dict[str(i)]
if len(dict) != 99:
Expand Down
4 changes: 2 additions & 2 deletions test/builtins_auto/list.act
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ actor main(env):
await async env.exit(1)

#shrinking
l = list(range(0,30,1))
for i in range(0,20,1):
l = list(range(30))
for i in range(20):
l.pop(-1)
if len(l) != 10 or l[4] != 4:
print("Unexpected shrinking of list")
Expand Down
4 changes: 2 additions & 2 deletions test/builtins_auto/protocol_test.act
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def concat(seq, zero):

actor main(env):
var lst = []
for i in range(1,10,1):
lst.append(list(range(i,2*i,1)))
for i in range(1, 10):
lst.append(list(range(i, 2*i)))

lst2 = concat(lst, [])
print(lst2)
Expand Down
6 changes: 3 additions & 3 deletions test/builtins_auto/set_test.act
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
actor main(env):
s = {400}
for i in range(13,1000,1):
for i in range(13, 1000):
s.add(i*i)
s.discard(64)
s.discard(225)
s.discard(10000)
n = 0
for k in range(0,1000,1):
for k in range(1000):
if k in s: n += 1
if n != 18:
raise ValueError("n is" + str(n) + ", not 18")

env.exit(1)
s2 = {1}
for i in range(0,500,1):
for i in range(500):
s2.add(i*i*i*i)
if len(s) != 985 or len(s2) != 500:
raise ValueError("set length error 1")
Expand Down
6 changes: 3 additions & 3 deletions test/builtins_auto/slice_test.act
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
actor main(env):
lst = list(range(0,100,1))
lst = list(range(100))
lst2 = lst[-1:0:-2]
lst2[10:30:2] = range(100,110,1)
lst4 = list(range(0,1000,1))
lst2[10:30:2] = range(100, 110)
lst4 = list(range(1000))
for i in range(100,1,-1):
del lst4[1:1000:i]
if sum(lst4,0) != 4500:
Expand Down
2 changes: 1 addition & 1 deletion test/perf-benchgames/edigits/1.act
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ actor main(env):
print(s[i:i+10] + "\t:" + str(i+10))
else:
spaces = ""
for j in range(0, (10-(len(str(s[i:])))), 1):
for j in range(10-len(str(s[i:]))):
spaces += " "
print(s[i:] + spaces + "\t:" + str(n))
#print(f'{s[i:]}{" "*(10-n%10)}\t:{n}')
Expand Down
8 changes: 4 additions & 4 deletions test/perf-benchgames/spectral-norm/1.act
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ def eval_A(i, j):

def eval_A_times_u(u):
res = []
for i in range(0, len(u), 1):
for i in range(len(u)):
res.append(part_A_times_u(i,u))
return res

def eval_At_times_u(u):
res = []
for i in range(0, len(u), 1):
for i in range(len(u)):
res.append(part_At_times_u(i,u))
return res

Expand All @@ -36,13 +36,13 @@ actor main(env):
var u = [1] * int(env.argv[1])
var v = []

for dummy in range(0, 10, 1):
for dummy in range(10):
v = eval_AtA_times_u(u)
u = eval_AtA_times_u(v)

vBv = vv = 0

for i in range(0, len(u), 1):
for i in range(len(u)):
ue = u[i]
ve = v[i]
vBv += ue * ve
Expand Down
12 changes: 6 additions & 6 deletions test/perf/src/pairs.act
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ actor Node(name: str, _affinity: int):
counter += 1
tokens += 1
if not _stop and tokens > 0 and partner is not None:
for i in range(0, 1000, 1):
for i in range(1000):
if tokens == 0:
return
tokens -= 1
Expand All @@ -58,12 +58,12 @@ actor Pairs(wthreads, num_pairs):
nodes = []
var count = 0

for i in range(0, num_pairs*2, 1):
for i in range(num_pairs*2):
affinity = int(i // 2) % wthreads
n = Node(str(i), affinity+1)
nodes.append(n)

# for i in range(0, num_pairs, 1):
# for i in range(num_pairs):
# affinity = i % wthreads
# n1 = Node(str(i), affinity+1)
# n2 = Node(str(i+1), affinity+1)
Expand All @@ -81,19 +81,19 @@ actor Pairs(wthreads, num_pairs):

def get_count():
count = 0
for i in range(0, num_pairs*2, 1):
for i in range(num_pairs*2):
c = nodes[i].get_count()
print("Actor %d:" % i, c)
count += c
return count

def start():
# print("Starting...")
for i in range(0, num_pairs*2, 1):
for i in range(num_pairs*2):
nodes[i].ping()

def stop():
for i in range(0, num_pairs*2, 1):
for i in range(num_pairs*2):
nodes[i].stop()


Expand Down
6 changes: 3 additions & 3 deletions test/perf/src/ring.act
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ actor main(env):
stop_at = float(env.argv[2])

nodes = []
for i in range(0, num_nodes, 1):
for i in range(num_nodes):
n = Node(i)
nodes.append(n)
for i in range(0, num_nodes-1, 1):
for i in range(num_nodes-1):
nodes[i].set_next(nodes[i+1])
nodes[-1].set_next(nodes[0])
a = nodes[0].ping()

var count = 0
def stop():
for i in range(0, num_nodes, 1):
for i in range(num_nodes):
c = nodes[i].get_count()
print("Actor %d:" % i, c)
count += c
Expand Down
2 changes: 1 addition & 1 deletion test/regression_auto/signature_with_typeargs.act
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lst : list[int]
lst = list(range(10,14,1))
lst = list(range(10, 14))

actor main(env):
print(lst==[10,11,12,13])
Expand Down
6 changes: 3 additions & 3 deletions test/rts_db/test_db_app.act
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ actor Tester(env, verbose, port_chunk):
are_we_done()

def dbc_start():
for i in range(0, 3, 1):
for i in range(3):
port = port_chunk + (2*i)
cmd = ["../dist/bin/actondb", "-p", str(port)]
p = process.Process(process_cap, cmd, None, None, on_stdout, on_stderr, db_on_exit, on_error)
Expand All @@ -113,9 +113,9 @@ actor Tester(env, verbose, port_chunk):
psp[paid] = "db%d" % i

def db_args(start_port, replication_factor) -> list[str]:
#a = ["127.0.0.1:" for idx in range(0, replication_factor, 1)]
#a = ["127.0.0.1:" for idx in range(replication_factor)]
args = ["--rts-ddb-replication", str(replication_factor)]
for idx in range(0, replication_factor, 1):
for idx in range(replication_factor):
args.append("--rts-ddb-host")
args.append("127.0.0.1:" + str(start_port + idx*2))
return args
Expand Down
Loading