reuse dict for checking subset
This commit is contained in:
parent
b0055d59da
commit
91c45fe176
3 changed files with 10 additions and 7 deletions
|
|
@ -398,8 +398,8 @@ class Script:
|
|||
|
||||
# Otherwise, if it has dependencies that are all resolved, then
|
||||
# resolve the definition
|
||||
elif not definition.is_subset_of(
|
||||
variables=resolved.keys(), custom_function_definitions=self._functions
|
||||
elif definition.is_subset_of(
|
||||
variables=resolved, custom_function_definitions=self._functions
|
||||
):
|
||||
resolved[variable] = unresolved[variable].resolve(
|
||||
resolved_variables=resolved,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import copy
|
||||
import functools
|
||||
from abc import ABC
|
||||
from dataclasses import dataclass
|
||||
|
|
@ -81,6 +80,10 @@ class CustomFunction(Function, NamedCustomFunction):
|
|||
|
||||
return out
|
||||
|
||||
# Implies the custom function does not exist. This should have
|
||||
# been checked in the parser with
|
||||
raise UNREACHABLE
|
||||
|
||||
|
||||
class BuiltInFunction(Function, BuiltInFunctionType):
|
||||
def validate_args(self) -> "BuiltInFunction":
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ class VariableDependency(ABC):
|
|||
@final
|
||||
def is_subset_of(
|
||||
self,
|
||||
variables: Iterable[Variable],
|
||||
variables: Dict[Variable, Resolvable],
|
||||
custom_function_definitions: Dict[str, "VariableDependency"],
|
||||
) -> bool:
|
||||
"""
|
||||
|
|
@ -171,12 +171,12 @@ class VariableDependency(ABC):
|
|||
True if it contains all input variables as a dependency. False otherwise.
|
||||
"""
|
||||
for custom_function in self.custom_functions:
|
||||
if custom_function_definitions[custom_function.name].is_subset_of(
|
||||
if not custom_function_definitions[custom_function.name].is_subset_of(
|
||||
variables=variables, custom_function_definitions=custom_function_definitions
|
||||
):
|
||||
return True
|
||||
return False
|
||||
|
||||
return not self.variables.issubset(variables)
|
||||
return all(var in variables for var in self.variables)
|
||||
|
||||
@final
|
||||
def contains(
|
||||
|
|
|
|||
Loading…
Reference in a new issue