diff --git a/benchmarks/ampform.py b/benchmarks/ampform.py index f129a137..6392c2bc 100644 --- a/benchmarks/ampform.py +++ b/benchmarks/ampform.py @@ -162,7 +162,7 @@ class TestJPsiToGammaPiPi: } @pytest.mark.benchmark(group="data", min_rounds=1) - @pytest.mark.parametrize("backend", ["jax", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "numpy", "tensorflow"]) @pytest.mark.parametrize("size", [10_000]) def test_data(self, backend, benchmark, model, size): n_data = size diff --git a/benchmarks/expression.py b/benchmarks/expression.py index 796b9c9a..5e1b9b30 100644 --- a/benchmarks/expression.py +++ b/benchmarks/expression.py @@ -100,7 +100,7 @@ def generate_data_and_domain( @pytest.mark.benchmark(group="data-simple") -@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tf"]) +@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tensorflow"]) @pytest.mark.parametrize("size", [3_000]) def test_data(backend, benchmark, size): domain, data = benchmark( @@ -111,7 +111,7 @@ def test_data(backend, benchmark, size): @pytest.mark.benchmark(group="fit-simple") -@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tf"]) +@pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tensorflow"]) @pytest.mark.parametrize("optimizer_type", [Minuit2, ScipyMinimizer]) @pytest.mark.parametrize("size", [1_000]) def test_fit( diff --git a/src/tensorwaves/function/_backend.py b/src/tensorwaves/function/_backend.py index ce71604f..c1d59143 100644 --- a/src/tensorwaves/function/_backend.py +++ b/src/tensorwaves/function/_backend.py @@ -52,7 +52,7 @@ def get_backend_modules(backend: str | tuple | dict) -> str | tuple | dict: return np, np.__dict__ # returning only np.__dict__ does not work well with conditionals - if backend in {"tensorflow", "tf"}: + if backend == "tensorflow": try: tf = _initialize_tensorflow() tnp = tf.experimental.numpy diff --git a/src/tensorwaves/function/sympy/__init__.py b/src/tensorwaves/function/sympy/__init__.py index daed4026..8fa51958 100644 --- a/src/tensorwaves/function/sympy/__init__.py +++ b/src/tensorwaves/function/sympy/__init__.py @@ -284,7 +284,7 @@ def tensorflow_lambdify() -> Callable: return jit_compile(jax_lambdify()) if backend == "numba": return jit_compile(numba_lambdify()) - if backend in {"tensorflow", "tf"}: + if backend == "tensorflow": return jit_compile(tensorflow_lambdify()) if isinstance(backend, tuple): diff --git a/tests/conftest.py b/tests/conftest.py index 73850b4e..333196a1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ if TYPE_CHECKING: from qrules import ParticleCollection -_TENSORFLOW_PARAMETERS = {"tf", "tensorflow", "TFUniformRealNumberGenerator"} +_TENSORFLOW_PARAMETERS = {"tensorflow", "TFUniformRealNumberGenerator"} def pytest_collection_modifyitems(items: list[pytest.Item]) -> None: diff --git a/tests/data/test_transform.py b/tests/data/test_transform.py index 46541e6a..52f992f6 100644 --- a/tests/data/test_transform.py +++ b/tests/data/test_transform.py @@ -59,7 +59,7 @@ def it_returns_the_same_sample_object(): def describe_SympyDataTransformer(): - @pytest.mark.parametrize("backend", ["jax", "numba", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "numba", "numpy", "tensorflow"]) def it_converts_polar_to_cartesian_coordinates(backend): r, phi, x, y = sp.symbols("r phi x y") expressions = { diff --git a/tests/function/test_ampform.py b/tests/function/test_ampform.py index 2e61c0db..106056b9 100644 --- a/tests/function/test_ampform.py +++ b/tests/function/test_ampform.py @@ -7,7 +7,7 @@ def describe_ComplexSqrt(): - @pytest.mark.parametrize("backend", ["jax", "math", "numba", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "math", "numba", "numpy", "tensorflow"]) def it_evaluates_like_the_numpy_complex_square_root(backend: str): import sympy as sp from ampform.sympy.math import ComplexSqrt @@ -23,7 +23,7 @@ def it_evaluates_like_the_numpy_complex_square_root(backend: str): else: linspace = find_function("linspace", backend) kwargs = {} - if backend == "tf": + if backend == "tensorflow": kwargs["dtype"] = find_function("complex64", backend) values = linspace(-4, +4, 9, **kwargs) data = {"x": values} @@ -32,7 +32,7 @@ def it_evaluates_like_the_numpy_complex_square_root(backend: str): def describe_SympyDataTransformer(): - @pytest.mark.parametrize("backend", ["jax", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "numpy", "tensorflow"]) def it_converts_four_momenta_to_helicity_angles(backend): import ampform import qrules diff --git a/tests/function/test_backend.py b/tests/function/test_backend.py index a94c22d3..a3a9c0fe 100644 --- a/tests/function/test_backend.py +++ b/tests/function/test_backend.py @@ -29,7 +29,11 @@ def it_finds_tensorflow_functions(): import tensorflow as tf import tensorflow.experimental.numpy as tnp # ty:ignore[import-not-found] - assert find_function("array", backend="tf") is tnp.array - assert find_function("linspace", backend="tf") is tnp.linspace - assert find_function("mean", backend="tf") is tnp.mean - assert find_function("Tensor", backend="tf") is tf.Tensor + assert find_function("array", backend="tensorflow") is tnp.array + assert find_function("linspace", backend="tensorflow") is tnp.linspace + assert find_function("mean", backend="tensorflow") is tnp.mean + assert find_function("Tensor", backend="tensorflow") is tf.Tensor + + def it_rejects_the_removed_tensorflow_alias(): + with pytest.raises(ValueError, match='Could not find function "array"'): + find_function("array", backend="tf") diff --git a/tests/function/test_sympy.py b/tests/function/test_sympy.py index f574b42d..96ccf37b 100644 --- a/tests/function/test_sympy.py +++ b/tests/function/test_sympy.py @@ -48,21 +48,21 @@ def it_collects_the_sub_expressions_without_free_symbols(free_symbols, expected) def describe_create_function(): - @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tensorflow"]) def it_orders_the_arguments_as_the_symbols_appear(backend: str): expression = create_expression(a, x, y, z) function = create_function(expression, backend) assert callable(function.function) assert function.argument_order == ("a", "x", "y", "z") - @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tensorflow"]) def it_names_indexed_symbols_by_their_index(backend: str): a = sp.IndexedBase("A") expr = a[0] ** 2 + a[1] ** 2 func = create_function(expr, backend=backend) assert func.argument_order == ("A[0]", "A[1]") - @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tensorflow"]) def it_names_matrix_symbols_by_their_element(backend: str): M = sp.MatrixSymbol("M", 2, 2) # ruff:ignore[non-lowercase-variable-in-function] expr = M[0, 0] ** 2 + M[1, 1] ** 2 @@ -107,7 +107,7 @@ def it_warns_about_free_symbols_that_do_not_appear(caplog: LogCaptureFixture): def describe_fast_lambdify(): - @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "math", "numpy", "tensorflow"]) @pytest.mark.parametrize("max_complexity", [0, 1, 2, 3, 4, 5]) @pytest.mark.parametrize("use_cse", [False, True]) @pytest.mark.parametrize("use_jit", [False, True, None]) diff --git a/tests/optimizer/test_fit_simple_model.py b/tests/optimizer/test_fit_simple_model.py index afb576fd..49fe63ee 100644 --- a/tests/optimizer/test_fit_simple_model.py +++ b/tests/optimizer/test_fit_simple_model.py @@ -114,7 +114,7 @@ def domain_and_data_sample( def describe_optimize(): @pytest.mark.parametrize("optimizer_type", [Minuit2, ScipyMinimizer]) - @pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tf"]) + @pytest.mark.parametrize("backend", ["jax", "numpy", "numba", "tensorflow"]) def it_recovers_the_parameters_that_generated_the_data( backend: str, domain_and_data_sample: tuple[DataSample, DataSample], diff --git a/tests/test_estimator.py b/tests/test_estimator.py index ffa782f8..aca85617 100644 --- a/tests/test_estimator.py +++ b/tests/test_estimator.py @@ -108,7 +108,7 @@ def it_scales_the_residuals_with_the_weights(backend: str, linear_function): def describe_create_cached_function(): - @pytest.fixture(params=["jax", "numba", "numpy", "tf"], scope="module") + @pytest.fixture(params=["jax", "numba", "numpy", "tensorflow"], scope="module") def backend(request) -> str: return request.param