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

Clean indexed terms when removing an equation #808

Merged
merged 2 commits into from
Jun 30, 2023

Conversation

geofjamg
Copy link
Member

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?

Bug fix

What is the current behavior?

When an equation is removed, corresponding indexed terms are not cleaned.

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

  • The Breaking Change or Deprecated label has been added
  • The migration guide has been updated in the github wiki (What changes might users need to make in their application due to this PR?)

Other information:

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@gmail.com>
@geofjamg geofjamg requested a review from annetill June 28, 2023 19:03
@geofjamg geofjamg added the bug Something isn't working label Jun 28, 2023
@@ -152,6 +152,14 @@ public Equation<V, E> removeEquation(int num, E type) {
if (equation != null) {
Pair<ElementType, Integer> element = Pair.of(type.getElementType(), num);
equationsByElement.get(element).remove(equation);
if (equationTermsByElement != null) {
Copy link
Member

@annetill annetill Jun 30, 2023

Choose a reason for hiding this comment

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

This is not working on my case and I don't know exactly why. If I put

    public Equation<V, E> removeEquation(int num, E type) {
        Pair<Integer, E> p = Pair.of(num, type);
        Equation<V, E> equation = equations.remove(p);
        if (equation != null) {
            Pair<ElementType, Integer> element = Pair.of(type.getElementType(), num);
            equationsByElement.get(element).remove(equation);
            equationTermsByElement = null;
            indexAllTerms();
            notifyEquationChange(equation, EquationEventType.EQUATION_REMOVED);
        }
        return equation;
    }

Copy link
Member Author

Choose a reason for hiding this comment

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

it is supposed to be equivalent but faster. The way you did it reindex everything which would be very slow.

Copy link
Member Author

Choose a reason for hiding this comment

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

looking at test case I did, does it seem ok?

Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

91.7% 91.7% Coverage
0.0% 0.0% Duplication

@geofjamg geofjamg merged commit c4d6405 into main Jun 30, 2023
@geofjamg geofjamg deleted the clean_terms_equation_remove branch June 30, 2023 07:43
jeandemanged pushed a commit that referenced this pull request Jul 18, 2023
Signed-off-by: Geoffroy Jamgotchian <geoffroy.jamgotchian@rte-france.com>
(cherry picked from commit c4d6405)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants