ソースを参照

Photonics structure prototype

Min 5 年 前
コミット
28162f72c0
1 ファイル変更32 行追加0 行削除
  1. 32 0
      photonics.py

+ 32 - 0
photonics.py

@@ -0,0 +1,32 @@
+from defs import Channel
+import numpy as np
+
+
+class PhotonicCoder:
+
+    def encode(self, data: np.ndarray) -> np.ndarray:
+        """
+        """
+        raise NotImplemented("encode function not defined")
+
+    def decode(self, data: np.ndarray) -> np.ndarray:
+        """
+        """
+        raise NotImplemented("decode function not defined")
+
+
+class PhotonicSimulation:
+    """
+    This is a main class that will contain coder/channel and all
+    necessary useful methods to run/monitor simulation
+    """
+
+    def __init__(self, coder: PhotonicCoder, channel: Channel):
+        self.coder = coder
+        self.channel = channel
+
+    def run(self, data: np.ndarray) -> np.ndarray:
+        encoded = self.coder.encode(data)
+        transmitted = self.channel.forward(encoded)
+        decoded = self.coder.decode(transmitted)
+        return decoded