Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ permissions:
# LIBRARY_DESTINATION_DIRECTORY: Path in this repo where shared library files should be placed.
env:
LIBRARY_BASE_REPO: NTIA/LFMF
LIBRARY_RELEASE_TAG: v1.1
LIBRARY_RELEASE_TAG: v1.2-rc.2
LIBRARY_DESTINATION_DIRECTORY: 'src/ITS/Propagation/LFMF'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ permissions:
# LIBRARY_DESTINATION_DIRECTORY: Path in this repo where shared library files should be placed.
env:
LIBRARY_BASE_REPO: NTIA/LFMF
LIBRARY_RELEASE_TAG: v1.1
LIBRARY_RELEASE_TAG: v1.2-rc.2
LIBRARY_DESTINATION_DIRECTORY: 'src/ITS/Propagation/LFMF'

jobs:
Expand Down
2 changes: 1 addition & 1 deletion .zenodo.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
"resource_type": "publication-softwaredocumentation"
}
],
"version": "1.1.0"
"version": "1.2.0"
}
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ keywords:
- propagation
- lfmf
- antennas
version: 1.1.0
version: 1.2.0
20 changes: 19 additions & 1 deletion src/ITS/Propagation/LFMF/LFMF.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LFMFResult(Structure):


# Load the shared library
lib = PropLibCDLL("LFMF-1.1")
lib = PropLibCDLL("LFMF-1.2")

# Define function prototypes
lib.LFMF.restype = c_int
Expand Down Expand Up @@ -106,3 +106,21 @@ def __convertResultStruct(c_result):
result.method = SolutionMethod(c_result.method)

return result


def GetLibraryName() -> str:
return __read_char_array(lib.GetLibraryNameCharArray())


def GetLibraryVersion() -> str:
return __read_char_array(lib.GetLibraryVersionCharArray())


def __read_char_array(msg) -> str:
try:
msg_bytes = cast(msg, c_char_p).value
if msg_bytes is None:
raise RuntimeError("The TODO-TEMPLATE library returned an empty text response.")
return msg_bytes.decode("utf-8")
finally:
lib.FreeCharArray(msg)
6 changes: 4 additions & 2 deletions src/ITS/Propagation/LFMF/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# Version X.Y.Z: X.Y is the version of the C++ source,
# and Z is the version of this Python wrapper
__version__ = "1.1.1"
__version__ = "1.2.0"

from .LFMF import (
LFMF,
Polarization,
SolutionMethod,
LFMFResult
LFMFResult,
GetLibraryName,
GetLibraryVersion,
)
10 changes: 7 additions & 3 deletions src/ITS/Propagation/LFMF/proplib_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ def __init__(self, name: str) -> None:
# Define expected function prototypes
self.GetReturnStatusCharArray.restype = POINTER(c_char_p)
self.GetReturnStatusCharArray.argtypes = (c_int,)
self.FreeReturnStatusCharArray.restype = None
self.FreeReturnStatusCharArray.argtypes = (POINTER(c_char_p),)
self.FreeCharArray.restype = None
self.FreeCharArray.argtypes = (POINTER(c_char_p),)
self.GetLibraryNameCharArray.restype = POINTER(c_char_p)
self.GetLibraryNameCharArray.argtypes = None
self.GetLibraryVersionCharArray.restype = POINTER(c_char_p)
self.GetLibraryVersionCharArray.argtypes = None


@staticmethod
Expand Down Expand Up @@ -122,5 +126,5 @@ def err_check(self, rtn_code: int) -> None:
)
msg_str = msg_bytes.decode("utf-8")
finally:
self.FreeReturnStatusCharArray(msg)
self.FreeCharArray(msg)
raise RuntimeError(msg_str)
4 changes: 2 additions & 2 deletions tests/test_proplib_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def GetReturnStatusCharArray(_code):
return cast(c_char_p(error_message), POINTER(c_char_p))

@staticmethod
def FreeReturnStatusCharArray(message) -> None:
def FreeCharArray(message) -> None:
freed_messages.append(message)

with pytest.raises(RuntimeError, match="example failure"):
Expand All @@ -82,7 +82,7 @@ def GetReturnStatusCharArray(_code):
return cast(c_char_p(None), POINTER(c_char_p))

@staticmethod
def FreeReturnStatusCharArray(message) -> None:
def FreeCharArray(message) -> None:
freed_messages.append(message)

with pytest.raises(RuntimeError, match="no error text was returned"):
Expand Down
12 changes: 12 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from pathlib import Path
from typing import Optional

from ITS.Propagation import LFMF

# Test data is expected to exist in tests/data
TEST_DATA_DIR = Path(__file__).parent / "data"
ABSTOL__DB = 0.1 # Absolute tolerance, in dB, to ensure outputs match expected value
Expand Down Expand Up @@ -38,3 +40,13 @@ def read_csv_test_data(filename: str, data_dir: Optional[Path] = None):
for row in reader:
# yields (*inputs, rtn, *outputs)
yield tuple(map(float, row[:-5])), int(row[-5]), tuple(map(float, row[-4:]))


def test_LibraryName():
name = LFMF.GetLibraryName()
assert name == 'LFMF'


def test_LibraryVersion():
version = LFMF.GetLibraryVersion()
assert version == '1.2'