Skip to content
New issue

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

Add missing sensor component unit tests #123

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
repos:
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.3.0
rev: 23.7.0
hooks:
- id: black

- repo: https://github.com/PyCQA/autoflake
rev: v1.7.7
rev: v2.2.0
hooks:
- id: autoflake

- repo: https://github.com/asottile/pyupgrade
rev: v2.32.0
rev: v3.9.0
hooks:
- id: pyupgrade

- repo: https://github.com/myint/docformatter
rev: v1.5.0
rev: v1.7.5
hooks:
- id: docformatter
args: [--blank, --in-place, --recursive, --wrap-descriptions=88, --wrap-summaries=80] # does not yet support toml config
Expand All @@ -33,7 +33,7 @@ repos:


- repo: https://github.com/nbQA-dev/nbQA
rev: 1.3.1
rev: 1.7.0
hooks:
- id: nbqa-isort
- id: nbqa-black
Expand Down
38 changes: 38 additions & 0 deletions tests/test_systems/test_optical/test_sensors/test_Sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ def test_get_shape():
assert result[1].decompose().unit == unit.m


def test_get_noise_read():
"""Test get_noise_read method."""

noise_read = 500 * unit.electron
sensor = Sensor(noise_read=noise_read)

result = sensor.get_noise_read()
LOG.info(result)

assert result == noise_read


def test_get_area():
"""Test get_area method."""

Expand Down Expand Up @@ -102,6 +114,20 @@ def test_get_mean_dark_signal():
assert result.decompose().unit == (unit.electron / unit.pix)


def test_get_dark_shot_noise():
"""Test get_dark_shot_noise method."""

ke = 1e3 * unit.electron
sensor = Sensor(
integration_time=166.7 * unit.ms, i_dark=140 * (ke / unit.pix / unit.s)
)

result = sensor.get_dark_shot_noise()
LOG.info(result)

assert result.decompose().unit == (unit.electron / unit.pix) ** 0.5


def test_get_quantization_noise():
"""Test get_quantization_noise method."""

Expand Down Expand Up @@ -156,3 +182,15 @@ def test_get_efficiency():
LOG.info(result)

assert result.unit == unit.pct * unit.electron


def test_get_waveband():
"""Test get_waveband method."""

waveband = 800 * unit.nm
sensor = Sensor(waveband=waveband)

result = sensor.get_waveband()
LOG.info(result)

assert result == waveband
Loading