Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some issues with make_dirty #15

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions sage_widget_adapters/generic_grid_view_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,22 @@ def make_dirty(self, l, dirty={}):
[[1, 2, 5, 6], [3, 7, 42], [4]]
sage: ga.make_dirty(t.to_list(), {(2,0):0})
[[1, 2, 5, 6], [3, 7]]
sage: ga.make_dirty(t.to_list(), {(0,2):0, (0,3):0})
[[1, 2], [3, 7], [4]]
"""
for p in dirty:
if p[0] < len(l):
if p[1] < len(l[p[0]]):
if dirty[p] == self.cellzero:
del l[p[0]][p[1]]
else:
l[p[0]][p[1]] = dirty[p]
elif len(l[p[0]]) == p[1] and dirty[p] != self.cellzero:
l[p[0]][p[1]] = dirty[p]
elif len(l[p[0]]) <= p[1] and dirty[p] != self.cellzero:
# padding with cellzero
l[p[0]] += [self.cellzero] * (p[1] - len(l[p[0]]))
l[p[0]].append(dirty[p])
else:
for i in range(p[0] - len(l)):
l.append([])
l.append([dirty[p]])
l.append([cellzero] * p[1] + [dirty[p]])
l = [[ val for val in row if val != self.cellzero ] for row in l]
return [val for val in l if val]

def set_cell(self, obj, pos, val, dirty={}, constructorname=''):
Expand All @@ -235,6 +237,7 @@ def set_cell(self, obj, pos, val, dirty={}, constructorname=''):
sage: from sage.combinat.tableau import Tableau
sage: t = Tableau([[1, 2, 5, 6], [3, 7], [4]])
sage: ga = GridViewAdapter()
sage: ga.cellzero = None
sage: ga.set_cell(t, (1,1), 8, constructorname='Tableau')
[[1, 2, 5, 6], [3, 8], [4]]
sage: from sage.matrix.constructor import Matrix, matrix
Expand Down