2023-04-12 18:31:58 +00:00
|
|
|
import numpy as np
|
|
|
|
|
2023-04-09 19:21:45 +00:00
|
|
|
from keras_core import testing
|
|
|
|
from keras_core.engine import keras_tensor
|
2023-04-09 19:35:32 +00:00
|
|
|
from keras_core.layers.layer import Layer
|
2023-04-09 19:21:45 +00:00
|
|
|
|
|
|
|
|
|
|
|
class FunctionTest(testing.TestCase):
|
|
|
|
def test_positional_arg_error(self):
|
|
|
|
class SomeLayer(Layer):
|
|
|
|
def call(self, x, bool_arg):
|
|
|
|
if bool_arg:
|
|
|
|
return x
|
|
|
|
return x + 1
|
|
|
|
|
|
|
|
x = keras_tensor.KerasTensor(shape=(2, 3), name="x")
|
2023-04-12 18:00:14 +00:00
|
|
|
with self.assertRaisesRegex(
|
|
|
|
ValueError, "Only input tensors may be passed as"
|
|
|
|
):
|
2023-04-09 19:21:45 +00:00
|
|
|
SomeLayer()(x, True)
|
|
|
|
|
|
|
|
# This works
|
|
|
|
SomeLayer()(x, bool_arg=True)
|