Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1""" 

2Contains custom errors and warnings. 

3 

4Errors should derive from Exception or another custom error. Custom errors are 

5only needed it standard errors, for example ValueError or TypeError, are not 

6accurate descriptions of the reason for the error. 

7 

8Warnings should derive from either an existing warning or another custom 

9warning, and should usually be accompanied by a sting using the format 

10warning_name_doc that services as a generic message to use when the warning is 

11raised. 

12""" 

13 

14import warnings 

15 

16 

17# Errors 

18class PerfectSeparationError(Exception): 

19 pass 

20 

21 

22class MissingDataError(Exception): 

23 pass 

24 

25 

26class X13NotFoundError(Exception): 

27 pass 

28 

29 

30class X13Error(Exception): 

31 pass 

32 

33 

34# Warning 

35class X13Warning(Warning): 

36 pass 

37 

38 

39class IOWarning(RuntimeWarning): 

40 pass 

41 

42 

43class ModuleUnavailableWarning(Warning): 

44 pass 

45 

46 

47module_unavailable_doc = """ 

48The module {0} is not available. Cannot run in parallel. 

49""" 

50 

51 

52class ModelWarning(UserWarning): 

53 pass 

54 

55 

56class ConvergenceWarning(ModelWarning): 

57 pass 

58 

59 

60convergence_doc = """ 

61Failed to converge on a solution. 

62""" 

63 

64 

65class CacheWriteWarning(ModelWarning): 

66 pass 

67 

68 

69class IterationLimitWarning(ModelWarning): 

70 pass 

71 

72 

73iteration_limit_doc = """ 

74Maximum iteration reached. 

75""" 

76 

77 

78class InvalidTestWarning(ModelWarning): 

79 pass 

80 

81 

82class NotImplementedWarning(ModelWarning): 

83 pass 

84 

85 

86class OutputWarning(ModelWarning): 

87 pass 

88 

89 

90class DomainWarning(ModelWarning): 

91 pass 

92 

93 

94class ValueWarning(ModelWarning): 

95 pass 

96 

97 

98class EstimationWarning(ModelWarning): 

99 pass 

100 

101 

102class SingularMatrixWarning(ModelWarning): 

103 pass 

104 

105 

106class HypothesisTestWarning(ModelWarning): 

107 pass 

108 

109 

110class InterpolationWarning(ModelWarning): 

111 pass 

112 

113 

114class PrecisionWarning(ModelWarning): 

115 pass 

116 

117 

118class SpecificationWarning(ModelWarning): 

119 pass 

120 

121 

122class HessianInversionWarning(ModelWarning): 

123 pass 

124 

125 

126class CollinearityWarning(ModelWarning): 

127 pass 

128 

129 

130recarray_warning = """\ 

131recarray support has been deprecated and will be removed after 0.12. Please \ 

132use pandas DataFrames and Series for structured data. 

133 

134You can suppress this warning using 

135 

136from warnings import filterwarnings 

137filterwarnings("ignore", message="recarray support", category=FutureWarning) 

138""" 

139 

140 

141warnings.simplefilter('always', category=ModelWarning) 

142warnings.simplefilter("always", (ConvergenceWarning, CacheWriteWarning, 

143 IterationLimitWarning, InvalidTestWarning))