repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
Legobot/Legobot | Legobot/Connectors/Discord.py | Discord.handle | def handle(self, message):
'''
Attempts to send a message to the specified destination in Discord.
Extends Legobot.Lego.handle()
Args:
message (Legobot.Message): message w/ metadata to send.
'''
logger.debug(message)
if Utilities.isNotEmpty(message['... | python | def handle(self, message):
'''
Attempts to send a message to the specified destination in Discord.
Extends Legobot.Lego.handle()
Args:
message (Legobot.Message): message w/ metadata to send.
'''
logger.debug(message)
if Utilities.isNotEmpty(message['... | Attempts to send a message to the specified destination in Discord.
Extends Legobot.Lego.handle()
Args:
message (Legobot.Message): message w/ metadata to send. | https://github.com/Legobot/Legobot/blob/d13da172960a149681cb5151ce34b2f3a58ad32b/Legobot/Connectors/Discord.py#L300-L312 |
cuihantao/andes | andes/variables/dae.py | DAE.resize | def resize(self):
"""Resize dae and and extend for init1 variables
"""
yext = self.m - len(self.y)
xext = self.n - len(self.x)
if yext > 0:
yzeros = zeros(yext, 1)
yones = ones(yext, 1)
self.y = matrix([self.y, yzeros], (self.m, 1), 'd')
... | python | def resize(self):
"""Resize dae and and extend for init1 variables
"""
yext = self.m - len(self.y)
xext = self.n - len(self.x)
if yext > 0:
yzeros = zeros(yext, 1)
yones = ones(yext, 1)
self.y = matrix([self.y, yzeros], (self.m, 1), 'd')
... | Resize dae and and extend for init1 variables | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L356-L376 |
cuihantao/andes | andes/variables/dae.py | DAE.hard_limit | def hard_limit(self, yidx, ymin, ymax, min_set=None, max_set=None):
"""Set hard limits for algebraic variables and reset the equation mismatches
:param yidx: algebraic variable indices
:param ymin: lower limit to check for
:param ymax: upper limit to check for
:param min_set: op... | python | def hard_limit(self, yidx, ymin, ymax, min_set=None, max_set=None):
"""Set hard limits for algebraic variables and reset the equation mismatches
:param yidx: algebraic variable indices
:param ymin: lower limit to check for
:param ymax: upper limit to check for
:param min_set: op... | Set hard limits for algebraic variables and reset the equation mismatches
:param yidx: algebraic variable indices
:param ymin: lower limit to check for
:param ymax: upper limit to check for
:param min_set: optional lower limit to set (``ymin`` as default)
:param max_set: optiona... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L378-L435 |
cuihantao/andes | andes/variables/dae.py | DAE.hard_limit_remote | def hard_limit_remote(self,
yidx,
ridx,
rtype='y',
rmin=None,
rmax=None,
min_yset=0,
max_yset=0):
"""Limit the output of yidx if t... | python | def hard_limit_remote(self,
yidx,
ridx,
rtype='y',
rmin=None,
rmax=None,
min_yset=0,
max_yset=0):
"""Limit the output of yidx if t... | Limit the output of yidx if the remote y is not within the limits
This function needs to be modernized. | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L437-L481 |
cuihantao/andes | andes/variables/dae.py | DAE.anti_windup | def anti_windup(self, xidx, xmin, xmax):
"""
Anti-windup limiter for state variables.
Resets the limited variables and differential equations.
:param xidx: state variable indices
:param xmin: lower limit
:param xmax: upper limit
:type xidx: matrix, list
... | python | def anti_windup(self, xidx, xmin, xmax):
"""
Anti-windup limiter for state variables.
Resets the limited variables and differential equations.
:param xidx: state variable indices
:param xmin: lower limit
:param xmax: upper limit
:type xidx: matrix, list
... | Anti-windup limiter for state variables.
Resets the limited variables and differential equations.
:param xidx: state variable indices
:param xmin: lower limit
:param xmax: upper limit
:type xidx: matrix, list
:type xmin: matrix, float, int, list
:type xmax: mat... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L483-L531 |
cuihantao/andes | andes/variables/dae.py | DAE.reset_Ac | def reset_Ac(self):
"""
Reset ``dae.Ac`` sparse matrix for disabled equations
due to hard_limit and anti_windup limiters.
:return: None
"""
if self.ac_reset is False:
return
mn = self.m + self.n
x = index(aandb(self.zxmin, self.zxmax), 0.)
... | python | def reset_Ac(self):
"""
Reset ``dae.Ac`` sparse matrix for disabled equations
due to hard_limit and anti_windup limiters.
:return: None
"""
if self.ac_reset is False:
return
mn = self.m + self.n
x = index(aandb(self.zxmin, self.zxmax), 0.)
... | Reset ``dae.Ac`` sparse matrix for disabled equations
due to hard_limit and anti_windup limiters.
:return: None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L533-L563 |
cuihantao/andes | andes/variables/dae.py | DAE.get_size | def get_size(self, m):
"""
Return the 2-D size of a Jacobian matrix in tuple
"""
nrow, ncol = 0, 0
if m[0] == 'F':
nrow = self.n
elif m[0] == 'G':
nrow = self.m
if m[1] == 'x':
ncol = self.n
elif m[1] == 'y':
... | python | def get_size(self, m):
"""
Return the 2-D size of a Jacobian matrix in tuple
"""
nrow, ncol = 0, 0
if m[0] == 'F':
nrow = self.n
elif m[0] == 'G':
nrow = self.m
if m[1] == 'x':
ncol = self.n
elif m[1] == 'y':
... | Return the 2-D size of a Jacobian matrix in tuple | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L565-L580 |
cuihantao/andes | andes/variables/dae.py | DAE.add_jac | def add_jac(self, m, val, row, col):
"""Add tuples (val, row, col) to the Jacobian matrix ``m``
Implemented in numpy.arrays for temporary storage.
"""
assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx0', 'Fy0', 'Gx0', 'Gy0'), \
'Wrong Jacobian matrix name <{0}>'.format(m)
if... | python | def add_jac(self, m, val, row, col):
"""Add tuples (val, row, col) to the Jacobian matrix ``m``
Implemented in numpy.arrays for temporary storage.
"""
assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx0', 'Fy0', 'Gx0', 'Gy0'), \
'Wrong Jacobian matrix name <{0}>'.format(m)
if... | Add tuples (val, row, col) to the Jacobian matrix ``m``
Implemented in numpy.arrays for temporary storage. | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L582-L595 |
cuihantao/andes | andes/variables/dae.py | DAE.temp_to_spmatrix | def temp_to_spmatrix(self, ty):
"""
Convert Jacobian tuples to matrices
:param ty: name of the matrices to convert in ``('jac0','jac')``
:return: None
"""
assert ty in ('jac0', 'jac')
jac0s = ['Fx0', 'Fy0', 'Gx0', 'Gy0']
jacs = ['Fx', 'Fy', 'Gx', 'Gy']
... | python | def temp_to_spmatrix(self, ty):
"""
Convert Jacobian tuples to matrices
:param ty: name of the matrices to convert in ``('jac0','jac')``
:return: None
"""
assert ty in ('jac0', 'jac')
jac0s = ['Fx0', 'Fy0', 'Gx0', 'Gy0']
jacs = ['Fx', 'Fy', 'Gx', 'Gy']
... | Convert Jacobian tuples to matrices
:param ty: name of the matrices to convert in ``('jac0','jac')``
:return: None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L597-L622 |
cuihantao/andes | andes/variables/dae.py | DAE.set_jac | def set_jac(self, m, val, row, col):
"""
Set the values at (row, col) to val in Jacobian m
:param m: Jacobian name
:param val: values to set
:param row: row indices
:param col: col indices
:return: None
"""
assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx... | python | def set_jac(self, m, val, row, col):
"""
Set the values at (row, col) to val in Jacobian m
:param m: Jacobian name
:param val: values to set
:param row: row indices
:param col: col indices
:return: None
"""
assert m in ('Fx', 'Fy', 'Gx', 'Gy', 'Fx... | Set the values at (row, col) to val in Jacobian m
:param m: Jacobian name
:param val: values to set
:param row: row indices
:param col: col indices
:return: None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L624-L644 |
cuihantao/andes | andes/variables/dae.py | DAE.apply_set | def apply_set(self, ty):
"""
Apply Jacobian set values to matrices
:param ty: Jacobian type in ``('jac0', 'jac')``
:return:
"""
assert ty in ('jac0', 'jac')
if ty == 'jac0':
todo = ['Fx0', 'Fy0', 'Gx0', 'Gy0']
else:
todo = ['Fx', ... | python | def apply_set(self, ty):
"""
Apply Jacobian set values to matrices
:param ty: Jacobian type in ``('jac0', 'jac')``
:return:
"""
assert ty in ('jac0', 'jac')
if ty == 'jac0':
todo = ['Fx0', 'Fy0', 'Gx0', 'Gy0']
else:
todo = ['Fx', ... | Apply Jacobian set values to matrices
:param ty: Jacobian type in ``('jac0', 'jac')``
:return: | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L646-L665 |
cuihantao/andes | andes/variables/dae.py | DAE.show | def show(self, eq, value=None):
"""Show equation or variable array along with the names"""
if eq in ['f', 'x']:
key = 'unamex'
elif eq in ['g', 'y']:
key = 'unamey'
if value:
value = list(value)
else:
value = list(self.__dict__[eq]... | python | def show(self, eq, value=None):
"""Show equation or variable array along with the names"""
if eq in ['f', 'x']:
key = 'unamex'
elif eq in ['g', 'y']:
key = 'unamey'
if value:
value = list(value)
else:
value = list(self.__dict__[eq]... | Show equation or variable array along with the names | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L667-L683 |
cuihantao/andes | andes/variables/dae.py | DAE.find_val | def find_val(self, eq, val):
"""Return the name of the equation having the given value"""
if eq not in ('f', 'g', 'q'):
return
elif eq in ('f', 'q'):
key = 'unamex'
elif eq == 'g':
key = 'unamey'
idx = 0
for m, n in zip(self.system.varn... | python | def find_val(self, eq, val):
"""Return the name of the equation having the given value"""
if eq not in ('f', 'g', 'q'):
return
elif eq in ('f', 'q'):
key = 'unamex'
elif eq == 'g':
key = 'unamey'
idx = 0
for m, n in zip(self.system.varn... | Return the name of the equation having the given value | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L685-L698 |
cuihantao/andes | andes/variables/dae.py | DAE.reset_small | def reset_small(self, eq):
"""Reset numbers smaller than 1e-12 in f and g equations"""
assert eq in ('f', 'g')
for idx, var in enumerate(self.__dict__[eq]):
if abs(var) <= 1e-12:
self.__dict__[eq][idx] = 0 | python | def reset_small(self, eq):
"""Reset numbers smaller than 1e-12 in f and g equations"""
assert eq in ('f', 'g')
for idx, var in enumerate(self.__dict__[eq]):
if abs(var) <= 1e-12:
self.__dict__[eq][idx] = 0 | Reset numbers smaller than 1e-12 in f and g equations | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L700-L705 |
cuihantao/andes | andes/variables/dae.py | DAE.check_diag | def check_diag(self, jac, name):
"""
Check matrix ``jac`` for diagonal elements that equals 0
"""
system = self.system
pos = []
names = []
pairs = ''
size = jac.size
diag = jac[0:size[0] ** 2:size[0] + 1]
for idx in range(size[0]):
... | python | def check_diag(self, jac, name):
"""
Check matrix ``jac`` for diagonal elements that equals 0
"""
system = self.system
pos = []
names = []
pairs = ''
size = jac.size
diag = jac[0:size[0] ** 2:size[0] + 1]
for idx in range(size[0]):
... | Check matrix ``jac`` for diagonal elements that equals 0 | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/variables/dae.py#L713-L735 |
DiamondLightSource/python-workflows | workflows/logging/__init__.py | get_exception_source | def get_exception_source():
"""Returns full file path, file name, line number, function name, and line contents
causing the last exception."""
_, _, tb = sys.exc_info()
while tb.tb_next:
tb = tb.tb_next
f = tb.tb_frame
lineno = tb.tb_lineno
co = f.f_code
filefullpath = co.co_file... | python | def get_exception_source():
"""Returns full file path, file name, line number, function name, and line contents
causing the last exception."""
_, _, tb = sys.exc_info()
while tb.tb_next:
tb = tb.tb_next
f = tb.tb_frame
lineno = tb.tb_lineno
co = f.f_code
filefullpath = co.co_file... | Returns full file path, file name, line number, function name, and line contents
causing the last exception. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/logging/__init__.py#L9-L27 |
DiamondLightSource/python-workflows | workflows/logging/__init__.py | CallbackHandler.prepare | def prepare(self, record):
# Function taken from Python 3.6 QueueHandler
"""
Prepares a record for queuing. The object returned by this method is
enqueued.
The base implementation formats the record to merge the message
and arguments, and removes unpickleable items from t... | python | def prepare(self, record):
# Function taken from Python 3.6 QueueHandler
"""
Prepares a record for queuing. The object returned by this method is
enqueued.
The base implementation formats the record to merge the message
and arguments, and removes unpickleable items from t... | Prepares a record for queuing. The object returned by this method is
enqueued.
The base implementation formats the record to merge the message
and arguments, and removes unpickleable items from the record
in-place.
You might want to override this method if you want to convert
... | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/logging/__init__.py#L38-L60 |
DiamondLightSource/python-workflows | workflows/logging/__init__.py | CallbackHandler.emit | def emit(self, record):
"""Send a LogRecord to the callback function, after preparing it
for serialization."""
try:
self._callback(self.prepare(record))
except Exception:
self.handleError(record) | python | def emit(self, record):
"""Send a LogRecord to the callback function, after preparing it
for serialization."""
try:
self._callback(self.prepare(record))
except Exception:
self.handleError(record) | Send a LogRecord to the callback function, after preparing it
for serialization. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/logging/__init__.py#L62-L68 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.update_status | def update_status(self, status_code=None):
"""Update the service status kept inside the frontend (_service_status).
The status is broadcast over the network immediately. If the status
changes to IDLE then this message is delayed. The IDLE status is only
broadcast if it is held for over 0... | python | def update_status(self, status_code=None):
"""Update the service status kept inside the frontend (_service_status).
The status is broadcast over the network immediately. If the status
changes to IDLE then this message is delayed. The IDLE status is only
broadcast if it is held for over 0... | Update the service status kept inside the frontend (_service_status).
The status is broadcast over the network immediately. If the status
changes to IDLE then this message is delayed. The IDLE status is only
broadcast if it is held for over 0.5 seconds.
When the status does not change it... | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L134-L170 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.run | def run(self):
"""The main loop of the frontend. Here incoming messages from the service
are processed and forwarded to the corresponding callback methods."""
self.log.debug("Entered main loop")
while not self.shutdown:
# If no service is running slow down the main loop
... | python | def run(self):
"""The main loop of the frontend. Here incoming messages from the service
are processed and forwarded to the corresponding callback methods."""
self.log.debug("Entered main loop")
while not self.shutdown:
# If no service is running slow down the main loop
... | The main loop of the frontend. Here incoming messages from the service
are processed and forwarded to the corresponding callback methods. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L172-L252 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.send_command | def send_command(self, command):
"""Send command to service via the command queue."""
if self._pipe_commands:
self._pipe_commands.send(command)
else:
if self.shutdown:
# Stop delivering messages in shutdown.
self.log.info(
... | python | def send_command(self, command):
"""Send command to service via the command queue."""
if self._pipe_commands:
self._pipe_commands.send(command)
else:
if self.shutdown:
# Stop delivering messages in shutdown.
self.log.info(
... | Send command to service via the command queue. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L254-L268 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.process_transport_command | def process_transport_command(self, header, message):
"""Parse a command coming in through the transport command subscription"""
if not isinstance(message, dict):
return
relevant = False
if "host" in message: # Filter by host
if message["host"] != self.__hostid:... | python | def process_transport_command(self, header, message):
"""Parse a command coming in through the transport command subscription"""
if not isinstance(message, dict):
return
relevant = False
if "host" in message: # Filter by host
if message["host"] != self.__hostid:... | Parse a command coming in through the transport command subscription | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L270-L294 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.parse_band_log | def parse_band_log(self, message):
"""Process incoming logging messages from the service."""
if "payload" in message and hasattr(message["payload"], "name"):
record = message["payload"]
for k in dir(record):
if k.startswith("workflows_exc_"):
s... | python | def parse_band_log(self, message):
"""Process incoming logging messages from the service."""
if "payload" in message and hasattr(message["payload"], "name"):
record = message["payload"]
for k in dir(record):
if k.startswith("workflows_exc_"):
s... | Process incoming logging messages from the service. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L296-L315 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.parse_band_request_termination | def parse_band_request_termination(self, message):
"""Service declares it should be terminated."""
self.log.debug("Service requests termination")
self._terminate_service()
if not self.restart_service:
self.shutdown = True | python | def parse_band_request_termination(self, message):
"""Service declares it should be terminated."""
self.log.debug("Service requests termination")
self._terminate_service()
if not self.restart_service:
self.shutdown = True | Service declares it should be terminated. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L317-L322 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.parse_band_set_name | def parse_band_set_name(self, message):
"""Process incoming message indicating service name change."""
if message.get("name"):
self._service_name = message["name"]
else:
self.log.warning(
"Received broken record on set_name band\nMessage: %s", str(message)... | python | def parse_band_set_name(self, message):
"""Process incoming message indicating service name change."""
if message.get("name"):
self._service_name = message["name"]
else:
self.log.warning(
"Received broken record on set_name band\nMessage: %s", str(message)... | Process incoming message indicating service name change. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L324-L331 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.parse_band_status_update | def parse_band_status_update(self, message):
"""Process incoming status updates from the service."""
self.log.debug("Status update: " + str(message))
self.update_status(status_code=message["statuscode"]) | python | def parse_band_status_update(self, message):
"""Process incoming status updates from the service."""
self.log.debug("Status update: " + str(message))
self.update_status(status_code=message["statuscode"]) | Process incoming status updates from the service. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L333-L336 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.get_status | def get_status(self):
"""Returns a dictionary containing all relevant status information to be
broadcast across the network."""
return {
"host": self.__hostid,
"status": self._service_status_announced,
"statustext": CommonService.human_readable_state.get(
... | python | def get_status(self):
"""Returns a dictionary containing all relevant status information to be
broadcast across the network."""
return {
"host": self.__hostid,
"status": self._service_status_announced,
"statustext": CommonService.human_readable_state.get(
... | Returns a dictionary containing all relevant status information to be
broadcast across the network. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L342-L355 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.exponential_backoff | def exponential_backoff(self):
"""A function that keeps waiting longer and longer the more rapidly it is called.
It can be used to increasingly slow down service starts when they keep failing."""
last_service_switch = self._service_starttime
if not last_service_switch:
return... | python | def exponential_backoff(self):
"""A function that keeps waiting longer and longer the more rapidly it is called.
It can be used to increasingly slow down service starts when they keep failing."""
last_service_switch = self._service_starttime
if not last_service_switch:
return... | A function that keeps waiting longer and longer the more rapidly it is called.
It can be used to increasingly slow down service starts when they keep failing. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L357-L375 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend.switch_service | def switch_service(self, new_service=None):
"""Start a new service in a subprocess.
:param new_service: Either a service name or a service class. If not set,
start up a new instance of the previous class
:return: True on success, False on failure.
"""
... | python | def switch_service(self, new_service=None):
"""Start a new service in a subprocess.
:param new_service: Either a service name or a service class. If not set,
start up a new instance of the previous class
:return: True on success, False on failure.
"""
... | Start a new service in a subprocess.
:param new_service: Either a service name or a service class. If not set,
start up a new instance of the previous class
:return: True on success, False on failure. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L377-L428 |
DiamondLightSource/python-workflows | workflows/frontend/__init__.py | Frontend._terminate_service | def _terminate_service(self):
"""Force termination of running service.
Disconnect queues, end queue feeder threads.
Wait for service process to clear, drop all references."""
with self.__lock:
if self._service:
self._service.terminate()
if self._pi... | python | def _terminate_service(self):
"""Force termination of running service.
Disconnect queues, end queue feeder threads.
Wait for service process to clear, drop all references."""
with self.__lock:
if self._service:
self._service.terminate()
if self._pi... | Force termination of running service.
Disconnect queues, end queue feeder threads.
Wait for service process to clear, drop all references. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/frontend/__init__.py#L430-L449 |
cuihantao/andes | andes/utils/solver.py | Solver.symbolic | def symbolic(self, A):
"""
Return the symbolic factorization of sparse matrix ``A``
Parameters
----------
sparselib
Library name in ``umfpack`` and ``klu``
A
Sparse matrix
Returns
symbolic factorization
-------
""... | python | def symbolic(self, A):
"""
Return the symbolic factorization of sparse matrix ``A``
Parameters
----------
sparselib
Library name in ``umfpack`` and ``klu``
A
Sparse matrix
Returns
symbolic factorization
-------
""... | Return the symbolic factorization of sparse matrix ``A``
Parameters
----------
sparselib
Library name in ``umfpack`` and ``klu``
A
Sparse matrix
Returns
symbolic factorization
------- | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L17-L38 |
cuihantao/andes | andes/utils/solver.py | Solver.numeric | def numeric(self, A, F):
"""
Return the numeric factorization of sparse matrix ``A`` using symbolic factorization ``F``
Parameters
----------
A
Sparse matrix
F
Symbolic factorization
Returns
-------
N
Numeric f... | python | def numeric(self, A, F):
"""
Return the numeric factorization of sparse matrix ``A`` using symbolic factorization ``F``
Parameters
----------
A
Sparse matrix
F
Symbolic factorization
Returns
-------
N
Numeric f... | Return the numeric factorization of sparse matrix ``A`` using symbolic factorization ``F``
Parameters
----------
A
Sparse matrix
F
Symbolic factorization
Returns
-------
N
Numeric factorization of ``A`` | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L40-L60 |
cuihantao/andes | andes/utils/solver.py | Solver.solve | def solve(self, A, F, N, b):
"""
Solve linear system ``Ax = b`` using numeric factorization ``N`` and symbolic factorization ``F``.
Store the solution in ``b``.
Parameters
----------
A
Sparse matrix
F
Symbolic factorization
N
... | python | def solve(self, A, F, N, b):
"""
Solve linear system ``Ax = b`` using numeric factorization ``N`` and symbolic factorization ``F``.
Store the solution in ``b``.
Parameters
----------
A
Sparse matrix
F
Symbolic factorization
N
... | Solve linear system ``Ax = b`` using numeric factorization ``N`` and symbolic factorization ``F``.
Store the solution in ``b``.
Parameters
----------
A
Sparse matrix
F
Symbolic factorization
N
Numeric factorization
b
... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L62-L86 |
cuihantao/andes | andes/utils/solver.py | Solver.linsolve | def linsolve(self, A, b):
"""
Solve linear equation set ``Ax = b`` and store the solutions in ``b``.
Parameters
----------
A
Sparse matrix
b
RHS of the equation
Returns
-------
None
"""
if self.sparselib =... | python | def linsolve(self, A, b):
"""
Solve linear equation set ``Ax = b`` and store the solutions in ``b``.
Parameters
----------
A
Sparse matrix
b
RHS of the equation
Returns
-------
None
"""
if self.sparselib =... | Solve linear equation set ``Ax = b`` and store the solutions in ``b``.
Parameters
----------
A
Sparse matrix
b
RHS of the equation
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/utils/solver.py#L88-L108 |
cuihantao/andes | andes/models/bus.py | Bus._varname_inj | def _varname_inj(self):
"""Customize varname for bus injections"""
# Bus Pi
if not self.n:
return
m = self.system.dae.m
xy_idx = range(m, self.n + m)
self.system.varname.append(
listname='unamey',
xy_idx=xy_idx,
var_name='P'... | python | def _varname_inj(self):
"""Customize varname for bus injections"""
# Bus Pi
if not self.n:
return
m = self.system.dae.m
xy_idx = range(m, self.n + m)
self.system.varname.append(
listname='unamey',
xy_idx=xy_idx,
var_name='P'... | Customize varname for bus injections | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L57-L86 |
cuihantao/andes | andes/models/bus.py | Bus.init0 | def init0(self, dae):
"""Set bus Va and Vm initial values"""
if not self.system.pflow.config.flatstart:
dae.y[self.a] = self.angle + 1e-10 * uniform(self.n)
dae.y[self.v] = self.voltage
else:
dae.y[self.a] = matrix(0.0,
(self... | python | def init0(self, dae):
"""Set bus Va and Vm initial values"""
if not self.system.pflow.config.flatstart:
dae.y[self.a] = self.angle + 1e-10 * uniform(self.n)
dae.y[self.v] = self.voltage
else:
dae.y[self.a] = matrix(0.0,
(self... | Set bus Va and Vm initial values | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L88-L96 |
cuihantao/andes | andes/models/bus.py | Bus.gisland | def gisland(self, dae):
"""Reset g(x) for islanded buses and areas"""
if (not self.islanded_buses) and (not self.island_sets):
return
a, v = list(), list()
# for islanded areas without a slack bus
# TODO: fix for islanded sets without sw
# for island in self... | python | def gisland(self, dae):
"""Reset g(x) for islanded buses and areas"""
if (not self.islanded_buses) and (not self.island_sets):
return
a, v = list(), list()
# for islanded areas without a slack bus
# TODO: fix for islanded sets without sw
# for island in self... | Reset g(x) for islanded buses and areas | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L98-L120 |
cuihantao/andes | andes/models/bus.py | Bus.gyisland | def gyisland(self, dae):
"""Reset gy(x) for islanded buses and areas"""
if self.system.Bus.islanded_buses:
a = self.system.Bus.islanded_buses
v = [self.system.Bus.n + item for item in a]
dae.set_jac(Gy, 1e-6, a, a)
dae.set_jac(Gy, 1e-6, v, v) | python | def gyisland(self, dae):
"""Reset gy(x) for islanded buses and areas"""
if self.system.Bus.islanded_buses:
a = self.system.Bus.islanded_buses
v = [self.system.Bus.n + item for item in a]
dae.set_jac(Gy, 1e-6, a, a)
dae.set_jac(Gy, 1e-6, v, v) | Reset gy(x) for islanded buses and areas | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L122-L128 |
cuihantao/andes | andes/models/bus.py | BusOld.gisland | def gisland(self, dae):
"""Reset g(x) for islanded buses and areas"""
if not (self.islanded_buses and self.island_sets):
return
a, v = list(), list()
# for islanded areas without a slack bus
for island in self.island_sets:
nosw = 1
for item i... | python | def gisland(self, dae):
"""Reset g(x) for islanded buses and areas"""
if not (self.islanded_buses and self.island_sets):
return
a, v = list(), list()
# for islanded areas without a slack bus
for island in self.island_sets:
nosw = 1
for item i... | Reset g(x) for islanded buses and areas | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/bus.py#L234-L255 |
DiamondLightSource/python-workflows | workflows/transport/__init__.py | get_known_transports | def get_known_transports():
"""Return a dictionary of all known transport mechanisms."""
if not hasattr(get_known_transports, "cache"):
setattr(
get_known_transports,
"cache",
{
e.name: e.load()
for e in pkg_resources.iter_entry_points(... | python | def get_known_transports():
"""Return a dictionary of all known transport mechanisms."""
if not hasattr(get_known_transports, "cache"):
setattr(
get_known_transports,
"cache",
{
e.name: e.load()
for e in pkg_resources.iter_entry_points(... | Return a dictionary of all known transport mechanisms. | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/transport/__init__.py#L21-L32 |
cuihantao/andes | andes/models/wind.py | WindBase.windspeed | def windspeed(self, t):
"""Return the wind speed list at time `t`"""
ws = [0] * self.n
for i in range(self.n):
q = ceil(t / self.dt[i])
q_prev = 0 if q == 0 else q - 1
r = t % self.dt[i]
r = 0 if abs(r) < 1e-6 else r
if r == 0:
... | python | def windspeed(self, t):
"""Return the wind speed list at time `t`"""
ws = [0] * self.n
for i in range(self.n):
q = ceil(t / self.dt[i])
q_prev = 0 if q == 0 else q - 1
r = t % self.dt[i]
r = 0 if abs(r) < 1e-6 else r
if r == 0:
... | Return the wind speed list at time `t` | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/wind.py#L82-L101 |
cuihantao/andes | andes/models/synchronous.py | SynBase.set_vf0 | def set_vf0(self, vf):
"""set value for self.vf0 and dae.y[self.vf]"""
self.vf0 = vf
self.system.dae.y[self.vf] = matrix(vf) | python | def set_vf0(self, vf):
"""set value for self.vf0 and dae.y[self.vf]"""
self.vf0 = vf
self.system.dae.y[self.vf] = matrix(vf) | set value for self.vf0 and dae.y[self.vf] | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/models/synchronous.py#L114-L117 |
cuihantao/andes | andes/system.py | PowerSystem.setup | def setup(self):
"""
Set up the power system object by executing the following workflow:
* Sort the loaded models to meet the initialization sequence
* Create call strings for routines
* Call the ``setup`` function of the loaded models
* Assign addresses for the load... | python | def setup(self):
"""
Set up the power system object by executing the following workflow:
* Sort the loaded models to meet the initialization sequence
* Create call strings for routines
* Call the ``setup`` function of the loaded models
* Assign addresses for the load... | Set up the power system object by executing the following workflow:
* Sort the loaded models to meet the initialization sequence
* Create call strings for routines
* Call the ``setup`` function of the loaded models
* Assign addresses for the loaded models
* Call ``dae.setup... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L187-L211 |
cuihantao/andes | andes/system.py | PowerSystem.to_sysbase | def to_sysbase(self):
"""
Convert model parameters to system base. This function calls the
``data_to_sys_base`` function of the loaded models.
Returns
-------
None
"""
if self.config.base:
for item in self.devman.devices:
self.... | python | def to_sysbase(self):
"""
Convert model parameters to system base. This function calls the
``data_to_sys_base`` function of the loaded models.
Returns
-------
None
"""
if self.config.base:
for item in self.devman.devices:
self.... | Convert model parameters to system base. This function calls the
``data_to_sys_base`` function of the loaded models.
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L213-L224 |
cuihantao/andes | andes/system.py | PowerSystem.to_elembase | def to_elembase(self):
"""
Convert parameters back to element base. This function calls the
```data_to_elem_base``` function.
Returns
-------
None
"""
if self.config.base:
for item in self.devman.devices:
self.__dict__[item].da... | python | def to_elembase(self):
"""
Convert parameters back to element base. This function calls the
```data_to_elem_base``` function.
Returns
-------
None
"""
if self.config.base:
for item in self.devman.devices:
self.__dict__[item].da... | Convert parameters back to element base. This function calls the
```data_to_elem_base``` function.
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L226-L237 |
cuihantao/andes | andes/system.py | PowerSystem.group_add | def group_add(self, name='Ungrouped'):
"""
Dynamically add a group instance to the system if not exist.
Parameters
----------
name : str, optional ('Ungrouped' as default)
Name of the group
Returns
-------
None
"""
if not hasa... | python | def group_add(self, name='Ungrouped'):
"""
Dynamically add a group instance to the system if not exist.
Parameters
----------
name : str, optional ('Ungrouped' as default)
Name of the group
Returns
-------
None
"""
if not hasa... | Dynamically add a group instance to the system if not exist.
Parameters
----------
name : str, optional ('Ungrouped' as default)
Name of the group
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L239-L254 |
cuihantao/andes | andes/system.py | PowerSystem.model_import | def model_import(self):
"""
Import and instantiate the non-JIT models and the JIT models.
Models defined in ``jits`` and ``non_jits`` in ``models/__init__.py``
will be imported and instantiated accordingly.
Returns
-------
None
"""
# non-JIT mode... | python | def model_import(self):
"""
Import and instantiate the non-JIT models and the JIT models.
Models defined in ``jits`` and ``non_jits`` in ``models/__init__.py``
will be imported and instantiated accordingly.
Returns
-------
None
"""
# non-JIT mode... | Import and instantiate the non-JIT models and the JIT models.
Models defined in ``jits`` and ``non_jits`` in ``models/__init__.py``
will be imported and instantiated accordingly.
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L256-L283 |
cuihantao/andes | andes/system.py | PowerSystem.routine_import | def routine_import(self):
"""
Dynamically import routines as defined in ``routines/__init__.py``.
The command-line argument ``--routine`` is defined in ``__cli__`` in
each routine file. A routine instance will be stored in the system
instance with the name being all lower case.
... | python | def routine_import(self):
"""
Dynamically import routines as defined in ``routines/__init__.py``.
The command-line argument ``--routine`` is defined in ``__cli__`` in
each routine file. A routine instance will be stored in the system
instance with the name being all lower case.
... | Dynamically import routines as defined in ``routines/__init__.py``.
The command-line argument ``--routine`` is defined in ``__cli__`` in
each routine file. A routine instance will be stored in the system
instance with the name being all lower case.
For example, a routine for power flow... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L285-L304 |
cuihantao/andes | andes/system.py | PowerSystem.model_setup | def model_setup(self):
"""
Call the ``setup`` function of the loaded models. This function is
to be called after parsing all the data files during the system set up.
Returns
-------
None
"""
for device in self.devman.devices:
if self.__dict__[... | python | def model_setup(self):
"""
Call the ``setup`` function of the loaded models. This function is
to be called after parsing all the data files during the system set up.
Returns
-------
None
"""
for device in self.devman.devices:
if self.__dict__[... | Call the ``setup`` function of the loaded models. This function is
to be called after parsing all the data files during the system set up.
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L306-L320 |
cuihantao/andes | andes/system.py | PowerSystem.xy_addr0 | def xy_addr0(self):
"""
Assign indicies and variable names for variables used in power flow
For each loaded model with the ``pflow`` flag as ``True``, the following
functions are called sequentially:
* ``_addr()``
* ``_intf_network()``
* ``_intf_ctrl()``
... | python | def xy_addr0(self):
"""
Assign indicies and variable names for variables used in power flow
For each loaded model with the ``pflow`` flag as ``True``, the following
functions are called sequentially:
* ``_addr()``
* ``_intf_network()``
* ``_intf_ctrl()``
... | Assign indicies and variable names for variables used in power flow
For each loaded model with the ``pflow`` flag as ``True``, the following
functions are called sequentially:
* ``_addr()``
* ``_intf_network()``
* ``_intf_ctrl()``
After resizing the ``varname`` inst... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L322-L350 |
cuihantao/andes | andes/system.py | PowerSystem.rmgen | def rmgen(self, idx):
"""
Remove the static generators if their dynamic models exist
Parameters
----------
idx : list
A list of static generator idx
Returns
-------
None
"""
stagens = []
for device, stagen in zip(self.d... | python | def rmgen(self, idx):
"""
Remove the static generators if their dynamic models exist
Parameters
----------
idx : list
A list of static generator idx
Returns
-------
None
"""
stagens = []
for device, stagen in zip(self.d... | Remove the static generators if their dynamic models exist
Parameters
----------
idx : list
A list of static generator idx
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L370-L389 |
cuihantao/andes | andes/system.py | PowerSystem.check_event | def check_event(self, sim_time):
"""
Check for event occurrance for``Event`` group models at ``sim_time``
Parameters
----------
sim_time : float
The current simulation time
Returns
-------
list
A list of model names who report (an... | python | def check_event(self, sim_time):
"""
Check for event occurrance for``Event`` group models at ``sim_time``
Parameters
----------
sim_time : float
The current simulation time
Returns
-------
list
A list of model names who report (an... | Check for event occurrance for``Event`` group models at ``sim_time``
Parameters
----------
sim_time : float
The current simulation time
Returns
-------
list
A list of model names who report (an) event(s) at ``sim_time`` | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L391-L413 |
cuihantao/andes | andes/system.py | PowerSystem.get_event_times | def get_event_times(self):
"""
Return event times of Fault, Breaker and other timed events
Returns
-------
list
A sorted list of event times
"""
times = []
times.extend(self.Breaker.get_times())
for model in self.__dict__['Event'].al... | python | def get_event_times(self):
"""
Return event times of Fault, Breaker and other timed events
Returns
-------
list
A sorted list of event times
"""
times = []
times.extend(self.Breaker.get_times())
for model in self.__dict__['Event'].al... | Return event times of Fault, Breaker and other timed events
Returns
-------
list
A sorted list of event times | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L415-L434 |
cuihantao/andes | andes/system.py | PowerSystem.load_config | def load_config(self, conf_path):
"""
Load config from an ``andes.conf`` file.
This function creates a ``configparser.ConfigParser`` object to read
the specified conf file and calls the ``load_config`` function of the
config instances of the system and the routines.
Par... | python | def load_config(self, conf_path):
"""
Load config from an ``andes.conf`` file.
This function creates a ``configparser.ConfigParser`` object to read
the specified conf file and calls the ``load_config`` function of the
config instances of the system and the routines.
Par... | Load config from an ``andes.conf`` file.
This function creates a ``configparser.ConfigParser`` object to read
the specified conf file and calls the ``load_config`` function of the
config instances of the system and the routines.
Parameters
----------
conf_path : None or... | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L436-L464 |
cuihantao/andes | andes/system.py | PowerSystem.dump_config | def dump_config(self, file_path):
"""
Dump system and routine configurations to an rc-formatted file.
Parameters
----------
file_path : str
path to the configuration file. The user will be prompted if the
file already exists.
Returns
----... | python | def dump_config(self, file_path):
"""
Dump system and routine configurations to an rc-formatted file.
Parameters
----------
file_path : str
path to the configuration file. The user will be prompted if the
file already exists.
Returns
----... | Dump system and routine configurations to an rc-formatted file.
Parameters
----------
file_path : str
path to the configuration file. The user will be prompted if the
file already exists.
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L466-L494 |
cuihantao/andes | andes/system.py | PowerSystem.check_islands | def check_islands(self, show_info=False):
"""
Check the connectivity for the ac system
Parameters
----------
show_info : bool
Show information when the system has islands. To be used when
initializing power flow.
Returns
-------
N... | python | def check_islands(self, show_info=False):
"""
Check the connectivity for the ac system
Parameters
----------
show_info : bool
Show information when the system has islands. To be used when
initializing power flow.
Returns
-------
N... | Check the connectivity for the ac system
Parameters
----------
show_info : bool
Show information when the system has islands. To be used when
initializing power flow.
Returns
-------
None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L496-L550 |
cuihantao/andes | andes/system.py | PowerSystem.get_busdata | def get_busdata(self, sort_names=False):
"""
get ac bus data from solved power flow
"""
if self.pflow.solved is False:
logger.error('Power flow not solved when getting bus data.')
return tuple([False] * 8)
idx = self.Bus.idx
names = self.Bus.name
... | python | def get_busdata(self, sort_names=False):
"""
get ac bus data from solved power flow
"""
if self.pflow.solved is False:
logger.error('Power flow not solved when getting bus data.')
return tuple([False] * 8)
idx = self.Bus.idx
names = self.Bus.name
... | get ac bus data from solved power flow | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L552-L578 |
cuihantao/andes | andes/system.py | PowerSystem.get_nodedata | def get_nodedata(self, sort_names=False):
"""
get dc node data from solved power flow
"""
if not self.Node.n:
return
if not self.pflow.solved:
logger.error('Power flow not solved when getting bus data.')
return tuple([False] * 7)
idx = ... | python | def get_nodedata(self, sort_names=False):
"""
get dc node data from solved power flow
"""
if not self.Node.n:
return
if not self.pflow.solved:
logger.error('Power flow not solved when getting bus data.')
return tuple([False] * 7)
idx = ... | get dc node data from solved power flow | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L580-L599 |
cuihantao/andes | andes/system.py | PowerSystem.get_linedata | def get_linedata(self, sort_names=False):
"""
get line data from solved power flow
"""
if not self.pflow.solved:
logger.error('Power flow not solved when getting line data.')
return tuple([False] * 7)
idx = self.Line.idx
fr = self.Line.bus1
... | python | def get_linedata(self, sort_names=False):
"""
get line data from solved power flow
"""
if not self.pflow.solved:
logger.error('Power flow not solved when getting line data.')
return tuple([False] * 7)
idx = self.Line.idx
fr = self.Line.bus1
... | get line data from solved power flow | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L601-L629 |
cuihantao/andes | andes/system.py | Group.register_model | def register_model(self, model):
"""
Register ``model`` to this group
:param model: model name
:return: None
"""
assert isinstance(model, str)
if model not in self.all_models:
self.all_models.append(model) | python | def register_model(self, model):
"""
Register ``model`` to this group
:param model: model name
:return: None
"""
assert isinstance(model, str)
if model not in self.all_models:
self.all_models.append(model) | Register ``model`` to this group
:param model: model name
:return: None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L651-L661 |
cuihantao/andes | andes/system.py | Group.register_element | def register_element(self, model, idx):
"""
Register element with index ``idx`` to ``model``
:param model: model name
:param idx: element idx
:return: final element idx
"""
if idx is None:
idx = model + '_' + str(len(self._idx_model))
self._... | python | def register_element(self, model, idx):
"""
Register element with index ``idx`` to ``model``
:param model: model name
:param idx: element idx
:return: final element idx
"""
if idx is None:
idx = model + '_' + str(len(self._idx_model))
self._... | Register element with index ``idx`` to ``model``
:param model: model name
:param idx: element idx
:return: final element idx | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L663-L678 |
cuihantao/andes | andes/system.py | Group.get_field | def get_field(self, field, idx):
"""
Return the field ``field`` of elements ``idx`` in the group
:param field: field name
:param idx: element idx
:return: values of the requested field
"""
ret = []
scalar = False
# TODO: ensure idx is unique in t... | python | def get_field(self, field, idx):
"""
Return the field ``field`` of elements ``idx`` in the group
:param field: field name
:param idx: element idx
:return: values of the requested field
"""
ret = []
scalar = False
# TODO: ensure idx is unique in t... | Return the field ``field`` of elements ``idx`` in the group
:param field: field name
:param idx: element idx
:return: values of the requested field | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L680-L705 |
cuihantao/andes | andes/system.py | Group.set_field | def set_field(self, field, idx, value):
"""
Set the field ``field`` of elements ``idx`` to ``value``.
This function does not if the field is valid for all models.
:param field: field name
:param idx: element idx
:param value: value of fields to set
:return: None... | python | def set_field(self, field, idx, value):
"""
Set the field ``field`` of elements ``idx`` to ``value``.
This function does not if the field is valid for all models.
:param field: field name
:param idx: element idx
:param value: value of fields to set
:return: None... | Set the field ``field`` of elements ``idx`` to ``value``.
This function does not if the field is valid for all models.
:param field: field name
:param idx: element idx
:param value: value of fields to set
:return: None | https://github.com/cuihantao/andes/blob/7067898d4f26ce7534e968b8486c4aa8fe3a511a/andes/system.py#L707-L730 |
DiamondLightSource/python-workflows | workflows/contrib/start_service.py | ServiceStarter.run | def run(
self,
cmdline_args=None,
program_name="start_service",
version=workflows.version(),
**kwargs
):
"""Example command line interface to start services.
:param cmdline_args: List of command line arguments to pass to parser
:param program_name: Nam... | python | def run(
self,
cmdline_args=None,
program_name="start_service",
version=workflows.version(),
**kwargs
):
"""Example command line interface to start services.
:param cmdline_args: List of command line arguments to pass to parser
:param program_name: Nam... | Example command line interface to start services.
:param cmdline_args: List of command line arguments to pass to parser
:param program_name: Name of the command line tool to display in help
:param version: Version number to print when run with '--version' | https://github.com/DiamondLightSource/python-workflows/blob/7ef47b457655b96f4d2ef7ee9863cf1b6d20e023/workflows/contrib/start_service.py#L49-L145 |
webstack/webstack-django-sorting | webstack_django_sorting/util.py | get_sort_field | def get_sort_field(request):
"""
Retrieve field used for sorting a queryset
:param request: HTTP request
:return: the sorted field name, prefixed with "-" if ordering is descending
"""
sort_direction = request.GET.get("dir")
field_name = (request.GET.get("sort") or "") if sort_direction els... | python | def get_sort_field(request):
"""
Retrieve field used for sorting a queryset
:param request: HTTP request
:return: the sorted field name, prefixed with "-" if ordering is descending
"""
sort_direction = request.GET.get("dir")
field_name = (request.GET.get("sort") or "") if sort_direction els... | Retrieve field used for sorting a queryset
:param request: HTTP request
:return: the sorted field name, prefixed with "-" if ordering is descending | https://github.com/webstack/webstack-django-sorting/blob/e78bfb890da1da6eb3cc12a7151390317ac4be99/webstack_django_sorting/util.py#L4-L15 |
webstack/webstack-django-sorting | webstack_django_sorting/templatetags/sorting_tags.py | anchor | def anchor(parser, token):
"""
Parses a tag that's supposed to be in this format '{% anchor field title %}'
Title may be a "string", _("trans string"), or variable
"""
bits = [b for b in token.split_contents()]
if len(bits) < 2:
raise template.TemplateSyntaxError("anchor tag takes at lea... | python | def anchor(parser, token):
"""
Parses a tag that's supposed to be in this format '{% anchor field title %}'
Title may be a "string", _("trans string"), or variable
"""
bits = [b for b in token.split_contents()]
if len(bits) < 2:
raise template.TemplateSyntaxError("anchor tag takes at lea... | Parses a tag that's supposed to be in this format '{% anchor field title %}'
Title may be a "string", _("trans string"), or variable | https://github.com/webstack/webstack-django-sorting/blob/e78bfb890da1da6eb3cc12a7151390317ac4be99/webstack_django_sorting/templatetags/sorting_tags.py#L25-L51 |
iliana/python-simplemediawiki | simplemediawiki.py | MediaWiki._fetch_http | def _fetch_http(self, url, params, force_get=False):
"""
Standard HTTP request handler for this class with gzip and cookie
support. This was separated out of :py:func:`MediaWiki.call` to make
:py:func:`MediaWiki.normalize_api_url` useful.
.. note::
This function shoul... | python | def _fetch_http(self, url, params, force_get=False):
"""
Standard HTTP request handler for this class with gzip and cookie
support. This was separated out of :py:func:`MediaWiki.call` to make
:py:func:`MediaWiki.normalize_api_url` useful.
.. note::
This function shoul... | Standard HTTP request handler for this class with gzip and cookie
support. This was separated out of :py:func:`MediaWiki.call` to make
:py:func:`MediaWiki.normalize_api_url` useful.
.. note::
This function should not be used. Use :py:func:`MediaWiki.call`
instead.
... | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L120-L167 |
iliana/python-simplemediawiki | simplemediawiki.py | MediaWiki.call | def call(self, params):
"""
Make an API call to the wiki. *params* is a dictionary of query string
arguments. For example, to get basic information about the wiki, run:
>>> wiki.call({'action': 'query', 'meta': 'siteinfo'})
which would make a call to
``http://domain/w/a... | python | def call(self, params):
"""
Make an API call to the wiki. *params* is a dictionary of query string
arguments. For example, to get basic information about the wiki, run:
>>> wiki.call({'action': 'query', 'meta': 'siteinfo'})
which would make a call to
``http://domain/w/a... | Make an API call to the wiki. *params* is a dictionary of query string
arguments. For example, to get basic information about the wiki, run:
>>> wiki.call({'action': 'query', 'meta': 'siteinfo'})
which would make a call to
``http://domain/w/api.php?action=query&meta=siteinfo&format=jso... | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L169-L183 |
iliana/python-simplemediawiki | simplemediawiki.py | MediaWiki.normalize_api_url | def normalize_api_url(self):
"""
Checks that the API URL used to initialize this object actually returns
JSON. If it doesn't, make some educated guesses and try to find the
correct URL.
:returns: a valid API URL or ``None``
"""
def tester(self, api_url):
... | python | def normalize_api_url(self):
"""
Checks that the API URL used to initialize this object actually returns
JSON. If it doesn't, make some educated guesses and try to find the
correct URL.
:returns: a valid API URL or ``None``
"""
def tester(self, api_url):
... | Checks that the API URL used to initialize this object actually returns
JSON. If it doesn't, make some educated guesses and try to find the
correct URL.
:returns: a valid API URL or ``None`` | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L185-L217 |
iliana/python-simplemediawiki | simplemediawiki.py | MediaWiki.login | def login(self, user, passwd):
"""
Logs into the wiki with username *user* and password *passwd*. Returns
``True`` on successful login.
:param user: username
:param passwd: password
:returns: ``True`` on successful login, otherwise ``False``
"""
def do_lo... | python | def login(self, user, passwd):
"""
Logs into the wiki with username *user* and password *passwd*. Returns
``True`` on successful login.
:param user: username
:param passwd: password
:returns: ``True`` on successful login, otherwise ``False``
"""
def do_lo... | Logs into the wiki with username *user* and password *passwd*. Returns
``True`` on successful login.
:param user: username
:param passwd: password
:returns: ``True`` on successful login, otherwise ``False`` | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L219-L250 |
iliana/python-simplemediawiki | simplemediawiki.py | MediaWiki.limits | def limits(self, low, high):
"""
Convenience function for determining appropriate limits in the API. If
the (usually logged-in) client has the ``apihighlimits`` right, it will
return *high*; otherwise it will return *low*.
It's generally a good idea to use the highest limit poss... | python | def limits(self, low, high):
"""
Convenience function for determining appropriate limits in the API. If
the (usually logged-in) client has the ``apihighlimits`` right, it will
return *high*; otherwise it will return *low*.
It's generally a good idea to use the highest limit poss... | Convenience function for determining appropriate limits in the API. If
the (usually logged-in) client has the ``apihighlimits`` right, it will
return *high*; otherwise it will return *low*.
It's generally a good idea to use the highest limit possible; this
reduces the amount of HTTP req... | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L263-L287 |
iliana/python-simplemediawiki | simplemediawiki.py | MediaWiki.namespaces | def namespaces(self, psuedo=True):
"""
Fetches a list of namespaces for this wiki and returns them as a
dictionary of namespace IDs corresponding to namespace names. If
*psuedo* is ``True``, the dictionary will also list psuedo-namespaces,
which are the "Special:" and "Media:" na... | python | def namespaces(self, psuedo=True):
"""
Fetches a list of namespaces for this wiki and returns them as a
dictionary of namespace IDs corresponding to namespace names. If
*psuedo* is ``True``, the dictionary will also list psuedo-namespaces,
which are the "Special:" and "Media:" na... | Fetches a list of namespaces for this wiki and returns them as a
dictionary of namespace IDs corresponding to namespace names. If
*psuedo* is ``True``, the dictionary will also list psuedo-namespaces,
which are the "Special:" and "Media:" namespaces (special because they
have no content ... | https://github.com/iliana/python-simplemediawiki/blob/e531dabcb6541cc95770ce3de418cabc6d2424a1/simplemediawiki.py#L289-L319 |
LettError/ufoProcessor | Lib/ufoProcessor/sp3.py | SuperpolatorReader.readLocationElement | def readLocationElement(self, locationElement):
""" Format 0 location reader """
if self._strictAxisNames and not self.documentObject.axes:
raise DesignSpaceDocumentError("No axes defined")
loc = {}
for dimensionElement in locationElement.findall(".dimension"):
di... | python | def readLocationElement(self, locationElement):
""" Format 0 location reader """
if self._strictAxisNames and not self.documentObject.axes:
raise DesignSpaceDocumentError("No axes defined")
loc = {}
for dimensionElement in locationElement.findall(".dimension"):
di... | Format 0 location reader | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/sp3.py#L303-L330 |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | build | def build(
documentPath,
outputUFOFormatVersion=3,
roundGeometry=True,
verbose=True, # not supported
logPath=None, # not supported
progressFunc=None, # not supported
processRules=True,
logger=None,
useVarlib=False,
... | python | def build(
documentPath,
outputUFOFormatVersion=3,
roundGeometry=True,
verbose=True, # not supported
logPath=None, # not supported
progressFunc=None, # not supported
processRules=True,
logger=None,
useVarlib=False,
... | Simple builder for UFO designspaces. | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L89-L124 |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | DesignSpaceProcessor.getInfoMutator | def getInfoMutator(self):
""" Returns a info mutator """
if self._infoMutator:
return self._infoMutator
infoItems = []
for sourceDescriptor in self.sources:
if sourceDescriptor.layerName is not None:
continue
loc = Location(sourceDescri... | python | def getInfoMutator(self):
""" Returns a info mutator """
if self._infoMutator:
return self._infoMutator
infoItems = []
for sourceDescriptor in self.sources:
if sourceDescriptor.layerName is not None:
continue
loc = Location(sourceDescri... | Returns a info mutator | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L346-L363 |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | DesignSpaceProcessor.getKerningMutator | def getKerningMutator(self, pairs=None):
""" Return a kerning mutator, collect the sources, build mathGlyphs.
If no pairs are given: calculate the whole table.
If pairs are given then query the sources for a value and make a mutator only with those values.
"""
if self._ke... | python | def getKerningMutator(self, pairs=None):
""" Return a kerning mutator, collect the sources, build mathGlyphs.
If no pairs are given: calculate the whole table.
If pairs are given then query the sources for a value and make a mutator only with those values.
"""
if self._ke... | Return a kerning mutator, collect the sources, build mathGlyphs.
If no pairs are given: calculate the whole table.
If pairs are given then query the sources for a value and make a mutator only with those values. | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L365-L405 |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | DesignSpaceProcessor.collectMastersForGlyph | def collectMastersForGlyph(self, glyphName, decomposeComponents=False):
""" Return a glyph mutator.defaultLoc
decomposeComponents = True causes the source glyphs to be decomposed first
before building the mutator. That gives you instances that do not depend
on a complete font... | python | def collectMastersForGlyph(self, glyphName, decomposeComponents=False):
""" Return a glyph mutator.defaultLoc
decomposeComponents = True causes the source glyphs to be decomposed first
before building the mutator. That gives you instances that do not depend
on a complete font... | Return a glyph mutator.defaultLoc
decomposeComponents = True causes the source glyphs to be decomposed first
before building the mutator. That gives you instances that do not depend
on a complete font. If you're calculating previews for instance.
XXX check glyphs in laye... | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L454-L553 |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | DesignSpaceProcessor.makeInstance | def makeInstance(self, instanceDescriptor,
doRules=False,
glyphNames=None,
pairs=None,
bend=False):
""" Generate a font object for this instance """
font = self._instantiateFont(None)
# make fonty things here
loc = Location(instanceDescript... | python | def makeInstance(self, instanceDescriptor,
doRules=False,
glyphNames=None,
pairs=None,
bend=False):
""" Generate a font object for this instance """
font = self._instantiateFont(None)
# make fonty things here
loc = Location(instanceDescript... | Generate a font object for this instance | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L597-L812 |
LettError/ufoProcessor | Lib/ufoProcessor/__init__.py | DesignSpaceProcessor._instantiateFont | def _instantiateFont(self, path):
""" Return a instance of a font object with all the given subclasses"""
try:
return self.fontClass(path,
layerClass=self.layerClass,
libClass=self.libClass,
kerningClass=self.kerningClass,
group... | python | def _instantiateFont(self, path):
""" Return a instance of a font object with all the given subclasses"""
try:
return self.fontClass(path,
layerClass=self.layerClass,
libClass=self.libClass,
kerningClass=self.kerningClass,
group... | Return a instance of a font object with all the given subclasses | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/__init__.py#L831-L848 |
LettError/ufoProcessor | Lib/ufoProcessor/emptyPen.py | checkGlyphIsEmpty | def checkGlyphIsEmpty(glyph, allowWhiteSpace=True):
"""
This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out gl... | python | def checkGlyphIsEmpty(glyph, allowWhiteSpace=True):
"""
This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out gl... | This will establish if the glyph is completely empty by drawing the glyph with an EmptyPen.
Additionally, the unicode of the glyph is checked against a list of known unicode whitespace
characters. This makes it possible to filter out glyphs that have a valid reason to be empty
and those that can... | https://github.com/LettError/ufoProcessor/blob/7c63e1c8aba2f2ef9b12edb6560aa6c58024a89a/Lib/ufoProcessor/emptyPen.py#L34-L75 |
signetlabdei/sem | sem/runner.py | SimulationRunner.configure_and_build | def configure_and_build(self, show_progress=True, optimized=True,
skip_configuration=False):
"""
Configure and build the ns-3 code.
Args:
show_progress (bool): whether or not to display a progress bar
during compilation.
optimi... | python | def configure_and_build(self, show_progress=True, optimized=True,
skip_configuration=False):
"""
Configure and build the ns-3 code.
Args:
show_progress (bool): whether or not to display a progress bar
during compilation.
optimi... | Configure and build the ns-3 code.
Args:
show_progress (bool): whether or not to display a progress bar
during compilation.
optimized (bool): whether to use an optimized build. If False, use
a standard ./waf configure.
skip_configuration (bool... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L108-L154 |
signetlabdei/sem | sem/runner.py | SimulationRunner.get_build_output | def get_build_output(self, process):
"""
Parse the output of the ns-3 build process to extract the information
that is needed to draw the progress bar.
Args:
process: the subprocess instance to listen to.
"""
while True:
output = process.stdout.r... | python | def get_build_output(self, process):
"""
Parse the output of the ns-3 build process to extract the information
that is needed to draw the progress bar.
Args:
process: the subprocess instance to listen to.
"""
while True:
output = process.stdout.r... | Parse the output of the ns-3 build process to extract the information
that is needed to draw the progress bar.
Args:
process: the subprocess instance to listen to. | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L156-L181 |
signetlabdei/sem | sem/runner.py | SimulationRunner.get_available_parameters | def get_available_parameters(self):
"""
Return a list of the parameters made available by the script.
"""
# At the moment, we rely on regex to extract the list of available
# parameters. This solution will break if the format of the output
# changes, but this is the best... | python | def get_available_parameters(self):
"""
Return a list of the parameters made available by the script.
"""
# At the moment, we rely on regex to extract the list of available
# parameters. This solution will break if the format of the output
# changes, but this is the best... | Return a list of the parameters made available by the script. | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L183-L215 |
signetlabdei/sem | sem/runner.py | SimulationRunner.run_simulations | def run_simulations(self, parameter_list, data_folder):
"""
Run several simulations using a certain combination of parameters.
Yields results as simulations are completed.
Args:
parameter_list (list): list of parameter combinations to simulate.
data_folder (str)... | python | def run_simulations(self, parameter_list, data_folder):
"""
Run several simulations using a certain combination of parameters.
Yields results as simulations are completed.
Args:
parameter_list (list): list of parameter combinations to simulate.
data_folder (str)... | Run several simulations using a certain combination of parameters.
Yields results as simulations are completed.
Args:
parameter_list (list): list of parameter combinations to simulate.
data_folder (str): folder in which to save subfolders containing
simulation o... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/runner.py#L221-L280 |
signetlabdei/sem | sem/utils.py | list_param_combinations | def list_param_combinations(param_ranges):
"""
Create a list of all parameter combinations from a dictionary specifying
desired parameter values as lists.
Example:
>>> param_ranges = {'a': [1], 'b': [2, 3]}
>>> list_param_combinations(param_ranges)
[{'a': 1, 'b': 2}, {'a': 1, '... | python | def list_param_combinations(param_ranges):
"""
Create a list of all parameter combinations from a dictionary specifying
desired parameter values as lists.
Example:
>>> param_ranges = {'a': [1], 'b': [2, 3]}
>>> list_param_combinations(param_ranges)
[{'a': 1, 'b': 2}, {'a': 1, '... | Create a list of all parameter combinations from a dictionary specifying
desired parameter values as lists.
Example:
>>> param_ranges = {'a': [1], 'b': [2, 3]}
>>> list_param_combinations(param_ranges)
[{'a': 1, 'b': 2}, {'a': 1, 'b': 3}]
Additionally, this function is robust in c... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/utils.py#L13-L38 |
signetlabdei/sem | sem/utils.py | get_command_from_result | def get_command_from_result(script, result, debug=False):
"""
Return the command that is needed to obtain a certain result.
Args:
params (dict): Dictionary containing parameter: value pairs.
debug (bool): Whether the command should include the debugging
template.
"""
if ... | python | def get_command_from_result(script, result, debug=False):
"""
Return the command that is needed to obtain a certain result.
Args:
params (dict): Dictionary containing parameter: value pairs.
debug (bool): Whether the command should include the debugging
template.
"""
if ... | Return the command that is needed to obtain a certain result.
Args:
params (dict): Dictionary containing parameter: value pairs.
debug (bool): Whether the command should include the debugging
template. | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/utils.py#L41-L59 |
signetlabdei/sem | sem/utils.py | automatic_parser | def automatic_parser(result, dtypes={}, converters={}):
"""
Try and automatically convert strings formatted as tables into nested
list structures.
Under the hood, this function essentially applies the genfromtxt function
to all files in the output, and passes it the additional kwargs.
Args:
... | python | def automatic_parser(result, dtypes={}, converters={}):
"""
Try and automatically convert strings formatted as tables into nested
list structures.
Under the hood, this function essentially applies the genfromtxt function
to all files in the output, and passes it the additional kwargs.
Args:
... | Try and automatically convert strings formatted as tables into nested
list structures.
Under the hood, this function essentially applies the genfromtxt function
to all files in the output, and passes it the additional kwargs.
Args:
result (dict): the result to parse.
dtypes (dict): a dicti... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/utils.py#L69-L99 |
signetlabdei/sem | sem/manager.py | CampaignManager.new | def new(cls, ns_path, script, campaign_dir, runner_type='Auto',
overwrite=False, optimized=True, check_repo=True):
"""
Create a new campaign from an ns-3 installation and a campaign
directory.
This method will create a DatabaseManager, which will install a
database i... | python | def new(cls, ns_path, script, campaign_dir, runner_type='Auto',
overwrite=False, optimized=True, check_repo=True):
"""
Create a new campaign from an ns-3 installation and a campaign
directory.
This method will create a DatabaseManager, which will install a
database i... | Create a new campaign from an ns-3 installation and a campaign
directory.
This method will create a DatabaseManager, which will install a
database in the specified campaign_dir. If a database is already
available at the ns_path described in the specified campaign_dir and
its con... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L57-L136 |
signetlabdei/sem | sem/manager.py | CampaignManager.load | def load(cls, campaign_dir, ns_path=None, runner_type='Auto',
optimized=True, check_repo=True):
"""
Load an existing simulation campaign.
Note that specifying an ns-3 installation is not compulsory when using
this method: existing results will be available, but in order to ... | python | def load(cls, campaign_dir, ns_path=None, runner_type='Auto',
optimized=True, check_repo=True):
"""
Load an existing simulation campaign.
Note that specifying an ns-3 installation is not compulsory when using
this method: existing results will be available, but in order to ... | Load an existing simulation campaign.
Note that specifying an ns-3 installation is not compulsory when using
this method: existing results will be available, but in order to run
additional simulations it will be necessary to specify a
SimulationRunner object, and assign it to the Campai... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L139-L176 |
signetlabdei/sem | sem/manager.py | CampaignManager.create_runner | def create_runner(ns_path, script, runner_type='Auto',
optimized=True):
"""
Create a SimulationRunner from a string containing the desired
class implementation, and return it.
Args:
ns_path (str): path to the ns-3 installation to employ in this
... | python | def create_runner(ns_path, script, runner_type='Auto',
optimized=True):
"""
Create a SimulationRunner from a string containing the desired
class implementation, and return it.
Args:
ns_path (str): path to the ns-3 installation to employ in this
... | Create a SimulationRunner from a string containing the desired
class implementation, and return it.
Args:
ns_path (str): path to the ns-3 installation to employ in this
SimulationRunner.
script (str): ns-3 script that will be executed to run simulations.
... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L178-L208 |
signetlabdei/sem | sem/manager.py | CampaignManager.run_simulations | def run_simulations(self, param_list, show_progress=True):
"""
Run several simulations specified by a list of parameter combinations.
Note: this function does not verify whether we already have the
required simulations in the database - it just runs all the parameter
combination... | python | def run_simulations(self, param_list, show_progress=True):
"""
Run several simulations specified by a list of parameter combinations.
Note: this function does not verify whether we already have the
required simulations in the database - it just runs all the parameter
combination... | Run several simulations specified by a list of parameter combinations.
Note: this function does not verify whether we already have the
required simulations in the database - it just runs all the parameter
combinations that are specified in the list.
Args:
param_list (list):... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L214-L288 |
signetlabdei/sem | sem/manager.py | CampaignManager.get_missing_simulations | def get_missing_simulations(self, param_list, runs=None):
"""
Return a list of the simulations among the required ones that are not
available in the database.
Args:
param_list (list): a list of dictionaries containing all the
parameters combinations.
... | python | def get_missing_simulations(self, param_list, runs=None):
"""
Return a list of the simulations among the required ones that are not
available in the database.
Args:
param_list (list): a list of dictionaries containing all the
parameters combinations.
... | Return a list of the simulations among the required ones that are not
available in the database.
Args:
param_list (list): a list of dictionaries containing all the
parameters combinations.
runs (int): an integer representing how many repetitions are wanted
... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L290-L332 |
signetlabdei/sem | sem/manager.py | CampaignManager.run_missing_simulations | def run_missing_simulations(self, param_list, runs=None):
"""
Run the simulations from the parameter list that are not yet available
in the database.
This function also makes sure that we have at least runs replications
for each parameter combination.
Additionally, para... | python | def run_missing_simulations(self, param_list, runs=None):
"""
Run the simulations from the parameter list that are not yet available
in the database.
This function also makes sure that we have at least runs replications
for each parameter combination.
Additionally, para... | Run the simulations from the parameter list that are not yet available
in the database.
This function also makes sure that we have at least runs replications
for each parameter combination.
Additionally, param_list can either be a list containing the desired
parameter combinati... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L334-L360 |
signetlabdei/sem | sem/manager.py | CampaignManager.get_results_as_numpy_array | def get_results_as_numpy_array(self, parameter_space,
result_parsing_function, runs):
"""
Return the results relative to the desired parameter space in the form
of a numpy array.
Args:
parameter_space (dict): dictionary containing
... | python | def get_results_as_numpy_array(self, parameter_space,
result_parsing_function, runs):
"""
Return the results relative to the desired parameter space in the form
of a numpy array.
Args:
parameter_space (dict): dictionary containing
... | Return the results relative to the desired parameter space in the form
of a numpy array.
Args:
parameter_space (dict): dictionary containing
parameter/list-of-values pairs.
result_parsing_function (function): user-defined function, taking a
result... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L366-L383 |
signetlabdei/sem | sem/manager.py | CampaignManager.save_to_mat_file | def save_to_mat_file(self, parameter_space,
result_parsing_function,
filename, runs):
"""
Return the results relative to the desired parameter space in the form
of a .mat file.
Args:
parameter_space (dict): dictionary contain... | python | def save_to_mat_file(self, parameter_space,
result_parsing_function,
filename, runs):
"""
Return the results relative to the desired parameter space in the form
of a .mat file.
Args:
parameter_space (dict): dictionary contain... | Return the results relative to the desired parameter space in the form
of a .mat file.
Args:
parameter_space (dict): dictionary containing
parameter/list-of-values pairs.
result_parsing_function (function): user-defined function, taking a
result d... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L385-L421 |
signetlabdei/sem | sem/manager.py | CampaignManager.save_to_npy_file | def save_to_npy_file(self, parameter_space,
result_parsing_function,
filename, runs):
"""
Save results to a numpy array file format.
"""
np.save(filename, self.get_results_as_numpy_array(
parameter_space, result_parsing_functi... | python | def save_to_npy_file(self, parameter_space,
result_parsing_function,
filename, runs):
"""
Save results to a numpy array file format.
"""
np.save(filename, self.get_results_as_numpy_array(
parameter_space, result_parsing_functi... | Save results to a numpy array file format. | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L423-L430 |
signetlabdei/sem | sem/manager.py | CampaignManager.save_to_folders | def save_to_folders(self, parameter_space, folder_name, runs):
"""
Save results to a folder structure.
"""
self.space_to_folders(self.db.get_results(), {}, parameter_space, runs,
folder_name) | python | def save_to_folders(self, parameter_space, folder_name, runs):
"""
Save results to a folder structure.
"""
self.space_to_folders(self.db.get_results(), {}, parameter_space, runs,
folder_name) | Save results to a folder structure. | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L432-L437 |
signetlabdei/sem | sem/manager.py | CampaignManager.space_to_folders | def space_to_folders(self, current_result_list, current_query, param_space,
runs, current_directory):
"""
Convert a parameter space specification to a directory tree with a
nested structure.
"""
# Base case: we iterate over the runs and copy files in the ... | python | def space_to_folders(self, current_result_list, current_query, param_space,
runs, current_directory):
"""
Convert a parameter space specification to a directory tree with a
nested structure.
"""
# Base case: we iterate over the runs and copy files in the ... | Convert a parameter space specification to a directory tree with a
nested structure. | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L439-L478 |
signetlabdei/sem | sem/manager.py | CampaignManager.get_results_as_xarray | def get_results_as_xarray(self, parameter_space,
result_parsing_function,
output_labels, runs):
"""
Return the results relative to the desired parameter space in the form
of an xarray data structure.
Args:
parameter... | python | def get_results_as_xarray(self, parameter_space,
result_parsing_function,
output_labels, runs):
"""
Return the results relative to the desired parameter space in the form
of an xarray data structure.
Args:
parameter... | Return the results relative to the desired parameter space in the form
of an xarray data structure.
Args:
parameter_space (dict): The space of parameters to export.
result_parsing_function (function): user-defined function, taking a
result dictionary as argument,... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L480-L516 |
signetlabdei/sem | sem/manager.py | CampaignManager.get_space | def get_space(self, current_result_list, current_query, param_space, runs,
result_parsing_function):
"""
Convert a parameter space specification to a nested array structure
representing the space. In other words, if the parameter space is::
param_space = {
... | python | def get_space(self, current_result_list, current_query, param_space, runs,
result_parsing_function):
"""
Convert a parameter space specification to a nested array structure
representing the space. In other words, if the parameter space is::
param_space = {
... | Convert a parameter space specification to a nested array structure
representing the space. In other words, if the parameter space is::
param_space = {
'a': [1, 2],
'b': [3, 4]
}
the function will return a structure like the following::
... | https://github.com/signetlabdei/sem/blob/5077dd7a6d15644a18790bb6fde320e905f0fef0/sem/manager.py#L525-L592 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.