aherbert commented on code in PR #236:
URL: https://github.com/apache/commons-math/pull/236#discussion_r1498863054


##########
commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/stat/ranking/NaturalRanking.java:
##########
@@ -158,8 +158,8 @@ public NaturalRanking(NaNStrategy nanStrategy,
     private NaturalRanking(NaNStrategy nanStrategy,
                            TiesStrategy tiesStrategy,
                            UniformRandomProvider random) {
-        this.nanStrategy = nanStrategy;
-        this.tiesStrategy = tiesStrategy;
+        this.nanStrategy = nanStrategy != null ? nanStrategy : 
DEFAULT_NAN_STRATEGY;

Review Comment:
   If the user-supplied parameter is null then this is an error. I think it may 
be preferable to throw a NPE here:
   ```java
   this.nanStrategy = Objects.requireNonNull(nanStrategy, "nanStrategy");
   this.tiesStrategy = Objects.requireNonNull(tiesStrategy, "tiesStrategy");
   ```
   
   Note: This class has been ported to the Commons Statistics project and will 
be released in version 1.1.
   See: 
https://github.com/apache/commons-statistics/blob/master/commons-statistics-ranking/src/main/java/org/apache/commons/statistics/ranking/NaturalRanking.java
   
   I updated that implementation to throw NPE for user-supplied arguments. 
Thanks for the prompting.
   
   You can test the current implementation using the apache snapshots repo 
using e.g.:
   ```xml
       <dependency>
         <groupId>org.apache.commons</groupId>
         <artifactId>commons-statistics-ranking</artifactId>
         <version>1.1-SNAPSHOT</version>
       </dependency>
   ```



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to