Skip to content

Commit

Permalink
Add: some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelSasser committed Apr 15, 2021
1 parent 031c73f commit dc289d1
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 10 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ repos:
hooks:
- id: mypy

- repo: https://github.com/econchick/interrogate
rev: 1.3.2
hooks:
- id: interrogate
args: [tests]
language_version: python3.9

# vulture
- repo: https://github.com/jendrikseipp/vulture
rev: "v2.3"
Expand Down
77 changes: 76 additions & 1 deletion ds2000/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@


class ChannelEnum(Enum):

"""Use the Enum to get or set the channel status."""

CHANNEL_1 = "channel_1"
CHANNEL_2 = "channel_2"
EXT = "ext"
Expand All @@ -37,6 +40,9 @@ class ChannelEnum(Enum):

# TODO: Maybe TriggerSlopeEnum
class SlopeEnum(Enum):

"""Use the Enum to get or set the slope status."""

POSITIVE = "positive"
NEGATIVE = "negative"
BOTH = "both"
Expand All @@ -46,6 +52,9 @@ class SlopeEnum(Enum):


class AcquireTypeEnum(Enum):

"""Use the Enum to get or set the acquire status."""

NORMAL = "normal"
AVERAGE = "average"
PEAKDETECT = "peakdetect"
Expand All @@ -63,6 +72,9 @@ class AcquireTypeEnum(Enum):


class TriggerStatusEnum(Enum):

"""Use the Enum to get or set the trigger status."""

TD = "td"
WAIT = "wait"
RUN = "run"
Expand All @@ -74,6 +86,9 @@ class TriggerStatusEnum(Enum):


class TriggerCouplingEnum(Enum):

"""Use the Enum to get or set the coupling status of the trigger."""

AC = "ac"
DC = "dc"
LF_REJECT = "lf_reject"
Expand All @@ -84,6 +99,9 @@ class TriggerCouplingEnum(Enum):


class TriggerDelayTypeEnum(Enum):

"""Use the Enum to get or set the delay type of the trigger."""

GREATER = "greater" # GREater
LESS = "less" # LESS
INSIDE = "inside" # GLESs # TODO: Maybe use between
Expand All @@ -94,6 +112,9 @@ class TriggerDelayTypeEnum(Enum):


class TriggerDurationWhenEnum(Enum): # TODO: most of TriggerDelayTypeEnum

"""Use the Enum to get or set the duration of the trigger."""

GREATER = "greater"
LESS = "less"
BETWEEN = "between"
Expand All @@ -106,6 +127,9 @@ class TriggerDurationWhenEnum(Enum): # TODO: most of TriggerDelayTypeEnum


class TriggerI2CWhenEnum(Enum):

"""Use the Enum to get or set the I²C trigger."""

START = "start"
RESTART = "restart"
STOP = "stop"
Expand All @@ -116,6 +140,9 @@ class TriggerI2CWhenEnum(Enum):


class TriggerI2CDirectionEnum(Enum):

"""Use the Enum to get or set the I²C direction to trigger."""

READ = "read"
WRITE = "write"
READ_AND_WRITE = "read_and_write"
Expand All @@ -125,6 +152,9 @@ class TriggerI2CDirectionEnum(Enum):


class TriggerModeEnum(Enum):

"""Use the Enum to get or set the trigger mode."""

EDGE = "edge"
PULSE = "pulse"
RUNT = "runt"
Expand All @@ -150,6 +180,9 @@ class TriggerModeEnum(Enum):


class TriggerPulseWhenEnum(Enum):

"""Use the Enum to get or set the pulse trigger."""

POSIVE_GREATER = "positive_greater"
POSITIVE_LESS = "positive_less"
NEGATIVE_GREATER = "negative_greater"
Expand All @@ -162,13 +195,19 @@ class TriggerPulseWhenEnum(Enum):


class TriggerRS232WhenEnum(Enum):

"""Use the Enum to get or set the RS232 trigger."""

START_FRAME = "start_frame"
ERROR = "error"
PARITY_ERROR = "parity_error"
DATA = "data"


class TriggerRS232Parity(Enum):

"""Use the Enum to get or set the RS232 parity to trigger."""

EVEN = "even"
ODD = "odd"
NONE = "none"
Expand All @@ -178,13 +217,19 @@ class TriggerRS232Parity(Enum):


class TriggerRuntWhenEnum(Enum):

"""Use the Enum to get or set the runt trigger."""

NONE = "none"
GREATER = "greater"
LESS = "less"
BETWEEN = "between"


class TriggerRuntPolarityEnum(Enum):

"""Use the Enum to get or set the runt polarity to trigger."""

POSITIVE = "positive"
NEGATIVE = "negative"

Expand All @@ -193,12 +238,18 @@ class TriggerRuntPolarityEnum(Enum):


class TriggerSetupHoldTypeEnum(Enum):

"""Use the Enum to get or set the SETUP & HOLD trigger type."""

SETUP = "setup"
HOLD = "hold"
SETUP_HOLD = "setup_hold"


class TriggerSetupHoldPatternEnum(Enum):

"""Use the Enum to get or set the SETUP & HOLD pattern to trigger."""

HIGH = "high"
LOW = "low"

Expand All @@ -207,6 +258,9 @@ class TriggerSetupHoldPatternEnum(Enum):


class TriggerSlopeWhenEnum(Enum):

"""Use the Enum to get or set the slope trigger."""

POSIVE_GREATER = "positive_greater"
POSITIVE_LESS = "positive_less"
NEGATIVE_GREATER = "negative_greater"
Expand All @@ -222,6 +276,9 @@ class TriggerSlopeWhenEnum(Enum):


class TriggerSweepEnum(Enum):

"""Use the Enum to get or set the sweep trigger."""

AUTO = "auto"
NORMAL = "normal"
SINGLE = "single"
Expand All @@ -234,14 +291,20 @@ class TriggerSweepEnum(Enum):

# TODO: Maybe rename to start, end etc.
class TriggerUSBWhenEnum(Enum):

"""Use the Enum to get or set the USB trigger."""

SOP = "sop"
EOP = "eop"
RC = "rc"
SUSPEND = "suspend"
SUSPEND_EXIT = "suspend exit"


class TrigerUSBSppedEnum(Enum):
class TrigerUSBSpeedEnum(Enum):

"""Use the Enum to get or set the USB speed to trigger."""

FULL = "full"
LOW = "low"

Expand All @@ -250,18 +313,27 @@ class TrigerUSBSppedEnum(Enum):


class TriggerVideoPolarityEnum(Enum):

"""Use the Enum to get or set the video polarity to trigger."""

POSITIVE = "positive"
NEGATIVE = "negative"


class TriggerVideoModeEnum(Enum):

"""Use the Enum to get or set the video mode to trigger."""

ODD_FIELD = "odd_field"
EVEN_FIELD = "even_line"
SPECIFIC_LINE = "specific_line"
ALL_LINES = "all_lines"


class TriggerVideoStandardEnum(Enum):

"""Use the Enum to get or set the video standard to trigger."""

VideoPALSecam = "VideoPALSecam"
VideoNTSC = "VideoNTSC"
Video480P = "Video480P"
Expand All @@ -285,6 +357,9 @@ class TriggerVideoStandardEnum(Enum):


class TriggerWindowsPositionEnum(Enum):

"""Use the Enum to get or set the window position to trigger."""

EXIT = "exit"
ENTER = "enter"
TIME = "time"
Expand Down
10 changes: 5 additions & 5 deletions ds2000/ieee.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ def __init__(self, dev):
super(IEEE, self).__init__(dev)

def idn(self) -> str:
r"""Get the ID chars of the device_address as Instrument Tuple.
"""Get the ID chars of the device_address as Instrument Tuple.
**Rigol Programming Guide**
**Syntax**
*IDN?
\\*IDN?
**Description**
Expand All @@ -53,20 +53,20 @@ def idn(self) -> str:
**Example**
*IDN?
\\*IDN?
The query returns RIGOL TECHNOLOGIES,DS2202,DS2xxx,00.00.01. Instrument
"""
return self.instrument.ask("*IDN?")

def rst(self):
r"""Restore the instrument to the default values.
"""Restore the instrument to the default values.
**Rigol Programming Guide**
**Syntax**
*RST
\\*RST
**Description**
Expand Down
8 changes: 4 additions & 4 deletions ds2000/trigger/usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from ds2000.common import channel_as_enum
from ds2000.common import check_level
from ds2000.enums import ChannelEnum
from ds2000.enums import TrigerUSBSppedEnum
from ds2000.enums import TrigerUSBSpeedEnum
from ds2000.enums import TriggerUSBWhenEnum
from ds2000.errors import DS2000StateError

Expand Down Expand Up @@ -496,7 +496,7 @@ def set_low(self) -> None:
"""
self.instrument.say(":TRIGger:USB:SPEed LOW")

def status(self) -> TrigerUSBSppedEnum:
def status(self) -> TrigerUSBSpeedEnum:
"""Query the current signal speed in USB trigger.
**Rigol Programming Guide**
Expand Down Expand Up @@ -530,9 +530,9 @@ def status(self) -> TrigerUSBSppedEnum:
"""
answer: str = self.instrument.ask(":TRIGger:USB:SPEed?")
if answer == "FULL":
return TrigerUSBSppedEnum.FULL
return TrigerUSBSpeedEnum.FULL
if answer == "LOW":
return TrigerUSBSppedEnum.LOW
return TrigerUSBSpeedEnum.LOW
raise DS2000StateError()


Expand Down
3 changes: 3 additions & 0 deletions ds2000/waveform.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class WaveformStatus(NamedTuple):


class Preamble(NamedTuple):

"""Use to store the preamble."""

format: str
type: str
points: int
Expand Down

0 comments on commit dc289d1

Please sign in to comment.