Skip to content

Commit

Permalink
flake8: fix B028 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
r-pascua committed Feb 23, 2023
1 parent 87b8938 commit 4065107
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[flake8]
ignore =
# No space before colon
E203,
E203,
W503,
# Ignore using dict() function.
C408,
# Missing docstring in __init__ (we do it in the class)
D107,
# "First line should be in imperative mood" -- this doesn't work for properties, see https://github.com/PyCQA/pydocstyle/issues/301
D401,
D401,
# allow method names to be the same as python builtins
A003,
# inline strong start-string without end-string. This is OK in the case of **kwargs in parameters.
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ Changelog
dev-version
===========

v3.1.1 [2023.02.23]
===================

Changed
-------
- Coupling matrix calculation in :class:`~.sigchain.MutualCoupling` has been updated
to correctly calculate the coupling coefficients from the provided E-field beam.

v3.1.0 [2023.01.17]
===================

Expand Down
5 changes: 4 additions & 1 deletion hera_sim/__yaml_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ def astropy_unit_constructor(loader, node):
if value is None:
return None
elif units is None:
warnings.warn("You have not specified the units for this item. Returning None.")
warnings.warn(
"You have not specified the units for this item. Returning None.",
stacklevel=2,
)
return None
else:
try:
Expand Down
3 changes: 2 additions & 1 deletion hera_sim/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def write_calfits(
if sim_x_orientation is None:
warnings.warn(
"x_orientation not specified in simulation object."
"Assuming that the x-direction points north."
"Assuming that the x-direction points north.",
stacklevel=1,
)
else:
x_orientation = sim_x_orientation
Expand Down
2 changes: 1 addition & 1 deletion hera_sim/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def _check_config(self):
"Please check your configuration, as only the last "
"value specified for each parameter will be used."
)
warnings.warn(warning)
warnings.warn(warning, stacklevel=1)

def _handler(self, func, *args, **kwargs):
"""Decorator for applying new function parameter defaults."""
Expand Down
3 changes: 2 additions & 1 deletion hera_sim/interpolators.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def _interpolator(self):
warnings.warn(
"The provided LSTs do not sufficiently cover [0, 2*pi). "
"The interpolated sky temperature may have unexpected behavior "
"near 0 and 2*pi."
"near 0 and 2*pi.",
stacklevel=1,
)

lsts = np.concatenate(
Expand Down
3 changes: 2 additions & 1 deletion hera_sim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def empty_uvdata(
"deprecated and will be removed in the future. Please "
"update your code to use the Nfreqs, Ntimes, and "
"array_layout parameters instead.",
DeprecationWarning,
category=DeprecationWarning,
stacklevel=2,
)

# for backwards compatability
Expand Down
6 changes: 5 additions & 1 deletion hera_sim/noise.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,5 +243,9 @@ def white_noise(*args, **kwargs):
Deprecated. Use ``utils.gen_white_noise`` instead.
"""
warnings.warn("white_noise is being deprecated. Use utils.gen_white_noise instead.")
warnings.warn(
"white_noise is being deprecated. Use utils.gen_white_noise instead.",
category=DeprecationWarning,
stacklevel=2,
)
return utils.gen_white_noise(*args, **kwargs)
8 changes: 6 additions & 2 deletions hera_sim/rfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,10 @@ def __call__(self, lsts, freqs, **kwargs):
rfi = np.zeros((lsts.size, freqs.size), dtype=complex)

if stations is None:
warnings.warn("You did not specify any stations to simulate.")
warnings.warn(
"You did not specify any stations to simulate.",
stacklevel=2,
)
return rfi
elif isinstance(stations, (str, Path)):
# assume that it's a path to a npy file
Expand Down Expand Up @@ -410,7 +413,8 @@ def __call__(self, lsts, freqs, **kwargs):
warnings.warn(
"The DTV band does not overlap with any of the passed "
"frequencies. Please ensure that you are passing the "
"correct set of parameters."
"correct set of parameters.",
stacklevel=2,
)

# define an iterator, just to keep things neat
Expand Down
17 changes: 10 additions & 7 deletions hera_sim/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,8 @@ def add(
if seed is None and add_vis:
warnings.warn(
"You have not specified how to seed the random state. "
"This effect might not be exactly recoverable."
"This effect might not be exactly recoverable.",
stacklevel=2,
)

# Simulate the effect by iterating over baselines and polarizations.
Expand Down Expand Up @@ -1007,7 +1008,8 @@ def _iteratively_apply(
warnings.warn(
"You have chosen to neither add nor return the effect "
"you are trying to simulate, so nothing will be "
f"computed. This warning was raised for the model: {model}"
f"computed. This warning was raised for the model: {model}",
stacklevel=2,
)
return

Expand All @@ -1030,7 +1032,8 @@ def _iteratively_apply(
"You are attempting to compute a component but have "
"not specified an ``is_multiplicative`` attribute for "
"the component. The component will be added under "
"the assumption that it is *not* multiplicative."
"the assumption that it is *not* multiplicative.",
stacklevel=2,
)
is_multiplicative = False

Expand Down Expand Up @@ -1487,14 +1490,14 @@ def _sanity_check(self, model):
if is_multiplicative and not has_data:
warnings.warn(
"You are trying to compute a multiplicative "
"effect, but no visibilities have been "
"simulated yet."
"effect, but no visibilities have been simulated yet.",
stacklevel=1,
)
elif not is_multiplicative and contains_multiplicative_effect:
warnings.warn(
"You are adding visibilities to a data array "
"*after* multiplicative effects have been "
"introduced."
"*after* multiplicative effects have been introduced.",
stacklevel=1,
)

def _update_history(self, model, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions hera_sim/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,8 @@ def Jy2T(freqs, omega_p):
Deprecated in v1.0.0. Will be removed in v1.1.0
"""
warnings.warn(
"The function Jy2T has been renamed 'jansky_to_kelvin'. It will be removed in "
"v1.1."
"This function has been deprecated. Please use `jansky_to_kelvin` instead.",
stacklevel=1,
)
return jansky_to_kelvin(freqs, omega_p)

Expand Down
10 changes: 5 additions & 5 deletions hera_sim/visibilities/healvis_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,10 @@ def __init__(self, fov=180, nprocesses=1, sky_ref_chan=0):
raise ImportError("to use the healvis wrapper, you must install healvis!")

warnings.warn(
(
"The healvis package is deprecated. Please use pyuvsim instead. "
"The healvis wrapper will be removed from hera_sim in version 4",
),
"The healvis package is deprecated. Please use pyuvsim instead. "
"The healvis wrapper will be removed from hera_sim in version 4",
category=DeprecationWarning,
stacklevel=2,
)

self.fov = fov
Expand All @@ -72,7 +71,8 @@ def validate(self, model_data: ModelData):
warnings.warn(
"Using pyuvsim.AnalyticBeam for healvis is not really supported. "
"model_data.beams is being automatically modified to be a single "
"healvis.AnalyticBeam of the same type."
"healvis.AnalyticBeam of the same type.",
stacklevel=1,
)
old_args = model_data.beams[0].__dict__

Expand Down
6 changes: 4 additions & 2 deletions hera_sim/visibilities/pyuvsim_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def simulate(self, data_model: ModelData):
data_model.sky_model.name = np.array(data_model.sky_model.name)

warnings.warn(
"UVSim requires time-ordered data. Ensuring that order in UVData..."
"UVSim requires time-ordered data. Ensuring that order in UVData...",
stacklevel=1,
)
data_model.uvdata.reorder_blts("time")

Expand All @@ -44,7 +45,8 @@ def simulate(self, data_model: ModelData):
# at least check whether reordering is necessary once uvdata has that ability.
if np.any(data_model.uvdata.polarization_array != np.array([-5, -6, -7, -8])):
warnings.warn(
"In UVSim, polarization array must be in AIPS order. Reordering..."
"In UVSim, polarization array must be in AIPS order. Reordering...",
stacklevel=1,
)
data_model.uvdata.reorder_pols("AIPS")

Expand Down

0 comments on commit 4065107

Please sign in to comment.