Пример #1
0
class ProficiencyEditModal(Component):
    """Definition of proficiency edit modal component."""

    name = Element(id_='proficiencyEditNameInput')
    type_ = Element(id_='proficiencyEditTypeInput')
    description = Element(id_='proficiencyEditDescriptionTextarea')
    done = Element(id_='proficiencyEditDoneButton')
Пример #2
0
class Background(Component):
    """Definition of background componenet."""

    traits = Element(id_='backgroundTraitsTextarea')
    ideals = Element(id_='backgroundIdealsTextarea')
    bonds = Element(id_='backgroundBondsTextarea')
    flaws = Element(id_='backgroundFlawsTextarea')
Пример #3
0
class SavingThrowEditModal(Component):
    """Definition of Saving Throw edit modal component."""

    name = Element(id_='savingThrowEditNameInput')
    modifier = Element(id_='savingThrowEditModifierButton')
    proficiency = Element(id_='savingThrowEditProficiencyCheckbox')
    done = Element(id_='savingThrowEditDoneButton')
Пример #4
0
def get_element(randomize=False,
                isotope_p=0.5,
                amount_p=0.5,
                symbol="He",
                **kwargs) -> Element:
    """Returns either a random Element or a Helium element.

    Args:
        randomize: whether a random Element is returned
        isotope_p: the likelihood of the random Element having an isotope
        amount_p: likelihood that the Element is provided a random amount
            argument.
        symbol: element's symbol as a string for a non-randomized element
        kwargs: keyword arguments passed down to non-randomized element

    Return:
        Element object.
    """
    if randomize:
        symbol = random.choice(list(masses._ISOTOPES.keys()))
        if random.random() < isotope_p:
            isotope = random.choice(
                masses.get_isotopes(symbol, filter_unlikely=False))["number"]
        else:
            isotope = None

        if random.random() < amount_p:
            amount = random.uniform(0, 100)
        else:
            amount = 0

        return Element(symbol, isotope=isotope, amount=amount)

    return Element(symbol, **kwargs)
Пример #5
0
class ProficiencyAddModal(Component):
    """Definition of proficiency add modal component."""

    name = Element(id_='proficiencyAddNameInput')
    type_ = Element(id_='proficiencyAddTypeInput')
    description = Element(id_='proficiencyAddDescriptionTextarea')
    add = Element(id_='proficiencyAddAddButton')
Пример #6
0
    def setUpClass(cls):
        cls.directory = Path(tempfile.gettempdir())
        target = Target(layers=[
            Layer("layer1", [
                Element.from_string("Li 1.0")
            ], 0.01, 0.01, start_depth=0.0),
            Layer("layer2", [
                Element.from_string("Li 0.048"),
                Element.from_string("O 0.649"),
                Element.from_string("Mn 0.303")
            ], 90.0, 4.0, start_depth=0.01),
            Layer("subtrate", [
                Element.from_string("Si 1.0")
            ], 1000.0, 2.32, start_depth=90.01)
        ])
        cls.mcerd = MCERD(101, {
            "recoil_element": mo.get_recoil_element(),
            "sim_dir": tempfile.gettempdir(),
            "simulation_type": SimulationType.ERD,
            "target": target,
            "detector": mo.get_detector(),
            "beam": mo.get_beam(),

            # Following simulation parameters have been determined by the
            # rigorous application of the Stetson-Harrison method.
            "minimum_scattering_angle": 5.5,
            "minimum_main_scattering_angle": 6.5,
            "minimum_energy_of_ions": 8.15,
            "number_of_recoils": 15,
            "simulation_mode": SimulationMode.NARROW,
            "number_of_scaling_ions": 14,
            "number_of_ions_in_presimu": 100,
            "number_of_ions": 1000
        }, mo.get_element_simulation().get_full_name())
Пример #7
0
class SpellSlotsEditModal(Component):
    """Definition of Spell Slots Edit component."""
    level = Element(id_='spellSlotsEditModalLevelInput')
    max_ = Element(id_='spellSlotsEditModalMaxInput')
    short_rest = Element(id_='spellSlotsEditModalShortRestButton')
    long_rest = Element(id_='spellSlotsEditModalLongRestButton')
    done = Element(id_='spellSlotsEditModalDoneButton')
Пример #8
0
    def test_initialization(self):
        """Tests the initialization of a DepthProfile object"""
        dp = DepthProfile([1], [2])
        self.assertEqual((1, ), dp.depths)
        self.assertEqual((2, ), dp.concentrations)
        self.assertIsNone(dp.events)
        self.assertEqual("total", dp.get_profile_name())

        # Currently the order of depth counts, or validity of
        # numerical values is not checked so following is ok.
        dp = DepthProfile([2, 1], [True, "Foo"])
        self.assertEqual((2, 1), dp.depths)
        self.assertEqual((True, "Foo"), dp.concentrations)

        dp = DepthProfile([1], [2], [3], element=Element.from_string("Si"))
        self.assertEqual((1, ), dp.depths)
        self.assertEqual((2, ), dp.concentrations)
        self.assertEqual((3, ), dp.events)
        self.assertEqual("Si", dp.get_profile_name())

        self.assertRaises(ValueError, lambda: DepthProfile([], [], []))
        self.assertRaises(ValueError, lambda: DepthProfile([], [1]))
        self.assertRaises(
            ValueError,
            lambda: DepthProfile([1], [], [1],
                                 element=Element.from_string("Si")))
        self.assertRaises(
            ValueError,
            lambda: DepthProfile([1], [1], [],
                                 element=Element.from_string("Si")))
Пример #9
0
    def test_get_full_name(self):
        self.assertEqual("He-bar", self.rec_elem.get_full_name())

        rec_elem = RecoilElement(Element.from_string("16O"), [], name=None)
        self.assertEqual("16O-Default", rec_elem.get_full_name())

        rec_elem = RecoilElement(Element.from_string("16O"), [], name="")
        self.assertEqual("16O-Default", rec_elem.get_full_name())
Пример #10
0
class Appearance(Component):
    """Definition of appearance componenet."""

    height = Element(id_='appearanceHeightInput')
    weight = Element(id_='appearanceWeightInput')
    hair_color = Element(id_='appearanceHairColorInput')
    eye_color = Element(id_='appearanceEyeColorInput')
    skin_color = Element(id_='appearanceSkinColorInput')
Пример #11
0
 def test_to_dict(self):
     layer = Layer("foo", [Element("He"), Element("C", 4, 2)], 3, 5,
                   start_depth=10)
     self.assertEqual({
         "name": "foo",
         "thickness": 3,
         "density": 5,
         "elements": ["He", "4C 2"],
         "start_depth": 10
     }, layer.to_dict())
Пример #12
0
class HitPointHitDice(Component):
    """Definition of HitPointsHitDice component."""

    max_hit_points = Element(
        xpath=
        '//*[@id="stats"]/div[1]/div[2]/stats/div/div/div/div/table/tbody/tr/td[2]/span'
    )
    hit_points_bar_label = Element(xpath='//*[@id="hitpointsCounter"]')
    damage_up = Element(
        xpath=
        '//*[@id="stats"]/div[1]/div[2]/stats/div/div/div/div/table/tbody/tr/td[3]/plus-minus/div[1]/div/button[1]'
    )
    damage_down = Element(
        xpath=
        '//*[@id="stats"]/div[1]/div[2]/stats/div/div/div/div/table/tbody/tr/td[3]/plus-minus/div[1]/div/button[2]'
    )
    reset = Element(
        xpath=
        '//*[@id="stats"]/div[1]/div[2]/stats/div/div/div/div/table/tbody/tr/td[4]/a'
    )
    hitdice1 = Element(xpath='//*[@id="0"]')
    hitdice2 = Element(xpath='//*[@id="1"]')
    hitdice3 = Element(xpath='//*[@id="2"]')
    open_edit_modal = Element(
        xpath=
        '//*[@id="stats"]/div[1]/div[2]/stats/div/div/div/div/table/tbody/tr/td[1]'
    )
Пример #13
0
class AbilityScoresGeneral(Component):
    """Definition of ability scoreswizard home componenet."""

    manual = Element(
        xpath=
        '//*[@id="content"]/wizard/div/div/div/wizard-ability-score-step/div/div/div[2]/div[1]/div[1]/div/div/label[1]'
    )
    point_buy = Element(
        xpath=
        '//*[@id="content"]/wizard/div/div/div/wizard-ability-score-step/div/div/div[2]/div[1]/div[1]/div/div/label[2]'
    )
Пример #14
0
    def assert_isotopes_match(self, symbol, isotopes, include_st_mass):
        isos = Element.get_isotopes(symbol, include_st_mass=include_st_mass)

        self.assertEqual(len(isotopes), len(isos))

        if include_st_mass and isos:
            self.assertIsNone(isos[0]["abundance"])

        for n, iso in zip(isotopes, isos):
            self.assertEqual(["element", "abundance", "mass"],
                             list(iso.keys()))
            self.assertEqual(Element("H", n), iso["element"])
Пример #15
0
    def test_subtraction(self):
        dp1 = DepthProfile([0, 1], [2, 3], [1, 2], Element.from_string("Si"))
        dp2 = DepthProfile([0, 1], [3, 4], [1, 2], Element.from_string("Si"))

        dp3 = dp2 - dp1
        self.assertEqual((1, 1), dp3.concentrations)
        self.assertEqual((0, 1), dp3.depths)
        self.assertIsNone(dp3.events)
        self.assertIsNone(dp3.element)

        dp3 -= dp3
        self.assertEqual((0, 0), dp3.concentrations)
Пример #16
0
class WeaponTable(Component):
    """Definition of weapons edit modal componenet."""

    add = Element(id_='weaponAddIcon')
    table = Element(id_='weaponTable')
    weapon_header = Element(id_='weaponTableWeaponHeader')
    to_hit_header = Element(id_='weaponTableToHitHeader')
    damage_header = Element(id_='weaponTableDamageHeader')
    damage_type_header = Element(id_='weaponTableDamageTypeHeader')
    range_header = Element(id_='weaponTableRangeHeader')
    property_header = Element(id_='weaponTablePropertyHeader')
    quantity_header = Element(id_='weaponTableQuantityHeader')
    total_weight = Element(id_='weaponTableTotalWeightSpan')
Пример #17
0
class HitPointEditModal(Component):
    """Definition of HitPointsHitDice component."""

    max_hit_points = Element(
        xpath='//*[@id="viewHealth"]/div/div/div[2]/form/div[1]/div/input')
    damage = Element(
        xpath='//*[@id="viewHealth"]/div/div/div[2]/form/div[2]/div/input')
    temp_hit_points = Element(
        xpath='//*[@id="viewHealth"]/div/div/div[2]/form/div[3]/div/input')
    hit_dice_type = Element(
        xpath='//*[@id="viewHealth"]/div/div/div[2]/form/div[4]/div/input')
    done = Element(
        xpath='//*[@id="viewHealth"]/div/div/div[2]/form/div[5]/button')
Пример #18
0
class SpellsPreviewModal(Component):
    """Definition of spells preview modal component."""

    name = Element(id_='spellsPreviewNameLabel')
    spell_summary_label = Element(id_='spellsPreviewSpellSummaryLabelLabel')
    type_ = Element(id_='spellsPreviewTypeLabel')
    damage = Element(id_='spellsPreviewDamageLabel')
    cast_time = Element(id_='spellsPreviewCastTimeLabel')
    range_ = Element(id_='spellsPreviewRangeLabel')
    components = Element(id_='spellsPreviewComponentsLabel')
    duration = Element(id_='spellsPreviewDurationLabel')
    description = Element(id_='spellsPreviewDescriptionLabel')
    done = Element(id_='spellsPreviewDoneButton')
Пример #19
0
    def test_amount_box(self):
        w = IsotopeSelectionWidget(self.elem_btn,
                                   self.isot_box,
                                   amount_input=self.amount_box)

        self.assertEqual(0, self.amount_box.value())

        w.set_element("2H 15.5")
        self.assertEqual(15.5, self.amount_box.value())
        self.assertEqual(Element("H", 2, 15.5), w.get_element())

        self.amount_box.setValue(25.5)
        self.assertEqual(Element("H", 2, 25.5), w.get_element())
Пример #20
0
class MagicItemsEditModal(Component):
    """Definition of magicItems edit modal component."""

    item = Element(id_='magicItemsEditItemInput')
    type_ = Element(id_='magicItemsEditTypeInput')
    rarity = Element(id_='magicItemsEditRarityInput')
    max_charges = Element(id_='magicItemsEditMaxChargesInput')
    charges = Element(id_='magicItemsEditChargesInput')
    weight = Element(id_='magicItemsEditWeightInput')
    requires_attunement = Element(
        id_='magicItemsEditRequiresAttunementCheckbox')
    attuned = Element(id_='magicItemsEditAttunedCheckbox')
    description = Element(id_='magicItemsEditDescriptionTextarea')
    done = Element(id_='magicItemsEditDoneButton')
Пример #21
0
class FeatureEditModal(Component):
    """Definition of feature edit modal component."""

    name = Element(id_='featureEditNameInput')
    class_ = Element(id_='featureEditClassInput')
    level = Element(id_='featureEditLevelInput')
    description = Element(id_='featureEditDescriptionTextarea')
    tracked = Element(id_='featureEditTrackedCheckbox')
    max_ = Element(id_='featureEditMaxInput')
    short_rest = Element(id_='featureEditShortRestInput')
    long_rest = Element(id_='featureEditLongRestInput')
    done = Element(id_='featureEditDoneButton')
Пример #22
0
class SpellsTable(Component):
    """Definition of spells edit modal componet."""

    prepared_header = Element(id_='spellsTablePreparedHeader')
    spell_header = Element(id_='spellsTableSpellHeader')
    level_header = Element(id_='spellsTableLevelHeader')
    type_header = Element(id_='spellsTableTypeHeader')
    damage_header = Element(id_='spellsTableDamageHeader')
    casting_time_header = Element(id_='spellsTableCastingHeader')
    range_header = Element(id_='spellsTableRangeHeader')
    add = Element(id_='spellsAddIcon')
    table = Element(id_='spellsTable')
Пример #23
0
class FeatureAddModal(Component):
    """Definition of feature add modal component."""

    name = Element(id_='featureAddNameInput')
    class_ = Element(id_='featureAddClassInput')
    level = Element(id_='featureAddLevelInput')
    description = Element(id_='featureAddDescriptionTextarea')
    tracked = Element(id_='featureAddTrackedCheckbox')
    max_ = Element(id_='featureAddMaxInput')
    short_rest = Element(id_='featureAddShortRestInput')
    long_rest = Element(id_='featureAddLongRestInput')
    add = Element(id_='featureAddAddButton')
Пример #24
0
    def set_element(self, element: Element):
        """Sets currently selected element.
        """
        if not isinstance(element, Element):
            try:
                element = Element.from_string(element)
            except (ValueError, AttributeError):
                self._isotope_input.clear()
                self.validate()
                self.selection_changed.emit()
                return

        show_st_mass_in_combobox = self._st_mass_input is None

        self._symbol_input.setText(element.symbol)
        gutils.load_isotopes(element.symbol,
                             self._isotope_input,
                             show_std_mass=show_st_mass_in_combobox,
                             current_isotope=element.isotope)

        if self._amount_input is not None and element.amount:
            self._amount_input.setValue(element.amount)

        self.validate()
        self.selection_changed.emit()
Пример #25
0
def load_isotopes(symbol: str,
                  combobox: QtWidgets.QComboBox,
                  current_isotope=None,
                  show_std_mass=False):
    """Load isotopes of given element into given combobox.

    Args:
        symbol: string representation of an element, e.g. 'He'.
        combobox: QComboBox to which items are added.
        current_isotope: Current isotope to select it on combobox by default.
        show_std_mass: if True, std mass is added as the first element
    """
    combobox.clear()
    # Sort isotopes based on their natural abundance
    isotopes = Element.get_isotopes(symbol, include_st_mass=show_std_mass)

    for idx, iso in enumerate(isotopes):
        if iso["element"].isotope is None:
            # Standard mass option
            txt = f"{round(iso['element'].get_mass())} (st. mass)"
        else:
            # Isotope specific options
            txt = f"{iso['element'].isotope} ({round(iso['abundance'], 3)}%)"
        combobox.addItem(txt, userData=iso)
        if current_isotope == iso["element"].isotope:
            combobox.setCurrentIndex(idx)
Пример #26
0
 def __sortt(self, key):
     cut_file = key.split('.')
     # TODO use RBS selection to sort (for example m1.35Cl.RBS_Mn.0.cut
     #  should be sorted by Mn, not Cl)
     # TODO provide elements as parameter instead of reinitializing them
     #  over and over again
     return Element.from_string(cut_file[0].strip())
Пример #27
0
class NotesList(Component):
    """Definition of notes list component."""

    add = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[1]/div/div[1]/div/div/span')
    note1_delete = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[1]/div/div[2]/a[1]/div/span')
    note1_select = Element(
        xpath='//*[@id="notes"]/div/div/notes/div/div[1]/div/div[2]/a[1]')
    note2_delete = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[1]/div/div[2]/a[2]/div/span')
    note2_select = Element(
        xpath='//*[@id="notes"]/div/div/notes/div/div[1]/div/div[2]/a[2]')
Пример #28
0
 def __sortt(key):
     cut_file = key.split('.')
     # TODO sort by RBS selection
     # TODO provide elements as parameters, do not initialize them here.
     #   Better yet, use CutFile objects here.
     # TODO is measurement removed from the cut file at this point? If
     #   not, this sorts by measurement instead of element
     return Element.from_string(cut_file[0].strip())
Пример #29
0
class NotesDetail(Component):
    """Definition of notes detail component."""

    preview_tab = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[2]/div/div/div/div/markdown-edit-preview/ul/li[1]'
    )
    preview_textarea = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[2]/div/div/div/div/markdown-edit-preview/div/div[1]/div/div/div'
    )
    no_notes_text = Element(
        xpath='//*[@id="notes"]/div/div/notes/div/div[2]/div/p')
    add = Element(xpath='//*[@id="notes"]/div/div/notes/div/div[2]/div')
    edit_tab = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[2]/div/div/div/div/markdown-edit-preview/ul/li[2]'
    )
    edit_textarea = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[2]/div/div/div/div/markdown-edit-preview/div/div[2]/div/textarea'
    )
    markdown_cheatcheat = Element(
        xpath=
        '//*[@id="notes"]/div/div/notes/div/div[2]/div/div/div/div/markdown-edit-preview/div/small/a'
    )
Пример #30
0
    def test_hash(self):
        e = Element.from_string("H")
        hashed_elems = {
            e, e,
            Element.from_string("H"),
            Element.from_string("1H"),
            Element.from_string("1H 4.0"),
            Element.from_string("1H 4.0"),
            Element.from_string("1H 5.0")
        }

        self.assertEqual(
            {
                Element.from_string("H"),
                Element.from_string("1H"),
                Element.from_string("1H 4.0"),
                Element.from_string("1H 5.0")
            }, hashed_elems)