-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IGNITE-7877: Improve code style in GA part #3695
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check comments and remove empty lines between class declaration and the first field for all classes.
@@ -46,7 +48,6 @@ | |||
private long[] genes; | |||
|
|||
/** | |||
* | |||
* @param genes Primary keys of Genes | |||
*/ | |||
public Chromosome(long[] genes) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed javadoc for line 103
/** {@inheritDoc} */
@Override public String toString() {
orderDirection = "asc"; | ||
} | ||
if (config.isHigherFitnessValueFitter() == false) { | ||
orderDirection = "asc"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
braces style and this expression may be improved:
if (!config.isHigherFitnessValueFitter())
orderDirection = "asc";
@@ -230,10 +231,9 @@ public Chromosome evolve() { | |||
List<Long> orderChromKeysByFittest = new ArrayList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed diamond?
List<Long> orderChromKeysByFittest = new ArrayList<>();
@@ -36,6 +36,7 @@ | |||
*/ | |||
public class Gene { | |||
|
|||
/** primary key of Gene */ | |||
private static final AtomicLong ID_GEN = new AtomicLong(); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed javadoc for toString()
@@ -42,6 +42,7 @@ | |||
/** primary keys of genes to be used in mutation **/ | |||
private List<Long> mutatedGeneKeys; | |||
|
|||
/** Ignite instance */ | |||
@IgniteInstanceResource | |||
private Ignite ignite = null; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
brace style for line 80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And TODO at the line 69
@@ -49,9 +49,11 @@ | |||
*/ | |||
public class MutateTask extends ComputeTaskAdapter<List<Long>, Boolean> { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line here and braces at the lines 145 and 148
@@ -42,6 +42,7 @@ | |||
/** primary keys of genes to be used in mutation */ | |||
private List<Long> mutatedGeneKeys; | |||
|
|||
/** Ignite instance */ | |||
@IgniteInstanceResource | |||
private Ignite ignite = null; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO at the line 64 and double braces at the line 72
@@ -44,9 +44,9 @@ | |||
/** | |||
* Responsible for performing truncate selection. | |||
*/ | |||
|
|||
public class TruncateSelectionTask extends ComputeTaskAdapter<List<Long>, Boolean> { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty line here and please format methods getChromosome and getEnhancedPopulation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And TODO in reduce method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ybabak, Please share with me what respective tools you are using to validate code style. Presently, I am using IntelliJ's format command to apply the respective style using 'ignite_codeStyle.xml'
IE:
format -s \ignite_codeStyle.xml -m *.java -r \modules\ml\src\main\java\org\apache\ignite\ml\genetic
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check comments
@@ -35,7 +35,6 @@ | |||
* Responsible for providing custom SQL functions to retrieve optimization results | |||
*/ | |||
public class GAGridFunction { | |||
|
|||
/** GAConfiguration **/ | |||
private GAConfiguration config = null; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for lines 52 and 63: are those lines is needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. These line are required.
@@ -34,4 +33,5 @@ | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please cleanup lines 34-36
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is they way source was formatted after applying IntelliJ's format and ignite_codeStyle.xml on source. - Fixed.
@IgniteInstanceResource | ||
private Ignite ignite = null; | ||
|
||
/** Ignite logger */ | ||
@LoggerResource | ||
private IgniteLogger log = null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check line 87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@@ -79,7 +78,6 @@ public GAGrid(GAConfiguration config, Ignite ignite) { | |||
* | |||
* @return Average fitness score | |||
*/ | |||
|
|||
private Double calculateAverageFitness() { | |||
|
|||
double avgFitnessScore = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 105: Do we need return value here?
And the same for line 122, 158, 310, 428
And for 148(+ 404): unnecessary local variable
Brace style for lines 362 and 365
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 105. Fixed
Line 122, 158, 310, 428. Fixed
148(+ 404): - These variable are necessary.
Brace style for lines 362 and 365. Fixed
config.getChromosomeLength(); | ||
|
||
for (int i = 0; i < config.getChromosomeLength(); i++) { | ||
// Gene gene=config.getGenePool().get(selectRandomIndex(config.getGenePool().size())); | ||
mutatedGenes.add(selectGene(i)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brace style for lines 143 and 146
And for 187: unnecessary local variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brace style for lines 143 and 146. Fixed.
And for 187: unnecessary local variable - This variable is necessary.
this closes #3695 (cherry picked from commit b97b1ee)
No description provided.