Incorrect code in BinaryModelParameters classes #4381
Labels
code-sanitation
Code consistency, maintainability, and best practices, moreso than any public API.
P3
Doc bugs, questions, minor issues, etc.
There is a problem with the code inside the Create method of the following classes:
The problem is that in those 4 cases, each Create method has a return statement that returns a
SchemaBindableCalibratedModelParameters<,>
object. Notice that these Create methods are supposed to load from disk, in each case, a BinaryModelParameters object of the appropriate type. So this doesn't make sense, since the SBCMP class is not supposed to be used as a BinaryModelParameter, and thus, these classes shouldn't be loaded as SBCMP objects.I pointed at this problem inside this comment (under question number 2) while working on my PR #4306 . There, @yaeldekel responded that these pieces of code seem 'very wrong' to her, and that they might be the result of some legacy code that is no longer valid. Specifically she mentioned that in the past Calibrators where a field of predictors, and predictors were responsible of loading them at deserialization time. This is no longer the case, and her guess is that the code that I've pointed to is no longer valid.
Even more, she believes that the
return new SBCMP
statements I've mentioned are actually unreachable now, since they all appear in branches that only execute when there is no calibrator to load inside the BinaryModelParameters (e.g. this 'if statement'). Since predictors are no longer in charge of loading calibrators, then those paths are unreachable, and then the Create methods I've mentioned, always return the predictor of the appropriate type anyway, without getting into creatingSBCMP
objects.In the case of the
LinearBinaryModelParameters
Create method, a ParameterMixingCalibratedModelParameters<,> object could also be returned, but this also seems invalid and unreachable for the same reasons already described for SBCMP.Perhaps further investigation is needed to clarify all of this, and if those pieces of code are truly unreachable and no longer valid, then it might be better to remove them.
The text was updated successfully, but these errors were encountered: