-
Notifications
You must be signed in to change notification settings - Fork 82
Multichannel instrument consistency for optical spectrum analyzer #431
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
Changes from all commits
8929ba2
368cf9e
fbd0fb2
2adc568
aeb0dd2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ | |
|
|
||
|
|
||
| from enum import IntEnum, Enum | ||
| import hashlib | ||
|
|
||
| from instruments.units import ureg as u | ||
|
|
||
|
|
@@ -46,6 +45,7 @@ class Yokogawa6370(OpticalSpectrumAnalyzer): | |
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self._channel_count = len(self.Traces) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. now required from metaclass. see |
||
|
|
||
| if isinstance(self._file, SocketCommunicator): | ||
| self.terminator = "\r\n" # TCP IP connection terminator | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,15 +19,9 @@ | |
| def osa(monkeypatch): | ||
| """Patch and return Optical Spectrum Analyzer class for access.""" | ||
| inst = ik.abstract_instruments.OpticalSpectrumAnalyzer | ||
| chan = ik.abstract_instruments.OpticalSpectrumAnalyzer.Channel | ||
| monkeypatch.setattr(inst, "__abstractmethods__", set()) | ||
| return inst | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def osc(monkeypatch): | ||
| """Patch and return OSAChannel class for access.""" | ||
| inst = ik.abstract_instruments.OpticalSpectrumAnalyzer.Channel | ||
| monkeypatch.setattr(inst, "__abstractmethods__", set()) | ||
| monkeypatch.setattr(chan, "__abstractmethods__", set()) | ||
| return inst | ||
|
|
||
|
|
||
|
|
@@ -37,8 +31,8 @@ def osc(monkeypatch): | |
| def test_osa_channel(osa): | ||
| """Get channel: ensure existence.""" | ||
| with expected_protocol(osa, [], []) as inst: | ||
| with pytest.raises(NotImplementedError): | ||
| _ = inst.channel | ||
| ch = inst.channel[0] | ||
| assert isinstance(ch, ik.abstract_instruments.OpticalSpectrumAnalyzer.Channel) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the channel itself is automatically implemented now and - if a single channel instrument - will forward to the parent's channel. so this needed to be changed |
||
|
|
||
|
|
||
| def test_osa_start_wl(osa): | ||
|
|
@@ -78,15 +72,25 @@ def test_osa_start_sweep(osa): | |
| # OSAChannel # | ||
|
|
||
|
|
||
| def test_osa_channel_wavelength(osc): | ||
| @pytest.mark.parametrize("num_ch", [1, 5]) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. take care of single and multichannel instruments |
||
| def test_osa_channel_wavelength(osa, num_ch): | ||
| """Channel wavelength method: ensure existence.""" | ||
| inst = osc() | ||
| with pytest.raises(NotImplementedError): | ||
| inst.wavelength() | ||
| with expected_protocol(osa, [], []) as inst: | ||
| inst._channel_count = num_ch | ||
| ch = inst.channel[0] | ||
| with pytest.raises(NotImplementedError): | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. call single/mutli channel instrument through the inst.channel ProxyList function and ensure proper forwarding |
||
| ch.wavelength() | ||
| with pytest.raises(NotImplementedError): | ||
| inst.wavelength() # single channel instrument | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the single channel function to call (directly from instrument class) and ensure it exists and raises appropriate error |
||
|
|
||
|
|
||
| def test_osa_channel_data(osc): | ||
| @pytest.mark.parametrize("num_ch", [1, 5]) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
| def test_osa_channel_data(osa, num_ch): | ||
| """Channel data method: ensure existence.""" | ||
| inst = osc() | ||
| with pytest.raises(NotImplementedError): | ||
| inst.data() | ||
| with expected_protocol(osa, [], []) as inst: | ||
| inst._channel_count = num_ch | ||
| ch = inst.channel[0] | ||
| with pytest.raises(NotImplementedError): | ||
| ch.data() | ||
| with pytest.raises(NotImplementedError): | ||
| inst.data() # single channel instrument | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ | |
|
|
||
| # IMPORTS ##################################################################### | ||
|
|
||
| import hashlib | ||
| import struct | ||
|
|
||
| from hypothesis import ( | ||
|
|
@@ -15,7 +14,6 @@ | |
| import socket | ||
|
|
||
| import instruments as ik | ||
| from instruments.abstract_instruments.comm import SocketCommunicator | ||
| from instruments.optional_dep_finder import numpy | ||
| from tests import ( | ||
| expected_protocol, | ||
|
|
@@ -31,6 +29,7 @@ | |
|
|
||
| def test_channel_is_channel_class(): | ||
| inst = ik.yokogawa.Yokogawa6370.open_test() | ||
| assert inst._channel_count == len(inst.Traces) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| assert isinstance(inst.channel["A"], inst.Channel) is True | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleanup unused import