Skip to content

Commit

Permalink
Merge pull request #226 from wpfff/fix/invaliddata
Browse files Browse the repository at this point in the history
Fix/invaliddata
  • Loading branch information
wpfff committed Sep 15, 2021
2 parents 855ee5f + 7ed446a commit e9e53fa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
13 changes: 10 additions & 3 deletions plottr/apps/autoplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,16 @@ def setDefaults(self, data: DataDictBase) -> None:
if len(axes) == 1:
drs = {axes[0]: 'x-axis'}

self.fc.nodes()['Data selection'].selectedData = selected
self.fc.nodes()['Grid'].grid = GridOption.guessShape, {}
self.fc.nodes()['Dimension assignment'].dimensionRoles = drs
try:
self.fc.nodes()['Data selection'].selectedData = selected
self.fc.nodes()['Grid'].grid = GridOption.guessShape, {}
self.fc.nodes()['Dimension assignment'].dimensionRoles = drs
# FIXME: this is maybe a bit excessive, but trying to set all the defaults
# like this can result in many types of errors.
# a better approach would be to inspect the data better and make sure
# we can set defaults reliably.
except:
pass
unwrap_optional(self.plotWidget).update()


Expand Down
5 changes: 2 additions & 3 deletions plottr/data/datadict.py
Original file line number Diff line number Diff line change
Expand Up @@ -988,11 +988,10 @@ def remove_invalid_entries(self) -> 'DataDict':
except TypeError:
pass

idxs.append(_idxs)
idxs.append(_idxs.astype(int))

if len(idxs) > 0:
remove_idxs = reduce(np.intersect1d,
tuple(np.array(idxs).astype(int)))
remove_idxs = reduce(np.intersect1d, tuple(idxs))
for k, v in ret.data_items():
v['values'] = np.delete(v['values'], remove_idxs, axis=0)

Expand Down
23 changes: 17 additions & 6 deletions plottr/node/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,28 @@ def process(self, dataIn: Optional[DataDictBase]=None) -> Optional[Dict[str, Opt
_structChanged = False
_shapesChanged = False

if daxes != self.dataAxes:
if self.dataAxes is None and daxes is not None:
_fieldsChanged = True
_structChanged = True
_axesChanged = True

if daxes != self.dataAxes or ddeps != self.dataDependents:
elif self.dataAxes is not None and daxes is None:
assert daxes is not None and self.dataAxes is not None
if set(daxes) != set(self.dataAxes):
_axesChanged = True
_fieldsChanged = True
_structChanged = True

if self.dataDependents is None and ddeps is not None:
_fieldsChanged = True
_structChanged = True
else:
assert ddeps is not None and self.dataDependents is not None
if set(ddeps) != set(self.dataDependents):
_fieldsChanged = True
_structChanged = True

if dtype != self.dataType:
_typeChanged = True

if dtype != self.dataType or daxes != self.dataAxes \
or ddeps != self.dataDependents:
_structChanged = True

if dshapes != self.dataShapes:
Expand Down

0 comments on commit e9e53fa

Please sign in to comment.