Skip to content

Commit

Permalink
v0.2.4: use backend v0.14.5, implement "contains" for buses, updated …
Browse files Browse the repository at this point in the history
…changelog.
  • Loading branch information
PMeira committed Mar 29, 2024
1 parent 9e26270 commit 2b6fa7e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
15 changes: 13 additions & 2 deletions altdss/Bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,18 @@ def __getitem__(self, index: Union[int, str]) -> Bus:
def __len__(self) -> int:
'''Total number of buses in the circuit.'''
return self._lib.Circuit_Get_NumBuses()


def __contains__(self, name_or_index: Union[int, str]) -> bool:
api_util = self._api_util
if isinstance(name_or_index, int):
return (api_util.lib_unpatched.Alt_Bus_GetByIndex(api_util.ctx, name_or_index) != api_util.ffi.NULL)

if not isinstance(name_or_index, bytes):
name_or_index = name_or_index.encode(api_util.codec)

return (api_util.lib_unpatched.Alt_Bus_GetByName(api_util.ctx, name_or_index) != api_util.ffi.NULL)


def find(self, index_or_name: Union[int, str]) -> Bus:
'''
Returns a bus object for the selected index or name.
Expand All @@ -575,4 +586,4 @@ def Name(self) -> List[str]:
'''
Array of strings containing names of all buses in circuit.
'''
return self._check_for_error(self._get_string_array(self._lib.Circuit_Get_AllBusNames))
return self._check_for_error(self._get_string_array(self._lib.Circuit_Get_AllBusNames))
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Remember that changes in our alternative OpenDSS engine, currently known as AltDSS/DSS C-API, are always
relevant. See [AltDSS/DSS C-API's repository](https://github.com/dss-extensions/dss_capi/) for more information.

## 0.2.4

- `altdss.Bus`: the Bus collection now implements the `in` operator: `"some_name" in altdss.Bus` or `"some_name" in altdss.Bus`
- The engine was updated to AltDSS/DSS C-API 0.14.5, but the changes there only affects the classic API.

## 0.2.3

The engine was updated to AltDSS/DSS C-API 0.14.4 in order to implement some of changes below.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ name = "altdss"
dynamic = ["version"]
dependencies = [
"dss_python",
"dss_python_backend==0.14.4",
"dss_python_backend==0.14.5",
"numpy>=1.21.0",
"typing_extensions>=4.5,<5",
"scipy",
Expand Down

0 comments on commit 2b6fa7e

Please sign in to comment.