Sourcery refactored master branch - #1
sourcery-ai[bot] wants to merge 1 commit into
Conversation
| if _platform == 'darwin': | ||
| if not opt.is_client: | ||
| if not opt.is_client: | ||
| if _platform == 'darwin': |
There was a problem hiding this comment.
Lines 22-23 refactored with the following changes:
- Swap positions of nested conditionals (
swap-nested-ifs)
| for i, f in enumerate(images_list): | ||
| for f in images_list: | ||
| if f.endswith('.jpg') or f.endswith('.jpeg') or f.endswith('.png'): | ||
| img = cv2.imread(f) | ||
| if img is None: | ||
| log("Failed to open image: {}".format(f)) | ||
| log(f"Failed to open image: {f}") |
There was a problem hiding this comment.
Function load_images refactored with the following changes:
- Remove unnecessary calls to
enumeratewhen the index is not used (remove-unused-enumerate) - Replace call to format with f-string (
use-fstring-for-formatting)
| elif cam_frames := cam_selector.query_cameras(config['query_n_cams']): | ||
| cam_id = ( | ||
| list(cam_frames)[0] | ||
| if len(cam_frames) == 1 | ||
| else cam_selector.select_camera( | ||
| cam_frames, window="CLICK ON YOUR CAMERA" | ||
| ) | ||
| ) | ||
| log(f"Selected camera {cam_id}") | ||
|
|
||
| with open(cam_config, 'w') as f: | ||
| yaml.dump({'cam_id': cam_id}, f) | ||
| else: | ||
| log("No cameras are available") | ||
| with open(cam_config, 'w') as f: | ||
| yaml.dump({'cam_id': cam_id}, f) | ||
| else: | ||
| log("No cameras are available") |
There was a problem hiding this comment.
Function select_camera refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Use named expression to simplify assignment and conditional (
use-named-expression) - Replace if statement with if expression (
assign-if-exp)
| continue | ||
|
|
||
| for i in range(10): | ||
| for _ in range(10): |
There was a problem hiding this comment.
Function query_cameras refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore)
| cv2.putText(grid, f'Click on the web camera to use', (10, grid.shape[0] - 30), 0, 0.7, (200, 200, 200), 2) | ||
| cv2.putText( | ||
| grid, | ||
| 'Click on the web camera to use', | ||
| (10, grid.shape[0] - 30), | ||
| 0, | ||
| 0.7, | ||
| (200, 200, 200), | ||
| 2, | ||
| ) |
There was a problem hiding this comment.
Function select_camera refactored with the following changes:
- Replace f-string with no interpolated values with string (
remove-redundant-fstring)
| cam_frames = query_cameras(config['query_n_cams']) | ||
|
|
||
| if cam_frames: | ||
| if cam_frames := query_cameras(config['query_n_cams']): |
There was a problem hiding this comment.
Lines 104-106 refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
| adapt_movement_scale = 1 | ||
|
|
||
| kp_new = {k: v for k, v in kp_driving.items()} | ||
| kp_new = dict(kp_driving.items()) |
There was a problem hiding this comment.
Function normalize_kp refactored with the following changes:
- Replace identity comprehension with call to collection constructor (
identity-comprehension)
| kp_landmarks = self.fa.get_landmarks(image) | ||
| if kp_landmarks: | ||
| if kp_landmarks := self.fa.get_landmarks(image): | ||
| kp_image = kp_landmarks[0] | ||
| kp_image = self.normalize_alignment_kp(kp_image) | ||
| return kp_image | ||
| return self.normalize_alignment_kp(kp_image) |
There was a problem hiding this comment.
Function PredictorLocal.get_frame_kp refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| timing = AccumDict() | ||
| log = Logger('./var/log/predictor_worker.log', verbose=opt.verbose) | ||
|
|
There was a problem hiding this comment.
Function PredictorWorker.predictor_worker refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass)
| pad_h += int(sh * (h / w) - sh) // 2 | ||
| out = np.pad(img, [[pad_h, pad_h], [pad_w, pad_w], [0,0]], 'constant') | ||
| return out | ||
| return np.pad(img, [[pad_h, pad_h], [pad_w, pad_w], [0,0]], 'constant') |
There was a problem hiding this comment.
Function pad_img refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
Branch
masterrefactored 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
masterbranch, then run:Help us improve this pull request!