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

Sourcery refactored master branch #407

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

sourcery-ai[bot]
Copy link

@sourcery-ai sourcery-ai bot commented Aug 3, 2023

Branch master refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch origin sourcery/master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from gjbex August 3, 2023 07:07
Copy link
Author

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to GitHub API limits, only the first 60 comments can be shown.

print("epoch:%s, iter:%s" % (i, j))
print(f"epoch:{i}, iter:{j}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function train refactored with the following changes:

center = data[0:2]
center = data[:2]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function compute_segments refactored with the following changes:

Comment on lines -20 to +25
time_avg = float(match.group(1))
time_avg = float(match[1])
nr_timings += 1
continue
match = re.match('^procs: (\d+)$', line)
if match is not None:
nr_procs = int(match.group(1))
nr_procs = int(match[1])
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 20-25 refactored with the following changes:

if options.version == '3':
version = 'NETCDF3_CLASSIC'
else:
version = 'NETCDF4'
version = 'NETCDF3_CLASSIC' if options.version == '3' else 'NETCDF4'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 20-23 refactored with the following changes:

avail_nucls = available_nucl(nucl_left)
if avail_nucls:
if avail_nucls := available_nucl(nucl_left):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_nucl refactored with the following changes:

Comment on lines -44 to +47
if not rows:
msg = "constant '{0}' is undefined".format(name)
raise UnknownConstantError(msg)
else:
if rows:
return rows[0][0]
msg = "constant '{0}' is undefined".format(name)
raise UnknownConstantError(msg)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ConstantDb.get_value refactored with the following changes:

if n > 1:
return n*fac(n - 1)
else:
return 1
return n*fac(n - 1) if n > 1 else 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fac refactored with the following changes:

print('account: ' + options.account)
print(f'account: {options.account}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 22-22 refactored with the following changes:

args = list()
args = []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parse_job_script refactored with the following changes:

if len(sys.argv) > 1:
cfg_file = sys.argv[1]
else:
cfg_file = 'defaults.conf'
cfg_file = sys.argv[1] if len(sys.argv) > 1 else 'defaults.conf'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

Comment on lines -40 to -43
with ContextTest(1) as c1, ContextTest(2) as c2:
with (ContextTest(1) as c1, ContextTest(2) as c2):
print('in context {0}'.format(c1._context_nr))
raise Exception()
print('in context {0}'.format(c2._context_nr))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

if mode == float:
return [float(item) for item in items]
else:
return items
return [float(item) for item in items] if mode == float else items
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function process_line refactored with the following changes:

Comment on lines -37 to +34
averagers = [stats() for name in names]
averagers = [stats() for _ in names]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 37-37 refactored with the following changes:

for iter_nr in range(options.iter):
for _ in range(options.iter):
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 28-28 refactored with the following changes:

Comment on lines -7 to +16
if kmax > 1000:
kmax = 1000
kmax = min(kmax, 1000)
k = 0
n = 2
while k < kmax:
i = 0
while i < k and n % p[i] != 0:
i = i + 1
i += 1
if i == k:
p[k] = n
k = k + 1
k += 1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function primes refactored with the following changes:

Comment on lines -40 to +42
data = dict()
data['time'] = list()
data = {'time': []}
for var in meta_data:
data[meta_data[var]] = list()
data[meta_data[var]] = []
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function init_data refactored with the following changes:

Comment on lines -49 to +48
buffer = dict()
buffer = {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function parse_data refactored with the following changes:

Comment on lines -71 to +70
data_line = list()
for var in columns:
data_line.append(data[var][time_step])
data_line = [data[var][time_step] for var in columns]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function write_vcd_data_structure refactored with the following changes:

jobs = []
for name in names:
jobs.append((random.random(), name))
return jobs
return [(random.random(), name) for name in names]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function create_jobs refactored with the following changes:

if len(args) != 1 and len(args) != 3:
if len(args) not in [1, 3]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ExperimentShell.parse_show_arg refactored with the following changes:

Comment on lines -71 to +82
else:
if cls == Experiment:
items = self._db_session.\
elif cls == Experiment:
items = self._db_session.\
query(Experiment).\
join(staff_assignments).\
filter_by(researcher_id=item_id).all()
elif cls == Researcher:
items = self._db_session.\
elif cls == Researcher:
items = self._db_session.\
query(Researcher).\
join(staff_assignments).\
filter_by(experiment_id=item_id).all()
elif cls == Sample:
items = self._db_session.\
elif cls == Sample:
items = self._db_session.\
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ExperimentShell.do_show refactored with the following changes:

print('\t{}'.format(sample.description))
print(f'\t{sample.description}')
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 20-29 refactored with the following changes:

Comment on lines -11 to +14
cities = []
for city_nr in range(nr_cities):
cities.append(''.join([random.choice(string.letters)
for i in range(code_length)]))
return cities
return [
''.join([random.choice(string.letters) for _ in range(code_length)])
for _ in range(nr_cities)
]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function generate_city_codes refactored with the following changes:

if n == 0:
return 1
else:
return n*fact(n - 1)
return 1 if n == 0 else n*fact(n - 1)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fact refactored with the following changes:

if n < 2:
return 1
else:
return fib_memoized(n - 1) + fib_memoized(n - 2)
return 1 if n < 2 else fib_memoized(n - 1) + fib_memoized(n - 2)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function fib_memoized refactored with the following changes:

Comment on lines -15 to +16
if coord[0] - 1 >= 0:
if coord[0] >= 1:
neighbours.append((coord[0] - 1, coord[1]))
if coord[0] + 1 < size:
neighbours.append((coord[0] + 1, coord[1]))
if coord[1] - 1 >= 0:
if coord[1] >= 1:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function compute_neighbouts refactored with the following changes:

Comment on lines -29 to +26
while len(queue) > 0:
while queue:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function find_domain refactored with the following changes:

Comment on lines -39 to +36
domains = []
for _ in range(len(lattice)):
domains.append([-1] * len(lattice))
domains = [[-1] * len(lattice) for _ in range(len(lattice))]
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function identify_domains refactored with the following changes:

if len(sys.argv) > 1:
n = int(sys.argv[1])
else:
n = 10
n = int(sys.argv[1]) if len(sys.argv) > 1 else 10
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

if n == 1 or n == 2:
if n in [1, 2]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function all_fibonacci refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants