def __init__(self): self.unit_list = [] self.unit_menu = unit_menu() self.base = { 'left': base(BASE_MAX_HP[0], POS_LEFT, 'left'), 'right': base(BASE_MAX_HP[0], POS_RIGHT, 'right') } self.enemy_menu = enemy_menu()
def getImageInfo(image, imagePath): """ Get image information :param image:image :param imagePath: image path :return:image info list """ b = base() _imgInfoList = [] _imgList = [] def _getImageInfoList(imgList): for i in imgList: _image = b.getFileName(i) _imageName = b.getFileNameNoSuffix(_image) _imageInfoFile = b.definedFileSuffix(_imageName, "txt") _imageInfoFile = imagePath + "/" + _imageInfoFile with open(_imageInfoFile, 'r', encoding='utf-8') as f: imageInfo = f.readline().strip("\n") _imgInfoList.append(imageInfo) return _imgInfoList if type(image) != list: _imgList.append(image) _imgInfoList = _getImageInfoList(_imgList) return _imgInfoList[0] else: _imgInfoList = _getImageInfoList(image) return _imgInfoList
def benchmark(): N = 9 win_random = 0 win_minimax = 0 for k in range(1000): judge = base(N) agent_random = random(N) agent_minimax = minimax(N) for l in range(N*N): color = l % 2 + 1 if (k + l) % 2 == 0: v, x, y = agent_random.play(color) else: v, x, y = agent_minimax.play(color) judge.make(x, y, color) agent_random.make(x, y, color) agent_minimax.make(x, y, color) if judge.checkwin() == 1: winner = N*N%2 + 1 else: winner = (N*N-1)%2 + 1 if winner == k % 2 + 1: win_random += 1 else: win_minimax += 1 print(win_random, win_minimax)
def testSetTest(testSet, imageinfopath, feats, imgNames): """ Verify test set test cases. :param testSet:test set :param imageinfopath:image info path :param feats:feature :param imgNames:image name :return: """ b = base() resultnum = 2 imageList = b.getFileList(testSet, "JPEG") probability = 00.00 num = len(imageList) errorNum = 0 for i in imageList: rank_ID, rank_score = featureSearch(i, feats) # 获取图像得分信息 imList, scoresList = getSearchResult(resultnum, imgNames, rank_ID, rank_score) _imageInfo1 = getImageInfo(i, imageinfopath) # 获取图片信息 _imageInfo2 = getImageInfo(imList[0], imageinfopath) if _imageInfo1 != _imageInfo2: errorNum += 1 print("测试集错误的图片信息: ", _imageInfo1) print("错误的图片最匹配的图片信息:", _imageInfo2) print("测试集错误的图片: ", i) print("错误的图片最匹配的图片:", imList[0]) print("相似度评分:", scoresList) probability = errorNum / num print("错误率: %.2f%%" % (probability * 100)) return 0
def crane_45deg_mirror(): """Mount for 45deg movable mirror""" screw_dist_from_center = 30/2/2**.5 # Four holes on circle d=30 mirror_plate_wh = 30 thick = 10 mirror_offset = 35 # TODO: calc dist_to_cam = 300 mirror_angle_deg = -numpy.rad2deg(numpy.arctan(mirror_offset/dist_to_cam))/2 plate = rounded_plate((40, 40, thick), 2) plate -= rounded_plate((30, 30, 2*thick), 2) mirror_plate_blank = rounded_plate((mirror_plate_wh, mirror_plate_wh, thick), 2) mirror_plate_blank += hole()(cylinder(d=20, h=2*thick, center=True)) mirror_plate_threads = mirror_plate_blank for (x,y) in itertools.product((1, -1), (1,-1)): thread = hole()(rotate((0, 180, 0))(sunk_hole())) # from above into z=0 mirror_plate_threads += translate((x*screw_dist_from_center, y*screw_dist_from_center, thick/2))(thread) mirror_plate_threads = rotate((0, mirror_angle_deg, 0))(mirror_plate_threads) mirror_plate_threads = translate((0, 0, 40*numpy.tan(numpy.deg2rad(-mirror_angle_deg))))(mirror_plate_threads) plate += translate((mirror_offset, 0, 0))(mirror_plate_blank) plate += translate((mirror_offset, 0, 0))(mirror_plate_threads) plate += base() return plate
def searchTest(): """ test function :return: """ from sys import argv imgpath = argv[1] print("需要检索的图像: ", imgpath) t = time() b = base() scoreList = [] isearchName = b.getImageName3(imgpath) isearch = getFeatus(imgpath) _feat = loadData("./model/feat_M.npy") _file = loadData("./model/file_M.npy") for feat, file in zip(_feat, _file): test = [] _score = knn(isearch, np.array(feat)) test.append(float(_score)) test.append(file) scoreList.append(test) scoreList.sort(reverse=True) print("匹配相似度最高的3个图像和分数:", scoreList[:3]) print("检索时间: %.2f s" % (time() - t)) showImage(isearchName, "Retrieve Images") showImage2(scoreList, 3) return 0
def gen(self, dataset, size): judge = base(self.N) judge.count = self.N**2 order = [] for i in range(self.N**2): judge.board[i] = i % 2 + 1 order += [i] datax = [] datay = [] for i in range(size): shuffle(judge.board) shuffle(order) for k in range(self.N**2): p = order[k] if judge.board[p] == (self.N**2-1) % 2 + 1: judge.unmake(p // self.N, p % self.N) for k in range(self.N**2): datax += [1 if judge.board[k] == 1 else 0] datax += [1 if judge.board[k] == 2 else 0] judge.make(p // self.N, p % self.N, (self.N**2-1) % 2 + 1) datay += [(-judge.checkwin() + 1)/2] break datax = np.asarray(datax, dtype=np.int8) datax = datax.reshape([-1, self.N, self.N, 2]) datay = np.asarray(datay, dtype=np.int8) np.savez(dataset + "_x.npz", datax) np.savez(dataset + "_y.npz", datay)
def recallRate(): """ testing recall :return: """ recallList = [] b = base() _testImgList = b.getFileList("H:/datasets/testingset", "JPEG") import random testList = random.sample(_testImgList, 40) feats, imgNames = rH5FileData2("feature", "imagename", "./models/imageCNNAll.h5") for queryImage in testList: rank_ID, rank_score = featureSearch(queryImage, feats) imList, scoresList = getSearchResult(40, imgNames, rank_ID, rank_score) imgInfoList = getImageInfo(imList, "H:/datasets/imageinfo") _imageInfo = getImageInfo(queryImage, "H:/datasets/imageinfo") # 获取图片信息 count = imgInfoList.count(_imageInfo) recallList.append(count / 40) print(recallList) print("recall rate:", (sum(recallList) / len(recallList))) return 0
def xxt_bus(query_data, path): headers: { 'Content-Type': 'application/x-www-form-urlencoded', 'Content-Length': postData.length } data = base(query_data) url = 'http://nxxtapi.gzyyjt.net:9009' + path response = requests.post(url, data=data) return response.text
def dataWriteFile2(): """ Data summary writes to the file. :return: """ b = base() fileList = b.getFileList("H:/datasets/M/", "JPEG") _file, _feat, _info = getAllList(fileList) saveData(_file, "./model/file.npy") saveData(_feat, "./model/feat.npy") saveData(_info, "./model/info.npy") return 0
def tick(): actualTime = dt.now().strftime("%H:%M") if actualTime != horaEnvio: print (("NOOOO ES LA MISMA " + actualTime + " = "+ horaEnvio)) print (("SALIENDO DE LA FUNCION ")) return #INICIO DE CONCATENACION DE DATOS control = concat() control.loop() time.sleep(30) #FIN CONCATENACION DE DATOS logging.basicConfig(filename = logfile, level=logging.INFO) dati = dt.now().strftime("%Y-%b-%d %H:%M:%S") logging.info(dati + ' - Inicio de envio ') #LOGG control = base(logging) if control.vpnuse: print (("CONEXION POR VPN SE ENCUENTRA ACTIVADA")) if not vpnconnect(): return True else: print (("CONEXION POR VPN SE ENCUENTRA DESACTIVADA")) #control = base() codigoprov = control.codprov print (("PROVINCIA: ", codigoprov)) #Anulado el borrado porque se pas[o a la clase concar #control.delTempTables(codigoprov) provincia = control.cursor.execute(""" SELECT DISTINCT codprov_conex.link, codprov_conex.codigoprov, codprocedimientos.nombre FROM public.codprov_conex INNER JOIN public.codprocedimientos ON (codprov_conex.codigoproced = codprocedimientos.codigoproced) WHERE codprov_conex.activo=true AND codprov_conex.codigoprov=%s""" % codigoprov) #22/08/2018 Se saco la condicion de que la provioncia se encuentre activa #para que ingrese sea tenida en cuenta activo=true AND #19/09/2018 La condicion anteirormente mencionada ,se agrego nevamente para Salta prov_conex = control.cursor.fetchall() for info_conex in prov_conex: print (("OBTENIENDO DATOS PARA ENVIAR: Conexion_link: "+ info_conex[0] +" Procedimiento: " +str(info_conex[2]) + " Cod_provincia: "+ str(info_conex[1]))) resp = control.control_caso_c(info_conex[0], info_conex[2], info_conex[1]) if resp: print (("TRUE: SE INSERTARON CORRECTAMENTE")) else: print (("FALSE: NO SE INSERTARON DATOS")) logging.info(dati + ' - No se insertaron datos de la tabla: '+ str(info_conex[2])) #A CONTINUACION SE ELIMINA LA TABLA TEMPORTAL #control.delTempTables(codigoprov) control.Desconect() vpndisconnect() del control dati = dt.now().strftime("%Y-%b-%d %H:%M:%S") logging.info(dati + ' - Fin de envio')
def cage_3_clips(z_length=10, inside=False): """3 clips arranged in proper distances for cage, aligned to optical axis at 0,0.""" third_rod_y = base.rods30_dist_third_rod - 25 # main pair of rods is at y=-25 clip_pair = base.base(z_length=z_length) single_clip = base.single_rod_clamp(z_length) if inside: clip_pair = translate((0, -50, 0))(mirror( (0, 1, 0))(clip_pair)) # clip at 25, needs to be moved back. single_clip = mirror((0, 1, 0))(single_clip) single_clip = translate((0, third_rod_y, 0))(rotate( (0, 0, 180))(single_clip)) return clip_pair + single_clip
def rpi_mount(assemble=False, hole_diam=3): """Mount for Raspberry Pi using four screws. Clipped to side of cage. Requires four cylindrical spacers. RPi is in (optical) XZ-plane. Plate is printed in (printer) XY plane https://www.raspberrypi.org/documentation/hardware/raspberrypi/mechanical/rpi_MECH_3bplus.pdf""" hole_sep_z = 58 hole_sep_x = 49 strut_width = 10 strut_thick = 3 hole_diagonal = (hole_sep_x**2 + hole_sep_z**2)**.5 strut_angle_deg = numpy.rad2deg(numpy.arctan(hole_sep_x / hole_sep_z)) # angle < 45° diag_strut = strut_with_holes(hole_diagonal, strut_thick, strut_width, hole_diam=hole_diam) cross = rotate((0, 0, -strut_angle_deg))(diag_strut) cross += rotate((0, 0, strut_angle_deg))(diag_strut) cross = translate((0, 0, +strut_thick / 2))(cross) # to z=0...-thick, baseplate = base.base( rod_sep=base.rods30_diag_third_rod ) # works for threads20 as well: superfluous kwargs are ignored. mount_strut = rotate((-90, 0, 0))(translate( (0, 20, 0))(baseplate)) # from optical-axis coords to our coords. cross += translate((0, hole_sep_z / 2 - strut_width, 0))(mount_strut) cross += translate((0, -hole_sep_z / 2 + strut_width, 0))(mount_strut) if assemble: cross = translate( (20, -base.rods30_diag_third_rod / 2 - 25, 0))(rotate( (90, 0, -90))(cross)) else: spacer_height = 5 spacer = cylinder(d=2 * hole_diam, h=spacer_height, center=True) spacer -= cylinder(d=1.2 * hole_diam, h=spacer_height + 1, center=True) for x in [15, 15 + 2.5 * hole_diam, -15, -15 - 2.5 * hole_diam]: cross += translate((x, 0, spacer_height / 2))(spacer) return cross
def crane_mirror(assemble=True, mirror_offset_x=25, crane_only=False): """Mount for 45deg movable mirror assemble=True: put things where they're supposed to go assemble=False: put things on printer bed""" thick = 10 dist_to_cam = 200 arm_width = 5.5 mirror_z = 17 rod_thick = 6 rod_to_mirror = 2*arm_width deflection_angle_rad = numpy.pi/2+numpy.arctan(mirror_offset_x/dist_to_cam) mirror_angle_rad = deflection_angle_rad/2 rod_z = mirror_z - rod_to_mirror*numpy.cos(mirror_angle_rad) # z-height of rod for y-rotation rod_x = mirror_offset_x + rod_to_mirror*numpy.sin(mirror_angle_rad) plate = rounded_plate((40, 40, thick), 2) plate -= translate((10,0,0))(rounded_plate((50, 30, 2*thick), 2)) arm_length = rod_x-20 clip_arm = cube((arm_length+arm_width, thick, arm_width), center=True) # thick <-> width because rotated x<->z clip_arm = rotate((90, 0, 0))(clip_arm) clip_arm = translate((arm_length/2+20, 20-arm_width/2, 0))(clip_arm) clip_arm += translate((rod_x, 20-arm_width/2, rod_z))(rotate((-90, 0, 0))(single_rod_clamp(arm_width))) plate += clip_arm plate += mirror((0, 1, 0))(clip_arm) if not crane_only: mirror_intermediate = crane_mirror_intermediate(rod_thick, arm_width, rod_to_mirror, assemble) if assemble: plate += translate((rod_x, 0, rod_z))( rotate((0, -numpy.rad2deg(mirror_angle_rad), 0))(mirror_intermediate) ) else: plate += translate((mirror_offset_x + 30, 0, -thick/2+rod_thick/2))(mirror_intermediate) plate += base() if assemble: plate = rotate((0, 180, 0))(plate) return plate
def dataWriteFile(num): """ Write the data in batches to the file. :param num: :return: """ b = base() fileList = b.getFileList("H:/datasets/M/M%.2d/" % num, "JPEG") # infoList = b.getImageInfo (fileList, "H:\datasets\imageinfo") t = time() _file, _feat, _info = getAllList(fileList) print("M%.2d获取特征时间:" % num, time() - t) saveData(_file, "./model/file_M%.2d.npy" % num) saveData(_feat, "./model/feat_M%.2d.npy" % num) saveData(_info, "./model/info_M%.2d.npy" % num) return 0
def imgSearch(imgpath): """ image search :param imgpath: :return: """ t = time() b = base() scoreList = [] # 检索图像名称 isearchName = b.getImageName3(imgpath) isearch = getFeatus(imgpath) _feat = loadData("./model/feat_M.npy") _file = loadData("./model/file_M.npy") for feat, file in zip(_feat[:1700], _file[:1700]): test = [] _score = knn(isearch, np.array(feat)) test.append(float(_score)) test.append(file) scoreList.append(test) # for i in range(1700): # test = [] # _score = knn (isearch,np.array(_feat[i])) # test.append (float(_score)) # test.append (_file[i]) # scoreList.append(test) # 排序 scoreList.sort(reverse=True) # 显示 # showImage (isearchName,"Search Image") # showImage2(scoreList,3) print("匹配分数:", scoreList[:3]) print("检索时间: %.2f s" % (time() - t)) imgName = b.plusName(scoreList[2][1]) kp1 = getFeatus2(imgpath) kp2 = getFeatus2(imgName) showImage3(imgpath, imgName, kp1, kp2, isearch, getFeatus(imgName)) return 0
def getAllList(fileList): """ Extract all information from the file list. :param fileList: :return: """ b = base() # 特征数据列表 _featList = [] # 图像名称列表 _fileNameList = [] # 图像信息列表 _fileInfoList = [] for i in fileList: _featList.append(getFeatus(i)) _fileNameList.append(b.getImageName2(b.getImageName(i))) _fileInfoList = b.getImageInfo(fileList, "D:\data\imageinfo") return _fileNameList, _featList, _fileInfoList
def rpi_cam_mount(assemble=False): # https://www.raspberrypi.org/documentation/hardware/camera/mechanical/rpi_MECH_Camera2_2p1.pdf # 2016-11-30: printed; works. but: needs 4 spacers to keep the smd components on the back of the camera from touching the plate. rpi_thick = 3 strut_y_end = 14.5 struts_x = [-7.5, 7.5] strut_thick = 3 base_thick = 5 # base_plate = translate([0, -20+base_thick/2, 0])(cube([40, base_thick, 10], center=True)) base_plate = translate([0, -20 + base_thick / 2, 0])(rotate([90, 0, 0])(rounded_plate([30, 10, base_thick], 2))) base_plate += base() plate = translate([0, 0, -5])(rpi_cam_plate(rpi_thick)) for strut_x in struts_x: strut = translate([strut_x, -(20 - strut_y_end) / 2, 0])(cube([strut_thick, 20 + strut_y_end, 10], center=True)) cyl = rotate([0, 90, 0])(cylinder( r=10, h=50, center=True)) # cylinder along x-axis, in origin cyl = scale([1, (strut_y_end + 20 - base_thick) / 10, 1])(cyl) # z=10, y = strut height cyl = translate([0, -20 + base_thick, -5])(cyl) # axis into front top edge of base plate strut *= cyl plate += strut mount = base_plate + plate return mount
'--yaml', dest='yaml', action='store_true', default=False, help='create makefile via yaml') parser.add_option('-c', '--config', dest='config', action='store_true', default=False, help='create makefile via config') parser.add_option('-p', '--push', dest='push', action='store_true', default=False, help='git push makefile') option, args = parser.parse_args(sys.argv[1:]) mk = makefile() if (option.yaml): mk.create_via_yaml(args[0]) elif (option.config): mk.create_via_config(base.config(args[0])) elif (option.push): mk.create_git_push(args) else: base.base().die("unknown command")
def loop(self): logging.basicConfig(filename=logfile, level=logging.INFO) dati = datetime.datetime.now().strftime("%Y-%b-%d %H:%M:%S") logging.info(dati + ' - Inicio de Concatenacion ') control = base(logging) codigoprov = control.codprov print(("PROVINCIA: ", codigoprov)) proced = self.obtainProced(control, codigoprov) cuenta = 1 for pro in proced: print((str(cuenta) + " - PROCEDIMIENTO: ", pro[0], pro[1])) cuenta = cuenta + 1 cod_proced = pro[0] nombre_proced = pro[1] self.deltable(control, nombre_proced) self.newtable(control, nombre_proced) prov_conex = self.obtainLocalTables(control, codigoprov, cod_proced) for info_conex in prov_conex: print(("OBTENIENDO DATOS PARA ENVIAR: ", info_conex[2], info_conex[3], info_conex[4], info_conex[10])) sridPosgar94 = info_conex[10] if not self.existtable(control, info_conex[4]): print(("NO EXISTE LA TABLA " + info_conex[4] + " Y SERA DESACTIVADA DE LA CONFIGURACION.")) self.disableTable(control, info_conex[4], codigoprov, logging, "-No existe la tabla-") else: validcol = self.validColumnNames(control, info_conex[4]) if not validcol: print(( "LA TABLA " + info_conex[4] + " NO TIENE LOS CAMPOS SOLICITADOS Y SERA DESACTIVADA" )) self.disableTable(control, info_conex[4], codigoprov, logging, "-No tiene las columnas correctas-") nullexped = self.nullexped(control, info_conex[4]) if nullexped > 0: print(( "Numero de registros con faltante de EXPEDIENTE EN: " + info_conex[4] + " ES: ", nullexped)) logging.info( 'La tabla ' + info_conex[4] + " tiene " + str(nullexped) + " registros con faltante del dato EXPEDIENTE.") resp = self.insertDataFromSelect(control, info_conex[4], nombre_proced, sridPosgar94) #resp = False if resp: print(("TRUE: SE INSERTARON CORRECTAMENTE")) else: print(("FALSE: NO SE INSERTARON DATOS")) logging.info( dati + ' - No se insertaron datos de la tabla: ' + str(info_conex[4])) control.Desconect() del control dati = datetime.datetime.now().strftime("%Y-%b-%d %H:%M:%S") logging.info(dati + ' - Fin de envio')
import requests import os import json import ast import glob import errno from base import base dir_path = os.path.dirname(os.path.realpath(__file__)) COOKIE_ROOT = dir_path + '/cookies' ROUTES_FILE = dir_path + '/res/routes' TEST_FILE = dir_path + '/res/test' base = base(COOKIE_ROOT, ROUTES_FILE, TEST_FILE) while 1: base.line() for i in range(int(base.columns) / 2 - 5): sys.stdout.write(' ') sys.stdout.flush() print '\033[1m[req]\033[0;0m' base.get_routes_from_file() base.display_routes() base.line() print 'type \'cmds\' for commands' base.get_command(raw_input()) base.short.clear()
def init(self): ''' function for initialization ''' # Load textures self.tex.loadTexture() # Load shaders and verify each myShaders = shaderSetup(None) self.tshader = myShaders.readAndCompile("texture.vert", "texture.frag") if self.tshader <= 0: print("Error setting up Texture shaders") raise Exception("Error setting up Texture Shaders", "fatal") sys.exit(1) self.pshader = myShaders.readAndCompile("ball.vert", "ball.frag") if self.pshader <= 0: print("Error setting up Phong shaders") raise Exception("Error setting up Phong Shaders", "fatal") sys.exit(1) self.bshader = myShaders.readAndCompile("base.vert", "base.frag") if self.bshader <= 0: print("Error setting up Base shaders") raise Exception("Error setting up Base Shaders", "fatal") sys.exit(1) self.sshader = myShaders.readAndCompile("stand.vert", "stand.frag") if self.sshader <= 0: print("Error setting up Stand shaders") raise Exception("Error setting up Stand Shaders", "fatal") sys.exit(1) self.lshader = myShaders.readAndCompile("tilt.vert", "tilt.frag") if self.lshader <= 0: print("Error setting up Tilt shaders") raise Exception("Error setting up Tilt Shaders", "fatal") sys.exit(1) self.cshader = myShaders.readAndCompile("lamp.vert", "lamp.frag") if self.cshader <= 0: print("Error setting up Lamp shaders") raise Exception("Error setting up Lamp Shaders", "fatal") sys.exit(1) # Other OpenGL initialization glEnable(GL_DEPTH_TEST) glClearColor(0.0, 0.0, 0.0, 0.0) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) glClearDepth(1.0) # create ball myShape = ball() myShape.clear() myShape.makeSphere(0.3, 30, 1) self.tVao = self.createVAO(myShape, self.pshader, self.ballBuffers) # create quad myShape = quad() myShape.clear() myShape.makeQuad() self.qVao = self.createVAO(myShape, self.tshader, self.quadBuffers) # create base myShape = base() myShape.clear() myShape.makeCylinder(80) self.bVao = self.createVAO(myShape, self.bshader, self.baseBuffers) # create stand myShape = stand() myShape.clear() myShape.makeStand(80) self.sVao = self.createVAO(myShape, self.sshader, self.standBuffers) # create tilt myShape = tilt() myShape.clear() myShape.makeTilt(80) self.lVao = self.createVAO(myShape, self.lshader, self.tiltBuffers) # create lamp myShape = lamp() myShape.clear() myShape.makeCone(0.3, 50, 50) self.cVao = self.createVAO(myShape, self.cshader, self.lampBuffers)
def round_mount_light(inner_diam=17.9, ring_thick=3, opening_angle=30, stop_inner_diam=None, cyl_length=10, clip_length=10, assemble=False): """ mount for cylinder centered on optical axis (z). If opening_angle is None, clamping tabs are added. defaults: mount for Kosmos objective :param inner_diam: usually diameter of thing to be mounted :param ring_thick: thickness of ring determines stiffness :param opening_angle: ring is opened from -angle to +angle :param stop_inner_diam: if not None, a smaller second cylinder acts as a stop, i.e. for a lens. :return: Scad object """ base_thick = 5 connector_w = 3 z_thick = 10 # thickness/z-length of entire assembly z_think_inner = 2 do_clamp = False if opening_angle is None: do_clamp = True opening_angle = numpy.arcsin(ring_thick / inner_diam) opening_angle = numpy.rad2deg(opening_angle) base_plate = translate([0, -20 + base_thick / 2, 0])(rotate([90, 0, 0])(rounded_plate([30, 10, base_thick], 4))) base_plate += translate( (0, 0, (clip_length - 10) / 2))(base(z_length=clip_length)) outer_diam = inner_diam + 2 * ring_thick ring = cyl_arc(r=outer_diam / 2, h=cyl_length, a0=90 + opening_angle, a1=90 - opening_angle) ring = translate((0, 0, (cyl_length - z_thick) / 2))(ring) if stop_inner_diam is None: ring -= cylinder(d=inner_diam, h=2 * cyl_length, center=True) else: ring -= cylinder(d=stop_inner_diam, h=2 * cyl_length, center=True) ring -= translate((0, 0, z_think_inner))(cylinder(d=inner_diam, h=z_thick, center=True)) if do_clamp: # clamps with holes extending towards +y hex_diam = 5.5 # M3 nut clamp_extension = hex_diam + 2 hole_diam = 3.5 clamp_length = ring_thick + clamp_extension single_clamp = rounded_plate((clamp_length, z_thick, ring_thick), True) through_nut_hole = cylinder(d=hole_diam, h=2 * ring_thick, center=True) through_nut_hole += translate( (0, 0, ring_thick / 2))(hexagon(hex_diam, ring_thick / 3)) single_clamp -= translate([ring_thick / 2, 0, 0])(through_nut_hole) ring += translate([ring_thick, inner_diam / 2 + clamp_length / 2, 0])(rotate([90, 0, 90])(single_clamp)) ring += translate([-ring_thick, inner_diam / 2 + clamp_length / 2, 0])(rotate([-90, 0, 90])(single_clamp)) connector_h = (40 - inner_diam) / 2 connector_yc = inner_diam / 2 + connector_h / 2 connector = translate([5, -connector_yc, 0])(cube([connector_w, connector_h, z_thick], center=True)) connector += translate([-5, -connector_yc, 0])(cube([connector_w, connector_h, z_thick], center=True)) label = "d = {:.1f}".format(inner_diam) info_text = linear_extrude(height=.5, center=True)(text( label, valign="center", halign="center", size=3., segments=1, font="Liberation Mono:style=Bold")) base_plate += translate( (0, -(20 - base_thick / 2), z_thick / 2))(info_text) mount = base_plate + ring + connector if assemble: mount = rotate((0, 180, 0))(mount) return mount
'flow': ran, 'probability': silence, 'begin': str(actual_step), 'end': str(next_step) } t += str(tpl.template_route(searchList=[dict_])) range_ptr += 12 # INTERMED if 0: #enable stage with some actual_step = next_step next_step = actual_step + ak_duration ran = [i + range_ptr for i in range(12)] dict_ = { 'flow': ran, 'probability': intermed, 'begin': str(actual_step), 'end': str(next_step) } t += str(tpl.template_route(searchList=[dict_])) range_ptr += 12 else: #use complete "silence", no traffic actual_step = next_step next_step = actual_step + 2 * ak_duration #print(t) t2 = base.base(searchList=[{'XMLZAO_DA_PORRA': t}]) print(t2)
def __init__(self, distanz): self.Datenbank = Datenbank.base("VokabelDatenbank.sqlite") self.distanz = distanz self.minTreffer = self.Datenbank.getDataAsList("select mindesttreffer from Einstellungen")[0][0]
from base import base from decisionTree import decisionTree import numpy as np base = base() movie_genre, movie_year, genres, movie_names = base.movie_genre() comedy = 1 drama = 2 fantasy = 3 war = 4 movies_genres_matrix = np.zeros(shape=(len(movie_year), len(genres)), dtype=float) movie_index = {n: movie for movie, n in enumerate(movie_genre.keys())} # tag_index = {n: tag for tag, n in enumerate(tags)} genre_list = [] # Create movie-genre matrix using count for movie, genre in movie_genre.items(): for g in genres: if g in genre: movies_genres_matrix[movie_index[movie]][genres[g]] += 1 genre_list.append(movie_genre[movie]) input_labels = [] input_movie_label = {} print "Enter number of labels:" no_labels = input() for i in range(no_labels): print "Enter label:"
@service1.rtype(list) def publica(selec): pu = base() resp = pu.Selecciona(selec) return resp @service1.params(int, str, str) @service1.rtype(bool) def reception(cod, tabla, lista): #print (("CODIGO DE PROV..." + str(cod))) #print (("TABLA ..." + str(tabla))) listaTabla = pu.transformaTextoEnLista(lista) pu.EliminaDatos(tabla, cod) pu.insertListaToTabla(cod, tabla, listaTabla) #listaExtraida = json.loads(lista) #print (("LISTA EXTRAIDA ..." + str(listaExtraida))) #resp = pu.recorreDataWebServiceB(listaExtraida, 'minas', 2) #jsresult = json.dumps('hola') return True pu = base() #config = ConfigParser.ConfigParser() #config.read('config.ini') #port = int(config.get('Publicacion', 'port')) port = 8049 httpd = make_server('0.0.0.0', port, application) httpd.serve_forever()
def publica(selec): pu = base() resp = pu.Selecciona(selec) return resp
"""Main module for command line parser. To enter the interface, just execute this file.""" from __future__ import print_function from base import base if __name__ == '__main__': while 1: print("kaichogami $:~/", end = ' ') value = raw_input() obj = base(value) obj.do()
def slide_holder(assemble=True, angle_deg=0): """deg=0: "normal" orientation: slide is perpendicular to optical axis""" dov_h = 3 dov_w0 = 5 dov_w1 = 7 dov_pad = .1 base_thick = 5 clamp_width = 8 clamp_spacing = 40 - clamp_width clamp_base = 2 clamp_reach = 20 - base_thick - clamp_base clamp_length = numpy.sqrt(2) * clamp_reach base_plate = translate([0, -(40 - base_thick) / 2, 0])(cube([40, base_thick, 10], center=True)) base_plate += base() base_plate = rotate((0, angle_deg, 0))(base_plate) base_plate += translate([0, -(40 - base_thick) / 2, 0])(cube([40, base_thick, 10], center=True)) clamp = translate([0, 0, -1])(slide_clamp(clamp_reach, clamp_length, base_height=clamp_base, width=clamp_width)) # dovetail: parts touch at y=0, tail into -y trap_pts = [[dov_w0 / 2, 0], [-dov_w0 / 2, 0], [-dov_w1 / 2, -dov_h], [dov_w1 / 2, -dov_h]] trap_pts_padded = [[dov_w0 / 2 + dov_pad, .01], [-dov_w0 / 2 - dov_pad, .01], [-dov_w1 / 2 - dov_pad, -dov_h - dov_pad], [dov_w1 / 2 + dov_pad, -dov_h - dov_pad]] trap_clear = [[dov_w0 / 4, -dov_h / 2], [-dov_w0 / 4, -dov_h / 2], [-dov_w1 / 4, -1.01 * dov_h], [dov_w1 / 4, -1.01 * dov_h]] dov_section = polygon(trap_pts) - polygon(trap_clear) dov_section_pad = polygon(trap_pts_padded) dov = linear_extrude(height=clamp_width)(dov_section) dov_pad = linear_extrude(height=2 * clamp_width)(dov_section_pad) dov = rotate([0, 90, 0])(translate([0, 0, -clamp_width / 2])(dov)) clamp += translate([0, -clamp_reach - clamp_base, 0])(dov) dov_pad = rotate([0, 90, 0])(translate([0, 0, -clamp_width])(dov_pad)) base_plate -= translate([20, -clamp_reach - clamp_base, 0])(dov_pad) base_plate -= translate([-20, -clamp_reach - clamp_base, 0])(dov_pad) if assemble: clamps = translate([1.3 * clamp_spacing / 2, 0, 0])(clamp) clamps += translate([-clamp_spacing / 2, 0, 0])(clamp) base_plate += cylinder(d=1, h=1, center=True) # visualize optical axis assembly = rotate((0, -angle_deg, 0))(base_plate + clamps) else: # separate for printing clamp = translate([30, 0, (clamp_width - 10) / 2])(rotate( (0, 90, 0))(clamp)) clamps = clamp + mirror((1, 0, 0))(clamp) base_plate = rotate((-90, 0, 0))(translate((0, 20, 0))(base_plate)) assembly = base_plate + clamps return assembly
import re from modules import RGSubModule from functions import RGFunctionFactory import base import state module = RGSubModule('t') base.base(module) #__all__ = ["module"] apply = base.apply @module @RGFunctionFactory('a') def ta(stack): stack.append(input()) @module @RGFunctionFactory('b') def tb(stack): stack.append(int(input())) @module @RGFunctionFactory('c') def tc(stack): stack.append(float(input())) @module @RGFunctionFactory('d')
__author__ = 'ryanvade' import base import fromBase myBase = base.base() myBase.printValue() myBase.printWhoAmI() myBase.value = "newValue" myBase.printValue() myBase.newValue = "A new Value" print(myBase.newValue) myFromBase = fromBase.fromBase() myFromBase.printValue() myFromBase.printWhoAmI() print(isinstance(myBase, base.base)) print(isinstance(myBase, fromBase.fromBase)) print(issubclass(base.base, fromBase.fromBase)) print(issubclass(fromBase.fromBase, base.base)) x = myBase.printValue() x()
from base import base import logging import datetime import os import psycopg2, psycopg2.extras da = datetime.date.today().strftime("%Y-%m-%d") thisfolder = os.path.dirname(os.path.abspath(__file__)) logfile = thisfolder + '/log' + da + '.log' print(('LOG FILE:' + logfile)) logging.basicConfig(filename=logfile, level=logging.INFO) dati = datetime.datetime.now().strftime("%Y-%b-%d %H:%M:%S") logging.info(dati + ' - Inicio de envio ') control = base(logging) #control = base() codigoprov = control.codprov print(("PROVINCIA: ", codigoprov)) #("salta_minas_union.gid", "geom", "area", "expediente", "expediente2", "descripcio") def insertData(tabla, wkt, expte, expte2, descripcio): try: control.cursor.execute("""INSERT INTO salta_minas_union ("gid", "geom", "expediente", "expediente2", "descripcio") VALUES (DEFAULT, '%s' , '%s', '%s', '%s')""" % (wkt, str(expte), str(expte2), str(descripcio))) except psycopg2.Error as e: pass print((e.pgerror))