content stringlengths 7 1.05M |
|---|
for i in range(nBlocks):
# Load new block of data from CSV file
xTrain = createSparseTable('./mldata/20newsgroups.coo.' + str(i + 1) + '.csv', nFeatures)
# Load new block of labels from CSV file
labelsDataSource = FileDataSource(
'./mldata/20newsgroups.labels.' + str(i + 1) + '.csv',
DataSourceIface.doAllocateNumericTable, DataSourceIface.doDictionaryFromContext
)
labelsDataSource.loadDataBlock()
yTrain = labelsDataSource.getNumericTable()
# Set input
#
# YOUR CODE HERE
#
# There are two pieces of input to be set: data and labels. You should
# use the 'input.set' member methods of the nbTrain algorithm object.
# The input IDs to use are 'classifier.training.data' and 'classifier.training.labels'
# respectively.
nbTrain.input.set(classifier.training.data,xTrain)
nbTrain.input.set(classifier.training.labels,yTrain)
# Compute
#
# YOUR CODE HERE
#
# Call the 'compute()' method of your algorithm object to update the partial model.
nbTrain.compute()
model = nbTrain.finalizeCompute().get(classifier.training.model) |
# -*- coding: UTF-8 -*-
logger.info("Loading 6 objects to table households_type...")
# fields: id, name
loader.save(create_households_type(1,['Married couple', 'Ehepaar', 'Couple mari\xe9']))
loader.save(create_households_type(2,['Divorced couple', 'Geschiedenes Paar', 'Couple divorc\xe9']))
loader.save(create_households_type(3,['Factual household', 'Faktischer Haushalt', 'Cohabitation de fait']))
loader.save(create_households_type(4,['Legal cohabitation', 'Legale Wohngemeinschaft', 'Cohabitation l\xe9gale']))
loader.save(create_households_type(5,['Isolated', 'Getrennt', 'Isol\xe9']))
loader.save(create_households_type(6,['Other', 'Sonstige', 'Autre']))
loader.flush_deferred_objects()
|
"""
Python program to solve N Queen
Problem using backtracking
"""
global N
def printSolution(board):
for i in range(N):
for j in range(N):
print(board[i][j], end="")
print()
def isSafe(board, row, col):
# Check this row on left side
for i in range(col):
if board[row][i] == 1:
return False
# Check upper diagonal on left side
for i, j in zip(range(row, -1, -1), range(col, -1, -1)):
if board[i][j] == 1:
return False
# Check lower diagonal on left side
for i, j in zip(range(row, N, 1), range(col, -1, -1)):
if board[i][j] == 1:
return False
return True
def solveNQUtil(board, col):
# base case: If all queens are placed
# then return true
if col >= N:
return True
# Consider this column and try placing
# this queen in all rows one by one
for i in range(N):
if isSafe(board, i, col):
# Place this queen in board[i][col]
board[i][col] = 1
# recur to place rest of the queens
if solveNQUtil(board, col + 1) == True:
return True
# If placing queen in board[i][col
# doesn't lead to a solution, then
# queen from board[i][col]
board[i][col] = 0
# if the queen can not be placed in any row in
# this column col then return false
return False
def solveNQ():
board = [ [0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
]
if solveNQUtil(board, 0) == False:
print("Solution does not exist")
return False
printSolution(board)
return True
if __name__ == "__main__":
N = 4
solveNQ()
|
user = {
'name' : 'magdy' ,
'age' : ' 23 ' ,
'country' : ' egypt'
}
print(user)
print(type(user))
print(user.values())
print(user.keys())
print(len(user))
print(user['name'])
print(user['age'])
print("="*50) # separator
user['friend'] = 'sameh'
print(user)
user.update({'father' : 'edwar' , 'mother' : " mariam"})
print(user)
print("="*50) # separator
all_items = user.items()
print(all_items)
a = ('magdy' , ' sameh' , ' peter' )
b = ('name_1' , 'name_2' , 'name_3')
DICT = dict.fromkeys(b,a)
print(DICT)
|
# 75
# Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: A) Quantas vezes apareceu o valor 9. B) Em que posição foi digitado o primeiro valor 3. C) Quais foram os números pares.
# Description
num = (int(input('Digite um número: ')),
int(input('Digite outro número: ')),
int(input('Digite mais um número: ')),
int(input('Digite o último número: '))
)
print(f'Você digitou os valores \33[36m{num}\33[m')
print(f'O valor 9 apareceu \33[36m{num.count(9)}\33[m')
if 3 in num:
print(f'O valor 3 apareceu na \33[36m{num.index(3)+1}\33[mª posição')
else:
print('O valor 3 não foi digitado em nenhuma posição')
print('Os valores pares digitados foram ',end='')
for n in num:
if n % 2 == 0:
print(f'\33[36m{n}\33[m', end=' ')
print('\n\n')
|
""" Leetcode 62 - Unique Paths
https://leetcode.com/problems/unique-paths/
1. self-implement BFS: Time Limit Exceeded
2. self-implement DP: Time: 32ms(57.17%) Memory: 13.8MB(68.02%)
"""
class Solution1:
""" self-implement BFS """
def unique_paths(self, m: int, n: int) -> int:
if m == 1 and n == 1:
return 1
x, y = 1, 1
go_down = (1, 0)
go_right = (0, 1)
count = 0
stack = [(x, y)]
while stack:
x, y = stack.pop()
print(x, y)
for dx, dy in [go_down, go_right]:
if x+dx == n and y+dy == m:
count += 1
elif x+dx <= n and y+dy <= m:
stack.insert(0, (x+dx, y+dy))
return count
class Solution2:
""" self-implement DP """
def unique_paths(self, m, n):
mat = [[1 for i in range(m)] for j in range(n)]
for x in range(1, n):
for y in range(1, m):
mat[x][y] = mat[x-1][y] + mat[x][y-1]
return mat[n-1][m-1]
if __name__ == '__main__':
m = 23
n = 12
res = Solution2().unique_paths(m, n)
print(res)
|
class Solution(object):
def mySqrt(self, x):
"""
:type x: int
:rtype: int
"""
left = 0
right = x+1
while left < right:
mid = (left+right)//2
if mid*mid > x:
right = mid
elif mid*mid < x:
left = mid+1
else:
return mid
return left-1
sol = Solution()
# Test Case1, answer should be 1
x1 = 1
answer1 = sol.mySqrt(x1)
print(answer1)
# Test Case2, answer should be 2
x2 = 5
answer2 = sol.mySqrt(x2)
print(answer2)
# Test Case3, answer should be 3
x3 = 11
answer3 = sol.mySqrt(x3)
print(answer3)
# Test Case4, answer should be 0
x4 = 0
answer4 = sol.mySqrt(x4)
print(answer4)
|
class DottableDict(dict):
"""能用点 '.' 访问的dict"""
def __init__(self, *args, **kwargs):
dict.__init__(self, *args, **kwargs)
for arg in args:
if isinstance(arg, dict):
for k, v in arg.items():
if isinstance(v, dict):
v = DottableDict(v)
self[k] = v
if kwargs:
for k, v in kwargs.items():
if isinstance(v, dict):
v = DottableDict(v)
self[k] = v
def __getattr__(self, attr):
v = self.get(attr)
if not v is None:
return v
else:
newDottableDict = DottableDict()
self.__setitem__(attr,newDottableDict)
return newDottableDict
def __setattr__(self, key, value):
self.__setitem__(key, value)
def __setitem__(self, key, value):
super().__setitem__(key, value)
self.__dict__.update({key: value})
def __delattr__(self, item):
self.__delitem__(item)
def __delitem__(self, key):
super().__delitem__(key)
del self.__dict__[key]
def __missing__(self, key):
return super().__setitem__(key, DottableDict())
|
def minimum():
l= [8, 6, 4, 8, 4, 50, 2, 7]
i=0
min=l[i]
while i<len(l):
if l[i]<min:
min=l[i]
i=i+1
print(min)
minimum() |
name = "ada lovelace"
#print(name.title())
#name refers to a the string "ada lovelace". The title *method* changes each word
#to title-case.
#A method is a specific function or group of funcitons that python can perform on
# a piece of data.
name = "adA LoveLace"
#print(name.upper())
#print(name.lower())
#print(name.title())
#Use variables within strings
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
#Important: put the letter f immediately before the opening quotation marks
# put braces around any variable names
#This is an 'f-string'
print(full_name)
print(f'{full_name.title()}') |
def chunks(l, n):
'''
:rtype list
split a list into a list of sublists
'''
n = max(1, n)
return [l[i:i + n] for i in range(0, len(l), n)]
|
#memotong array bisa dengan menggunakan fungsi del
#dengan cara memasukkan angka dari urutan array
#array variable
#data array
a = ['medan', 'banjarmasin', 'jakarta', 'pekanbaru']
#saya ingin memotong array dengan menyisakan medan dan pekanbaru
del a[1:3]
print(a)
#hmm sepertinya jika menggunakan fungsi del akan dihitung dari 1
#bukan dari 0
|
"""
Empty pytest settings.
"""
SECRET_KEY = 'dummy secret key' # nosec
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.admin',
'django.contrib.messages',
'site_config_client',
]
FEATURES = {}
MIDDLEWARE = [
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
]
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
|
"""
Tuples are ecnlosed in parenthesis.
The values inside a tuple cannot be
changed.
"""
#declaring a tuple
flush = (1, 3, 4, 5)
print(flush[0]) #This will index 1 out of the tuple |
# Project Picframe
# Copyright 2021, Alef Solutions, Inc.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
"""
picframe_settings.py holds the user-configurable settings for the
frame.
"""
############################################################
#
# PFSettings
# This class holds user-configurable settings values.
#
class PFSettings:
"""
This class holds user-configurable settings values. All of these
can also be configured on the command line.
"""
##########################################################
# Where should logging information be sent? If log_to_stdout is set
# to true, it ignores log_directory and sends logging information to
# stdout. Otherwise it creates a logfile and puts it into the log
# directory. The logfile name is picframe_<timestamp>.log
log_to_stdout = True
log_directory = '/tmp'
##########################################################
# Debug level. CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
debug_level = 'INFO'
##########################################################
# Should the images be displayed fullscreen? You can also specify a
# default non-fullscreen size by setting the geom. If it is
# set to None, it defaults to 400x400
fullscreen = False
geometry_str = "400x400"
##########################################################
# The fullscreen_geom is calculated by the program and is
# generally right unless you are on linux and using more than
# one monitor, in which case it WILL BE WRONG.
# Put in the form of fullscreen_geom_str = "1920x1080"
fullscreen_geom_str = "1920x1080"
##########################################################
# How long should an image be displayed (in seconds)?
display_time = 30
##########################################################
# Should the screen go dark during certain hours? If not, set the
# blackout_hour to None. Otherwise set the values using a 24 hour
# clock time.
#blackout_hour = None
blackout_hour = 23
blackout_minute = 0
end_blackout_hour = 7
end_blackout_minute = 15
##########################################################
# How long (minutes) should the motion sensor wait to see motion before
# blacking out the screen. Setting to None or 0 disables the motion
# detector.
# You can also disable the motion detector by setting
# use_motion_detector = False
# If you set motion_sensor_timeout to a usable number, you can toggle
# the motion sensor on and off using the keyboard.
motion_sensor_timeout = 15
use_motion_sensor = True
##########################################################
# Where should images be sourced from?
# Options are "Google Drive", "Filesystem"
image_source = 'Filesystem'
#image_source = 'Google Drive'
# Settings if for Filesystem
# image_paths can be a single path, the path to a single file,
# or a list of comma separated paths.
#image_paths = ('/mnt/c/tmp/images/IMG_1275.JPG',)
#image_paths = ('/mnt/c/tmp/images/',)
image_paths = ('/mnt/pibackup/',)
#image_paths = ('../images/black.png',)
#image_paths = ('/mnt/c/Users/andym/Pictures/',)
# Settings if for Google Drive (if used)
# If there is a root level directory to start in, can save a lot of time
# not traversing the rest. If the desired directory is at root level,
# then give both.
gdrive_root_folder = "PicFrame"
# The directory the photos are in. It may be the same as the
# ROOT_FOLDER_TITLE
gdrive_photos_folder = "PicFrame"
############################################################
############################################################
#
# Advanced settings. Adjust these carefully
#
############################################################
#
# Video settings:
#
# camera_port is useful if you have two video cameras and the
# wrong one is being selected. If that is the case, first try
# to set it to 1, then -1.
# default:
# camera_port = 0
camera_port = 0
# pixel_threshold identifies how many pixels need to change
# before a difference is tagged as motion. If the camera is
# lousy, light flickers, or small movements are common, this
# can be increased.
# default:
# pixel_threshold = 10
pixel_threshold = 15
# TIMER_STEP is the amount of time in seconds to increase or decrease
# the display time by when the keyboard toggle is used.
timer_step = 10
|
#
# PySNMP MIB module HUAWEI-SLOG-EUDM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-SLOG-EUDM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:36:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint")
hwDatacomm, = mibBuilder.importSymbols("HUAWEI-MIB", "hwDatacomm")
ModuleCompliance, ObjectGroup, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup")
Counter32, ObjectIdentity, ModuleIdentity, Gauge32, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Counter64, Unsigned32, MibIdentifier, NotificationType, Bits, IpAddress, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "ObjectIdentity", "ModuleIdentity", "Gauge32", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Counter64", "Unsigned32", "MibIdentifier", "NotificationType", "Bits", "IpAddress", "Integer32")
TextualConvention, DisplayString, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "TruthValue")
hwSLOGEudm = ModuleIdentity((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2))
if mibBuilder.loadTexts: hwSLOGEudm.setLastUpdated('200304081633Z')
if mibBuilder.loadTexts: hwSLOGEudm.setOrganization('Huawei Technologies co.,Ltd.')
class FlowLogType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("flowLogSysLog", 1), ("flowLogExport", 2))
hwSLOG = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16))
hwSLogEudmGlobalCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1))
hwSLogEudmAttackLogInterval = MibScalar((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmAttackLogInterval.setStatus('current')
hwSLogEudmFlowLogInterval = MibScalar((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmFlowLogInterval.setStatus('current')
hwSLogEudmStreamLogInterval = MibScalar((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmStreamLogInterval.setStatus('current')
hwSLogEudmFlowLogMode = MibScalar((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1, 4), FlowLogType().clone('flowLogSysLog')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmFlowLogMode.setStatus('current')
hwSLogEudmServerIP = MibScalar((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1, 5), IpAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmServerIP.setStatus('current')
hwSLogEudmServerPort = MibScalar((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmServerPort.setStatus('current')
hwSLogInterZoneEnableCfg = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2))
hwSLogEudmFlowLogEnableTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2, 1), )
if mibBuilder.loadTexts: hwSLogEudmFlowLogEnableTable.setStatus('current')
hwSLogEudmFlowLogEnableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2, 1, 1), ).setIndexNames((0, "HUAWEI-SLOG-EUDM-MIB", "hwSLogFlowEnableZoneID1"), (0, "HUAWEI-SLOG-EUDM-MIB", "hwSLogFlowEnableZoneID2"))
if mibBuilder.loadTexts: hwSLogEudmFlowLogEnableEntry.setStatus('current')
hwSLogFlowEnableZoneID1 = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16)))
if mibBuilder.loadTexts: hwSLogFlowEnableZoneID1.setStatus('current')
hwSLogFlowEnableZoneID2 = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16)))
if mibBuilder.loadTexts: hwSLogFlowEnableZoneID2.setStatus('current')
hwSLogEudmFlowEnableFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2, 1, 1, 3), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmFlowEnableFlag.setStatus('current')
hwSLogEudmEnableHostAcl = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 2, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(0, 0), ValueRangeConstraint(2000, 3999), ))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hwSLogEudmEnableHostAcl.setStatus('current')
hwSLOGEudmConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 3))
hwSLOGEudmCompliance = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 3, 1))
hwSLOGEudmMibGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 3, 2))
hwSLOGEudmGlobalCfgGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 3, 2, 1)).setObjects(("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmAttackLogInterval"), ("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmStreamLogInterval"), ("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmFlowLogMode"), ("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmFlowLogInterval"), ("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmServerIP"), ("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmServerPort"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
hwSLOGEudmGlobalCfgGroup = hwSLOGEudmGlobalCfgGroup.setStatus('current')
hwSLOGEudmFlowLogEnableGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 16, 2, 3, 2, 2)).setObjects(("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmFlowEnableFlag"), ("HUAWEI-SLOG-EUDM-MIB", "hwSLogEudmEnableHostAcl"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
hwSLOGEudmFlowLogEnableGroup = hwSLOGEudmFlowLogEnableGroup.setStatus('current')
mibBuilder.exportSymbols("HUAWEI-SLOG-EUDM-MIB", hwSLOG=hwSLOG, hwSLogFlowEnableZoneID1=hwSLogFlowEnableZoneID1, FlowLogType=FlowLogType, hwSLogEudmServerIP=hwSLogEudmServerIP, hwSLOGEudmMibGroups=hwSLOGEudmMibGroups, hwSLogEudmServerPort=hwSLogEudmServerPort, hwSLOGEudmFlowLogEnableGroup=hwSLOGEudmFlowLogEnableGroup, hwSLogEudmStreamLogInterval=hwSLogEudmStreamLogInterval, hwSLogEudmAttackLogInterval=hwSLogEudmAttackLogInterval, PYSNMP_MODULE_ID=hwSLOGEudm, hwSLogEudmFlowLogEnableEntry=hwSLogEudmFlowLogEnableEntry, hwSLOGEudmCompliance=hwSLOGEudmCompliance, hwSLogEudmEnableHostAcl=hwSLogEudmEnableHostAcl, hwSLogEudmFlowLogMode=hwSLogEudmFlowLogMode, hwSLogInterZoneEnableCfg=hwSLogInterZoneEnableCfg, hwSLOGEudmConformance=hwSLOGEudmConformance, hwSLogEudmFlowEnableFlag=hwSLogEudmFlowEnableFlag, hwSLogFlowEnableZoneID2=hwSLogFlowEnableZoneID2, hwSLogEudmFlowLogInterval=hwSLogEudmFlowLogInterval, hwSLOGEudm=hwSLOGEudm, hwSLOGEudmGlobalCfgGroup=hwSLOGEudmGlobalCfgGroup, hwSLogEudmFlowLogEnableTable=hwSLogEudmFlowLogEnableTable, hwSLogEudmGlobalCfg=hwSLogEudmGlobalCfg)
|
# -*- coding: utf-8 -*-
"""
This source code file is licensed under the GNU General Public License Version 3.
For full details, please refer to the file "LICENSE.txt" which is provided as part of this source code package.
Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
"""
SETTING_FILENAME = 'filename'
SETTING_RECENT_FILES = 'recentFiles'
SETTING_WIN_SIZE = 'window/size'
SETTING_WIN_POSE = 'window/position'
SETTING_WIN_GEOMETRY = 'window/geometry'
SETTING_LINE_COLOR = 'line/color'
SETTING_FILL_COLOR = 'fill/color'
SETTING_ADVANCE_MODE = 'advanced'
SETTING_WIN_STATE = 'window/state'
SETTING_SAVE_DIR = 'savedir'
SETTING_PAINT_LABEL = 'paintlabel'
SETTING_LAST_OPEN_DIR = 'lastOpenDir'
SETTING_AUTO_SAVE = 'autosave'
SETTING_SINGLE_CLASS = 'singleclass'
FORMAT_PASCALVOC='PascalVOC'
FORMAT_YOLO='YOLO'
SETTING_DRAW_SQUARE = 'draw/square'
DEFAULT_ENCODING = 'utf-8'
|
class MljarException(Exception):
"""Base exception class for this module"""
pass
class TokenException(MljarException):
pass
class DataReadException(MljarException):
pass
class JSONReadException(MljarException):
pass
class NotFoundException(MljarException):
pass
class AuthenticationException(MljarException):
pass
class BadRequestException(MljarException):
pass
class BadValueException(MljarException):
pass
class UnknownProjectTask(MljarException):
pass
class IncorrectInputDataException(MljarException):
pass
class FileUploadException(MljarException):
pass
class CreateProjectException(MljarException):
pass
class CreateDatasetException(MljarException):
pass
class CreateExperimentException(MljarException):
pass
class UndefinedExperimentException(MljarException):
pass
class DatasetUnknownException(MljarException):
pass
class PredictionDownloadException(MljarException):
pass
|
class Invitation ():
def __init__(self, _id, sender, recipient):
self._id = _id
self.sender = sender
self.recipient = recipient
def __repr__(self):
return f'Invitation({self._id}, {self.sender}, {self.recipient})'
|
# coding=utf-8
"""
二叉树的前序遍历
给出一棵二叉树,返回其节点值的前序遍历。
思路:
先去了解二叉树, 再来解决问题
"""
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: A Tree
@return: Preorder in ArrayList which contains node values.
"""
def preorderTraversal(self, root):
# write your code here
if not root:
return []
ans = []
ans.append(root.val)
if root.left:
ans += self.preorderTraversal(root.left)
if root.right:
ans += self.preorderTraversal(root.right)
return ans |
class Brackets():
# You are given an expression with numbers, brackets and operators.
# For this task only the brackets matter.
# Brackets come in three flavors: "{}" "()" or "[]".
# Brackets are used to determine scope or to restrict some expression.
# If a bracket is open, then it must be closed with a closing bracket of the same type.
# The scope of a bracket must not intersected by another bracket.
# In this task you should make a decision, whether to correct an expression or not based on the brackets.
# Do not worry about operators and operands.
#
# Input:
# - An expression with different of types brackets as a string (unicode).
#
# Output:
# - A verdict on the correctness of the expression in boolean (True or False).
#
# Precondition:
# - There are only brackets ("{}" "()" or "[]"), digits or operators ("+" "-" "*" "/").
# - 0 < len(expression) < 103
def checkio(expression):
opening = '({['
closing = ')}]'
mapping = dict(zip(opening, closing))
queue = []
for letter in expression:
if letter in opening:
queue.append(mapping[letter])
elif letter in closing:
if not queue or letter != queue.pop():
return False
return not queue
#These "asserts" using only for self-checking and not necessary for auto-testing
if __name__ == '__main__':
assert checkio("((5+3)*2+1)") == True, "Simple"
assert checkio("{[(3+1)+2]+}") == True, "Different types"
assert checkio("(3+{1-1)}") == False, ") is alone inside {}"
assert checkio("[1+1]+(2*2)-{3/3}") == True, "Different operators"
assert checkio("(({[(((1)-2)+3)-3]/3}-3)") == False, "One is redundant"
assert checkio("2+3") == True, "No brackets, no problem"
print("The local tests are done.") |
logo = '''
_____ _ _ _____ _
| __|_ _ ___ ___ ___ | |_| |_ ___ | | |_ _ _____| |_ ___ ___
| | | | | -_|_ -|_ -| | _| | -_| | | | | | | | . | -_| _|
|_____|___|___|___|___| |_| |_|_|___| |_|___|___|_|_|_|___|___|_|
''' |
def test():
print('software installed')
print('a new version')
print('version update')
|
#!/usr/bin/python3
"""
DOWNLOAD ALL THE PROBLEMS OF CODE FORCE
"""
CODEF_SET_URLS = list()
CODEF_SET_URLS.append("https://codeforces.com/problemset")
CODEF_SET_URLS.append("https://codeforces.com/problemset/acmsguru")
print("Code Forces Scrapping.")
|
# The Rabin-Karp Algorithm for Pattern Searching
# uses hashing to find patterns in text
# It is O(nm)
# ascii values go up to 255, so use 256 as a large prime number
d = 256
def rk(text, pat, q):
# q is a prime number for hashing
M = len(pat)
N = len(text)
i = 0
j = 0
pHash = 0
tHash = 0
hash = 1
for i in range(0, M-1):
hash = (hash*d)%q
# calculate the hash value of the pattern
# and the window
for i in range(0, M):
pHash = (d*pHash + ord(pat[i]))%q
tHash = (d*tHash + ord(text[i]))%q
# slide the pattern over text one by one
for i in range(0, N-M+1):
# check the hash values of current window of text and pattern
# if hash values match, the check characters one by one
if pHash == tHash:
# check for characters one by one
for j in range(0, M):
if text[i+j] != pat[j]:
break
j += 1
if j == M:
print("Pattern found at index ", i)
# Calculate the hash value for the next window
# Remove leading and trailing digit
if i < N-M:
tHash = (d*(tHash-ord(text[i])*hash) + ord(text[i+M]))%q
if tHash < 0:
tHash = tHash + q
text = "TEEST AND TEEEST AND TEEEEST"
pat = "EE"
num = 101
rk(text, pat, num)
|
'''
Blind Curated 75 - Problem 56
=============================
Meeting Rooms
-------------
Given an array of meeting time intervals consisting of start and end times, find
whether it is possible for one person to attend all meetings.
[→ LintCode][1]
[1]: https://www.lintcode.com/problem/meeting-rooms/description
'''
class Interval():
def __init__(self, start, end):
self.start = start
self.end = end
def solution(intervals):
'''
Sort the intervals by start time.
'''
intervals.sort(key=lambda x: x.start)
for a, b in zip(intervals, intervals[1:]):
if b.start < a.end:
return False
return True
|
#!/usr/bin/env python3
### PRIME FACTORIZATION ###
# The program make the user enter a number and find all prime factors (if there are any) and display them.
# Firstly, we define "factors", "prime" and "prime_factors".
factors = lambda a: [n for n in range(1, a + 1) if not a % n]
prime = lambda a: len(factors(a)) == 2
prime_factors = lambda a: list(filter(prime, factors(a)))
# Then, we create the prime factorization function.
def primefact(a):
a = int(a)
x = prime_factors(a)
if prime(a):
return str(a)
else:
return str(x[0]) + '*' + primefact(a / x[0])
if __name__ == '__main__':
print("Welcome to the Prime Factorization program! Please enter a number to continue or 'exit' to leave.")
num = 0
while True:
if num:
print(primefact(num))
print(">>>",end='')
num = input()
if num == 'exit':
break
|
t=int(input())
while(t>0):
t=t-1
n,k=map(int,input().split())
n1=n
k1=k
l=[]
while(k1>1):
if(n%k!=0):
firstn=int(n/k)+1
elif(k==2):
firstn=int(n/2)+1
else:
firstn=int(n/k)
l.append(firstn)
n=n-firstn
k1=k1-1
l.append(n)
if(n1==(k*(k+1)/2)):
print('0')
elif(n1<(k*(k+1)/2)):
print('-1')
elif(k>=n1):
print('-1')
else:
l1=[i*i-i for i in l]
p=1
for i in l1:
p*=i
print(p%((10**9)+7))
|
expected_output = {
"vrf": {
"default": {
"associations": {
"address": {
"172.31.32.2": {
"local_mode": {
"active": {
"isconfigured": {
"True": {
"selected": False,
"unsynced": False,
"address": "172.31.32.2",
"isconfigured": True,
"authenticated": False,
"sane": False,
"valid": False,
"master": False,
"stratum": 5,
"refid": "172.31.32.1",
"input_time": "AFE252C1.6DBDDFF2 (00:12:01.428 PDT Mon Jul 5 1993)",
"peer_interface": "172.31.32.1",
"poll": "1024",
"vrf": "default",
"local_mode": "active",
"peer": {
"172.31.32.1": {
"local_mode": {
"active": {
"poll": 64,
"local_mode": "active",
}
}
}
},
"root_delay_msec": "137.77",
"root_disp": "142.75",
"reach": "376",
"sync_dist": "215.363",
"delay_msec": "4.23",
"offset_msec": "-8.587",
"dispersion": "1.62",
"jitter_msec": "None",
"precision": "2**19",
"version": 4,
"assoc_name": "192.168.1.55",
"assoc_id": 1,
"ntp_statistics": {
"packet_received": 60,
"packet_sent": 60,
"packet_dropped": 0,
},
"originate_time": "AFE252E2.3AC0E887 (00:12:34.229 PDT Tue Oct 4 2011)",
"receive_time": "AFE252E2.3D7E464D (00:12:34.240 PDT Mon Jan 1 1900)",
"transmit_time": "AFE25301.6F83E753 (00:13:05.435 PDT Tue Oct 4 2011)",
"filtdelay": "4.23 4.14 2.41 5.95 2.37 2.33 4.26 4.33",
"filtoffset": "-8.59 -8.82 -9.91 -8.42 -10.51 -10.77 -10.13 -10.11",
"filterror": "0.50 1.48 2.46 3.43 4.41 5.39 6.36 7.34",
}
}
}
}
},
"192.168.13.33": {
"local_mode": {
"client": {
"isconfigured": {
"True": {
"selected": True,
"unsynced": False,
"address": "192.168.13.33",
"isconfigured": True,
"authenticated": False,
"sane": True,
"valid": True,
"master": False,
"stratum": 3,
"refid": "192.168.1.111",
"input_time": "AFE24F0E.14283000 (23:56:14.078 PDT Sun Jul 4 1993)",
"peer_interface": "192.168.1.111",
"poll": "128",
"vrf": "default",
"local_mode": "client",
"peer": {
"192.168.1.111": {
"local_mode": {
"server": {
"poll": 128,
"local_mode": "server",
}
}
}
},
"root_delay_msec": "83.72",
"root_disp": "217.77",
"reach": "377",
"sync_dist": "264.633",
"delay_msec": "4.07",
"offset_msec": "3.483",
"dispersion": "2.33",
"jitter_msec": "None",
"precision": "2**6",
"version": 3,
"assoc_name": "myserver",
"assoc_id": 2,
"ntp_statistics": {
"packet_received": 0,
"packet_sent": 0,
"packet_dropped": 0,
},
"originate_time": "AFE252B9.713E9000 (00:11:53.442 PDT Tue Oct 4 2011)",
"receive_time": "AFE252B9.7124E14A (00:11:53.441 PDT Mon Jan 1 1900)",
"transmit_time": "AFE252B9.6F625195 (00:11:53.435 PDT Mon Jan 1 1900)",
"filtdelay": "6.47 4.07 3.94 3.86 7.31 7.20 9.52 8.71",
"filtoffset": "3.63 3.48 3.06 2.82 4.51 4.57 4.28 4.59",
"filterror": "0.00 1.95 3.91 4.88 5.84 6.82 7.80 8.77",
}
}
}
}
},
"192.168.13.57": {
"local_mode": {
"client": {
"isconfigured": {
"True": {
"selected": False,
"unsynced": False,
"address": "192.168.13.57",
"isconfigured": True,
"authenticated": False,
"sane": True,
"valid": True,
"master": True,
"stratum": 3,
"refid": "192.168.1.111",
"input_time": "AFE252DC.1F2B3000 (00:12:28.121 PDT Mon Jul 5 1993)",
"peer_interface": "192.168.1.111",
"poll": "128",
"vrf": "default",
"local_mode": "client",
"peer": {
"192.168.1.111": {
"local_mode": {
"server": {
"poll": 128,
"local_mode": "server",
}
}
}
},
"root_delay_msec": "125.50",
"root_disp": "115.80",
"reach": "377",
"sync_dist": "186.157",
"delay_msec": "7.86",
"offset_msec": "11.176",
"dispersion": "3.62",
"jitter_msec": "None",
"precision": "2**6",
"version": 2,
"assoc_name": "myserver",
"assoc_id": 2,
"ntp_statistics": {
"packet_received": 0,
"packet_sent": 0,
"packet_dropped": 0,
},
"originate_time": "AFE252DE.77C29000 (00:12:30.467 PDT Tue Oct 4 2011)",
"receive_time": "AFE252DE.7B2AE40B (00:12:30.481 PDT Mon Jan 1 1900)",
"transmit_time": "AFE252DE.6E6D12E4 (00:12:30.431 PDT Mon Jan 1 1900)",
"filtdelay": "49.21 7.86 8.18 8.80 4.30 4.24 7.58 6.42",
"filtoffset": "11.30 11.18 11.13 11.28 8.91 9.09 9.27 9.57",
"filterror": "0.00 1.95 3.91 4.88 5.78 6.76 7.74 8.71",
}
}
}
}
},
}
}
}
}
}
|
"""Test User API resources"""
def test_user_list__get_200(app, client, db, user):
res = client.get("/users/")
res_json = res.get_json()
assert res.status_code == 200
assert len(res_json) == 1
assert res_json[0]["id"] == str(user.id)
def test_user_list__post_200(app, client, db):
payload = [{"email": "gandalf@gmail.com", "password": "MinesofMoria68"}]
res = client.post("/users/", json=payload)
res_json = res.get_json()
assert res.status_code == 200
assert len(res_json) == 1
def test_user_list__post_422(app, client, db):
payload = [{"i_should_not_be_here": "me_too"}]
res = client.post("/users/", json=payload)
assert res.status_code == 422
|
"""
expo.commands.app
~~~~~~~~~~~~~~~~~
hikari Application Command Handler.
:copyright: 2022 VincentRPS
:license: Apache-2.0
"""
# This is a COMING-SOON feature.
# it shouldn't be priority currently.
|
"""
Utils functions
"""
def print_bytes_int(value):
array = []
for val in value:
array.append(val)
print(array)
def print_bytes_bit(value):
array = []
for val in value:
for j in range(7, -1, -1):
array.append((val >> j) % 2)
print(array)
|
class Solution:
def isMatch(self, s: str, p: str) -> bool:
if not p: return not s
first_match = bool(s) and p[0] in {s[0], '.'}
if len(p) >= 2 and p[1] == '*':
return (self.isMatch(s, p[2:]) or first_match and self.isMatch(s[1:], p))
else:
return first_match and self.isMatch(s[1:], p[1:])
s = Solution()
print(s.isMatch("aa", "a"))
# bool 运算可以将内容进行布尔运算,如果为空内容 ""/0/None/False/[]/{}/(),那么输出为False
# 拓展:如果 p="" 为空,那么 not p == True
# print(bool("ads"))
# print("a" in {"a", '.'})
print((True or False) and False)
|
school = {
"Cavell": ["Claim"],
"Master": ["Austin1975", "Wittgenstein2009"],
"Most cited": [
"Burge2010",
"Davidson2013",
"Dummett1973",
"Fodor1983",
"Frege1948",
"Kripke1980",
"Lewis2002",
"Putnam2004",
"Quine2013",
"Russell1967",
"Williamson2002",
"Wright1992",
],
"Anti-teorethical": [
"Anscombe",
"Baier1991",
"Diamond1995",
"Foot2002",
"MacIntyre2007",
"McDowell1994",
"Murdoch2013",
"Williams2011",
"Winch1990",
],
}
print("\\begin{center}\n\\begin{tabular}{|r l l|}")
print("\\hline")
print("Author & Title & Category \\\\")
print("\\hline")
for cat in school.keys():
for bib in school[cat]:
print("\\citeauthor{" + bib + "} & \\citetitle{" + bib + "} & " + cat + " \\\\")
print("\\hline")
print("\\end{tabular}\n\\end{center}")
year = {
"must_we_mean_what_we_say": 1969,
"the_claim_of_reason_1": "1972, 1979",
"the_senses_of_walden_1": "1972, 1980",
"the_world_viewed_1": "1971, 1979",
"pursuits_of_happiness": 1981,
"themes_out_of_school": 1984,
"a_pitch_of_philosophy": 1994,
"cities_of_words": 2004,
"conditions_handsome_and_unhandsome": 1990,
"contesting_tears": 1996,
"in_quest_of_the_ordinary": 1988,
"philosophical_passages": 1995,
"this_new_yet_unapproachable_america": 1988,
"little_did_i_know": 2010,
"philosophy_the_day_after": 2005,
}
bibs = {
"must_we_mean_what_we_say": "Must",
"the_claim_of_reason_1": "Claim",
"the_senses_of_walden_1": "Senses",
"the_world_viewed_1": "World",
"pursuits_of_happiness": "Pursuits",
"themes_out_of_school": "Themes",
"a_pitch_of_philosophy": "aPitch",
"cities_of_words": "Cities",
"conditions_handsome_and_unhandsome": "Conditions",
"contesting_tears": "Contesting",
"in_quest_of_the_ordinary": "inQuest",
"philosophical_passages": "Philosophical",
"this_new_yet_unapproachable_america": "thisNew",
"little_did_i_know": "Little",
"philosophy_the_day_after": "Philosophy",
}
print("\\begin{center}\n\\begin{tabular}{|r l l|}")
print("\\hline")
print("Title & 1st and enlarged Editions & Used Edition \\\\")
print("\\hline")
for bib in bibs.keys():
print(
"\\citetitle{"
+ bibs[bib]
+ "} & \\ "
+ str(year[bib])
+ " & \\citeyear{"
+ bibs[bib]
+ "} \\\\"
)
print("\\hline")
print("\\end{tabular}\n\\end{center}")
|
print("{}, {}, {}".format("a", "b", "c")) #By default position; most common
print("{2}, {1}, {0}".format("a", "b", "c")) #By numbered position
print("Coordinates: {latitude}, {longitude}".format(latitude="37.24N", longitude="-115.81W")) #By name; automatically handles format
print("Coordinates: {latitude}, {longitude}".format(latitude="37.24", longitude="-115.81")) #Automatically handles number types
name = "Camelot"
print(f"Look, it's {name}!") #f-string
# f-string calling function
def to_lowercase(value):
return value.lower()
print(f"That model looks like {to_lowercase(name)}.")
|
##########################################################
# Author: Raghav Sikaria
# LinkedIn: https://www.linkedin.com/in/raghavsikaria/
# Github: https://github.com/raghavsikaria
# Last Update: 12-5-2020
# Project: LeetCode May 31 Day 2020 Challenge - Day 12
##########################################################
# QUESTION
# This question is from the abovementioned challenge and can be found here on LeetCode: https://leetcode.com/explore/featured/card/may-leetcoding-challenge/535/week-2-may-8th-may-14th/3327/
############################################################################
# You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once. Find this single element that appears only once.
# Example 1:
# Input: [1,1,2,3,3,4,4,8,8]
# Output: 2
# Example 2:
# Input: [3,3,7,7,10,11,11]
# Output: 10
# Note: Your solution should run in O(log n) time and O(1) space.
############################################################################
# ACCEPTED SOLUTION #1
# This solution ensures O(n) Time and O(1) Space Complexity
# XOR Approach
# NOTE: But here we don't make use of the information
# that the Array is sorted
class Solution:
def singleNonDuplicate(self, nums: List[int]) -> int:
answer = 0
for i in nums: answer ^= i
return answer
# ACCEPTED SOLUTION #2
# MODIFIED Binary Search
# PERSONAL COMMENTS: Had never modified a Binary Search for
# this type of use. Blew my mind completely.
# [NEW LEARNING][SOURCE]: https://www.geeksforgeeks.org/find-the-element-that-appears-once-in-a-sorted-array/
class Solution_:
def singleNonDuplicate(self, nums: List[int]) -> int:
answer = -1
low = 0
high = len(nums) - 1
while low <= high:
if low == high:
answer = nums[low]
break
mid = low + (high - low)//2
if mid%2 == 0:
if nums[mid] == nums[mid+1]: low = mid + 2
else: high = mid
else:
if nums[mid] == nums[mid-1]: low = mid + 1
else: high = mid - 1
return answer |
"""
Program: momentum.py
Project 2.11
Given an object's mass and velocity, compute its momentum
and kinetic energy.
"""
# Request the input
mass = float(input("Enter the object's mass: "))
velocity = float(input("Enter the object's velocity: "))
# Compute the results
momentum = mass * velocity
kineticEnergy = (mass * velocity ** 2) / 2
# Display the results
print("The object's momentum is", momentum)
print("The object's kinetic energy is", kineticEnergy)
|
def usuario_escolhe_jogada(n,m):
while n<=m:
print("Oops! Jogada inválida! Tente de novo")
n=int(input("Digite novamente o n"))
m=int (input("Digite novamente o m"))
jm=0
jm=int(input("Qual e o numero(s) de peça(s) retirada(s): "))
while jm>m or jm<=0:
print("Oops! Jogada inválida! Tente de novo")
jm=int(input("Qual e o numero(s) de peça(s) retirada(s): " ))
if jm<=m:
print("O jogador tirou",jm,"peça(a)")
n=n-jm
return jm
#devolver apenas o numero de peças removidas
def computador_escolhe_jogada (n,m):
#n= Quantas peças?
#m= Limite de peças por jogada?
mt=m+1
x=0 #numero retirado de peça(s)
s=n
while x<m:
x+=1
if(n-x)%mt==0:
print ("O computador tirou",x,"peça(s).")
n-=x
return x
#print ("O computador tirou",m,"peça(s).")
x=m
print ("O computador tirou",x,"peça(s).")
n=n-x
return x
def partida():
n=int(input("Quantas peças?"))
m=int(input("Limite de peças por jogada?"))
mt=m+1
jm=0
x=0
if n%mt==0:
print("Você começa!") #usuario_escolhe_jogada(n,m)
while n>0:
jm=usuario_escolhe_jogada(n,m)
n-=jm
x=computador_escolhe_jogada(n,m)
n-=x
print ("Fim do jogo! Você ganhou, que legal")
else:
print("Computador começa!") #computador_escolhe_jogada(n,m)
while n>0:
x=computador_escolhe_jogada(n,m)
n-=x
if n==0:
print ("Fim do jogo! O computador ganhou, que pena!")
else: jm=usuario_escolhe_jogada(n,m)
n-=jm
def campeonato():
print("**** Rodada 1 ****")
partida()
print("**** Rodada 2 ****")
partida()
print("**** Rodada 3 ****")
partida()
print("******* Final do campeonato! ****")
print("Placar: Você 0 X 3 Computador")
#def man():
print ("Bem-vindo ao jogo do NIM! Escolha: ")
camp=int(input("1 - para jogar uma partida isolada \n2 - para jogar um campeonato\n"))
while camp<1 or camp>2:
print ("informe uma opção válida!")
camp=int(input("1 - para jogar uma partida isolada \n2 - para jogar um campeonato\n"))
if camp==1:
print("Você escolheu uma partida isolada!")
partida()
if camp==2:
print("Voce escolheu um campeonato!")
campeonato()
|
def gb_syn():
return [
['MT-CO1','cox1','COX1','COI','coi','cytochome oxidase 1','cytochome oxidase I',
'cytochome oxidase subunit 1','cytochome oxidase subunit I',
'cox I','coxI', 'cytochrome c oxidase subunit I','CO1','cytochrome oxidase subunit 1',
'cytochrome oxidase subunit I'],
['MT-CO2','cox2','COX2','COII','coii','cytochome oxidase 2','cytochome oxidase II',
'cytochome oxidase subunit 2','cytochome oxidase subunit II','cox II',
'cytochrome c oxidase subunit II'],
['MT-CO3','cox3','COX3','COIII','coiii','cytochome oxidase 3',
'cytochome oxidase III','cytochome oxidase subunit 3','cytochome oxidase subunit III'
,'cox III','cytochrome c oxidase subunit III'],
['18s','18S','SSU rRNA','18S ribosomal RNA','small subunit 18S ribosomal RNA', '18S rRNA'],
['28s','28S','LSU rRNA','28S ribosomal RNA','28S large subunit ribosomal RNA'],
['MT-ATP6','atp6','ATP6','atpase6','atpase 6','ATPase6','ATPASE6'],
['MT-ATP8','atp8','ATP8','atpase8','atpase 8','ATPase8','ATPASE8'],
['ATP9','atp9'],
['MT-CYB','cytochrome-b','cytb','CYTB','Cytb', 'cytochrome B','cytochrome b','Cb',
'CytB','Cyt_B','Cyt_b','cytB','cyt_b'],
['ef1a','Ef1a', 'elongation factor 1-alpha','elongation factor-1 alpha',
'ef1-alpha','elongation factor 1 alpha'],
['MT-ND1','nd1','ND1','nadh1','NADH1','nadh 1','NADH 1',
'NADH dehydrogenase subunit 1','NADH dehydrogenase subunit I','nad1','nadh1'],
['MT-ND2','nd2','ND2','nadh2','NADH2','nadh 2','NADH 2','NADH dehydrogenase subunit 2',
'NADH dehydrogenase subunit II','nad2','nadh2'],
['MT-ND3','nd3','ND3','nadh3','NADH3','nadh 3','NADH 3','NADH dehydrogenase subunit 3',
'NADH dehydrogenase subunit III','nad3','nadh3'],
['MT-ND4','nd4','ND4','nadh4','NADH4','nadh 4','NADH 4','NADH dehydrogenase subunit 4',
'NADH dehydrogenase subunit IV','nad4','nadh4'],
['MT-ND4L','nd4l','ND4L','nad4l','nadh4l', 'nadh4L', 'NADH dehydrogenase subunit 4l',
'NADH dehydrogenase subunit 4L'],
['MT-ND5','nd5','ND5','nad5', 'nadh5','NADH5','nadh 5','NADH 5','NADH dehydrogenase subunit 5',
'NADH dehydrogenase subunit V'],
['MT-ND6','nd6','ND6','nad6','nadh6','NADH6','nadh 6','NADH 6','NADH dehydrogenase subunit 6',
'NADH dehydrogenase subunit VI'],
['rrnS','12srRNA','12s rRNA','12S ribosomal RNA','12S rRNA','12S r RNA',
'12S small subunit ribosomal RNA','12 S rRNA','rrns','s-rRNA'],
['rrnL','16srRNA','16s rRNA','16S ribosomal RNA','16S rRNA'],
['C_mos', 'C-mos','c-mos','C-MOS'],
['GAPDH','gapdh'],
['RNApol2','RNApolII','RNA polymerase II']
] |
BACKUP = {
# MAIN USER ID: BACKUP USER ID
# MAIN CHAT ID: BACKUP CHAT ID
-1001111111111: -1002222222222,
}
DEBUG = False # log outgoing events
|
"""data_index contains all of the quantities calculated by the compute functions.
label = (str) Title of the quantity in LaTeX format.
units = (str) Units of the quantity in LaTeX format.
units_long (str) Full units without abbreviations.
description (str) Description of the quantity.
fun = (str) Function name in compute_funs.py that computes the quantity.
dim = (int) Dimension of the quantity: 0-D, 1-D, or 3-D.
"""
data_index = {}
# flux coordinates
data_index["rho"] = {
"label": "\\rho",
"units": "~",
"units_long": "None",
"description": "Radial coordinate, proportional to the square root of the toroidal flux",
"fun": "compute_flux_coords",
"dim": 1,
}
data_index["theta"] = {
"label": "\\theta",
"units": "rad",
"units_long": "radians",
"description": "Poloidal angular coordinate (geometric, not magnetic)",
"fun": "compute_flux_coords",
"dim": 1,
}
data_index["zeta"] = {
"label": "\\zeta",
"units": "rad",
"units_long": "radians",
"description": "Toroidal angular coordinate, equal to the geometric toroidal angle",
"fun": "compute_flux_coords",
"dim": 1,
}
# toroidal flux
data_index["psi"] = {
"label": "\\psi = \\Psi / (2 \\pi)",
"units": "Wb",
"units_long": "Webers",
"description": "Toroidal flux",
"fun": "compute_toroidal_flux",
"dim": 1,
}
data_index["psi_r"] = {
"label": "\\psi' = \\partial_{\\rho} \\Psi / (2 \\pi)",
"units": "Wb",
"units_long": "Webers",
"description": "Toroidal flux, first radial derivative",
"fun": "compute_toroidal_flux",
"dim": 1,
}
data_index["psi_rr"] = {
"label": "\\psi'' = \\partial_{\\rho\\rho} \\Psi / (2 \\pi)",
"units": "Wb",
"units_long": "Webers",
"description": "Toroidal flux, second radial derivative",
"fun": "compute_toroidal_flux",
"dim": 1,
}
# R
data_index["R"] = {
"label": "R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
data_index["R_r"] = {
"label": "\\partial_{\\rho} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, first radial derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 0, 0]],
}
data_index["R_t"] = {
"label": "\\partial_{\\theta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, first poloidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 1, 0]],
}
data_index["R_z"] = {
"label": "\\partial_{\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, first toroidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 1]],
}
data_index["R_rr"] = {
"label": "\\partial_{\\rho\\rho} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, second radial derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[2, 0, 0]],
}
data_index["R_tt"] = {
"label": "\\partial_{\\theta\\theta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, second poloidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 2, 0]],
}
data_index["R_zz"] = {
"label": "\\partial_{\\zeta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, second toroidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 2]],
}
data_index["R_rt"] = {
"label": "\\partial_{\\rho\\theta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, second derivative wrt to radius and poloidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 1, 0]],
}
data_index["R_rz"] = {
"label": "\\partial_{\\rho\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, second derivative wrt to radius and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 0, 1]],
}
data_index["R_tz"] = {
"label": "\\partial_{\\theta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, second derivative wrt to poloidal and toroidal angles",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 1, 1]],
}
data_index["R_rrr"] = {
"label": "\\partial_{\\rho\\rho\\rho} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third radial derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[3, 0, 0]],
}
data_index["R_ttt"] = {
"label": "\\partial_{\\theta\\theta\\theta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third poloidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 3, 0]],
}
data_index["R_zzz"] = {
"label": "\\partial_{\\zeta\\zeta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third toroidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 3]],
}
data_index["R_rrt"] = {
"label": "\\partial_{\\rho\\rho\\theta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative, wrt to radius twice and poloidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[2, 1, 0]],
}
data_index["R_rtt"] = {
"label": "\\partial_{\\rho\\theta\\theta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative wrt to radius and poloidal angle twice",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 2, 0]],
}
data_index["R_rrz"] = {
"label": "\\partial_{\\rho\\rho\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative wrt to radius twice and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[2, 0, 1]],
}
data_index["R_rzz"] = {
"label": "\\partial_{\\rho\\zeta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative wrt to radius and toroidal angle twice",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 0, 2]],
}
data_index["R_ttz"] = {
"label": "\\partial_{\\theta\\theta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative wrt to poloidal angle twice and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 2, 1]],
}
data_index["R_tzz"] = {
"label": "\\partial_{\\theta\\zeta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative wrt to poloidal angle and toroidal angle twice",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 1, 2]],
}
data_index["R_rtz"] = {
"label": "\\partial_{\\rho\\theta\\zeta} R",
"units": "m",
"units_long": "meters",
"description": "Major radius in lab frame, third derivative wrt to radius, poloidal angle, and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 1, 1]],
}
# Z
data_index["Z"] = {
"label": "Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
data_index["Z_r"] = {
"label": "\\partial_{\\rho} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, first radial derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 0, 0]],
}
data_index["Z_t"] = {
"label": "\\partial_{\\theta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, first poloidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 1, 0]],
}
data_index["Z_z"] = {
"label": "\\partial_{\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, first toroidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 1]],
}
data_index["Z_rr"] = {
"label": "\\partial_{\\rho\\rho} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, second radial derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[2, 0, 0]],
}
data_index["Z_tt"] = {
"label": "\\partial_{\\theta\\theta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, second poloidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 2, 0]],
}
data_index["Z_zz"] = {
"label": "\\partial_{\\zeta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, second toroidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 2]],
}
data_index["Z_rt"] = {
"label": "\\partial_{\\rho\\theta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, second derivative wrt to radius and poloidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 1, 0]],
}
data_index["Z_rz"] = {
"label": "\\partial_{\\rho\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, second derivative wrt to radius and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 0, 1]],
}
data_index["Z_tz"] = {
"label": "\\partial_{\\theta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, second derivative wrt to poloidal and toroidal angles",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 1, 1]],
}
data_index["Z_rrr"] = {
"label": "\\partial_{\\rho\\rho\\rho} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third radial derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[3, 0, 0]],
}
data_index["Z_ttt"] = {
"label": "\\partial_{\\theta\\theta\\theta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third poloidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 3, 0]],
}
data_index["Z_zzz"] = {
"label": "\\partial_{\\zeta\\zeta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third toroidal derivative",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 0, 3]],
}
data_index["Z_rrt"] = {
"label": "\\partial_{\\rho\\rho\\theta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative, wrt to radius twice and poloidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[2, 1, 0]],
}
data_index["Z_rtt"] = {
"label": "\\partial_{\\rho\\theta\\theta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative wrt to radius and poloidal angle twice",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 2, 0]],
}
data_index["Z_rrz"] = {
"label": "\\partial_{\\rho\\rho\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative wrt to radius twice and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[2, 0, 1]],
}
data_index["Z_rzz"] = {
"label": "\\partial_{\\rho\\zeta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative wrt to radius and toroidal angle twice",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 0, 2]],
}
data_index["Z_ttz"] = {
"label": "\\partial_{\\theta\\theta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative wrt to poloidal angle twice and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 2, 1]],
}
data_index["Z_tzz"] = {
"label": "\\partial_{\\theta\\zeta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative wrt to poloidal angle and toroidal angle twice",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[0, 1, 2]],
}
data_index["Z_rtz"] = {
"label": "\\partial_{\\rho\\theta\\zeta} Z",
"units": "m",
"units_long": "meters",
"description": "Vertical coordinate in lab frame, third derivative wrt to radius, poloidal angle, and toroidal angle",
"fun": "compute_toroidal_coords",
"dim": 1,
"R_derivs": [[1, 1, 1]],
}
# cartesian coordinates
data_index["phi"] = {
"label": "\\phi = \\zeta",
"units": "rad",
"units_long": "radians",
"description": "Toroidal angle in lab frame",
"fun": "compute_cartesian_coords",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
data_index["X"] = {
"label": "X = R \\cos{\\phi}",
"units": "m",
"units_long": "meters",
"description": "Cartesian X coordinate",
"fun": "compute_cartesian_coords",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
data_index["Y"] = {
"label": "Y = R \\sin{\\phi}",
"units": "m",
"units_long": "meters",
"description": "Cartesian Y coordinate",
"fun": "compute_cartesian_coords",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
# lambda
data_index["lambda"] = {
"label": "\\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 0, 0]],
}
data_index["lambda_r"] = {
"label": "\\partial_{\\rho} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, first radial derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[1, 0, 0]],
}
data_index["lambda_t"] = {
"label": "\\partial_{\\theta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, first poloidal derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 1, 0]],
}
data_index["lambda_z"] = {
"label": "\\partial_{\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, first toroidal derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 0, 1]],
}
data_index["lambda_rr"] = {
"label": "\\partial_{\\rho\\rho} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, second radial derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[2, 0, 0]],
}
data_index["lambda_tt"] = {
"label": "\\partial_{\\theta\\theta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, second poloidal derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 2, 0]],
}
data_index["lambda_zz"] = {
"label": "\\partial_{\\zeta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, second toroidal derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 0, 2]],
}
data_index["lambda_rt"] = {
"label": "\\partial_{\\rho\\theta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, second derivative wrt to radius and poloidal angle",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[1, 1, 0]],
}
data_index["lambda_rz"] = {
"label": "\\partial_{\\rho\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, second derivative wrt to radius and toroidal angle",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[1, 0, 1]],
}
data_index["lambda_tz"] = {
"label": "\\partial_{\\theta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, second derivative wrt to poloidal and toroidal angles",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 1, 1]],
}
data_index["lambda_rrr"] = {
"label": "\\partial_{\\rho\\rho\\rho} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third radial derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[3, 0, 0]],
}
data_index["lambda_ttt"] = {
"label": "\\partial_{\\theta\\theta\\theta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third poloidal derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 3, 0]],
}
data_index["lambda_zzz"] = {
"label": "\\partial_{\\zeta\\zeta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third toroidal derivative",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 0, 3]],
}
data_index["lambda_rrt"] = {
"label": "\\partial_{\\rho\\rho\\theta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative, wrt to radius twice and poloidal angle",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[2, 1, 0]],
}
data_index["lambda_rtt"] = {
"label": "\\partial_{\\rho\\theta\\theta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative wrt to radius and poloidal angle twice",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[1, 2, 0]],
}
data_index["lambda_rrz"] = {
"label": "\\partial_{\\rho\\rho\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative wrt to radius twice and toroidal angle",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[2, 0, 1]],
}
data_index["lambda_rzz"] = {
"label": "\\partial_{\\rho\\zeta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative wrt to radius and toroidal angle twice",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[1, 0, 2]],
}
data_index["lambda_ttz"] = {
"label": "\\partial_{\\theta\\theta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative wrt to poloidal angle twice and toroidal angle",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 2, 1]],
}
data_index["lambda_tzz"] = {
"label": "\\partial_{\\theta\\zeta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative wrt to poloidal angle and toroidal angle twice",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[0, 1, 2]],
}
data_index["lambda_rtz"] = {
"label": "\\partial_{\\rho\\theta\\zeta} \\lambda",
"units": "rad",
"units_long": "radians",
"description": "Poloidal stream function, third derivative wrt to radius, poloidal angle, and toroidal angle",
"fun": "compute_lambda",
"dim": 1,
"L_derivs": [[1, 1, 1]],
}
# pressure
data_index["p"] = {
"label": "p",
"units": "Pa",
"units_long": "Pascal",
"description": "Pressure",
"fun": "compute_pressure",
"dim": 1,
}
data_index["p_r"] = {
"label": "\\partial_{\\rho} p",
"units": "Pa",
"units_long": "Pascal",
"description": "Pressure, first radial derivative",
"fun": "compute_pressure",
"dim": 1,
}
# rotational transform
data_index["iota"] = {
"label": "\\iota",
"units": "~",
"units_long": "None",
"description": "Rotational transform",
"fun": "compute_rotational_transform",
"dim": 1,
}
data_index["iota_r"] = {
"label": "\\partial_{\\rho} \\iota",
"units": "~",
"units_long": "None",
"description": "Rotational transform, first radial derivative",
"fun": "compute_rotational_transform",
"dim": 1,
}
data_index["iota_rr"] = {
"label": "\\partial_{\\rho\\rho} \\iota",
"units": "~",
"units_long": "None",
"description": "Rotational transform, second radial derivative",
"fun": "compute_rotational_transform",
"dim": 1,
}
# covariant basis
data_index["e_rho"] = {
"label": "\\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 0, 0]],
}
data_index["e_theta"] = {
"label": "\\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 1, 0]],
}
data_index["e_zeta"] = {
"label": "\\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 0, 0], [0, 0, 1]],
}
data_index["e_rho_r"] = {
"label": "\\partial_{\\rho} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, derivative wrt radial coordinate",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[2, 0, 0]],
}
data_index["e_rho_t"] = {
"label": "\\partial_{\\theta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, derivative wrt poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 1, 0]],
}
data_index["e_rho_z"] = {
"label": "\\partial_{\\zeta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, derivative wrt toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 0, 1]],
}
data_index["e_theta_r"] = {
"label": "\\partial_{\\rho} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, derivative wrt radial coordinate",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 1, 0]],
}
data_index["e_theta_t"] = {
"label": "\\partial_{\\theta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, derivative wrt poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 2, 0]],
}
data_index["e_theta_z"] = {
"label": "\\partial_{\\zeta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, derivative wrt toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 1, 1]],
}
data_index["e_zeta_r"] = {
"label": "\\partial_{\\rho} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, derivative wrt radial coordinate",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 0, 0], [1, 0, 1]],
}
data_index["e_zeta_t"] = {
"label": "\\partial_{\\theta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, derivative wrt poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 1, 0], [0, 1, 1]],
}
data_index["e_zeta_z"] = {
"label": "\\partial_{\\zeta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, derivative wrt toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 0, 1], [0, 0, 2]],
}
data_index["e_rho_rr"] = {
"label": "\\partial_{\\rho\\rho} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, second derivative wrt radial coordinate",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[3, 0, 0]],
}
data_index["e_rho_tt"] = {
"label": "\\partial_{\\theta\\theta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, second derivative wrt poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 2, 0]],
}
data_index["e_rho_zz"] = {
"label": "\\partial_{\\zeta\\zeta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, second derivative wrt toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 0, 2]],
}
data_index["e_rho_rt"] = {
"label": "\\partial_{\\rho\\theta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, second derivative wrt radial coordinate and poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[2, 1, 0]],
}
data_index["e_rho_rz"] = {
"label": "\\partial_{\\rho\\zeta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, second derivative wrt radial coordinate and toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[2, 1, 0]],
}
data_index["e_rho_tz"] = {
"label": "\\partial_{\\theta\\zeta} \\mathbf{e}_{\\rho}",
"units": "m",
"units_long": "meters",
"description": "Covariant radial basis vector, second derivative wrt poloidal and toroidal angles",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 1, 1]],
}
data_index["e_theta_rr"] = {
"label": "\\partial_{\\rho\\rho} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, second derivative wrt radial coordinate",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[2, 1, 0]],
}
data_index["e_theta_tt"] = {
"label": "\\partial_{\\theta\\theta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, second derivative wrt poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 3, 0]],
}
data_index["e_theta_zz"] = {
"label": "\\partial_{\\zeta\\zeta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, second derivative wrt toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 1, 2]],
}
data_index["e_theta_rt"] = {
"label": "\\partial_{\\rho\\theta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, second derivative wrt radial coordinate and poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 2, 0]],
}
data_index["e_theta_rz"] = {
"label": "\\partial_{\\rho\\zeta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, second derivative wrt radial coordinate and toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 1, 1]],
}
data_index["e_theta_tz"] = {
"label": "\\partial_{\\theta\\zeta} \\mathbf{e}_{\\theta}",
"units": "m",
"units_long": "meters",
"description": "Covariant poloidal basis vector, second derivative wrt poloidal and toroidal angles",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 2, 1]],
}
data_index["e_zeta_rr"] = {
"label": "\\partial_{\\rho\\rho} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, second derivative wrt radial coordinate",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[2, 0, 0], [2, 0, 1]],
}
data_index["e_zeta_tt"] = {
"label": "\\partial_{\\theta\\theta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, second derivative wrt poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 2, 0], [0, 2, 1]],
}
data_index["e_zeta_zz"] = {
"label": "\\partial_{\\zeta\\zeta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, second derivative wrt toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 0, 2], [0, 0, 3]],
}
data_index["e_zeta_rt"] = {
"label": "\\partial_{\\rho\\theta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, second derivative wrt radial coordinate and poloidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 1, 0], [1, 1, 1]],
}
data_index["e_zeta_rz"] = {
"label": "\\partial_{\\rho\\zeta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, second derivative wrt radial coordinate and toroidal angle",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[1, 0, 1], [1, 0, 2]],
}
data_index["e_zeta_tz"] = {
"label": "\\partial_{\\theta\\zeta} \\mathbf{e}_{\\zeta}",
"units": "m",
"units_long": "meters",
"description": "Covariant toroidal basis vector, second derivative wrt poloidal and toroidal angles",
"fun": "compute_covariant_basis",
"dim": 3,
"R_derivs": [[0, 1, 1], [0, 1, 2]],
}
# contravariant basis
data_index["e^rho"] = {
"label": "\\mathbf{e}^{\\rho}",
"units": "m^{-1}",
"units_long": "inverse meters",
"description": "Contravariant radial basis vector",
"fun": "compute_contravariant_basis",
"dim": 3,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["e^theta"] = {
"label": "\\mathbf{e}^{\\theta}",
"units": "m^{-1}",
"units_long": "inverse meters",
"description": "Contravariant poloidal basis vector",
"fun": "compute_contravariant_basis",
"dim": 3,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["e^zeta"] = {
"label": "\\mathbf{e}^{\\zeta}",
"units": "m^{-1}",
"units_long": "inverse meters",
"description": "Contravariant toroidal basis vector",
"fun": "compute_contravariant_basis",
"dim": 3,
"R_derivs": [[0, 0, 0]],
}
# Jacobian
data_index["sqrt(g)"] = {
"label": "\\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["sqrt(g)_r"] = {
"label": "\\partial_{\\rho} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, derivative wrt radial coordinate",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
}
data_index["sqrt(g)_t"] = {
"label": "\\partial_{\\theta} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, derivative wrt poloidal angle",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
}
data_index["sqrt(g)_z"] = {
"label": "\\partial_{\\zeta} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, derivative wrt toroidal angle",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["sqrt(g)_rr"] = {
"label": "\\partial_{\\rho\\rho} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, second derivative wrt radial coordinate",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
[3, 0, 0],
[2, 1, 0],
[2, 0, 1],
],
}
data_index["sqrt(g)_tt"] = {
"label": "\\partial_{\\theta\\theta} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, second derivative wrt poloidal angle",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
[0, 3, 0],
[1, 2, 0],
[0, 2, 1],
],
}
data_index["sqrt(g)_zz"] = {
"label": "\\partial_{\\zeta\\zeta} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, second derivative wrt toroidal angle",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
[0, 0, 3],
[1, 0, 2],
[0, 1, 2],
],
}
data_index["sqrt(g)_tz"] = {
"label": "\\partial_{\\theta\\zeta} \\sqrt{g}",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Jacobian determinant, second derivative wrt poloidal and toroidal angles",
"fun": "compute_jacobian",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
}
# covariant metric coefficients
data_index["g_rr"] = {
"label": "g_{\\rho\\rho}",
"units": "m^{2}",
"units_long": "square meters",
"description": "Radial/Radial element of covariant metric tensor",
"fun": "compute_covariant_metric_coefficients",
"dim": 1,
"R_derivs": [[1, 0, 0]],
}
data_index["g_tt"] = {
"label": "g_{\\theta\\theta}",
"units": "m^{2}",
"units_long": "square meters",
"description": "Poloidal/Poloidal element of covariant metric tensor",
"fun": "compute_covariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 1, 0]],
}
data_index["g_zz"] = {
"label": "g_{\\zeta\\zeta}",
"units": "m^{2}",
"units_long": "square meters",
"description": "Toroidal/Toroidal element of covariant metric tensor",
"fun": "compute_covariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [0, 0, 1]],
}
data_index["g_rt"] = {
"label": "g_{\\rho\\theta}",
"units": "m^{2}",
"units_long": "square meters",
"description": "Radial/Poloidal element of covariant metric tensor",
"fun": "compute_covariant_metric_coefficients",
"dim": 1,
"R_derivs": [[1, 0, 0], [0, 1, 0]],
}
data_index["g_rz"] = {
"label": "g_{\\rho\\zeta}",
"units": "m^{2}",
"units_long": "square meters",
"description": "Radial/Toroidal element of covariant metric tensor",
"fun": "compute_covariant_metric_coefficients",
"dim": 1,
"R_derivs": [[1, 0, 0], [0, 0, 1]],
}
data_index["g_tz"] = {
"label": "g_{\\theta\\zeta}",
"units": "m^{2}",
"units_long": "square meters",
"description": "Poloidal/Toroidal element of covariant metric tensor",
"fun": "compute_covariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
# contravariant metric coefficients
data_index["g^rr"] = {
"label": "g^{\\rho\\rho}",
"units": "m^{-2}",
"units_long": "inverse square meters",
"description": "Radial/Radial element of contravariant metric tensor",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["g^tt"] = {
"label": "g^{\\theta\\theta}",
"units": "m^{-2}",
"units_long": "inverse square meters",
"description": "Poloidal/Poloidal element of contravariant metric tensor",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["g^zz"] = {
"label": "g^{\\zeta\\zeta}",
"units": "m^{-2}",
"units_long": "inverse square meters",
"description": "Toroidal/Toroidal element of contravariant metric tensor",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
data_index["g^rt"] = {
"label": "g^{\\rho\\theta}",
"units": "m^{-2}",
"units_long": "inverse square meters",
"description": "Radial/Poloidal element of contravariant metric tensor",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["g^rz"] = {
"label": "g^{\\rho\\zeta}",
"units": "m^{-2}",
"units_long": "inverse square meters",
"description": "Radial/Toroidal element of contravariant metric tensor",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["g^tz"] = {
"label": "g^{\\theta\\zeta}",
"units": "m^{-2}",
"units_long": "inverse square meters",
"description": "Poloidal/Toroidal element of contravariant metric tensor",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["|grad(rho)|"] = {
"label": "|\\nabla \\rho|",
"units": "m^{-1}",
"units_long": "inverse meters",
"description": "Magnitude of contravariant radial basis vector",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["|grad(theta)|"] = {
"label": "|\\nabla \\theta|",
"units": "m^{-1}",
"units_long": "inverse meters",
"description": "Magnitude of contravariant poloidal basis vector",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["|grad(zeta)|"] = {
"label": "|\\nabla \\zeta|",
"units": "m^{-1}",
"units_long": "inverse meters",
"description": "Magnitude of contravariant toroidal basis vector",
"fun": "compute_contravariant_metric_coefficients",
"dim": 1,
"R_derivs": [[0, 0, 0]],
}
# contravariant magnetic field
data_index["B0"] = {
"label": "\\psi' / \\sqrt{g}",
"units": "T m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0]],
}
data_index["B^rho"] = {
"label": "B^{\\rho}",
"units": "T m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant radial component of magnetic field",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0]],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta"] = {
"label": "B^{\\theta}",
"units": "T m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 0, 1]],
}
data_index["B^zeta"] = {
"label": "B^{\\zeta}",
"units": "T m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0]],
}
data_index["B"] = {
"label": "\\mathbf{B}",
"units": "T",
"units_long": "Tesla",
"description": "Magnetic field",
"fun": "compute_contravariant_magnetic_field",
"dim": 3,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B_R"] = {
"label": "B_{R}",
"units": "T",
"units_long": "Tesla",
"description": "Radial component of magnetic field in lab frame",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B_phi"] = {
"label": "B_{\\phi}",
"units": "T",
"units_long": "Tesla",
"description": "Toroidal component of magnetic field in lab frame",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B_Z"] = {
"label": "B_{Z}",
"units": "T",
"units_long": "Tesla",
"description": "Vertical component of magnetic field in lab frame",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B0_r"] = {
"label": "\\psi'' / \\sqrt{g} - \\psi' \\partial_{\\rho} \\sqrt{g} / g",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta_r"] = {
"label": "\\partial_{\\rho} B^{\\theta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field, derivative wrt radial coordinate",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 0, 1], [1, 0, 1]],
}
data_index["B^zeta_r"] = {
"label": "\\partial_{\\rho} B^{\\zeta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field, derivative wrt radial coordinate",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [1, 1, 0]],
}
data_index["B_r"] = {
"label": "\\partial_{\\rho} \\mathbf{B}",
"units": "T",
"units_long": "Tesla",
"description": "Magnetic field, derivative wrt radial coordinate",
"fun": "compute_contravariant_magnetic_field",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [1, 1, 0]],
}
data_index["B0_t"] = {
"label": "-\\psi' \\partial_{\\theta} \\sqrt{g} / g",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta_t"] = {
"label": "\\partial_{\\theta} B^{\\theta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field, derivative wrt poloidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 0, 1], [0, 1, 1]],
}
data_index["B^zeta_t"] = {
"label": "\\partial_{\\theta} B^{\\zeta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field, derivative wrt poloidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 2, 0]],
}
data_index["B_t"] = {
"label": "\\partial_{\\theta} \\mathbf{B}",
"units": "T",
"units_long": "Tesla",
"description": "Magnetic field, derivative wrt poloidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 1, 1]],
}
data_index["B0_z"] = {
"label": "-\\psi' \\partial_{\\zeta} \\sqrt{g} / g",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta_z"] = {
"label": "\\partial_{\\zeta} B^{\\theta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field, derivative wrt toroidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 0, 1], [0, 0, 2]],
}
data_index["B^zeta_z"] = {
"label": "\\partial_{\\zeta} B^{\\zeta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field, derivative wrt toroidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 1, 1]],
}
data_index["B_z"] = {
"label": "\\partial_{\\zeta} \\mathbf{B}",
"units": "T",
"units_long": "Tesla",
"description": "Magnetic field, derivative wrt toroidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1]],
}
data_index["B0_tt"] = {
"label": "-\\psi' \\partial_{\\theta\\theta} \\sqrt{g} / g + "
+ "2 \\psi' (\\partial_{\\theta} \\sqrt{g})^2 / (\\sqrt{g})^{3}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
[0, 3, 0],
[1, 2, 0],
[0, 2, 1],
],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta_tt"] = {
"label": "\\partial_{\\theta\\theta} B^{\\theta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field, second derivative wrt poloidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
[0, 3, 0],
[1, 2, 0],
[0, 2, 1],
],
"L_derivs": [[0, 0, 0], [0, 0, 1], [0, 1, 1], [0, 2, 1]],
}
data_index["B^zeta_tt"] = {
"label": "\\partial_{\\theta\\theta} B^{\\zeta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field, second derivative wrt poloidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
[0, 3, 0],
[1, 2, 0],
[0, 2, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 2, 0], [0, 3, 0]],
}
data_index["B0_zz"] = {
"label": "-\\psi' \\partial_{\\zeta\\zeta} \\sqrt{g} / g + "
+ "2 \\psi' (\\partial_{\\zeta} \\sqrt{g})^2 / (\\sqrt{g})^{3}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
[0, 0, 3],
[1, 0, 2],
[0, 1, 2],
],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta_zz"] = {
"label": "\\partial_{\\zeta\\zeta} B^{\\theta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field, second derivative wrt toroidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
[0, 0, 3],
[1, 0, 2],
[0, 1, 2],
],
"L_derivs": [[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 0, 3]],
}
data_index["B^zeta_zz"] = {
"label": "\\partial_{\\zeta\\zeta} B^{\\zeta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field, second derivative wrt toroidal angle",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
[0, 0, 3],
[1, 0, 2],
[0, 1, 2],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 1, 2]],
}
data_index["B0_tz"] = {
"label": "-\\psi' \\partial_{\\theta\\zeta} \\sqrt{g} / g + "
+ "2 \\psi' \\partial_{\\theta} \\sqrt{g} \\partial_{\\zeta} \\sqrt{g} / "
+ "(\\sqrt{g})^{3}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [[0, 0, 0]],
}
data_index["B^theta_tz"] = {
"label": "\\partial_{\\theta\\zeta} B^{\\theta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant poloidal component of magnetic field, second derivative wrt poloidal and toroidal angles",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1], [0, 1, 2]],
}
data_index["B^zeta_tz"] = {
"label": "\\partial_{\\theta\\zeta} B^{\\zeta}",
"units": "T \\cdot m^{-1}",
"units_long": "Tesla / meters",
"description": "Contravariant toroidal component of magnetic field, second derivative wrt poloidal and toroidal angles",
"fun": "compute_contravariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 2, 0], [0, 1, 1], [0, 2, 1]],
}
# covariant magnetic field
data_index["B_rho"] = {
"label": "B_{\\rho}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant radial component of magnetic field",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B_theta"] = {
"label": "B_{\\theta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant poloidal component of magnetic field",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B_zeta"] = {
"label": "B_{\\zeta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant toroidal component of magnetic field",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B_rho_r"] = {
"label": "\\partial_{\\rho} B_{\\rho}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant radial component of magnetic field, derivative wrt radial coordinate",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1]],
}
data_index["B_theta_r"] = {
"label": "\\partial_{\\rho} B_{\\theta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant poloidal component of magnetic field, derivative wrt radial coordinate",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1]],
}
data_index["B_zeta_r"] = {
"label": "\\partial_{\\rho} B_{\\zeta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant toroidal component of magnetic field, derivative wrt radial coordinate",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1]],
}
data_index["B_rho_t"] = {
"label": "\\partial_{\\theta} B_{\\rho}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant radial component of magnetic field, derivative wrt poloidal angle",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 1, 1]],
}
data_index["B_theta_t"] = {
"label": "\\partial_{\\theta} B_{\\theta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant poloidal component of magnetic field, derivative wrt poloidal angle",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 1, 1]],
}
data_index["B_zeta_t"] = {
"label": "\\partial_{\\theta} B_{\\zeta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant toroidal component of magnetic field, derivative wrt poloidal angle",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 1, 1]],
}
data_index["B_rho_z"] = {
"label": "\\partial_{\\zeta} B_{\\rho}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant radial component of magnetic field, derivative wrt toroidal angle",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1]],
}
data_index["B_theta_z"] = {
"label": "\\partial_{\\zeta} B_{\\theta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant poloidal component of magnetic field, derivative wrt toroidal angle",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1]],
}
data_index["B_zeta_z"] = {
"label": "\\partial_{\\zeta} B_{\\zeta}",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Covariant toroidal component of magnetic field, derivative wrt toroidal angle",
"fun": "compute_covariant_magnetic_field",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1]],
}
# magnetic field magnitude
data_index["|B|"] = {
"label": "|\\mathbf{B}|",
"units": "T",
"units_long": "Tesla",
"description": "Magnitude of magnetic field",
"fun": "compute_magnetic_field_magnitude",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["|B|_t"] = {
"label": "\\partial_{\\theta} |\\mathbf{B}|",
"units": "T",
"units_long": "Tesla",
"description": "Magnitude of magnetic field, derivative wrt poloidal angle",
"fun": "compute_magnetic_field_magnitude",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 1, 1]],
}
data_index["|B|_z"] = {
"label": "\\partial_{\\zeta} |\\mathbf{B}|",
"units": "T",
"units_long": "Tesla",
"description": "Magnitude of magnetic field, derivative wrt toroidal angle",
"fun": "compute_magnetic_field_magnitude",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1]],
}
data_index["|B|_tt"] = {
"label": "\\partial_{\\theta\\theta} |\\mathbf{B}|",
"units": "T",
"units_long": "Tesla",
"description": "Magnitude of magnetic field, second derivative wrt poloidal angle",
"fun": "compute_magnetic_field_magnitude",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
[0, 3, 0],
[1, 2, 0],
[0, 2, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 1, 1],
[0, 3, 0],
[0, 2, 1],
],
}
data_index["|B|_zz"] = {
"label": "\\partial_{\\zeta\\zeta} |\\mathbf{B}|",
"units": "T",
"units_long": "Tesla",
"description": "Magnitude of magnetic field, second derivative wrt toroidal angle",
"fun": "compute_magnetic_field_magnitude",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
[0, 0, 3],
[1, 0, 2],
[0, 1, 2],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[0, 1, 1],
[0, 0, 3],
[0, 1, 2],
],
}
data_index["|B|_tz"] = {
"label": "\\partial_{\\theta\\zeta} |\\mathbf{B}|",
"units": "T",
"units_long": "Tesla",
"description": "Magnitude of magnetic field, derivative wrt poloidal and toroidal angles",
"fun": "compute_magnetic_field_magnitude",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[0, 1, 1],
[0, 2, 1],
[0, 1, 2],
],
}
# magnetic pressure gradient
data_index["grad(|B|^2)_rho"] = {
"label": "(\\nabla B^{2})_{\\rho}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant radial component of magnetic pressure gradient",
"fun": "compute_magnetic_pressure_gradient",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[1, 1, 0],
[1, 0, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [1, 1, 0], [1, 0, 1]],
}
data_index["grad(|B|^2)_theta"] = {
"label": "(\\nabla B^{2})_{\\theta}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant poloidal component of magnetic pressure gradient",
"fun": "compute_magnetic_pressure_gradient",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 1, 1]],
}
data_index["grad(|B|^2)_zeta"] = {
"label": "(\\nabla B^{2})_{\\zeta}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant toroidal component of magnetic pressure gradient",
"fun": "compute_magnetic_pressure_gradient",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 0, 2], [0, 1, 1]],
}
data_index["grad(|B|^2)"] = {
"label": "\\nabla B^{2}",
"units": "T^{2} \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "Magnetic pressure gradient",
"fun": "compute_magnetic_pressure_gradient",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["|grad(|B|^2)|"] = {
"label": "|\\nabla B^{2}|",
"units": "T^{2} \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "Magnitude of magnetic pressure gradient",
"fun": "compute_magnetic_pressure_gradient",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
# magnetic tension
data_index["(curl(B)xB)_rho"] = {
"label": "((\\nabla \\times \\mathbf{B}) \\times \\mathbf{B})_{\\rho}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant radial component of Lorentz force",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["(curl(B)xB)_theta"] = {
"label": "((\\nabla \\times \\mathbf{B}) \\times \\mathbf{B})_{\\theta}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant poloidal component of Lorentz force",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["(curl(B)xB)_zeta"] = {
"label": "((\\nabla \\times \\mathbf{B}) \\times \\mathbf{B})_{\\zeta}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant toroidal component of Lorentz force",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["curl(B)xB"] = {
"label": "(\\nabla \\times \\mathbf{B}) \\times \\mathbf{B}",
"units": "T^{2} \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "Lorentz force",
"fun": "compute_magnetic_tension",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["(B*grad)B"] = {
"label": "(\\mathbf{B} \\cdot \\nabla) \\mathbf{B}",
"units": "T^{2} \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "Magnetic tension",
"fun": "compute_magnetic_tension",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["((B*grad)B)_rho"] = {
"label": "((\\mathbf{B} \\cdot \\nabla) \\mathbf{B})_{\\rho}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant radial component of magnetic tension",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["((B*grad)B)_theta"] = {
"label": "((\\mathbf{B} \\cdot \\nabla) \\mathbf{B})_{\\theta}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant poloidal component of magnetic tension",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["((B*grad)B)_zeta"] = {
"label": "((\\mathbf{B} \\cdot \\nabla) \\mathbf{B})_{\\zeta}",
"units": "T^{2}",
"units_long": "Tesla squared",
"description": "Covariant toroidal component of magnetic tension",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["|(B*grad)B|"] = {
"label": "|(\\mathbf{B} \\cdot \\nabla) \\mathbf{B}|",
"units": "T^2 \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "Magnitude of magnetic tension",
"fun": "compute_magnetic_tension",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
# B dot grad(B)
data_index["B*grad(|B|)"] = {
"label": "\\mathbf{B} \\cdot \\nabla B",
"units": "T^2 \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "",
"fun": "compute_B_dot_gradB",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["(B*grad(|B|))_t"] = {
"label": "\\partial_{\\theta} (\\mathbf{B} \\cdot \\nabla B)",
"units": "T^2 \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "",
"fun": "compute_B_dot_gradB",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 3, 0],
[1, 2, 0],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[0, 1, 1],
[0, 3, 0],
[0, 2, 1],
[0, 1, 2],
],
}
data_index["(B*grad(|B|))_z"] = {
"label": "\\partial_{\\zeta} (\\mathbf{B} \\cdot \\nabla B)",
"units": "T^2 \\cdot m^{-1}",
"units_long": "Tesla squared / meters",
"description": "",
"fun": "compute_B_dot_gradB",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 0, 3],
[1, 2, 0],
[1, 0, 2],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[0, 1, 1],
[0, 0, 3],
[0, 2, 1],
[0, 1, 2],
],
}
# contravarian current density
data_index["J^rho"] = {
"label": "J^{\\rho}",
"units": "A \\cdot m^{-3}",
"units_long": "Amperes / cubic meter",
"description": "Contravariant radial component of plasma current",
"fun": "compute_contravariant_current_density",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["J^theta"] = {
"label": "J^{\\theta}",
"units": "A \\cdot m^{-3}",
"units_long": "Amperes / cubic meter",
"description": "Contravariant poloidal component of plasma current",
"fun": "compute_contravariant_current_density",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["J^zeta"] = {
"label": "J^{\\zeta}",
"units": "A \\cdot m^{-3}",
"units_long": "Amperes / cubic meter",
"description": "Contravariant toroidal component of plasma current",
"fun": "compute_contravariant_current_density",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["J"] = {
"label": "\\mathbf{J}",
"units": "A \\cdot m^{-2}",
"units_long": "Amperes / square meter",
"description": "Plasma current",
"fun": "compute_contravariant_current_density",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["J_parallel"] = {
"label": "\\mathbf{J}_{\parallel}",
"units": "A \\cdot m^{-2}",
"units_long": "Amperes / square meter",
"description": "Plasma current parallel to magnetic field",
"fun": "compute_contravariant_current_density",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["div_J_perp"] = {
"label": "\\nabla \\cdot \\mathbf{J}_{\perp}",
"units": "A \\cdot m^{-3}",
"units_long": "Amperes / cubic meter",
"description": "Divergence of Plasma current perpendicular to magnetic field",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
# force error
data_index["F_rho"] = {
"label": "F_{\\rho}",
"units": "N \\cdot m^{-2}",
"units_long": "Newtons / square meter",
"description": "Covariant radial component of force balance error",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["F_theta"] = {
"label": "F_{\\theta}",
"units": "N \\cdot m^{-2}",
"units_long": "Newtons / square meter",
"description": "Covariant poloidal component of force balance error",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["F_zeta"] = {
"label": "F_{\\zeta}",
"units": "N \\cdot m^{-2}",
"units_long": "Newtons / square meter",
"description": "Covariant toroidal component of force balance error",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["F_beta"] = {
"label": "F_{\\beta}",
"units": "A",
"units_long": "Amperes",
"description": "Covariant helical component of force balance error",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["F"] = {
"label": "\\mathbf{J} \\times \\mathbf{B} - \\nabla p",
"units": "N \\cdot m^{-3}",
"units_long": "Newtons / cubic meter",
"description": "Force balance error",
"fun": "compute_force_error",
"dim": 3,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["|F|"] = {
"label": "|\\mathbf{J} \\times \\mathbf{B} - \\nabla p|",
"units": "N \\cdot m^{-3}",
"units_long": "Newtons / cubic meter",
"description": "Magnitude of force balance error",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[2, 0, 0],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
}
data_index["|grad(p)|"] = {
"label": "|\\nabla p|",
"units": "N \\cdot m^{-3}",
"units_long": "Newtons / cubic meter",
"description": "Magnitude of pressure gradient",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0]],
}
data_index["|beta|"] = {
"label": "|B^{\\theta} \\nabla \\zeta - B^{\\zeta} \\nabla \\theta|",
"units": "T \\cdot m^{-2}",
"units_long": "Tesla / square meter",
"description": "Magnitude of helical basis vector",
"fun": "compute_force_error",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
# quasi-symmetry
data_index["I"] = {
"label": "I",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Boozer toroidal current",
"fun": "compute_quasisymmetry_error",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["G"] = {
"label": "G",
"units": "T \\cdot m",
"units_long": "Tesla * meters",
"description": "Boozer poloidal current",
"fun": "compute_quasisymmetry_error",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["nu"] = {
"label": "\\nu = \\zeta_{B} - \\zeta",
"units": "rad",
"units_long": "radians",
"description": "Boozer toroidal stream function",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["nu_t"] = {
"label": "\\partial_{\\theta} \\nu",
"units": "rad",
"units_long": "radians",
"description": "Boozer toroidal stream function, first poloidal derivative",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["nu_z"] = {
"label": "\\partial_{\\zeta} \\nu",
"units": "rad",
"units_long": "radians",
"description": "Boozer toroidal stream function, first toroidal derivative",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["theta_B"] = {
"label": "\\theta_{B}",
"units": "rad",
"units_long": "radians",
"description": "Boozer poloidal angular coordinate",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["zeta_B"] = {
"label": "\\zeta_{B}",
"units": "rad",
"units_long": "radians",
"description": "Boozer toroidal angular coordinate",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["sqrt(g)_B"] = {
"label": "\\sqrt{g}_{B}",
"units": "~",
"units_long": "None",
"description": "Jacobian determinant of Boozer coordinates",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["|B|_mn"] = {
"label": "B_{mn}^{Boozer}",
"units": "T",
"units_long": "Tesla",
"description": "Boozer harmonics of magnetic field",
"fun": "compute_boozer_coords",
"dim": 1,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["B modes"] = {
"label": "Boozer modes",
"units": "",
"units_long": "None",
"description": "Boozer harmonics",
"fun": "compute_boozer_coords",
"dim": 1,
}
data_index["f_C"] = {
"label": "(\\mathbf{B} \\times \\nabla \\psi) \\cdot \\nabla B - "
+ "(M G + N I) / (M \\iota - N) \\mathbf{B} \\cdot \\nabla B",
"units": "T^{3}",
"units_long": "Tesla cubed",
"description": "Two-term quasisymmetry metric",
"fun": "compute_quasisymmetry_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1], [0, 2, 0], [0, 0, 2], [0, 1, 1]],
}
data_index["f_T"] = {
"label": "\\nabla \\psi \\times \\nabla B \\cdot \\nabla "
+ "(\\mathbf{B} \\cdot \\nabla B)",
"units": "T^{4} \\cdot m^{-2}",
"units_long": "Tesla quarted / square meters",
"description": "Triple product quasisymmetry metric",
"fun": "compute_quasisymmetry_error",
"dim": 1,
"R_derivs": [
[0, 0, 0],
[1, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[1, 1, 0],
[1, 0, 1],
[0, 1, 1],
[0, 3, 0],
[0, 0, 3],
[1, 2, 0],
[1, 0, 2],
[0, 2, 1],
[0, 1, 2],
[1, 1, 1],
],
"L_derivs": [
[0, 0, 0],
[0, 1, 0],
[0, 0, 1],
[0, 2, 0],
[0, 0, 2],
[0, 1, 1],
[0, 3, 0],
[0, 0, 3],
[0, 2, 1],
[0, 1, 2],
],
}
# energy
data_index["W"] = {
"label": "W",
"units": "J",
"units_long": "Joules",
"description": "Plasma total energy",
"fun": "compute_energy",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["W_B"] = {
"label": "W_B",
"units": "J",
"units_long": "Joules",
"description": "Plasma magnetic energy",
"fun": "compute_energy",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["W_p"] = {
"label": "W_p",
"units": "J",
"units_long": "Joules",
"description": "Plasma thermodynamic energy",
"fun": "compute_energy",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
"L_derivs": [[0, 0, 0]],
}
# geometry
data_index["V"] = {
"label": "V",
"units": "m^{3}",
"units_long": "cubic meters",
"description": "Volume",
"fun": "compute_geometry",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["A"] = {
"label": "A",
"units": "m^{2}",
"units_long": "square meters",
"description": "Cross-sectional area",
"fun": "compute_geometry",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["R0"] = {
"label": "R_{0}",
"units": "m",
"units_long": "meters",
"description": "Major radius",
"fun": "compute_geometry",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["a"] = {
"label": "a",
"units": "m",
"units_long": "meters",
"description": "Minor radius",
"fun": "compute_geometry",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
data_index["R0/a"] = {
"label": "R_{0} / a",
"units": "~",
"units_long": "None",
"description": "Aspect ratio",
"fun": "compute_geometry",
"dim": 0,
"R_derivs": [[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]],
}
|
n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
m.sort()
x -= sum(m)
print(n + x // m[0])
|
#!/usr/bin/python
imagedir = parent + "/oiio-images"
files = [ "dpx_nuke_10bits_rgb.dpx", "dpx_nuke_16bits_rgba.dpx" ]
for f in files:
command += rw_command (imagedir, f)
|
n = input()
arr = list(map(int, input().split(' ')))
print(arr.count(max(arr)))
|
# 本参考程序来自九章算法,由 @ 提供。版权所有,转发请注明出处。
# - 九章算法致力于帮助更多中国人找到好的工作,教师团队均来自硅谷和国内的一线大公司在职工程师。
# - 现有的面试培训课程包括:九章算法班,系统设计班,算法强化班,Java入门与基础算法班,Android 项目实战班,
# - Big Data 项目实战班,算法面试高频题班, 动态规划专题班
# - 更多详情请见官方网站:http://www.jiuzhang.com/?source=code
class Solution:
# @param nums: The integer array
# @param target: Target number to find
# @return the first position of target in nums, position start from 0
def binarySearch(self, nums, target):
if not nums:
return -1
start, end = 0, len(nums) - 1
# 用 start + 1 < end 而不是 start < end 的目的是为了避免死循环
# 在 first position of target 的情况下不会出现死循环
# 但是在 last position of target 的情况下会出现死循环
# 样例:nums=[1,1] target = 1
# 为了统一模板,我们就都采用 start + 1 < end,就保证不会出现死循环
while start + 1 < end:
# python 没有 overflow 的问题,直接 // 2 就可以了
# java和C++ 最好写成 mid = start + (end - start) / 2
# 防止在 start = 2^31 - 1, end = 2^31 - 1 的情况下出现加法 overflow
mid = (start + end) // 2
# > , =, < 的逻辑先分开写,然后在看看 = 的情况是否能合并到其他分支里
if nums[mid] < target:
# 写作 start = mid + 1 也是正确的
# 只是可以偷懒不写,因为不写也没问题,不会影响时间复杂度
# 不写的好处是,万一你不小心写成了 mid - 1 你就错了
start = mid
elif nums[mid] == target:
end = mid
else:
# 写作 end = mid - 1 也是正确的
# 只是可以偷懒不写,因为不写也没问题,不会影响时间复杂度
# 不写的好处是,万一你不小心写成了 mid + 1 你就错了
end = mid
# 因为上面的循环退出条件是 start + 1 < end
# 因此这里循环结束的时候,start 和 end 的关系是相邻关系(1和2,3和4这种)
# 因此需要再单独判断 start 和 end 这两个数谁是我们要的答案
# 如果是找 first position of target 就先看 start,否则就先看 end
if nums[start] == target:
return start
if nums[end] == target:
return end
return -1
|
cube=[value**3 for value in range(1,10)]
print(cube)
print("Los primero tres numeros de la lista son: " , cube[:3])
print("Los tres numeros centro de la lista son: " , cube[3:6])
print("Los ultimos tres numeros de la lista son: " , cube[6:]) |
class Demag(object):
def __init__(self):
pass
def get_mif(self):
mif = '# Demag\n'
mif += 'Specify Oxs_Demag {}\n\n'
return mif
|
"""
vigor - A collection of semi-random, semi-useful Python scripts and CLI tools.
"""
__version__ = '0.1.1'
__author__ = 'Ryan Liu <ryan@ryanliu6.xyz>'
"""
__all__ only affects if you do from vigor import *.
"""
__all__ = []
|
def divisible7(n):
for x in range(0,n):
if x%7==0:
yield x
print([x for x in divisible7(1000)]) |
getApproxError = lambda x_i, x_i_1: abs(x_i_1-x_i)/x_i_1 # For Percent error
def _NR_(xn, f, fp, iterations, n = 1, c_error = 1, p_error = 2):
if iterations == 0 or c_error > p_error:
return xn
xr = xn - f(xn)/fp(xn)
p_error = c_error
c_error = getApproxError(xn, xr)
print(f'{n}\t{xn:.8f}\t\t{c_error*100}%')
return _NR_(xr, f, fp, iterations - 1, n + 1, c_error, p_error)
def newtonRaphson(x, f, fp, iterations):
return _NR_(x, f, fp, iterations)
f = lambda x: (x**3)-(2*x**2)-5
fp = lambda x: 3*(x**2)-(4*x)
x0 = 2
print('n\txn\t\t\terror')
print('**\t**********\t\t***************')
newtonRaphson(x0, f, fp, 6) |
class Solution:
def reverseParentheses(self, s: str) -> str:
#initialize a stack to keep track of left bracket indexes
leftBracketIndices = []
#iterate through the string
outputString = s
index = 0
while index < len(outputString):
if outputString[index] == "(":
leftBracketIndices.append(index)
elif outputString[index] == ")":
#print("right bracket found at index " + str(index))
lastLeftBracketIndex = leftBracketIndices[len(leftBracketIndices)-1]
toBeReplaced = outputString[lastLeftBracketIndex:index+1]
reversedString = toBeReplaced[::-1]
outputString = outputString.replace(toBeReplaced,reversedString[1:len(reversedString)-1])
leftBracketIndices.pop()
index = index-2
index = index + 1
return outputString
|
# -*- coding: utf-8 -*-
# Copyright 2019 Cohesity Inc.
class TypeFlashBladeProtectionSourceEnum(object):
"""Implementation of the 'Type_FlashBladeProtectionSource' enum.
Specifies the type of managed object in a Pure Storage FlashBlade
like 'kStorageArray' or 'kFileSystem'.
'kStorageArray' indicates a top level Pure Storage FlashBlade array.
'kFileSystem' indicates a Pure Storage FlashBlade file system within the
array.
Attributes:
KSTORAGEARRAY: TODO: type description here.
KFILESYSTEM: TODO: type description here.
"""
KSTORAGEARRAY = 'kStorageArray'
KFILESYSTEM = 'kFileSystem'
|
students = ['Ivan', 'Masha', 'Sasha']
students += ['Olga']
students += 'Olga'
print(len(students))
|
class OpenSRSError(Exception):
"""Base class for errors in this library."""
pass
class XCPError(OpenSRSError):
def __init__(self, response_message):
self.response_message = response_message
self.message_data = response_message.get_data()
self.response_code = self.message_data['response_code']
self.response_text = self.message_data['response_text']
def __str__(self):
return "%s: %s" % (self.response_code, self.response_text)
class BadResponseError(OpenSRSError):
def __init__(self, xcp_error):
self.response_message = xcp_error.response_message
self.message_data = xcp_error.message_data
self.response_code = xcp_error.response_code
self.response_text = xcp_error.response_text
def __str__(self):
return "%s: %s" % (self.response_code, self.response_text)
class OperationFailure(OpenSRSError):
def __init__(self, response_message, response_code=None,
response_text=None):
self.response_message = response_message
self.message_data = response_message.get_data()
self.response_code = response_code or \
self.message_data['response_code']
self.response_text = response_text or \
self.message_data['response_text']
def __str__(self):
return "%s: %s" % (self.response_code, self.response_text)
class InvalidDomain(BadResponseError):
pass
class AuthenticationFailure(BadResponseError):
pass
class DomainRegistrationFailure(BadResponseError):
pass
class DomainTaken(DomainRegistrationFailure):
pass
class DomainTransferFailure(BadResponseError):
pass
class DomainNotTransferable(DomainTransferFailure):
pass
class DomainLookupFailure(OperationFailure):
pass
class DomainAlreadyRenewed(BadResponseError):
pass
class DomainLookupUnavailable(OperationFailure):
pass
class DomainRegistrationTimedOut(BadResponseError):
pass
|
def rot_char(character, n):
"""Rot-n for a single character"""
if character.islower():
return chr(((ord(character)-97+n)%26)+97)
elif character.isupper():
return chr(((ord(character)-65+n)%26)+65)
else:
return character
def rot_n(plaintext,n):
"""Implementation of caesar cypher"""
cyphertext = ""
for character in plaintext:
cyphertext += rot_char(character, n)
return cyphertext
def ui():
"""UI Implementation with prints and inputs"""
print("Insert the text to be encyphered")
plaintext = input()
print("Input the desired N for the ROT-N")
n = int(input())
return plaintext, n
if __name__ == "__main__":
plaintext, n = ui()
print(rot_n(plaintext, n)) |
#!/usr/bin/env python
'''
Copyright (C) 2020, WAFW00F Developers.
See the LICENSE file for copying permission.
'''
NAME = 'chuangyudun (zhidaochuangyu Technologies)'
def is_waf(self):
schemes = [
self.matchContent(r'<span class="r-tip01"><%= error_403 %>'),
self.matchContent(r"'hacker';"),
self.matchContent(r'<center>client: (.*?), server: (.*?), time: (.*?)</center>'),
]
if all(i for i in schemes):
return True
return False |
#replace username,pwd, api_key with yours
USER_NAME = '6565'
PWD = '6g!fdfgd'
API_KEY = '657hgg'
#Dont change below varibale
FEED_TOKEN = None
TOKEN_MAP = None
SMART_API_OBJ = None
|
"""
Summary:
--------
0416: sequence labeling, with granularity 1/4 of the signal's frequency
0433: (subtract) unet
0436: object detection (yolo)
0430: unet
0437: unet (+lstm)
0343: unet/lstm/etc.
0348: crnn (cnn no downsampling)
"""
|
nome = input("Insira o seu nome: ")
print()
print("____________00____00___00000___0000000__0000000__00____00___________")
print("____________00____00__00___00__00___00__00___00___00__00____________")
print("____________00000000__0000000__000000___000000______00______________")
print("____________00____00__00___00__00_______00__________00______________")
print("____________00____00__00___00__00_______00__________00______________")
print()
print("0000000__00__0000000__00000000__00___00__00000_____000000___00____00")
print("00___00__00__00___00_____00_____00___00__00__00___00____00___00__00_")
print("000000___00__0000000_____00_____0000000__00___00__00000000_____00___")
print("00___00__00__00_000______00_____00___00__00__00___00____00_____00___")
print("0000000__00__00___00_____00_____00___00__00000____00____00_____00___")
print()
print(f"♥ . ♥ FELIZ ANIVERSÁRIO! {nome} ♥ . ♥")
print("FELICIDADE: ao máximo!")
print("ÊXITO: em cada fase da tua vida!")
print("BONS AMIGOS: para todas as horas!")
print("SONHOS: se convertendo em realidade!")
print()
print("♥ BEIJOS NO CORAÇÃO! ♥")
print("¸¸.•*´¨`*•.¸¸.•*´¨`*•.¸¸.•*´¨`*•.¸¸.•*´¨`*•.¸")
print()
print("───▐▀▄─────────▄▀▌")
print("───▐▓░▀▄▀▀▀▀▀▄▀░▓▌▄▀▀▄▀▀▄")
print("───▐░▓░▄▀░░░▀▄░▓░▌▀▄───▄▀")
print("────█░░▌█▐░▌█▐░░█───▀▄▀")
print("─▄▄▄▐▀░░░▀█▀░░░▀▌▄▄▄")
print("█▐▐▐▌▀▄░▀▄▀▄▀░▄▀▐▌▌▌█")
print("▀▀▀▀▀▀▀▀▀▄▄▄▀▀▀▀▀▀▀▀▀") |
#!/usr/bin/python2
# Copyright (c) 2017 Public Library of Science
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
"""Test case representations for volumes and issues."""
class VolumeCase(object):
"""One test case of a volume to create."""
def __init__(self, doi, journal_key, display_name, issues=()):
self.doi = DOI_PREFIX + doi
self.journal_key = journal_key
self.display_name = display_name
self.issues = issues
def __str__(self):
return 'TestVolume({0!r}, {1!r}, {2!r}, {3!r})'.format(
self.doi, self.journal_key, self.display_name, self.issues)
class IssueCase(object):
"""One test case of an issue to create.
In order to be created, an instance should belong to the 'issues' field
of a TestVolume object.
"""
def __init__(self, suffix, display_name, image_uri=None):
if not suffix.startswith('.'):
suffix = '.' + suffix
self.suffix = suffix
self.display_name = display_name
self.image_uri = image_uri
def __str__(self):
return 'TestIssue({0!r}, {1!r}, {2!r})'.format(
self.suffix, self.display_name, self.image_uri)
TEST_VOLUMES = [
VolumeCase('volume.pone.v47', 'PLoSONE', 'TestVolume',
issues=[TestIssue('i23', 'TestIssue')]),
]
"""A list of cases to use."""
|
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class MyLinkedList(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.head = None
self.length = 0
def get(self, index):
"""
Get the value of the index-th node in the linked list.
If the index is invalid, return -1.
:type index: int
:rtype: int
"""
if index < 0 or index >= self.length:
return -1
curr = self.head
for i in range(1, index + 1):
curr = curr.next
return curr.val
def addAtHead(self, val):
"""
Add a node of value val before the first element of the linked list.
After the insertion, the new node will be the first node of the
linked list.
:type val: int
:rtype: None
"""
new_node = ListNode(val)
new_node.next = self.head
self.head = new_node
self.length += 1
def addAtTail(self, val):
"""
Append a node of value val to the last element of the linked list.
:type val: int
:rtype: None
"""
curr = self.head
while curr.next:
curr = curr.next
new_node = ListNode(val)
curr.next = new_node
self.length += 1
def addAtIndex(self, index, val):
"""
Add a node of value val before the index-th node in the linked list.
If index equals to the length of linked list,
the node will be appended to the end of linked list.
If index is greater than the length, the node will not be inserted.
:type index: int
:type val: int
:rtype: None
"""
if index < 0:
new_node = ListNode(val)
new_node.next = self.head
self.head = new_node
if index <= self.length:
prev = None
curr = self.head
for i in range(1, index + 1):
prev = curr
curr = curr.next
new_node = ListNode(val)
if prev:
prev.next = new_node
else:
self.head = new_node
new_node.next = curr
self.length += 1
def deleteAtIndex(self, index):
"""
Delete the index-th node in the linked list, if the index is valid.
:type index: int
:rtype: None
"""
if index >= 0 and index < self.length:
prev = None
curr = self.head
_next = None
if curr:
_next = curr.next
for i in range(1, index + 1):
prev = curr
curr = curr.next
if curr:
_next = curr.next
if prev:
prev.next = _next
else:
self.head = _next
self.length -= 1
def test_my_linked_list_1():
ll = MyLinkedList()
ll.addAtHead(1)
assert 1 == ll.get(0)
ll.addAtTail(3)
assert -1 == ll.get(-1)
assert 1 == ll.get(0)
assert 3 == ll.get(1)
ll.addAtIndex(1, 2)
assert 1 == ll.get(0)
assert 2 == ll.get(1)
assert 3 == ll.get(2)
ll.deleteAtIndex(1)
assert 3 == ll.get(1)
assert -1 == ll.get(-3)
def test_my_linked_list_2():
ll = MyLinkedList()
ll.addAtHead(1)
assert 1 == ll.get(0)
ll.addAtIndex(1, 2)
assert 1 == ll.get(0)
assert 2 == ll.get(1)
assert -1 == ll.get(2)
def test_my_linked_list_3():
ll = MyLinkedList()
ll.addAtHead(1)
assert 1 == ll.get(0)
ll.addAtTail(3)
assert -1 == ll.get(-1)
assert 1 == ll.get(0)
assert 3 == ll.get(1)
ll.addAtIndex(4, 2)
assert 3 == ll.get(1)
ll.deleteAtIndex(-1)
assert 3 == ll.get(1)
def test_my_linked_list_4():
ll = MyLinkedList()
ll.addAtIndex(-1, 0)
assert 0 == ll.get(0)
|
# -*- coding: UTF-8 -*-
class Values():
def __init__(self):
return None
class ScreenIdValue():
def DEFAULT():
return 0
def GOOGLE_SEARCH():
return 1
class AccountTitleClassificationTypeValue():
def __init__(self, account_title_value):
self.__account_title_value = account_title_value
self.__account_titles = {
1: '資産',
2: '負債',
3: '資本',
4: '費用',
5: '収益',
}
def has_error(self):
if(self.__account_title_value in values(self.__account_titles)):
return False
else:
return True
def get(self):
return self.__account_title_value
def get_name(self):
return self.__account_titles[int(self.__account_title_value)] |
S = input()
#win = S.count("o")
lose = S.count("x")
if lose <= 7:
print("YES")
else:
print("NO")
|
class Fish:
def __init__(self, color, age):
self.color = color
self.age = age
def speed_up(self, speed):
print("Move speed to "+speed+" mph")
p1 = Fish("blue","0.5")
print(p1.color)
print(p1.age)
p1.speed_up("100") |
def smallest_range(nums, k):
difference = max(nums) - min(nums)
if 2 * k >= difference:
return 0
else:
return difference - 2 * k
print(smallest_range([0, 10], 2))
print(smallest_range([1, 3, 6], 3))
print(smallest_range([1], 0))
print(smallest_range([9, 9, 2, 8, 7], 4))
|
# Exercício 056:
'''Desenvolva um programa que leia o nome, idade e sexo de 4 pessoas. No final do programa, mostre:
- A média de idade do grupo;
- Qual é o nome do homem mais velho;
- Quantas mulheres têm menos de 21 anos.'''
soma = 0
homem = 0
velho = 0
idoso = 0
mulher = 0
for c in range(1, 5):
nome = str(input(f'Digite o nome da {c}ª pessoa:')).strip().capitalize()
idade = int(input(f'Digite a idade de {nome}:'))
sexo = str(input(f'Qual o sexo de {nome}? Digite [ M ] para masculino e [ F ] para feminino.')).strip().upper()
soma = soma + idade
if sexo == 'M':
if idade > velho:
velho = idade
idoso = nome
else:
if idade < 21:
mulher = mulher + 1
print(f'A média de idade do grupo é {soma / 4:.2f}.')
if idoso == 0:
print('Você não digitou o nome de nenhum homem.')
else:
print(f'O nome do homem mais velho é {idoso} e ele tem {velho} anos.')
if mulher == 0:
print('Você não digitou nenhuma mulher menor de idade.')
else:
print(f'Você digitou {mulher} mulheres menores de 21 anos de idade.')
|
# Default `TAR` package extensions.
# Please change the below value to suit your corresponding environment requirement.
TAR_EXTENSION = {'gz': '.tar.gz', 'bz2': '.tar.bz2'}
# Store the `TAR` extracts in the below destination directory option.
TAR_BASE_EXTRACT_DIRECTORY = '/home/vagrant/downloads/MW_AUTOMATE/TarExtractsCommon/'
# Default `TAR` extraction directory.
DEFAULT_TAR_PACKAGE_TYPE = 'Default/' |
class QuizBrain:
def __init__(self, question_list):
"""takes a list of questions as input. questions are dicts with text and answer keys."""
self.question_list = question_list
self.question_number = 0
self.score = 0
def next_question(self):
"""will print the next question, collect a response, print the answer, then advance the question number"""
# grab the next question
question = self.question_list[self.question_number]
# ask it and collect a response
response = input(f"Q.{self.question_number + 1}: {question.text} (True/False): ")
# score the response
self.score_response(response, question.answer)
# advance question number in prep for next question
self.question_number += 1
# done with this question
print()
def has_next(self):
return self.question_number < len(self.question_list)
def score_response(self, response, answer):
if response.lower() == answer.lower():
self.score += 1
print("You got it right!")
else:
print("That's wrong.")
print(f"The correct answer was: {answer}.")
print(f"Score: {self.score}/{self.question_number + 1}") |
__import__('pkg_resources').declare_namespace(__name__)
version = (0, 1, 4)
__version__ = ".".join(map(str, version))
|
# -*- coding: utf-8 -*-
class Card:
""" generic game card """
def __init__(self, value):
self.value = value
def __eq__(self, other_card):
return self.value == other_card.value
def __ne__(self, other_card):
return self.value != other_card.value
def __lt__(self, other_card):
return self.value < other_card.value
def __le__(self, other_card):
return self.value <= other_card.value
def __gt__(self, other_card):
return self.value > other_card.value
def __ge__(self, other_card):
return self.value >= other_card.value
def offset(self, diff=0):
return self.__class__(self.value + diff)
def __sub__(self, diff):
return self.offset(-diff)
def __add__(self, diff):
return self.offset(diff)
class OppCard(Card):
""" card played by the opponent player on the other player stacks """
def __str__(self):
return "O({})".format(self.value)
def __repr__(self):
return "O({})".format(self.value)
class SelfCard(Card):
""" card played by one player on its own stacks """
def __str__(self):
return "S({})".format(self.value)
def __repr__(self):
return "S({})".format(self.value)
def get_opp(self):
return OppCard(self.value)
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# src/model.py
# Author : Irreq
"""
DOCUMENTATION: Define the model.
TODO: Everything.
Implement the CNN and fix the core of
modem.
"""
|
USER_NAME = 'Big Joe'
USER_EMAIL = 'bigjoe@bigjoe.com'
USER_PASSWORD = 'bigjoe99'
def delete_user(login_manager, email):
"""Delete given user"""
try:
login_manager.delete_user(email=email)
except Exception:
pass
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
#######################################
# Author: Jorge Mauricio
# Email: jorge.ernesto.mauricio@gmail.com
# Date: 2018-02-01
# Version: 1.0
#######################################
Objetivo:
Escribe un programa que calcule el valor neto de una cuenta de banco basado
en las transacciones que se ingresan en la consola de comandos.
Ej:
D 200
D 250
P 300
D 100
P 200
Donde:
D = Deposito
P = Pago
Resultado:
50
"""
|
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
"""
Given a Binary Search Tree (BST) with the root node root, return the minimum
difference between the values of any two different nodes in the tree.
1. Naive solution: traverse the tree, get in order traversal. Then find all possible
difference between pairs, which takes O(n^2)
2. For each node find the closest number to it, which takes O(nlogn), because we search
for closer number in logn time for each n nodes.
3. Do in order traversal and Compare the adjacents, keep track of min difference
"""
class Solution(object):
# smallest number possible
prev = -float('inf')
# the biggest possible difference
difference = float('inf')
def minDiffInBST(self, root):
"""
:type root: TreeNode
:rtype: int
"""
self.in_order(root)
return self.difference
def in_order(self, node, prev=None, difference=None):
if node is None:
return
# if prev is None and difference is None:
# prev = -float('inf')
# difference = float('inf')
self.in_order(node.left)
self.difference = min(node.val-self.prev, self.difference)
# update the prev value to current node's val
self.prev = node.val
# move to the right side of node
self.in_order(node.right)
|
class FileWriter:
def __init__(self):
pass
def Write(self, path, record):
with open(path, 'w') as f:
if None is not record['Title'] and 0 != len(record['Title']):
f.write(record['Title'])
f.write('\n\n')
f.write(record['Content'])
|
expected_output = {
'red_sys_info': {
'available_system_uptime': '21 weeks, 5 days, 1 hour, 3 minutes',
'communications': 'Down',
'communications_reason': 'Simplex mode',
'conf_red_mode': 'sso',
'hw_mode': 'Simplex',
'last_switchover_reason': 'none',
'maint_mode': 'Disabled',
'oper_red_mode': 'sso',
'standby_failures': '0',
'switchovers_system_experienced': '0',
},
'slot': {
'slot 1': {
'compiled_by': 'kellythw',
'compiled_date': 'Thu 23-Nov-06 06:26',
'config_register': '0x2102',
'curr_sw_state': 'ACTIVE',
'image_id': 's72033_rp-ADVENTERPRISEK9_WAN-M',
'image_ver': 'Cisco Internetwork Operating System Software',
'os': 'IOS',
'platform': 's72033_rp',
'uptime_in_curr_state': '21 weeks, 5 days, 1 hour, 2 minutes',
'version': '12.2(18)SXF7',
},
},
}
|
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 24 10:52:22 2018
@author: haiwa
"""
|
"""
Datos de entrada
edad_uno-> e_uno-->int
edad_dos--> e_dos-->int
edad_tres--> e_tres-->int
Datos de salida
promedio-->p-->float
"""
# Entradas
e_uno=int(input("Digite edad uno : "))
e_dos=int(input("Digite edad dos : "))
e_tres=int(input("Digite edad tres : "))
# Caja Negra
p=((e_uno+e_dos+e_tres)/3)#float
# Salidas
print("El promedio es " , p)
|
""" 43: Desenvolva uma lógica que leia o peso e a altura de uma pessoa, calcule seu Índice de Massa Corporal (IMC) e
mostre seu status, de acordo com a tabela abaixo:
- IMC abaixo de 18,5: Abaixo do Peso
- Entre 18,5 e 25: Peso Ideal
- 25 até 30: Sobrepeso
- 30 até 40: Obesidade
- Acima de 40: Obesidade Mórbida """
peso = float(input('Qual é o peso (Kg)? '))
altura = float(input('Qual é a altura (m)? '))
imc = peso / altura ** 2 # também pode escrever pow(altura, 2) ou altura * altura
print(f'''O IMC dessa pessoa é de {imc:.1f}.
Ela está''', end=' ')
if imc < 18.5:
print('\033[34mabaixo do peso normal\033[m.')
elif 18.5 <= imc < 25:
print('\033[32mno peso ideal\033[m.')
elif 25 <= imc < 30:
print('\033[33mcom sobrepeso\033[m.')
elif 30 <= imc < 40:
print('\033[35mcom obesidade\033[m.')
elif imc > 40: # também pode escrever else:
print('\033[31mcom obesidade mórbida\033[m.')
# Esta outra resposta foi criada pelo Marcos do futuro:
"""
while True:
peso = float(input('Qual é o peso (Kg) [Digite 0 para parar]? '))
if peso == 0:
break
altura = float(input('Qual é a altura (m) [Digite 0 para parar]? '))
if altura == 0:
break
imc = peso / altura ** 2
print(f'''O IMC dessa pessoa é de {imc:.1f}.
Ela está''', end=' ')
if imc < 18.5:
print('\033[34mabaixo do peso normal\033[m.')
elif 18.5 <= imc < 25:
print('\033[32mno peso ideal\033[m.')
elif 25 <= imc < 30:
print('\033[33mcom sobrepeso\033[m.')
elif 30 <= imc < 40:
print('\033[35mcom obesidade\033[m.')
elif imc > 40:
print('\033[31mcom obesidade mórbida\033[m.')
print('Fim do programa.')
""" |
#
# ----------------------------------------------------------------------------------------------------
# DESCRIPTION
# ----------------------------------------------------------------------------------------------------
#
# ----------------------------------------------------------------------------------------------------
# IMPORTS
# ----------------------------------------------------------------------------------------------------
#
# ----------------------------------------------------------------------------------------------------
# CODE
# ----------------------------------------------------------------------------------------------------
#
## @brief [ ENUM CLASS ] - Language codes.
class LanguageLabel(object):
## [ str ] - US english.
kUSEnglish = 'English'
## [ str ] - Spanish.
kSpanish = 'Spanish'
#
## @brief [ ENUM CLASS ] - Language codes.
class LanguageCode(object):
## [ str ] - US english.
kUSEnglish = 'en-us'
## [ str ] - Spanish.
kSpanish = 'es'
## [ tuple ] - Language choices.
LANGUAGE_CODE_CHOICES = (
(LanguageCode.kUSEnglish , LanguageLabel.kUSEnglish),
(LanguageCode.kSpanish , LanguageLabel.kSpanish),
)
|
'''052 - NÚMEROS PRIMOS
'''
numero = int(input('Digite um valor: '))
totaldivisoes = 0
for sequencia in range(1, numero + 1):
if numero % sequencia == 0:
print('\033[32m', end=' ')
totaldivisoes = totaldivisoes + 1
else:
print('\033[31m', end=' ')
print(sequencia, end=' ')
print('\nO número {} foi divido {} vezes.'.format(numero, totaldivisoes))
if totaldivisoes == 2:
print('\n\033[mPor isso é número PRIMO')
else:
print('\n\033[mPor isso NÃO é número PRIMO')
|
# https://www.codewars.com/kata/5276c18121e20900c0000235/
'''
Instructions :
Background:
You're working in a number zoo, and it seems that one of the numbers has gone missing!
Zoo workers have no idea what number is missing, and are too incompetent to figure it out, so they're hiring you to do it for them.
In case the zoo loses another number, they want your program to work regardless of how many numbers there are in total.
Task:
Write a function that takes a shuffled list of unique numbers from 1 to n with one element missing (which can be any number including n). Return this missing number.
Note: huge lists will be tested.
Examples:
[1, 3, 4] => 2
[1, 2, 3] => 4
[4, 2, 3] => 1
'''
def find_missing_number(numbers):
s = sum(list(range(len(numbers)+2)))
return (s - sum(numbers))
|
class Network:
'''
TODO: Document this
'''
def train(self, **kwargs):
'''
Train the network
'''
raise NotImplementedError
|
# Declaration
x, y, z = 1, 2, 3
p, q, r = (1, 2, 3)
# In function definition
def f(*a):
print(a[0])
f([1, 2, 3], [2])
# In function calls
def g(a, b):
print(a + b)
g(*[1,2])
|
"""
author: Shawn
time : 11/9/18 6:41 PM
desc :
update: Shawn 11/9/18 6:41 PM
""" |
DEFAULT_TAGS = {
'Key': 'Solution',
'Value': 'DataMeshUtils'
}
DOMAIN_TAG_KEY = 'Domain'
DATA_PRODUCT_TAG_KEY = 'DataProduct'
DATA_MESH_MANAGER_ROLENAME = 'DataMeshManager'
DATA_MESH_ADMIN_PRODUCER_ROLENAME = 'DataMeshAdminProducer'
DATA_MESH_ADMIN_CONSUMER_ROLENAME = 'DataMeshAdminConsumer'
DATA_MESH_READONLY_ROLENAME = 'DataMeshAdminReadOnly'
DATA_MESH_PRODUCER_ROLENAME = 'DataMeshProducer'
DATA_MESH_CONSUMER_ROLENAME = 'DataMeshConsumer'
DATA_MESH_IAM_PATH = '/AwsDataMesh/'
PRODUCER_POLICY_NAME = 'DataMeshProducerAccess'
CONSUMER_POLICY_NAME = 'DataMeshConsumerAccess'
SUBSCRIPTIONS_TRACKER_TABLE = 'AwsDataMeshSubscriptions'
MESH = 'Mesh'
PRODUCER = 'Producer'
CONSUMER = 'Consumer'
PRODUCER_ADMIN = 'ProducerAdmin'
CONSUMER_ADMIN = 'ConsumerAdmin'
BUCKET_POLICY_STATEMENT_SID = 'AwsDataMeshUtilsBucketPolicyStatement'
|
"""
219. Contains Duplicate II
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute difference between i and j is at most k.
Example 1:
Input: nums = [1,2,3,1], k = 3
Output: true
Example 2:
Input: nums = [1,0,1,1], k = 1
Output: true
Example 3:
Input: nums = [1,2,3,1,2,3], k = 2
Output: false
"""
class Solution(object):
def containsNearbyDuplicate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: bool
"""
if len(nums) == len(set(nums)):
return False
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
if nums[i] == nums[j]:
if j - i <= k:
return True
return False
class Solution(object):
def containsNearbyDuplicate(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: bool
"""
dic = {}
for i, v in enumerate(nums):
if v in dic and i - dic[v] <= k:
return True
dic[v] = i
return False |
class Bounds:
def __init__(self, minimum, maximum):
self.minimum = minimum
self.maximum = maximum
def keep_in_bounds(self, value):
if value < self.minimum:
return self.minimum
if value > self.maximum:
return self.maximum
return value
|
# Description: Run the PE75 function from the pymolshortcuts.py file to show the pearl effect with the inner sphere scaled by 0.75 of the van der Waals surface.
# Source: placeHolder
"""
cmd.do('cmd.do("PE75")')
"""
cmd.do('cmd.do("PE75")')
|
"""
Write a Python program to convert a list of multiple integers into a single integer.
"""
l = [11, 33, 50]
print("Original List: ", l)
x = int("".join(map(str, l)))
print("Single integer: ",x) |
company = 'Tesla'
model = 'Model 3'
fsd = 12000
base_price = 36000
tax_per = 7.5
retail = (fsd + base_price)
tax = ((fsd + base_price) * tax_per )/100
print(retail+tax)
print(type(company))
print(type(base_price))
print(type(tax_per))
print(type(retail))
|
'''
import gym
from myrl.environments.environment import Environment
def make(name, gamma):
if name == 'CartPole-v0':
return GymCartPole(name=name, gamma=gamma)
else:
raise ValueError('Agent name [' + name + '] not found.')
class GymCartPole(Environment):
def __init__(self, name, gamma):
Environment.__init__(self, name=name, actions=[0, 1], gamma=gamma)
self.env = gym.make('CartPole-v0')
def get_state_dimension(self):
return 4
def get_state_dtype(self):
return float
def get_state_magnitude(self):
return -self.x_threshold, self.x_threshold
def get_initial_state(self):
return self.env.reset()
def step(self, s, a):
"""
:param s: state
:param a: action
:return: r, s_p, is_terminal(s_p)
"""
s_p, r, is_terminal, _ = self.env.step(a)
return r, s_p, is_terminal
def get_info(self):
"""
Get general information to be saved on disk.
"""
return {
'name': self.name,
'actions': self.actions,
'gamma': self.gamma
}
''' |
# -*- coding: utf-8 -*-
#
class AB2R():
# AB2/TR method as described in 3.16.4 of
#
# Incompressible flow and the finite element method;
# Volume 2: Isothermal laminar flow;
# P.M. Gresho, R.L. Sani.
#
# Here, the Navier-Stokes equation is written as
#
# Mu' + (K+N(u)) u + Cp = f,
# C^T u = g.
#
# For incompressible Navier-Stokes,
#
# rho (u' + u.nabla(u)) = - nabla(p) + mu Delta(u) + f,
# div(u) = 0,
#
# we have
#
# M = rho,
# K = - mu \Delta,
# N(u) = rho * u.nabla(u),
# C = nabla,
# C^T = div,
# g = 0.
#
def __init__(self):
return
# Initial AB2/TR step.
def ab2tr_step0(u0,
P,
f, # right-hand side
rho,
mu,
dudt_bcs=None,
p_bcs=None,
eps=1.0e-4, # relative error tolerance
verbose=True
):
if dudt_bcs is None:
dudt_bcs = []
if p_bcs is None:
p_bcs = []
# Make sure that the initial velocity is divergence-free.
alpha = norm(u0, 'Hdiv0')
if abs(alpha) > DOLFIN_EPS:
warn('Initial velocity not divergence-free (||u||_div = %e).'
% alpha
)
# Get the initial u0' and p0 by solving the linear equation system
#
# [M C] [u0'] [f0 - (K+N(u0)u0)]
# [C^T 0] [p0 ] = [ g0' ],
#
# i.e.,
#
# rho u0' + nabla(p0) = f0 + mu\Delta(u0) - rho u0.nabla(u0),
# div(u0') = 0.
#
W = u0.function_space()
WP = W*P
# Translate the boundary conditions into product space. See
# <http://fenicsproject.org/qa/703/boundary-conditions-in-product-space>.
dudt_bcs_new = []
for dudt_bc in dudt_bcs:
dudt_bcs_new.append(DirichletBC(WP.sub(0),
dudt_bc.value(),
dudt_bc.user_sub_domain()))
p_bcs_new = []
for p_bc in p_bcs:
p_bcs_new.append(DirichletBC(WP.sub(1),
p_bc.value(),
p_bc.user_sub_domain()))
new_bcs = dudt_bcs_new + p_bcs_new
(u, p) = TrialFunctions(WP)
(v, q) = TestFunctions(WP)
# a = rho * dot(u, v) * dx + dot(grad(p), v) * dx \
a = rho * inner(u, v) * dx - p * div(v) * dx \
- div(u) * q * dx
L = _rhs_weak(u0, v, f, rho, mu)
A, b = assemble_system(a, L, new_bcs)
# Similar preconditioner as for the Stokes problem.
# TODO implement something better!
prec = rho * inner(u, v) * dx \
- p*q*dx
M, _ = assemble_system(prec, L, new_bcs)
solver = KrylovSolver('gmres', 'amg')
solver.parameters['monitor_convergence'] = verbose
solver.parameters['report'] = verbose
solver.parameters['absolute_tolerance'] = 0.0
solver.parameters['relative_tolerance'] = 1.0e-6
solver.parameters['maximum_iterations'] = 10000
# Associate operator (A) and preconditioner matrix (M)
solver.set_operators(A, M)
# solver.set_operator(A)
# Solve
up = Function(WP)
solver.solve(up.vector(), b)
# Get sub-functions
dudt0, p0 = up.split()
# Choosing the first step size for the trapezoidal rule can be tricky.
# Chapters 2.7.4a, 2.7.4e of the book
#
# Incompressible flow and the finite element method,
# volume 1: advection-diffusion;
# P.M. Gresho, R.L. Sani,
#
# give some hints.
#
# eps ... relative error tolerance
# tau ... estimate of the initial 'time constant'
tau = None
if tau:
dt0 = tau * eps**(1.0/3.0)
else:
# Choose something 'reasonably small'.
dt0 = 1.0e-3
# Alternative:
# Use a dissipative scheme like backward Euler or BDF2 for the first
# couple of steps. This makes sure that noisy initial data is damped
# out.
return dudt0, p0, dt0
def ab2tr_step(
W, P, dt0, dt_1,
mu, rho,
u0, u_1, u_bcs,
dudt0, dudt_1, dudt_bcs,
p_1, p_bcs,
f0, f1,
tol=1.0e-12,
verbose=True
):
# General AB2/TR step.
#
# Steps are labeled in the following way:
#
# * u_1: previous step.
# * u0: current step.
# * u1: next step.
#
# The same scheme applies to all other entities.
#
WP = W * P
# Make sure the boundary conditions fit with the space.
u_bcs_new = []
for u_bc in u_bcs:
u_bcs_new.append(DirichletBC(WP.sub(0),
u_bc.value(),
u_bc.user_sub_domain()))
p_bcs_new = []
for p_bc in p_bcs:
p_bcs_new.append(DirichletBC(WP.sub(1),
p_bc.value(),
p_bc.user_sub_domain()))
# Predict velocity.
if dudt_1:
u_pred = u0 \
+ 0.5*dt0*((2 + dt0/dt_1) * dudt0 - (dt0/dt_1) * dudt_1)
else:
# Simple linear extrapolation.
u_pred = u0 + dt0 * dudt0
uu = TrialFunctions(WP)
vv = TestFunctions(WP)
# Assign up[1] with u_pred and up[1] with p_1.
# As of now (2013/09/05), there is no proper subfunction assignment in
# Dolfin, cf.
# <https://bitbucket.org/fenics-project/dolfin/issue/84/subfunction-assignment>.
# Hence, we need to be creative here.
# TODO proper subfunction assignment
#
# up1.assign(0, u_pred)
# up1.assign(1, p_1)
#
up1 = Function(WP)
a = (dot(uu[0], vv[0]) + uu[1] * vv[1]) * dx
L = dot(u_pred, vv[0]) * dx
if p_1:
L += p_1 * vv[1] * dx
solve(a == L, up1,
bcs=u_bcs_new + p_bcs_new
)
# Split up1 for easier access.
# This is not as easy as it may seem at first, see
# <http://fenicsproject.org/qa/1123/nonlinear-solves-with-mixed-function-spaces>.
# Note in particular that
# u1, p1 = up1.split()
# doesn't work here.
#
u1, p1 = split(up1)
# Form the nonlinear equation system (3.16-235) in Gresho/Sani.
# Left-hand side of the nonlinear equation system.
F = 2.0/dt0 * rho * dot(u1, vv[0]) * dx \
+ mu * inner(grad(u1), grad(vv[0])) * dx \
+ rho * 0.5 * (inner(grad(u1)*u1, vv[0])
- inner(grad(vv[0]) * u1, u1)) * dx \
+ dot(grad(p1), vv[0]) * dx \
+ div(u1) * vv[1] * dx
# Subtract the right-hand side.
F -= dot(rho*(2.0/dt0*u0 + dudt0) + f1, vv[0]) * dx
# J = derivative(F, up1)
# Solve nonlinear system for u1, p1.
solve(
F == 0, up1,
bcs=u_bcs_new + p_bcs_new,
# J = J,
solver_parameters={
# 'nonlinear_solver': 'snes',
'nonlinear_solver': 'newton',
'newton_solver': {
'maximum_iterations': 5,
'report': True,
'absolute_tolerance': tol,
'relative_tolerance': 0.0
},
'linear_solver': 'direct',
# 'linear_solver': 'iterative',
# # The nonlinear term makes the problem
# # generally nonsymmetric.
# 'symmetric': False,
# # If the nonsymmetry is too strong, e.g., if
# # u_1 is large, then AMG preconditioning
# # might not work very well.
# 'preconditioner': 'ilu',
# #'preconditioner': 'hypre_amg',
# 'krylov_solver': {'relative_tolerance': tol,
# 'absolute_tolerance': 0.0,
# 'maximum_iterations': 100,
# 'monitor_convergence': verbose}
})
# # Simpler access to the solution.
# u1, p1 = up1.split()
# Invert trapezoidal rule for next du/dt.
dudt1 = 2 * (u1 - u0)/dt0 - dudt0
# Get next dt.
if dt_1:
# Compute local trunction error (LTE) estimate.
d = (u1 - u_pred) / (3*(1.0 + dt_1 / dt))
# There are other ways of estimating the LTE norm.
norm_d = numpy.sqrt(inner(d, d) / u_max**2)
# Get next step size.
dt1 = dt0 * (eps / norm_d)**(1.0/3.0)
else:
dt1 = dt0
return u1, p1, dudt1, dt1
|
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# file_name: COMMON.py
# author: ScCcWe
# time: 2022/3/5 9:32 上午
DEBUG = True
MODULE_NAME = "pymysql_dao"
|
#!/usr/bin/env python
"""
_ThreadPool_t_
ThreadPool test methods
"""
__all__ = []
|
# Scrapy settings for worldmeters project
#
# For simplicity, this file contains only settings considered important or
# commonly used. You can find more settings consulting the documentation:
#
# https://docs.scrapy.org/en/latest/topics/settings.html
# https://docs.scrapy.org/en/latest/topics/downloader-middleware.html
# https://docs.scrapy.org/en/latest/topics/spider-middleware.html
BOT_NAME = 'worldmeters'
SPIDER_MODULES = ['worldmeters.spiders']
NEWSPIDER_MODULE = 'worldmeters.spiders'
# Crawl responsibly by identifying yourself (and your website) on the user-agent
#USER_AGENT = 'worldmeters (+http://www.yourdomain.com)'
# Obey robots.txt rules
ROBOTSTXT_OBEY = True
DOWNLOAD_DELAY = 3
COOKIES_ENABLED = False
# scrapy-user-agents uses a file with 2200 user-agent strings
DOWNLOADER_MIDDLEWARES = {
'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware': None,
'scrapy_user_agents.middlewares.RandomUserAgentMiddleware': 400,
}
# splash setting
# SPLASH_URL = 'http://localhost:8050'
# DOWNLOADER_MIDDLEWARES = {
# 'scrapy_splash.SplashCookiesMiddleware': 723,
# 'scrapy_splash.SplashMiddleware': 725,
# 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware': 810,
# }
# SPIDER_MIDDLEWARES = {
# 'scrapy_splash.SplashDeduplicateArgsMiddleware': 100,
# }
# DUPEFILTER_CLASS = 'scrapy_splash.SplashAwareDupeFilter'
# HTTPCACHE_STORAGE = 'scrapy_splash.SplashAwareFSCacheStorage' |
# Multiplicación
x, y, z = 0.1, 10, 12
a = x * y * z # 12.0
a = x * x * x # 0.001
a = y * y * y # 1000
a = x * z * z # 14.4
a = z * z # 144
a = y * z * y # 1200
print("Final") |
class Maximum(Bound):
__metaclass__ = ABCMeta
class MaximumWidth(
Property,
Minimum,
):
pass
class MinimumHeight(
Property,
Minimum,
):
pass
|
"""
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes.
You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity.
Example 1:
Input: 1->2->3->4->5->NULL
Output: 1->3->5->2->4->NULL
Example 2:
Input: 2->1->3->5->6->4->7->NULL
Output: 2->3->6->7->1->5->4->NULL
"""
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
def __repr__(self):
return repr(self.val) # to print the Node values
class Solution:
def __init__(self, head=None):
self.head = head
def print_list(self, head):
"""
This will return entire linkedlist.
"""
nodes = list() # create empty list first
curr = head # current pointer is at the head of the list
while curr: # while current node has val and does not contains None, loop over
nodes.append(repr(curr)) # append val of current node to the nodes list
curr = curr.next # now the current pointer shifts to the next node
return '->'.join(nodes) + "->None" # return list of all elements in the linkedlist
def append(self, data):
if not self.head: # check if head is None
self.head = ListNode(val=data) # add first value to the head and return
return
curr = self.head # if head is not None, head is the current node
while curr.next: # loop till the point we reach None
curr = curr.next # point next node to current pointer
curr.next = ListNode(val=data) # add new listnode at end of linkedlist having found None
def oddEvenList(self, head: ListNode) -> ListNode:
curr = head # current node is the head of linkedlist
values = list() # initialize list to hold node values
while curr:
values.append(curr.val) # append value of the current node
curr = curr.next # go to the next node
i = 0 # start from index 0 for odd values
curr = head # point current node back to head again
while i < len(values):
curr.val = values[i] # add odd values from the value list
curr = curr.next # move to next node
i += 2 # increment counter by 2
i = 1 # start from index 1 for even values
while i < len(values):
curr.val = values[i] # add even values from the value list
curr = curr.next # next node
i += 2 # increment counter by 2
return head
s1 = Solution()
s1.append(1)
s1.append(2)
s1.append(3)
s1.append(4)
s1.append(5)
print("Original LinkedList: ", s1.print_list(s1.head))
oe = s1.oddEvenList(s1.head)
print("Odd-Even LinkedList: {}\n".format(s1.print_list(oe)))
s2 = Solution()
s2.append(2)
s2.append(1)
s2.append(3)
s2.append(5)
s2.append(6)
s2.append(4)
s2.append(7)
print("Original LinkedList: ", s2.print_list(s2.head))
oe = s2.oddEvenList(s2.head)
print("Odd-Even LinkedList: {}\n".format(s2.print_list(oe)))
|
# Good morning! Here's your coding interview problem for today.
# This problem was asked by Stripe.
# Given an array of integers, find the first missing positive integer in linear time and constant space.
# In other words, find the lowest positive integer that does not exist in the array.
# The array can contain duplicates and negative numbers as well.
# For example, the input [3, 4, -1, 1] should give 2. The input [1, 2, 0] should give 3.
# You can modify the input array in-place.
list = [3, 5, 2, -1, 1,6,5]
# didn't find this one in linear time, because i didn't understand that making a constant number of iteration on the whole
# set is still linear time...
# Remove non-positive numbers
for i in range(len(list)-1,-1, -1):
if list[i] <= 0 :
list.pop(i)
# Setting negative values at index found
for v in list:
if abs(v) <= len(list):
list[abs(v)-1] = - list[abs(v)-1]
# Searching the first positive value
solution = len(list)+1
for i in range(0,len(list)-1):
if list[i] > 0:
solution = i + 1
break
print (solution) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.