Skip to content

Commit

Permalink
Fix regex used to detect an attribute that must be convert to a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
brenard31 authored and jeandet committed Dec 19, 2024
1 parent a415c1a commit d1eac57
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion speasy/core/codecs/bundled_codecs/istp_cdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from speasy.products import SpeasyVariable, VariableAxis, VariableTimeAxis, DataContainer

log = logging.getLogger(__name__)
_PTR_rx = re.compile(r".*_PTR_\d+")
_PTR_rx = re.compile(r".*_PTR(_\d+)?")


def _fix_value_type(value):
Expand Down
Binary file added tests/resources/ge_h0_cpi_00000000_v01.cdf
Binary file not shown.
15 changes: 15 additions & 0 deletions tests/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,18 @@ def test_variable_is_loaded(self):

def test_variable_shape(self):
self.assertEqual(self.v.values.shape, (24, 3))


@ddt
class TestCDFWriterPtrAttributes(unittest.TestCase):

@data(
(f"{__HERE__}/resources/ge_h0_cpi_00000000_v01.cdf", "cdf", "SW_V"),
)
@unpack
def test_read_files(self, filename, codec_id, variable):
codec = get_codec(codec_id)
self.assertIsNotNone(codec)
data = codec.load_variable(variable, file=filename)
buffer = codec.save_variables([data])
self.assertIsNotNone(buffer)

0 comments on commit d1eac57

Please sign in to comment.