You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/03/10 04:37:00 UTC
[jira] [Work logged] (MATH-1522) The generic parameter of
ClusterRanking can move onto method
[ https://issues.apache.org/jira/browse/MATH-1522?focusedWorklogId=400555&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-400555 ]
ASF GitHub Bot logged work on MATH-1522:
----------------------------------------
Author: ASF GitHub Bot
Created on: 10/Mar/20 04:36
Start Date: 10/Mar/20 04:36
Worklog Time Spent: 10m
Work Description: chentao106 commented on pull request #124: MATH-1522 Remove generic parameter in ClusterEvaluator and ClusterRan…
URL: https://github.com/apache/commons-math/pull/124
MATH-1522 Remove generic parameter in ClusterEvaluator and ClusterRanking, then the object declarations can be easier, and can be reused.
Before remove the generic parameter:
```java
ClusterRanking<DoublePoint> evaluator = new SumOfClusterVariances<>();
List<Cluster<DoublePoint>> clusters1 = ...
evaluator.compute(clusters1); // It is OK.
...
// The evaluator could be reused, but trigger a compile error
List<Cluster<MyClusterable>> clusters2 = ...
evaluator.compute(clusters2); // Compile error
```
After remove the generic parameter:
```java
// The variable define is simple now.
ClusterRanking evaluator = new SumOfClusterVariances();
...
List<Cluster<DoublePoint>> clusters1 = ...
double score1 = evaluator.compute(clusters1); // OK.
...
// It can be reused now.
List<Cluster<MyClusterable>> clusters2 = ...
double score2 = evaluator.compute(clusters2); // OK.
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Issue Time Tracking
-------------------
Worklog Id: (was: 400555)
Remaining Estimate: 0h
Time Spent: 10m
> The generic parameter of ClusterRanking can move onto method
> ------------------------------------------------------------
>
> Key: MATH-1522
> URL: https://issues.apache.org/jira/browse/MATH-1522
> Project: Commons Math
> Issue Type: Improvement
> Reporter: Chen Tao
> Priority: Major
> Time Spent: 10m
> Remaining Estimate: 0h
>
> The generic parameter on class "ClusterRanking" is unnecessary,
> it is redundancy when define a variable, and hard to reuse(it could be):
> {code:java}
> ClusterRanking<DoublePoint> evaluator = new SumOfClusterVariances<>();
> List<Cluster<DoublePoint>> clusters1 = ...
> evaluator.compute(clusters1); // It is OK.
> ...
> // It could be reused globally, but now trigger a compile error
> List<Cluster<MyClusterable>> clusters2 = ...
> evaluator.compute(clusters2); // Compile error
> {code}
> The generic parameter of ClusterRanking can be move onto method:
> {code:java}
> @FunctionalInterface
> public interface ClusterRanking {
> /**
> * Computes the rank (higher is better).
> *
> * @param clusters Clusters to be evaluated.
> * @return the rank of the provided {@code clusters}.
> */
> <T extends Clusterable> double compute(List<? extends Cluster<T>> clusters);
> }
> {code}
> Then we can define a ClusterRanking easier and reuse it globally:
> {code:java}
> // The variable define is simple now.
> ClusterRanking evaluator = new SumOfClusterVariances();
> ...
> List<Cluster<DoublePoint>> clusters1 = ...
> double score1 = evaluator.compute(clusters1); // OK.
> ...
> // It can be reused globally now.
> List<Cluster<MyClusterable>> clusters2 = ...
> double score2 = evaluator.compute(clusters2); // OK.
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)