Skip to content

Commit

Permalink
MNT: Clean up various issues found by CodeQL
Browse files Browse the repository at this point in the history
Including a big commented out test for a solar_irradiance function we
haven't had since the early days.
  • Loading branch information
dopplershift committed Jun 24, 2021
1 parent de081c5 commit 013d12c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 39 deletions.
3 changes: 3 additions & 0 deletions src/metpy/io/nexrad.py
Expand Up @@ -664,6 +664,8 @@ def _buffer_segment(self, msg_hdr):
if msg_hdr.num_segments == len(bufs):
self._msg_buf.pop(msg_hdr.msg_type)
return b''.join(bytes(item[1]) for item in sorted(bufs.items()))
else:
return None

def _add_sweep(self, hdr):
if not self.sweeps and not hdr.rad_status & START_VOLUME:
Expand Down Expand Up @@ -1753,6 +1755,7 @@ def __init__(self, filename):
self._buffer.splice(comp_start, decomp_data)
assert self._buffer.check_remains(self.metadata['uncompressed_size'])
except OSError:
# Compression didn't work, so we just assume it wasn't actually compressed.
pass

# Unpack the various blocks, if present. The factor of 2 converts from
Expand Down
2 changes: 0 additions & 2 deletions src/metpy/pandas.py
Expand Up @@ -3,12 +3,10 @@
# SPDX-License-Identifier: BSD-3-Clause
"""Provide accessors to enhance interoperability between Pandas and MetPy."""
import functools
import logging

import pandas as pd

__all__ = []
log = logging.getLogger(__name__)


def preprocess_pandas(func):
Expand Down
1 change: 1 addition & 0 deletions src/metpy/plots/wx_symbols.py
Expand Up @@ -63,6 +63,7 @@ def wx_code_to_numeric(codes):
wx_sym_list.append(wx_code_map[wxcode[opt]])
break
except KeyError:
# That option didn't work--move on.
pass
else:
wx_sym_list.append(0)
Expand Down
35 changes: 0 additions & 35 deletions tests/calc/test_basic.py
Expand Up @@ -317,41 +317,6 @@ def test_geopotential_to_height_32bit():
assert_almost_equal(geopotential_to_height(geopot), truth, 2)


# class TestIrrad(object):
# def test_basic(self):
# 'Test the basic solar irradiance calculation.'
# from datetime import date

# d = date(2008, 9, 28)
# lat = 35.25
# hours = np.linspace(6,18,10)

# s = solar_irradiance(lat, d, hours)
# values = np.array([0., 344.1, 682.6, 933.9, 1067.6, 1067.6, 933.9,
# 682.6, 344.1, 0.])
# assert_array_almost_equal(s, values, 1)

# def test_scalar(self):
# from datetime import date
# d = date(2008, 9, 28)
# lat = 35.25
# hour = 9.5
# s = solar_irradiance(lat, d, hour)
# assert_almost_equal(s, 852.1, 1)

# def test_invalid(self):
# 'Test for values that should be masked.'
# from datetime import date
# d = date(2008, 9, 28)
# lat = 35.25
# hours = np.linspace(0,22,12)
# s = solar_irradiance(lat, d, hours)

# mask = np.array([ True, True, True, True, False, False, False,
# False, False, True, True, True])
# assert_array_equal(s.mask, mask)


def test_pressure_to_heights_basic():
"""Test basic pressure to height calculation for standard atmosphere."""
pressures = np.array([975.2, 987.5, 956., 943.]) * units.mbar
Expand Down
4 changes: 2 additions & 2 deletions tests/test_xarray.py
Expand Up @@ -1069,8 +1069,8 @@ def test_update_attribute_dictionary(test_ds_generic):
def test_update_attribute_callable(test_ds_generic):
"""Test update_attribute using callable."""
def even_ascii(varname, **kwargs):
if ord(varname[0]) % 2 == 0:
return 'yes'
return 'yes' if ord(varname[0]) % 2 == 0 else 'no'

result = test_ds_generic.metpy.update_attribute('even', even_ascii)

# Test attribute updates
Expand Down

0 comments on commit 013d12c

Please sign in to comment.