[GitHub] metron pull request #651: METRON-1037 Added POWER function
Github user mattf-horton commented on a diff in the pull request: https://github.com/apache/metron/pull/651#discussion_r127277799 --- Diff: metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java --- @@ -60,4 +60,38 @@ public boolean isInitialized() { } } + @Stellar(name="POWER" + ,description="Raises the number to a given power" + ,params = { + "number - the number", + "power - the exponent to raise the number to" + } + , returns="The power-th power of the number passed in." --- End diff -- ditto: "The value of number to the given power." --- 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] metron pull request #651: METRON-1037 Added POWER function
Github user mattf-horton commented on a diff in the pull request: https://github.com/apache/metron/pull/651#discussion_r127279766 --- Diff: metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/MathFunctionsTest.java --- @@ -44,4 +44,16 @@ public void testAbs() { Assert.assertEquals((Double)run("ABS(value)", ImmutableMap.of("value", -10.5)), 10.5, 1e-7); } + @Test + public void testPower() { +Assert.assertEquals((Double)run("POWER(e,b)", ImmutableMap.of("e", 2.0, "b", 2.0)), 4.0, 1e-7 ); --- End diff -- Please put expected value first, test result value second, in assertEquals() calls. Otherwise reported failures look funny. --- 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] metron pull request #651: METRON-1037 Added POWER function
Github user mattf-horton commented on a diff in the pull request: https://github.com/apache/metron/pull/651#discussion_r127279153 --- Diff: metron-stellar/stellar-common/src/test/java/org/apache/metron/stellar/dsl/functions/MathFunctionsTest.java --- @@ -44,4 +44,16 @@ public void testAbs() { Assert.assertEquals((Double)run("ABS(value)", ImmutableMap.of("value", -10.5)), 10.5, 1e-7); } + @Test + public void testPower() { +Assert.assertEquals((Double)run("POWER(e,b)", ImmutableMap.of("e", 2.0, "b", 2.0)), 4.0, 1e-7 ); +Assert.assertTrue(Double.isNaN((Double)run("ABS(value)", ImmutableMap.of("e", Double.NaN, "b", 2.0; +Assert.assertTrue(Double.isNaN((Double)run("ABS(value)", ImmutableMap.of("e", 2.0, "b", Double.NaN; +Assert.assertTrue(Double.isNaN((Double)run("ABS(value)", ImmutableMap.of("e", Double.NaN, "b", Double.NaN; + --- End diff -- Were these 3 lines supposed to be POWER(e,b) invocations rather than ABS(value)? --- 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] metron pull request #651: METRON-1037 Added POWER function
Github user mattf-horton commented on a diff in the pull request: https://github.com/apache/metron/pull/651#discussion_r127277470 --- Diff: metron-stellar/stellar-common/README.md --- @@ -518,6 +519,13 @@ In the core language functions, we support basic functional programming primitiv * dateTime - The datetime as a long representing the milliseconds since unix epoch * Returns: The current month (0-based). +### `POWER` + * Description: Raises the number to a given power. + * Input: +* number - the number +* power - the exponent to raise the number to + * Returns: The power-th power of the number passed in. --- End diff -- Suggest: Returns: The value of number to the given power. --- 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] metron pull request #651: METRON-1037 Added POWER function
Github user simonellistonball closed the pull request at: https://github.com/apache/metron/pull/651 --- 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] metron pull request #651: METRON-1037 Added POWER function
Github user cestella commented on a diff in the pull request: https://github.com/apache/metron/pull/651#discussion_r127263511 --- Diff: metron-stellar/stellar-common/src/main/java/org/apache/metron/stellar/dsl/functions/MathFunctions.java --- @@ -60,4 +60,38 @@ public boolean isInitialized() { } } + @Stellar(name="POWER" --- End diff -- can we call it POW? --- 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] metron pull request #651: METRON-1037 Added POWER function
GitHub user simonellistonball opened a pull request: https://github.com/apache/metron/pull/651 METRON-1037 Added POWER function ## Contributor Comments This is a quick addition to the Math functions. It may be worth revising following the work @cestella did this morning to add a more general implementation on top of #650 I will probably add 2 argument capabilities and port this work to #650 when it's in once that is in. ### For all changes: - [x] Is there a JIRA ticket associated with this PR? If not one needs to be created at [Metron Jira](https://issues.apache.org/jira/browse/METRON/?selectedTab=com.atlassian.jira.jira-projects-plugin:summary-panel). - [x] Does your PR title start with METRON- where is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character. - [x] Has your PR been rebased against the latest commit within the target branch (typically master)? ### For code changes: - [x] Have you included steps to reproduce the behavior or problem that is being changed or addressed? - [x] Have you included steps or a guide to how the change may be verified and tested manually? - [x] Have you ensured that the full suite of tests and checks have been executed in the root metron folder via: ``` mvn -q clean integration-test install && build_utils/verify_licenses.sh ``` - [x] Have you written or updated unit tests and or integration tests to verify your changes? - [x] Have you verified the basic functionality of the build by building and running locally with Vagrant full-dev environment or the equivalent? ### For documentation related changes: - [x] Have you ensured that format looks appropriate for the output in which it is rendered by building and verifying the site-book? If not then run the following commands and the verify changes via `site-book/target/site/index.html`: ``` cd site-book mvn site ``` You can merge this pull request into a Git repository by running: $ git pull https://github.com/simonellistonball/incubator-metron METRON-1037 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/metron/pull/651.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 #651 commit 3e784245576d28ba275b1d4b3cf98347ea13f14f Author: Simon Elliston BallDate: 2017-07-13T00:51:44Z Added POWER function --- 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. ---