[
https://issues.apache.org/jira/browse/MATH-195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12905031#action_12905031
]
Gilles commented on MATH-195:
-----------------------------
Coming back to my favourite :-} issue.
"Checkedness" again showed its nuisance (personal point-of-view, of course)
during the work on the {{optimization}} package (cf. point 8 in
[MATH-413|https://issues.apache.org/jira/browse/MATH-413]).
Doing a "find", we can observe that "FunctionEvaluationException" is very
rarely instantiated in CM. In the few cases where it is, I think that it's not
the best thing to be done:
* in {{PolynomialFunctionLagrangeForm}}, it should really be a sub-class of
{{IllegalArgumentException}}.
* in {{AbstractIntegerDistribution}} and {{AbstractContinuousDistribution}},
the functionality can be achieved with an unchecked exception.
* in {{AbstractLeastSquaresOptimizer}}, I suspect that the problem should be
caught sooner.
Furthermore, the basic question is: What is the intended purpose of
"FunctionEvaluationException"? And one should consider this question together
with the remarkable fact that neither {{java.lang.Math}} nor {{FastMath}}
throws any exception!
Hence I'd like to create an _unchecked_ "FunctionEvaluationException" (and
deprecate the checked one) and have a _policy_ stating that the {{value}}
method in the various "...Function" classes can throw that exception when the
problem does not arise from a violation of preconditions.
This will be a considerable improvement in the CM code readability and
usability without any loss in functionality.
> Inconsistencies in the Exception hierarchy
> ------------------------------------------
>
> Key: MATH-195
> URL: https://issues.apache.org/jira/browse/MATH-195
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 1.1, 1.2, 2.0, Nightly Builds
> Reporter: Thomas Chust
> Assignee: Gilles
> Priority: Minor
> Fix For: 3.0
>
> Original Estimate: 0.17h
> Remaining Estimate: 0.17h
>
> I think there are some inconsistencies in the hierarchy of exceptions used by
> the Commons Math library which could easily be fixed:
> - org.apache.commons.math.linear.MatrixIndexException should really be a
> subclass of
> java.lang.IndexOutOfBoundsException.
> - Either org.apache.commons.math.linear.InvalidMatrixException should be
> checked or
> org.apache.commons.math.random.NotPositiveDefiniteMatrixException and
> org.apache.commons.math.geometry.NotARotationMatrixException should be
> unchecked, but in any case the latter two
> should be subclasses of the former. An unchecked InvalidMatrixException
> should probably be a subclass of
> java.lang.ArithmeticException while a checked InvalidMatrixException
> should be a subclass of
> org.apache.commons.math.MathException.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.