Open giovannipizzi opened 4 years ago
@dou-du I suggest that we start working with PRs so I can give feedback before it's merged?
@dou-du I suggest that we start working with PRs so I can give feedback before it's merged?
Sure, I will work on the develop branch.
Hi Giovanni @giovannipizzi ,
This issue is quite problematic to fix. First, I was struggling with a Traitlets bug:
For example, self.selected_elements[1] = "H" will not trigger the Javascript function. This is a traitlets bug. Other people also notice this.
For the selected_states and selected_elements, I try to consider all the possible cases:
if we give more states than elements, it will truncate the same length of the selected elements.
When we init the elements through w.selected_elements:
1 if the element had been selected before, it will keep intact.
2 if the element is not selected before, it will be set as state zero.
I also update the binder docs. Please check my pull request #13
There are more bugs. Forget about the pull request. I think it is very problematic to have two separate variable (selected_elements, selected_states). I will use a dictionary instead.
Here a few minor changes that I would do:
noselect_color
->unselected_color
to be consistent withselected_colors
state
is very large. Something like(I didn't test it, maybe double check)
noselcted
withunselected
)on_set_from_ptyhon
[x] selecting from python seems buggy:
widget.selected_elements = ['Li', 'H']
, they get selected but with different state. How do I chose the state?Li
to change its state, they jump back (at least it happened to me once, I cannot reproduce). Definitely one thing I can reproduce is that if I select with different states some other elements, say 'Si' and 'Ge', and then I callwidget.selected_elements = ['Li', 'H']
, when I click onSi
andGe
(now unselected) they don't start from state 0, but from some other state.widget.selected_elements
is['Li', 'H', 'B', 'Al', 'Ga', 'In']
andwidget.selected_states
is[0, 1, 2, 0, 0, 0, 0]
, a call towidget.get_elements_by_state(0)
crashes with/srv/conda/envs/notebook/lib/python3.7/site-packages/widget_periodictable/periodic_table.py in get_elements_by_state(self, state) 46 for i, j in enumerate(self.selected_states): 47 if j == state: ---> 48 x.append(self.selected_elements[i]) 49 return x
IndexError: list index out of range