Skip to content

Commit

Permalink
test_compiler bugfix for new ViewCollection implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
dorisjlee committed Jun 10, 2020
1 parent ef67512 commit 46b2467
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 9 additions & 6 deletions lux/view/ViewCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ class ViewCollection():
'''
def __init__(self,inputLst:Union[List[View],List[Spec]]):
# Overloaded Constructor
if (type(inputLst[0])==View):
self.collection = inputLst
self.inputType = "View"
elif (type(inputLst[0])==Spec):
self.specLst = inputLst
if len(inputLst)>0:
if (type(inputLst[0])==View):
self.collection = inputLst
self.inputType = "View"
elif (type(inputLst[0])==Spec):
self.specLst = inputLst
self.collection = []
self.inputType = "Spec"
else:
self.collection = []
self.inputType = "Spec"
def __getitem__(self, key):
return self.collection[key]
def __setitem__(self, key, value):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,14 @@ def test_populateOptions():
df = pd.read_csv("lux/data/cars.csv")
df.setContext([lux.Spec(attribute="?"), lux.Spec(attribute="MilesPerGal")])
colSet = set()
for specOptions in Compiler.populateWildcardOptions(df)["attributes"]:
for specOptions in Compiler.populateWildcardOptions(df.context,df)["attributes"]:
for spec in specOptions:
colSet.add(spec.attribute)
assert listEqual(list(colSet), list(df.columns))

df.setContext([lux.Spec(attribute="?",dataModel="measure"), lux.Spec(attribute="MilesPerGal")])
colSet = set()
for specOptions in Compiler.populateWildcardOptions(df)["attributes"]:
for specOptions in Compiler.populateWildcardOptions(df.context,df)["attributes"]:
for spec in specOptions:
colSet.add(spec.attribute)
assert listEqual(list(colSet), ['Acceleration', 'Weight', 'Horsepower', 'MilesPerGal', 'Displacement'])
Expand Down

0 comments on commit 46b2467

Please sign in to comment.