Skip to content

Commit

Permalink
Remove deprecated traits ending with version 25.01 (#346) (#379)
Browse files Browse the repository at this point in the history
* Remove deprecated traits ending with version 25.01 (#346)

Traits were removed from:

* Grid

* RectGrid3D

* PowerSpectra

* PointSource

* UncorrelatedNoiseSource

* SineGenerator

* BeamformerTime

* BeamformerBase

* PointSpreadFunction

Update What's New section (#346)

* finally remove calib

* finalize

* remove _source

* resolve

---------

Co-authored-by: Adam Kujawski <adam.kujawski@tu-berlin.de>
  • Loading branch information
jtodev and adku1173 authored Dec 4, 2024
1 parent 0897d2e commit 358b376
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 588 deletions.
252 changes: 8 additions & 244 deletions acoular/fbeamform.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
if parse(sklearn.__version__) < parse('1.4'):
sklearn_ndict['normalize'] = False # pragma: no cover

BEAMFORMER_BASE_DIGEST_DEPENDENCIES = ['freq_data.digest', 'r_diag', 'r_diag_norm', 'precision', '_steer_obj.digest']
BEAMFORMER_BASE_DIGEST_DEPENDENCIES = ['freq_data.digest', 'r_diag', 'r_diag_norm', 'precision', 'steer.digest']


class SteeringVector(HasStrictTraits):
Expand Down Expand Up @@ -310,126 +310,7 @@ class BeamformerBase(HasStrictTraits):
# Instance of :class:`~acoular.fbeamform.SteeringVector` or its derived classes
# that contains information about the steering vector. This is a private trait.
# Do not set this directly, use `steer` trait instead.
_steer_obj = Instance(SteeringVector(), SteeringVector)

#: :class:`~acoular.fbeamform.SteeringVector` or derived object.
#: Defaults to :class:`~acoular.fbeamform.SteeringVector` object.
steer = Property(desc='steering vector object')

def _get_steer(self):
return self._steer_obj

def _set_steer(self, steer):
if isinstance(steer, SteeringVector):
self._steer_obj = steer
elif steer in ('true level', 'true location', 'classic', 'inverse'):
# Type of steering vectors, see also :cite:`Sarradj2012`.
msg = (
"Deprecated use of 'steer' trait. Please use the 'steer' with an object of class "
"'SteeringVector'. Using a string to specify the steer type will be removed in "
'version 25.01.'
)
warn(
msg,
DeprecationWarning,
stacklevel=2,
)
self._steer_obj.steer_type = steer
else:
raise (TraitError(args=self, name='steer', info='SteeringVector', value=steer))

# --- List of backwards compatibility traits and their setters/getters -----------

# :class:`~acoular.environments.Environment` or derived object.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait.
env = Property()

def _get_env(self):
return self._steer_obj.env

def _set_env(self, env):
msg = (
"Deprecated use of 'env' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'env' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.env = env

# The speed of sound.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait.
c = Property()

def _get_c(self):
return self._steer_obj.env.c

def _set_c(self, c):
msg = (
"Deprecated use of 'c' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector' that holds an 'Environment' instance."
"The 'c' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.env.c = c

# :class:`~acoular.grids.Grid`-derived object that provides the grid locations.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait.
grid = Property()

def _get_grid(self):
return self._steer_obj.grid

def _set_grid(self, grid):
msg = (
"Deprecated use of 'grid' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'grid' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.grid = grid

# :class:`~acoular.microphones.MicGeom` object that provides the microphone locations.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait
mpos = Property()

def _get_mpos(self):
return self._steer_obj.mics

def _set_mpos(self, mpos):
msg = (
"Deprecated use of 'mpos' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'mpos' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.mics = mpos

# Sound travel distances from microphone array center to grid points (r0)
# and all array mics to grid points (rm). Readonly.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait
r0 = Property()

def _get_r0(self):
msg = (
"Deprecated use of 'r0' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'r0' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
return self._steer_obj.r0

rm = Property()

def _get_rm(self):
msg = (
"Deprecated use of 'rm' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'rm' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
return self._steer_obj.rm

# --- End of backwards compatibility traits --------------------------------------
steer = Instance(SteeringVector, args=())

#: :class:`~acoular.spectra.PowerSpectra` object that provides the
#: cross spectral matrix and eigenvalues
Expand Down Expand Up @@ -498,7 +379,7 @@ def _get_filecache(self):
# print("no data existent for nodename:", nodename)
if config.global_caching == 'readonly':
return (None, None, None)
numfreq = self.freq_data.fftfreq().shape[0] # block_size/2 + 1steer_obj
numfreq = self.freq_data.fftfreq().shape[0]
group = self.h5f.create_new_group(nodename)
self.h5f.create_compressible_array(
'freqs',
Expand Down Expand Up @@ -1090,131 +971,14 @@ class PointSpreadFunction(HasStrictTraits):
# Instance of :class:`~acoular.fbeamform.SteeringVector` or its derived classes
# that contains information about the steering vector. This is a private trait.
# Do not set this directly, use `steer` trait instead.
_steer_obj = Instance(SteeringVector(), SteeringVector)

#: :class:`~acoular.fbeamform.SteeringVector` or derived object.
#: Defaults to :class:`~acoular.fbeamform.SteeringVector` object.
steer = Property(desc='steering vector object')

def _get_steer(self):
return self._steer_obj

def _set_steer(self, steer):
if isinstance(steer, SteeringVector):
self._steer_obj = steer
elif steer in ('true level', 'true location', 'classic', 'inverse'):
msg = (
"Deprecated use of 'steer' trait. Please use object of class 'SteeringVector'."
"The functionality of using string values for 'steer' will be removed in version 25.01."
)
# Type of steering vectors, see also :cite:`Sarradj2012`.
warn(
msg,
Warning,
stacklevel=2,
)
self._steer_obj = SteeringVector(steer_type=steer)
else:
raise (TraitError(args=self, name='steer', info='SteeringVector', value=steer))

# --- List of backwards compatibility traits and their setters/getters -----------

# :class:`~acoular.environments.Environment` or derived object.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait.
env = Property()

def _get_env(self):
return self._steer_obj.env

def _set_env(self, env):
msg = (
"Deprecated use of 'env' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'env' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.env = env

# The speed of sound.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait.
c = Property()

def _get_c(self):
return self._steer_obj.env.c

def _set_c(self, c):
msg = (
"Deprecated use of 'c' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'c' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.env.c = c

# :class:`~acoular.grids.Grid`-derived object that provides the grid locations.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait.
grid = Property()

def _get_grid(self):
return self._steer_obj.grid

def _set_grid(self, grid):
msg = (
"Deprecated use of 'grid' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'grid' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.grid = grid

# :class:`~acoular.microphones.MicGeom` object that provides the microphone locations.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait
mpos = Property()

def _get_mpos(self):
return self._steer_obj.mics

def _set_mpos(self, mpos):
msg = (
"Deprecated use of 'mpos' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'mpos' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
self._steer_obj.mics = mpos

# Sound travel distances from microphone array center to grid points (r0)
# and all array mics to grid points (rm). Readonly.
# Deprecated! Only kept for backwards compatibility.
# Now governed by :attr:`steer` trait
r0 = Property()

def _get_r0(self):
msg = (
"Deprecated use of 'r0' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'r0' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
return self._steer_obj.r0

rm = Property()

def _get_rm(self):
msg = (
"Deprecated use of 'rm' trait. Please use the 'steer' trait with an object of class"
"'SteeringVector'. The 'rm' trait will be removed in version 25.01."
)
warn(msg, DeprecationWarning, stacklevel=2)
return self._steer_obj.rm

# --- End of backwards compatibility traits --------------------------------------
steer = Instance(SteeringVector, args=())

#: Indices of grid points to calculate the PSF for.
grid_indices = CArray(
dtype=int,
value=array([]),
desc='indices of grid points for psf',
) # value=array([]), value=self.grid.pos(),
) # value=array([]), value=self.steer.grid.pos(),

#: Flag that defines how to calculate and store the point spread function
#: defaults to 'single'.
Expand Down Expand Up @@ -1242,7 +1006,7 @@ def _get_rm(self):
h5f = Instance(H5CacheFileBase, transient=True)

# internal identifier
digest = Property(depends_on=['_steer_obj.digest', 'precision'], cached=True)
digest = Property(depends_on=['steer.digest', 'precision'], cached=True)

@cached_property
def _get_digest(self):
Expand Down Expand Up @@ -1363,7 +1127,7 @@ def _psf_call(self, ind):
self.steer.steer_type,
self.steer.r0,
self.steer.rm,
2 * pi * self.freq / self.env.c,
2 * pi * self.freq / self.steer.env.c,
ind,
self.precision,
)
Expand Down Expand Up @@ -2602,7 +2366,7 @@ class BeamformerGridlessOrth(BeamformerAdaptiveGrid):

# internal identifier
digest = Property(
depends_on=['freq_data.digest', '_steer_obj.digest', 'precision', 'r_diag', 'eva_list', 'bounds', 'shgo'],
depends_on=['freq_data.digest', 'steer.digest', 'precision', 'r_diag', 'eva_list', 'bounds', 'shgo'],
)

@cached_property
Expand Down
20 changes: 0 additions & 20 deletions acoular/grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# imports from other packages
import xml.dom.minidom
from abc import abstractmethod
from warnings import warn

from numpy import (
absolute,
Expand Down Expand Up @@ -555,25 +554,6 @@ def _set_increment(self, increment):
else:
raise (TraitError(args=self, name='increment', info='Float or CArray(3,)', value=increment))

# Respective increments in x,y, and z-direction (in m).
# Deprecated: Use :attr:`~RectGrid.increment` for this functionality
increment3D = Property(desc='3D step sizes') # noqa N815

def _get_increment3D(self): # noqa N802
msg = "Using 'increment3D' is deprecated and will be removed in version 25.01." "Use 'increment' instead."
warn(msg, DeprecationWarning, stacklevel=2)
if isscalar(self._increment):
return array([self._increment, self._increment, self._increment])
return self._increment

def _set_increment3D(self, inc): # noqa N802
msg = "Using 'increment3D' is deprecated and will be removed in version 25.01." "Use 'increment' instead."
warn(msg, DeprecationWarning, stacklevel=2)
if not isscalar(inc) and len(inc) == 3:
self._increment = array(inc, dtype=float)
else:
raise (TraitError(args=self, name='increment3D', info='CArray(3,)', value=inc))

# internal identifier
digest = Property(
depends_on=['x_min', 'x_max', 'y_min', 'y_max', 'z_min', 'z_max', '_increment'],
Expand Down
32 changes: 2 additions & 30 deletions acoular/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,40 +233,12 @@ class SineGenerator(SignalGenerator):
#: Sine wave phase (in radians), float, defaults to 0.0.
phase = Float(0.0, desc='Phase')

# Internal shadow trait for rms/amplitude values.
# Do not set directly.
_amp = Float(1.0)

#: RMS of source signal (for point source: in 1 m distance).
#: Deprecated. For amplitude use :attr:`amplitude`.
rms = Property(desc='rms amplitude')

def _get_rms(self):
return self._amp / 2**0.5

def _set_rms(self, rms):
warn(
'Using rms to set amplitude is deprecated and will be removed in version 25.01. '
'Up to Acoular 20.02, rms is interpreted as sine amplitude. '
'This has since been corrected (rms now is 1/sqrt(2) of amplitude). '
"Use 'amplitude' trait to directly set the ampltiude.",
DeprecationWarning,
stacklevel=2,
)
self._amp = rms * 2**0.5

#: Amplitude of source signal (for point source: in 1 m distance).
#: Defaults to 1.0.
amplitude = Property(desc='amplitude')

def _get_amplitude(self):
return self._amp

def _set_amplitude(self, amp):
self._amp = amp
amplitude = Float(1.0)

# internal identifier
digest = Property(depends_on=['_amp', 'numsamples', 'sample_freq', 'freq', 'phase', '__class__'])
digest = Property(depends_on=['amplitude', 'numsamples', 'sample_freq', 'freq', 'phase', '__class__'])

@cached_property
def _get_digest(self):
Expand Down
Loading

0 comments on commit 358b376

Please sign in to comment.