Skip to content

Commit

Permalink
Display input for view and view collection in __repr__ even when data…
Browse files Browse the repository at this point in the history
… not yet loaded (#19)

* change View repr to show specLst if no data
  • Loading branch information
westernguy2 committed Jun 25, 2020
1 parent e1663f6 commit 3e631e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/DatetimeDemo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -622,4 +622,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}
4 changes: 3 additions & 1 deletion lux/view/View.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def __init__(self, specLst, mark="", title=""):
self.xMinMax = {}
self.yMinMax = {}
def __repr__(self):
if not self.data:
return f"<View ({str(self.specLst)}) mark: {self.mark}, score: {self.score} >"
filter_spec = None
channels, additional_channels = [], []
for spec in self.specLst:
Expand All @@ -39,7 +41,7 @@ def __repr__(self):
channels.insert(1, [spec.channel, attribute])
elif spec.channel != "":
additional_channels.append([spec.channel, attribute])

channels.extend(additional_channels)
str_channels = ""
for channel in channels:
Expand Down
4 changes: 3 additions & 1 deletion lux/view/ViewCollection.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __setitem__(self, key, value):
def __len__(self):
return len(self.collection)
def __repr__(self):
if len(self.collection) == 0:
return str(self.inputLst)
x_channel = ""
y_channel = ""
largest_mark = 0
Expand Down Expand Up @@ -230,4 +232,4 @@ def load(self, ldf) -> ViewCollection:
PandasExecutor.execute(vc,ldf)
return vc
else:
return self
return self

0 comments on commit 3e631e2

Please sign in to comment.