Skip to content

Commit 4cdc35e

Browse files
authored
fromfile & fromarchive (#114)
* import fromfile & fromarchive into top level to simplify usage * increment patch
1 parent 26ef5d5 commit 4cdc35e

File tree

5 files changed

+16
-16
lines changed

5 files changed

+16
-16
lines changed

docs/source/advanced.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Now lets add another SigMF Recording and associate them with a SigMF Collection:
9999

100100
.. code-block:: python
101101
102-
from sigmf import SigMFCollection
102+
from sigmf import SigMFFile, SigMFCollection
103103
104104
data_ci16 = np.zeros(1024, dtype=np.complex64)
105105
@@ -134,8 +134,8 @@ The SigMF Collection and its associated Recordings can now be loaded like this:
134134

135135
.. code-block:: python
136136
137-
from sigmf import sigmffile
138-
collection = sigmffile.fromfile('example_zeros')
137+
import sigmf
138+
collection = sigmf.fromfile('example_zeros')
139139
ci16_sigmffile = collection.get_SigMFFile(stream_name='example_ci16')
140140
cf32_sigmffile = collection.get_SigMFFile(stream_name='example_cf32')
141141
@@ -194,4 +194,4 @@ read it, this can be done "in mid air" or "without touching the ground (disk)".
194194
>>> arc = sigmf.SigMFArchiveReader(archive_buffer=sigmf_bytes)
195195
>>> arc[:10]
196196
array([-20.+11.j, -21. -6.j, -17.-20.j, -13.-52.j, 0.-75.j, 22.-58.j,
197-
48.-44.j, 49.-60.j, 31.-56.j, 23.-47.j], dtype=complex64)
197+
48.-44.j, 49.-60.j, 31.-56.j, 23.-47.j], dtype=complex64)

docs/source/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Read a SigMF Recording
2323
.. code-block:: python
2424
2525
import sigmf
26-
handle = sigmf.sigmffile.fromfile("example.sigmf")
26+
handle = sigmf.fromfile("example.sigmf")
2727
handle.read_samples() # returns all timeseries data
2828
handle.get_global_info() # returns 'global' dictionary
2929
handle.get_captures() # returns list of 'captures' dictionaries
@@ -79,4 +79,4 @@ Save a Numpy array as a SigMF Recording
7979
})
8080
8181
# check for mistakes & write to disk
82-
meta.tofile('example_cf32.sigmf-meta') # extension is optional
82+
meta.tofile('example_cf32.sigmf-meta') # extension is optional

sigmf/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
# SPDX-License-Identifier: LGPL-3.0-or-later
66

77
# version of this python module
8-
__version__ = "1.2.11"
8+
__version__ = "1.2.12"
99
# matching version of the SigMF specification
1010
__specification__ = "1.2.5"
1111

1212
from . import archive, archivereader, error, schema, sigmffile, utils, validate
1313
from .archive import SigMFArchive
1414
from .archivereader import SigMFArchiveReader
15-
from .sigmffile import SigMFCollection, SigMFFile
15+
from .sigmffile import SigMFCollection, SigMFFile, fromarchive, fromfile

tests/test_archivereader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def test_archiveread_data_file_unchanged(test_sigmffile):
8686
with NamedTemporaryFile(suffix=".sigmf") as temp_file:
8787
input_samples = test_sigmffile.read_samples()
8888
test_sigmffile.archive(temp_file.name)
89-
arc = sigmf.sigmffile.fromfile(temp_file.name)
89+
arc = sigmf.fromfile(temp_file.name)
9090
output_samples = arc.read_samples()
9191

9292
assert np.array_equal(input_samples, output_samples)

tests/test_sigmffile.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
import numpy as np
1717

18-
from sigmf import error, sigmffile, utils
19-
from sigmf.sigmffile import SigMFFile
18+
import sigmf
19+
from sigmf import SigMFFile, error, utils
2020

2121
from .testdata import *
2222

@@ -38,9 +38,9 @@ def tearDown(self):
3838
def test_pathlib_handle(self):
3939
"""ensure file can be a string or a pathlib object"""
4040
self.assertTrue(self.temp_path_data.exists())
41-
obj_str = sigmffile.fromfile(str(self.temp_path_data))
41+
obj_str = sigmf.fromfile(str(self.temp_path_data))
4242
obj_str.validate()
43-
obj_pth = sigmffile.fromfile(self.temp_path_data)
43+
obj_pth = sigmf.fromfile(self.temp_path_data)
4444
obj_pth.validate()
4545

4646
def test_filenames_with_dots(self):
@@ -54,7 +54,7 @@ def test_filenames_with_dots(self):
5454
self.sigmf_object.tofile(temp_path_meta)
5555
files = [str(temp_path_data), temp_path_data, str(temp_path_meta), temp_path_meta]
5656
for filename in files:
57-
obj = sigmffile.fromfile(filename)
57+
obj = sigmf.fromfile(filename)
5858
obj.validate()
5959

6060
def test_iterator_basic(self):
@@ -245,7 +245,7 @@ def prepare(self, data: list, meta: dict, dtype: type) -> SigMFFile:
245245
np.array(data, dtype=dtype).tofile(self.temp_path_data)
246246
with open(self.temp_path_meta, "w") as handle:
247247
json.dump(meta, handle)
248-
meta = sigmffile.fromfile(self.temp_path_meta, skip_checksum=True)
248+
meta = sigmf.fromfile(self.temp_path_meta, skip_checksum=True)
249249
return meta
250250

251251
def test_000(self) -> None:
@@ -367,7 +367,7 @@ def test_add_annotation():
367367
def test_fromarchive(test_sigmffile):
368368
with tempfile.NamedTemporaryFile(suffix=".sigmf") as temp_file:
369369
archive_path = test_sigmffile.archive(name=temp_file.name)
370-
result = sigmffile.fromarchive(archive_path=archive_path)
370+
result = sigmf.fromarchive(archive_path=archive_path)
371371
assert result._metadata == test_sigmffile._metadata == TEST_METADATA
372372

373373

0 commit comments

Comments
 (0)