From 9bf9b3c743441a13aec7e1d9adfa46e32260b42b Mon Sep 17 00:00:00 2001 From: Umut Date: Mon, 4 Apr 2022 13:28:53 +0200 Subject: [PATCH] feat: implement internal module --- concrete/numpy/internal/__init__.py | 3 +++ concrete/numpy/internal/utils.py | 31 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 concrete/numpy/internal/__init__.py create mode 100644 concrete/numpy/internal/utils.py diff --git a/concrete/numpy/internal/__init__.py b/concrete/numpy/internal/__init__.py new file mode 100644 index 000000000..065af833e --- /dev/null +++ b/concrete/numpy/internal/__init__.py @@ -0,0 +1,3 @@ +""" +Declaration of `concrete.numpy.internal` namespace. +""" diff --git a/concrete/numpy/internal/utils.py b/concrete/numpy/internal/utils.py new file mode 100644 index 000000000..804f4fe6c --- /dev/null +++ b/concrete/numpy/internal/utils.py @@ -0,0 +1,31 @@ +""" +Declaration of various functions and constants related to the entire project. +""" + + +def assert_that(condition: bool, message: str = ""): + """ + Assert a condition. + + Args: + condition (bool): + condition to assert + + message (str): + message to give to `AssertionError` if the condition does not hold + + Raises: + AssertionError: + if the condition does not hold + """ + + if not condition: + raise AssertionError(message) + + +def unreachable(): + """ + Raise a RuntimeError to indicate unreachable code is entered. + """ + + raise RuntimeError("Entered unreachable code")