[jira] [Work logged] (NUMBERS-186) Lists of complex numbers
[ https://issues.apache.org/jira/browse/NUMBERS-186?focusedWorklogId=806850=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-806850 ] ASF GitHub Bot logged work on NUMBERS-186: -- Author: ASF GitHub Bot Created on: 07/Sep/22 22:52 Start Date: 07/Sep/22 22:52 Worklog Time Spent: 10m Work Description: aherbert commented on code in PR #123: URL: https://github.com/apache/commons-numbers/pull/123#discussion_r965359957 ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -166,20 +190,76 @@ private void setNoRangeCheck(int index, double real, double imaginary) { /** * {@inheritDoc} * - * @param element Complex element to be set. + * @param number Complex number to be set. */ @Override -public Complex set(int index, Complex element) { +public Complex set(int index, Complex number) { rangeCheck(index); final int i = index << 1; final Complex oldValue = Complex.ofCartesian(realAndImagParts[i], realAndImagParts[i + 1]); -setNoRangeCheck(index, element.getReal(), element.getImaginary()); +setNoRangeCheck(index, number.getReal(), number.getImaginary()); return oldValue; } +/** + * Replaces the complex number's real part at the specified position + * in the list with the specified real number. + * + * @param index Index of the complex number. + * @param real Real part \( a \) of the complex number \( (a +ib) \). + */ +public void setReal(int index, double real) { +rangeCheck(index); +final int i = index << 1; +realAndImagParts[i] = real; +} + +/** + * Replaces the complex number's imaginary part at the specified position + * in the list with the specified imaginary number. + * + * @param index Index of the complex number. + * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \). + */ +public void setImaginary(int index, double imaginary) { +rangeCheck(index); +final int i = index << 1; Review Comment: This index i should be inlined. ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -166,20 +190,76 @@ private void setNoRangeCheck(int index, double real, double imaginary) { /** * {@inheritDoc} * - * @param element Complex element to be set. + * @param number Complex number to be set. */ @Override -public Complex set(int index, Complex element) { +public Complex set(int index, Complex number) { rangeCheck(index); final int i = index << 1; final Complex oldValue = Complex.ofCartesian(realAndImagParts[i], realAndImagParts[i + 1]); -setNoRangeCheck(index, element.getReal(), element.getImaginary()); +setNoRangeCheck(index, number.getReal(), number.getImaginary()); return oldValue; } +/** + * Replaces the complex number's real part at the specified position + * in the list with the specified real number. + * + * @param index Index of the complex number. + * @param real Real part \( a \) of the complex number \( (a +ib) \). + */ +public void setReal(int index, double real) { +rangeCheck(index); +final int i = index << 1; Review Comment: This index i should be inlined. ## commons-numbers-complex-arrays/src/test/java/org/apache/commons/numbers/complex/arrays/ComplexListTest.java: ## @@ -152,9 +153,9 @@ void testAddIndexOutOfBoundExceptions() { @Test void testRemoveIndexOutOfBoundExceptions() { +List objectList = generateList(2); Review Comment: Since a lot of the tests now use generateList() then addAll to a new ComplexList instance this should be refactored into a method: `private static ComplexList generateComplexList(int)` Issue Time Tracking --- Worklog Id: (was: 806850) Time Spent: 2h 10m (was: 2h) > Lists of complex numbers > > > Key: NUMBERS-186 > URL: https://issues.apache.org/jira/browse/NUMBERS-186 > Project: Commons Numbers > Issue Type: Sub-task > Components: complex >Reporter: Alex Herbert >Assignee: Sumanth Sulur Rajkumar >Priority: Minor > Labels: gsoc, gsoc2022 > Time Spent: 2h 10m > Remaining Estimate: 0h > > Update the support for complex numbers in the {{complex}} package to allow > operations to be performed on lists of complex numbers. This requires > abstracting the representation of multiple complex numbers into a list > structure storing real and imaginary parts that can be efficiently iterated > to apply
[GitHub] [commons-numbers] aherbert commented on a diff in pull request #123: NUMBERS-186 added additional complex list operations
aherbert commented on code in PR #123: URL: https://github.com/apache/commons-numbers/pull/123#discussion_r965359957 ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -166,20 +190,76 @@ private void setNoRangeCheck(int index, double real, double imaginary) { /** * {@inheritDoc} * - * @param element Complex element to be set. + * @param number Complex number to be set. */ @Override -public Complex set(int index, Complex element) { +public Complex set(int index, Complex number) { rangeCheck(index); final int i = index << 1; final Complex oldValue = Complex.ofCartesian(realAndImagParts[i], realAndImagParts[i + 1]); -setNoRangeCheck(index, element.getReal(), element.getImaginary()); +setNoRangeCheck(index, number.getReal(), number.getImaginary()); return oldValue; } +/** + * Replaces the complex number's real part at the specified position + * in the list with the specified real number. + * + * @param index Index of the complex number. + * @param real Real part \( a \) of the complex number \( (a +ib) \). + */ +public void setReal(int index, double real) { +rangeCheck(index); +final int i = index << 1; +realAndImagParts[i] = real; +} + +/** + * Replaces the complex number's imaginary part at the specified position + * in the list with the specified imaginary number. + * + * @param index Index of the complex number. + * @param imaginary Imaginary part \( b \) of the complex number \( (a +ib) \). + */ +public void setImaginary(int index, double imaginary) { +rangeCheck(index); +final int i = index << 1; Review Comment: This index i should be inlined. ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -166,20 +190,76 @@ private void setNoRangeCheck(int index, double real, double imaginary) { /** * {@inheritDoc} * - * @param element Complex element to be set. + * @param number Complex number to be set. */ @Override -public Complex set(int index, Complex element) { +public Complex set(int index, Complex number) { rangeCheck(index); final int i = index << 1; final Complex oldValue = Complex.ofCartesian(realAndImagParts[i], realAndImagParts[i + 1]); -setNoRangeCheck(index, element.getReal(), element.getImaginary()); +setNoRangeCheck(index, number.getReal(), number.getImaginary()); return oldValue; } +/** + * Replaces the complex number's real part at the specified position + * in the list with the specified real number. + * + * @param index Index of the complex number. + * @param real Real part \( a \) of the complex number \( (a +ib) \). + */ +public void setReal(int index, double real) { +rangeCheck(index); +final int i = index << 1; Review Comment: This index i should be inlined. ## commons-numbers-complex-arrays/src/test/java/org/apache/commons/numbers/complex/arrays/ComplexListTest.java: ## @@ -152,9 +153,9 @@ void testAddIndexOutOfBoundExceptions() { @Test void testRemoveIndexOutOfBoundExceptions() { +List objectList = generateList(2); Review Comment: Since a lot of the tests now use generateList() then addAll to a new ComplexList instance this should be refactored into a method: `private static ComplexList generateComplexList(int)` -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-configuration] garydgregory merged pull request #206: Bump spotbugs from 4.7.0 to 4.7.2
garydgregory merged PR #206: URL: https://github.com/apache/commons-configuration/pull/206 -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[jira] [Resolved] (CONFIGURATION-797) exposed settings method for list delimiter handler in DefaultConversionHandler
[ https://issues.apache.org/jira/browse/CONFIGURATION-797?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gary D. Gregory resolved CONFIGURATION-797. --- Fix Version/s: 2.9.0 Resolution: Fixed This feature is now in git master but implemented differently. > exposed settings method for list delimiter handler in DefaultConversionHandler > -- > > Key: CONFIGURATION-797 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-797 > Project: Commons Configuration > Issue Type: Improvement >Affects Versions: 2.1.1 >Reporter: Shiyou xin >Priority: Minor > Fix For: 2.9.0 > > Attachments: CONFIGURATION-797.patch > > > currently, it's not easy to implements ConversionHandler and construct a > custom conversion handler. > exposed settings method for list delimiter handler in > DefaultConversionHandler.java, which could flexible set list delimiter as > comma, semicolon and so on, just setting listDelimiterHandler. -- This message was sent by Atlassian Jira (v8.20.10#820010)
[GitHub] [commons-configuration] dependabot[bot] commented on pull request #204: Bump checkstyle from 9.3 to 10.3.3
dependabot[bot] commented on PR #204: URL: https://github.com/apache/commons-configuration/pull/204#issuecomment-1239517220 OK, I won't notify you again about this release, but will get in touch when a new version is available. If you'd rather skip all updates until the next major or minor version, let me know by commenting `@dependabot ignore this major version` or `@dependabot ignore this minor version`. You can also ignore all major, minor, or patch releases for a dependency by adding an [`ignore` condition](https://docs.github.com/en/code-security/supply-chain-security/configuration-options-for-dependency-updates#ignore) with the desired `update_types` to your config file. If you change your mind, just re-open this PR and I'll resolve any conflicts on it. -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-configuration] garydgregory closed pull request #204: Bump checkstyle from 9.3 to 10.3.3
garydgregory closed pull request #204: Bump checkstyle from 9.3 to 10.3.3 URL: https://github.com/apache/commons-configuration/pull/204 -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-configuration] garydgregory merged pull request #205: Bump jackson-databind from 2.13.3 to 2.13.4
garydgregory merged PR #205: URL: https://github.com/apache/commons-configuration/pull/205 -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[GitHub] [commons-configuration] garydgregory commented on pull request #204: Bump checkstyle from 9.3 to 10.3.3
garydgregory commented on PR #204: URL: https://github.com/apache/commons-configuration/pull/204#issuecomment-1239500363 Close: Requires Java 11. -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[jira] [Updated] (CONFIGURATION-821) Upgrade snakeyaml to 1.31 due to CVE (optional dependency)
[ https://issues.apache.org/jira/browse/CONFIGURATION-821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gary D. Gregory updated CONFIGURATION-821: -- Summary: Upgrade snakeyaml to 1.31 due to CVE (optional dependency) (was: upgrade snakeyaml to 1.31 due to CVE (optional dependency)) > Upgrade snakeyaml to 1.31 due to CVE (optional dependency) > -- > > Key: CONFIGURATION-821 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-821 > Project: Commons Configuration > Issue Type: Improvement >Reporter: PJ Fanning >Priority: Major > Fix For: 2.9.0 > > > https://github.com/advisories/GHSA-3mc7-4q67-w48m -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Comment Edited] (CONFIGURATION-821) upgrade snakeyaml to 1.31 due to CVE (optional dependency)
[ https://issues.apache.org/jira/browse/CONFIGURATION-821?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17601348#comment-17601348 ] Gary D. Gregory edited comment on CONFIGURATION-821 at 9/7/22 2:52 PM: --- Already done in git master. {{commit 17d7fb1227df4e1e4f37d79ff0d1835e15d31082}} {{Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2022-09-02 09:04:06}} {{Committer: Bruno P. Kinoshita 2022-09-02 13:18:15}} {{Parent: f805f742b66a3046944c07c79e22c19e88449908 (Use GAV coordinates Maven Central coordinates to make sure to pick up the latest)}} {{Child: 4117b2050ab011f131d5a81c824bf89ddde303d4 (Bump actions/checkout from 3 to 3.0.2.)}} {{{}Branches: master, origin/HEAD, origin/master, upstream/master{}}}{{{}Bump snakeyaml from 1.30 to 1.31{}}}{{{}Bumps [snakeyaml](https://bitbucket.org/snakeyaml/snakeyaml) from 1.30 to 1.31.{}}} {{{}- [Commits](https://bitbucket.org/snakeyaml/snakeyaml/branches/compare/snakeyaml-1.31..snakeyaml-1.30){}}}{{{}---{}}} {{updated-dependencies:}} {{- dependency-name: org.yaml:snakeyaml}} {{ dependency-type: direct:production}} {{ update-type: version-update:semver-minor}} {{{}...{}}}{{{}Signed-off-by: dependabot[bot] {}}} was (Author: garydgregory): Already done in git master. > upgrade snakeyaml to 1.31 due to CVE (optional dependency) > -- > > Key: CONFIGURATION-821 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-821 > Project: Commons Configuration > Issue Type: Improvement >Reporter: PJ Fanning >Priority: Major > Fix For: 2.9.0 > > > https://github.com/advisories/GHSA-3mc7-4q67-w48m -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Resolved] (CONFIGURATION-821) upgrade snakeyaml to 1.31 due to CVE (optional dependency)
[ https://issues.apache.org/jira/browse/CONFIGURATION-821?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Gary D. Gregory resolved CONFIGURATION-821. --- Fix Version/s: 2.9.0 Resolution: Fixed Already done in git master. > upgrade snakeyaml to 1.31 due to CVE (optional dependency) > -- > > Key: CONFIGURATION-821 > URL: https://issues.apache.org/jira/browse/CONFIGURATION-821 > Project: Commons Configuration > Issue Type: Improvement >Reporter: PJ Fanning >Priority: Major > Fix For: 2.9.0 > > > https://github.com/advisories/GHSA-3mc7-4q67-w48m -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (IO-611) FilenameUtils.normalize does not sanitize multiple slashes after prefix
[ https://issues.apache.org/jira/browse/IO-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17601335#comment-17601335 ] Gary D. Gregory commented on IO-611: Hi [~urvanov] You must use GitHub to create a pull request: https://github.com/apache/commons-io > FilenameUtils.normalize does not sanitize multiple slashes after prefix > --- > > Key: IO-611 > URL: https://issues.apache.org/jira/browse/IO-611 > Project: Commons IO > Issue Type: Bug >Affects Versions: 2.6 >Reporter: Urvanov >Priority: Major > > FilenameUtils.#normalize states in javadoc that //foo//./bar becomes /foo/bar > {code:java} > System.out.println(FilenameUtils.normalize("//foo//./bar")); > System.out.println(FilenameUtils.normalize("foo.\\bar")); > {code} > Result: > {code:java} > //foo//bar > //foo//bar > {code} > So, javadoc says, that it should be /foo/bar. I think, that //foo is prefix, > so it should be //foo/bar. But in real life it becomes the third way > (//foo//bar). > > I think we should fix javadoc and the code. The correct result should be > //foo/bar -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Commented] (IO-611) FilenameUtils.normalize does not sanitize multiple slashes after prefix
[ https://issues.apache.org/jira/browse/IO-611?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17601318#comment-17601318 ] Urvanov commented on IO-611: [~ggregory] I made some changes, but how can I create merge request in [https://gitbox.apache.org/repos/asf/commons-io.git?] I don't have developer access to it. > FilenameUtils.normalize does not sanitize multiple slashes after prefix > --- > > Key: IO-611 > URL: https://issues.apache.org/jira/browse/IO-611 > Project: Commons IO > Issue Type: Bug >Affects Versions: 2.6 >Reporter: Urvanov >Priority: Major > > FilenameUtils.#normalize states in javadoc that //foo//./bar becomes /foo/bar > {code:java} > System.out.println(FilenameUtils.normalize("//foo//./bar")); > System.out.println(FilenameUtils.normalize("foo.\\bar")); > {code} > Result: > {code:java} > //foo//bar > //foo//bar > {code} > So, javadoc says, that it should be /foo/bar. I think, that //foo is prefix, > so it should be //foo/bar. But in real life it becomes the third way > (//foo//bar). > > I think we should fix javadoc and the code. The correct result should be > //foo/bar -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (CSV-304) Provide access methods for header and trailer comments
[ https://issues.apache.org/jira/browse/CSV-304?focusedWorklogId=806707=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-806707 ] ASF GitHub Bot logged work on CSV-304: -- Author: ASF GitHub Bot Created on: 07/Sep/22 13:28 Start Date: 07/Sep/22 13:28 Worklog Time Spent: 10m Work Description: pedro-w commented on PR #257: URL: https://github.com/apache/commons-csv/pull/257#issuecomment-1239390837 I noticed that github is parsing the Javadoc annotation `@since` as a username. I apologize to the owner of that account. Issue Time Tracking --- Worklog Id: (was: 806707) Time Spent: 40m (was: 0.5h) > Provide access methods for header and trailer comments > -- > > Key: CSV-304 > URL: https://issues.apache.org/jira/browse/CSV-304 > Project: Commons CSV > Issue Type: Improvement > Components: Parser >Affects Versions: 1.9.0 >Reporter: Peter Hull >Priority: Minor > Fix For: Discussion > > Attachments: header-comment.patch > > Time Spent: 40m > Remaining Estimate: 0h > > The Apache Commons CSV library can deal with comments by attaching the > comment to the following record. > It does not seem possible to access comments that are before the header line > ("header comments"), or after the last record ("trailer comments") > I feel this would be a useful enhancement to the current comment-handling > features of version 1.9. > I have not been able to find mention of this in other JIRA tickets. > I have attached a patch implementing this, for discussion purposes. (n.b. I > had trouble with git showing spurious ^M at the end of changed lines in > CSVParserTest.java which I could not get rid of) > This adds methods String CSVParser::getHeaderComment(), String > CSVParser::getTrailerComment(), bool CSVParser::hasHeaderComment() and bool > CSVParser::hasTrailerComment() . The last two could be omitted assuming a > missing comment would return a null String. > > See also > [https://stackoverflow.com/questions/72619095/get-leading-comments-from-csv-with-apache-commons-csv] > and [https://lists.apache.org/thread/8tczpqlnjgbcyovyhb484tt11vqv91jt] -- This message was sent by Atlassian Jira (v8.20.10#820010)
[GitHub] [commons-csv] pedro-w commented on pull request #257: [CSV-304] Accessors for header/trailer comments
pedro-w commented on PR #257: URL: https://github.com/apache/commons-csv/pull/257#issuecomment-1239390837 I noticed that github is parsing the Javadoc annotation `@since` as a username. I apologize to the owner of that account. -- 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: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org
[jira] [Created] (CONFIGURATION-821) upgrade snakeyaml to 1.31 due to CVE (optional dependency)
PJ Fanning created CONFIGURATION-821: Summary: upgrade snakeyaml to 1.31 due to CVE (optional dependency) Key: CONFIGURATION-821 URL: https://issues.apache.org/jira/browse/CONFIGURATION-821 Project: Commons Configuration Issue Type: Improvement Reporter: PJ Fanning https://github.com/advisories/GHSA-3mc7-4q67-w48m -- This message was sent by Atlassian Jira (v8.20.10#820010)
[jira] [Work logged] (NUMBERS-186) Lists of complex numbers
[ https://issues.apache.org/jira/browse/NUMBERS-186?focusedWorklogId=806646=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-806646 ] ASF GitHub Bot logged work on NUMBERS-186: -- Author: ASF GitHub Bot Created on: 07/Sep/22 10:27 Start Date: 07/Sep/22 10:27 Worklog Time Spent: 10m Work Description: aherbert commented on code in PR #123: URL: https://github.com/apache/commons-numbers/pull/123#discussion_r964653374 ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -348,4 +433,25 @@ public void replaceAll(ComplexUnaryOperator operator) { } modCount++; } + +/** + * Replaces each element of the list with the result of applying the action to that element. Review Comment: This javadoc is wrong. Look at the javadoc for `forEach(Consumer)` and adapt as appropriate. ## commons-numbers-complex-arrays/src/test/java/org/apache/commons/numbers/complex/arrays/ComplexListTest.java: ## @@ -223,6 +224,71 @@ void testReplaceAllComplexScalarFunction() { Assertions.assertEquals(objectList, actualList); } +@Test +void testReplaceAllComplexConsumer() { +List data1 = generateList(10); +ArrayList actual1 = new ArrayList<>(); +ComplexList expected = new ComplexList(); +expected.addAll(data1); +Assertions.assertThrows(NullPointerException.class, () -> expected.forEach((ComplexConsumer) null)); +expected.forEach((real, imaginary) -> actual1.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected, actual1); + +//Testing case of when list is empty +List data2 = new ArrayList<>(); +ArrayList actual2 = new ArrayList<>(); +ComplexList expected2 = new ComplexList(); +expected2.addAll(data2); +expected2.forEach((real, imaginary) -> actual2.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected2, actual2); +} + +@Test +void testGetRealAndImaginary() { +ComplexList list = new ComplexList(); +list.add(Complex.ofCartesian(42, 13)); +list.addAll(1, list); Review Comment: Please stop creating larger lists using duplication. The list elements should be unique. Create the list using random complex numbers or a sequence. ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -149,6 +151,30 @@ public Complex get(int index) { return Complex.ofCartesian(realAndImagParts[i], realAndImagParts[i + 1]); } +/** + * Gets the real part \( a \) of the complex number \( (a + i b) \) at the indexed position of the list. + * + * @param index Index of the element's real part to get. Review Comment: `Index of the complex number.` ## commons-numbers-complex-arrays/src/test/java/org/apache/commons/numbers/complex/arrays/ComplexListTest.java: ## @@ -223,6 +224,71 @@ void testReplaceAllComplexScalarFunction() { Assertions.assertEquals(objectList, actualList); } +@Test +void testReplaceAllComplexConsumer() { +List data1 = generateList(10); +ArrayList actual1 = new ArrayList<>(); +ComplexList expected = new ComplexList(); +expected.addAll(data1); +Assertions.assertThrows(NullPointerException.class, () -> expected.forEach((ComplexConsumer) null)); +expected.forEach((real, imaginary) -> actual1.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected, actual1); + +//Testing case of when list is empty +List data2 = new ArrayList<>(); +ArrayList actual2 = new ArrayList<>(); +ComplexList expected2 = new ComplexList(); +expected2.addAll(data2); +expected2.forEach((real, imaginary) -> actual2.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected2, actual2); +} + +@Test +void testGetRealAndImaginary() { +ComplexList list = new ComplexList(); +list.add(Complex.ofCartesian(42, 13)); +list.addAll(1, list); +list.addAll(list); +list.set(2, Complex.ofCartesian(200, 1)); +for (int i = 0; i < list.size(); i++) { +Assertions.assertEquals(list.get(i).getReal(), list.getReal(i)); +} +for (int i = 0; i < list.size(); i++) { +Assertions.assertEquals(list.get(i).getImaginary(), list.getImaginary(i)); +} +} + +@Test +void testSetRealAndImaginary() { +ComplexList list = new ComplexList(); +list.add(Complex.ofCartesian(42, 13)); +list.addAll(1, list); +list.addAll(list); +list.setReal(2, 200); +list.setImaginary(2, 1); +
[GitHub] [commons-numbers] aherbert commented on a diff in pull request #123: NUMBERS-186 added additional complex list operations
aherbert commented on code in PR #123: URL: https://github.com/apache/commons-numbers/pull/123#discussion_r964653374 ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -348,4 +433,25 @@ public void replaceAll(ComplexUnaryOperator operator) { } modCount++; } + +/** + * Replaces each element of the list with the result of applying the action to that element. Review Comment: This javadoc is wrong. Look at the javadoc for `forEach(Consumer)` and adapt as appropriate. ## commons-numbers-complex-arrays/src/test/java/org/apache/commons/numbers/complex/arrays/ComplexListTest.java: ## @@ -223,6 +224,71 @@ void testReplaceAllComplexScalarFunction() { Assertions.assertEquals(objectList, actualList); } +@Test +void testReplaceAllComplexConsumer() { +List data1 = generateList(10); +ArrayList actual1 = new ArrayList<>(); +ComplexList expected = new ComplexList(); +expected.addAll(data1); +Assertions.assertThrows(NullPointerException.class, () -> expected.forEach((ComplexConsumer) null)); +expected.forEach((real, imaginary) -> actual1.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected, actual1); + +//Testing case of when list is empty +List data2 = new ArrayList<>(); +ArrayList actual2 = new ArrayList<>(); +ComplexList expected2 = new ComplexList(); +expected2.addAll(data2); +expected2.forEach((real, imaginary) -> actual2.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected2, actual2); +} + +@Test +void testGetRealAndImaginary() { +ComplexList list = new ComplexList(); +list.add(Complex.ofCartesian(42, 13)); +list.addAll(1, list); Review Comment: Please stop creating larger lists using duplication. The list elements should be unique. Create the list using random complex numbers or a sequence. ## commons-numbers-complex-arrays/src/main/java/org/apache/commons/numbers/complex/arrays/ComplexList.java: ## @@ -149,6 +151,30 @@ public Complex get(int index) { return Complex.ofCartesian(realAndImagParts[i], realAndImagParts[i + 1]); } +/** + * Gets the real part \( a \) of the complex number \( (a + i b) \) at the indexed position of the list. + * + * @param index Index of the element's real part to get. Review Comment: `Index of the complex number.` ## commons-numbers-complex-arrays/src/test/java/org/apache/commons/numbers/complex/arrays/ComplexListTest.java: ## @@ -223,6 +224,71 @@ void testReplaceAllComplexScalarFunction() { Assertions.assertEquals(objectList, actualList); } +@Test +void testReplaceAllComplexConsumer() { +List data1 = generateList(10); +ArrayList actual1 = new ArrayList<>(); +ComplexList expected = new ComplexList(); +expected.addAll(data1); +Assertions.assertThrows(NullPointerException.class, () -> expected.forEach((ComplexConsumer) null)); +expected.forEach((real, imaginary) -> actual1.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected, actual1); + +//Testing case of when list is empty +List data2 = new ArrayList<>(); +ArrayList actual2 = new ArrayList<>(); +ComplexList expected2 = new ComplexList(); +expected2.addAll(data2); +expected2.forEach((real, imaginary) -> actual2.add(Complex.ofCartesian(real, imaginary))); +Assertions.assertEquals(expected2, actual2); +} + +@Test +void testGetRealAndImaginary() { +ComplexList list = new ComplexList(); +list.add(Complex.ofCartesian(42, 13)); +list.addAll(1, list); +list.addAll(list); +list.set(2, Complex.ofCartesian(200, 1)); +for (int i = 0; i < list.size(); i++) { +Assertions.assertEquals(list.get(i).getReal(), list.getReal(i)); +} +for (int i = 0; i < list.size(); i++) { +Assertions.assertEquals(list.get(i).getImaginary(), list.getImaginary(i)); +} +} + +@Test +void testSetRealAndImaginary() { +ComplexList list = new ComplexList(); +list.add(Complex.ofCartesian(42, 13)); +list.addAll(1, list); +list.addAll(list); +list.setReal(2, 200); +list.setImaginary(2, 1); +Assertions.assertEquals(Complex.ofCartesian(200, 1), list.get(2)); Review Comment: Test set at all positions: ```Java for (int i = 0; i < list.size(); i++) { final double value = Math.PI * i; list.setReal(i, value); Assertions.assertEquals(value, list.get(i).getReal()); } ``` Also test set/get with invalid index positions (-1, size, size+1). ##
[jira] [Created] (CONFIGURATION-820) INIConfiguration: Sections containing a "." (dot) in the name write only 1 property even if there are 2 set
Reinhold Degenfellner created CONFIGURATION-820: --- Summary: INIConfiguration: Sections containing a "." (dot) in the name write only 1 property even if there are 2 set Key: CONFIGURATION-820 URL: https://issues.apache.org/jira/browse/CONFIGURATION-820 Project: Commons Configuration Issue Type: Bug Affects Versions: 2.8.0, 2.7 Environment: Java 17 Reporter: Reinhold Degenfellner The code below reproduces the Problem. {code:java} @Test public void t() throws IOException, ConfigurationException { var authSvn = new INIConfiguration(); var groups = authSvn.getSection("sec.sec"); groups.setProperty("p1", "val1"); groups.setProperty("p2", "val2"); authSvn.setSeparatorUsedInOutput("="); authSvn.write(new FileWriter(TEST_RESOURCES_OUTPUT + "sec.ini")); } {code} The expected output file content is: {code:java} [sec.sec] p1=val1 p2=val2 {code} The actual output is: {code:java} [sec.sec] p1=val1 {code} The second property is missing. If I remove the dot from the section name the second property is written to the file. -- This message was sent by Atlassian Jira (v8.20.10#820010)