fixing test_inputs.py

This commit is contained in:
Abubakar Abid 2022-03-18 17:08:24 -07:00
parent 408f743ba8
commit 6bcbde43d7
3 changed files with 6 additions and 7 deletions

View File

@ -384,9 +384,8 @@ class Number(Component):
default (float): default value. default (float): default value.
label (str): component name in interface. label (str): component name in interface.
""" """
default = float(default) self.default = float(default) if default is not None else None
self.default = default self.test_input = self.default if self.default is not None else 1
self.test_input = default if default is not None else 1
self.interpret_by_tokens = False self.interpret_by_tokens = False
super().__init__(label=label, **kwargs) super().__init__(label=label, **kwargs)

View File

@ -3,7 +3,7 @@ import math
import numpy as np import numpy as np
from gradio.components import Label, Textbox from gradio.components import Label, Textbox, Number
def run_interpret(interface, raw_input): def run_interpret(interface, raw_input):
@ -198,7 +198,7 @@ def quantify_difference_in_label(interface, original_output, perturbed_output):
score = diff(original_label, perturbed_label) score = diff(original_label, perturbed_label)
return score return score
elif isinstance(output_component, Textbox): elif isinstance(output_component, (Textbox, Number)):
score = diff(post_original_output, post_perturbed_output) score = diff(post_original_output, post_perturbed_output)
return score return score

View File

@ -771,9 +771,9 @@ class TestTimeseries(unittest.TestCase):
class TestNames(unittest.TestCase): class TestNames(unittest.TestCase):
# this ensures that `inputs.get_input_instance()` works correctly when instantiating from components # this ensures that `components.get_component_instance()` works correctly when instantiating from components
def test_no_duplicate_uncased_names(self): def test_no_duplicate_uncased_names(self):
subclasses = gr.inputs.InputComponent.__subclasses__() subclasses = gr.components.Component.__subclasses__()
unique_subclasses_uncased = set([s.__name__.lower() for s in subclasses]) unique_subclasses_uncased = set([s.__name__.lower() for s in subclasses])
self.assertEqual(len(subclasses), len(unique_subclasses_uncased)) self.assertEqual(len(subclasses), len(unique_subclasses_uncased))