Skip to content

Fix RGBSensor nbit max#98

Merged
singer-yang merged 2 commits intovccimaging:mainfrom
BecIcan:fix/rgb-sensor-nbit-max
Jan 8, 2026
Merged

Fix RGBSensor nbit max#98
singer-yang merged 2 commits intovccimaging:mainfrom
BecIcan:fix/rgb-sensor-nbit-max

Conversation

@BecIcan
Copy link
Copy Markdown
Contributor

@BecIcan BecIcan commented Jan 8, 2026

Fix critical bug where RGBSensor does not initialize self.nbit_max, causing it to inherit the incorrect default value from the parent Sensor class (1023 for 10-bit instead of the configured bit depth).

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical bug in RGBSensor where the nbit_max attribute was not properly initialized, causing it to inherit the incorrect default value from the parent Sensor class (1023 for 10-bit) instead of computing the value based on the configured bit depth from the sensor configuration file.

Key Changes:

  • Added explicit initialization of self.nbit_max = 2**self.bit - 1 in RGBSensor.__init__() after reading the bit depth from the config file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

self.res = config["sensor_res"]
self.pixel_size = 2 / math.sqrt(self.res[0] ** 2 + self.res[1] ** 2)
self.bit = config["bit"]
self.nbit_max = 2**self.bit - 1
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

Remove trailing whitespace at the end of this line.

Copilot uses AI. Check for mistakes.
self.res = config["sensor_res"]
self.pixel_size = 2 / math.sqrt(self.res[0] ** 2 + self.res[1] ** 2)
self.bit = config["bit"]
self.nbit_max = 2**self.bit - 1
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

Consider adding a test to verify that RGBSensor correctly initializes nbit_max based on the bit depth from the config file. For example, a test could create an RGBSensor with a 14-bit config and verify that self.nbit_max equals 16383 (2^14 - 1) instead of the default 1023 (2^10 - 1). This would prevent regression of this critical bug.

Copilot uses AI. Check for mistakes.
@singer-yang singer-yang merged commit 9b080ca into vccimaging:main Jan 8, 2026
7 checks passed
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.

3 participants