Skip to content

Commit 2b6fa7e

Browse files
committed
v0.2.4: use backend v0.14.5, implement "contains" for buses, updated changelog.
1 parent 9e26270 commit 2b6fa7e

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

altdss/Bus.py

+13-2
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,18 @@ def __getitem__(self, index: Union[int, str]) -> Bus:
562562
def __len__(self) -> int:
563563
'''Total number of buses in the circuit.'''
564564
return self._lib.Circuit_Get_NumBuses()
565-
565+
566+
def __contains__(self, name_or_index: Union[int, str]) -> bool:
567+
api_util = self._api_util
568+
if isinstance(name_or_index, int):
569+
return (api_util.lib_unpatched.Alt_Bus_GetByIndex(api_util.ctx, name_or_index) != api_util.ffi.NULL)
570+
571+
if not isinstance(name_or_index, bytes):
572+
name_or_index = name_or_index.encode(api_util.codec)
573+
574+
return (api_util.lib_unpatched.Alt_Bus_GetByName(api_util.ctx, name_or_index) != api_util.ffi.NULL)
575+
576+
566577
def find(self, index_or_name: Union[int, str]) -> Bus:
567578
'''
568579
Returns a bus object for the selected index or name.
@@ -575,4 +586,4 @@ def Name(self) -> List[str]:
575586
'''
576587
Array of strings containing names of all buses in circuit.
577588
'''
578-
return self._check_for_error(self._get_string_array(self._lib.Circuit_Get_AllBusNames))
589+
return self._check_for_error(self._get_string_array(self._lib.Circuit_Get_AllBusNames))

docs/changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
Remember that changes in our alternative OpenDSS engine, currently known as AltDSS/DSS C-API, are always
44
relevant. See [AltDSS/DSS C-API's repository](https://github.com/dss-extensions/dss_capi/) for more information.
55

6+
## 0.2.4
7+
8+
- `altdss.Bus`: the Bus collection now implements the `in` operator: `"some_name" in altdss.Bus` or `"some_name" in altdss.Bus`
9+
- The engine was updated to AltDSS/DSS C-API 0.14.5, but the changes there only affects the classic API.
10+
611
## 0.2.3
712

813
The engine was updated to AltDSS/DSS C-API 0.14.4 in order to implement some of changes below.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ name = "altdss"
2121
dynamic = ["version"]
2222
dependencies = [
2323
"dss_python",
24-
"dss_python_backend==0.14.4",
24+
"dss_python_backend==0.14.5",
2525
"numpy>=1.21.0",
2626
"typing_extensions>=4.5,<5",
2727
"scipy",

0 commit comments

Comments
 (0)