2020from sigmf import SigMFFile , error , utils
2121from sigmf .sigmffile import _DeprecatingKey , _SigMFDeprecatingMeta
2222
23- from .testdata import *
23+ from .testdata import (
24+ TEST_FLOAT32_DATA ,
25+ TEST_METADATA ,
26+ TEST_U8_DATA0 ,
27+ TEST_U8_DATA1 ,
28+ TEST_U8_DATA2 ,
29+ TEST_U8_DATA3 ,
30+ TEST_U8_DATA4 ,
31+ TEST_U8_META0 ,
32+ TEST_U8_META1 ,
33+ TEST_U8_META2 ,
34+ TEST_U8_META3 ,
35+ TEST_U8_META4 ,
36+ )
2437
2538
2639class TestClassMethods (unittest .TestCase ):
@@ -140,8 +153,10 @@ def test_set_data_file_with_annotations(self):
140153
141154class TestMultichannel (unittest .TestCase ):
142155 def setUp (self ):
143- # in order to check shapes we need some positive number of samples to work with
144- # number of samples should be lowest common factor of num_channels
156+ """
157+ In order to check shapes we need some positive number of samples to work with.
158+ Number of samples should be lowest common factor of num_channels.
159+ """
145160 self .raw_count = 16
146161 self .lut = {
147162 "i8" : np .int8 ,
@@ -534,19 +549,13 @@ def tearDown(self):
534549
535550 def test_basic_creation (self ):
536551 """test creating SigMFFile from array"""
537- meta = sigmf .fromarray (TEST_FLOAT32_DATA , sample_rate = 4000 )
538- self .assertEqual (meta .get_global_field (sigmf .SAMPLE_RATE_KEY ), 4000 )
552+ meta = sigmf .fromarray (TEST_FLOAT32_DATA )
539553 self .assertEqual (meta .get_global_field (sigmf .DATATYPE_KEY ), "rf32_le" )
540554 np .testing .assert_array_equal (TEST_FLOAT32_DATA , meta [:])
541555
542- def test_with_frequency (self ):
543- """test that frequency kwarg populates capture metadata"""
544- meta = sigmf .fromarray (TEST_FLOAT32_DATA , sample_rate = 4000 , frequency = 915e6 )
545- self .assertEqual (meta .get_capture_info (0 ).get ("core:frequency" ), 915e6 )
546-
547556 def test_write_separate_files (self ):
548557 """test writing to separate meta and data files"""
549- meta = sigmf .fromarray (TEST_FLOAT32_DATA , sample_rate = 4000 )
558+ meta = sigmf .fromarray (TEST_FLOAT32_DATA )
550559 path = self .temp_dir / "basic"
551560 meta .tofile (str (path ))
552561 self .assertTrue ((self .temp_dir / "basic.sigmf-data" ).exists ())
@@ -556,7 +565,7 @@ def test_write_separate_files(self):
556565
557566 def test_write_archive (self ):
558567 """test writing to uncompressed archive"""
559- meta = sigmf .fromarray (TEST_FLOAT32_DATA , sample_rate = 4000 )
568+ meta = sigmf .fromarray (TEST_FLOAT32_DATA )
560569 path = self .temp_dir / "archived.sigmf"
561570 meta .tofile (str (path ))
562571 self .assertTrue ((self .temp_dir / "archived.sigmf" ).exists ())
@@ -567,19 +576,11 @@ def test_write_archive(self):
567576
568577 def test_write_compressed_archive (self ):
569578 """test writing to compressed archive"""
570- meta = sigmf .fromarray (TEST_FLOAT32_DATA , sample_rate = 4000 )
579+ meta = sigmf .fromarray (TEST_FLOAT32_DATA )
571580 path = self .temp_dir / "comp.sigmf.xz"
572581 meta .tofile (str (path ))
573582 self .assertTrue ((self .temp_dir / "comp.sigmf.xz" ).exists ())
574583 self .assertFalse ((self .temp_dir / "comp.sigmf-data" ).exists ())
575584 self .assertFalse ((self .temp_dir / "comp.sigmf-meta" ).exists ())
576585 loopback = sigmf .fromfile (str (path ))
577586 np .testing .assert_array_equal (TEST_FLOAT32_DATA , loopback [:])
578-
579- def test_with_global_info (self ):
580- """test that global_info dict is merged into metadata"""
581- meta = sigmf .fromarray (
582- TEST_FLOAT32_DATA , sample_rate = 4000 , global_info = {"core:author" : "test_author" , "core:description" : "test" }
583- )
584- self .assertEqual (meta .get_global_field ("core:author" ), "test_author" )
585- self .assertEqual (meta .get_global_field ("core:description" ), "test" )
0 commit comments