body_hash
stringlengths 64
64
| body
stringlengths 23
109k
| docstring
stringlengths 1
57k
| path
stringlengths 4
198
| name
stringlengths 1
115
| repository_name
stringlengths 7
111
| repository_stars
float64 0
191k
| lang
stringclasses 1
value | body_without_docstring
stringlengths 14
108k
| unified
stringlengths 45
133k
|
|---|---|---|---|---|---|---|---|---|---|
c4bc01bfb47a683eedd21c08e3116d22009fad754bc9fa4f05237579b00686e6
|
@staticmethod
def _convert_configuration(configuration):
'Converts the given execution configuration to the 2.0 schema\n\n :param configuration: The previous configuration\n :type configuration: dict\n :return: The converted configuration\n :rtype: dict\n '
previous = previous_version.ExecutionConfiguration(configuration)
converted = previous.get_dict()
converted['version'] = SCHEMA_VERSION
ExecutionConfiguration._convert_configuration_task(converted, 'pre', 'pre_task')
ExecutionConfiguration._convert_configuration_task(converted, 'main', 'job_task')
ExecutionConfiguration._convert_configuration_task(converted, 'post', 'post_task')
return converted
|
Converts the given execution configuration to the 2.0 schema
:param configuration: The previous configuration
:type configuration: dict
:return: The converted configuration
:rtype: dict
|
scale/job/execution/configuration/json/exe_config.py
|
_convert_configuration
|
kaydoh/scale
| 121
|
python
|
@staticmethod
def _convert_configuration(configuration):
'Converts the given execution configuration to the 2.0 schema\n\n :param configuration: The previous configuration\n :type configuration: dict\n :return: The converted configuration\n :rtype: dict\n '
previous = previous_version.ExecutionConfiguration(configuration)
converted = previous.get_dict()
converted['version'] = SCHEMA_VERSION
ExecutionConfiguration._convert_configuration_task(converted, 'pre', 'pre_task')
ExecutionConfiguration._convert_configuration_task(converted, 'main', 'job_task')
ExecutionConfiguration._convert_configuration_task(converted, 'post', 'post_task')
return converted
|
@staticmethod
def _convert_configuration(configuration):
'Converts the given execution configuration to the 2.0 schema\n\n :param configuration: The previous configuration\n :type configuration: dict\n :return: The converted configuration\n :rtype: dict\n '
previous = previous_version.ExecutionConfiguration(configuration)
converted = previous.get_dict()
converted['version'] = SCHEMA_VERSION
ExecutionConfiguration._convert_configuration_task(converted, 'pre', 'pre_task')
ExecutionConfiguration._convert_configuration_task(converted, 'main', 'job_task')
ExecutionConfiguration._convert_configuration_task(converted, 'post', 'post_task')
return converted<|docstring|>Converts the given execution configuration to the 2.0 schema
:param configuration: The previous configuration
:type configuration: dict
:return: The converted configuration
:rtype: dict<|endoftext|>
|
4d588d284c71f3a362cc7955106bd31eb6e7dcd16683e5ac47eee614af629b19
|
@staticmethod
def _convert_configuration_task(configuration, task_type, old_task_name):
'Converts the given task in the configuration\n\n :param configuration: The configuration to convert\n :type configuration: dict\n :param task_type: The type of the task\n :type task_type: string\n :param old_task_name: The old task name\n :type old_task_name: string\n '
if (old_task_name not in configuration):
return
old_task_dict = configuration[old_task_name]
new_task_dict = {'task_id': old_task_name, 'type': task_type, 'args': ''}
if ('workspaces' in old_task_dict):
new_workspace_dict = {}
new_task_dict['workspaces'] = new_workspace_dict
for old_workspace in old_task_dict['workspaces']:
name = old_workspace['name']
mode = old_workspace['mode']
new_workspace_dict[name] = {'mode': mode, 'volume_name': ('wksp_%s' % name)}
if ('settings' in old_task_dict):
new_settings_dict = {}
new_task_dict['settings'] = new_settings_dict
for old_setting in old_task_dict['settings']:
name = old_setting['name']
value = old_setting['value']
new_settings_dict[name] = value
if ('docker_params' in old_task_dict):
new_params_list = []
new_task_dict['docker_params'] = new_params_list
for old_param in old_task_dict['docker_params']:
new_params_list.append(old_param)
if ('tasks' not in configuration):
configuration['tasks'] = []
configuration['tasks'].append(new_task_dict)
del configuration[old_task_name]
|
Converts the given task in the configuration
:param configuration: The configuration to convert
:type configuration: dict
:param task_type: The type of the task
:type task_type: string
:param old_task_name: The old task name
:type old_task_name: string
|
scale/job/execution/configuration/json/exe_config.py
|
_convert_configuration_task
|
kaydoh/scale
| 121
|
python
|
@staticmethod
def _convert_configuration_task(configuration, task_type, old_task_name):
'Converts the given task in the configuration\n\n :param configuration: The configuration to convert\n :type configuration: dict\n :param task_type: The type of the task\n :type task_type: string\n :param old_task_name: The old task name\n :type old_task_name: string\n '
if (old_task_name not in configuration):
return
old_task_dict = configuration[old_task_name]
new_task_dict = {'task_id': old_task_name, 'type': task_type, 'args': }
if ('workspaces' in old_task_dict):
new_workspace_dict = {}
new_task_dict['workspaces'] = new_workspace_dict
for old_workspace in old_task_dict['workspaces']:
name = old_workspace['name']
mode = old_workspace['mode']
new_workspace_dict[name] = {'mode': mode, 'volume_name': ('wksp_%s' % name)}
if ('settings' in old_task_dict):
new_settings_dict = {}
new_task_dict['settings'] = new_settings_dict
for old_setting in old_task_dict['settings']:
name = old_setting['name']
value = old_setting['value']
new_settings_dict[name] = value
if ('docker_params' in old_task_dict):
new_params_list = []
new_task_dict['docker_params'] = new_params_list
for old_param in old_task_dict['docker_params']:
new_params_list.append(old_param)
if ('tasks' not in configuration):
configuration['tasks'] = []
configuration['tasks'].append(new_task_dict)
del configuration[old_task_name]
|
@staticmethod
def _convert_configuration_task(configuration, task_type, old_task_name):
'Converts the given task in the configuration\n\n :param configuration: The configuration to convert\n :type configuration: dict\n :param task_type: The type of the task\n :type task_type: string\n :param old_task_name: The old task name\n :type old_task_name: string\n '
if (old_task_name not in configuration):
return
old_task_dict = configuration[old_task_name]
new_task_dict = {'task_id': old_task_name, 'type': task_type, 'args': }
if ('workspaces' in old_task_dict):
new_workspace_dict = {}
new_task_dict['workspaces'] = new_workspace_dict
for old_workspace in old_task_dict['workspaces']:
name = old_workspace['name']
mode = old_workspace['mode']
new_workspace_dict[name] = {'mode': mode, 'volume_name': ('wksp_%s' % name)}
if ('settings' in old_task_dict):
new_settings_dict = {}
new_task_dict['settings'] = new_settings_dict
for old_setting in old_task_dict['settings']:
name = old_setting['name']
value = old_setting['value']
new_settings_dict[name] = value
if ('docker_params' in old_task_dict):
new_params_list = []
new_task_dict['docker_params'] = new_params_list
for old_param in old_task_dict['docker_params']:
new_params_list.append(old_param)
if ('tasks' not in configuration):
configuration['tasks'] = []
configuration['tasks'].append(new_task_dict)
del configuration[old_task_name]<|docstring|>Converts the given task in the configuration
:param configuration: The configuration to convert
:type configuration: dict
:param task_type: The type of the task
:type task_type: string
:param old_task_name: The old task name
:type old_task_name: string<|endoftext|>
|
7a952e1048a36ec03107cae70aea7f0ea51c4c8c05edaff6cdd2be207dac6ba9
|
@staticmethod
def _create_task(task_type):
'Creates a new task with the given type\n\n :param task_type: The task type\n :type task_type: string\n :return: The task dict\n :rtype: dict\n '
return {'type': task_type, 'args': ''}
|
Creates a new task with the given type
:param task_type: The task type
:type task_type: string
:return: The task dict
:rtype: dict
|
scale/job/execution/configuration/json/exe_config.py
|
_create_task
|
kaydoh/scale
| 121
|
python
|
@staticmethod
def _create_task(task_type):
'Creates a new task with the given type\n\n :param task_type: The task type\n :type task_type: string\n :return: The task dict\n :rtype: dict\n '
return {'type': task_type, 'args': }
|
@staticmethod
def _create_task(task_type):
'Creates a new task with the given type\n\n :param task_type: The task type\n :type task_type: string\n :return: The task dict\n :rtype: dict\n '
return {'type': task_type, 'args': }<|docstring|>Creates a new task with the given type
:param task_type: The task type
:type task_type: string
:return: The task dict
:rtype: dict<|endoftext|>
|
4876b516c128e5f84593b6789903473477a82eff298b02524124584c7f2492f1
|
def _get_task_dict(self, task_type):
'Returns the dict for the task with the given type, if it exists\n\n :param task_type: The task type\n :type task_type: string\n :return: The task dict, possibly None\n :rtype: dict\n '
for task_dict in self._configuration['tasks']:
if (task_dict['type'] == task_type):
return task_dict
return {}
|
Returns the dict for the task with the given type, if it exists
:param task_type: The task type
:type task_type: string
:return: The task dict, possibly None
:rtype: dict
|
scale/job/execution/configuration/json/exe_config.py
|
_get_task_dict
|
kaydoh/scale
| 121
|
python
|
def _get_task_dict(self, task_type):
'Returns the dict for the task with the given type, if it exists\n\n :param task_type: The task type\n :type task_type: string\n :return: The task dict, possibly None\n :rtype: dict\n '
for task_dict in self._configuration['tasks']:
if (task_dict['type'] == task_type):
return task_dict
return {}
|
def _get_task_dict(self, task_type):
'Returns the dict for the task with the given type, if it exists\n\n :param task_type: The task type\n :type task_type: string\n :return: The task dict, possibly None\n :rtype: dict\n '
for task_dict in self._configuration['tasks']:
if (task_dict['type'] == task_type):
return task_dict
return {}<|docstring|>Returns the dict for the task with the given type, if it exists
:param task_type: The task type
:type task_type: string
:return: The task dict, possibly None
:rtype: dict<|endoftext|>
|
8996b6804a0ab927d9130d451f94f45890c895e86c02654694259feaab781a17
|
def _populate_default_values(self):
'Populates any missing JSON fields that have default values\n '
if ('tasks' not in self._configuration):
self._configuration['tasks'] = []
|
Populates any missing JSON fields that have default values
|
scale/job/execution/configuration/json/exe_config.py
|
_populate_default_values
|
kaydoh/scale
| 121
|
python
|
def _populate_default_values(self):
'\n '
if ('tasks' not in self._configuration):
self._configuration['tasks'] = []
|
def _populate_default_values(self):
'\n '
if ('tasks' not in self._configuration):
self._configuration['tasks'] = []<|docstring|>Populates any missing JSON fields that have default values<|endoftext|>
|
53b49fd9ad47e730f04ef9812550c08a7d9725cfe8ab8340c647995946c1fd73
|
def verify_phone(request):
'\n # 1、验证手机格式\n # 2、生成验证码\n # 3、保存验证码\n # 4、发送验证码\n\n :param request:\n :return:\n '
phone_num = request.POST.get('phone_num')
if is_phone_num(phone_num):
if logics.send_verify_code(phone_num):
return render_json()
else:
return render_json(code=errors.SMS_SEND_ERR)
else:
return render_json(code=errors.PHONE_NUM_ERR)
|
# 1、验证手机格式
# 2、生成验证码
# 3、保存验证码
# 4、发送验证码
:param request:
:return:
|
user/apis.py
|
verify_phone
|
gz-1901/swiper
| 4
|
python
|
def verify_phone(request):
'\n # 1、验证手机格式\n # 2、生成验证码\n # 3、保存验证码\n # 4、发送验证码\n\n :param request:\n :return:\n '
phone_num = request.POST.get('phone_num')
if is_phone_num(phone_num):
if logics.send_verify_code(phone_num):
return render_json()
else:
return render_json(code=errors.SMS_SEND_ERR)
else:
return render_json(code=errors.PHONE_NUM_ERR)
|
def verify_phone(request):
'\n # 1、验证手机格式\n # 2、生成验证码\n # 3、保存验证码\n # 4、发送验证码\n\n :param request:\n :return:\n '
phone_num = request.POST.get('phone_num')
if is_phone_num(phone_num):
if logics.send_verify_code(phone_num):
return render_json()
else:
return render_json(code=errors.SMS_SEND_ERR)
else:
return render_json(code=errors.PHONE_NUM_ERR)<|docstring|># 1、验证手机格式
# 2、生成验证码
# 3、保存验证码
# 4、发送验证码
:param request:
:return:<|endoftext|>
|
0211d02c3e4e4844b7b80658955804d1f6ea95d472f6679d30f1bd39cc79e819
|
def login(request):
'\n 通过验证码登录或注册接口\n 如果手机号已存在,则登录,否则,注册\n\n # 1、检测验证码是否正确\n # 2、注册或登录\n\n :param request:\n :return:\n '
phone_num = request.POST.get('phone_num', '')
code = request.POST.get('code', '')
phone_num = phone_num.strip()
code = code.strip()
cached_code = cache.get(cache_keys.VERIFY_CODE_KEY_PREFIX.format(phone_num))
if (cached_code != code):
return render_json(code=errors.VERIFY_CODE_ERR)
(user, created) = User.get_or_create(phonenum=phone_num)
request.session['uid'] = user.id
logger.info('user.login, uid: {}'.format(user.id))
return render_json(data=user.to_dict())
|
通过验证码登录或注册接口
如果手机号已存在,则登录,否则,注册
# 1、检测验证码是否正确
# 2、注册或登录
:param request:
:return:
|
user/apis.py
|
login
|
gz-1901/swiper
| 4
|
python
|
def login(request):
'\n 通过验证码登录或注册接口\n 如果手机号已存在,则登录,否则,注册\n\n # 1、检测验证码是否正确\n # 2、注册或登录\n\n :param request:\n :return:\n '
phone_num = request.POST.get('phone_num', )
code = request.POST.get('code', )
phone_num = phone_num.strip()
code = code.strip()
cached_code = cache.get(cache_keys.VERIFY_CODE_KEY_PREFIX.format(phone_num))
if (cached_code != code):
return render_json(code=errors.VERIFY_CODE_ERR)
(user, created) = User.get_or_create(phonenum=phone_num)
request.session['uid'] = user.id
logger.info('user.login, uid: {}'.format(user.id))
return render_json(data=user.to_dict())
|
def login(request):
'\n 通过验证码登录或注册接口\n 如果手机号已存在,则登录,否则,注册\n\n # 1、检测验证码是否正确\n # 2、注册或登录\n\n :param request:\n :return:\n '
phone_num = request.POST.get('phone_num', )
code = request.POST.get('code', )
phone_num = phone_num.strip()
code = code.strip()
cached_code = cache.get(cache_keys.VERIFY_CODE_KEY_PREFIX.format(phone_num))
if (cached_code != code):
return render_json(code=errors.VERIFY_CODE_ERR)
(user, created) = User.get_or_create(phonenum=phone_num)
request.session['uid'] = user.id
logger.info('user.login, uid: {}'.format(user.id))
return render_json(data=user.to_dict())<|docstring|>通过验证码登录或注册接口
如果手机号已存在,则登录,否则,注册
# 1、检测验证码是否正确
# 2、注册或登录
:param request:
:return:<|endoftext|>
|
a14d3f2ac5ad3a70ac8d626e569c67ff4ffb7e7b2dda12ff95a7ba45285bb3d0
|
def param_curve(t, R, r, d):
'Coordinates of a hypotrochoid for parameters t, R, r and d'
x = (((R - r) * cos(t)) + (d * cos((((R - r) / r) * t))))
y = (((R - r) * sin(t)) - (d * sin((((R - r) / r) * t))))
z = (3 * sin(t))
return (x, y, z)
|
Coordinates of a hypotrochoid for parameters t, R, r and d
|
mana_item/mana_item.py
|
param_curve
|
nicoguaro/3D_models
| 2
|
python
|
def param_curve(t, R, r, d):
x = (((R - r) * cos(t)) + (d * cos((((R - r) / r) * t))))
y = (((R - r) * sin(t)) - (d * sin((((R - r) / r) * t))))
z = (3 * sin(t))
return (x, y, z)
|
def param_curve(t, R, r, d):
x = (((R - r) * cos(t)) + (d * cos((((R - r) / r) * t))))
y = (((R - r) * sin(t)) - (d * sin((((R - r) / r) * t))))
z = (3 * sin(t))
return (x, y, z)<|docstring|>Coordinates of a hypotrochoid for parameters t, R, r and d<|endoftext|>
|
a4cf45985fbd907f6c8f6c43e4aaee15742d8e69459d8e487175017b1cbf0614
|
def test_get_uri(self):
'\n Test on getting a pinot connection uri\n '
db_hook = self.db_hook()
assert (db_hook.get_uri() == 'http://host:1000/query/sql')
|
Test on getting a pinot connection uri
|
tests/providers/apache/pinot/hooks/test_pinot.py
|
test_get_uri
|
jiantao01/airflow
| 15,947
|
python
|
def test_get_uri(self):
'\n \n '
db_hook = self.db_hook()
assert (db_hook.get_uri() == 'http://host:1000/query/sql')
|
def test_get_uri(self):
'\n \n '
db_hook = self.db_hook()
assert (db_hook.get_uri() == 'http://host:1000/query/sql')<|docstring|>Test on getting a pinot connection uri<|endoftext|>
|
8ee54ba8a56b6a34774656afc5eff48e62dc6d19c7e01d7a5328ed9032ec2a62
|
def test_get_conn(self):
'\n Test on getting a pinot connection\n '
conn = self.db_hook().get_conn()
assert (conn.host == 'host')
assert (conn.port == '1000')
assert (conn.conn_type == 'http')
assert (conn.extra_dejson.get('endpoint') == 'query/sql')
|
Test on getting a pinot connection
|
tests/providers/apache/pinot/hooks/test_pinot.py
|
test_get_conn
|
jiantao01/airflow
| 15,947
|
python
|
def test_get_conn(self):
'\n \n '
conn = self.db_hook().get_conn()
assert (conn.host == 'host')
assert (conn.port == '1000')
assert (conn.conn_type == 'http')
assert (conn.extra_dejson.get('endpoint') == 'query/sql')
|
def test_get_conn(self):
'\n \n '
conn = self.db_hook().get_conn()
assert (conn.host == 'host')
assert (conn.port == '1000')
assert (conn.conn_type == 'http')
assert (conn.extra_dejson.get('endpoint') == 'query/sql')<|docstring|>Test on getting a pinot connection<|endoftext|>
|
bcee2957bc1d713da28a47fc1ec5c9392ec991cced07137f78d7a7035cbc3f4d
|
def __stretch__(p, s1, f1):
' If a point has coordinate p when the steep/flat points are at s0/f0,\n this returns its coordinates when the steep/flat points are at s1/f1.\n This is necessary to preserve the colourmap features.\n '
s0 = 0.3125
f0 = 0.75
dsf = (f0 - s0)
if (p <= s0):
return ((p * s1) / s0)
elif (p <= f0):
return ((((p - s0) * f1) + ((f0 - p) * s1)) / dsf)
else:
return (((p - f0) + ((1.0 - p) * f1)) / (1 - f0))
|
If a point has coordinate p when the steep/flat points are at s0/f0,
this returns its coordinates when the steep/flat points are at s1/f1.
This is necessary to preserve the colourmap features.
|
specindex.py
|
__stretch__
|
jayannee/CosmosCanvas
| 0
|
python
|
def __stretch__(p, s1, f1):
' If a point has coordinate p when the steep/flat points are at s0/f0,\n this returns its coordinates when the steep/flat points are at s1/f1.\n This is necessary to preserve the colourmap features.\n '
s0 = 0.3125
f0 = 0.75
dsf = (f0 - s0)
if (p <= s0):
return ((p * s1) / s0)
elif (p <= f0):
return ((((p - s0) * f1) + ((f0 - p) * s1)) / dsf)
else:
return (((p - f0) + ((1.0 - p) * f1)) / (1 - f0))
|
def __stretch__(p, s1, f1):
' If a point has coordinate p when the steep/flat points are at s0/f0,\n this returns its coordinates when the steep/flat points are at s1/f1.\n This is necessary to preserve the colourmap features.\n '
s0 = 0.3125
f0 = 0.75
dsf = (f0 - s0)
if (p <= s0):
return ((p * s1) / s0)
elif (p <= f0):
return ((((p - s0) * f1) + ((f0 - p) * s1)) / dsf)
else:
return (((p - f0) + ((1.0 - p) * f1)) / (1 - f0))<|docstring|>If a point has coordinate p when the steep/flat points are at s0/f0,
this returns its coordinates when the steep/flat points are at s1/f1.
This is necessary to preserve the colourmap features.<|endoftext|>
|
34a548ebe24f9adf632274af4c8af44751c41a092e32b6ec5e806007e7401cd9
|
def create_cmap_specindex(min_p, max_p, steep_p=(- 0.8), flat_p=(- 0.1), name='CC-specindex-default', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a new colour map based on Jayanne English's colourmap\n of yellow - plum, where the orange and dark cyan points\n are fixed to the steep and flat components, while the outer\n regions extend to the min and max values provided.\n "
color_width = (max_p - min_p)
if ((steep_p < min_p) or (flat_p < min_p) or (steep_p > max_p) or (flat_p > max_p)):
print('Error: Currently must have min_p < steep_p < flat_p < max_p')
(print(' min_p = '), min_p)
(print(' steep_p = '), steep_p)
(print(' flat_p = '), flat_p)
(print(' max_p = '), max_p)
return None
s1 = ((steep_p - min_p) / color_width)
f1 = ((flat_p - min_p) / color_width)
m1 = (0.5 * (s1 + f1))
LCH_x_vals = [0, s1, m1, __stretch__(0.6, s1, f1), f1, __stretch__(0.9, s1, f1), 1]
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.copy(LCH_x_vals)
LCH_y['L'] = [85, 54, 39, 34.3, 24, 15.5, 15]
LCH_y['C'] = [60.0, 74.4, 0, 7.9, 25.1, 46.1, 54.4]
LCH_y['H'] = [86, 51.7, 72, 200, 276.2, 302.5, 320]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB
|
Makes a new colour map based on Jayanne English's colourmap
of yellow - plum, where the orange and dark cyan points
are fixed to the steep and flat components, while the outer
regions extend to the min and max values provided.
|
specindex.py
|
create_cmap_specindex
|
jayannee/CosmosCanvas
| 0
|
python
|
def create_cmap_specindex(min_p, max_p, steep_p=(- 0.8), flat_p=(- 0.1), name='CC-specindex-default', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a new colour map based on Jayanne English's colourmap\n of yellow - plum, where the orange and dark cyan points\n are fixed to the steep and flat components, while the outer\n regions extend to the min and max values provided.\n "
color_width = (max_p - min_p)
if ((steep_p < min_p) or (flat_p < min_p) or (steep_p > max_p) or (flat_p > max_p)):
print('Error: Currently must have min_p < steep_p < flat_p < max_p')
(print(' min_p = '), min_p)
(print(' steep_p = '), steep_p)
(print(' flat_p = '), flat_p)
(print(' max_p = '), max_p)
return None
s1 = ((steep_p - min_p) / color_width)
f1 = ((flat_p - min_p) / color_width)
m1 = (0.5 * (s1 + f1))
LCH_x_vals = [0, s1, m1, __stretch__(0.6, s1, f1), f1, __stretch__(0.9, s1, f1), 1]
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.copy(LCH_x_vals)
LCH_y['L'] = [85, 54, 39, 34.3, 24, 15.5, 15]
LCH_y['C'] = [60.0, 74.4, 0, 7.9, 25.1, 46.1, 54.4]
LCH_y['H'] = [86, 51.7, 72, 200, 276.2, 302.5, 320]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB
|
def create_cmap_specindex(min_p, max_p, steep_p=(- 0.8), flat_p=(- 0.1), name='CC-specindex-default', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a new colour map based on Jayanne English's colourmap\n of yellow - plum, where the orange and dark cyan points\n are fixed to the steep and flat components, while the outer\n regions extend to the min and max values provided.\n "
color_width = (max_p - min_p)
if ((steep_p < min_p) or (flat_p < min_p) or (steep_p > max_p) or (flat_p > max_p)):
print('Error: Currently must have min_p < steep_p < flat_p < max_p')
(print(' min_p = '), min_p)
(print(' steep_p = '), steep_p)
(print(' flat_p = '), flat_p)
(print(' max_p = '), max_p)
return None
s1 = ((steep_p - min_p) / color_width)
f1 = ((flat_p - min_p) / color_width)
m1 = (0.5 * (s1 + f1))
LCH_x_vals = [0, s1, m1, __stretch__(0.6, s1, f1), f1, __stretch__(0.9, s1, f1), 1]
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.copy(LCH_x_vals)
LCH_y['L'] = [85, 54, 39, 34.3, 24, 15.5, 15]
LCH_y['C'] = [60.0, 74.4, 0, 7.9, 25.1, 46.1, 54.4]
LCH_y['H'] = [86, 51.7, 72, 200, 276.2, 302.5, 320]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB<|docstring|>Makes a new colour map based on Jayanne English's colourmap
of yellow - plum, where the orange and dark cyan points
are fixed to the steep and flat components, while the outer
regions extend to the min and max values provided.<|endoftext|>
|
438e9f97af353219f15e85ac339ea506e518ee1c65f154186b6411f1a99acf37
|
def create_cmap_specindex_constantL(L_0=75, C_0=35, H_start=70.0, H_dir='left', name='CC-specindex-constL', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a new colour map based on Jayanne English's constant Luminosity/chroma colourmap\n of orange - blue.\n "
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.arange(0, 1.05, 0.05)
LCH_y['L'] = ([L_0] * len(LCH_x['L']))
LCH_y['C'] = ([C_0] * len(LCH_x['C']))
if (H_dir == 'left'):
H_end = (H_start - 180.0)
elif (H_dir == 'right'):
H_end = (H_start + 180.0)
else:
print("Error: H_dir must be 'left' or 'right'")
return (- 1)
LCH_y['H'] = [((H_start * (1 - i)) + (H_end * i)) for i in LCH_x['H']]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB
|
Makes a new colour map based on Jayanne English's constant Luminosity/chroma colourmap
of orange - blue.
|
specindex.py
|
create_cmap_specindex_constantL
|
jayannee/CosmosCanvas
| 0
|
python
|
def create_cmap_specindex_constantL(L_0=75, C_0=35, H_start=70.0, H_dir='left', name='CC-specindex-constL', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a new colour map based on Jayanne English's constant Luminosity/chroma colourmap\n of orange - blue.\n "
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.arange(0, 1.05, 0.05)
LCH_y['L'] = ([L_0] * len(LCH_x['L']))
LCH_y['C'] = ([C_0] * len(LCH_x['C']))
if (H_dir == 'left'):
H_end = (H_start - 180.0)
elif (H_dir == 'right'):
H_end = (H_start + 180.0)
else:
print("Error: H_dir must be 'left' or 'right'")
return (- 1)
LCH_y['H'] = [((H_start * (1 - i)) + (H_end * i)) for i in LCH_x['H']]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB
|
def create_cmap_specindex_constantL(L_0=75, C_0=35, H_start=70.0, H_dir='left', name='CC-specindex-constL', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a new colour map based on Jayanne English's constant Luminosity/chroma colourmap\n of orange - blue.\n "
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.arange(0, 1.05, 0.05)
LCH_y['L'] = ([L_0] * len(LCH_x['L']))
LCH_y['C'] = ([C_0] * len(LCH_x['C']))
if (H_dir == 'left'):
H_end = (H_start - 180.0)
elif (H_dir == 'right'):
H_end = (H_start + 180.0)
else:
print("Error: H_dir must be 'left' or 'right'")
return (- 1)
LCH_y['H'] = [((H_start * (1 - i)) + (H_end * i)) for i in LCH_x['H']]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB<|docstring|>Makes a new colour map based on Jayanne English's constant Luminosity/chroma colourmap
of orange - blue.<|endoftext|>
|
20fbf8aa8da3e1a6e9624793981381dffc3d03651c47bda03f4b4a8110817d70
|
def create_cmap_specindex_error(c_mid=0.5, L_ends=72, L_mid=50.0, L_min=None, L_max=None, C_max=85.0, H_0=70.0, H_min=None, H_mid=None, H_max=None, name='CC-specindex-error', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a colour map for uncertainties in spectral index. This is based on Jayanne English's\n error colourmap of light orange and grey, where the pure orange hue indicates the most uncertainty.\n\n We have added more flexibility for the user, but the default values are setup to produce the desired effect.\n "
if ((c_mid < 0.0) or (1.0 < c_mid)):
print('Error: Currently must have c_mid outside of [0:1]')
(print(' midp = '), c_mid)
return None
if ((L_min == None) and (L_max == None)):
L_min = L_ends
L_max = L_ends
elif ((L_min == None) or (L_max == None)):
print('Error: Currently must set both L_min and L_max, or neither and just set L_ends')
return None
if ((H_min == None) and (H_max == None)):
H_min = H_0
H_max = H_0
elif (((H_min == None) and (H_mid == None)) or ((H_mid == None) and (H_max == None))):
print('Error: Currently must set either both of H_min and H_max, or H_mid and one of H_mid and H_max, or none of them and just set H_0')
return None
C_mid = (C_max / 2.0)
if (H_mid == None):
H_mid = (0.5 * (H_min + H_max))
elif (H_min == None):
H_min = H_mid
elif (H_max == None):
H_max = H_mid
LCH_x_vals = [0, c_mid, 1]
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.copy(LCH_x_vals)
LCH_y['L'] = [L_min, L_mid, L_max]
LCH_y['C'] = [0.0, C_mid, C_max]
LCH_y['H'] = [H_min, H_mid, H_max]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB
|
Makes a colour map for uncertainties in spectral index. This is based on Jayanne English's
error colourmap of light orange and grey, where the pure orange hue indicates the most uncertainty.
We have added more flexibility for the user, but the default values are setup to produce the desired effect.
|
specindex.py
|
create_cmap_specindex_error
|
jayannee/CosmosCanvas
| 0
|
python
|
def create_cmap_specindex_error(c_mid=0.5, L_ends=72, L_mid=50.0, L_min=None, L_max=None, C_max=85.0, H_0=70.0, H_min=None, H_mid=None, H_max=None, name='CC-specindex-error', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a colour map for uncertainties in spectral index. This is based on Jayanne English's\n error colourmap of light orange and grey, where the pure orange hue indicates the most uncertainty.\n\n We have added more flexibility for the user, but the default values are setup to produce the desired effect.\n "
if ((c_mid < 0.0) or (1.0 < c_mid)):
print('Error: Currently must have c_mid outside of [0:1]')
(print(' midp = '), c_mid)
return None
if ((L_min == None) and (L_max == None)):
L_min = L_ends
L_max = L_ends
elif ((L_min == None) or (L_max == None)):
print('Error: Currently must set both L_min and L_max, or neither and just set L_ends')
return None
if ((H_min == None) and (H_max == None)):
H_min = H_0
H_max = H_0
elif (((H_min == None) and (H_mid == None)) or ((H_mid == None) and (H_max == None))):
print('Error: Currently must set either both of H_min and H_max, or H_mid and one of H_mid and H_max, or none of them and just set H_0')
return None
C_mid = (C_max / 2.0)
if (H_mid == None):
H_mid = (0.5 * (H_min + H_max))
elif (H_min == None):
H_min = H_mid
elif (H_max == None):
H_max = H_mid
LCH_x_vals = [0, c_mid, 1]
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.copy(LCH_x_vals)
LCH_y['L'] = [L_min, L_mid, L_max]
LCH_y['C'] = [0.0, C_mid, C_max]
LCH_y['H'] = [H_min, H_mid, H_max]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB
|
def create_cmap_specindex_error(c_mid=0.5, L_ends=72, L_mid=50.0, L_min=None, L_max=None, C_max=85.0, H_0=70.0, H_min=None, H_mid=None, H_max=None, name='CC-specindex-error', mode='clip', targets=['mpl', 'png'], mpl_reg=True, png_dir='./cmaps', out=False):
" Makes a colour map for uncertainties in spectral index. This is based on Jayanne English's\n error colourmap of light orange and grey, where the pure orange hue indicates the most uncertainty.\n\n We have added more flexibility for the user, but the default values are setup to produce the desired effect.\n "
if ((c_mid < 0.0) or (1.0 < c_mid)):
print('Error: Currently must have c_mid outside of [0:1]')
(print(' midp = '), c_mid)
return None
if ((L_min == None) and (L_max == None)):
L_min = L_ends
L_max = L_ends
elif ((L_min == None) or (L_max == None)):
print('Error: Currently must set both L_min and L_max, or neither and just set L_ends')
return None
if ((H_min == None) and (H_max == None)):
H_min = H_0
H_max = H_0
elif (((H_min == None) and (H_mid == None)) or ((H_mid == None) and (H_max == None))):
print('Error: Currently must set either both of H_min and H_max, or H_mid and one of H_mid and H_max, or none of them and just set H_0')
return None
C_mid = (C_max / 2.0)
if (H_mid == None):
H_mid = (0.5 * (H_min + H_max))
elif (H_min == None):
H_min = H_mid
elif (H_max == None):
H_max = H_mid
LCH_x_vals = [0, c_mid, 1]
LCH_x = {}
LCH_y = {}
for coord in ['L', 'C', 'H']:
LCH_x[coord] = np.copy(LCH_x_vals)
LCH_y['L'] = [L_min, L_mid, L_max]
LCH_y['C'] = [0.0, C_mid, C_max]
LCH_y['H'] = [H_min, H_mid, H_max]
if isinstance(mode, str):
modes = [mode]
elif isinstance(mode, list):
modes = mode
if (len(mode) > 1):
print("Warning: ColourConvas tutorials only address a single mode of colourmap from colourspace (either 'clip' or 'crop').")
print("Warning: By providing both, the colour map names will match the 'name' argument with suffix '_clip' and '_crop'.")
print("Warning: Please ensure that you wish to use colourspace and CosmosCanvas in this way. Expected 'mode' is a string.")
else:
print("Error. Expected 'mode' to be a string. 'mode' can also be a list. 'mode' has value and type:", mode, type(mode))
exit((- 1))
try:
path = Path(png_dir)
path.mkdir(parents=True, exist_ok=True)
except:
pass
RGB = maps.make_cmap_segmented(LCH_x, LCH_y, name=name, modes=modes, targets=targets, mpl_reg=mpl_reg, png_dir=png_dir, out=out)
if out:
return RGB<|docstring|>Makes a colour map for uncertainties in spectral index. This is based on Jayanne English's
error colourmap of light orange and grey, where the pure orange hue indicates the most uncertainty.
We have added more flexibility for the user, but the default values are setup to produce the desired effect.<|endoftext|>
|
de3be67ae9185a7e5394e208caa6aaf7cd91d1aeaa630e501dd6533ae4a28486
|
def create_cmap_velocity(min_p, max_p, div=0.0, width=0.0):
" Makes a color map based on Jayanne English's velocity colourmap\n of yellow - plum, where the orange and dark cyan points\n are fixed to the steep and flat points, while the outer\n regions extend to the min and max values provided.\n "
color_width = (max_p - min_p)
d0 = (float((div - min_p)) / float(color_width))
points = {}
values = {}
points['L'] = [0, 1]
values['L'] = [90, 10]
points['C'] = [0, d0, 1]
values['C'] = [50, 0, 50]
points['H'] = [0, (d0 - (width / 2.0)), (d0 + (width / 2.0)), 1]
values['H'] = [(30 + 180), (30 + 179), 31, 30]
(name_cmap, L, C, H) = maps.make_cmap_segmented(points, values, name='blue-red')
return (name_cmap, L, C, H)
|
Makes a color map based on Jayanne English's velocity colourmap
of yellow - plum, where the orange and dark cyan points
are fixed to the steep and flat points, while the outer
regions extend to the min and max values provided.
|
specindex.py
|
create_cmap_velocity
|
jayannee/CosmosCanvas
| 0
|
python
|
def create_cmap_velocity(min_p, max_p, div=0.0, width=0.0):
" Makes a color map based on Jayanne English's velocity colourmap\n of yellow - plum, where the orange and dark cyan points\n are fixed to the steep and flat points, while the outer\n regions extend to the min and max values provided.\n "
color_width = (max_p - min_p)
d0 = (float((div - min_p)) / float(color_width))
points = {}
values = {}
points['L'] = [0, 1]
values['L'] = [90, 10]
points['C'] = [0, d0, 1]
values['C'] = [50, 0, 50]
points['H'] = [0, (d0 - (width / 2.0)), (d0 + (width / 2.0)), 1]
values['H'] = [(30 + 180), (30 + 179), 31, 30]
(name_cmap, L, C, H) = maps.make_cmap_segmented(points, values, name='blue-red')
return (name_cmap, L, C, H)
|
def create_cmap_velocity(min_p, max_p, div=0.0, width=0.0):
" Makes a color map based on Jayanne English's velocity colourmap\n of yellow - plum, where the orange and dark cyan points\n are fixed to the steep and flat points, while the outer\n regions extend to the min and max values provided.\n "
color_width = (max_p - min_p)
d0 = (float((div - min_p)) / float(color_width))
points = {}
values = {}
points['L'] = [0, 1]
values['L'] = [90, 10]
points['C'] = [0, d0, 1]
values['C'] = [50, 0, 50]
points['H'] = [0, (d0 - (width / 2.0)), (d0 + (width / 2.0)), 1]
values['H'] = [(30 + 180), (30 + 179), 31, 30]
(name_cmap, L, C, H) = maps.make_cmap_segmented(points, values, name='blue-red')
return (name_cmap, L, C, H)<|docstring|>Makes a color map based on Jayanne English's velocity colourmap
of yellow - plum, where the orange and dark cyan points
are fixed to the steep and flat points, while the outer
regions extend to the min and max values provided.<|endoftext|>
|
7299aeba341421054a564fae11491607b2771e6033665e8302b5c66df90ad795
|
def __init__(self, sim_params):
'\n Constructor function initilizing class variables using sim_params\n\n Parameters\n ----------\n sim_params : DICTIONARY\n Dictionary containing steering law parameters.\n\n Returns\n -------\n None.\n\n '
self.nmpc_params = NMPCParams(sim_params)
self.x = sim_params['x']
self.y = sim_params['y']
self.yaw = sim_params['yaw']
self.v = sim_params['v']
self.ox = sim_params['obstacle'][0]
self.oy = sim_params['obstacle'][1]
self.L = sim_params['L']
self.a_max = self.nmpc_params.a_max
self.a_min = self.nmpc_params.a_min
setup_params = {}
setup_params['N'] = self.nmpc_params.len_horizon
setup_params['T'] = self.nmpc_params.T
setup_params['L'] = self.nmpc_params.L
setup_params['Q'] = self.nmpc_params.Q
setup_params['R'] = self.nmpc_params.R
setup_params['mu_w'] = self.nmpc_params.mu_w
setup_params['mu_v'] = self.nmpc_params.mu_v
setup_params['SigmaW'] = self.nmpc_params.SigmaW
setup_params['SigmaV'] = self.nmpc_params.SigmaV
setup_params['SigmaE'] = self.nmpc_params.SigmaE
setup_params['CrossCor'] = self.nmpc_params.CrossCorel
setup_params['joint_mu'] = self.nmpc_params.joint_mu
setup_params['WV_Noise'] = self.nmpc_params.WV_Noise
setup_params['joint_cov'] = self.nmpc_params.joint_cov
setup_params['min_vel'] = self.nmpc_params.v_min
setup_params['max_vel'] = self.nmpc_params.v_max
setup_params['min_accel'] = self.nmpc_params.a_min
setup_params['max_accel'] = self.nmpc_params.a_max
setup_params['min_steer'] = self.nmpc_params.min_steer
setup_params['max_steer'] = self.nmpc_params.max_steer
setup_params['min_x_pos'] = self.nmpc_params.x_min
setup_params['min_y_pos'] = self.nmpc_params.y_min
setup_params['max_x_pos'] = self.nmpc_params.x_max
setup_params['max_y_pos'] = self.nmpc_params.y_max
setup_params['obs_x_min'] = self.nmpc_params.obs_x_min
setup_params['obs_y_min'] = self.nmpc_params.obs_y_min
setup_params['obs_x_max'] = self.nmpc_params.obs_x_max
setup_params['obs_y_max'] = self.nmpc_params.obs_y_max
setup_params['goal_x'] = sim_params['goal_x']
setup_params['goal_y'] = sim_params['goal_y']
setup_params['sim_time'] = self.nmpc_params.sim_time
setup_params['num_ctrls'] = self.nmpc_params.num_ctrls
setup_params['num_states'] = self.nmpc_params.num_states
setup_params['num_outputs'] = self.nmpc_params.num_outputs
self.tracking_controller = Tracking_Controller.NMPC_Steering(setup_params)
|
Constructor function initilizing class variables using sim_params
Parameters
----------
sim_params : DICTIONARY
Dictionary containing steering law parameters.
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
__init__
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def __init__(self, sim_params):
'\n Constructor function initilizing class variables using sim_params\n\n Parameters\n ----------\n sim_params : DICTIONARY\n Dictionary containing steering law parameters.\n\n Returns\n -------\n None.\n\n '
self.nmpc_params = NMPCParams(sim_params)
self.x = sim_params['x']
self.y = sim_params['y']
self.yaw = sim_params['yaw']
self.v = sim_params['v']
self.ox = sim_params['obstacle'][0]
self.oy = sim_params['obstacle'][1]
self.L = sim_params['L']
self.a_max = self.nmpc_params.a_max
self.a_min = self.nmpc_params.a_min
setup_params = {}
setup_params['N'] = self.nmpc_params.len_horizon
setup_params['T'] = self.nmpc_params.T
setup_params['L'] = self.nmpc_params.L
setup_params['Q'] = self.nmpc_params.Q
setup_params['R'] = self.nmpc_params.R
setup_params['mu_w'] = self.nmpc_params.mu_w
setup_params['mu_v'] = self.nmpc_params.mu_v
setup_params['SigmaW'] = self.nmpc_params.SigmaW
setup_params['SigmaV'] = self.nmpc_params.SigmaV
setup_params['SigmaE'] = self.nmpc_params.SigmaE
setup_params['CrossCor'] = self.nmpc_params.CrossCorel
setup_params['joint_mu'] = self.nmpc_params.joint_mu
setup_params['WV_Noise'] = self.nmpc_params.WV_Noise
setup_params['joint_cov'] = self.nmpc_params.joint_cov
setup_params['min_vel'] = self.nmpc_params.v_min
setup_params['max_vel'] = self.nmpc_params.v_max
setup_params['min_accel'] = self.nmpc_params.a_min
setup_params['max_accel'] = self.nmpc_params.a_max
setup_params['min_steer'] = self.nmpc_params.min_steer
setup_params['max_steer'] = self.nmpc_params.max_steer
setup_params['min_x_pos'] = self.nmpc_params.x_min
setup_params['min_y_pos'] = self.nmpc_params.y_min
setup_params['max_x_pos'] = self.nmpc_params.x_max
setup_params['max_y_pos'] = self.nmpc_params.y_max
setup_params['obs_x_min'] = self.nmpc_params.obs_x_min
setup_params['obs_y_min'] = self.nmpc_params.obs_y_min
setup_params['obs_x_max'] = self.nmpc_params.obs_x_max
setup_params['obs_y_max'] = self.nmpc_params.obs_y_max
setup_params['goal_x'] = sim_params['goal_x']
setup_params['goal_y'] = sim_params['goal_y']
setup_params['sim_time'] = self.nmpc_params.sim_time
setup_params['num_ctrls'] = self.nmpc_params.num_ctrls
setup_params['num_states'] = self.nmpc_params.num_states
setup_params['num_outputs'] = self.nmpc_params.num_outputs
self.tracking_controller = Tracking_Controller.NMPC_Steering(setup_params)
|
def __init__(self, sim_params):
'\n Constructor function initilizing class variables using sim_params\n\n Parameters\n ----------\n sim_params : DICTIONARY\n Dictionary containing steering law parameters.\n\n Returns\n -------\n None.\n\n '
self.nmpc_params = NMPCParams(sim_params)
self.x = sim_params['x']
self.y = sim_params['y']
self.yaw = sim_params['yaw']
self.v = sim_params['v']
self.ox = sim_params['obstacle'][0]
self.oy = sim_params['obstacle'][1]
self.L = sim_params['L']
self.a_max = self.nmpc_params.a_max
self.a_min = self.nmpc_params.a_min
setup_params = {}
setup_params['N'] = self.nmpc_params.len_horizon
setup_params['T'] = self.nmpc_params.T
setup_params['L'] = self.nmpc_params.L
setup_params['Q'] = self.nmpc_params.Q
setup_params['R'] = self.nmpc_params.R
setup_params['mu_w'] = self.nmpc_params.mu_w
setup_params['mu_v'] = self.nmpc_params.mu_v
setup_params['SigmaW'] = self.nmpc_params.SigmaW
setup_params['SigmaV'] = self.nmpc_params.SigmaV
setup_params['SigmaE'] = self.nmpc_params.SigmaE
setup_params['CrossCor'] = self.nmpc_params.CrossCorel
setup_params['joint_mu'] = self.nmpc_params.joint_mu
setup_params['WV_Noise'] = self.nmpc_params.WV_Noise
setup_params['joint_cov'] = self.nmpc_params.joint_cov
setup_params['min_vel'] = self.nmpc_params.v_min
setup_params['max_vel'] = self.nmpc_params.v_max
setup_params['min_accel'] = self.nmpc_params.a_min
setup_params['max_accel'] = self.nmpc_params.a_max
setup_params['min_steer'] = self.nmpc_params.min_steer
setup_params['max_steer'] = self.nmpc_params.max_steer
setup_params['min_x_pos'] = self.nmpc_params.x_min
setup_params['min_y_pos'] = self.nmpc_params.y_min
setup_params['max_x_pos'] = self.nmpc_params.x_max
setup_params['max_y_pos'] = self.nmpc_params.y_max
setup_params['obs_x_min'] = self.nmpc_params.obs_x_min
setup_params['obs_y_min'] = self.nmpc_params.obs_y_min
setup_params['obs_x_max'] = self.nmpc_params.obs_x_max
setup_params['obs_y_max'] = self.nmpc_params.obs_y_max
setup_params['goal_x'] = sim_params['goal_x']
setup_params['goal_y'] = sim_params['goal_y']
setup_params['sim_time'] = self.nmpc_params.sim_time
setup_params['num_ctrls'] = self.nmpc_params.num_ctrls
setup_params['num_states'] = self.nmpc_params.num_states
setup_params['num_outputs'] = self.nmpc_params.num_outputs
self.tracking_controller = Tracking_Controller.NMPC_Steering(setup_params)<|docstring|>Constructor function initilizing class variables using sim_params
Parameters
----------
sim_params : DICTIONARY
Dictionary containing steering law parameters.
Returns
-------
None.<|endoftext|>
|
a23c56547f90243ef4bbccee22b8bff07126d78b1970a66b3d9cd1c6e575233c
|
def Update_State(self, robot_state, ob_state):
'\n Updates the class variables using the robot_state and ob_state\n\n Parameters\n ----------\n robot_state : LIST OF FLOATS\n states of thr robot.\n ob_state : LIST OF FLOATS\n states of the obstacle.\n\n Returns\n -------\n None.\n\n '
self.x = robot_state[0]
self.y = robot_state[1]
self.yaw = self.Bound_Angles(robot_state[2])
self.v = robot_state[3]
self.ox = ob_state[0]
self.oy = ob_state[1]
|
Updates the class variables using the robot_state and ob_state
Parameters
----------
robot_state : LIST OF FLOATS
states of thr robot.
ob_state : LIST OF FLOATS
states of the obstacle.
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Update_State
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Update_State(self, robot_state, ob_state):
'\n Updates the class variables using the robot_state and ob_state\n\n Parameters\n ----------\n robot_state : LIST OF FLOATS\n states of thr robot.\n ob_state : LIST OF FLOATS\n states of the obstacle.\n\n Returns\n -------\n None.\n\n '
self.x = robot_state[0]
self.y = robot_state[1]
self.yaw = self.Bound_Angles(robot_state[2])
self.v = robot_state[3]
self.ox = ob_state[0]
self.oy = ob_state[1]
|
def Update_State(self, robot_state, ob_state):
'\n Updates the class variables using the robot_state and ob_state\n\n Parameters\n ----------\n robot_state : LIST OF FLOATS\n states of thr robot.\n ob_state : LIST OF FLOATS\n states of the obstacle.\n\n Returns\n -------\n None.\n\n '
self.x = robot_state[0]
self.y = robot_state[1]
self.yaw = self.Bound_Angles(robot_state[2])
self.v = robot_state[3]
self.ox = ob_state[0]
self.oy = ob_state[1]<|docstring|>Updates the class variables using the robot_state and ob_state
Parameters
----------
robot_state : LIST OF FLOATS
states of thr robot.
ob_state : LIST OF FLOATS
states of the obstacle.
Returns
-------
None.<|endoftext|>
|
49ca3565aa22551c04b02b81e129e55332f0b4d92b1d5d24efe61326ff1495a2
|
def Update_Waypt(self, waypt):
'\n Updates the waypoint information\n\n Parameters\n ----------\n waypt : CARLA Transform \n Waypoint description.\n\n Returns\n -------\n None.\n\n '
self.waypt_x = waypt[0]
self.waypt_y = waypt[1]
self.waypt_yaw = self.Bound_Angles(waypt[2])
self.waypt_v = 0
|
Updates the waypoint information
Parameters
----------
waypt : CARLA Transform
Waypoint description.
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Update_Waypt
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Update_Waypt(self, waypt):
'\n Updates the waypoint information\n\n Parameters\n ----------\n waypt : CARLA Transform \n Waypoint description.\n\n Returns\n -------\n None.\n\n '
self.waypt_x = waypt[0]
self.waypt_y = waypt[1]
self.waypt_yaw = self.Bound_Angles(waypt[2])
self.waypt_v = 0
|
def Update_Waypt(self, waypt):
'\n Updates the waypoint information\n\n Parameters\n ----------\n waypt : CARLA Transform \n Waypoint description.\n\n Returns\n -------\n None.\n\n '
self.waypt_x = waypt[0]
self.waypt_y = waypt[1]
self.waypt_yaw = self.Bound_Angles(waypt[2])
self.waypt_v = 0<|docstring|>Updates the waypoint information
Parameters
----------
waypt : CARLA Transform
Waypoint description.
Returns
-------
None.<|endoftext|>
|
d2d1b338dc52369cfdcff851b4ea40c2bd9c6645b0e82ab41a5fed75660acc41
|
@staticmethod
def Bound_Angles(theta):
'\n Converts angle from degrees to radians\n\n Parameters\n ----------\n theta : FLOAT\n Angle in degrees.\n\n Returns\n -------\n theta : FLOAT\n Angle in radians.\n\n '
if (theta < 0):
theta = (theta + 360)
theta = ((theta * np.pi) / 180)
return theta
|
Converts angle from degrees to radians
Parameters
----------
theta : FLOAT
Angle in degrees.
Returns
-------
theta : FLOAT
Angle in radians.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Bound_Angles
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
@staticmethod
def Bound_Angles(theta):
'\n Converts angle from degrees to radians\n\n Parameters\n ----------\n theta : FLOAT\n Angle in degrees.\n\n Returns\n -------\n theta : FLOAT\n Angle in radians.\n\n '
if (theta < 0):
theta = (theta + 360)
theta = ((theta * np.pi) / 180)
return theta
|
@staticmethod
def Bound_Angles(theta):
'\n Converts angle from degrees to radians\n\n Parameters\n ----------\n theta : FLOAT\n Angle in degrees.\n\n Returns\n -------\n theta : FLOAT\n Angle in radians.\n\n '
if (theta < 0):
theta = (theta + 360)
theta = ((theta * np.pi) / 180)
return theta<|docstring|>Converts angle from degrees to radians
Parameters
----------
theta : FLOAT
Angle in degrees.
Returns
-------
theta : FLOAT
Angle in radians.<|endoftext|>
|
11031395b2ce5d6ec5f7e77f9d09deccc5e4a7ff92cef21b7e26fb0f5cf9133b
|
def Get_Control_Inputs(self, ego_player, static_player, ref_iterator, x, y, yaw, v, ox, oy, waypts):
'\n Given a car player, obstacle & set of states, function Get_Control_Inputs\n applies the computed NMPC control inputs to steer the car player from \n the current state to the commanded waypoint. \n\n Parameters\n ----------\n ego_player : Carla Car Vehicle Object\n object representing the ego car in the CARLA environment.\n static_player : Carla Car Vehicle Object\n object representing the static obstacle car in the CARLA environment.\n x : FLOAT\n ego car x position.\n y : FLOAT\n ego car y position.\n yaw : FLOAT\n ego car yaw orientation.\n v : FLOAT\n ego car velocity.\n ox : FLOAT\n obstacle x position.\n oy : FLOAT\n obstacle y position.\n waypts : CARLA TRANSFORM OBJECTS\n contains the list of waypoints information.\n\n Returns\n -------\n None.\n\n '
self.Update_State([x, y, yaw, v], [ox, oy])
waypt = waypts[(:, (- 1))]
self.Update_Waypt(waypt)
start_w = [self.x, self.y, self.yaw, self.v, self.ox, self.oy]
next_w = [self.waypt_x, self.waypt_y, self.waypt_yaw, self.waypt_v, self.ox, self.oy]
self.tracking_controller.NMPC_Track_Waypoint(ego_player, static_player, ref_iterator, start_w, next_w, waypts, self.nmpc_params.SigmaE)
|
Given a car player, obstacle & set of states, function Get_Control_Inputs
applies the computed NMPC control inputs to steer the car player from
the current state to the commanded waypoint.
Parameters
----------
ego_player : Carla Car Vehicle Object
object representing the ego car in the CARLA environment.
static_player : Carla Car Vehicle Object
object representing the static obstacle car in the CARLA environment.
x : FLOAT
ego car x position.
y : FLOAT
ego car y position.
yaw : FLOAT
ego car yaw orientation.
v : FLOAT
ego car velocity.
ox : FLOAT
obstacle x position.
oy : FLOAT
obstacle y position.
waypts : CARLA TRANSFORM OBJECTS
contains the list of waypoints information.
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Get_Control_Inputs
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Get_Control_Inputs(self, ego_player, static_player, ref_iterator, x, y, yaw, v, ox, oy, waypts):
'\n Given a car player, obstacle & set of states, function Get_Control_Inputs\n applies the computed NMPC control inputs to steer the car player from \n the current state to the commanded waypoint. \n\n Parameters\n ----------\n ego_player : Carla Car Vehicle Object\n object representing the ego car in the CARLA environment.\n static_player : Carla Car Vehicle Object\n object representing the static obstacle car in the CARLA environment.\n x : FLOAT\n ego car x position.\n y : FLOAT\n ego car y position.\n yaw : FLOAT\n ego car yaw orientation.\n v : FLOAT\n ego car velocity.\n ox : FLOAT\n obstacle x position.\n oy : FLOAT\n obstacle y position.\n waypts : CARLA TRANSFORM OBJECTS\n contains the list of waypoints information.\n\n Returns\n -------\n None.\n\n '
self.Update_State([x, y, yaw, v], [ox, oy])
waypt = waypts[(:, (- 1))]
self.Update_Waypt(waypt)
start_w = [self.x, self.y, self.yaw, self.v, self.ox, self.oy]
next_w = [self.waypt_x, self.waypt_y, self.waypt_yaw, self.waypt_v, self.ox, self.oy]
self.tracking_controller.NMPC_Track_Waypoint(ego_player, static_player, ref_iterator, start_w, next_w, waypts, self.nmpc_params.SigmaE)
|
def Get_Control_Inputs(self, ego_player, static_player, ref_iterator, x, y, yaw, v, ox, oy, waypts):
'\n Given a car player, obstacle & set of states, function Get_Control_Inputs\n applies the computed NMPC control inputs to steer the car player from \n the current state to the commanded waypoint. \n\n Parameters\n ----------\n ego_player : Carla Car Vehicle Object\n object representing the ego car in the CARLA environment.\n static_player : Carla Car Vehicle Object\n object representing the static obstacle car in the CARLA environment.\n x : FLOAT\n ego car x position.\n y : FLOAT\n ego car y position.\n yaw : FLOAT\n ego car yaw orientation.\n v : FLOAT\n ego car velocity.\n ox : FLOAT\n obstacle x position.\n oy : FLOAT\n obstacle y position.\n waypts : CARLA TRANSFORM OBJECTS\n contains the list of waypoints information.\n\n Returns\n -------\n None.\n\n '
self.Update_State([x, y, yaw, v], [ox, oy])
waypt = waypts[(:, (- 1))]
self.Update_Waypt(waypt)
start_w = [self.x, self.y, self.yaw, self.v, self.ox, self.oy]
next_w = [self.waypt_x, self.waypt_y, self.waypt_yaw, self.waypt_v, self.ox, self.oy]
self.tracking_controller.NMPC_Track_Waypoint(ego_player, static_player, ref_iterator, start_w, next_w, waypts, self.nmpc_params.SigmaE)<|docstring|>Given a car player, obstacle & set of states, function Get_Control_Inputs
applies the computed NMPC control inputs to steer the car player from
the current state to the commanded waypoint.
Parameters
----------
ego_player : Carla Car Vehicle Object
object representing the ego car in the CARLA environment.
static_player : Carla Car Vehicle Object
object representing the static obstacle car in the CARLA environment.
x : FLOAT
ego car x position.
y : FLOAT
ego car y position.
yaw : FLOAT
ego car yaw orientation.
v : FLOAT
ego car velocity.
ox : FLOAT
obstacle x position.
oy : FLOAT
obstacle y position.
waypts : CARLA TRANSFORM OBJECTS
contains the list of waypoints information.
Returns
-------
None.<|endoftext|>
|
f7f586b14cc9833ea13cb52397378522111e5f833ec9ad8ef7983e2e0d3b3187
|
def __init__(self, controller_params):
'\n Constructor function initilizing class variables using controller_params\n\n Parameters\n ----------\n controller_params : DICTIONARY\n Dictionary containing steering law parameters..\n\n Returns\n -------\n None.\n\n '
self._current_x = 0
self._current_y = 0
self._current_yaw = 0
self._current_speed = 0
self._obstacle_x = 0
self._obstacle_y = 0
self._waypt_references = None
self._current_frame = 0
self._current_timestamp = 0
self._set_throttle = 0
self._set_brake = 0
self._set_steer = 0
self._conv_rad_to_steer = ((180.0 / 70.0) / np.pi)
sim_params = {}
sim_params['x'] = self._current_x
sim_params['y'] = self._current_y
sim_params['yaw'] = self._current_yaw
sim_params['v'] = self._current_speed
sim_params['obstacle'] = controller_params['obstacle']
sim_params['goal_x'] = controller_params['goal_x_pos']
sim_params['goal_y'] = controller_params['goal_y_pos']
sim_params['L'] = controller_params['wheelbase']
sim_params['boundary'] = controller_params['boundary']
self.controller = NMPC_Tracker(sim_params)
|
Constructor function initilizing class variables using controller_params
Parameters
----------
controller_params : DICTIONARY
Dictionary containing steering law parameters..
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
__init__
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def __init__(self, controller_params):
'\n Constructor function initilizing class variables using controller_params\n\n Parameters\n ----------\n controller_params : DICTIONARY\n Dictionary containing steering law parameters..\n\n Returns\n -------\n None.\n\n '
self._current_x = 0
self._current_y = 0
self._current_yaw = 0
self._current_speed = 0
self._obstacle_x = 0
self._obstacle_y = 0
self._waypt_references = None
self._current_frame = 0
self._current_timestamp = 0
self._set_throttle = 0
self._set_brake = 0
self._set_steer = 0
self._conv_rad_to_steer = ((180.0 / 70.0) / np.pi)
sim_params = {}
sim_params['x'] = self._current_x
sim_params['y'] = self._current_y
sim_params['yaw'] = self._current_yaw
sim_params['v'] = self._current_speed
sim_params['obstacle'] = controller_params['obstacle']
sim_params['goal_x'] = controller_params['goal_x_pos']
sim_params['goal_y'] = controller_params['goal_y_pos']
sim_params['L'] = controller_params['wheelbase']
sim_params['boundary'] = controller_params['boundary']
self.controller = NMPC_Tracker(sim_params)
|
def __init__(self, controller_params):
'\n Constructor function initilizing class variables using controller_params\n\n Parameters\n ----------\n controller_params : DICTIONARY\n Dictionary containing steering law parameters..\n\n Returns\n -------\n None.\n\n '
self._current_x = 0
self._current_y = 0
self._current_yaw = 0
self._current_speed = 0
self._obstacle_x = 0
self._obstacle_y = 0
self._waypt_references = None
self._current_frame = 0
self._current_timestamp = 0
self._set_throttle = 0
self._set_brake = 0
self._set_steer = 0
self._conv_rad_to_steer = ((180.0 / 70.0) / np.pi)
sim_params = {}
sim_params['x'] = self._current_x
sim_params['y'] = self._current_y
sim_params['yaw'] = self._current_yaw
sim_params['v'] = self._current_speed
sim_params['obstacle'] = controller_params['obstacle']
sim_params['goal_x'] = controller_params['goal_x_pos']
sim_params['goal_y'] = controller_params['goal_y_pos']
sim_params['L'] = controller_params['wheelbase']
sim_params['boundary'] = controller_params['boundary']
self.controller = NMPC_Tracker(sim_params)<|docstring|>Constructor function initilizing class variables using controller_params
Parameters
----------
controller_params : DICTIONARY
Dictionary containing steering law parameters..
Returns
-------
None.<|endoftext|>
|
f65653e4f53a649e38d39366894357c61165e49911f7d282a4c6a45d965f79ad
|
def Update_Waypoint(self, waypt):
'\n Update the states of robots & obstacles with timestampe and frame info\n\n Parameters\n ----------\n waypt : LIST OF FLOATS\n Reference states for N future time steps.\n\n Returns\n -------\n NONE\n\n '
self._waypt_references = waypt
|
Update the states of robots & obstacles with timestampe and frame info
Parameters
----------
waypt : LIST OF FLOATS
Reference states for N future time steps.
Returns
-------
NONE
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Update_Waypoint
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Update_Waypoint(self, waypt):
'\n Update the states of robots & obstacles with timestampe and frame info\n\n Parameters\n ----------\n waypt : LIST OF FLOATS\n Reference states for N future time steps.\n\n Returns\n -------\n NONE\n\n '
self._waypt_references = waypt
|
def Update_Waypoint(self, waypt):
'\n Update the states of robots & obstacles with timestampe and frame info\n\n Parameters\n ----------\n waypt : LIST OF FLOATS\n Reference states for N future time steps.\n\n Returns\n -------\n NONE\n\n '
self._waypt_references = waypt<|docstring|>Update the states of robots & obstacles with timestampe and frame info
Parameters
----------
waypt : LIST OF FLOATS
Reference states for N future time steps.
Returns
-------
NONE<|endoftext|>
|
b93747ea9bf7b815a1c4cb0536e7962877ee81250abe5f095940c7039b969f52
|
def Update_Information(self, robot_state, ob_state, timestamp, frame):
'\n Update the states of robots & obstacles with timestampe and frame info\n\n Parameters\n ----------\n robot_state : LIST OF FLOATS\n Robot states.\n ob_state : LIST OF FLOATS\n Obstacle states.\n timestamp : FLOAT\n time stamp information.\n frame : FLOAT\n frame value.\n\n Returns\n -------\n _start_control_loop BOOLEAN\n variable encoding the readiness for tracking.\n\n '
self._current_x = robot_state[0]
self._current_y = robot_state[1]
self._current_yaw = robot_state[2]
self._current_speed = robot_state[3]
self._obstacle_x = ob_state[0]
self._obstacle_y = ob_state[1]
self._current_timestamp = timestamp
self._current_frame = frame
self.controller.Update_State(robot_state, ob_state)
if self._current_frame:
return True
return False
|
Update the states of robots & obstacles with timestampe and frame info
Parameters
----------
robot_state : LIST OF FLOATS
Robot states.
ob_state : LIST OF FLOATS
Obstacle states.
timestamp : FLOAT
time stamp information.
frame : FLOAT
frame value.
Returns
-------
_start_control_loop BOOLEAN
variable encoding the readiness for tracking.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Update_Information
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Update_Information(self, robot_state, ob_state, timestamp, frame):
'\n Update the states of robots & obstacles with timestampe and frame info\n\n Parameters\n ----------\n robot_state : LIST OF FLOATS\n Robot states.\n ob_state : LIST OF FLOATS\n Obstacle states.\n timestamp : FLOAT\n time stamp information.\n frame : FLOAT\n frame value.\n\n Returns\n -------\n _start_control_loop BOOLEAN\n variable encoding the readiness for tracking.\n\n '
self._current_x = robot_state[0]
self._current_y = robot_state[1]
self._current_yaw = robot_state[2]
self._current_speed = robot_state[3]
self._obstacle_x = ob_state[0]
self._obstacle_y = ob_state[1]
self._current_timestamp = timestamp
self._current_frame = frame
self.controller.Update_State(robot_state, ob_state)
if self._current_frame:
return True
return False
|
def Update_Information(self, robot_state, ob_state, timestamp, frame):
'\n Update the states of robots & obstacles with timestampe and frame info\n\n Parameters\n ----------\n robot_state : LIST OF FLOATS\n Robot states.\n ob_state : LIST OF FLOATS\n Obstacle states.\n timestamp : FLOAT\n time stamp information.\n frame : FLOAT\n frame value.\n\n Returns\n -------\n _start_control_loop BOOLEAN\n variable encoding the readiness for tracking.\n\n '
self._current_x = robot_state[0]
self._current_y = robot_state[1]
self._current_yaw = robot_state[2]
self._current_speed = robot_state[3]
self._obstacle_x = ob_state[0]
self._obstacle_y = ob_state[1]
self._current_timestamp = timestamp
self._current_frame = frame
self.controller.Update_State(robot_state, ob_state)
if self._current_frame:
return True
return False<|docstring|>Update the states of robots & obstacles with timestampe and frame info
Parameters
----------
robot_state : LIST OF FLOATS
Robot states.
ob_state : LIST OF FLOATS
Obstacle states.
timestamp : FLOAT
time stamp information.
frame : FLOAT
frame value.
Returns
-------
_start_control_loop BOOLEAN
variable encoding the readiness for tracking.<|endoftext|>
|
5ccda450be48a2dae909ba172119acb745e92082040255704a8c8183d2d9ada5
|
def Set_Control_Commands(self, input_throttle, input_steer_in_rad, input_brake):
'\n Processes input commands to be within their respective ranges\n\n Parameters\n ----------\n input_throttle : FLOAT\n throlle value.\n input_steer_in_rad : FLOAT\n steering angle value.\n input_brake : FLOAT\n braking value.\n\n Returns\n -------\n None.\n\n '
throttle = np.fmax(np.fmin(input_throttle, 1.0), 0.0)
steer = np.fmax(np.fmin((self._conv_rad_to_steer * input_steer_in_rad), 1.0), (- 1.0))
brake = np.fmax(np.fmin(input_brake, 1.0), 0.0)
self._set_steer = steer
self._set_brake = brake
self._set_throttle = throttle
|
Processes input commands to be within their respective ranges
Parameters
----------
input_throttle : FLOAT
throlle value.
input_steer_in_rad : FLOAT
steering angle value.
input_brake : FLOAT
braking value.
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Set_Control_Commands
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Set_Control_Commands(self, input_throttle, input_steer_in_rad, input_brake):
'\n Processes input commands to be within their respective ranges\n\n Parameters\n ----------\n input_throttle : FLOAT\n throlle value.\n input_steer_in_rad : FLOAT\n steering angle value.\n input_brake : FLOAT\n braking value.\n\n Returns\n -------\n None.\n\n '
throttle = np.fmax(np.fmin(input_throttle, 1.0), 0.0)
steer = np.fmax(np.fmin((self._conv_rad_to_steer * input_steer_in_rad), 1.0), (- 1.0))
brake = np.fmax(np.fmin(input_brake, 1.0), 0.0)
self._set_steer = steer
self._set_brake = brake
self._set_throttle = throttle
|
def Set_Control_Commands(self, input_throttle, input_steer_in_rad, input_brake):
'\n Processes input commands to be within their respective ranges\n\n Parameters\n ----------\n input_throttle : FLOAT\n throlle value.\n input_steer_in_rad : FLOAT\n steering angle value.\n input_brake : FLOAT\n braking value.\n\n Returns\n -------\n None.\n\n '
throttle = np.fmax(np.fmin(input_throttle, 1.0), 0.0)
steer = np.fmax(np.fmin((self._conv_rad_to_steer * input_steer_in_rad), 1.0), (- 1.0))
brake = np.fmax(np.fmin(input_brake, 1.0), 0.0)
self._set_steer = steer
self._set_brake = brake
self._set_throttle = throttle<|docstring|>Processes input commands to be within their respective ranges
Parameters
----------
input_throttle : FLOAT
throlle value.
input_steer_in_rad : FLOAT
steering angle value.
input_brake : FLOAT
braking value.
Returns
-------
None.<|endoftext|>
|
01c36434eb253498c6fa3933e88c3bf5a01fd453192adc834cd38017e2054eb9
|
def Track_Waypoint(self, ego_player, static_player, ref_iterator):
'\n Asks the ego player to to move to the commanded waypt by avoiding the \n obstacle\n\n Parameters\n ----------\n ego_player : Carla Car Type Object\n object respresenting the ego car in the Carla environment.\n static_player : Carla Car Type Object\n object respresenting the obstacle car in the Carla environment.\n waypt : Carla Transform\n contains the next waypoint position and orientation information\n\n Returns\n -------\n None.\n\n '
x = self._current_x
y = self._current_y
yaw = self._current_yaw
v = self._current_speed
ox = self._obstacle_x
oy = self._obstacle_y
waypts = self._waypt_references
self.controller.Get_Control_Inputs(ego_player, static_player, ref_iterator, x, y, yaw, v, ox, oy, waypts)
|
Asks the ego player to to move to the commanded waypt by avoiding the
obstacle
Parameters
----------
ego_player : Carla Car Type Object
object respresenting the ego car in the Carla environment.
static_player : Carla Car Type Object
object respresenting the obstacle car in the Carla environment.
waypt : Carla Transform
contains the next waypoint position and orientation information
Returns
-------
None.
|
Dynamic Obstacle Simulation/MPC_Tracker.py
|
Track_Waypoint
|
TSummersLab/Risk_Bounded_Nonlinear_Robot_Motion_Planning
| 3
|
python
|
def Track_Waypoint(self, ego_player, static_player, ref_iterator):
'\n Asks the ego player to to move to the commanded waypt by avoiding the \n obstacle\n\n Parameters\n ----------\n ego_player : Carla Car Type Object\n object respresenting the ego car in the Carla environment.\n static_player : Carla Car Type Object\n object respresenting the obstacle car in the Carla environment.\n waypt : Carla Transform\n contains the next waypoint position and orientation information\n\n Returns\n -------\n None.\n\n '
x = self._current_x
y = self._current_y
yaw = self._current_yaw
v = self._current_speed
ox = self._obstacle_x
oy = self._obstacle_y
waypts = self._waypt_references
self.controller.Get_Control_Inputs(ego_player, static_player, ref_iterator, x, y, yaw, v, ox, oy, waypts)
|
def Track_Waypoint(self, ego_player, static_player, ref_iterator):
'\n Asks the ego player to to move to the commanded waypt by avoiding the \n obstacle\n\n Parameters\n ----------\n ego_player : Carla Car Type Object\n object respresenting the ego car in the Carla environment.\n static_player : Carla Car Type Object\n object respresenting the obstacle car in the Carla environment.\n waypt : Carla Transform\n contains the next waypoint position and orientation information\n\n Returns\n -------\n None.\n\n '
x = self._current_x
y = self._current_y
yaw = self._current_yaw
v = self._current_speed
ox = self._obstacle_x
oy = self._obstacle_y
waypts = self._waypt_references
self.controller.Get_Control_Inputs(ego_player, static_player, ref_iterator, x, y, yaw, v, ox, oy, waypts)<|docstring|>Asks the ego player to to move to the commanded waypt by avoiding the
obstacle
Parameters
----------
ego_player : Carla Car Type Object
object respresenting the ego car in the Carla environment.
static_player : Carla Car Type Object
object respresenting the obstacle car in the Carla environment.
waypt : Carla Transform
contains the next waypoint position and orientation information
Returns
-------
None.<|endoftext|>
|
b8010c9f7ea724f1e8b353440b582dcd34c01ecd051ce555479fb730d861f076
|
def GetCredential(self, *__args):
'\n GetCredential(self: NetworkCredential,host: str,port: int,authenticationType: str) -> NetworkCredential\n\n \n\n Returns an instance of the System.Net.NetworkCredential class for the specified host,port,and \n\n authentication type.\n\n \n\n \n\n host: The host computer that authenticates the client.\n\n port: The port on the host that the client communicates with.\n\n authenticationType: The type of authentication requested,as defined in the \n\n System.Net.IAuthenticationModule.AuthenticationType property.\n\n \n\n Returns: A System.Net.NetworkCredential for the specified host,port,and authentication protocol,or \n\n null if there are no credentials available for the specified host,port,and authentication \n\n protocol.\n\n \n\n GetCredential(self: NetworkCredential,uri: Uri,authType: str) -> NetworkCredential\n\n \n\n Returns an instance of the System.Net.NetworkCredential class for the specified Uniform Resource \n\n Identifier (URI) and authentication type.\n\n \n\n \n\n uri: The URI that the client provides authentication for.\n\n authType: The type of authentication requested,as defined in the \n\n System.Net.IAuthenticationModule.AuthenticationType property.\n\n \n\n Returns: A System.Net.NetworkCredential object.\n '
pass
|
GetCredential(self: NetworkCredential,host: str,port: int,authenticationType: str) -> NetworkCredential
Returns an instance of the System.Net.NetworkCredential class for the specified host,port,and
authentication type.
host: The host computer that authenticates the client.
port: The port on the host that the client communicates with.
authenticationType: The type of authentication requested,as defined in the
System.Net.IAuthenticationModule.AuthenticationType property.
Returns: A System.Net.NetworkCredential for the specified host,port,and authentication protocol,or
null if there are no credentials available for the specified host,port,and authentication
protocol.
GetCredential(self: NetworkCredential,uri: Uri,authType: str) -> NetworkCredential
Returns an instance of the System.Net.NetworkCredential class for the specified Uniform Resource
Identifier (URI) and authentication type.
uri: The URI that the client provides authentication for.
authType: The type of authentication requested,as defined in the
System.Net.IAuthenticationModule.AuthenticationType property.
Returns: A System.Net.NetworkCredential object.
|
release/stubs.min/System/Net/__init___parts/NetworkCredential.py
|
GetCredential
|
daddycocoaman/ironpython-stubs
| 182
|
python
|
def GetCredential(self, *__args):
'\n GetCredential(self: NetworkCredential,host: str,port: int,authenticationType: str) -> NetworkCredential\n\n \n\n Returns an instance of the System.Net.NetworkCredential class for the specified host,port,and \n\n authentication type.\n\n \n\n \n\n host: The host computer that authenticates the client.\n\n port: The port on the host that the client communicates with.\n\n authenticationType: The type of authentication requested,as defined in the \n\n System.Net.IAuthenticationModule.AuthenticationType property.\n\n \n\n Returns: A System.Net.NetworkCredential for the specified host,port,and authentication protocol,or \n\n null if there are no credentials available for the specified host,port,and authentication \n\n protocol.\n\n \n\n GetCredential(self: NetworkCredential,uri: Uri,authType: str) -> NetworkCredential\n\n \n\n Returns an instance of the System.Net.NetworkCredential class for the specified Uniform Resource \n\n Identifier (URI) and authentication type.\n\n \n\n \n\n uri: The URI that the client provides authentication for.\n\n authType: The type of authentication requested,as defined in the \n\n System.Net.IAuthenticationModule.AuthenticationType property.\n\n \n\n Returns: A System.Net.NetworkCredential object.\n '
pass
|
def GetCredential(self, *__args):
'\n GetCredential(self: NetworkCredential,host: str,port: int,authenticationType: str) -> NetworkCredential\n\n \n\n Returns an instance of the System.Net.NetworkCredential class for the specified host,port,and \n\n authentication type.\n\n \n\n \n\n host: The host computer that authenticates the client.\n\n port: The port on the host that the client communicates with.\n\n authenticationType: The type of authentication requested,as defined in the \n\n System.Net.IAuthenticationModule.AuthenticationType property.\n\n \n\n Returns: A System.Net.NetworkCredential for the specified host,port,and authentication protocol,or \n\n null if there are no credentials available for the specified host,port,and authentication \n\n protocol.\n\n \n\n GetCredential(self: NetworkCredential,uri: Uri,authType: str) -> NetworkCredential\n\n \n\n Returns an instance of the System.Net.NetworkCredential class for the specified Uniform Resource \n\n Identifier (URI) and authentication type.\n\n \n\n \n\n uri: The URI that the client provides authentication for.\n\n authType: The type of authentication requested,as defined in the \n\n System.Net.IAuthenticationModule.AuthenticationType property.\n\n \n\n Returns: A System.Net.NetworkCredential object.\n '
pass<|docstring|>GetCredential(self: NetworkCredential,host: str,port: int,authenticationType: str) -> NetworkCredential
Returns an instance of the System.Net.NetworkCredential class for the specified host,port,and
authentication type.
host: The host computer that authenticates the client.
port: The port on the host that the client communicates with.
authenticationType: The type of authentication requested,as defined in the
System.Net.IAuthenticationModule.AuthenticationType property.
Returns: A System.Net.NetworkCredential for the specified host,port,and authentication protocol,or
null if there are no credentials available for the specified host,port,and authentication
protocol.
GetCredential(self: NetworkCredential,uri: Uri,authType: str) -> NetworkCredential
Returns an instance of the System.Net.NetworkCredential class for the specified Uniform Resource
Identifier (URI) and authentication type.
uri: The URI that the client provides authentication for.
authType: The type of authentication requested,as defined in the
System.Net.IAuthenticationModule.AuthenticationType property.
Returns: A System.Net.NetworkCredential object.<|endoftext|>
|
32b5271afcd5ecc37febb67dd854fa2d1b2c4c68b2c41d2ec119d33157e9bbaa
|
def __init__(self, *args):
' x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature '
pass
|
x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature
|
release/stubs.min/System/Net/__init___parts/NetworkCredential.py
|
__init__
|
daddycocoaman/ironpython-stubs
| 182
|
python
|
def __init__(self, *args):
' '
pass
|
def __init__(self, *args):
' '
pass<|docstring|>x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature<|endoftext|>
|
b045c7b4a5ebc0b4d36c77551e09122fe7525fa68ca76eb3d6447b27fd5ef38f
|
@staticmethod
def __new__(self, userName=None, password=None, domain=None):
'\n __new__(cls: type)\n\n __new__(cls: type,userName: str,password: str)\n\n __new__(cls: type,userName: str,password: SecureString)\n\n __new__(cls: type,userName: str,password: str,domain: str)\n\n __new__(cls: type,userName: str,password: SecureString,domain: str)\n '
pass
|
__new__(cls: type)
__new__(cls: type,userName: str,password: str)
__new__(cls: type,userName: str,password: SecureString)
__new__(cls: type,userName: str,password: str,domain: str)
__new__(cls: type,userName: str,password: SecureString,domain: str)
|
release/stubs.min/System/Net/__init___parts/NetworkCredential.py
|
__new__
|
daddycocoaman/ironpython-stubs
| 182
|
python
|
@staticmethod
def __new__(self, userName=None, password=None, domain=None):
'\n __new__(cls: type)\n\n __new__(cls: type,userName: str,password: str)\n\n __new__(cls: type,userName: str,password: SecureString)\n\n __new__(cls: type,userName: str,password: str,domain: str)\n\n __new__(cls: type,userName: str,password: SecureString,domain: str)\n '
pass
|
@staticmethod
def __new__(self, userName=None, password=None, domain=None):
'\n __new__(cls: type)\n\n __new__(cls: type,userName: str,password: str)\n\n __new__(cls: type,userName: str,password: SecureString)\n\n __new__(cls: type,userName: str,password: str,domain: str)\n\n __new__(cls: type,userName: str,password: SecureString,domain: str)\n '
pass<|docstring|>__new__(cls: type)
__new__(cls: type,userName: str,password: str)
__new__(cls: type,userName: str,password: SecureString)
__new__(cls: type,userName: str,password: str,domain: str)
__new__(cls: type,userName: str,password: SecureString,domain: str)<|endoftext|>
|
746ad82e56350ce0365d6c7705d304bec5ee6fa3615ee6dcbcff4ffb0e8e54d3
|
def __repr__(self, *args):
' __repr__(self: object) -> str '
pass
|
__repr__(self: object) -> str
|
release/stubs.min/System/Net/__init___parts/NetworkCredential.py
|
__repr__
|
daddycocoaman/ironpython-stubs
| 182
|
python
|
def __repr__(self, *args):
' '
pass
|
def __repr__(self, *args):
' '
pass<|docstring|>__repr__(self: object) -> str<|endoftext|>
|
1a41f0dfd69b8a332621f271c878ee0e11f73240def84a30a18a19eb6929b6f1
|
def from_data(syms, xyzs, angstrom=False):
' geometry data structure from symbols and coordinates\n '
return automol.create.geom.from_data(symbols=syms, coordinates=xyzs, angstrom=angstrom)
|
geometry data structure from symbols and coordinates
|
automol/geom.py
|
from_data
|
sjklipp/autochem_1219
| 0
|
python
|
def from_data(syms, xyzs, angstrom=False):
' \n '
return automol.create.geom.from_data(symbols=syms, coordinates=xyzs, angstrom=angstrom)
|
def from_data(syms, xyzs, angstrom=False):
' \n '
return automol.create.geom.from_data(symbols=syms, coordinates=xyzs, angstrom=angstrom)<|docstring|>geometry data structure from symbols and coordinates<|endoftext|>
|
b82cd987310c2b7df7dfabd34945f9e29e125826fe1e614edde0c85ec46c4207
|
def symbols(geo):
' atomic symbols\n '
if geo:
(syms, _) = zip(*geo)
else:
syms = ()
return syms
|
atomic symbols
|
automol/geom.py
|
symbols
|
sjklipp/autochem_1219
| 0
|
python
|
def symbols(geo):
' \n '
if geo:
(syms, _) = zip(*geo)
else:
syms = ()
return syms
|
def symbols(geo):
' \n '
if geo:
(syms, _) = zip(*geo)
else:
syms = ()
return syms<|docstring|>atomic symbols<|endoftext|>
|
34c2a01b378e419e62271f140694b705f5674d21b885a4bb752bd1d9be75a8d6
|
def coordinates(geo, angstrom=False):
' atomic coordinates\n '
if geo:
(_, xyzs) = zip(*geo)
else:
xyzs = ()
xyzs = (xyzs if (not angstrom) else numpy.multiply(xyzs, qcc.conversion_factor('bohr', 'angstrom')))
return xyzs
|
atomic coordinates
|
automol/geom.py
|
coordinates
|
sjklipp/autochem_1219
| 0
|
python
|
def coordinates(geo, angstrom=False):
' \n '
if geo:
(_, xyzs) = zip(*geo)
else:
xyzs = ()
xyzs = (xyzs if (not angstrom) else numpy.multiply(xyzs, qcc.conversion_factor('bohr', 'angstrom')))
return xyzs
|
def coordinates(geo, angstrom=False):
' \n '
if geo:
(_, xyzs) = zip(*geo)
else:
xyzs = ()
xyzs = (xyzs if (not angstrom) else numpy.multiply(xyzs, qcc.conversion_factor('bohr', 'angstrom')))
return xyzs<|docstring|>atomic coordinates<|endoftext|>
|
9e19d630cfd94b782a669636b6e364f7c57252206e25773dd1ae84ea385e4361
|
def is_valid(geo):
' is this a valid geometry?\n '
ret = hasattr(geo, '__iter__')
if ret:
ret = all(((hasattr(obj, '__len__') and (len(obj) == 2)) for obj in geo))
if ret:
(syms, xyzs) = zip(*geo)
try:
from_data(syms, xyzs)
except AssertionError:
ret = False
return ret
|
is this a valid geometry?
|
automol/geom.py
|
is_valid
|
sjklipp/autochem_1219
| 0
|
python
|
def is_valid(geo):
' \n '
ret = hasattr(geo, '__iter__')
if ret:
ret = all(((hasattr(obj, '__len__') and (len(obj) == 2)) for obj in geo))
if ret:
(syms, xyzs) = zip(*geo)
try:
from_data(syms, xyzs)
except AssertionError:
ret = False
return ret
|
def is_valid(geo):
' \n '
ret = hasattr(geo, '__iter__')
if ret:
ret = all(((hasattr(obj, '__len__') and (len(obj) == 2)) for obj in geo))
if ret:
(syms, xyzs) = zip(*geo)
try:
from_data(syms, xyzs)
except AssertionError:
ret = False
return ret<|docstring|>is this a valid geometry?<|endoftext|>
|
a01a3139c55bc64ecb5d930187613c3f8fa4f46b463d4da9d0f2cd4d2f911b8b
|
def set_coordinates(geo, xyz_dct):
' set coordinate values for the geometry, using a dictionary by index\n '
syms = symbols(geo)
xyzs = coordinates(geo)
natms = len(syms)
assert all(((idx in range(natms)) for idx in xyz_dct))
xyzs = [(xyz_dct[idx] if (idx in xyz_dct) else xyz) for (idx, xyz) in enumerate(xyzs)]
return from_data(syms, xyzs)
|
set coordinate values for the geometry, using a dictionary by index
|
automol/geom.py
|
set_coordinates
|
sjklipp/autochem_1219
| 0
|
python
|
def set_coordinates(geo, xyz_dct):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
natms = len(syms)
assert all(((idx in range(natms)) for idx in xyz_dct))
xyzs = [(xyz_dct[idx] if (idx in xyz_dct) else xyz) for (idx, xyz) in enumerate(xyzs)]
return from_data(syms, xyzs)
|
def set_coordinates(geo, xyz_dct):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
natms = len(syms)
assert all(((idx in range(natms)) for idx in xyz_dct))
xyzs = [(xyz_dct[idx] if (idx in xyz_dct) else xyz) for (idx, xyz) in enumerate(xyzs)]
return from_data(syms, xyzs)<|docstring|>set coordinate values for the geometry, using a dictionary by index<|endoftext|>
|
01ff432d8510674a32d7227c7eabafa7512f12a0ef076bd24d68d69b5d8aaa5d
|
def without_dummy_atoms(geo):
' return a copy of the geometry without dummy atoms\n '
syms = symbols(geo)
xyzs = coordinates(geo)
non_dummy_keys = [idx for (idx, sym) in enumerate(syms) if pt.to_Z(sym)]
syms = list(map(syms.__getitem__, non_dummy_keys))
xyzs = list(map(xyzs.__getitem__, non_dummy_keys))
return from_data(syms, xyzs)
|
return a copy of the geometry without dummy atoms
|
automol/geom.py
|
without_dummy_atoms
|
sjklipp/autochem_1219
| 0
|
python
|
def without_dummy_atoms(geo):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
non_dummy_keys = [idx for (idx, sym) in enumerate(syms) if pt.to_Z(sym)]
syms = list(map(syms.__getitem__, non_dummy_keys))
xyzs = list(map(xyzs.__getitem__, non_dummy_keys))
return from_data(syms, xyzs)
|
def without_dummy_atoms(geo):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
non_dummy_keys = [idx for (idx, sym) in enumerate(syms) if pt.to_Z(sym)]
syms = list(map(syms.__getitem__, non_dummy_keys))
xyzs = list(map(xyzs.__getitem__, non_dummy_keys))
return from_data(syms, xyzs)<|docstring|>return a copy of the geometry without dummy atoms<|endoftext|>
|
6ca6705d58056752b0c1cb0d23629a029219c0eafc4744e54014692f413ab1a2
|
def join(geo1, geo2, dist_cutoff=(3.0 * qcc.conversion_factor('angstrom', 'bohr')), theta=(0.0 * qcc.conversion_factor('degree', 'radian')), phi=(0.0 * qcc.conversion_factor('degree', 'radian'))):
' join two geometries together\n '
orient_vec = numpy.array([(numpy.sin(theta) * numpy.cos(phi)), (numpy.sin(theta) * numpy.sin(phi)), numpy.cos(theta)])
geo1 = mass_centered(geo1)
geo2 = mass_centered(geo2)
ext1 = max((numpy.vdot(orient_vec, xyz) for xyz in coordinates(geo1)))
ext2 = max((numpy.vdot((- orient_vec), xyz) for xyz in coordinates(geo2)))
cm_dist = ((ext1 + dist_cutoff) + ext2)
dist_grid = numpy.arange(cm_dist, 0.0, (- 0.1))
for dist in dist_grid:
trans_geo2 = translated(geo2, (orient_vec * dist))
min_dist = minimum_distance(geo1, trans_geo2)
if (numpy.abs((min_dist - dist_cutoff)) < 0.1):
break
geo2 = trans_geo2
syms = (symbols(geo1) + symbols(geo2))
xyzs = (coordinates(geo1) + coordinates(geo2))
return from_data(syms, xyzs)
|
join two geometries together
|
automol/geom.py
|
join
|
sjklipp/autochem_1219
| 0
|
python
|
def join(geo1, geo2, dist_cutoff=(3.0 * qcc.conversion_factor('angstrom', 'bohr')), theta=(0.0 * qcc.conversion_factor('degree', 'radian')), phi=(0.0 * qcc.conversion_factor('degree', 'radian'))):
' \n '
orient_vec = numpy.array([(numpy.sin(theta) * numpy.cos(phi)), (numpy.sin(theta) * numpy.sin(phi)), numpy.cos(theta)])
geo1 = mass_centered(geo1)
geo2 = mass_centered(geo2)
ext1 = max((numpy.vdot(orient_vec, xyz) for xyz in coordinates(geo1)))
ext2 = max((numpy.vdot((- orient_vec), xyz) for xyz in coordinates(geo2)))
cm_dist = ((ext1 + dist_cutoff) + ext2)
dist_grid = numpy.arange(cm_dist, 0.0, (- 0.1))
for dist in dist_grid:
trans_geo2 = translated(geo2, (orient_vec * dist))
min_dist = minimum_distance(geo1, trans_geo2)
if (numpy.abs((min_dist - dist_cutoff)) < 0.1):
break
geo2 = trans_geo2
syms = (symbols(geo1) + symbols(geo2))
xyzs = (coordinates(geo1) + coordinates(geo2))
return from_data(syms, xyzs)
|
def join(geo1, geo2, dist_cutoff=(3.0 * qcc.conversion_factor('angstrom', 'bohr')), theta=(0.0 * qcc.conversion_factor('degree', 'radian')), phi=(0.0 * qcc.conversion_factor('degree', 'radian'))):
' \n '
orient_vec = numpy.array([(numpy.sin(theta) * numpy.cos(phi)), (numpy.sin(theta) * numpy.sin(phi)), numpy.cos(theta)])
geo1 = mass_centered(geo1)
geo2 = mass_centered(geo2)
ext1 = max((numpy.vdot(orient_vec, xyz) for xyz in coordinates(geo1)))
ext2 = max((numpy.vdot((- orient_vec), xyz) for xyz in coordinates(geo2)))
cm_dist = ((ext1 + dist_cutoff) + ext2)
dist_grid = numpy.arange(cm_dist, 0.0, (- 0.1))
for dist in dist_grid:
trans_geo2 = translated(geo2, (orient_vec * dist))
min_dist = minimum_distance(geo1, trans_geo2)
if (numpy.abs((min_dist - dist_cutoff)) < 0.1):
break
geo2 = trans_geo2
syms = (symbols(geo1) + symbols(geo2))
xyzs = (coordinates(geo1) + coordinates(geo2))
return from_data(syms, xyzs)<|docstring|>join two geometries together<|endoftext|>
|
6b65d50d4cb7753a1fffe7b566356fd2b431ba22e395786d83e7164a1b298939
|
def from_string(geo_str, angstrom=True):
' read a cartesian geometry from a string\n '
(syms, xyzs) = ar.geom.read(geo_str)
geo = from_data(syms, xyzs, angstrom=angstrom)
return geo
|
read a cartesian geometry from a string
|
automol/geom.py
|
from_string
|
sjklipp/autochem_1219
| 0
|
python
|
def from_string(geo_str, angstrom=True):
' \n '
(syms, xyzs) = ar.geom.read(geo_str)
geo = from_data(syms, xyzs, angstrom=angstrom)
return geo
|
def from_string(geo_str, angstrom=True):
' \n '
(syms, xyzs) = ar.geom.read(geo_str)
geo = from_data(syms, xyzs, angstrom=angstrom)
return geo<|docstring|>read a cartesian geometry from a string<|endoftext|>
|
c380f44adaca02180a3d295baee9f78810cc80b9cf73fc013c90bc8cd2122b1a
|
def from_xyz_string(xyz_str):
' read a cartesian geometry from a .xyz string\n '
(syms, xyzs) = ar.geom.read_xyz(xyz_str)
geo = from_data(syms, xyzs, angstrom=True)
return geo
|
read a cartesian geometry from a .xyz string
|
automol/geom.py
|
from_xyz_string
|
sjklipp/autochem_1219
| 0
|
python
|
def from_xyz_string(xyz_str):
' \n '
(syms, xyzs) = ar.geom.read_xyz(xyz_str)
geo = from_data(syms, xyzs, angstrom=True)
return geo
|
def from_xyz_string(xyz_str):
' \n '
(syms, xyzs) = ar.geom.read_xyz(xyz_str)
geo = from_data(syms, xyzs, angstrom=True)
return geo<|docstring|>read a cartesian geometry from a .xyz string<|endoftext|>
|
4ad2879b91470342f9360a8cafd929b94697df8e7780a6b1c905f1363b708907
|
def string(geo, angstrom=True):
' write the cartesian geometry as a string\n '
syms = symbols(geo)
xyzs = coordinates(geo, angstrom=angstrom)
geo_str = aw.geom.write(syms=syms, xyzs=xyzs)
return geo_str
|
write the cartesian geometry as a string
|
automol/geom.py
|
string
|
sjklipp/autochem_1219
| 0
|
python
|
def string(geo, angstrom=True):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo, angstrom=angstrom)
geo_str = aw.geom.write(syms=syms, xyzs=xyzs)
return geo_str
|
def string(geo, angstrom=True):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo, angstrom=angstrom)
geo_str = aw.geom.write(syms=syms, xyzs=xyzs)
return geo_str<|docstring|>write the cartesian geometry as a string<|endoftext|>
|
3814e1945e434cfd377c66ebcd3c5e06b2a874e4212b5514c1bf6bd1f4f1e2ce
|
def xyz_string(geo, comment=None):
' write the cartesian geometry to a .xyz string\n '
syms = symbols(geo)
xyzs = coordinates(geo, angstrom=True)
geo_str = aw.geom.write_xyz(syms=syms, xyzs=xyzs, comment=comment)
return geo_str
|
write the cartesian geometry to a .xyz string
|
automol/geom.py
|
xyz_string
|
sjklipp/autochem_1219
| 0
|
python
|
def xyz_string(geo, comment=None):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo, angstrom=True)
geo_str = aw.geom.write_xyz(syms=syms, xyzs=xyzs, comment=comment)
return geo_str
|
def xyz_string(geo, comment=None):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo, angstrom=True)
geo_str = aw.geom.write_xyz(syms=syms, xyzs=xyzs, comment=comment)
return geo_str<|docstring|>write the cartesian geometry to a .xyz string<|endoftext|>
|
08e924abbb4838e05a76a17c75b791223d263db0b10e56c5c06a7f9e58cdcb17
|
def xyz_trajectory_string(geo_lst, comments=None):
' write a series of cartesian geometries to a .xyz string\n '
syms_lst = [symbols(geo) for geo in geo_lst]
xyzs_lst = [coordinates(geo, angstrom=True) for geo in geo_lst]
assert (len(set(syms_lst)) == 1)
syms = syms_lst[0]
xyz_traj_str = aw.geom.write_xyz_trajectory(syms, xyzs_lst, comments=comments)
return xyz_traj_str
|
write a series of cartesian geometries to a .xyz string
|
automol/geom.py
|
xyz_trajectory_string
|
sjklipp/autochem_1219
| 0
|
python
|
def xyz_trajectory_string(geo_lst, comments=None):
' \n '
syms_lst = [symbols(geo) for geo in geo_lst]
xyzs_lst = [coordinates(geo, angstrom=True) for geo in geo_lst]
assert (len(set(syms_lst)) == 1)
syms = syms_lst[0]
xyz_traj_str = aw.geom.write_xyz_trajectory(syms, xyzs_lst, comments=comments)
return xyz_traj_str
|
def xyz_trajectory_string(geo_lst, comments=None):
' \n '
syms_lst = [symbols(geo) for geo in geo_lst]
xyzs_lst = [coordinates(geo, angstrom=True) for geo in geo_lst]
assert (len(set(syms_lst)) == 1)
syms = syms_lst[0]
xyz_traj_str = aw.geom.write_xyz_trajectory(syms, xyzs_lst, comments=comments)
return xyz_traj_str<|docstring|>write a series of cartesian geometries to a .xyz string<|endoftext|>
|
3923927154c31ea8c75c88e1f52313d50a1f14befdc7e08fbe03ad9707ed9695
|
def view(geo):
' view the geometry using nglview\n '
import nglview
xyz_str = xyz_string(geo)
qcm = qcel.models.Molecule.from_data(xyz_str)
ngv = nglview.show_qcelemental(qcm)
return ngv
|
view the geometry using nglview
|
automol/geom.py
|
view
|
sjklipp/autochem_1219
| 0
|
python
|
def view(geo):
' \n '
import nglview
xyz_str = xyz_string(geo)
qcm = qcel.models.Molecule.from_data(xyz_str)
ngv = nglview.show_qcelemental(qcm)
return ngv
|
def view(geo):
' \n '
import nglview
xyz_str = xyz_string(geo)
qcm = qcel.models.Molecule.from_data(xyz_str)
ngv = nglview.show_qcelemental(qcm)
return ngv<|docstring|>view the geometry using nglview<|endoftext|>
|
f2eed382b91cce00382b455ae6e91f5dc6741ebcc1b381aa8ef45f1626070437
|
def coulomb_spectrum(geo):
' (sorted) coulomb matrix eigenvalue spectrum\n '
mat = _coulomb_matrix(geo)
vals = tuple(sorted(numpy.linalg.eigvalsh(mat)))
return vals
|
(sorted) coulomb matrix eigenvalue spectrum
|
automol/geom.py
|
coulomb_spectrum
|
sjklipp/autochem_1219
| 0
|
python
|
def coulomb_spectrum(geo):
' \n '
mat = _coulomb_matrix(geo)
vals = tuple(sorted(numpy.linalg.eigvalsh(mat)))
return vals
|
def coulomb_spectrum(geo):
' \n '
mat = _coulomb_matrix(geo)
vals = tuple(sorted(numpy.linalg.eigvalsh(mat)))
return vals<|docstring|>(sorted) coulomb matrix eigenvalue spectrum<|endoftext|>
|
8aaade2d19e476f5767745bdda9700a1725478caf265cd7647839bcbbd393b92
|
def almost_equal(geo1, geo2, rtol=0.002):
' are these geometries numerically equal?\n '
ret = False
if (symbols(geo1) == symbols(geo2)):
ret = numpy.allclose(coordinates(geo1), coordinates(geo2), rtol=rtol)
return ret
|
are these geometries numerically equal?
|
automol/geom.py
|
almost_equal
|
sjklipp/autochem_1219
| 0
|
python
|
def almost_equal(geo1, geo2, rtol=0.002):
' \n '
ret = False
if (symbols(geo1) == symbols(geo2)):
ret = numpy.allclose(coordinates(geo1), coordinates(geo2), rtol=rtol)
return ret
|
def almost_equal(geo1, geo2, rtol=0.002):
' \n '
ret = False
if (symbols(geo1) == symbols(geo2)):
ret = numpy.allclose(coordinates(geo1), coordinates(geo2), rtol=rtol)
return ret<|docstring|>are these geometries numerically equal?<|endoftext|>
|
4a3646438d4e49d1189958f8062ea06add528c6a479c38c503373230310eda0e
|
def minimum_distance(geo1, geo2):
' get the minimum distance between atoms in geo1 and those in geo2\n '
xyzs1 = coordinates(geo1)
xyzs2 = coordinates(geo2)
return min((cart.vec.distance(xyz1, xyz2) for (xyz1, xyz2) in itertools.product(xyzs1, xyzs2)))
|
get the minimum distance between atoms in geo1 and those in geo2
|
automol/geom.py
|
minimum_distance
|
sjklipp/autochem_1219
| 0
|
python
|
def minimum_distance(geo1, geo2):
' \n '
xyzs1 = coordinates(geo1)
xyzs2 = coordinates(geo2)
return min((cart.vec.distance(xyz1, xyz2) for (xyz1, xyz2) in itertools.product(xyzs1, xyzs2)))
|
def minimum_distance(geo1, geo2):
' \n '
xyzs1 = coordinates(geo1)
xyzs2 = coordinates(geo2)
return min((cart.vec.distance(xyz1, xyz2) for (xyz1, xyz2) in itertools.product(xyzs1, xyzs2)))<|docstring|>get the minimum distance between atoms in geo1 and those in geo2<|endoftext|>
|
a7f134e0f9bc33c56ed08f0b0925eb9a9836e8d254e349acacb1949de6ceb5a6
|
def almost_equal_coulomb_spectrum(geo1, geo2, rtol=0.01):
' do these geometries have similar coulomb spectrums?\n '
ret = numpy.allclose(coulomb_spectrum(geo1), coulomb_spectrum(geo2), rtol=rtol)
return ret
|
do these geometries have similar coulomb spectrums?
|
automol/geom.py
|
almost_equal_coulomb_spectrum
|
sjklipp/autochem_1219
| 0
|
python
|
def almost_equal_coulomb_spectrum(geo1, geo2, rtol=0.01):
' \n '
ret = numpy.allclose(coulomb_spectrum(geo1), coulomb_spectrum(geo2), rtol=rtol)
return ret
|
def almost_equal_coulomb_spectrum(geo1, geo2, rtol=0.01):
' \n '
ret = numpy.allclose(coulomb_spectrum(geo1), coulomb_spectrum(geo2), rtol=rtol)
return ret<|docstring|>do these geometries have similar coulomb spectrums?<|endoftext|>
|
5b5df0a8d3bb5bbde910a545616362e54d4cf54ac4041117514f6c5333503342
|
def argunique_coulomb_spectrum(geos, seen_geos=(), rtol=0.01):
' get indices of unique geometries, by coulomb spectrum\n '
comp_ = functools.partial(almost_equal_coulomb_spectrum, rtol=rtol)
idxs = _argunique(geos, comp_, seen_items=seen_geos)
return idxs
|
get indices of unique geometries, by coulomb spectrum
|
automol/geom.py
|
argunique_coulomb_spectrum
|
sjklipp/autochem_1219
| 0
|
python
|
def argunique_coulomb_spectrum(geos, seen_geos=(), rtol=0.01):
' \n '
comp_ = functools.partial(almost_equal_coulomb_spectrum, rtol=rtol)
idxs = _argunique(geos, comp_, seen_items=seen_geos)
return idxs
|
def argunique_coulomb_spectrum(geos, seen_geos=(), rtol=0.01):
' \n '
comp_ = functools.partial(almost_equal_coulomb_spectrum, rtol=rtol)
idxs = _argunique(geos, comp_, seen_items=seen_geos)
return idxs<|docstring|>get indices of unique geometries, by coulomb spectrum<|endoftext|>
|
48c947e2b65139be25f26276fdd2b349d87899b0dd9766bc2c885774d05dd0ef
|
def _argunique(items, comparison, seen_items=()):
' get the indices of unique items using some comparison function\n '
idxs = []
seen_items = list(seen_items)
for (idx, item) in enumerate(items):
if (not any((comparison(item, seen_item) for seen_item in seen_items))):
idxs.append(idx)
seen_items.append(item)
idxs = tuple(idxs)
return idxs
|
get the indices of unique items using some comparison function
|
automol/geom.py
|
_argunique
|
sjklipp/autochem_1219
| 0
|
python
|
def _argunique(items, comparison, seen_items=()):
' \n '
idxs = []
seen_items = list(seen_items)
for (idx, item) in enumerate(items):
if (not any((comparison(item, seen_item) for seen_item in seen_items))):
idxs.append(idx)
seen_items.append(item)
idxs = tuple(idxs)
return idxs
|
def _argunique(items, comparison, seen_items=()):
' \n '
idxs = []
seen_items = list(seen_items)
for (idx, item) in enumerate(items):
if (not any((comparison(item, seen_item) for seen_item in seen_items))):
idxs.append(idx)
seen_items.append(item)
idxs = tuple(idxs)
return idxs<|docstring|>get the indices of unique items using some comparison function<|endoftext|>
|
f8ae671fd4bfc23ba8cb11ee8d9f264d6d0dac69091b17714a10f3142ada8bcf
|
def displaced(geo, xyzs):
' displacement of the geometry\n '
syms = symbols(geo)
orig_xyzs = coordinates(geo)
xyzs = numpy.add(orig_xyzs, xyzs)
return from_data(syms, xyzs)
|
displacement of the geometry
|
automol/geom.py
|
displaced
|
sjklipp/autochem_1219
| 0
|
python
|
def displaced(geo, xyzs):
' \n '
syms = symbols(geo)
orig_xyzs = coordinates(geo)
xyzs = numpy.add(orig_xyzs, xyzs)
return from_data(syms, xyzs)
|
def displaced(geo, xyzs):
' \n '
syms = symbols(geo)
orig_xyzs = coordinates(geo)
xyzs = numpy.add(orig_xyzs, xyzs)
return from_data(syms, xyzs)<|docstring|>displacement of the geometry<|endoftext|>
|
81e02081da1f465ed78c05e76fdded22c3af7150327cbe551f45c0793bc2fdb5
|
def translated(geo, xyz):
' translation of the geometry\n '
syms = symbols(geo)
xyzs = coordinates(geo)
xyzs = numpy.add(xyzs, xyz)
return from_data(syms, xyzs)
|
translation of the geometry
|
automol/geom.py
|
translated
|
sjklipp/autochem_1219
| 0
|
python
|
def translated(geo, xyz):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
xyzs = numpy.add(xyzs, xyz)
return from_data(syms, xyzs)
|
def translated(geo, xyz):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
xyzs = numpy.add(xyzs, xyz)
return from_data(syms, xyzs)<|docstring|>translation of the geometry<|endoftext|>
|
8622fac1b8101f80005f4c7678da39d20b7440d24c37bdb604cf2ca427aeac62
|
def rotated(geo, axis, angle):
' axis-angle rotation of the geometry\n '
syms = symbols(geo)
xyzs = coordinates(geo)
rot_mat = cart.mat.rotation(axis, angle)
xyzs = numpy.dot(xyzs, numpy.transpose(rot_mat))
return from_data(syms, xyzs)
|
axis-angle rotation of the geometry
|
automol/geom.py
|
rotated
|
sjklipp/autochem_1219
| 0
|
python
|
def rotated(geo, axis, angle):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
rot_mat = cart.mat.rotation(axis, angle)
xyzs = numpy.dot(xyzs, numpy.transpose(rot_mat))
return from_data(syms, xyzs)
|
def rotated(geo, axis, angle):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
rot_mat = cart.mat.rotation(axis, angle)
xyzs = numpy.dot(xyzs, numpy.transpose(rot_mat))
return from_data(syms, xyzs)<|docstring|>axis-angle rotation of the geometry<|endoftext|>
|
8c74e56243385015606c789754280d98f7afd51491871c98666f939e56d74f9c
|
def euler_rotated(geo, theta, phi, psi):
' axis-angle rotation of the geometry\n '
syms = symbols(geo)
xyzs = coordinates(geo)
rot_mat = cart.mat.euler_rotation(theta, phi, psi)
xyzs = numpy.dot(xyzs, numpy.transpose(rot_mat))
return from_data(syms, xyzs)
|
axis-angle rotation of the geometry
|
automol/geom.py
|
euler_rotated
|
sjklipp/autochem_1219
| 0
|
python
|
def euler_rotated(geo, theta, phi, psi):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
rot_mat = cart.mat.euler_rotation(theta, phi, psi)
xyzs = numpy.dot(xyzs, numpy.transpose(rot_mat))
return from_data(syms, xyzs)
|
def euler_rotated(geo, theta, phi, psi):
' \n '
syms = symbols(geo)
xyzs = coordinates(geo)
rot_mat = cart.mat.euler_rotation(theta, phi, psi)
xyzs = numpy.dot(xyzs, numpy.transpose(rot_mat))
return from_data(syms, xyzs)<|docstring|>axis-angle rotation of the geometry<|endoftext|>
|
48c706a91edd5b574177a8c26aa9fa29bd2135c6e624d19c468575af8185b9fc
|
def swap_coordinates(geo, idx1, idx2):
' swap the order of the coordinates of the two atoms\n '
geo = [list(x) for x in geo]
(geo[idx1], geo[idx2]) = (geo[idx2], geo[idx1])
geo_swp = tuple((tuple(x) for x in geo))
return geo_swp
|
swap the order of the coordinates of the two atoms
|
automol/geom.py
|
swap_coordinates
|
sjklipp/autochem_1219
| 0
|
python
|
def swap_coordinates(geo, idx1, idx2):
' \n '
geo = [list(x) for x in geo]
(geo[idx1], geo[idx2]) = (geo[idx2], geo[idx1])
geo_swp = tuple((tuple(x) for x in geo))
return geo_swp
|
def swap_coordinates(geo, idx1, idx2):
' \n '
geo = [list(x) for x in geo]
(geo[idx1], geo[idx2]) = (geo[idx2], geo[idx1])
geo_swp = tuple((tuple(x) for x in geo))
return geo_swp<|docstring|>swap the order of the coordinates of the two atoms<|endoftext|>
|
e5aab28878059c0d2a83c385f50fbac5f07d413e6a651dfcee55bd15a390ad0b
|
def move_coordinates(geo, idx1, idx2):
' move the atom at position idx1 to idx2, shifting all other atoms\n '
geo = [list(x) for x in geo]
moving_coords = geo[idx1]
geo.remove(moving_coords)
geo.insert(idx2, moving_coords)
geo_move = tuple((tuple(x) for x in geo))
return geo_move
|
move the atom at position idx1 to idx2, shifting all other atoms
|
automol/geom.py
|
move_coordinates
|
sjklipp/autochem_1219
| 0
|
python
|
def move_coordinates(geo, idx1, idx2):
' \n '
geo = [list(x) for x in geo]
moving_coords = geo[idx1]
geo.remove(moving_coords)
geo.insert(idx2, moving_coords)
geo_move = tuple((tuple(x) for x in geo))
return geo_move
|
def move_coordinates(geo, idx1, idx2):
' \n '
geo = [list(x) for x in geo]
moving_coords = geo[idx1]
geo.remove(moving_coords)
geo.insert(idx2, moving_coords)
geo_move = tuple((tuple(x) for x in geo))
return geo_move<|docstring|>move the atom at position idx1 to idx2, shifting all other atoms<|endoftext|>
|
8d18fb31a78efafad5c1471c976cfb6e9236e653ba7925788ea5a210aedbef89
|
def reflect_coordinates(geo, idxs, axes):
' reflect each coordinate about the requested axes\n '
assert all(((idx < len(geo)) for idx in idxs))
assert all(((axis in ('x', 'y', 'z')) for axis in axes))
coords = coordinates(geo)
axis_dct = {'x': 0, 'y': 1, 'z': 2}
axes = [axis_dct[axis] for axis in axes]
reflect_dct = {}
for idx in idxs:
coord_lst = list(coords[idx])
for axis in axes:
coord_lst[axis] *= (- 1.0)
reflect_dct[idx] = coord_lst
geo_reflected = set_coordinates(geo, reflect_dct)
return geo_reflected
|
reflect each coordinate about the requested axes
|
automol/geom.py
|
reflect_coordinates
|
sjklipp/autochem_1219
| 0
|
python
|
def reflect_coordinates(geo, idxs, axes):
' \n '
assert all(((idx < len(geo)) for idx in idxs))
assert all(((axis in ('x', 'y', 'z')) for axis in axes))
coords = coordinates(geo)
axis_dct = {'x': 0, 'y': 1, 'z': 2}
axes = [axis_dct[axis] for axis in axes]
reflect_dct = {}
for idx in idxs:
coord_lst = list(coords[idx])
for axis in axes:
coord_lst[axis] *= (- 1.0)
reflect_dct[idx] = coord_lst
geo_reflected = set_coordinates(geo, reflect_dct)
return geo_reflected
|
def reflect_coordinates(geo, idxs, axes):
' \n '
assert all(((idx < len(geo)) for idx in idxs))
assert all(((axis in ('x', 'y', 'z')) for axis in axes))
coords = coordinates(geo)
axis_dct = {'x': 0, 'y': 1, 'z': 2}
axes = [axis_dct[axis] for axis in axes]
reflect_dct = {}
for idx in idxs:
coord_lst = list(coords[idx])
for axis in axes:
coord_lst[axis] *= (- 1.0)
reflect_dct[idx] = coord_lst
geo_reflected = set_coordinates(geo, reflect_dct)
return geo_reflected<|docstring|>reflect each coordinate about the requested axes<|endoftext|>
|
76ef7e0ef48cd20d8f48fdaf9b837118ecc0e98b36f8ec88c141527bf73f26c5
|
def rot_permutated_geoms(geo, saddle=False, frm_bnd_key=[], brk_bnd_key=[], form_coords=[]):
' convert an input geometry to a list of geometries\n corresponding to the rotational permuations of all the terminal groups\n '
gra = graph(geo, remove_stereo=True)
term_atms = {}
all_hyds = []
neighbor_dct = automol.graph.atom_neighbor_keys(gra)
unsat_atms = automol.graph.unsaturated_atom_keys(gra)
if (not saddle):
rad_atms = automol.graph.sing_res_dom_radical_atom_keys(gra)
res_rad_atms = automol.graph.resonance_dominant_radical_atom_keys(gra)
rad_atms = [atm for atm in rad_atms if (atm not in res_rad_atms)]
else:
rad_atms = []
gra = gra[0]
for atm in gra:
if (gra[atm][0] == 'H'):
all_hyds.append(atm)
for atm in gra:
if ((atm in unsat_atms) and (atm not in rad_atms)):
pass
elif ((atm not in frm_bnd_key) and (atm not in brk_bnd_key)):
nonh_neighs = []
h_neighs = []
neighs = neighbor_dct[atm]
for nei in neighs:
if (nei in all_hyds):
h_neighs.append(nei)
else:
nonh_neighs.append(nei)
if ((len(nonh_neighs) < 2) and (len(h_neighs) > 1)):
term_atms[atm] = h_neighs
geo_final_lst = [geo]
for atm in term_atms:
hyds = term_atms[atm]
geo_lst = []
for geom in geo_final_lst:
geo_lst.extend(_swap_for_one(geom, hyds))
geo_final_lst = geo_lst
return geo_final_lst
|
convert an input geometry to a list of geometries
corresponding to the rotational permuations of all the terminal groups
|
automol/geom.py
|
rot_permutated_geoms
|
sjklipp/autochem_1219
| 0
|
python
|
def rot_permutated_geoms(geo, saddle=False, frm_bnd_key=[], brk_bnd_key=[], form_coords=[]):
' convert an input geometry to a list of geometries\n corresponding to the rotational permuations of all the terminal groups\n '
gra = graph(geo, remove_stereo=True)
term_atms = {}
all_hyds = []
neighbor_dct = automol.graph.atom_neighbor_keys(gra)
unsat_atms = automol.graph.unsaturated_atom_keys(gra)
if (not saddle):
rad_atms = automol.graph.sing_res_dom_radical_atom_keys(gra)
res_rad_atms = automol.graph.resonance_dominant_radical_atom_keys(gra)
rad_atms = [atm for atm in rad_atms if (atm not in res_rad_atms)]
else:
rad_atms = []
gra = gra[0]
for atm in gra:
if (gra[atm][0] == 'H'):
all_hyds.append(atm)
for atm in gra:
if ((atm in unsat_atms) and (atm not in rad_atms)):
pass
elif ((atm not in frm_bnd_key) and (atm not in brk_bnd_key)):
nonh_neighs = []
h_neighs = []
neighs = neighbor_dct[atm]
for nei in neighs:
if (nei in all_hyds):
h_neighs.append(nei)
else:
nonh_neighs.append(nei)
if ((len(nonh_neighs) < 2) and (len(h_neighs) > 1)):
term_atms[atm] = h_neighs
geo_final_lst = [geo]
for atm in term_atms:
hyds = term_atms[atm]
geo_lst = []
for geom in geo_final_lst:
geo_lst.extend(_swap_for_one(geom, hyds))
geo_final_lst = geo_lst
return geo_final_lst
|
def rot_permutated_geoms(geo, saddle=False, frm_bnd_key=[], brk_bnd_key=[], form_coords=[]):
' convert an input geometry to a list of geometries\n corresponding to the rotational permuations of all the terminal groups\n '
gra = graph(geo, remove_stereo=True)
term_atms = {}
all_hyds = []
neighbor_dct = automol.graph.atom_neighbor_keys(gra)
unsat_atms = automol.graph.unsaturated_atom_keys(gra)
if (not saddle):
rad_atms = automol.graph.sing_res_dom_radical_atom_keys(gra)
res_rad_atms = automol.graph.resonance_dominant_radical_atom_keys(gra)
rad_atms = [atm for atm in rad_atms if (atm not in res_rad_atms)]
else:
rad_atms = []
gra = gra[0]
for atm in gra:
if (gra[atm][0] == 'H'):
all_hyds.append(atm)
for atm in gra:
if ((atm in unsat_atms) and (atm not in rad_atms)):
pass
elif ((atm not in frm_bnd_key) and (atm not in brk_bnd_key)):
nonh_neighs = []
h_neighs = []
neighs = neighbor_dct[atm]
for nei in neighs:
if (nei in all_hyds):
h_neighs.append(nei)
else:
nonh_neighs.append(nei)
if ((len(nonh_neighs) < 2) and (len(h_neighs) > 1)):
term_atms[atm] = h_neighs
geo_final_lst = [geo]
for atm in term_atms:
hyds = term_atms[atm]
geo_lst = []
for geom in geo_final_lst:
geo_lst.extend(_swap_for_one(geom, hyds))
geo_final_lst = geo_lst
return geo_final_lst<|docstring|>convert an input geometry to a list of geometries
corresponding to the rotational permuations of all the terminal groups<|endoftext|>
|
bf67744f42acc52e4298caeb39add0b4e9c3d71804334725a93df1c5b3a8776a
|
def _swap_for_one(geo, hyds):
' rotational permuation for one rotational group\n '
geo_lst = []
if (len(hyds) > 1):
new_geo = geo
if (len(hyds) > 2):
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
new_geo = swap_coordinates(new_geo, hyds[0], hyds[2])
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
new_geo = swap_coordinates(new_geo, hyds[0], hyds[2])
geo_lst.append(new_geo)
else:
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
geo_lst.append(new_geo)
return geo_lst
|
rotational permuation for one rotational group
|
automol/geom.py
|
_swap_for_one
|
sjklipp/autochem_1219
| 0
|
python
|
def _swap_for_one(geo, hyds):
' \n '
geo_lst = []
if (len(hyds) > 1):
new_geo = geo
if (len(hyds) > 2):
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
new_geo = swap_coordinates(new_geo, hyds[0], hyds[2])
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
new_geo = swap_coordinates(new_geo, hyds[0], hyds[2])
geo_lst.append(new_geo)
else:
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
geo_lst.append(new_geo)
return geo_lst
|
def _swap_for_one(geo, hyds):
' \n '
geo_lst = []
if (len(hyds) > 1):
new_geo = geo
if (len(hyds) > 2):
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
new_geo = swap_coordinates(new_geo, hyds[0], hyds[2])
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
new_geo = swap_coordinates(new_geo, hyds[0], hyds[2])
geo_lst.append(new_geo)
else:
geo_lst.append(new_geo)
new_geo = swap_coordinates(new_geo, hyds[0], hyds[1])
geo_lst.append(new_geo)
return geo_lst<|docstring|>rotational permuation for one rotational group<|endoftext|>
|
2d760647d37feba43df9aecc4f9a071452d612a6a3a15a3550c510034badcbac
|
def distance(geo, key1, key2):
' measure the distance between atoms\n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
return cart.vec.distance(xyz1, xyz2)
|
measure the distance between atoms
|
automol/geom.py
|
distance
|
sjklipp/autochem_1219
| 0
|
python
|
def distance(geo, key1, key2):
' \n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
return cart.vec.distance(xyz1, xyz2)
|
def distance(geo, key1, key2):
' \n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
return cart.vec.distance(xyz1, xyz2)<|docstring|>measure the distance between atoms<|endoftext|>
|
8287bc75e4fdcf656053036453ca21f5445aed2b30e6e18f8ac982b3440cae51
|
def central_angle(geo, key1, key2, key3):
' measure the angle inscribed by three atoms\n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
xyz3 = xyzs[key3]
return cart.vec.central_angle(xyz1, xyz2, xyz3)
|
measure the angle inscribed by three atoms
|
automol/geom.py
|
central_angle
|
sjklipp/autochem_1219
| 0
|
python
|
def central_angle(geo, key1, key2, key3):
' \n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
xyz3 = xyzs[key3]
return cart.vec.central_angle(xyz1, xyz2, xyz3)
|
def central_angle(geo, key1, key2, key3):
' \n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
xyz3 = xyzs[key3]
return cart.vec.central_angle(xyz1, xyz2, xyz3)<|docstring|>measure the angle inscribed by three atoms<|endoftext|>
|
38135406e0120a479c39ac6dcf191ec738015c502f05593c0013a2473e41f1c0
|
def dihedral_angle(geo, key1, key2, key3, key4):
' measure the dihedral angle defined by four atoms\n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
xyz3 = xyzs[key3]
xyz4 = xyzs[key4]
return cart.vec.dihedral_angle(xyz1, xyz2, xyz3, xyz4)
|
measure the dihedral angle defined by four atoms
|
automol/geom.py
|
dihedral_angle
|
sjklipp/autochem_1219
| 0
|
python
|
def dihedral_angle(geo, key1, key2, key3, key4):
' \n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
xyz3 = xyzs[key3]
xyz4 = xyzs[key4]
return cart.vec.dihedral_angle(xyz1, xyz2, xyz3, xyz4)
|
def dihedral_angle(geo, key1, key2, key3, key4):
' \n '
xyzs = coordinates(geo)
xyz1 = xyzs[key1]
xyz2 = xyzs[key2]
xyz3 = xyzs[key3]
xyz4 = xyzs[key4]
return cart.vec.dihedral_angle(xyz1, xyz2, xyz3, xyz4)<|docstring|>measure the dihedral angle defined by four atoms<|endoftext|>
|
474b476a250ac070cb63c8b25b312650112c7e575149ef864e5a3bdd29183980
|
def dist_mat(geo):
'form distance matrix for a set of xyz coordinates\n '
mat = numpy.zeros((len(geo), len(geo)))
for i in range(len(geo)):
for j in range(len(geo)):
mat[i][j] = distance(geo, i, j)
return mat
|
form distance matrix for a set of xyz coordinates
|
automol/geom.py
|
dist_mat
|
sjklipp/autochem_1219
| 0
|
python
|
def dist_mat(geo):
'\n '
mat = numpy.zeros((len(geo), len(geo)))
for i in range(len(geo)):
for j in range(len(geo)):
mat[i][j] = distance(geo, i, j)
return mat
|
def dist_mat(geo):
'\n '
mat = numpy.zeros((len(geo), len(geo)))
for i in range(len(geo)):
for j in range(len(geo)):
mat[i][j] = distance(geo, i, j)
return mat<|docstring|>form distance matrix for a set of xyz coordinates<|endoftext|>
|
ffe525307f46492f23caffe484ee49200a9c6c4719e64c5080b031028d05e4be
|
def almost_equal_dist_mat(geo1, geo2, thresh=0.1):
'form distance matrix for a set of xyz coordinates\n '
dist_mat1 = dist_mat(geo1)
dist_mat2 = dist_mat(geo2)
diff_mat = numpy.zeros((len(geo1), len(geo2)))
almost_equal_dm = True
for (i, _) in enumerate(dist_mat1):
for (j, _) in enumerate(dist_mat1):
diff_mat[i][j] = abs((dist_mat1[i][j] - dist_mat2[i][j]))
if (numpy.amax(diff_mat) > thresh):
almost_equal_dm = False
return almost_equal_dm
|
form distance matrix for a set of xyz coordinates
|
automol/geom.py
|
almost_equal_dist_mat
|
sjklipp/autochem_1219
| 0
|
python
|
def almost_equal_dist_mat(geo1, geo2, thresh=0.1):
'\n '
dist_mat1 = dist_mat(geo1)
dist_mat2 = dist_mat(geo2)
diff_mat = numpy.zeros((len(geo1), len(geo2)))
almost_equal_dm = True
for (i, _) in enumerate(dist_mat1):
for (j, _) in enumerate(dist_mat1):
diff_mat[i][j] = abs((dist_mat1[i][j] - dist_mat2[i][j]))
if (numpy.amax(diff_mat) > thresh):
almost_equal_dm = False
return almost_equal_dm
|
def almost_equal_dist_mat(geo1, geo2, thresh=0.1):
'\n '
dist_mat1 = dist_mat(geo1)
dist_mat2 = dist_mat(geo2)
diff_mat = numpy.zeros((len(geo1), len(geo2)))
almost_equal_dm = True
for (i, _) in enumerate(dist_mat1):
for (j, _) in enumerate(dist_mat1):
diff_mat[i][j] = abs((dist_mat1[i][j] - dist_mat2[i][j]))
if (numpy.amax(diff_mat) > thresh):
almost_equal_dm = False
return almost_equal_dm<|docstring|>form distance matrix for a set of xyz coordinates<|endoftext|>
|
821a4d0cf75a62b7f86c5d196324363b9ba3f2d3c75824e88b06bd577e86b23a
|
def external_symmetry_factor(geo):
' obtain external symmetry factor for a geometry using x2z\n '
if automol.geom.is_atom(geo):
ext_sym_fac = 1.0
else:
oriented_geom = to_oriented_geometry(geo)
ext_sym_fac = oriented_geom.sym_num()
if oriented_geom.is_enantiomer():
ext_sym_fac *= 0.5
return ext_sym_fac
|
obtain external symmetry factor for a geometry using x2z
|
automol/geom.py
|
external_symmetry_factor
|
sjklipp/autochem_1219
| 0
|
python
|
def external_symmetry_factor(geo):
' \n '
if automol.geom.is_atom(geo):
ext_sym_fac = 1.0
else:
oriented_geom = to_oriented_geometry(geo)
ext_sym_fac = oriented_geom.sym_num()
if oriented_geom.is_enantiomer():
ext_sym_fac *= 0.5
return ext_sym_fac
|
def external_symmetry_factor(geo):
' \n '
if automol.geom.is_atom(geo):
ext_sym_fac = 1.0
else:
oriented_geom = to_oriented_geometry(geo)
ext_sym_fac = oriented_geom.sym_num()
if oriented_geom.is_enantiomer():
ext_sym_fac *= 0.5
return ext_sym_fac<|docstring|>obtain external symmetry factor for a geometry using x2z<|endoftext|>
|
80b0ea28db1d1bcf8a593e89931e9159faaa381adeebfc0e0e24bdc3d59a558a
|
def find_xyzp_using_internals(xyz1, xyz2, xyz3, pdist, pangle, pdihed):
' geometric approach for calculating the xyz coordinates of atom A\n when the xyz coordinates of the A B and C are known and\n the position is defined w/r to A B C with internal coordinates\n '
xyz1 = numpy.array(xyz1)
xyz2 = numpy.array(xyz2)
xyz3 = numpy.array(xyz3)
xyzp_rt = numpy.array([((pdist * numpy.sin(pangle)) * numpy.cos(pdihed)), (pdist * numpy.cos(pangle)), (- ((pdist * numpy.sin(pangle)) * numpy.sin(pdihed)))])
dist12 = numpy.linalg.norm((xyz1 - xyz2))
dist13 = numpy.linalg.norm((xyz1 - xyz3))
dist23 = numpy.linalg.norm((xyz2 - xyz3))
xyz2_rt = numpy.array([0.0, dist12, 0.0])
val = (((((dist12 ** 2) + (dist13 ** 2)) - (dist23 ** 2)) / 2.0) / dist12)
valx3 = numpy.sqrt(((dist13 ** 2) - (val ** 2)))
valy3 = (((((dist12 ** 2) + (dist13 ** 2)) - (dist23 ** 2)) / 2.0) / dist12)
xyz3_rt = numpy.array([valx3, valy3, 0.0])
xyz2_t = (xyz2 - xyz1)
xyz3_t = (xyz3 - xyz1)
r12 = ((xyz2[0] - xyz1[0]) / xyz2_rt[1])
r22 = ((xyz2[1] - xyz1[1]) / xyz2_rt[1])
r32 = ((xyz2[2] - xyz1[2]) / xyz2_rt[1])
r11 = (((xyz3[0] - xyz1[0]) - (xyz3_rt[1] * r12)) / xyz3_rt[0])
r21 = (((xyz3[1] - xyz1[1]) - (xyz3_rt[1] * r22)) / xyz3_rt[0])
r31 = (((xyz3[2] - xyz1[2]) - (xyz3_rt[1] * r32)) / xyz3_rt[0])
anum_aconst = (xyz2_t[1] - ((xyz3_t[1] / xyz3_t[0]) * xyz2_t[0]))
den_aconst = (xyz2_t[2] - ((xyz3_t[2] / xyz3_t[0]) * xyz2_t[0]))
if ((abs(anum_aconst) < 1e-06) and (abs(den_aconst) < 1e-06)):
if (anum_aconst < 0.0):
aconst = (- 1e+20)
else:
aconst = 1e+20
elif (abs(den_aconst) < 1e-06):
if (anum_aconst < 0.0):
aconst = (- 1e+20)
else:
aconst = 1e+20
else:
print('xyz3')
print(xyz3_t)
anum = (xyz2_t[1] - ((xyz3_t[1] / xyz3_t[0]) * xyz2_t[0]))
aden = (xyz2_t[2] - ((xyz3_t[2] / xyz3_t[0]) * xyz2_t[0]))
aconst = (anum / aden)
den1 = ((xyz3_t[1] / xyz3_t[0]) - (aconst * (xyz3_t[2] / xyz3_t[0])))
if (den1 == 0.0):
den1 = 1e-20
bconst = (1.0 / den1)
valx = (- (1.0 / numpy.sqrt((1.0 + ((bconst ** 2) * (1.0 + (aconst ** 2)))))))
valy = (- (valx * bconst))
xyz4_t = numpy.array([valx, valy, (- (valy * aconst))])
r13 = xyz4_t[0]
r23 = xyz4_t[1]
r33 = xyz4_t[2]
r13n = (- r13)
r23n = (- r23)
r33n = (- r33)
xap = (((xyz1[0] + (r11 * xyzp_rt[0])) + (r12 * xyzp_rt[1])) + (r13 * xyzp_rt[2]))
yap = (((xyz1[1] + (r21 * xyzp_rt[0])) + (r22 * xyzp_rt[1])) + (r33 * xyzp_rt[2]))
zap = (((xyz1[2] + (r31 * xyzp_rt[0])) + (r32 * xyzp_rt[1])) + (r33 * xyzp_rt[2]))
xan = (((xyz1[0] + (r11 * xyzp_rt[0])) + (r12 * xyzp_rt[1])) + (r13n * xyzp_rt[2]))
yan = (((xyz1[1] + (r21 * xyzp_rt[0])) + (r22 * xyzp_rt[1])) + (r23n * xyzp_rt[2]))
zan = (((xyz1[2] + (r31 * xyzp_rt[0])) + (r32 * xyzp_rt[1])) + (r33n * xyzp_rt[2]))
bvec = (xyz1 - xyz2)
cvec = (xyz2 - xyz3)
vec1 = ((bvec[1] * cvec[2]) - (bvec[2] * cvec[1]))
vec2 = ((bvec[2] * cvec[0]) - (bvec[0] * cvec[2]))
vec3 = ((bvec[0] * cvec[1]) - (bvec[1] * cvec[0]))
if (abs(xyz4_t[0]) > 1e-05):
checkv = (vec1 / xyz4_t[0])
elif (abs(xyz4_t[1]) > 1e-05):
checkv = (vec2 / xyz4_t[1])
else:
checkv = (vec3 / xyz4_t[2])
if (checkv >= 0.0):
xyzp = numpy.array([xap, yap, zap])
else:
xyzp = numpy.array([xan, yan, zan])
return (xyzp[0], xyzp[1], xyzp[2])
|
geometric approach for calculating the xyz coordinates of atom A
when the xyz coordinates of the A B and C are known and
the position is defined w/r to A B C with internal coordinates
|
automol/geom.py
|
find_xyzp_using_internals
|
sjklipp/autochem_1219
| 0
|
python
|
def find_xyzp_using_internals(xyz1, xyz2, xyz3, pdist, pangle, pdihed):
' geometric approach for calculating the xyz coordinates of atom A\n when the xyz coordinates of the A B and C are known and\n the position is defined w/r to A B C with internal coordinates\n '
xyz1 = numpy.array(xyz1)
xyz2 = numpy.array(xyz2)
xyz3 = numpy.array(xyz3)
xyzp_rt = numpy.array([((pdist * numpy.sin(pangle)) * numpy.cos(pdihed)), (pdist * numpy.cos(pangle)), (- ((pdist * numpy.sin(pangle)) * numpy.sin(pdihed)))])
dist12 = numpy.linalg.norm((xyz1 - xyz2))
dist13 = numpy.linalg.norm((xyz1 - xyz3))
dist23 = numpy.linalg.norm((xyz2 - xyz3))
xyz2_rt = numpy.array([0.0, dist12, 0.0])
val = (((((dist12 ** 2) + (dist13 ** 2)) - (dist23 ** 2)) / 2.0) / dist12)
valx3 = numpy.sqrt(((dist13 ** 2) - (val ** 2)))
valy3 = (((((dist12 ** 2) + (dist13 ** 2)) - (dist23 ** 2)) / 2.0) / dist12)
xyz3_rt = numpy.array([valx3, valy3, 0.0])
xyz2_t = (xyz2 - xyz1)
xyz3_t = (xyz3 - xyz1)
r12 = ((xyz2[0] - xyz1[0]) / xyz2_rt[1])
r22 = ((xyz2[1] - xyz1[1]) / xyz2_rt[1])
r32 = ((xyz2[2] - xyz1[2]) / xyz2_rt[1])
r11 = (((xyz3[0] - xyz1[0]) - (xyz3_rt[1] * r12)) / xyz3_rt[0])
r21 = (((xyz3[1] - xyz1[1]) - (xyz3_rt[1] * r22)) / xyz3_rt[0])
r31 = (((xyz3[2] - xyz1[2]) - (xyz3_rt[1] * r32)) / xyz3_rt[0])
anum_aconst = (xyz2_t[1] - ((xyz3_t[1] / xyz3_t[0]) * xyz2_t[0]))
den_aconst = (xyz2_t[2] - ((xyz3_t[2] / xyz3_t[0]) * xyz2_t[0]))
if ((abs(anum_aconst) < 1e-06) and (abs(den_aconst) < 1e-06)):
if (anum_aconst < 0.0):
aconst = (- 1e+20)
else:
aconst = 1e+20
elif (abs(den_aconst) < 1e-06):
if (anum_aconst < 0.0):
aconst = (- 1e+20)
else:
aconst = 1e+20
else:
print('xyz3')
print(xyz3_t)
anum = (xyz2_t[1] - ((xyz3_t[1] / xyz3_t[0]) * xyz2_t[0]))
aden = (xyz2_t[2] - ((xyz3_t[2] / xyz3_t[0]) * xyz2_t[0]))
aconst = (anum / aden)
den1 = ((xyz3_t[1] / xyz3_t[0]) - (aconst * (xyz3_t[2] / xyz3_t[0])))
if (den1 == 0.0):
den1 = 1e-20
bconst = (1.0 / den1)
valx = (- (1.0 / numpy.sqrt((1.0 + ((bconst ** 2) * (1.0 + (aconst ** 2)))))))
valy = (- (valx * bconst))
xyz4_t = numpy.array([valx, valy, (- (valy * aconst))])
r13 = xyz4_t[0]
r23 = xyz4_t[1]
r33 = xyz4_t[2]
r13n = (- r13)
r23n = (- r23)
r33n = (- r33)
xap = (((xyz1[0] + (r11 * xyzp_rt[0])) + (r12 * xyzp_rt[1])) + (r13 * xyzp_rt[2]))
yap = (((xyz1[1] + (r21 * xyzp_rt[0])) + (r22 * xyzp_rt[1])) + (r33 * xyzp_rt[2]))
zap = (((xyz1[2] + (r31 * xyzp_rt[0])) + (r32 * xyzp_rt[1])) + (r33 * xyzp_rt[2]))
xan = (((xyz1[0] + (r11 * xyzp_rt[0])) + (r12 * xyzp_rt[1])) + (r13n * xyzp_rt[2]))
yan = (((xyz1[1] + (r21 * xyzp_rt[0])) + (r22 * xyzp_rt[1])) + (r23n * xyzp_rt[2]))
zan = (((xyz1[2] + (r31 * xyzp_rt[0])) + (r32 * xyzp_rt[1])) + (r33n * xyzp_rt[2]))
bvec = (xyz1 - xyz2)
cvec = (xyz2 - xyz3)
vec1 = ((bvec[1] * cvec[2]) - (bvec[2] * cvec[1]))
vec2 = ((bvec[2] * cvec[0]) - (bvec[0] * cvec[2]))
vec3 = ((bvec[0] * cvec[1]) - (bvec[1] * cvec[0]))
if (abs(xyz4_t[0]) > 1e-05):
checkv = (vec1 / xyz4_t[0])
elif (abs(xyz4_t[1]) > 1e-05):
checkv = (vec2 / xyz4_t[1])
else:
checkv = (vec3 / xyz4_t[2])
if (checkv >= 0.0):
xyzp = numpy.array([xap, yap, zap])
else:
xyzp = numpy.array([xan, yan, zan])
return (xyzp[0], xyzp[1], xyzp[2])
|
def find_xyzp_using_internals(xyz1, xyz2, xyz3, pdist, pangle, pdihed):
' geometric approach for calculating the xyz coordinates of atom A\n when the xyz coordinates of the A B and C are known and\n the position is defined w/r to A B C with internal coordinates\n '
xyz1 = numpy.array(xyz1)
xyz2 = numpy.array(xyz2)
xyz3 = numpy.array(xyz3)
xyzp_rt = numpy.array([((pdist * numpy.sin(pangle)) * numpy.cos(pdihed)), (pdist * numpy.cos(pangle)), (- ((pdist * numpy.sin(pangle)) * numpy.sin(pdihed)))])
dist12 = numpy.linalg.norm((xyz1 - xyz2))
dist13 = numpy.linalg.norm((xyz1 - xyz3))
dist23 = numpy.linalg.norm((xyz2 - xyz3))
xyz2_rt = numpy.array([0.0, dist12, 0.0])
val = (((((dist12 ** 2) + (dist13 ** 2)) - (dist23 ** 2)) / 2.0) / dist12)
valx3 = numpy.sqrt(((dist13 ** 2) - (val ** 2)))
valy3 = (((((dist12 ** 2) + (dist13 ** 2)) - (dist23 ** 2)) / 2.0) / dist12)
xyz3_rt = numpy.array([valx3, valy3, 0.0])
xyz2_t = (xyz2 - xyz1)
xyz3_t = (xyz3 - xyz1)
r12 = ((xyz2[0] - xyz1[0]) / xyz2_rt[1])
r22 = ((xyz2[1] - xyz1[1]) / xyz2_rt[1])
r32 = ((xyz2[2] - xyz1[2]) / xyz2_rt[1])
r11 = (((xyz3[0] - xyz1[0]) - (xyz3_rt[1] * r12)) / xyz3_rt[0])
r21 = (((xyz3[1] - xyz1[1]) - (xyz3_rt[1] * r22)) / xyz3_rt[0])
r31 = (((xyz3[2] - xyz1[2]) - (xyz3_rt[1] * r32)) / xyz3_rt[0])
anum_aconst = (xyz2_t[1] - ((xyz3_t[1] / xyz3_t[0]) * xyz2_t[0]))
den_aconst = (xyz2_t[2] - ((xyz3_t[2] / xyz3_t[0]) * xyz2_t[0]))
if ((abs(anum_aconst) < 1e-06) and (abs(den_aconst) < 1e-06)):
if (anum_aconst < 0.0):
aconst = (- 1e+20)
else:
aconst = 1e+20
elif (abs(den_aconst) < 1e-06):
if (anum_aconst < 0.0):
aconst = (- 1e+20)
else:
aconst = 1e+20
else:
print('xyz3')
print(xyz3_t)
anum = (xyz2_t[1] - ((xyz3_t[1] / xyz3_t[0]) * xyz2_t[0]))
aden = (xyz2_t[2] - ((xyz3_t[2] / xyz3_t[0]) * xyz2_t[0]))
aconst = (anum / aden)
den1 = ((xyz3_t[1] / xyz3_t[0]) - (aconst * (xyz3_t[2] / xyz3_t[0])))
if (den1 == 0.0):
den1 = 1e-20
bconst = (1.0 / den1)
valx = (- (1.0 / numpy.sqrt((1.0 + ((bconst ** 2) * (1.0 + (aconst ** 2)))))))
valy = (- (valx * bconst))
xyz4_t = numpy.array([valx, valy, (- (valy * aconst))])
r13 = xyz4_t[0]
r23 = xyz4_t[1]
r33 = xyz4_t[2]
r13n = (- r13)
r23n = (- r23)
r33n = (- r33)
xap = (((xyz1[0] + (r11 * xyzp_rt[0])) + (r12 * xyzp_rt[1])) + (r13 * xyzp_rt[2]))
yap = (((xyz1[1] + (r21 * xyzp_rt[0])) + (r22 * xyzp_rt[1])) + (r33 * xyzp_rt[2]))
zap = (((xyz1[2] + (r31 * xyzp_rt[0])) + (r32 * xyzp_rt[1])) + (r33 * xyzp_rt[2]))
xan = (((xyz1[0] + (r11 * xyzp_rt[0])) + (r12 * xyzp_rt[1])) + (r13n * xyzp_rt[2]))
yan = (((xyz1[1] + (r21 * xyzp_rt[0])) + (r22 * xyzp_rt[1])) + (r23n * xyzp_rt[2]))
zan = (((xyz1[2] + (r31 * xyzp_rt[0])) + (r32 * xyzp_rt[1])) + (r33n * xyzp_rt[2]))
bvec = (xyz1 - xyz2)
cvec = (xyz2 - xyz3)
vec1 = ((bvec[1] * cvec[2]) - (bvec[2] * cvec[1]))
vec2 = ((bvec[2] * cvec[0]) - (bvec[0] * cvec[2]))
vec3 = ((bvec[0] * cvec[1]) - (bvec[1] * cvec[0]))
if (abs(xyz4_t[0]) > 1e-05):
checkv = (vec1 / xyz4_t[0])
elif (abs(xyz4_t[1]) > 1e-05):
checkv = (vec2 / xyz4_t[1])
else:
checkv = (vec3 / xyz4_t[2])
if (checkv >= 0.0):
xyzp = numpy.array([xap, yap, zap])
else:
xyzp = numpy.array([xan, yan, zan])
return (xyzp[0], xyzp[1], xyzp[2])<|docstring|>geometric approach for calculating the xyz coordinates of atom A
when the xyz coordinates of the A B and C are known and
the position is defined w/r to A B C with internal coordinates<|endoftext|>
|
ec24ea747161e01ac5cfc157356c7898a01e9696e045aec32311f8d2db8849e7
|
def is_atom(geo):
' return return the atomic masses\n '
syms = symbols(geo)
ret = False
if (len(syms) == 1):
ret = True
return ret
|
return return the atomic masses
|
automol/geom.py
|
is_atom
|
sjklipp/autochem_1219
| 0
|
python
|
def is_atom(geo):
' \n '
syms = symbols(geo)
ret = False
if (len(syms) == 1):
ret = True
return ret
|
def is_atom(geo):
' \n '
syms = symbols(geo)
ret = False
if (len(syms) == 1):
ret = True
return ret<|docstring|>return return the atomic masses<|endoftext|>
|
296d7ee35116f415f7a107d3557c1aeba63b3438e32d9b108469509de26d05df
|
def masses(geo, amu=True):
' return the atomic masses\n '
syms = symbols(geo)
amas = list(map(pt.to_mass, syms))
if (not amu):
conv = qcc.conversion_factor('atomic_mass_unit', 'electron_mass')
amas = numpy.multiply(amas, conv)
amas = tuple(amas)
return amas
|
return the atomic masses
|
automol/geom.py
|
masses
|
sjklipp/autochem_1219
| 0
|
python
|
def masses(geo, amu=True):
' \n '
syms = symbols(geo)
amas = list(map(pt.to_mass, syms))
if (not amu):
conv = qcc.conversion_factor('atomic_mass_unit', 'electron_mass')
amas = numpy.multiply(amas, conv)
amas = tuple(amas)
return amas
|
def masses(geo, amu=True):
' \n '
syms = symbols(geo)
amas = list(map(pt.to_mass, syms))
if (not amu):
conv = qcc.conversion_factor('atomic_mass_unit', 'electron_mass')
amas = numpy.multiply(amas, conv)
amas = tuple(amas)
return amas<|docstring|>return the atomic masses<|endoftext|>
|
943c01e5508f54e3ae52280ee4d0ff3ec8f465b4b2fcd4e1e38ce89be0124d89
|
def center_of_mass(geo):
' center of mass\n '
xyzs = coordinates(geo)
amas = masses(geo)
cm_xyz = tuple((sum((numpy.multiply(xyz, ama) for (xyz, ama) in zip(xyzs, amas))) / sum(amas)))
return cm_xyz
|
center of mass
|
automol/geom.py
|
center_of_mass
|
sjklipp/autochem_1219
| 0
|
python
|
def center_of_mass(geo):
' \n '
xyzs = coordinates(geo)
amas = masses(geo)
cm_xyz = tuple((sum((numpy.multiply(xyz, ama) for (xyz, ama) in zip(xyzs, amas))) / sum(amas)))
return cm_xyz
|
def center_of_mass(geo):
' \n '
xyzs = coordinates(geo)
amas = masses(geo)
cm_xyz = tuple((sum((numpy.multiply(xyz, ama) for (xyz, ama) in zip(xyzs, amas))) / sum(amas)))
return cm_xyz<|docstring|>center of mass<|endoftext|>
|
70fea196286a42eae022d7baf6cab28c91a4ea3446d2717de54726be3acff2c4
|
def mass_centered(geo):
' mass-centered geometry\n '
geo = translated(geo, numpy.negative(center_of_mass(geo)))
return geo
|
mass-centered geometry
|
automol/geom.py
|
mass_centered
|
sjklipp/autochem_1219
| 0
|
python
|
def mass_centered(geo):
' \n '
geo = translated(geo, numpy.negative(center_of_mass(geo)))
return geo
|
def mass_centered(geo):
' \n '
geo = translated(geo, numpy.negative(center_of_mass(geo)))
return geo<|docstring|>mass-centered geometry<|endoftext|>
|
0d7dae8b8c6280b4f3a4f43e130c0ad0fef8f758f660baea7a6d1e3b1bf47594
|
def inertia_tensor(geo, amu=True):
' molecula# r inertia tensor (atomic units if amu=False)\n '
geo = mass_centered(geo)
amas = masses(geo, amu=amu)
xyzs = coordinates(geo)
ine = tuple(map(tuple, sum(((ama * ((numpy.vdot(xyz, xyz) * numpy.eye(3)) - numpy.outer(xyz, xyz))) for (ama, xyz) in zip(amas, xyzs)))))
return ine
|
molecula# r inertia tensor (atomic units if amu=False)
|
automol/geom.py
|
inertia_tensor
|
sjklipp/autochem_1219
| 0
|
python
|
def inertia_tensor(geo, amu=True):
' \n '
geo = mass_centered(geo)
amas = masses(geo, amu=amu)
xyzs = coordinates(geo)
ine = tuple(map(tuple, sum(((ama * ((numpy.vdot(xyz, xyz) * numpy.eye(3)) - numpy.outer(xyz, xyz))) for (ama, xyz) in zip(amas, xyzs)))))
return ine
|
def inertia_tensor(geo, amu=True):
' \n '
geo = mass_centered(geo)
amas = masses(geo, amu=amu)
xyzs = coordinates(geo)
ine = tuple(map(tuple, sum(((ama * ((numpy.vdot(xyz, xyz) * numpy.eye(3)) - numpy.outer(xyz, xyz))) for (ama, xyz) in zip(amas, xyzs)))))
return ine<|docstring|>molecula# r inertia tensor (atomic units if amu=False)<|endoftext|>
|
661d59ee9dabf3bf01a42817b09d485aaabee315a57c6e141468d2f2f1a5055f
|
def principal_axes(geo, amu=True):
' principal inertial axes (atomic units if amu=False)\n '
ine = inertia_tensor(geo, amu=amu)
(_, paxs) = numpy.linalg.eigh(ine)
paxs = tuple(map(tuple, paxs))
return paxs
|
principal inertial axes (atomic units if amu=False)
|
automol/geom.py
|
principal_axes
|
sjklipp/autochem_1219
| 0
|
python
|
def principal_axes(geo, amu=True):
' \n '
ine = inertia_tensor(geo, amu=amu)
(_, paxs) = numpy.linalg.eigh(ine)
paxs = tuple(map(tuple, paxs))
return paxs
|
def principal_axes(geo, amu=True):
' \n '
ine = inertia_tensor(geo, amu=amu)
(_, paxs) = numpy.linalg.eigh(ine)
paxs = tuple(map(tuple, paxs))
return paxs<|docstring|>principal inertial axes (atomic units if amu=False)<|endoftext|>
|
be7a87523a8eb65b3863a431b4617d2ad352e189123eaac2460be27040106fac
|
def moments_of_inertia(geo, amu=True):
' principal inertial axes (atomic units if amu=False)\n '
ine = inertia_tensor(geo, amu=amu)
(moms, _) = numpy.linalg.eigh(ine)
moms = tuple(moms)
return moms
|
principal inertial axes (atomic units if amu=False)
|
automol/geom.py
|
moments_of_inertia
|
sjklipp/autochem_1219
| 0
|
python
|
def moments_of_inertia(geo, amu=True):
' \n '
ine = inertia_tensor(geo, amu=amu)
(moms, _) = numpy.linalg.eigh(ine)
moms = tuple(moms)
return moms
|
def moments_of_inertia(geo, amu=True):
' \n '
ine = inertia_tensor(geo, amu=amu)
(moms, _) = numpy.linalg.eigh(ine)
moms = tuple(moms)
return moms<|docstring|>principal inertial axes (atomic units if amu=False)<|endoftext|>
|
2ad184a3b468b195896a1305fcf0615ee4462af11fbd32807bf269265004df1e
|
def rotational_constants(geo, amu=True):
' rotational constants (atomic units if amu=False)\n '
moms = moments_of_inertia(geo, amu=amu)
sol = (qcc.get('speed of light in vacuum') * qcc.conversion_factor('meter / second', 'bohr hartree / h'))
cons = (((numpy.divide(1.0, moms) / 4.0) / numpy.pi) / sol)
cons = tuple(cons)
return cons
|
rotational constants (atomic units if amu=False)
|
automol/geom.py
|
rotational_constants
|
sjklipp/autochem_1219
| 0
|
python
|
def rotational_constants(geo, amu=True):
' \n '
moms = moments_of_inertia(geo, amu=amu)
sol = (qcc.get('speed of light in vacuum') * qcc.conversion_factor('meter / second', 'bohr hartree / h'))
cons = (((numpy.divide(1.0, moms) / 4.0) / numpy.pi) / sol)
cons = tuple(cons)
return cons
|
def rotational_constants(geo, amu=True):
' \n '
moms = moments_of_inertia(geo, amu=amu)
sol = (qcc.get('speed of light in vacuum') * qcc.conversion_factor('meter / second', 'bohr hartree / h'))
cons = (((numpy.divide(1.0, moms) / 4.0) / numpy.pi) / sol)
cons = tuple(cons)
return cons<|docstring|>rotational constants (atomic units if amu=False)<|endoftext|>
|
7595ad63461c15f7e38c79df9bd1b255723fcc5d6eff65bced810643a5ff3930
|
def is_linear(geo, tol=(2.0 * qcc.conversion_factor('degree', 'radian'))):
' is this geometry linear?\n '
ret = True
if (len(geo) == 1):
ret = False
elif (len(geo) == 2):
ret = True
else:
keys = range(len(symbols(geo)))
for (key1, key2, key3) in mit.windowed(keys, 3):
cangle = numpy.abs(central_angle(geo, key1, key2, key3))
if ((cangle % numpy.pi) > tol):
ret = False
return ret
|
is this geometry linear?
|
automol/geom.py
|
is_linear
|
sjklipp/autochem_1219
| 0
|
python
|
def is_linear(geo, tol=(2.0 * qcc.conversion_factor('degree', 'radian'))):
' \n '
ret = True
if (len(geo) == 1):
ret = False
elif (len(geo) == 2):
ret = True
else:
keys = range(len(symbols(geo)))
for (key1, key2, key3) in mit.windowed(keys, 3):
cangle = numpy.abs(central_angle(geo, key1, key2, key3))
if ((cangle % numpy.pi) > tol):
ret = False
return ret
|
def is_linear(geo, tol=(2.0 * qcc.conversion_factor('degree', 'radian'))):
' \n '
ret = True
if (len(geo) == 1):
ret = False
elif (len(geo) == 2):
ret = True
else:
keys = range(len(symbols(geo)))
for (key1, key2, key3) in mit.windowed(keys, 3):
cangle = numpy.abs(central_angle(geo, key1, key2, key3))
if ((cangle % numpy.pi) > tol):
ret = False
return ret<|docstring|>is this geometry linear?<|endoftext|>
|
b784ade483bdec84dacb883ba12546344f6efd050e2e48812fbc69146f056d08
|
def zmatrix(geo):
' geometry => z-matrix\n '
return automol.convert.geom.zmatrix(geo)
|
geometry => z-matrix
|
automol/geom.py
|
zmatrix
|
sjklipp/autochem_1219
| 0
|
python
|
def zmatrix(geo):
' \n '
return automol.convert.geom.zmatrix(geo)
|
def zmatrix(geo):
' \n '
return automol.convert.geom.zmatrix(geo)<|docstring|>geometry => z-matrix<|endoftext|>
|
ec39f2592537ea2711c0333ae084c0233906ac09e39a66a881b1abc5645d5828
|
def zmatrix_torsion_coordinate_names(geo):
' z-matrix torsional coordinate names\n '
return automol.convert.geom.zmatrix_torsion_coordinate_names(geo)
|
z-matrix torsional coordinate names
|
automol/geom.py
|
zmatrix_torsion_coordinate_names
|
sjklipp/autochem_1219
| 0
|
python
|
def zmatrix_torsion_coordinate_names(geo):
' \n '
return automol.convert.geom.zmatrix_torsion_coordinate_names(geo)
|
def zmatrix_torsion_coordinate_names(geo):
' \n '
return automol.convert.geom.zmatrix_torsion_coordinate_names(geo)<|docstring|>z-matrix torsional coordinate names<|endoftext|>
|
4cd6eadeab669a5ccb7d0b3b4ad63567c39a36d9c9190d192b5d65899d4e708d
|
def zmatrix_atom_ordering(geo):
' z-matrix atom ordering\n '
return automol.convert.geom.zmatrix_atom_ordering(geo)
|
z-matrix atom ordering
|
automol/geom.py
|
zmatrix_atom_ordering
|
sjklipp/autochem_1219
| 0
|
python
|
def zmatrix_atom_ordering(geo):
' \n '
return automol.convert.geom.zmatrix_atom_ordering(geo)
|
def zmatrix_atom_ordering(geo):
' \n '
return automol.convert.geom.zmatrix_atom_ordering(geo)<|docstring|>z-matrix atom ordering<|endoftext|>
|
732bd7d47180269c25c9a6cea50d8c089ec6a81a47ed04362461b827f536b0f8
|
def graph(geo, remove_stereo=False):
' geometry => graph\n '
return automol.convert.geom.graph(geo, remove_stereo=remove_stereo)
|
geometry => graph
|
automol/geom.py
|
graph
|
sjklipp/autochem_1219
| 0
|
python
|
def graph(geo, remove_stereo=False):
' \n '
return automol.convert.geom.graph(geo, remove_stereo=remove_stereo)
|
def graph(geo, remove_stereo=False):
' \n '
return automol.convert.geom.graph(geo, remove_stereo=remove_stereo)<|docstring|>geometry => graph<|endoftext|>
|
9f995566a5b719ffbbb95269f2d37c8889d470fc61a280a8a085e0a77bda9841
|
def weakly_connected_graph(geo, remove_stereo=False):
' geometry => graph\n '
return automol.convert.geom.weakly_connected_graph(geo, remove_stereo=remove_stereo)
|
geometry => graph
|
automol/geom.py
|
weakly_connected_graph
|
sjklipp/autochem_1219
| 0
|
python
|
def weakly_connected_graph(geo, remove_stereo=False):
' \n '
return automol.convert.geom.weakly_connected_graph(geo, remove_stereo=remove_stereo)
|
def weakly_connected_graph(geo, remove_stereo=False):
' \n '
return automol.convert.geom.weakly_connected_graph(geo, remove_stereo=remove_stereo)<|docstring|>geometry => graph<|endoftext|>
|
cc52f4144777faee6963e7bfded3ff075e3f2e19c200a38a223ce7bfcbeb5b06
|
def inchi(geo, remove_stereo=False):
' geometry => inchi\n '
return automol.convert.geom.inchi(geo, remove_stereo=remove_stereo)
|
geometry => inchi
|
automol/geom.py
|
inchi
|
sjklipp/autochem_1219
| 0
|
python
|
def inchi(geo, remove_stereo=False):
' \n '
return automol.convert.geom.inchi(geo, remove_stereo=remove_stereo)
|
def inchi(geo, remove_stereo=False):
' \n '
return automol.convert.geom.inchi(geo, remove_stereo=remove_stereo)<|docstring|>geometry => inchi<|endoftext|>
|
032ade647b924ead3d9a8e9e57d939413035825c6825413acd43f576700a2bcc
|
def smiles(geo, remove_stereo=False):
' geometry => inchi\n '
ich = inchi(geo, remove_stereo=remove_stereo)
return automol.convert.inchi.smiles(ich)
|
geometry => inchi
|
automol/geom.py
|
smiles
|
sjklipp/autochem_1219
| 0
|
python
|
def smiles(geo, remove_stereo=False):
' \n '
ich = inchi(geo, remove_stereo=remove_stereo)
return automol.convert.inchi.smiles(ich)
|
def smiles(geo, remove_stereo=False):
' \n '
ich = inchi(geo, remove_stereo=remove_stereo)
return automol.convert.inchi.smiles(ich)<|docstring|>geometry => inchi<|endoftext|>
|
575717773039d1674858d6724cd4656c9cc266b7d5ceea5e0afd831ce87de28f
|
def formula(geo):
' geometry => formula\n '
return automol.convert.geom.formula(geo)
|
geometry => formula
|
automol/geom.py
|
formula
|
sjklipp/autochem_1219
| 0
|
python
|
def formula(geo):
' \n '
return automol.convert.geom.formula(geo)
|
def formula(geo):
' \n '
return automol.convert.geom.formula(geo)<|docstring|>geometry => formula<|endoftext|>
|
8aad2a83e7cf06a9ab3d9de19c55dba6b7a4f39d73744eaf64af5db2a4e62d45
|
@subscriber(ResourceChanged, for_resources=('group',), for_actions=(ACTIONS.DELETE,))
def on_groups_deleted(event):
'Some groups were deleted, remove them from users principals.\n '
permission_backend = event.request.registry.permission
for change in event.impacted_records:
group = change['old']
bucket_id = event.payload['bucket_id']
group_uri = utils.instance_uri(event.request, 'group', bucket_id=bucket_id, id=group['id'])
permission_backend.remove_principal(group_uri)
|
Some groups were deleted, remove them from users principals.
|
kinto/views/groups.py
|
on_groups_deleted
|
peterdemin/kinto
| 0
|
python
|
@subscriber(ResourceChanged, for_resources=('group',), for_actions=(ACTIONS.DELETE,))
def on_groups_deleted(event):
'\n '
permission_backend = event.request.registry.permission
for change in event.impacted_records:
group = change['old']
bucket_id = event.payload['bucket_id']
group_uri = utils.instance_uri(event.request, 'group', bucket_id=bucket_id, id=group['id'])
permission_backend.remove_principal(group_uri)
|
@subscriber(ResourceChanged, for_resources=('group',), for_actions=(ACTIONS.DELETE,))
def on_groups_deleted(event):
'\n '
permission_backend = event.request.registry.permission
for change in event.impacted_records:
group = change['old']
bucket_id = event.payload['bucket_id']
group_uri = utils.instance_uri(event.request, 'group', bucket_id=bucket_id, id=group['id'])
permission_backend.remove_principal(group_uri)<|docstring|>Some groups were deleted, remove them from users principals.<|endoftext|>
|
5609a177afd86c0ba3c84c97c0e7e58db1ffc662e0e5d57f2278f521a4234334
|
@subscriber(ResourceChanged, for_resources=('group',), for_actions=(ACTIONS.CREATE, ACTIONS.UPDATE))
def on_groups_changed(event):
'Some groups were changed, update users principals.\n '
permission_backend = event.request.registry.permission
for change in event.impacted_records:
if ('old' in change):
existing_record_members = set(change['old'].get('members', []))
else:
existing_record_members = set()
group = change['new']
group_uri = '/buckets/{bucket_id}/groups/{id}'.format(id=group['id'], **event.payload)
new_record_members = set(group.get('members', []))
new_members = (new_record_members - existing_record_members)
removed_members = (existing_record_members - new_record_members)
for member in new_members:
permission_backend.add_user_principal(member, group_uri)
for member in removed_members:
permission_backend.remove_user_principal(member, group_uri)
|
Some groups were changed, update users principals.
|
kinto/views/groups.py
|
on_groups_changed
|
peterdemin/kinto
| 0
|
python
|
@subscriber(ResourceChanged, for_resources=('group',), for_actions=(ACTIONS.CREATE, ACTIONS.UPDATE))
def on_groups_changed(event):
'\n '
permission_backend = event.request.registry.permission
for change in event.impacted_records:
if ('old' in change):
existing_record_members = set(change['old'].get('members', []))
else:
existing_record_members = set()
group = change['new']
group_uri = '/buckets/{bucket_id}/groups/{id}'.format(id=group['id'], **event.payload)
new_record_members = set(group.get('members', []))
new_members = (new_record_members - existing_record_members)
removed_members = (existing_record_members - new_record_members)
for member in new_members:
permission_backend.add_user_principal(member, group_uri)
for member in removed_members:
permission_backend.remove_user_principal(member, group_uri)
|
@subscriber(ResourceChanged, for_resources=('group',), for_actions=(ACTIONS.CREATE, ACTIONS.UPDATE))
def on_groups_changed(event):
'\n '
permission_backend = event.request.registry.permission
for change in event.impacted_records:
if ('old' in change):
existing_record_members = set(change['old'].get('members', []))
else:
existing_record_members = set()
group = change['new']
group_uri = '/buckets/{bucket_id}/groups/{id}'.format(id=group['id'], **event.payload)
new_record_members = set(group.get('members', []))
new_members = (new_record_members - existing_record_members)
removed_members = (existing_record_members - new_record_members)
for member in new_members:
permission_backend.add_user_principal(member, group_uri)
for member in removed_members:
permission_backend.remove_user_principal(member, group_uri)<|docstring|>Some groups were changed, update users principals.<|endoftext|>
|
dc0f554b61f89d9878e498a1d89518974985e54a3436a6fc4717bac71778620a
|
def __init__(self, Data, Keys, framerate, iterate_with_framerate, iterate_with_keys, j_root, j_left, j_right, n_joints, name, joints_per_limb, mirror_fn=None):
'\n :param Data: [data0, data1, ...] lists of sequences, all\n dataX must have the same length. This is a list so that\n multiple things can be associated with each other, e.g.\n human poses <--> activity labels\n :param Keys: key that uniquly identifies the video\n :param framerate: framerate in Hz for each sequence\n :param iterate_with_framerate: if True the iterator returns the framerate as well\n :param iterate_with_keys: if True the iterator returns the key as well\n :param mirror_fn: def mirror(seq): -->\n :param n_joints:\n :param joints_per_limb: {dict} [{Limb}: [{jid1}, {jid2}, ...]]\n '
self.name = name
self.n_joints = n_joints
self.iterate_with_framerate = iterate_with_framerate
self.iterate_with_keys = iterate_with_keys
self.j_root = j_root
self.j_left = j_left
self.j_right = j_right
self.joints_per_limb = joints_per_limb
self.mirror_fn = mirror_fn
n_sequences = (- 1)
for data in Data:
if (n_sequences < 0):
n_sequences = len(data)
else:
assert (n_sequences == len(data)), ((('length mismatch:' + str(n_sequences)) + ' vs ') + str(len(data)))
assert (n_sequences == len(Keys)), ((str(n_sequences) + ' vs ') + str(len(Keys)))
if (not isinstance(framerate, int)):
assert (len(framerate) == n_sequences)
self.Data = Data
self.Keys = Keys
self.framerate = framerate
self.n_data_entries = len(Data)
self.n_sequences = n_sequences
|
:param Data: [data0, data1, ...] lists of sequences, all
dataX must have the same length. This is a list so that
multiple things can be associated with each other, e.g.
human poses <--> activity labels
:param Keys: key that uniquly identifies the video
:param framerate: framerate in Hz for each sequence
:param iterate_with_framerate: if True the iterator returns the framerate as well
:param iterate_with_keys: if True the iterator returns the key as well
:param mirror_fn: def mirror(seq): -->
:param n_joints:
:param joints_per_limb: {dict} [{Limb}: [{jid1}, {jid2}, ...]]
|
mocap/datasets/dataset.py
|
__init__
|
zaverichintan/mocap
| 22
|
python
|
def __init__(self, Data, Keys, framerate, iterate_with_framerate, iterate_with_keys, j_root, j_left, j_right, n_joints, name, joints_per_limb, mirror_fn=None):
'\n :param Data: [data0, data1, ...] lists of sequences, all\n dataX must have the same length. This is a list so that\n multiple things can be associated with each other, e.g.\n human poses <--> activity labels\n :param Keys: key that uniquly identifies the video\n :param framerate: framerate in Hz for each sequence\n :param iterate_with_framerate: if True the iterator returns the framerate as well\n :param iterate_with_keys: if True the iterator returns the key as well\n :param mirror_fn: def mirror(seq): -->\n :param n_joints:\n :param joints_per_limb: {dict} [{Limb}: [{jid1}, {jid2}, ...]]\n '
self.name = name
self.n_joints = n_joints
self.iterate_with_framerate = iterate_with_framerate
self.iterate_with_keys = iterate_with_keys
self.j_root = j_root
self.j_left = j_left
self.j_right = j_right
self.joints_per_limb = joints_per_limb
self.mirror_fn = mirror_fn
n_sequences = (- 1)
for data in Data:
if (n_sequences < 0):
n_sequences = len(data)
else:
assert (n_sequences == len(data)), ((('length mismatch:' + str(n_sequences)) + ' vs ') + str(len(data)))
assert (n_sequences == len(Keys)), ((str(n_sequences) + ' vs ') + str(len(Keys)))
if (not isinstance(framerate, int)):
assert (len(framerate) == n_sequences)
self.Data = Data
self.Keys = Keys
self.framerate = framerate
self.n_data_entries = len(Data)
self.n_sequences = n_sequences
|
def __init__(self, Data, Keys, framerate, iterate_with_framerate, iterate_with_keys, j_root, j_left, j_right, n_joints, name, joints_per_limb, mirror_fn=None):
'\n :param Data: [data0, data1, ...] lists of sequences, all\n dataX must have the same length. This is a list so that\n multiple things can be associated with each other, e.g.\n human poses <--> activity labels\n :param Keys: key that uniquly identifies the video\n :param framerate: framerate in Hz for each sequence\n :param iterate_with_framerate: if True the iterator returns the framerate as well\n :param iterate_with_keys: if True the iterator returns the key as well\n :param mirror_fn: def mirror(seq): -->\n :param n_joints:\n :param joints_per_limb: {dict} [{Limb}: [{jid1}, {jid2}, ...]]\n '
self.name = name
self.n_joints = n_joints
self.iterate_with_framerate = iterate_with_framerate
self.iterate_with_keys = iterate_with_keys
self.j_root = j_root
self.j_left = j_left
self.j_right = j_right
self.joints_per_limb = joints_per_limb
self.mirror_fn = mirror_fn
n_sequences = (- 1)
for data in Data:
if (n_sequences < 0):
n_sequences = len(data)
else:
assert (n_sequences == len(data)), ((('length mismatch:' + str(n_sequences)) + ' vs ') + str(len(data)))
assert (n_sequences == len(Keys)), ((str(n_sequences) + ' vs ') + str(len(Keys)))
if (not isinstance(framerate, int)):
assert (len(framerate) == n_sequences)
self.Data = Data
self.Keys = Keys
self.framerate = framerate
self.n_data_entries = len(Data)
self.n_sequences = n_sequences<|docstring|>:param Data: [data0, data1, ...] lists of sequences, all
dataX must have the same length. This is a list so that
multiple things can be associated with each other, e.g.
human poses <--> activity labels
:param Keys: key that uniquly identifies the video
:param framerate: framerate in Hz for each sequence
:param iterate_with_framerate: if True the iterator returns the framerate as well
:param iterate_with_keys: if True the iterator returns the key as well
:param mirror_fn: def mirror(seq): -->
:param n_joints:
:param joints_per_limb: {dict} [{Limb}: [{jid1}, {jid2}, ...]]<|endoftext|>
|
474cbcf7ae5a626eca841df12159376d3325a51feb383b5315a3dd4f50f03a32
|
def get_joints_for_limb(self, limb):
'\n :param limb: {Limb}\n '
return self.joints_per_limb[limb]
|
:param limb: {Limb}
|
mocap/datasets/dataset.py
|
get_joints_for_limb
|
zaverichintan/mocap
| 22
|
python
|
def get_joints_for_limb(self, limb):
'\n \n '
return self.joints_per_limb[limb]
|
def get_joints_for_limb(self, limb):
'\n \n '
return self.joints_per_limb[limb]<|docstring|>:param limb: {Limb}<|endoftext|>
|
a37a6d5c82880d04630299c49a2fd45db922b0bc9b6372c9cc30e1537f27e8e5
|
def get_framerate(self, index):
' return the framerate for the given sequence\n '
assert isinstance(index, int)
assert ((index >= 0) and (index < self.n_sequences)), ((('out of bounds: ' + str(self.n_sequences)) + ' vs ') + str(index))
if isinstance(self.framerate, int):
return self.framerate
else:
return self.framerate[index]
|
return the framerate for the given sequence
|
mocap/datasets/dataset.py
|
get_framerate
|
zaverichintan/mocap
| 22
|
python
|
def get_framerate(self, index):
' \n '
assert isinstance(index, int)
assert ((index >= 0) and (index < self.n_sequences)), ((('out of bounds: ' + str(self.n_sequences)) + ' vs ') + str(index))
if isinstance(self.framerate, int):
return self.framerate
else:
return self.framerate[index]
|
def get_framerate(self, index):
' \n '
assert isinstance(index, int)
assert ((index >= 0) and (index < self.n_sequences)), ((('out of bounds: ' + str(self.n_sequences)) + ' vs ') + str(index))
if isinstance(self.framerate, int):
return self.framerate
else:
return self.framerate[index]<|docstring|>return the framerate for the given sequence<|endoftext|>
|
e6790a392437e14b65c8aa7bb9caf4527a382b9f6621b67066ad45a8ee3ee8bc
|
def get_sequence(self, index):
' return all data entries for the given sequence\n '
assert isinstance(index, int)
assert ((index >= 0) and (index < self.n_sequences)), ((('out of bounds: ' + str(self.n_sequences)) + ' vs ') + str(index))
if (self.n_data_entries == 1):
return self.Data[0][index]
result = []
for data in self.Data:
result.append(data[index])
return result
|
return all data entries for the given sequence
|
mocap/datasets/dataset.py
|
get_sequence
|
zaverichintan/mocap
| 22
|
python
|
def get_sequence(self, index):
' \n '
assert isinstance(index, int)
assert ((index >= 0) and (index < self.n_sequences)), ((('out of bounds: ' + str(self.n_sequences)) + ' vs ') + str(index))
if (self.n_data_entries == 1):
return self.Data[0][index]
result = []
for data in self.Data:
result.append(data[index])
return result
|
def get_sequence(self, index):
' \n '
assert isinstance(index, int)
assert ((index >= 0) and (index < self.n_sequences)), ((('out of bounds: ' + str(self.n_sequences)) + ' vs ') + str(index))
if (self.n_data_entries == 1):
return self.Data[0][index]
result = []
for data in self.Data:
result.append(data[index])
return result<|docstring|>return all data entries for the given sequence<|endoftext|>
|
43515361f3b0f8ea45ee5f0407db2c8cc302ca862b7088544af74138eb63dcc1
|
def normalize(self, seq):
'\n :param seq: [n_frames x dim]\n '
assert (len(seq.shape) == 2), str(seq.shape)
n_frames = len(seq)
n_joints = self.n_joints
seq = seq.reshape((n_frames, n_joints, (- 1)))
assert ((seq.shape[2] == 3) or (seq.shape[2] == 4)), str(seq.shape)
seq = (seq - self.mu)
seq = seq.reshape((n_frames, (- 1)))
return seq
|
:param seq: [n_frames x dim]
|
mocap/datasets/dataset.py
|
normalize
|
zaverichintan/mocap
| 22
|
python
|
def normalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
n_frames = len(seq)
n_joints = self.n_joints
seq = seq.reshape((n_frames, n_joints, (- 1)))
assert ((seq.shape[2] == 3) or (seq.shape[2] == 4)), str(seq.shape)
seq = (seq - self.mu)
seq = seq.reshape((n_frames, (- 1)))
return seq
|
def normalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
n_frames = len(seq)
n_joints = self.n_joints
seq = seq.reshape((n_frames, n_joints, (- 1)))
assert ((seq.shape[2] == 3) or (seq.shape[2] == 4)), str(seq.shape)
seq = (seq - self.mu)
seq = seq.reshape((n_frames, (- 1)))
return seq<|docstring|>:param seq: [n_frames x dim]<|endoftext|>
|
313b754a4a7f55d876dbec12e4283997871541f9e8e9459b22f4406bac6791e3
|
def denormalize(self, seq):
'\n :param seq: [n_frames x dim]\n '
assert (len(seq.shape) == 2), str(seq.shape)
n_frames = len(seq)
n_joints = self.n_joints
seq = seq.reshape((n_frames, n_joints, (- 1)))
assert ((seq.shape[2] == 3) or (seq.shape[2] == 4)), str(seq.shape)
seq = (seq + self.mu)
seq = seq.reshape((n_frames, (- 1)))
return seq
|
:param seq: [n_frames x dim]
|
mocap/datasets/dataset.py
|
denormalize
|
zaverichintan/mocap
| 22
|
python
|
def denormalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
n_frames = len(seq)
n_joints = self.n_joints
seq = seq.reshape((n_frames, n_joints, (- 1)))
assert ((seq.shape[2] == 3) or (seq.shape[2] == 4)), str(seq.shape)
seq = (seq + self.mu)
seq = seq.reshape((n_frames, (- 1)))
return seq
|
def denormalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
n_frames = len(seq)
n_joints = self.n_joints
seq = seq.reshape((n_frames, n_joints, (- 1)))
assert ((seq.shape[2] == 3) or (seq.shape[2] == 4)), str(seq.shape)
seq = (seq + self.mu)
seq = seq.reshape((n_frames, (- 1)))
return seq<|docstring|>:param seq: [n_frames x dim]<|endoftext|>
|
02da3abbe1b425c850f07b04079b26af6efacd60a29936c31c91e0e0f8ebe744
|
def normalize(self, seq):
'\n :param seq: [n_frames x dim]\n '
assert (len(seq.shape) == 2), str(seq.shape)
seq = (seq - self.mu)
return seq
|
:param seq: [n_frames x dim]
|
mocap/datasets/dataset.py
|
normalize
|
zaverichintan/mocap
| 22
|
python
|
def normalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
seq = (seq - self.mu)
return seq
|
def normalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
seq = (seq - self.mu)
return seq<|docstring|>:param seq: [n_frames x dim]<|endoftext|>
|
e320201fab404c381a8e284764b0b3ea1ce6c1eee16df6c583762a022f5b254c
|
def denormalize(self, seq):
'\n :param seq: [n_frames x dim]\n '
assert (len(seq.shape) == 2), str(seq.shape)
seq = (seq + self.mu)
return seq
|
:param seq: [n_frames x dim]
|
mocap/datasets/dataset.py
|
denormalize
|
zaverichintan/mocap
| 22
|
python
|
def denormalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
seq = (seq + self.mu)
return seq
|
def denormalize(self, seq):
'\n \n '
assert (len(seq.shape) == 2), str(seq.shape)
seq = (seq + self.mu)
return seq<|docstring|>:param seq: [n_frames x dim]<|endoftext|>
|
1864b4d419d84bdb26cbfe79c124cacab1f6f70b9c4c22ee23a3ed091921017d
|
def _update_players(player1, player2, signer):
'\n Return: upd_player1, upd_player2\n '
if (player1 == ''):
return (signer, player2)
elif (player2 == ''):
return (player1, signer)
return (player1, player2)
|
Return: upd_player1, upd_player2
|
sdk/examples/xo_python/sawtooth_xo/processor/handler.py
|
_update_players
|
patricknieves/seth
| 4
|
python
|
def _update_players(player1, player2, signer):
'\n \n '
if (player1 == ):
return (signer, player2)
elif (player2 == ):
return (player1, signer)
return (player1, player2)
|
def _update_players(player1, player2, signer):
'\n \n '
if (player1 == ):
return (signer, player2)
elif (player2 == ):
return (player1, signer)
return (player1, player2)<|docstring|>Return: upd_player1, upd_player2<|endoftext|>
|
b49f2195cec82df0f451264ebe17b01583d70dbd9f963a4ebfc66aa1f3d052a9
|
def upload(self, local: str, remote: str, **kwargs):
'\n Upload the local file (not directory) to the specified remote URI.\n Args:\n local (str): path of the local file to be uploaded.\n remote (str): the remote uri.\n '
handler = self.__get_path_handler(remote)
assert isinstance(handler, KODOHandler), 'Invalid remote path: {}.'.format(remote)
return handler._upload(local, remote, **kwargs)
|
Upload the local file (not directory) to the specified remote URI.
Args:
local (str): path of the local file to be uploaded.
remote (str): the remote uri.
|
detectron2/utils/file_io.py
|
upload
|
Chen-Jianhu/detectron2
| 0
|
python
|
def upload(self, local: str, remote: str, **kwargs):
'\n Upload the local file (not directory) to the specified remote URI.\n Args:\n local (str): path of the local file to be uploaded.\n remote (str): the remote uri.\n '
handler = self.__get_path_handler(remote)
assert isinstance(handler, KODOHandler), 'Invalid remote path: {}.'.format(remote)
return handler._upload(local, remote, **kwargs)
|
def upload(self, local: str, remote: str, **kwargs):
'\n Upload the local file (not directory) to the specified remote URI.\n Args:\n local (str): path of the local file to be uploaded.\n remote (str): the remote uri.\n '
handler = self.__get_path_handler(remote)
assert isinstance(handler, KODOHandler), 'Invalid remote path: {}.'.format(remote)
return handler._upload(local, remote, **kwargs)<|docstring|>Upload the local file (not directory) to the specified remote URI.
Args:
local (str): path of the local file to be uploaded.
remote (str): the remote uri.<|endoftext|>
|
23b343f6c86511ae7d6582a2220213dd45c772ec43ea7969648b73333a70eec1
|
def nextPermutation(self, nums):
'\n :type nums: List[int]\n :rtype: void Do not return anything, modify nums in-place instead.\n Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.\n\n If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).\n\n The replacement must be in-place and use only constant extra memory.\n\n Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.\n\n 1,2,3 → 1,3,2\n 3,2,1 → 1,2,3\n 1,1,5 → 1,5,1\n '
if (not nums):
return None
i = (len(nums) - 1)
j = (- 1)
while (i > 0):
if (nums[(i - 1)] < nums[i]):
j = (i - 1)
break
i -= 1
for i in range((len(nums) - 1), (- 1), (- 1)):
if (nums[i] > nums[j]):
(nums[i], nums[j]) = (nums[j], nums[i])
nums[(j + 1):] = sorted(nums[(j + 1):])
return
|
:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place and use only constant extra memory.
Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
1,2,3 → 1,3,2
3,2,1 → 1,2,3
1,1,5 → 1,5,1
|
facebook/nextPermutation.py
|
nextPermutation
|
rando3/leetcode-python
| 0
|
python
|
def nextPermutation(self, nums):
'\n :type nums: List[int]\n :rtype: void Do not return anything, modify nums in-place instead.\n Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.\n\n If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).\n\n The replacement must be in-place and use only constant extra memory.\n\n Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.\n\n 1,2,3 → 1,3,2\n 3,2,1 → 1,2,3\n 1,1,5 → 1,5,1\n '
if (not nums):
return None
i = (len(nums) - 1)
j = (- 1)
while (i > 0):
if (nums[(i - 1)] < nums[i]):
j = (i - 1)
break
i -= 1
for i in range((len(nums) - 1), (- 1), (- 1)):
if (nums[i] > nums[j]):
(nums[i], nums[j]) = (nums[j], nums[i])
nums[(j + 1):] = sorted(nums[(j + 1):])
return
|
def nextPermutation(self, nums):
'\n :type nums: List[int]\n :rtype: void Do not return anything, modify nums in-place instead.\n Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.\n\n If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).\n\n The replacement must be in-place and use only constant extra memory.\n\n Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.\n\n 1,2,3 → 1,3,2\n 3,2,1 → 1,2,3\n 1,1,5 → 1,5,1\n '
if (not nums):
return None
i = (len(nums) - 1)
j = (- 1)
while (i > 0):
if (nums[(i - 1)] < nums[i]):
j = (i - 1)
break
i -= 1
for i in range((len(nums) - 1), (- 1), (- 1)):
if (nums[i] > nums[j]):
(nums[i], nums[j]) = (nums[j], nums[i])
nums[(j + 1):] = sorted(nums[(j + 1):])
return<|docstring|>:type nums: List[int]
:rtype: void Do not return anything, modify nums in-place instead.
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such arrangement is not possible, it must rearrange it as the lowest possible order (ie, sorted in ascending order).
The replacement must be in-place and use only constant extra memory.
Here are some examples. Inputs are in the left-hand column and its corresponding outputs are in the right-hand column.
1,2,3 → 1,3,2
3,2,1 → 1,2,3
1,1,5 → 1,5,1<|endoftext|>
|
53d06604eecb2349e41b73dde20baa8f39309a8f09ba0b4f19b6b6f665723fea
|
@staticmethod
def confirm_transparent_redirect(query_string):
'\n Confirms a transparent redirect request. It expects the query string from the\n redirect request. The query string should _not_ include the leading "?" character. ::\n\n result = braintree.CreditCard.confirm_transparent_redirect_request("foo=bar&id=12345")\n '
warnings.warn('Please use TransparentRedirect.confirm instead', DeprecationWarning)
return Configuration.gateway().credit_card.confirm_transparent_redirect(query_string)
|
Confirms a transparent redirect request. It expects the query string from the
redirect request. The query string should _not_ include the leading "?" character. ::
result = braintree.CreditCard.confirm_transparent_redirect_request("foo=bar&id=12345")
|
myvenv/Lib/site-packages/braintree/credit_card.py
|
confirm_transparent_redirect
|
Fa67/saleor-shop
| 0
|
python
|
@staticmethod
def confirm_transparent_redirect(query_string):
'\n Confirms a transparent redirect request. It expects the query string from the\n redirect request. The query string should _not_ include the leading "?" character. ::\n\n result = braintree.CreditCard.confirm_transparent_redirect_request("foo=bar&id=12345")\n '
warnings.warn('Please use TransparentRedirect.confirm instead', DeprecationWarning)
return Configuration.gateway().credit_card.confirm_transparent_redirect(query_string)
|
@staticmethod
def confirm_transparent_redirect(query_string):
'\n Confirms a transparent redirect request. It expects the query string from the\n redirect request. The query string should _not_ include the leading "?" character. ::\n\n result = braintree.CreditCard.confirm_transparent_redirect_request("foo=bar&id=12345")\n '
warnings.warn('Please use TransparentRedirect.confirm instead', DeprecationWarning)
return Configuration.gateway().credit_card.confirm_transparent_redirect(query_string)<|docstring|>Confirms a transparent redirect request. It expects the query string from the
redirect request. The query string should _not_ include the leading "?" character. ::
result = braintree.CreditCard.confirm_transparent_redirect_request("foo=bar&id=12345")<|endoftext|>
|
dde3480e12a28e2f02480187247c01a7c468b1d4be59704916af781efb634e62
|
@staticmethod
def create(params={}):
'\n Create a CreditCard.\n\n A number and expiration_date are required. ::\n\n result = braintree.CreditCard.create({\n "number": "4111111111111111",\n "expiration_date": "12/2012"\n })\n\n '
return Configuration.gateway().credit_card.create(params)
|
Create a CreditCard.
A number and expiration_date are required. ::
result = braintree.CreditCard.create({
"number": "4111111111111111",
"expiration_date": "12/2012"
})
|
myvenv/Lib/site-packages/braintree/credit_card.py
|
create
|
Fa67/saleor-shop
| 0
|
python
|
@staticmethod
def create(params={}):
'\n Create a CreditCard.\n\n A number and expiration_date are required. ::\n\n result = braintree.CreditCard.create({\n "number": "4111111111111111",\n "expiration_date": "12/2012"\n })\n\n '
return Configuration.gateway().credit_card.create(params)
|
@staticmethod
def create(params={}):
'\n Create a CreditCard.\n\n A number and expiration_date are required. ::\n\n result = braintree.CreditCard.create({\n "number": "4111111111111111",\n "expiration_date": "12/2012"\n })\n\n '
return Configuration.gateway().credit_card.create(params)<|docstring|>Create a CreditCard.
A number and expiration_date are required. ::
result = braintree.CreditCard.create({
"number": "4111111111111111",
"expiration_date": "12/2012"
})<|endoftext|>
|
9400ba2c25eda6062a01f2c5f440f8719264f9f3019f3d304a4335d2e478d0b5
|
@staticmethod
def update(credit_card_token, params={}):
'\n Update an existing CreditCard\n\n By credit_card_id. The params are similar to create::\n\n result = braintree.CreditCard.update("my_credit_card_id", {\n "cardholder_name": "John Doe"\n })\n\n '
return Configuration.gateway().credit_card.update(credit_card_token, params)
|
Update an existing CreditCard
By credit_card_id. The params are similar to create::
result = braintree.CreditCard.update("my_credit_card_id", {
"cardholder_name": "John Doe"
})
|
myvenv/Lib/site-packages/braintree/credit_card.py
|
update
|
Fa67/saleor-shop
| 0
|
python
|
@staticmethod
def update(credit_card_token, params={}):
'\n Update an existing CreditCard\n\n By credit_card_id. The params are similar to create::\n\n result = braintree.CreditCard.update("my_credit_card_id", {\n "cardholder_name": "John Doe"\n })\n\n '
return Configuration.gateway().credit_card.update(credit_card_token, params)
|
@staticmethod
def update(credit_card_token, params={}):
'\n Update an existing CreditCard\n\n By credit_card_id. The params are similar to create::\n\n result = braintree.CreditCard.update("my_credit_card_id", {\n "cardholder_name": "John Doe"\n })\n\n '
return Configuration.gateway().credit_card.update(credit_card_token, params)<|docstring|>Update an existing CreditCard
By credit_card_id. The params are similar to create::
result = braintree.CreditCard.update("my_credit_card_id", {
"cardholder_name": "John Doe"
})<|endoftext|>
|
ef1752bd43df12942b77b25c6f3bbb6f7fda7bfababd9fe452495858afafea83
|
@staticmethod
def delete(credit_card_token):
'\n Delete a credit card\n\n Given a credit_card_id::\n\n result = braintree.CreditCard.delete("my_credit_card_id")\n\n '
return Configuration.gateway().credit_card.delete(credit_card_token)
|
Delete a credit card
Given a credit_card_id::
result = braintree.CreditCard.delete("my_credit_card_id")
|
myvenv/Lib/site-packages/braintree/credit_card.py
|
delete
|
Fa67/saleor-shop
| 0
|
python
|
@staticmethod
def delete(credit_card_token):
'\n Delete a credit card\n\n Given a credit_card_id::\n\n result = braintree.CreditCard.delete("my_credit_card_id")\n\n '
return Configuration.gateway().credit_card.delete(credit_card_token)
|
@staticmethod
def delete(credit_card_token):
'\n Delete a credit card\n\n Given a credit_card_id::\n\n result = braintree.CreditCard.delete("my_credit_card_id")\n\n '
return Configuration.gateway().credit_card.delete(credit_card_token)<|docstring|>Delete a credit card
Given a credit_card_id::
result = braintree.CreditCard.delete("my_credit_card_id")<|endoftext|>
|
1820dd35d0f53cc14eae1cb77714d5b0dff1edc2f5f623d38355b95860806353
|
@staticmethod
def expired():
' Return a collection of expired credit cards. '
return Configuration.gateway().credit_card.expired()
|
Return a collection of expired credit cards.
|
myvenv/Lib/site-packages/braintree/credit_card.py
|
expired
|
Fa67/saleor-shop
| 0
|
python
|
@staticmethod
def expired():
' '
return Configuration.gateway().credit_card.expired()
|
@staticmethod
def expired():
' '
return Configuration.gateway().credit_card.expired()<|docstring|>Return a collection of expired credit cards.<|endoftext|>
|
486668ebde4628f7a20b3b39eef422098f27d7567042807531fa03f3e0c95179
|
@staticmethod
def expiring_between(start_date, end_date):
' Return a collection of credit cards expiring between the given dates. '
return Configuration.gateway().credit_card.expiring_between(start_date, end_date)
|
Return a collection of credit cards expiring between the given dates.
|
myvenv/Lib/site-packages/braintree/credit_card.py
|
expiring_between
|
Fa67/saleor-shop
| 0
|
python
|
@staticmethod
def expiring_between(start_date, end_date):
' '
return Configuration.gateway().credit_card.expiring_between(start_date, end_date)
|
@staticmethod
def expiring_between(start_date, end_date):
' '
return Configuration.gateway().credit_card.expiring_between(start_date, end_date)<|docstring|>Return a collection of credit cards expiring between the given dates.<|endoftext|>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.