Skip to content

Commit

Permalink
Added typing and improved the docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
SanPen committed Jun 27, 2023
1 parent f46ec0e commit 305fd96
Show file tree
Hide file tree
Showing 12 changed files with 503 additions and 504 deletions.
50 changes: 31 additions & 19 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/ntc_pruebas.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def nc_time_series(last_time_idx=None):
nbr=circuit.get_branch_number(),
X=branch_data.X,
R=branch_data.R,
m=branch_data.tap_module,
tap_modules=branch_data.tap_module,
active=branch_data.active,
Cf=branch_data.C_branch_bus_f,
Ct=branch_data.C_branch_bus_t,
Expand Down
13 changes: 3 additions & 10 deletions src/GridCal/Engine/Core/Compilers/circuit_to_bentayga.py
Original file line number Diff line number Diff line change
Expand Up @@ -572,19 +572,12 @@ def get_snapshots_from_bentayga(circuit: MultiCircuit):
for btg_data in btg_data_lst:

data = NumericalCircuit(nbus=0,
nline=0,
ndcline=0,
ntr=0,
nvsc=0,
nupfc=0,
nhvdc=0,
nload=0,
ngen=0,
nbatt=0,
nshunt=0,
nstagen=0,
sbase=0,
ntime=1)
sbase=0)

data.Vbus_ = btg_data.Vbus.reshape(-1, 1)
data.Sbus_ = btg_data.Sbus.reshape(-1, 1)
Expand Down Expand Up @@ -618,8 +611,8 @@ def get_snapshots_from_bentayga(circuit: MultiCircuit):
data.vd_ = btg_data.bus_types_data.vd
data.pqpv_ = btg_data.bus_types_data.pqpv

data.original_bus_idx = btg_data.bus_data.original_indices
data.original_branch_idx = btg_data.branch_data.original_indices
data.bus_data.original_idx = btg_data.bus_data.original_indices
data.branch_data.original_idx = btg_data.branch_data.original_indices

data.Qmax_bus_ = btg_data.Qmax_bus
data.Qmin_bus_ = btg_data.Qmin_bus
Expand Down
18 changes: 13 additions & 5 deletions src/GridCal/Engine/Core/Devices/editable_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ def __init__(self,
tpe: Union[Type[int], Type[bool], Type[float], Type[str], DeviceType, Type[BuildStatus]],
definition: str,
profile_name: str = '',
display: bool = True):
display: bool = True,
editable: bool = True):
"""
GridCal property
:param units: units of the property
:param tpe: data type [Type[int], Type[bool], Type[float], Type[str], DeviceType, Type[BuildStatus]]
:param definition: Definition of the property
:param profile_name: name of the associated profile property
:param display: Display the property in the GUI
:param editable: Is this editable?
"""

self.units = units
Expand All @@ -48,8 +50,13 @@ def __init__(self,

self.display = display

self.editable = editable


class EditableDevice:
"""
This is the main device class from which all inherit
"""

def __init__(self,
name: str,
Expand Down Expand Up @@ -93,7 +100,7 @@ def __init__(self,
self.register(key='name', units='', tpe=str, definition='Name of the branch.')
self.register(key='idtag', units='', tpe=str, definition='Unique ID', editable=False)
self.register(key='code', units='', tpe=str, definition='Secondary ID')
self.register(key='active', units='', tpe=bool, definition='Is active?')
self.register(key='active', units='', tpe=bool, definition='Is active?') # this one is overriden if active_prof is present

def register(self,
key: str,
Expand All @@ -114,16 +121,17 @@ def register(self,
:param display: display this property?
:param editable: is this editable?
"""
assert (hasattr(self, key)) # the property must exist, this avoids bugs in registering
assert (hasattr(self, key)) # the property must exist, this avoids bugs when registering

self.editable_headers[key] = GCProp(units=units,
tpe=tpe,
definition=definition,
profile_name=profile_name,
display=display)
display=display,
editable=editable)

if profile_name != '':
assert (hasattr(self, profile_name)) # the property must exist, this avoids bugs in registering
assert (hasattr(self, profile_name)) # the property must exist, this avoids bugs in registering
self.properties_with_profile[key] = profile_name

if not editable:
Expand Down
Loading

0 comments on commit 305fd96

Please sign in to comment.