Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new type of NodeCalc to compute Min/Max between timeseries #2820

Merged
merged 17 commits into from
Dec 18, 2023

Conversation

rolnico
Copy link
Member

@rolnico rolnico commented Dec 5, 2023

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

No

What kind of change does this PR introduce?

Feature

What is the current behavior?

Using NodeCalc, it is only possible to get timeseries["foo"].min(comparedValue) the minimum between comparedValue and the values of the timeseries.

What is the new behavior (if this is a feature change)?
It is now possible to get the minimal value(s) between two timeseries using min(timeseries["foo"], timeseries["bar"]) in a groovy script

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

If yes, please check if the following requirements are fulfilled

  • The Breaking Change or Deprecated label has been added
  • The migration steps are described in the following section

What changes might users need to make in their application due to this PR? (migration steps)

Other information:

Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
@rolnico rolnico requested review from geofjamg and olperr1 December 7, 2023 10:08
assertEquals(Sets.newHashSet(1), tsCalc.getVersions());

List<DoubleTimeSeries> tsLs = Arrays.asList(ts, tsCalc);
List<DoubleTimeSeries> tsLs = Arrays.asList(ts, tsCalc, tsCalcMin, tsCalcMax);
String json = TimeSeries.toJson(tsLs);
String jsonRef = String.join(System.lineSeparator(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have text blocks in Java 17, we can do it much simpler and cleaner.
Maybe should be done in another PR.

@@ -52,4 +48,8 @@ public interface NodeCalcVisitor<R, A> {
R visit(TimeSeriesNameNodeCalc nodeCalc, A arg);

R visit(TimeSeriesNumNodeCalc nodeCalc, A arg);

R visit(AbstractBinaryNodeCal nodeCalc, A arg, R left, R right);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should continue with same design that previous by having in the visitor only child node and not abstracts. As you can see, as doing that you need to lot of instanceof check in all implementations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -8,6 +8,7 @@ package com.powsybl.timeseries.dsl

import com.powsybl.commons.PowsyblException
import com.powsybl.timeseries.ast.BigDecimalNodeCalc
import com.powsybl.timeseries.ast.BinaryMinCalc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Signed-off-by: Nicolas Rol <nicolas.rol@rte-france.com>
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions

5.1% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@geofjamg geofjamg merged commit 3a3190f into main Dec 18, 2023
5 of 6 checks passed
@geofjamg geofjamg deleted the nro/calculated_minmax_timeseries branch December 18, 2023 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants