Skip to content

Commit

Permalink
update 'generate_legacy_interface' to deal with change of conversions…
Browse files Browse the repository at this point in the history
… of argument value
  • Loading branch information
jihobak committed Mar 10, 2017
1 parent c6c9373 commit 0744a25
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion keras/legacy/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@


def generate_legacy_interface(allowed_positional_args=None,
conversions=None):
conversions=None,
value_conversions=None):
allowed_positional_args = allowed_positional_args or []
conversions = conversions or []
value_conversions = value_conversions or []

def legacy_support(func):
@six.wraps(func)
Expand All @@ -23,6 +25,11 @@ def wrapper(*args, **kwargs):
'you passed the following '
'positional arguments: ' +
str(args[1:]))
for key in list(value_conversions.keys()):
if key in kwargs:
for old_value, new_value in value_conversions[key]:
if kwargs[key] == old_value:
kwargs[key] = new_value
for old_name, new_name in conversions:
if old_name in kwargs:
value = kwargs.pop(old_name)
Expand Down

0 comments on commit 0744a25

Please sign in to comment.