Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def setUp(self):
"""
Setup the test fixture for the Resistor class.
"""
self.DUT = Model()
self._base_values = (0, 32, 'Alt Part #', 'Attachments', 'CAGE Code',
'Comp Ref Des', 0.0, 0.0, 0.0, 'Description',
100.0, 0, 0, 'Figure #', 50.0, 'LCN', 1, 0, 10.0,
'Name', 'NSN', 0, 'Page #', 0, 0, 'Part #', 1,
'Ref Des', 1.0, 0, 'Remarks', 0.0, 'Spec #', 0,
30.0, 30.0, 0.0, 2014) # 0 - 37
self._stress_values = (1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0,
1.0, 0.0, 1.0) # 38 - 49
self._rel_values = (0.0, 1.0, 1.0, 0.0, 0.0, 0, 0.0, 0.0, 0.0, 0.0,
0.0, 0.0, 1, 0.0, '', 0.0, 0.0, 0.0, 1, 0.0, 0.0,
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
1.0, 1.0, 0.0, 0.0, 0) # 50 - 86
self._user_values = (
0.0, 1.0, 2.0, 30.0, 440.0, 5, 6, 7.0, 8.0, 99.0, 10.0, 11, 12,
13.0, 14, 15.0, 16.0, 17.0, 18, 19.0, 0.0, 1.0, 2, 3, 440.0, 50,
self.piV = 1.22
elif(_v_applied / self.rated_voltage > 0.8 and
_v_applied / self.rated_voltage <= 0.9):
self.piV = 1.40
elif _v_applied / self.rated_voltage > 0.9:
self.piV = 2.00
self.hazard_rate_model['piV'] = self.piV
# Construction factor.
self.piC = self._lst_piC[self.construction - 1]
self.hazard_rate_model['piC'] = self.piC
return Resistor.calculate_part(self)
class SemiPrecisionWirewound(Resistor):
"""
The Semi-Precision Wirewound Variable resistor data model contains the
attributes and methods of a Semi-Precision Wirewound Variable resistor.
The attributes of a Semi-Precision Wirewound Variable resistor are:
:cvar list _lst_piE: list of MIL-HDBK-217FN2 operating environment factor
values.
:cvar list _lst_piQ_count: list of quality factor values for the
MIL-HDBK-217FN2 parts count method.
:cvar list _lst_piQ_stress: list of quality factor values for the
MIL-HDBK-217FN2 parts stress method.
:cvar list _lst_lambdab_count: list of base hazard rate values for the
MIL-HDBK-217FN2 parts count method.
:cvar int subcategory: default value: 35
:ivar int n_taps: the number of taps on the potentiometer.
__author__ = 'Andrew Rowland'
__email__ = 'andrew.rowland@reliaqual.com'
__organization__ = 'ReliaQual Associates, LLC'
__copyright__ = 'Copyright 2007 - 2015 Andrew "weibullguy" Rowland'
# Add localization support.
try:
locale.setlocale(locale.LC_ALL, Configuration.LOCALE)
except locale.Error: # pragma: no cover
locale.setlocale(locale.LC_ALL, '')
_ = gettext.gettext
class VarWirewound(Resistor):
"""
The Wirewound Variable resistor data model contains the attributes and
methods of a Wirewound Variable resistor. The attributes of a Wirewound
Variable resistor are:
:cvar list _lst_piE: list of MIL-HDBK-217FN2 operating environment factor
values.
:cvar list _lst_piQ_count: list of quality factor values for the
MIL-HDBK-217FN2 parts count method.
:cvar list _lst_piQ_stress: list of quality factor values for the
MIL-HDBK-217FN2 parts stress method.
:cvar list _lst_lambdab_count: list of base hazard rate values for the
MIL-HDBK-217FN2 parts count method.
:cvar int subcategory: default value: 33
:ivar int n_taps: the number of taps on the potentiometer.
__author__ = 'Andrew Rowland'
__email__ = 'andrew.rowland@reliaqual.com'
__organization__ = 'ReliaQual Associates, LLC'
__copyright__ = 'Copyright 2007 - 2015 Andrew "weibullguy" Rowland'
# Add localization support.
try:
locale.setlocale(locale.LC_ALL, Configuration.LOCALE)
except locale.Error: # pragma: no cover
locale.setlocale(locale.LC_ALL, '')
_ = gettext.gettext
class Composition(Resistor):
"""
The Carbon Composition resistor data model contains the attributes and
methods of a Carbon Composition resistor. The attributes of a carbon
composition resistor are:
:cvar list _lst_piR: list of resistance factor values.
:cvar list _lst_piE: list of environment factor values.
:cvar list _lst_piQ_count: list of quality factor values for the
MIL-HDBK-217FN2 parts count method.
:cvar list _lst_piQ_stress: list of quality factor values for the
MIL-HDBK-217FN2 parts stress method.
:cvar list _lst_lambdab_count: list of base hazard rate values for
MIL-HDBK-217FN2 parts count.
:cvar int subcategory: default value: 25
Covers specifications MIL-R-11 and MIL-R-39008.
self.piR = 1.8
self.hazard_rate_model['piR'] = self.piR
# Voltage factor.
_v_applied = sqrt(self.resistance * self.operating_power)
if _v_applied / self.rated_voltage <= 0.8:
self.piV = 1.00
elif(_v_applied / self.rated_voltage > 0.8 and
_v_applied / self.rated_voltage <= 0.9):
self.piV = 1.05
elif(_v_applied / self.rated_voltage > 0.9 and
_v_applied / self.rated_voltage <= 1.0):
self.piV = 1.20
self.hazard_rate_model['piV'] = self.piV
return Resistor.calculate_part(self)
except OverflowError:
# TODO: Handle overflow error.
return True
# Resistance factor.
if self.resistance < 100000.0:
self.piR = 1.0
elif self.resistance >= 100000.0 and self.resistance < 1.0E6:
self.piR = 1.1
elif self.resistance >= 1.0E6 and self.resistance < 1.0E7:
self.piR = 1.6
elif self.resistance >= 1.0E7:
self.piR = 2.5
self.hazard_rate_model['piR'] = self.piR
return Resistor.calculate_part(self)
# Resistance factor.
if self.resistance < 100000.0:
self.piR = 1.0
elif self.resistance >= 100000.0 and self.resistance < 1.0E6:
self.piR = 1.1
elif self.resistance >= 1.0E6 and self.resistance < 1.0E7:
self.piR = 1.6
elif self.resistance >= 1.0E7:
self.piR = 2.5
self.hazard_rate_model['piR'] = self.piR
return Resistor.calculate_part(self)
class FilmPower(Resistor):
"""
The Carbon Film power resistor data model contains the attributes and
methods of a Carbon Film power resistor. The attributes of a carbon film
power resistor are:
:cvar list _lst_piR: list of resistance factor values.
:cvar list _lst_piE: list of environment factor values.
:cvar list _lst_piQ_count: list of quality factor values for the
MIL-HDBK-217FN2 parts count method.
:cvar list _lst_piQ_stress: list of quality factor values for the
MIL-HDBK-217FN2 parts stress method.
:cvar list _lst_lambdab_count: list of base hazard rate values for the
MIL-HDBK-217FN2 parts count method.
:cvar int subcategory: default value: 27
Covers specifications MIL-R-11804.
def get_attributes(self):
"""
Method to retrieve the current values of the Wirewound Chassis Mount
Power resistor data model attributes.
:return: (specification, style)
:rtype: tuple
"""
_values = Resistor.get_attributes(self)
_values = _values + (self.characteristic, self.style)
return _values