Ejemplo n.º 1
0
 def __setitem__(self, key, item):
     if key is None:
         return
     if isinstance(key, str):
         key = ep.get_atomic_number(key)
     if key < 1:
         raise ValueError('Atomic number cannot be less than hydrogen')
     if key > 118:
         raise ValueError('Atomic number cannot be greater than Uuo')
     self._data[np.uint8(key)] = convert_value(item)
Ejemplo n.º 2
0
    def setSelection(self, selection):
        def _uncheckedAll():
            for widget in self._group.buttons():
                widget.setChecked(False)

        if selection is None:
            _uncheckedAll()
            self.selectionChanged.emit()
            return

        if isinstance(selection, (int, six.string_types)):
            selection = [selection]

        if not self.isMultipleSelection() and len(selection) > 1:
            raise ValueError('Multiple selection mode is off. Cannot select more than one element')

        _uncheckedAll()

        for z in selection:
            if isinstance(z, six.string_types):
                z = get_atomic_number(z)
            self._group.button(z).setChecked(True)

        self.selectionChanged.emit()
 def testatomic_number(self):
     self.assertEqual(1, get_atomic_number('H'))
     self.assertEqual(118, get_atomic_number('Uuo'))
Ejemplo n.º 4
0
 def __delitem__(self, key):
     if isinstance(key, str):
         key = ep.get_atomic_number(key)
     del self._data[key]
Ejemplo n.º 5
0
 def __getitem__(self, key):
     if isinstance(key, str):
         key = ep.get_atomic_number(key)
     return self._data[key]
Ejemplo n.º 6
0
 def atomicNumber(self):
     symbol = self.text()
     if symbol == str(None):
         return None
     return get_atomic_number(symbol)
Ejemplo n.º 7
0
 def set_symbol(self, symbol):
     self.atomic_number = get_atomic_number(symbol)