[ 
https://issues.apache.org/jira/browse/MATH-1651?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17628351#comment-17628351
 ] 

Alex Herbert commented on MATH-1651:
------------------------------------

{quote}Please expand on what the problem is for testUpdate.
{quote}
Since the collection of neurons is stored in an unordered Map the neurons may 
be returned in a different order for each iteration so distancesBefore and 
distanceAfter, when using the same index, do not refer to the same neuron.

In the recently closed PR-213 I suggested updating to:
{code:java}
for (Neuron n : net) {
    distancesBefore[(int) n.getIdentifier()] = 
dist.applyAsDouble(n.getFeatures(), features);
}
// ...
for (Neuron n : net) {
    distancesAfter[(int) n.getIdentifier()] = 
dist.applyAsDouble(n.getFeatures(), features);
}
{code}
However given that the collection of neurons between the two statements has not 
changed I think the changing iteration order of the two loops is being 
artificially introduced when testing using the nondex plugin. For completeness 
we should update the arrays to store the distances using the neuron ID, this is 
assuming the network neuron IDs are not updated in the intermediate actions.

> junit flaky tests in commons-math-neuralnet
> -------------------------------------------
>
>                 Key: MATH-1651
>                 URL: https://issues.apache.org/jira/browse/MATH-1651
>             Project: Commons Math
>          Issue Type: Bug
>            Reporter: Anant Dahiya
>            Priority: Major
>          Time Spent: 50m
>  Remaining Estimate: 0h
>
>  
> Flaky JUnit Tests identified  in commons-math-neuralnet
> *How did we detect Flaky Test ?*
> We detected the existence of flaky test using the tool 
> [NonDex|https://github.com/TestingResearchIllinois/NonDex]
>  
> *Command*
> {code:java}
> mvn -pl commons-math-neuralnet edu.illinois:nondex-maven-plugin:1.1.2:nondex 
> -Dtest=org.apache.commons.math4.neuralnet.NetworkTest#testIterationOrder{code}
>  
> *Tests :* 
>  
>  
> ||Path||Test||
> |commons-math-neuralnet|org.apache.commons.math4.neuralnet.NetworkTest#testIterationOrder|
> |commons-math-neuralnet|org.apache.commons.math4.neuralnet.sofm.KohonenUpdateActionTest#testUpdate|



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to