Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/ampform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/expression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/tensorwaves/function/_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tensorwaves/function/sympy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/data/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions tests/function/test_ampform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand All @@ -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
Expand Down
12 changes: 8 additions & 4 deletions tests/function/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
8 changes: 4 additions & 4 deletions tests/function/test_sympy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion tests/optimizer/test_fit_simple_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion tests/test_estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading