Skip to content

Commit

Permalink
fixed linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nmahesh1412 committed Oct 16, 2024
1 parent 1278f41 commit 2638c31
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/pyuvdata/uvbeam/uvbeam.py
Original file line number Diff line number Diff line change
Expand Up @@ -4056,7 +4056,7 @@ def read_feko_beam(
"""
from . import feko_beam

Check warning on line 4057 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4057

Added line #L4057 was not covered by tests

if not isinstance(filename, (list, tuple)) and filename.endswith("yaml"):
if not isinstance(filename, list | tuple) and filename.endswith("yaml"):
settings_dict = self._read_feko_beam_yaml(filename)
if not isinstance(settings_dict["frequencies"], list):
raise ValueError("frequencies in yaml file must be a list.")
Expand All @@ -4082,8 +4082,8 @@ def read_feko_beam(
for key, val in overriding_keywords.items():
if val is not None:
warnings.warn(

Check warning on line 4084 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4078-L4084

Added lines #L4078 - L4084 were not covered by tests
"The {key} keyword is set, overriding the "
"value in the settings yaml file.".format(key=key)
f"The {key} keyword is set, overriding the "
"value in the settings yaml file."
)

if feed_pol is None:
Expand Down Expand Up @@ -4131,7 +4131,7 @@ def read_feko_beam(
rename_extra_keys_map = {"sim_beam_type": "sim_type"}
for key, value in settings_dict.items():
if key not in known_keys:
if key in rename_extra_keys_map.keys():
if key in rename_extra_keys_map:
extra_keywords[rename_extra_keys_map[key]] = value

Check warning on line 4135 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4131-L4135

Added lines #L4131 - L4135 were not covered by tests
else:
extra_keywords[key] = value

Check warning on line 4137 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4137

Added line #L4137 was not covered by tests
Expand All @@ -4155,9 +4155,9 @@ def read_feko_beam(
raise ValueError(f"frequency {freq} not in frequency list")
freq_inds = np.array(freq_inds)
frequency = freq_array[freq_inds].tolist()
cst_filename = np.array(cst_filename)[freq_inds].tolist()
if len(cst_filename) == 1:
cst_filename = cst_filename[0]
feko_filename = np.array(feko_filename)[freq_inds].tolist()
if len(feko_filename) == 1:
feko_filename = feko_filename[0]
if isinstance(feed_pol, list):
if rotate_pol is None:

Check warning on line 4162 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4155-L4162

Added lines #L4155 - L4162 were not covered by tests
# if a mix of feed pols, don't rotate by default
Expand All @@ -4182,21 +4182,19 @@ def read_feko_beam(
if len(frequency.shape) > 1:
raise ValueError("frequency can not be a multi-dimensional array")
frequency = frequency.tolist()
if isinstance(frequency, (list, tuple)):
if len(frequency) == 1:
frequency = frequency[0]
if isinstance(frequency, list | tuple) and len(frequency) == 1:
frequency = frequency[0]

Check warning on line 4186 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4181-L4186

Added lines #L4181 - L4186 were not covered by tests

if isinstance(feed_pol, np.ndarray):
if len(feed_pol.shape) > 1:
raise ValueError("feed_pol can not be a multi-dimensional array")
feed_pol = feed_pol.tolist()
if isinstance(feed_pol, (list, tuple)):
if len(feed_pol) == 1:
feed_pol = feed_pol[0]
if isinstance(feed_pol, list | tuple) and len(feed_pol) == 1:
feed_pol = feed_pol[0]

Check warning on line 4193 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4188-L4193

Added lines #L4188 - L4193 were not covered by tests

if isinstance(feko_filename, (list, tuple)):
if isinstance(feko_filename, list | tuple):
if frequency is not None:
if isinstance(frequency, (list, tuple)):
if isinstance(frequency, list | tuple):
if not len(frequency) == len(feko_filename):
raise ValueError(

Check warning on line 4199 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4195-L4199

Added lines #L4195 - L4199 were not covered by tests
"If frequency and filename are both "
Expand All @@ -4208,7 +4206,7 @@ def read_feko_beam(
else:
freq = None

Check warning on line 4207 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4207

Added line #L4207 was not covered by tests

if isinstance(feed_pol, (list, tuple)):
if isinstance(feed_pol, list | tuple):
if not len(feed_pol) == len(feko_filename):
raise ValueError(

Check warning on line 4211 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4209-L4211

Added lines #L4209 - L4211 were not covered by tests
"If feed_pol and filename are both "
Expand All @@ -4219,9 +4217,9 @@ def read_feko_beam(
else:
pol = feed_pol

Check warning on line 4218 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4218

Added line #L4218 was not covered by tests

if isinstance(freq, (list, tuple)):
if isinstance(freq, list | tuple):
raise ValueError("frequency can not be a nested list")
if isinstance(pol, (list, tuple)):
if isinstance(pol, list | tuple):
raise ValueError("feed_pol can not be a nested list")
self.read_feko_beam(

Check warning on line 4224 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4220-L4224

Added lines #L4220 - L4224 were not covered by tests
feko_filename[0],
Expand All @@ -4245,16 +4243,16 @@ def read_feko_beam(
fix_auto_power=fix_auto_power,
)
for file_i, f in enumerate(feko_filename[1:]):
if isinstance(f, (list, tuple)):
if isinstance(f, list | tuple):
raise ValueError("filename can not be a nested list")

Check warning on line 4247 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4245-L4247

Added lines #L4245 - L4247 were not covered by tests

if isinstance(frequency, (list, tuple)):
if isinstance(frequency, list | tuple):
freq = frequency[file_i + 1]
elif frequency is not None:
freq = frequency

Check warning on line 4252 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4249-L4252

Added lines #L4249 - L4252 were not covered by tests
else:
freq = None
if isinstance(feed_pol, (list, tuple)):
if isinstance(feed_pol, list | tuple):
pol = feed_pol[file_i + 1]

Check warning on line 4256 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4254-L4256

Added lines #L4254 - L4256 were not covered by tests
else:
pol = feed_pol
Expand Down Expand Up @@ -4284,9 +4282,9 @@ def read_feko_beam(
if len(feko_filename) > 1:
del beam2

Check warning on line 4283 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4281-L4283

Added lines #L4281 - L4283 were not covered by tests
else:
if isinstance(frequency, (list, tuple)):
if isinstance(frequency, list | tuple):
raise ValueError("Too many frequencies specified")
if isinstance(feed_pol, (list, tuple)):
if isinstance(feed_pol, list | tuple):
raise ValueError("Too many feed_pols specified")
feko_beam_obj = feko_beam.FEKOBeam()
feko_beam_obj.read_feko_beam(

Check warning on line 4290 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4285-L4290

Added lines #L4285 - L4290 were not covered by tests
Expand All @@ -4313,7 +4311,7 @@ def read_feko_beam(
self._convert_from_filetype(feko_beam_obj)
del feko_beam_obj

Check warning on line 4312 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4311-L4312

Added lines #L4311 - L4312 were not covered by tests

if not isinstance(filename, (list, tuple)) and filename.endswith("yaml"):
if not isinstance(filename, list | tuple) and filename.endswith("yaml"):

Check warning on line 4314 in src/pyuvdata/uvbeam/uvbeam.py

View check run for this annotation

Codecov / codecov/patch

src/pyuvdata/uvbeam/uvbeam.py#L4314

Added line #L4314 was not covered by tests
# update filelist
basename = os.path.basename(filename)
self.filename = utils._combine_filenames(self.filename, [basename])
Expand Down

1 comment on commit 2638c31

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 2638c31 Previous: 72dd3bc Ratio
tests/utils/test_bls.py::test_bls_to_ant[min=65536-len=1] 2795.0890910229364 iter/sec (stddev: 0.004830778803389285) 44005.55885505945 iter/sec (stddev: 0.000006947401622823317) 15.74
tests/utils/test_bls.py::test_bls_to_ant[min=65536-len=10] 13577.926243981909 iter/sec (stddev: 0.0017807709707240878) 39574.76477815693 iter/sec (stddev: 0.000014323943066984319) 2.91
tests/utils/test_bls.py::test_bls_to_ant[min=65536-len=100] 14338.857665273566 iter/sec (stddev: 0.0016348689668018027) 41745.83447873154 iter/sec (stddev: 0.00001520973371302237) 2.91
tests/utils/test_bls.py::test_bls_to_ant[min=65536-len=1000] 5479.193857872854 iter/sec (stddev: 0.0037757170837767655) 33672.05686613388 iter/sec (stddev: 0.000012705208926630871) 6.15
tests/utils/test_bls.py::test_bls_to_ant[min=65536-len=10000] 2688.845344263472 iter/sec (stddev: 0.00044884061636996916) 16651.36143925881 iter/sec (stddev: 0.000028714782332499303) 6.19
tests/utils/test_bls.py::test_bls_to_ant[min=65536-len=100000] 1219.133648706373 iter/sec (stddev: 0.001718295188802219) 2697.029604108284 iter/sec (stddev: 0.00006945868233318298) 2.21
tests/utils/test_bls.py::test_bls_to_ant[min=4259840-len=1] 12890.913039924322 iter/sec (stddev: 0.0014849532999373677) 45253.21348892038 iter/sec (stddev: 0.000006309466103868728) 3.51
tests/utils/test_bls.py::test_bls_to_ant[min=4259840-len=10] 12445.568109136551 iter/sec (stddev: 0.0015427111414052697) 42057.530643802216 iter/sec (stddev: 0.000008611893556022929) 3.38
tests/utils/test_bls.py::test_bls_to_ant[min=4259840-len=100] 17342.80892503266 iter/sec (stddev: 0.00002723075709980511) 42670.934804243894 iter/sec (stddev: 0.000009504441735601591) 2.46
tests/utils/test_bls.py::test_bls_to_ant[min=4259840-len=100000] 1071.4057799127022 iter/sec (stddev: 0.00041734378725408265) 2842.225436345786 iter/sec (stddev: 0.00005047587926328867) 2.65
tests/utils/test_bls.py::test_ants_to_bls[min=0-len=1] 3489.929949003207 iter/sec (stddev: 0.0006405815878294171) 17219.397451343597 iter/sec (stddev: 0.00009948268395025477) 4.93
tests/utils/test_bls.py::test_ants_to_bls[min=0-len=1000000] 10.261729115846672 iter/sec (stddev: 0.020087201234865768) 25.39529318728484 iter/sec (stddev: 0.0051326475372339125) 2.47
tests/utils/test_bls.py::test_ants_to_bls[min=65536-len=1] 9269.764395617745 iter/sec (stddev: 0.0016755567525856916) 19018.809758528256 iter/sec (stddev: 0.000020634598156091437) 2.05
tests/utils/test_bls.py::test_ants_to_bls[min=65536-len=100] 4610.991265726372 iter/sec (stddev: 0.0025864421038376993) 16502.48961933711 iter/sec (stddev: 0.000017937603983490586) 3.58
tests/utils/test_bls.py::test_ants_to_bls[min=65536-len=10000] 1149.6226082253024 iter/sec (stddev: 0.000828389191642038) 2626.1443811390286 iter/sec (stddev: 0.00004557742609505649) 2.28
tests/utils/test_bls.py::test_ants_to_bls[min=65536-len=100000] 146.6117930173466 iter/sec (stddev: 0.0026126264272924517) 301.3821261017551 iter/sec (stddev: 0.0007376766486852108) 2.06
tests/utils/test_bls.py::test_ants_to_bls[min=65536-len=1000000] 11.092230163421176 iter/sec (stddev: 0.04281137226695342) 22.342898800491287 iter/sec (stddev: 0.004313131039787093) 2.01
tests/utils/test_bls.py::test_ants_to_bls[min=4259840-len=1] 8484.019256072554 iter/sec (stddev: 0.00026075236721200603) 17581.03116720083 iter/sec (stddev: 0.0001299437220421759) 2.07
tests/utils/test_bls.py::test_ants_to_bls[min=4259840-len=100000] 123.02899718451295 iter/sec (stddev: 0.01436128642142318) 279.315884969191 iter/sec (stddev: 0.00110962046471358) 2.27

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.