Conversation
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.59%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! Help us improve this quality report! |
|
|
||
| self.frequency = frequency | ||
|
|
||
| self.frame_length = 47 |
There was a problem hiding this comment.
why 47? Can you add a comment pointing to a source or explaining it.
| return len(list(filter(lambda x: x is not None, self.bytes))) | ||
|
|
||
| def get_frame_length(self): | ||
| return 44 + 8 * self.get_length() |
There was a problem hiding this comment.
why 44 and 8? Can you add a comment pointing to a source or explaining it.
| loads = can.get_can_load_by_topic() | ||
| ids = list(loads.keys()) | ||
| ids.sort() | ||
| for id in ids: | ||
| print("Id: ", id, "load:", loads[id]) | ||
| print("Total load:", round(can.get_can_load(),3), "%") |
There was a problem hiding this comment.
Can you extract out these lines into a helper function?
| modules = [] | ||
| signature = [] | ||
| ids = [] | ||
| names = [] | ||
| frequency = [] | ||
| load = [] | ||
| frame_length = [] | ||
| description = [] | ||
|
|
||
| for module in self.modules: | ||
| for topic in module["topics"]: | ||
| modules.append(module["name"]) | ||
| signature.append(module["signature"]) | ||
| ids.append(topic["id"]) | ||
| names.append(topic["name"]) | ||
| frequency.append(round(topic["frequency"],3)) | ||
| load.append(round(self.get_topic_load(topic),3)) | ||
| frame_length.append(topic["frame_length"]) | ||
| description.append(topic["description"]) | ||
|
|
||
| df = pd.DataFrame({ | ||
| "modules":modules, | ||
| "signature": signature, | ||
| "name": names, | ||
| "ids": ids, | ||
| "frequency": frequency, | ||
| "load": load, | ||
| "frame_length": frame_length, | ||
| "description": description, | ||
| }) |
There was a problem hiding this comment.
Since this data is small it is okay doing it this way, but note that for bigger data, possibly it would be better convert it to a DataFrame first, then group / add / remove columns as you need.
| # load = period for 1 msg * frequency * 100% | ||
| # Reference: | ||
| # https://support.vector.com/kb?id=kb_article_view&sysparm_article=KB0012332&sys_kb_id=99354e281b2614148e9a535c2e4bcb6d&spa=1 |
There was a problem hiding this comment.
Always great to have references, move it on the beginning of the function
Compute bus load with the size of the frame, message frequency, and bit rate
And implement figures to better analyzes