Cleaned up wv_helper.py
* Formatted with autopep8 * Removed unused import typing.Any * Adding Coding Magic * Renamed argument input->inp to avoid shadowing python builtin * Removed unnecessary dummy variable creation
This commit is contained in:
parent
9cb3608b27
commit
6a68790653
@ -1,33 +1,37 @@
|
||||
from typing import Any, List
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
from typing import List
|
||||
|
||||
|
||||
def awg_equiv(mm2):
|
||||
awg_equiv_table = {
|
||||
'0.09': 28,
|
||||
'0.14': 26,
|
||||
'0.25': 24,
|
||||
'0.34': 22,
|
||||
'0.5': 21,
|
||||
'0.75': 20,
|
||||
'1': 18,
|
||||
'1.5': 16,
|
||||
'2.5': 14,
|
||||
'4': 12,
|
||||
'6': 10,
|
||||
'10': 8,
|
||||
'16': 6,
|
||||
'25': 4,
|
||||
'35': 2,
|
||||
'50': 1,
|
||||
}
|
||||
'0.09': 28,
|
||||
'0.14': 26,
|
||||
'0.25': 24,
|
||||
'0.34': 22,
|
||||
'0.5': 21,
|
||||
'0.75': 20,
|
||||
'1': 18,
|
||||
'1.5': 16,
|
||||
'2.5': 14,
|
||||
'4': 12,
|
||||
'6': 10,
|
||||
'10': 8,
|
||||
'16': 6,
|
||||
'25': 4,
|
||||
'35': 2,
|
||||
'50': 1,
|
||||
}
|
||||
k = str(mm2)
|
||||
if k in awg_equiv_table:
|
||||
return awg_equiv_table[k]
|
||||
else:
|
||||
return 'unknown'
|
||||
|
||||
def nested(input):
|
||||
|
||||
def nested(inp):
|
||||
l = []
|
||||
for x in input:
|
||||
for x in inp:
|
||||
if isinstance(x, list):
|
||||
if len(x) > 0:
|
||||
n = nested(x)
|
||||
@ -37,25 +41,26 @@ def nested(input):
|
||||
if x is not None:
|
||||
if x != '':
|
||||
l.append(str(x))
|
||||
s = '|'.join(l)
|
||||
return s
|
||||
return '|'.join(l)
|
||||
|
||||
def int2tuple(input):
|
||||
if isinstance(input, tuple):
|
||||
output = input
|
||||
|
||||
def int2tuple(inp):
|
||||
if isinstance(inp, tuple):
|
||||
output = inp
|
||||
else:
|
||||
output = (input,)
|
||||
output = (inp,)
|
||||
return output
|
||||
|
||||
def flatten2d(input):
|
||||
output = [[str(item) if not isinstance(item, List) else ', '.join(item) for item in row] for row in input]
|
||||
return output
|
||||
|
||||
def tuplelist2tsv(input, header=None):
|
||||
def flatten2d(inp):
|
||||
return [[str(item) if not isinstance(item, List) else ', '.join(item) for item in row] for row in inp]
|
||||
|
||||
|
||||
def tuplelist2tsv(inp, header=None):
|
||||
output = ''
|
||||
if header is not None:
|
||||
input.insert(0, header)
|
||||
input = flatten2d(input)
|
||||
for row in input:
|
||||
inp.insert(0, header)
|
||||
inp = flatten2d(inp)
|
||||
for row in inp:
|
||||
output = output + '\t'.join(str(item) for item in row) + '\n'
|
||||
return output
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user