Skip to content

Commit

Permalink
refactor(local): reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
salemsd committed Dec 11, 2024
1 parent 7b9cc41 commit f87348c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
17 changes: 6 additions & 11 deletions src/antares/service/local_services/binding_constraint_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

import numpy as np
import pandas as pd
from pydantic import ValidationError, Field

from pydantic import Field

from antares.config.local_configuration import LocalConfiguration
from antares.exceptions.exceptions import BindingConstraintCreationError, ConstraintTermAdditionError
from antares.exceptions.exceptions import BindingConstraintCreationError
from antares.model.binding_constraint import (
BindingConstraint,
BindingConstraintFrequency,
Expand Down Expand Up @@ -116,13 +117,11 @@ def _create_local_property_args(constraint: BindingConstraint) -> dict[str, Unio
"constraint_name": constraint.name,
"constraint_id": constraint.id,
"terms": constraint.get_terms(),
**constraint.properties.model_dump(mode="json", exclude_none=True)
**constraint.properties.model_dump(mode="json", exclude_none=True),
}

def _generate_local_properties(self, constraint: BindingConstraint) -> BindingConstraintPropertiesLocal:
return BindingConstraintPropertiesLocal.model_validate(
self._create_local_property_args(constraint)
)
return BindingConstraintPropertiesLocal.model_validate(self._create_local_property_args(constraint))

def _store_time_series(
self,
Expand Down Expand Up @@ -188,11 +187,7 @@ def _write_binding_constraint_ini(
# Persist the updated INI content
self.ini_file.write_ini_file()
else:
terms_dict = {term.id: term for term in terms} if terms else {}

full_properties = BindingConstraintPropertiesLocal(
**local_properties.model_dump()
)
full_properties = BindingConstraintPropertiesLocal(**local_properties.model_dump())

section_index = len(current_ini_content)
current_ini_content[str(section_index)] = full_properties.list_ini_fields
Expand Down
3 changes: 1 addition & 2 deletions tests/antares/services/local_services/test_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
from antares.model.settings.thematic_trimming import DefaultThematicTrimmingParameters, ThematicTrimmingParametersLocal
from antares.model.study import create_study_local
from antares.service.local_services.area_local import AreaLocalService
from antares.service.local_services.binding_constraint_local import BindingConstraintPropertiesLocal
from antares.service.local_services.link_local import LinkLocalService
from antares.service.local_services.renewable_local import RenewableLocalService
from antares.service.local_services.st_storage_local import ShortTermStorageLocalService
Expand Down Expand Up @@ -2285,4 +2284,4 @@ def test_submitted_time_series_is_saved(self, local_study):
actual_time_series = pd.read_csv(actual_file_path, sep="\t", header=None, dtype=float)

# Then
assert actual_time_series.equals(expected_time_series)
assert actual_time_series.equals(expected_time_series)

0 comments on commit f87348c

Please sign in to comment.