Skip to content

Commit

Permalink
Renamed transform functionals to avoid overridden imports (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Boegner <luke.boegner@peratonlabs.com>
  • Loading branch information
TorchDSP and Luke Boegner authored Oct 19, 2022
1 parent 143ece8 commit c230f50
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 50 deletions.
2 changes: 1 addition & 1 deletion torchsig/transforms/deep_learning_techniques/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .dlt import *
from .functional import *
from .dlt_functional import *
10 changes: 5 additions & 5 deletions torchsig/transforms/deep_learning_techniques/dlt.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from torchsig.transforms.wireless_channel import TargetSNR
from torchsig.transforms.functional import to_distribution, uniform_continuous_distribution, uniform_discrete_distribution
from torchsig.transforms.functional import NumericParameter, FloatParameter
from torchsig.transforms.deep_learning_techniques import functional
from torchsig.transforms.deep_learning_techniques import dlt_functional


class DatasetBasebandMixUp(SignalTransform):
Expand Down Expand Up @@ -356,10 +356,10 @@ def __call__(self, data: Any) -> Any:
new_data.signal_description = new_signal_description

# Perform data augmentation
new_data.iq_data = functional.cut_out(data.iq_data, cut_start, cut_dur, cut_type)
new_data.iq_data = dlt_functional.cut_out(data.iq_data, cut_start, cut_dur, cut_type)

else:
new_data = functional.cut_out(data, cut_start, cut_dur, cut_type)
new_data = dlt_functional.cut_out(data, cut_start, cut_dur, cut_type)
return new_data


Expand Down Expand Up @@ -408,9 +408,9 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.patch_shuffle(data.iq_data, patch_size, shuffle_ratio)
new_data.iq_data = dlt_functional.patch_shuffle(data.iq_data, patch_size, shuffle_ratio)

else:
new_data = functional.patch_shuffle(data, patch_size, shuffle_ratio)
new_data = dlt_functional.patch_shuffle(data, patch_size, shuffle_ratio)
return new_data

2 changes: 1 addition & 1 deletion torchsig/transforms/expert_feature/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .eft import *
from .functional import *
from .eft_functional import *
2 changes: 1 addition & 1 deletion torchsig/transforms/expert_feature/eft.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Callable, Tuple, Any

from torchsig.utils.types import SignalData
from torchsig.transforms.expert_feature import functional as F
from torchsig.transforms.expert_feature import eft_functional as F
from torchsig.transforms.transforms import SignalTransform


Expand Down
2 changes: 1 addition & 1 deletion torchsig/transforms/signal_processing/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .sp import *
from .functional import *
from .sp_functional import *
2 changes: 1 addition & 1 deletion torchsig/transforms/signal_processing/sp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from torchsig.utils.types import SignalData, SignalDescription
from torchsig.transforms.transforms import SignalTransform
from torchsig.transforms.signal_processing import functional as F
from torchsig.transforms.signal_processing import sp_functional as F
from torchsig.transforms.functional import NumericParameter, to_distribution


Expand Down
2 changes: 1 addition & 1 deletion torchsig/transforms/system_impairment/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .si import *
from .functional import *
from .si_functional import *
74 changes: 37 additions & 37 deletions torchsig/transforms/system_impairment/si.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from torchsig.utils.types import SignalData, SignalDescription
from torchsig.transforms.transforms import SignalTransform
from torchsig.transforms.system_impairment import functional
from torchsig.transforms.system_impairment import si_functional
from torchsig.transforms.functional import NumericParameter, IntParameter, FloatParameter
from torchsig.transforms.functional import to_distribution, uniform_continuous_distribution, uniform_discrete_distribution

Expand Down Expand Up @@ -67,13 +67,13 @@ def __call__(self, data: Any) -> Any:
)

# Apply data transformation
new_data.iq_data = functional.fractional_shift(
new_data.iq_data = si_functional.fractional_shift(
data.iq_data,
self.taps,
self.interp_rate,
-decimal_part # this needed to be negated to be consistent with the previous implementation
)
new_data.iq_data = functional.time_shift(new_data.iq_data, int(integer_part))
new_data.iq_data = si_functional.time_shift(new_data.iq_data, int(integer_part))

# Update SignalDescription
new_signal_description = []
Expand All @@ -91,13 +91,13 @@ def __call__(self, data: Any) -> Any:
new_data.signal_description = new_signal_description

else:
new_data = functional.fractional_shift(
new_data = si_functional.fractional_shift(
data,
self.taps,
self.interp_rate,
-decimal_part # this needed to be negated to be consistent with the previous implementation
)
new_data = functional.time_shift(new_data, int(integer_part))
new_data = si_functional.time_shift(new_data, int(integer_part))
return new_data


Expand Down Expand Up @@ -167,7 +167,7 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.time_crop(iq_data, start, self.length)
new_data.iq_data = si_functional.time_crop(iq_data, start, self.length)

# Update SignalDescription
new_signal_description = []
Expand All @@ -190,7 +190,7 @@ def __call__(self, data: Any) -> Any:
new_data.signal_description = new_signal_description

else:
new_data = functional.time_crop(data, start, self.length)
new_data = si_functional.time_crop(data, start, self.length)
return new_data


Expand Down Expand Up @@ -228,10 +228,10 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.time_reversal(data.iq_data)
new_data.iq_data = si_functional.time_reversal(data.iq_data)
if undo_spec_inversion:
# If spectral inversion not desired, reverse effect
new_data.iq_data = functional.spectral_inversion(new_data.iq_data)
new_data.iq_data = si_functional.spectral_inversion(new_data.iq_data)

# Update SignalDescription
new_signal_description = []
Expand All @@ -258,10 +258,10 @@ def __call__(self, data: Any) -> Any:
new_data.signal_description = new_signal_description

else:
new_data = functional.time_reversal(data)
new_data = si_functional.time_reversal(data)
if undo_spec_inversion:
# If spectral inversion not desired, reverse effect
new_data = functional.spectral_inversion(new_data)
new_data = si_functional.spectral_inversion(new_data)
return new_data


Expand All @@ -284,10 +284,10 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.amplitude_reversal(data.iq_data)
new_data.iq_data = si_functional.amplitude_reversal(data.iq_data)

else:
new_data = functional.amplitude_reversal(data)
new_data = si_functional.amplitude_reversal(data)
return new_data


Expand Down Expand Up @@ -373,13 +373,13 @@ def __call__(self, data: Any) -> Any:
# Apply data augmentation
if avoid_aliasing:
# If any potential aliasing detected, perform shifting at higher sample rate
new_data.iq_data = functional.freq_shift_avoid_aliasing(data.iq_data, freq_shift)
new_data.iq_data = si_functional.freq_shift_avoid_aliasing(data.iq_data, freq_shift)
else:
# Otherwise, use faster freq shifter
new_data.iq_data = functional.freq_shift(data.iq_data, freq_shift)
new_data.iq_data = si_functional.freq_shift(data.iq_data, freq_shift)

else:
new_data = functional.freq_shift(data, freq_shift)
new_data = si_functional.freq_shift(data, freq_shift)
return new_data


Expand Down Expand Up @@ -600,7 +600,7 @@ def __call__(self, data: Any) -> Any:

ref_level_db = np.random.uniform(-.5 + self.ref_level_db, .5 + self.ref_level_db, 1)

iq_data = functional.agc(
iq_data = si_functional.agc(
np.ascontiguousarray(iq_data, dtype=np.complex64),
np.float64(self.initial_gain_db),
np.float64(alpha_smooth),
Expand Down Expand Up @@ -677,14 +677,14 @@ def __call__(self, data: Any) -> Any:
dc_offset = self.dc_offset()

if isinstance(data, SignalData):
data.iq_data = functional.iq_imbalance(
data.iq_data = si_functional.iq_imbalance(
data.iq_data,
amp_imbalance,
phase_imbalance,
dc_offset
)
else:
data = functional.iq_imbalance(
data = si_functional.iq_imbalance(
data,
amp_imbalance,
phase_imbalance,
Expand Down Expand Up @@ -742,9 +742,9 @@ def __call__(self, data: Any) -> Any:
upper_freq = self.upper_freq() if np.random.rand() < self.upper_cut_apply else 1.0
order = self.order()
if isinstance(data, SignalData):
data.iq_data = functional.roll_off(data.iq_data, low_freq, upper_freq, int(order))
data.iq_data = si_functional.roll_off(data.iq_data, low_freq, upper_freq, int(order))
else:
data = functional.roll_off(data, low_freq, upper_freq, int(order))
data = si_functional.roll_off(data, low_freq, upper_freq, int(order))
return data


Expand All @@ -767,10 +767,10 @@ def __call__(self, data: Any) -> Any:
)

# Apply data augmentation
new_data.iq_data = functional.add_slope(data.iq_data)
new_data.iq_data = si_functional.add_slope(data.iq_data)

else:
new_data = functional.add_slope(data)
new_data = si_functional.add_slope(data)
return new_data


Expand All @@ -792,7 +792,7 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.spectral_inversion(data.iq_data)
new_data.iq_data = si_functional.spectral_inversion(data.iq_data)

# Update SignalDescription
new_signal_description = []
Expand All @@ -812,7 +812,7 @@ def __call__(self, data: Any) -> Any:
new_data.signal_description = new_signal_description

else:
new_data = functional.spectral_inversion(data)
new_data = si_functional.spectral_inversion(data)
return new_data


Expand Down Expand Up @@ -851,10 +851,10 @@ def __call__(self, data: Any) -> Any:
new_data.signal_description = new_signal_description

# Perform data augmentation
new_data.iq_data = functional.channel_swap(data.iq_data)
new_data.iq_data = si_functional.channel_swap(data.iq_data)

else:
new_data = functional.channel_swap(data)
new_data = si_functional.channel_swap(data)
return new_data


Expand Down Expand Up @@ -901,10 +901,10 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.mag_rescale(data.iq_data, start, scale)
new_data.iq_data = si_functional.mag_rescale(data.iq_data, start, scale)

else:
new_data = functional.mag_rescale(data, start, scale)
new_data = si_functional.mag_rescale(data, start, scale)
return new_data


Expand Down Expand Up @@ -970,14 +970,14 @@ def __call__(self, data: Any) -> Any:
drop_sizes = self.size(drop_instances).astype(int)
drop_starts = np.random.uniform(1, data.iq_data.shape[0]-max(drop_sizes)-1, drop_instances).astype(int)

new_data.iq_data = functional.drop_samples(data.iq_data, drop_starts, drop_sizes, fill)
new_data.iq_data = si_functional.drop_samples(data.iq_data, drop_starts, drop_sizes, fill)

else:
drop_instances = int(data.shape[0] * drop_rate)
drop_sizes = self.size(drop_instances).astype(int)
drop_starts = np.random.uniform(0, data.shape[0]-max(drop_sizes), drop_instances).astype(int)

new_data = functional.drop_samples(data, drop_starts, drop_sizes, fill)
new_data = si_functional.drop_samples(data, drop_starts, drop_sizes, fill)
return new_data


Expand Down Expand Up @@ -1022,10 +1022,10 @@ def __call__(self, data: Any) -> Any:
)

# Perform data augmentation
new_data.iq_data = functional.quantize(data.iq_data, num_levels, round_type)
new_data.iq_data = si_functional.quantize(data.iq_data, num_levels, round_type)

else:
new_data = functional.quantize(data, num_levels, round_type)
new_data = si_functional.quantize(data, num_levels, round_type)
return new_data


Expand Down Expand Up @@ -1063,10 +1063,10 @@ def __call__(self, data: Any) -> Any:
)

# Apply data augmentation
new_data.iq_data = functional.clip(data.iq_data, clip_percentage)
new_data.iq_data = si_functional.clip(data.iq_data, clip_percentage)

else:
new_data = functional.clip(data, clip_percentage)
new_data = si_functional.clip(data, clip_percentage)
return new_data


Expand Down Expand Up @@ -1117,8 +1117,8 @@ def __call__(self, data: Any) -> Any:
)

# Apply data augmentation
new_data.iq_data = functional.random_convolve(data.iq_data, num_taps, alpha)
new_data.iq_data = si_functional.random_convolve(data.iq_data, num_taps, alpha)

else:
new_data = functional.random_convolve(data, num_taps, alpha)
new_data = si_functional.random_convolve(data, num_taps, alpha)
return new_data
2 changes: 1 addition & 1 deletion torchsig/transforms/wireless_channel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from .wce import *
from .functional import *
from .wce_functional import *
2 changes: 1 addition & 1 deletion torchsig/transforms/wireless_channel/wce.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from torchsig.utils.types import SignalData, SignalDescription
from torchsig.transforms.transforms import SignalTransform
from torchsig.transforms.wireless_channel import functional as F
from torchsig.transforms.wireless_channel import wce_functional as F
from torchsig.transforms.functional import NumericParameter, FloatParameter, IntParameter
from torchsig.transforms.functional import to_distribution, uniform_continuous_distribution, uniform_discrete_distribution

Expand Down

0 comments on commit c230f50

Please sign in to comment.