__init__() got an unexpected keyword argument 'bounds'
时间: 2023-09-30 21:05:35 浏览: 67
This error occurs when the `bounds` argument is used in the `__init__()` method of a class that doesn't accept it. The `bounds` argument is typically used in optimization functions to specify constraints on the variables being optimized.
To fix this error, you can either remove the `bounds` argument from the `__init__()` method or modify the class to accept the `bounds` argument. For example:
```
class MyClass:
def __init__(self, arg1, arg2):
# do something with arg1 and arg2
pass
# If you try to create an instance of MyClass with bounds parameter
obj = MyClass(arg1=1, arg2=2, bounds=[0, 1])
# You will get the error: __init__() got an unexpected keyword argument 'bounds'
# To fix this error, you can modify the class to accept the bounds parameter:
class MyClass:
def __init__(self, arg1, arg2, bounds=None):
# do something with arg1 and arg2
self.bounds = bounds
# Now you can create an instance of MyClass with bounds parameter
obj = MyClass(arg1=1, arg2=2, bounds=[0, 1])
# This will work without any errors
```
阅读全文