[GitHub] commons-lang pull request #246: DateUtilsTest asserts

2017-02-27 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/commons-lang/pull/246


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang issue #246: DateUtilsTest asserts

2017-02-27 Thread PascalSchumacher
Github user PascalSchumacher commented on the issue:

https://github.com/apache/commons-lang/pull/246
  
Thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang issue #246: DateUtilsTest asserts

2017-02-27 Thread kinow
Github user kinow commented on the issue:

https://github.com/apache/commons-lang/pull/246
  
:+1: 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] commons-lang pull request #246: DateUtilsTest asserts

2017-02-27 Thread mureinik
GitHub user mureinik opened a pull request:

https://github.com/apache/commons-lang/pull/246

DateUtilsTest asserts

Use JUnit's assertFalse for assertions with conditions instead of
re-implementing the logic here by testing the condition and throwing an
AssertionFailureException if the condition is met.

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/mureinik/commons-lang DateUtilsTest

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/commons-lang/pull/246.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #246


commit 59effed7ad53df5a59bee8b09b8e21ba9900156b
Author: Allon Mureinik 
Date:   2017-02-27T19:35:03Z

DateUtilsTest asserts

Use JUnit's assertFalse for assertions with conditions instead of
re-implementing the logic here by testing the condition and throwing an
AssertionFailureException if the condition is met.




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[jira] [Commented] (MATH-1403) Collinearity test: QR Decomposition rank incorrect (SVD ok)

2017-02-27 Thread Gilles (JIRA)

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

Gilles commented on MATH-1403:
--

Jama's documentation for says:
{noformat}
public int rank()

Matrix rank

Returns:
effective numerical rank, obtained from SVD.
{noformat}


> Collinearity test: QR Decomposition rank incorrect (SVD ok)
> ---
>
> Key: MATH-1403
> URL: https://issues.apache.org/jira/browse/MATH-1403
> Project: Commons Math
>  Issue Type: Bug
>Affects Versions: 3.6.1
> Environment: Linux ubuntu
> JDK 8
>Reporter: Hugo Ferrira
>
> Hello,
> I am aware that such a question have been asked before but I cannot seem to 
> solve this issue for a very simple example. The closest example I have is:
> https://issues.apache.org/jira/browse/MATH-1100
> from which I could not get an answer.
> I am trying to copy an algorithm from R's Caret package that identifies 
> collinear columns of a matrix [1]. I am assuming a "long" matrix and and am 
> using the trivial example from the reference above. However I cannot get this 
> to work because the QR's rank result is incorrect.
> I have the following example:
> import org.apache.commons.math3.linear.RealMatrix;
> import org.apache.commons.math3.linear.RRQRDecomposition;
> import org.apache.commons.math3.linear.Array2DRowRealMatrix;
> import org.apache.commons.math3.linear.SingularValueDecomposition ;
> public class QRIssue {
>   public static void main(String[] args) {
> double[][] am = new double[5][];
> double[] c1 = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0} ;
> double[] c2 = new double[] {1.0, 1.0, 1.0, 0.0, 0.0, 0.0} ;
> double[] c3 = new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0} ;
> double[] c4 = new double[] {1.0, 0.0, 0.0, 1.0, 0.0, 0.0 } ;
> double[] c6 = new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 1.0 } ;
> am[0] = c1 ;
> am[1] = c2 ;
> am[2] = c3 ;
> am[3] = c4 ;
> am[4] = c6 ;
> Double threshold = 1e-1;
> Array2DRowRealMatrix m = new Array2DRowRealMatrix( am, false )  ; // use 
> array, don't copy
> RRQRDecomposition qr = new RRQRDecomposition( m,  threshold) ;
> RealMatrix r = qr.getR() ;
> int numColumns = r.getColumnDimension() ;
> int rank = qr.getRank( threshold ) ;
> System.out.println("QR rank: " + rank) ;
> System.out.println("QR is singular: " + !qr.getSolver().isNonSingular()) ;
> System.out.println("QR is singular: " + (numColumns == rank) ) ;
> SingularValueDecomposition sv2 = new 
> org.apache.commons.math3.linear.SingularValueDecomposition(m);
> System.out.println("SVD rank: " + sv2.getRank()) ;
> }
> }
> For SVD I get a rank of 4 which is correct (columns 0,1,2 are collinear : c0 
> = c1 + c2). But for QR I get 5. I have tried several thresholds with no 
> success. For several subsets of the columns above (example only 0,1,2 I get 
> the correct answer). What am I doing wrong?
> TIA,
> Hugo F.
> 1. https://topepo.github.io/caret/pre-processing.html#lindep



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (MATH-1403) Collinearity test: QR Decomposition rank incorrect (SVD ok)

2017-02-27 Thread Gilles (JIRA)

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

Gilles commented on MATH-1403:
--

bq. Unfortunately I am not knowledgeable enough to tackle this task.

It could start by finding out a reference algorithm (either in a scientific 
textbook or paper) or another code that implements the functionality, and 
figure out where the key differences are).
Unfortunately the Javadoc is out-of-sync since it refers to Jama having this 
same algo, whereas it [hasn't|http://math.nist.gov/javanumerics/jama/doc/].


> Collinearity test: QR Decomposition rank incorrect (SVD ok)
> ---
>
> Key: MATH-1403
> URL: https://issues.apache.org/jira/browse/MATH-1403
> Project: Commons Math
>  Issue Type: Bug
>Affects Versions: 3.6.1
> Environment: Linux ubuntu
> JDK 8
>Reporter: Hugo Ferrira
>
> Hello,
> I am aware that such a question have been asked before but I cannot seem to 
> solve this issue for a very simple example. The closest example I have is:
> https://issues.apache.org/jira/browse/MATH-1100
> from which I could not get an answer.
> I am trying to copy an algorithm from R's Caret package that identifies 
> collinear columns of a matrix [1]. I am assuming a "long" matrix and and am 
> using the trivial example from the reference above. However I cannot get this 
> to work because the QR's rank result is incorrect.
> I have the following example:
> import org.apache.commons.math3.linear.RealMatrix;
> import org.apache.commons.math3.linear.RRQRDecomposition;
> import org.apache.commons.math3.linear.Array2DRowRealMatrix;
> import org.apache.commons.math3.linear.SingularValueDecomposition ;
> public class QRIssue {
>   public static void main(String[] args) {
> double[][] am = new double[5][];
> double[] c1 = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0} ;
> double[] c2 = new double[] {1.0, 1.0, 1.0, 0.0, 0.0, 0.0} ;
> double[] c3 = new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0} ;
> double[] c4 = new double[] {1.0, 0.0, 0.0, 1.0, 0.0, 0.0 } ;
> double[] c6 = new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 1.0 } ;
> am[0] = c1 ;
> am[1] = c2 ;
> am[2] = c3 ;
> am[3] = c4 ;
> am[4] = c6 ;
> Double threshold = 1e-1;
> Array2DRowRealMatrix m = new Array2DRowRealMatrix( am, false )  ; // use 
> array, don't copy
> RRQRDecomposition qr = new RRQRDecomposition( m,  threshold) ;
> RealMatrix r = qr.getR() ;
> int numColumns = r.getColumnDimension() ;
> int rank = qr.getRank( threshold ) ;
> System.out.println("QR rank: " + rank) ;
> System.out.println("QR is singular: " + !qr.getSolver().isNonSingular()) ;
> System.out.println("QR is singular: " + (numColumns == rank) ) ;
> SingularValueDecomposition sv2 = new 
> org.apache.commons.math3.linear.SingularValueDecomposition(m);
> System.out.println("SVD rank: " + sv2.getRank()) ;
> }
> }
> For SVD I get a rank of 4 which is correct (columns 0,1,2 are collinear : c0 
> = c1 + c2). But for QR I get 5. I have tried several thresholds with no 
> success. For several subsets of the columns above (example only 0,1,2 I get 
> the correct answer). What am I doing wrong?
> TIA,
> Hugo F.
> 1. https://topepo.github.io/caret/pre-processing.html#lindep



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (TEXT-64) Investigate locale issue in ExtendedMessageFormatTest

2017-02-27 Thread Rob Tompkins (JIRA)

[ 
https://issues.apache.org/jira/browse/TEXT-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885774#comment-15885774
 ] 

Rob Tompkins commented on TEXT-64:
--

We are comparing the results from {{java.text.MessageFormat}} with those from 
{{org.apache.commons.text.ExtendedMessageFormat}}, and there are slight 
differences when calling {{Locale.getDefault}}. Namely:

{code:java}
public MessageFormat(String pattern) {
this.locale = Locale.getDefault(Locale.Category.FORMAT);
applyPattern(pattern);
}
{code}

versus

{code:java}
public ExtendedMessageFormat(final String pattern) {
this(pattern, Locale.getDefault());
}
{code}

The key differences here in the {{Locale}} class reside in the {{initDefault}} 
method:

{code:java}
private static Locale initDefault() {
String language, region, script, country, variant;
language = AccessController.doPrivileged(
new GetPropertyAction("user.language", "en"));
// for compatibility, check for old user.region property
region = AccessController.doPrivileged(
new GetPropertyAction("user.region"));
if (region != null) {
// region can be of form country, country_variant, or _variant
int i = region.indexOf('_');
if (i >= 0) {
country = region.substring(0, i);
variant = region.substring(i + 1);
} else {
country = region;
variant = "";
}
script = "";
} else {
script = AccessController.doPrivileged(
new GetPropertyAction("user.script", ""));
country = AccessController.doPrivileged(
new GetPropertyAction("user.country", ""));
variant = AccessController.doPrivileged(
new GetPropertyAction("user.variant", ""));
}

return getInstance(language, script, country, variant, null);
}

private static Locale initDefault(Locale.Category category) {
return getInstance(
AccessController.doPrivileged(
new GetPropertyAction(category.languageKey, 
defaultLocale.getLanguage())),
AccessController.doPrivileged(
new GetPropertyAction(category.scriptKey, 
defaultLocale.getScript())),
AccessController.doPrivileged(
new GetPropertyAction(category.countryKey, 
defaultLocale.getCountry())),
AccessController.doPrivileged(
new GetPropertyAction(category.variantKey, 
defaultLocale.getVariant())),
null);
}
{code}

I suppose we could add the {{Locale.Category}} to the default locale creation, 
but as I'm unfamiliar with the mechanics here I plan to bubble this up to the 
ML.

> Investigate locale issue in ExtendedMessageFormatTest
> -
>
> Key: TEXT-64
> URL: https://issues.apache.org/jira/browse/TEXT-64
> Project: Commons Text
>  Issue Type: Bug
>Affects Versions: 1.0-beta-1
>Reporter: Rob Tompkins
> Fix For: 1.0
>
>
> During release testing, Bruno found the following problem, needing 
> investigation, (http://markmail.org/message/hhio4ye2xlvdznlv).
> /* --- snip -- */
> Results :
> {code}
> Failed tests: 
> ExtendedMessageFormatTest.testBuiltInChoiceFormat:211->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1234.5: {0,choice,1#One|2#Two|3#Many {0,number}}], 
> locale=[null]
> expected:<1234.5: Many 1[.234,]5> but was:<1234.5: Many 1[,234.]5>
> ExtendedMessageFormatTest.testBuiltInDateTimeFormat:230->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1: {0,date,short}], locale=[null] expected:<1: [23/01]/07> but
> was:<1: [1/23]/07>
> ExtendedMessageFormatTest.testBuiltInNumberFormat:277->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1: {0,number}], locale=[null] expected:<1: 6[.543,]21> but
> was:<1: 6[,543.]21>
> ExtendedMessageFormatTest.testExtendedAndBuiltInFormats:141 null 
> expected: JOHN DOE DOB: [23/01/07 Salary: R$ 12.345,]67> but was: [1/23/07 Salary: $12,345.]67>
> ExtendedMessageFormatTest.testOverriddenBuiltinFormat:253->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1: {0,date}], locale=[null] expected:<1: [23/01/]2007> but
> was:<1: [Jan 23, ]2007>
> Tests run: 476, Failures: 5, Errors: 0, Skipped: 0
> [INFO] 
> 
> [INFO] BUILD FAILURE
> [INFO] 
> 
> [INFO] Total time: 11.385 s
> [INFO] Finished at: 2017-02-06T14:07:52-02:00
> [INFO] Final Memory: 30M/328M
> [INFO] 
> 
> {code}
> /* --- snip -- */
> Here's my env:
> Apache Maven 3.3.9
> Maven home: /usr/share/maven
> Java version: 1.8.0_111, vendor: Oracle Corporation
> Java home: 

[jira] [Commented] (TEXT-64) Investigate locale issue in ExtendedMessageFormatTest

2017-02-27 Thread Rob Tompkins (JIRA)

[ 
https://issues.apache.org/jira/browse/TEXT-64?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15885728#comment-15885728
 ] 

Rob Tompkins commented on TEXT-64:
--

The above hypothesis is incorrect. The scenario in which this is happening is 
under execution of: 
https://github.com/apache/commons-text/blob/master/src/test/java/org/apache/commons/text/ExtendedMessageFormatTest.java#L372
which uses {{Locale.getDefault()}} as the locale for which the tests get run.

Before iterating through the array of available locales, we attempt with the 
default locale.

> Investigate locale issue in ExtendedMessageFormatTest
> -
>
> Key: TEXT-64
> URL: https://issues.apache.org/jira/browse/TEXT-64
> Project: Commons Text
>  Issue Type: Bug
>Affects Versions: 1.0-beta-1
>Reporter: Rob Tompkins
> Fix For: 1.0
>
>
> During release testing, Bruno found the following problem, needing 
> investigation, (http://markmail.org/message/hhio4ye2xlvdznlv).
> /* --- snip -- */
> Results :
> {code}
> Failed tests: 
> ExtendedMessageFormatTest.testBuiltInChoiceFormat:211->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1234.5: {0,choice,1#One|2#Two|3#Many {0,number}}], 
> locale=[null]
> expected:<1234.5: Many 1[.234,]5> but was:<1234.5: Many 1[,234.]5>
> ExtendedMessageFormatTest.testBuiltInDateTimeFormat:230->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1: {0,date,short}], locale=[null] expected:<1: [23/01]/07> but
> was:<1: [1/23]/07>
> ExtendedMessageFormatTest.testBuiltInNumberFormat:277->checkBuiltInFormat:336->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1: {0,number}], locale=[null] expected:<1: 6[.543,]21> but
> was:<1: 6[,543.]21>
> ExtendedMessageFormatTest.testExtendedAndBuiltInFormats:141 null 
> expected: JOHN DOE DOB: [23/01/07 Salary: R$ 12.345,]67> but was: [1/23/07 Salary: $12,345.]67>
> ExtendedMessageFormatTest.testOverriddenBuiltinFormat:253->checkBuiltInFormat:347->checkBuiltInFormat:376
> format Pattern=[1: {0,date}], locale=[null] expected:<1: [23/01/]2007> but
> was:<1: [Jan 23, ]2007>
> Tests run: 476, Failures: 5, Errors: 0, Skipped: 0
> [INFO] 
> 
> [INFO] BUILD FAILURE
> [INFO] 
> 
> [INFO] Total time: 11.385 s
> [INFO] Finished at: 2017-02-06T14:07:52-02:00
> [INFO] Final Memory: 30M/328M
> [INFO] 
> 
> {code}
> /* --- snip -- */
> Here's my env:
> Apache Maven 3.3.9
> Maven home: /usr/share/maven
> Java version: 1.8.0_111, vendor: Oracle Corporation
> Java home: /usr/lib/jvm/java-8-oracle/jre
> Default locale: en_US, platform encoding: UTF-8
> OS name: "linux", version: "4.4.0-59-generic", arch: "amd64", family: "unix"
> Even though the JVM locale seems to be set to en_US, I'm in Brazil right now
> with the time in Ubuntu set to local time, as well as the locale (or so I
> think). Here's my output of running the `locale` command.
> /* --- snip --- */
> $ locale
> LANG=en_US.UTF-8
> LANGUAGE=en_US
> LC_CTYPE=pt_BR.UTF-8
> LC_NUMERIC=pt_BR.UTF-8
> LC_TIME=pt_BR.UTF-8
> LC_COLLATE="en_US.UTF-8"
> LC_MONETARY=pt_BR.UTF-8
> LC_MESSAGES="en_US.UTF-8"
> LC_PAPER=pt_BR.UTF-8
> LC_NAME=pt_BR.UTF-8
> LC_ADDRESS=pt_BR.UTF-8
> LC_TELEPHONE=pt_BR.UTF-8
> LC_MEASUREMENT=pt_BR.UTF-8
> LC_IDENTIFICATION=pt_BR.UTF-8
> LC_ALL=
> /* --- snip --- */



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)


[jira] [Commented] (MATH-1403) Collinearity test: QR Decomposition rank incorrect (SVD ok)

2017-02-27 Thread Hugo Ferrira (JIRA)

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

Hugo Ferrira commented on MATH-1403:


Hello Gilles,

Thanks for the feedback. Unfortunately I am not knowledgeable enough to tackle 
this task.

Finally, I confirmed that the original R code uses the BLAS library. Its 
implementation
is also a rank revealing QR decomposition. What I find interesting is that the 
rank value
is obtained after the decomposition and no explicit function is called. So 
these 
don't seem to be implementations of the same algorithm. 

As I said, I don't know much about numerical methods. However, if someone can
point me to a simple description of an algorithm I could try and debug it. 

Thanks

> Collinearity test: QR Decomposition rank incorrect (SVD ok)
> ---
>
> Key: MATH-1403
> URL: https://issues.apache.org/jira/browse/MATH-1403
> Project: Commons Math
>  Issue Type: Bug
>Affects Versions: 3.6.1
> Environment: Linux ubuntu
> JDK 8
>Reporter: Hugo Ferrira
>
> Hello,
> I am aware that such a question have been asked before but I cannot seem to 
> solve this issue for a very simple example. The closest example I have is:
> https://issues.apache.org/jira/browse/MATH-1100
> from which I could not get an answer.
> I am trying to copy an algorithm from R's Caret package that identifies 
> collinear columns of a matrix [1]. I am assuming a "long" matrix and and am 
> using the trivial example from the reference above. However I cannot get this 
> to work because the QR's rank result is incorrect.
> I have the following example:
> import org.apache.commons.math3.linear.RealMatrix;
> import org.apache.commons.math3.linear.RRQRDecomposition;
> import org.apache.commons.math3.linear.Array2DRowRealMatrix;
> import org.apache.commons.math3.linear.SingularValueDecomposition ;
> public class QRIssue {
>   public static void main(String[] args) {
> double[][] am = new double[5][];
> double[] c1 = new double[] {1.0, 1.0, 1.0, 1.0, 1.0, 1.0} ;
> double[] c2 = new double[] {1.0, 1.0, 1.0, 0.0, 0.0, 0.0} ;
> double[] c3 = new double[] {0.0, 0.0, 0.0, 1.0, 1.0, 1.0} ;
> double[] c4 = new double[] {1.0, 0.0, 0.0, 1.0, 0.0, 0.0 } ;
> double[] c6 = new double[] {0.0, 0.0, 1.0, 0.0, 0.0, 1.0 } ;
> am[0] = c1 ;
> am[1] = c2 ;
> am[2] = c3 ;
> am[3] = c4 ;
> am[4] = c6 ;
> Double threshold = 1e-1;
> Array2DRowRealMatrix m = new Array2DRowRealMatrix( am, false )  ; // use 
> array, don't copy
> RRQRDecomposition qr = new RRQRDecomposition( m,  threshold) ;
> RealMatrix r = qr.getR() ;
> int numColumns = r.getColumnDimension() ;
> int rank = qr.getRank( threshold ) ;
> System.out.println("QR rank: " + rank) ;
> System.out.println("QR is singular: " + !qr.getSolver().isNonSingular()) ;
> System.out.println("QR is singular: " + (numColumns == rank) ) ;
> SingularValueDecomposition sv2 = new 
> org.apache.commons.math3.linear.SingularValueDecomposition(m);
> System.out.println("SVD rank: " + sv2.getRank()) ;
> }
> }
> For SVD I get a rank of 4 which is correct (columns 0,1,2 are collinear : c0 
> = c1 + c2). But for QR I get 5. I have tried several thresholds with no 
> success. For several subsets of the columns above (example only 0,1,2 I get 
> the correct answer). What am I doing wrong?
> TIA,
> Hugo F.
> 1. https://topepo.github.io/caret/pre-processing.html#lindep



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)