You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently test_indexes save all test cases using hard encoding, by listing all functions and their valid inputs separately, where lots of functions share the same input. With HeroSeries objects as inputs, it seems easy infer a valid input for each of them.
For example, save a allowed_hero_series_type variable for each function,
Then iterate all functions through dir(hero) and generate test cases,
# Define the valid inputs for each HeroSeries type
valid_inputs = {
"TokenSeries": s_tokenized_lists,
"TextSeries": s_text,
"VectorSeries": s_numeric_lists
}
test_cases = []
# Find all functions under texthero
func_strs = [s for s in dir(hero) if not s.startswith("__") and s not in {'preprocessing', 'visualization', 'representation', 'nlp', 'stopwords'}]
# Exceptions for test cases in case they need specific inputs
test_case_exceptions = {
"pca": ["pca", representation.pca, (s_numeric_lists, 0)]
}
for func_str in func_strs:
if func_str in test_case_exceptions:
test_cases.append(test_case_exceptions[func_str])
else:
func = getattr(hero, func_str)
if hasattr(func, 'allowed_hero_series_type'):
if func.allowed_hero_series_type.__name__ in valid_inputs:
test_cases.append([func_str, func, (valid_inputs[func.allowed_hero_series_type.__name__],)])
Will it make the code cleaner and easier to maintain?
The text was updated successfully, but these errors were encountered:
Hey @AlfredWGA, I agree with you and it seems a good idea!
The only part that might be tricky is that for some functions we need to pass more than one parameter (see for instance pca in test_indexes).
By the way, we should also test that all functions work when the given Series input is empty and also when it contains nan values. I believe we can unify all these three tests ...
The only part that might be tricky is that for some functions we need to pass more than one parameter (see for instance pca in test_indexes).
That can be done by manually adding test cases like
# Exceptions for test cases in case they need specific inputs
test_case_exceptions = {
"pca": ["pca", representation.pca, (s_numeric_lists, 0)]
}
And adding empty and nan Series test shouldn't be a problem, I'll work on that. Through this we can keep only one test_indexes.py as mentioned in #128.
Currently
test_indexes
save all test cases using hard encoding, by listing all functions and their valid inputs separately, where lots of functions share the same input. With HeroSeries objects as inputs, it seems easy infer a valid input for each of them.For example, save a
allowed_hero_series_type
variable for each function,Then iterate all functions through
dir(hero)
and generate test cases,Will it make the code cleaner and easier to maintain?
The text was updated successfully, but these errors were encountered: