Skip to content

Conversation

@nawendt
Copy link
Contributor

@nawendt nawendt commented Mar 11, 2024

Description Of Changes

Use set instead of list to hold possible elements within the GEMPAK file object. set has better performance when checking for element membership. This change also allowed for modifications to the looping done to unpack elements such that performance would be further increased.

@nawendt nawendt requested a review from a team as a code owner March 11, 2024 19:17
@nawendt nawendt requested review from dcamron and removed request for a team March 11, 2024 19:17
@dopplershift
Copy link
Member

I'm ok with the change. Can you take a look and see if there is a major file type or scenario here that's not covered in our tests? It looks like 30% of the changes here don't get run by the tests.


def test_merged_sounding_no_packing():
"""Test loading a merged sounding without data packing."""
gso = GempakSounding(get_test_data('gem_merged_nopack.snd')).snxarray(

Check warning

Code scanning / CodeQL

File is not always closed

File is opened but is not closed.
gsped = gso[0].sped.values.squeeze()
ghght = gso[0].hght.values.squeeze()

gempak = pd.read_csv(get_test_data('gem_merged_nopack.csv', as_file_obj=False),

Check warning

Code scanning / CodeQL

File is not always closed

File is opened but is not closed.

def test_climate_surface():
"""Test to read a cliamte surface file."""
gsf = GempakSurface(get_test_data('gem_climate.sfc'))

Check warning

Code scanning / CodeQL

File is not always closed

File is opened but is not closed.
gsf = GempakSurface(get_test_data('gem_climate.sfc'))
gstns = gsf.sfjson()

gempak = pd.read_csv(get_test_data('gem_climate.csv', as_file_obj=False))

Check warning

Code scanning / CodeQL

File is not always closed

File is opened but is not closed.
@pytest.mark.parametrize('order', ['little', 'big'])
def test_byte_swap(order):
""""Test byte swapping."""
g = get_test_data(f'gem_{order}_endian.grd')

Check warning

Code scanning / CodeQL

File is not always closed

File may not be closed if an exception is raised.
Use `set` instead of `list` to hold possible elements within the
GEMPAK file object. `set` has better performance when checking for
element membership. This change also allowed for modifications to the
looping done to unpack elements such that performace would be further
increased.

Adds climate surface files for testing. This also updates the surface
file type detection that was producing incorrect results. String data
was removed from unmerged sounding unpacking routine as this should not
appear in those file types per GEMPAK documentation.

Add additional tests to improve coverage.
Copy link
Member

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Thanks for the work to improve the test coverage!

@dopplershift dopplershift added Type: Enhancement Enhancement to existing functionality Area: IO Pertains to reading data labels Mar 14, 2024
@dopplershift dopplershift merged commit 8f510ae into Unidata:main Mar 14, 2024
@github-actions github-actions bot added this to the 1.7.0 milestone Mar 14, 2024
@nawendt nawendt deleted the gem-perf branch April 25, 2024 23:34
@dopplershift dopplershift modified the milestones: 1.7.0, 1.6.2 Jun 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: IO Pertains to reading data Type: Enhancement Enhancement to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants