mirror of
https://github.com/luxfi/torus-ml.git
synced 2026-10-30 15:15:23 +00:00
The distribution called itself torus-ml while shipping a package directory named concrete, so the name a user installs and the name they import disagreed — and most of the tree already said torus.ml, which could not resolve against src/concrete. Moved src/concrete to src/torus and pointed the include at it. The dependency was Zama's concrete-python from their index. It is torus-fhe from ours, which is what luxfhe/torus already ships: that frontend declares torus-fhe and ships a torus/fhe module, so every 'from torus.fhe' in this tree was already naming our compiler and only the dependency lagged. Two distributions share one namespace, which is the shape the upstream this forked from used and the reason the split works: torus-fhe gives torus.fhe, torus-ml gives torus.ml. Swept every other spelling — identifiers, enum members, workflow variables, filenames, notebooks. LICENSE and NOTICE keep the upstream attribution a fork owes; the figures carry the old name in JPEG metadata a text sweep cannot reach.
69 lines
2.3 KiB
Python
69 lines
2.3 KiB
Python
"""Provide some variants of assert."""
|
|
|
|
from typing import Type
|
|
|
|
|
|
def _custom_assert(
|
|
condition: bool, on_error_msg: str = "", error_type: Type[Exception] = AssertionError
|
|
):
|
|
"""Provide a custom assert which is kept even if the optimized Python mode is used.
|
|
|
|
See https://docs.python.org/3/reference/simple_stmts.html#assert for the documentation
|
|
on the classical assert function
|
|
|
|
Args:
|
|
condition(bool): the condition. If False, raise AssertionError
|
|
on_error_msg(str): optional message for precising the error, in case of error
|
|
error_type (Type[Exception]): the type of error to raise, if condition is not fulfilled.
|
|
Default to AssertionError
|
|
|
|
Raises:
|
|
error_type: Raises an error if condition is False
|
|
|
|
"""
|
|
|
|
if not condition:
|
|
raise error_type(on_error_msg)
|
|
|
|
|
|
def assert_true(
|
|
condition: bool, on_error_msg: str = "", error_type: Type[Exception] = AssertionError
|
|
):
|
|
"""Provide a custom assert to check that the condition is True.
|
|
|
|
Args:
|
|
condition(bool): the condition. If False, raise AssertionError
|
|
on_error_msg(str): optional message for precising the error, in case of error
|
|
error_type (Type[Exception]): the type of error to raise, if condition is not fulfilled.
|
|
Default to AssertionError
|
|
|
|
"""
|
|
_custom_assert(condition, on_error_msg, error_type)
|
|
|
|
|
|
def assert_false(
|
|
condition: bool, on_error_msg: str = "", error_type: Type[Exception] = AssertionError
|
|
):
|
|
"""Provide a custom assert to check that the condition is False.
|
|
|
|
Args:
|
|
condition(bool): the condition. If True, raise AssertionError
|
|
on_error_msg(str): optional message for precising the error, in case of error
|
|
error_type (Type[Exception]): the type of error to raise, if condition is not fulfilled.
|
|
Default to AssertionError
|
|
|
|
"""
|
|
_custom_assert(not condition, on_error_msg, error_type)
|
|
|
|
|
|
def assert_not_reached(on_error_msg: str, error_type: Type[Exception] = AssertionError):
|
|
"""Provide a custom assert to check that a piece of code is never reached.
|
|
|
|
Args:
|
|
on_error_msg(str): message for precising the error
|
|
error_type (Type[Exception]): the type of error to raise, if condition is not fulfilled.
|
|
Default to AssertionError
|
|
|
|
"""
|
|
_custom_assert(False, on_error_msg, error_type)
|