Esempio n. 1
0
def test_isclose_lazy():
    value0 = LazyOptionMock(1)

    assert base.isclose(value0, LazyOptionMock(1))
    assert not base.isclose(value0, LazyOptionMock(2))
    assert not base.isclose(value0, None)
    assert not base.isclose(value0, 1)
Esempio n. 2
0
 def __eq__(self, other):
     return (super().__eq__(other)
             and base.isclose(self.program, other.program)
             and base.isclose(self.beam, other.beam)
             and base.isclose(self.sample, other.sample)
             and base.are_sequence_similar(self.analyses, other.analyses)
             and base.are_sequence_similar(self.tags, other.tags))
Esempio n. 3
0
 def __eq__(self, other):
     return (super().__eq__(other)
             and base.isclose(self.left_material, other.left_material)
             and base.isclose(self.right_material, other.right_material)
             and base.isclose(self.depth_m,
                              other.depth_m,
                              abs_tol=self.DEPTH_TOLERANCE_m))
Esempio n. 4
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(self.material, other.material)
         and base.isclose(
             self.diameter_m, other.diameter_m, abs_tol=self.DIAMETER_TOLERANCE_m
         )
     )
Esempio n. 5
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(self.material, other.material)
         and base.isclose(
             self.thickness_m, other.thickness_m, abs_tol=self.THICKNESS_TOLERANCE_m
         )
     )
Esempio n. 6
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(
             self.tilt_rad, other.tilt_rad, abs_tol=self.TILT_TOLERANCE_rad
         )
         and base.isclose(
             self.azimuth_rad, other.azimuth_rad, abs_tol=self.AZIMUTH_TOLERANCE_rad
         )
     )
Esempio n. 7
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(
             self.relative_uncertainty,
             other.relative_uncertainty,
             abs_tol=self.RELATIVE_UNCERTAINTY_TOLERANCE,
         )
         and base.isclose(self.xrayline, other.xrayline)
     )
Esempio n. 8
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(self.substrate_material, other.substrate_material)
         and base.isclose(self.inclusion_material, other.inclusion_material)
         and base.isclose(
             self.inclusion_diameter_m,
             other.inclusion_diameter_m,
             abs_tol=self.INCLUSION_DIAMETER_TOLERANCE_m,
         ))
Esempio n. 9
0
 def __eq__(self, other):
     # NOTE: color is not tested in equality
     return (super().__eq__(other) and base.isclose(self.name, other.name)
             and base.are_mapping_value_close(
                 self.composition,
                 other.composition,
                 abs_tol=self.WEIGHT_FRACTION_TOLERANCE,
             ) and base.isclose(
                 self.density_kg_per_m3,
                 other.density_kg_per_m3,
                 abs_tol=self.DENSITY_TOLERANCE_kg_per_m3,
             ))
Esempio n. 10
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(
             self.elevation_rad,
             other.elevation_rad,
             abs_tol=self.ELEVATION_TOLERANCE_rad,
         )
         and base.isclose(
             self.azimuth_rad, other.azimuth_rad, abs_tol=self.AZIMUTH_TOLERANCE_rad
         )
     )
Esempio n. 11
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.are_mapping_value_close(
             self._interactions, other._interactions, abs_tol=self.TOLERANCE
         )
         and base.isclose(
             self.bremsstrahlung_xray_splitting_factor,
             other.bremsstrahlung_xray_splitting_factor,
         )
         and base.isclose(
             self.characteristic_xray_splitting_factor,
             other.characteristic_xray_splitting_factor,
         )
     )
Esempio n. 12
0
 def __eq__(self, other):
     return (super().__eq__(other)
             and self.simulation_parameters == other.simulation_parameters
             and self.interaction_forcings == other.interaction_forcings
             and self.reference_line == other.reference_line
             and base.isclose(
                 self.simulation_time_s,
                 other.simulation_time_s,
                 abs_tol=self.SIMULATION_TIME_TOLERANCE_s,
             ) and self.number_trajectories == other.number_trajectories)
Esempio n. 13
0
 def __eq__(self, other):
     return (super().__eq__(other) and base.isclose(
         self.number_trajectories, other.number_trajectories)
             and self.elastic_cross_section_model
             == other.elastic_cross_section_model
             and self.ionization_cross_section_model
             == other.ionization_cross_section_model
             and self.ionization_potential_model
             == other.ionization_potential_model
             and self.random_number_generator_model
             == other.random_number_generator_model
             and self.direction_cosine_model == other.direction_cosine_model
             and self.energy_loss_model == other.energy_loss_model)
Esempio n. 14
0
 def __eq__(self, other):
     return (
         super().__eq__(other) and base.isclose(
             self.eabs_electron_eV,
             other.eabs_electron_eV,
             abs_tol=self.ENERGY_TOLERANCE_eV,
         ) and base.isclose(
             self.eabs_photon_eV,
             other.eabs_photon_eV,
             abs_tol=self.ENERGY_TOLERANCE_eV,
         ) and base.isclose(
             self.eabs_positron_eV,
             other.eabs_positron_eV,
             abs_tol=self.ENERGY_TOLERANCE_eV,
         ) and base.isclose(self.c1, other.c1, abs_tol=self.C1_C2_TOLERANCE)
         and base.isclose(self.c2, other.c2, abs_tol=self.C1_C2_TOLERANCE)
         and base.isclose(
             self.wcc_eV, other.wcc_eV, abs_tol=self.ENERGY_TOLERANCE_eV)
         and base.isclose(self.wcr_eV,
                          other.wcr_eV,
                          abs_tol=self.ENERGY_TOLERANCE_eV))
Esempio n. 15
0
 def __eq__(self, other):
     return super().__eq__(other) and base.isclose(self.name, other.name)
Esempio n. 16
0
 def __eq__(self, other):
     return super().__eq__(other) and base.isclose(
         self.photon_detector, other.photon_detector
     )
Esempio n. 17
0
 def __eq__(self, other):
     return super().__eq__(other) and base.isclose(self.material, other.material)
Esempio n. 18
0
 def __eq__(self, other):
     return super().__eq__(other) and base.isclose(
         self.minimum_energy_eV,
         other.minimum_energy_eV,
         abs_tol=self.ENERGY_TOLERANCE_eV,
     )
Esempio n. 19
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(self.x0_m, other.x0_m, abs_tol=self.POSITION_TOLERANCE_m)
         and base.isclose(self.y0_m, other.y0_m, abs_tol=self.POSITION_TOLERANCE_m)
     )
Esempio n. 20
0
 def __eq__(self, other):
     return super().__eq__(other) and base.isclose(self.value, other.value)
Esempio n. 21
0
 def __eq__(self, other):
     return (super().__eq__(other) and base.isclose(
         self.energy_eV, other.energy_eV, abs_tol=self.ENERGY_TOLERANCE_eV)
             and base.isclose(self.particle, other.particle))
Esempio n. 22
0
 def __eq__(self, other):
     return (
         super().__eq__(other)
         and base.isclose(self.xrayline, other.xrayline)
         and base.isclose(self.c1, other.c1, abs_tol=self.C1_C2_TOLERANCE)
         and base.isclose(self.c2, other.c2, abs_tol=self.C1_C2_TOLERANCE))
Esempio n. 23
0
def test_isclose_numbers():
    assert base.isclose(4.0, 4.01, abs_tol=0.1)
Esempio n. 24
0
def test_isclose_none():
    assert base.isclose(None, None)
    assert not base.isclose(None, 4.0)
    assert not base.isclose(4.0, None)