use unions for compatibility with older versions of python

This commit is contained in:
Jakob Ketterl 2023-08-30 01:56:39 +02:00
parent 30d0a1b947
commit ce6029fe94
2 changed files with 7 additions and 6 deletions

View File

@ -1,6 +1,7 @@
from csdr.chain import Chain from csdr.chain import Chain
from pycsdr.modules import Shift, FirDecimate, Bandpass, Squelch, FractionalDecimator, Writer from pycsdr.modules import Shift, FirDecimate, Bandpass, Squelch, FractionalDecimator, Writer
from pycsdr.types import Format from pycsdr.types import Format
from typing import Union
import math import math
@ -133,11 +134,11 @@ class Selector(Chain):
scaled = [x / self.outputRate for x in self.bandpassCutoffs] scaled = [x / self.outputRate for x in self.bandpassCutoffs]
self.bandpass.setBandpass(*scaled) self.bandpass.setBandpass(*scaled)
def setLowCut(self, lowCut: float | None) -> None: def setLowCut(self, lowCut: Union[float, None]) -> None:
self.bandpassCutoffs[0] = lowCut self.bandpassCutoffs[0] = lowCut
self.setBandpass(*self.bandpassCutoffs) self.setBandpass(*self.bandpassCutoffs)
def setHighCut(self, highCut: float | None) -> None: def setHighCut(self, highCut: Union[float, None]) -> None:
self.bandpassCutoffs[1] = highCut self.bandpassCutoffs[1] = highCut
self.setBandpass(*self.bandpassCutoffs) self.setBandpass(*self.bandpassCutoffs)

View File

@ -220,10 +220,10 @@ class ClientDemodulatorChain(Chain):
else: else:
self.selector.setSquelchLevel(self.squelchLevel) self.selector.setSquelchLevel(self.squelchLevel)
def setLowCut(self, lowCut: float | None): def setLowCut(self, lowCut: Union[float, None]):
self.selector.setLowCut(lowCut) self.selector.setLowCut(lowCut)
def setHighCut(self, highCut: float | None): def setHighCut(self, highCut: Union[float, None]):
self.selector.setHighCut(highCut) self.selector.setHighCut(highCut)
def setBandpass(self, lowCut, highCut): def setBandpass(self, lowCut, highCut):
@ -648,10 +648,10 @@ class DspManager(SdrSourceEventClient, ClientDemodulatorSecondaryDspEventClient)
self.chain.setSecondaryFftWriter(buffer) self.chain.setSecondaryFftWriter(buffer)
self.wireOutput("secondary_fft", buffer) self.wireOutput("secondary_fft", buffer)
def setLowCut(self, lowCut: float | PropertyDeletion): def setLowCut(self, lowCut: Union[float, PropertyDeletion]):
self.chain.setLowCut(None if lowCut is PropertyDeleted else lowCut) self.chain.setLowCut(None if lowCut is PropertyDeleted else lowCut)
def setHighCut(self, highCut: float | PropertyDeletion): def setHighCut(self, highCut: Union[float, PropertyDeletion]):
self.chain.setHighCut(None if highCut is PropertyDeleted else highCut) self.chain.setHighCut(None if highCut is PropertyDeleted else highCut)
def start(self): def start(self):