Conversation
6aee5f8 to
fb1afdb
Compare
|
@davidplowman here's a first pass to look at. |
| QVBoxLayout, | ||
| QWidget, | ||
| ) | ||
|
|
There was a problem hiding this comment.
This shows some of the obvious differences. It will break right at an open bracket (, and not after the next token or parameter. Then it will put every subsequent item one-per-line. Finally, the last item will have a trailing comma ,.
I don't think I mind any of this too much, the most important thing is that it's legible and easy to follow. Sometimes the one-item-per-line thing seems a bit extreme and it might be nicer to be able to group things.
| black_level = metadata["SensorBlackLevels"][0] / 2 ** (16 - raw_format.bit_depth) | ||
| accumulated -= (num_frames - 1) * int(black_level) | ||
| accumulated = accumulated.clip(0, 2 ** raw_format.bit_depth - 1).astype(np.uint16) | ||
| accumulated = accumulated.clip(0, 2**raw_format.bit_depth - 1).astype(np.uint16) |
There was a problem hiding this comment.
It does seem a bit confused by the power ** operator. When not followed by a bracket, it wants to remove spaces. But when followed by a bracket, it adds them!
Don't mind terribly, but consistency would probably be easier to live with!
| R_KNEE, | ||
| L_ANKLE, | ||
| R_ANKLE, | ||
| ) = range(17) |
There was a problem hiding this comment.
I suspect rolling some of these lines together would be better?
| while True: | ||
| buffer = picam2.capture_buffer("lores") | ||
| grey = buffer[:stride * lowresSize[1]].reshape((lowresSize[1], stride)) | ||
| grey = buffer[: stride * lowresSize[1]].reshape((lowresSize[1], stride)) |
There was a problem hiding this comment.
Adding spaces round : seems a bit strange to me, but I guess it doesn't particularly matter.
| picam2.start_preview(Preview.QTGL) | ||
| config = picam2.create_preview_configuration(main={"size": normalSize}, | ||
| lores={"size": lowresSize, "format": "YUV420"}) | ||
| config = picam2.create_preview_configuration(main={"size": normalSize}, lores={"size": lowresSize, "format": "YUV420"}) |
There was a problem hiding this comment.
Sometimes I quite like to put longer parameters on separate lines. I'd be OK with it splitting immediately after the (, but could we get it to accept the split line version even when the line isn't technically too long?
| video_config = picam2.create_video_configuration( | ||
| main={"size": (1280, 720), "format": "RGB888"}, lores={"size": (640, 480), "format": "YUV420"} | ||
| ) | ||
|
|
There was a problem hiding this comment.
I'm surprised it puts both parameters on one line here. I'd have preferred to separate them, I think.
| [11, 13], | ||
| [12, 14], | ||
| [13, 15], | ||
| [14, 16], # Legs |
There was a problem hiding this comment.
Again, would prefer to group more like the original?
| 87, | ||
| 88, | ||
| 89, | ||
| 90, |
There was a problem hiding this comment.
Not particularly liking the one-item-per-line here!
| '-c:a', self.audio_codec] | ||
| audio_input = [ | ||
| '-itsoffset', | ||
| str(self.audio_sync), |
There was a problem hiding this comment.
Quite a lot of these are actually option + value pairs, so it would be nice to be able to keep them like that.
| 0, | ||
| EGL_RENDERABLE_TYPE, | ||
| EGL_OPENGL_ES2_BIT, | ||
| EGL_NONE, |
There was a problem hiding this comment.
Again, all parameter name + value pairs, so would be nice to group them in pairs?
| 1.0, 1.0, | ||
| 0.0, 1.0 | ||
| ] | ||
| vertPositions = [0.0, 0.0, 1.0, 0.0, 1.0, 1.0, 0.0, 1.0] |
There was a problem hiding this comment.
Preferred the one coord (2 numbers) per line version.
| h * cfg.stride + h2 * stride2, | ||
| EGL_DMA_BUF_PLANE2_PITCH_EXT, | ||
| stride2, | ||
| EGL_NONE, |
There was a problem hiding this comment.
Again, nicer in pairs (ditto below).
| YUV2RGB_REC709 = np.array([[1.164, 1.164, 1.164], [0.0, -0.213, 2.112], [1.793, -0.533, 0.0]]) # noqa | ||
| YUV2RGB_JPEG = np.array([[1.0, 1.0, 1.0], [0.0, -0.344, 1.772], [1.402, -0.714, 0.0]]) # noqa | ||
| YUV2RGB_SMPTE170M = np.array([[1.164, 1.164, 1.164], [0.0, -0.392, 2.017], [1.596, -0.813, 0.0]]) # noqa | ||
| YUV2RGB_REC709 = np.array([[1.164, 1.164, 1.164], [0.0, -0.213, 2.112], [1.793, -0.533, 0.0]]) # noqa |
There was a problem hiding this comment.
Quite like being able to add spaces so as to line up the matrix columns...
Replace flake8 (plus 10 plugins) and pylint with ruff for both CI and pre-commit hooks. The new CI workflow uses astral-sh/ruff-action and no longer needs to build libcamera/kmsxx since ruff doesn't import project code. - Add pyproject.toml with ruff configuration - Add .github/workflows/ruff.yml (replaces flake8.yml) - Update .pre-commit-config.yaml to use ruff hooks - Update requirements-test.txt (11 deps removed, ruff added) - Delete .flake8, .pylintrc, .github/workflows/flake8.yml - Add .ruff_cache/ to .gitignore Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
| Quality.MEDIUM: 6, | ||
| Quality.HIGH: 9, | ||
| Quality.VERY_HIGH: 15} | ||
| BITRATE_TABLE = {Quality.VERY_LOW: 2, Quality.LOW: 4, Quality.MEDIUM: 6, Quality.HIGH: 9, Quality.VERY_HIGH: 15} |
There was a problem hiding this comment.
I think I preferred it with the extra line breaks?
Run ruff format across the entire codebase and fix lint violations that ruff catches but flake8 did not: - B904: Add 'from err' to re-raises in except blocks - E721: Use 'is' instead of '==' for type comparisons - E741: Rename ambiguous variable name 'l' to 'lo' - I001: Sort import blocks Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Move all package metadata from setup.py to pyproject.toml using PEP 621 declarative format. Use setuptools as the build backend with automatic package discovery for picamera2*. Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
|
Overall, mostly I don't mind the changes and am happy to go with them. The only general feeling I got was that it was quite opinionated on when to break lines, and how to break them. Often creating very many single entry lines, and sometimes even rolling lines together that were initially separated. Mostly I feel I wanted it to be less dictatorial here - either with hints that you could give, or even as a more general setting. Most of the other stuff, .e.g. spaces around |
No description provided.