Skip to content

Commit

Permalink
Merge pull request #823 from PowerGridModel/release/v1.10.0-rc
Browse files Browse the repository at this point in the history
Release/v1.10.x
  • Loading branch information
mgovers authored Nov 11, 2024
2 parents 553bae0 + 5e16d13 commit 1c8139c
Show file tree
Hide file tree
Showing 37 changed files with 391 additions and 370 deletions.
1 change: 0 additions & 1 deletion .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ concurrency:

jobs:
sonar-cloud:
if: (github.event_name == 'push') || (!startsWith(github.head_ref, 'release'))
name: SonarCloud
runs-on: ubuntu-24.04
env:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9
1.10
17 changes: 9 additions & 8 deletions docs/examples/Power Flow Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -447,8 +447,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"List of component types in result dataset and associated data types\n",
"{'ComponentType.node': <class 'numpy.ndarray'>, 'ComponentType.line': <class 'dict'>, 'ComponentType.sym_load': <class 'dict'>}\n",
"List of component types in result dataset\n",
"[<ComponentType.node: 'node'>, <ComponentType.line: 'line'>, <ComponentType.sym_load: 'sym_load'>]\n",
"------node result------\n",
"('id', 'energized', 'u_pu', 'u', 'u_angle', 'p', 'q')\n",
"------line result attributes------\n",
Expand All @@ -471,8 +471,8 @@
" },\n",
")\n",
"\n",
"print(\"List of component types in result dataset and associated data types\")\n",
"print({str(component_type): type(component_data) for component_type, component_data in output_data.items()})\n",
"print(\"List of component types in result dataset\")\n",
"print(list(output_data.keys()))\n",
"print(\"------node result------\")\n",
"print(output_data[ComponentType.node].dtype.names)\n",
"print(\"------line result attributes------\")\n",
Expand All @@ -499,8 +499,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"List of component types in result dataset and associated data types\n",
"{'ComponentType.node': <class 'dict'>, 'ComponentType.line': <class 'dict'>, 'ComponentType.sym_load': <class 'dict'>, 'ComponentType.source': <class 'dict'>}\n",
"List of component types in result dataset\n",
"[<ComponentType.node: 'node'>, <ComponentType.line: 'line'>, <ComponentType.sym_load: 'sym_load'>, <ComponentType.source: 'source'>]\n",
"------node result------\n",
"['id', 'energized', 'u_pu', 'u', 'u_angle', 'p', 'q']\n",
"------line result attributes------\n",
Expand All @@ -519,8 +519,8 @@
" output_component_types=ComponentAttributeFilterOptions.everything, # all attributes for all component types as columns\n",
")\n",
"\n",
"print(\"List of component types in result dataset and associated data types\")\n",
"print({str(component_type): type(component_data) for component_type, component_data in output_data.items()})\n",
"print(\"List of component types in result dataset\")\n",
"print(list(output_data.keys()))\n",
"print(\"------node result------\")\n",
"print(list(output_data[ComponentType.node].keys()))\n",
"print(\"------line result attributes------\")\n",
Expand Down Expand Up @@ -1430,6 +1430,7 @@
"# we run the batch calculation with continue_on_batch_error=True,\n",
"# it will return the results with partially valid data\n",
"\n",
"\n",
"output_data = model.calculate_power_flow(update_data=time_series_mutation, continue_on_batch_error=True)\n",
"\n",
"# print node data for u_pu, note that the data is rubbish for scenario 3 and 7\n",
Expand Down
4 changes: 2 additions & 2 deletions docs/examples/Validation Examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mIDWrongType\u001b[0m Traceback (most recent call last)",
"Cell \u001b[0;32mIn[2], line 2\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;66;03m# Without validation\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m model \u001b[38;5;241m=\u001b[39m \u001b[43mPowerGridModel\u001b[49m\u001b[43m(\u001b[49m\u001b[43merror_data\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 3\u001b[0m output_data \u001b[38;5;241m=\u001b[39m model\u001b[38;5;241m.\u001b[39mcalculate_state_estimation(symmetric\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m)\n",
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/core/power_grid_model.py:125\u001b[0m, in \u001b[0;36mPowerGridModel.__init__\u001b[0;34m(self, input_data, system_frequency)\u001b[0m\n\u001b[1;32m 123\u001b[0m prepared_input \u001b[38;5;241m=\u001b[39m prepare_input_view(_map_to_component_types(input_data))\n\u001b[1;32m 124\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_model_ptr \u001b[38;5;241m=\u001b[39m pgc\u001b[38;5;241m.\u001b[39mcreate_model(system_frequency, input_data\u001b[38;5;241m=\u001b[39mprepared_input\u001b[38;5;241m.\u001b[39mget_dataset_ptr())\n\u001b[0;32m--> 125\u001b[0m \u001b[43massert_no_error\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 126\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_all_component_count \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m prepared_input\u001b[38;5;241m.\u001b[39mget_info()\u001b[38;5;241m.\u001b[39mtotal_elements()\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m}\n",
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/core/error_handling.py:169\u001b[0m, in \u001b[0;36massert_no_error\u001b[0;34m(batch_size, decode_error)\u001b[0m\n\u001b[1;32m 167\u001b[0m error \u001b[38;5;241m=\u001b[39m find_error(batch_size\u001b[38;5;241m=\u001b[39mbatch_size, decode_error\u001b[38;5;241m=\u001b[39mdecode_error)\n\u001b[1;32m 168\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m error \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 169\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error\n",
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/_core/power_grid_model.py:125\u001b[0m, in \u001b[0;36mPowerGridModel.__init__\u001b[0;34m(self, input_data, system_frequency)\u001b[0m\n\u001b[1;32m 123\u001b[0m prepared_input \u001b[38;5;241m=\u001b[39m prepare_input_view(_map_to_component_types(input_data))\n\u001b[1;32m 124\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_model_ptr \u001b[38;5;241m=\u001b[39m pgc\u001b[38;5;241m.\u001b[39mcreate_model(system_frequency, input_data\u001b[38;5;241m=\u001b[39mprepared_input\u001b[38;5;241m.\u001b[39mget_dataset_ptr())\n\u001b[0;32m--> 125\u001b[0m \u001b[43massert_no_error\u001b[49m\u001b[43m(\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 126\u001b[0m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_all_component_count \u001b[38;5;241m=\u001b[39m {k: v \u001b[38;5;28;01mfor\u001b[39;00m k, v \u001b[38;5;129;01min\u001b[39;00m prepared_input\u001b[38;5;241m.\u001b[39mget_info()\u001b[38;5;241m.\u001b[39mtotal_elements()\u001b[38;5;241m.\u001b[39mitems() \u001b[38;5;28;01mif\u001b[39;00m v \u001b[38;5;241m>\u001b[39m \u001b[38;5;241m0\u001b[39m}\n",
"File \u001b[0;32m~/pgm/power-grid-model/src/power_grid_model/_core/error_handling.py:169\u001b[0m, in \u001b[0;36massert_no_error\u001b[0;34m(batch_size, decode_error)\u001b[0m\n\u001b[1;32m 167\u001b[0m error \u001b[38;5;241m=\u001b[39m find_error(batch_size\u001b[38;5;241m=\u001b[39mbatch_size, decode_error\u001b[38;5;241m=\u001b[39mdecode_error)\n\u001b[1;32m 168\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m error \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;129;01mnot\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[0;32m--> 169\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m error\n",
"\u001b[0;31mIDWrongType\u001b[0m: Wrong type for object with id 4\n\nTry validate_input_data() or validate_batch_data() to validate your data.\n"
]
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def generate_build_ext(pkg_dir: Path, pkg_name: str):
# list of extensions
exts = [
CTypesExtension(
name="power_grid_model.core._power_grid_core",
name="power_grid_model._core._power_grid_core",
sources=sources,
include_dirs=include_dirs,
library_dirs=library_dirs,
Expand Down
6 changes: 3 additions & 3 deletions src/power_grid_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

"""Power Grid Model"""

from power_grid_model.core.dataset_definitions import ComponentType, DatasetType
from power_grid_model.core.power_grid_meta import initialize_array, power_grid_meta_data
from power_grid_model.core.power_grid_model import PowerGridModel
from power_grid_model._core.dataset_definitions import ComponentType, DatasetType
from power_grid_model._core.power_grid_meta import initialize_array, power_grid_meta_data
from power_grid_model._core.power_grid_model import PowerGridModel
from power_grid_model.enum import (
Branch3Side,
BranchSide,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,22 @@
Power grid model buffer handler
"""

import warnings
from dataclasses import dataclass
from typing import cast

import numpy as np

from power_grid_model._core.error_handling import VALIDATOR_MSG
from power_grid_model._core.index_integer import IdxC, IdxNp
from power_grid_model._core.power_grid_core import IdxPtr, VoidPtr
from power_grid_model._core.power_grid_meta import ComponentMetaData
from power_grid_model._utils import (
_extract_data_from_component_data,
_extract_indptr,
check_indptr_consistency,
is_columnar,
is_sparse,
)
from power_grid_model.core.error_handling import VALIDATOR_MSG
from power_grid_model.core.index_integer import IdxC, IdxNp
from power_grid_model.core.power_grid_core import IdxPtr, VoidPtr
from power_grid_model.core.power_grid_meta import ComponentMetaData
from power_grid_model.data_types import (
AttributeType,
ComponentData,
Expand Down Expand Up @@ -85,7 +84,7 @@ def _get_raw_data_view(data: np.ndarray, dtype: np.dtype) -> VoidPtr:
a raw view on the data set.
"""
if data.dtype != dtype:
warnings.warn(f"Data type does not match schema. {VALIDATOR_MSG}", DeprecationWarning)
raise ValueError(f"Data type does not match schema. {VALIDATOR_MSG}")
return np.ascontiguousarray(data, dtype=dtype).ctypes.data_as(VoidPtr)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

import numpy as np

from power_grid_model._core.dataset_definitions import ComponentType, DatasetType
from power_grid_model._core.power_grid_dataset import CConstDataset, CMutableDataset
from power_grid_model._core.power_grid_meta import initialize_array, power_grid_meta_data
from power_grid_model._utils import process_data_filter
from power_grid_model.core.dataset_definitions import ComponentType, DatasetType
from power_grid_model.core.power_grid_dataset import CConstDataset, CMutableDataset
from power_grid_model.core.power_grid_meta import initialize_array, power_grid_meta_data
from power_grid_model.data_types import Dataset, SingleDataset
from power_grid_model.enum import CalculationType, ComponentAttributeFilterOptions
from power_grid_model.errors import PowerGridUnreachableHitError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import numpy as np

from power_grid_model.core.index_integer import IdxNp
from power_grid_model.core.power_grid_core import power_grid_core as pgc
from power_grid_model._core.index_integer import IdxNp
from power_grid_model._core.power_grid_core import power_grid_core as pgc
from power_grid_model.errors import (
AutomaticTapCalculationError,
ConflictID,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from typing import Any, Callable

from power_grid_model.core.power_grid_core import OptionsPtr, power_grid_core as pgc
from power_grid_model._core.power_grid_core import OptionsPtr, power_grid_core as pgc


class OptionSetter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pathlib import Path
from typing import Callable, Optional

from power_grid_model.core.index_integer import IdC, IdxC
from power_grid_model._core.index_integer import IdC, IdxC

# integer index
IdxPtr = POINTER(IdxC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@

from typing import Any, Mapping, Optional

from power_grid_model._utils import get_dataset_type, is_columnar, is_nan_or_equivalent, process_data_filter
from power_grid_model.core.buffer_handling import (
from power_grid_model._core.buffer_handling import (
BufferProperties,
CAttributeBuffer,
CBuffer,
create_buffer,
get_buffer_properties,
get_buffer_view,
)
from power_grid_model.core.dataset_definitions import ComponentType, DatasetType, _str_to_component_type
from power_grid_model.core.error_handling import VALIDATOR_MSG, assert_no_error
from power_grid_model.core.power_grid_core import (
from power_grid_model._core.dataset_definitions import ComponentType, DatasetType, _str_to_component_type
from power_grid_model._core.error_handling import VALIDATOR_MSG, assert_no_error
from power_grid_model._core.power_grid_core import (
ConstDatasetPtr,
DatasetInfoPtr,
MutableDatasetPtr,
WritableDatasetPtr,
power_grid_core as pgc,
)
from power_grid_model.core.power_grid_meta import ComponentMetaData, DatasetMetaData, power_grid_meta_data
from power_grid_model._core.power_grid_meta import ComponentMetaData, DatasetMetaData, power_grid_meta_data
from power_grid_model._utils import get_dataset_type, is_columnar, is_nan_or_equivalent, process_data_filter
from power_grid_model.data_types import AttributeType, ComponentData, Dataset
from power_grid_model.enum import ComponentAttributeFilterOptions
from power_grid_model.typing import ComponentAttributeMapping, _ComponentAttributeMappingDict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@

import numpy as np

from power_grid_model.core.dataset_definitions import (
from power_grid_model._core.dataset_definitions import (
ComponentTypeLike,
ComponentTypeVar,
DatasetType,
DatasetTypeLike,
_str_to_component_type,
_str_to_datatype,
)
from power_grid_model.core.power_grid_core import AttributePtr, ComponentPtr, DatasetPtr, power_grid_core as pgc
from power_grid_model._core.power_grid_core import AttributePtr, ComponentPtr, DatasetPtr, power_grid_core as pgc
from power_grid_model.data_types import DenseBatchArray, SingleArray


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@

import numpy as np

from power_grid_model.core.data_handling import (
from power_grid_model._core.data_handling import (
create_output_data,
get_output_type,
prepare_input_view,
prepare_output_view,
prepare_update_view,
)
from power_grid_model.core.dataset_definitions import (
from power_grid_model._core.dataset_definitions import (
ComponentType,
ComponentTypeLike,
_map_to_component_types,
_str_to_component_type,
)
from power_grid_model.core.error_handling import PowerGridBatchError, assert_no_error, handle_errors
from power_grid_model.core.index_integer import IdNp, IdxNp
from power_grid_model.core.options import Options
from power_grid_model.core.power_grid_core import ConstDatasetPtr, IDPtr, IdxPtr, ModelPtr, power_grid_core as pgc
from power_grid_model._core.error_handling import PowerGridBatchError, assert_no_error, handle_errors
from power_grid_model._core.index_integer import IdNp, IdxNp
from power_grid_model._core.options import Options
from power_grid_model._core.power_grid_core import ConstDatasetPtr, IDPtr, IdxPtr, ModelPtr, power_grid_core as pgc
from power_grid_model.data_types import Dataset, SingleDataset
from power_grid_model.enum import (
CalculationMethod,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
from ctypes import byref
from enum import IntEnum

from power_grid_model.core.dataset_definitions import DatasetType, _map_to_component_types, _str_to_datatype
from power_grid_model.core.error_handling import assert_no_error
from power_grid_model.core.index_integer import IdxC
from power_grid_model.core.power_grid_core import (
from power_grid_model._core.dataset_definitions import DatasetType, _map_to_component_types, _str_to_datatype
from power_grid_model._core.error_handling import assert_no_error
from power_grid_model._core.index_integer import IdxC
from power_grid_model._core.power_grid_core import (
CharPtr,
DeserializerPtr,
SerializerPtr,
WritableDatasetPtr,
power_grid_core as pgc,
)
from power_grid_model.core.power_grid_dataset import CConstDataset, CWritableDataset
from power_grid_model._core.power_grid_dataset import CConstDataset, CWritableDataset
from power_grid_model.data_types import Dataset
from power_grid_model.errors import PowerGridSerializationError
from power_grid_model.typing import ComponentAttributeMapping
Expand Down
6 changes: 3 additions & 3 deletions src/power_grid_model/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@

import numpy as np

from power_grid_model.core.dataset_definitions import ComponentType, DatasetType
from power_grid_model.core.error_handling import VALIDATOR_MSG
from power_grid_model.core.power_grid_meta import initialize_array, power_grid_meta_data
from power_grid_model._core.dataset_definitions import ComponentType, DatasetType
from power_grid_model._core.error_handling import VALIDATOR_MSG
from power_grid_model._core.power_grid_meta import initialize_array, power_grid_meta_data
from power_grid_model.data_types import (
BatchColumn,
BatchComponentData,
Expand Down
2 changes: 1 addition & 1 deletion src/power_grid_model/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import numpy as np

from power_grid_model.core.dataset_definitions import ComponentTypeVar
from power_grid_model._core.dataset_definitions import ComponentTypeVar

AttributeType: TypeAlias = str
"""
Expand Down
4 changes: 2 additions & 2 deletions src/power_grid_model/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
This includes all miscellaneous type hints not under dataset or categories.
"""

from power_grid_model.core.dataset_definitions import ( # pylint: disable=unused-import
from power_grid_model._core.dataset_definitions import ( # pylint: disable=unused-import
ComponentType,
ComponentTypeVar,
DatasetType,
DatasetTypeVar,
)
from power_grid_model.core.power_grid_meta import ( # pylint: disable=unused-import
from power_grid_model._core.power_grid_meta import ( # pylint: disable=unused-import
ComponentMetaData,
DatasetMetaData,
PowerGridMetaData,
Expand Down
14 changes: 7 additions & 7 deletions src/power_grid_model/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@
import numpy as np

from power_grid_model import CalculationMethod, PowerGridModel
from power_grid_model._core.dataset_definitions import DatasetType, _map_to_component_types
from power_grid_model._core.serialization import ( # pylint: disable=unused-import
json_deserialize,
json_serialize,
msgpack_deserialize,
msgpack_serialize,
)
from power_grid_model._utils import (
_extract_data_from_component_data,
_extract_indptr,
Expand All @@ -25,13 +32,6 @@
is_columnar,
is_sparse,
)
from power_grid_model.core.dataset_definitions import DatasetType, _map_to_component_types
from power_grid_model.core.serialization import ( # pylint: disable=unused-import
json_deserialize,
json_serialize,
msgpack_deserialize,
msgpack_serialize,
)
from power_grid_model.data_types import (
BatchComponentData,
BatchDataset,
Expand Down
Loading

0 comments on commit 1c8139c

Please sign in to comment.