We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Describe the bug The coverage page shows multiple lines of metrics for a single file
Screenshots
Reason It seems the remove inside the inner for loop breaks the self.files list
remove
self.files
InfraBox/src/pyinfraboxutils/coverage.py
Lines 307 to 316 in 22c18ef
A more functional way of doing the same thing is
import itertools, functools tmp_files = [] get_filename = lambda f: f.name for _, group in itertools.groupby(sorted(self.files, key=get_filename), key=get_filename): tmp_files.append(functools.reduce(lambda a,b : a+b, group))
To Reproduce
class Account(object): def __init__(self, name, count): self.name = name self.count = count def __str__(self): return "Account[%s] = {%s}" % (self.name, self.count) def __add__(self, other): if type(other) is not Account: raise TypeError() if other.name != self.name: raise valueError() return Account(self.name, self.count + other.count) accounts = [ Account('a1', 1), Account('a1', 2), Account('a1', 3), Account('a1', 4), Account('a1', 5), ] temps = [] while accounts != []: f1 = accounts.pop(0) for f in accounts: if f.name == f1.name: f1 = f1 + f accounts.remove(f) temps.append(f1) for s in temps: print(s)
Which outputs
Account[a1] = {7} Account[a1] = {8}
The text was updated successfully, but these errors were encountered:
c0ceada
Merge pull request #407 from larryzju/coverage-fix
e9614af
fix #406
No branches or pull requests
Describe the bug
The coverage page shows multiple lines of metrics for a single file
Screenshots
Reason
It seems the
remove
inside the inner for loop breaks theself.files
listInfraBox/src/pyinfraboxutils/coverage.py
Lines 307 to 316 in 22c18ef
A more functional way of doing the same thing is
To Reproduce
Which outputs
The text was updated successfully, but these errors were encountered: