Skip to content

Commit

Permalink
address PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
bhazelton committed Sep 20, 2024
1 parent 8079201 commit 2769fc3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions docs/make_uvbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def write_uvbeam_rst(write_file=None):
-----------------------
UVbeams can be instantiated directly from yaml files using the
``!UVBeam`` tag. The ``filename`` parameter must be specified and and
``!UVBeam`` tag. The ``filename`` parameter must be specified and
any other parameter that can be passed to the :meth:`pyuvdata.UVBeam.read`
method can also be specified.
Expand All @@ -86,7 +86,7 @@ def write_uvbeam_rst(write_file=None):
beam: !UVBeam
filename: hera.beamfits
An UVbeam specification with some with some keywords to pass to ``UVBeam.read``::
An UVbeam specification with some keywords to pass to ``UVBeam.read``::
beam: !UVBeam
filename: mwa_full_EE_test.h5
Expand Down
12 changes: 7 additions & 5 deletions src/pyuvdata/analytic_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def __post_init__(self, include_cross_pols):
for feed in self.feed_array:
allowed_feeds = ["n", "e", "x", "y", "r", "l"]
if feed not in allowed_feeds:
raise ValueError(f"Feeds must be one of: {allowed_feeds}")
raise ValueError(
f"Feeds must be one of: {allowed_feeds}, "
f"got feeds: {self.feed_array}"
)
self.feed_array = np.asarray(self.feed_array)
else:
self.feed_array = np.asarray(["x", "y"])
Expand Down Expand Up @@ -471,12 +474,9 @@ def _analytic_beam_constructor(loader, node):
class_parts = (values.pop("class")).split(".")
class_name = class_parts[-1]

if class_name in AnalyticBeam.__types__:
beam_class = AnalyticBeam.__types__[class_name]
elif len(class_parts) > 1:
if class_name not in AnalyticBeam.__types__ and len(class_parts) > 1:
module = (".").join(class_parts[:-1])
module = importlib.import_module(module)
beam_class = getattr(module, class_name)

if class_name not in AnalyticBeam.__types__:
raise NameError(
Expand All @@ -486,6 +486,8 @@ def _analytic_beam_constructor(loader, node):
"dot-pathed modules included (i.e. `my_module.MyAnalyticBeam`)"
)

beam_class = AnalyticBeam.__types__[class_name]

beam = beam_class(**values)

return beam
Expand Down
10 changes: 5 additions & 5 deletions src/pyuvdata/beam_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class BeamInterface:
beam_type: Literal["efield", "power"] | None = None
include_cross_pols: InitVar[bool] = True

def __post_init__(self, include_cross_pols):
def __post_init__(self, include_cross_pols: bool):
"""
Post-initialization validation and conversions.
Expand All @@ -67,7 +67,6 @@ def __post_init__(self, include_cross_pols):
f"{type(self.beam)}."
)
if isinstance(self.beam, UVBeam):
self._isuvbeam = True
if self.beam_type is None or self.beam_type == self.beam.beam_type:
self.beam_type = self.beam.beam_type
elif self.beam_type == "power":
Expand All @@ -83,9 +82,10 @@ def __post_init__(self, include_cross_pols):
"efield beam, either provide an efield UVBeam or do not "
"specify `beam_type`."
)
else:
# AnalyticBeam
self._isuvbeam = False

@property
def _isuvbeam(self):
return isinstance(self.beam, UVBeam)

def compute_response(
self,
Expand Down

0 comments on commit 2769fc3

Please sign in to comment.