From b6d041e999c778fbbbcd3c8f7817fdaa714563e9 Mon Sep 17 00:00:00 2001 From: Holger Mueller Date: Thu, 21 Nov 2019 13:23:17 +0100 Subject: [PATCH] Added r as attribute to Touchstone --- NanoVNASaver/Touchstone.py | 6 +++++- test/test_touchstone.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NanoVNASaver/Touchstone.py b/NanoVNASaver/Touchstone.py index 64bdf5e..7a9f5f7 100644 --- a/NanoVNASaver/Touchstone.py +++ b/NanoVNASaver/Touchstone.py @@ -113,7 +113,11 @@ class Touchstone: def s22data(self) -> list: return self.s("22") - def s(self, name: str): + @property + def r(self) -> int: + return self.opts.resistance + + def s(self, name: str) -> list: return self.sdata[Touchstone.FIELD_ORDER.index(name)] def _parse_comments(self, fp) -> str: diff --git a/test/test_touchstone.py b/test/test_touchstone.py index 3747c95..2841d09 100644 --- a/test/test_touchstone.py +++ b/test/test_touchstone.py @@ -61,6 +61,7 @@ class TestTouchstoneTouchstone(unittest.TestCase): self.assertEqual(str(ts.opts), "# HZ S RI R 50") self.assertEqual(len(ts.s11data), 1010) self.assertEqual(len(ts.s21data), 0) + self.assertEqual(ts.r, 50) ts = Touchstone("./test/data/valid.s2p") ts.load()