Couldnt solve a hspice syntax error - syntax-error

I'm new to hspice and this is a very basic question.
.dc vin VDD VDD 1
.print v(out) par('abs(i(vVDD)*VDD)') v(d2)
.measure dc avg_leak_low=par('abs(i(vVDD)*VDD)') TRIG v(in) VAL= VDD TD=slew
I'm following the syntax but I'm getting an error:
error
(test.sp:50)syntax error at or before "(" "'abs(i(vVDD)*VDD)'" ")" "TRIG" "v"
"(" "in" ")" "VAL" "=" "VDD" "TD" "=" "slew"
line 50 is the measure statement. VDD and slew are parameters with some values.

Related

Iterate over the tokens in the doc contains a dot in front a number

It looks like the output is not as what I expecting. Could it be by design or program bug?
doc = nlp(
"Line 1 50%. "
"Line 2 40% end space and dot ." # try comment
# "Line 2 40% end space and dot." # try comment
"20% at line 3 where Line 2 end with or without space"
)
# Iterate over the tokens in the doc
for token in doc:
# Check if the token resembles a number
if token.like_num:
# Get the next token in the document
next_token = doc[token.i+1]
# Check if the next token's text equals "%"
if next_token.text == "%":
print("Percentage found:", token.text)
Try doc.text and see the reason for what you're getting:
doc.text
'Line 1 50%. Line 2 40% end space and dot .20% at line 3 where Line 2 end with or without space'
Tip: you have all your strings concatenated into one.
To achieve what you want feed your docs as comma separated strings:
docs = nlp.pipe(["Line 1 50%. "
,"Line 2 40% end space and dot ."
,"20% at line 3 where Line 2 end with or without space"])
for doc in docs:
for token in doc:
if token.like_num and doc[token.i+1].text=="%":
print("Percentage found:", token)
Percentage found: 50
Percentage found: 40
Percentage found: 20

replace occurance of character between 2 string using mawk only

replace occurance of character in string using mawk
Hi Guys, need this solution using mawk, please help.
I have 2 strings STR_IN & STR_CMPR.
Want to repalce all character of STR_CMPR in STR_IN
main thing is, if STR_IN have some character twice & in STR_CMPR same character is only once then from STR_IN only one character should be replce.
can someone help using mawk only, no other method please.
if it can be achieve using gsub & regex or match & regex then its best. I dont want to run through each character using some loop.
Below are 3 examples with expected output.
eg 1 :
STR_IN="AABBCCDD";
STR_CMPR="DBAC";
if using gsub;
gsub(STR_CMPR, "", STR_IN);
result should be, STR_IN = ABCD;
if using match,
result : STR_IN_MATCH_CNT = 4 out of 8;
eg 2 :
STR_IN="DBAC";
STR_CMPR="AABBCCDD";
if using gsub;
gsub(STR_CMPR, "", STR_IN);
result should be, STR_IN = blank;
if using match;
result : STR_IN_MATCH_CNT = 4 out of 4;
eg 3 :
STR_IN="DDBBAC";
STR_CMPR="AABCCD";
if using gsub,
gsub(STR_CMPR, "", STR_IN);
result should be, STR_IN = DB;
if using match,
result : STR_IN_MATCH_CNT = 4 out of 6;
There is no way out of this, a for loop is needed, the quickest is:
STR_IN_MATCH_CNT=length(STR_IN)
for(i=1;i<=length(STR_CMPR);++i) sub(substr(STR_CMPR,i,1),"",STR_IN)
STR_IN_MATCH_CNT-=length(STR_IN)

How to use PLY module to realize two-line syntax analysis of "1+1 \n 2+2", output 2 and 4 respectively

Through PLY to achieve the "1+1 \n 2+2" result analysis, I think it is two irrelevant statements, but PLY has reduced them, how to make them irrelevant
def p_statement_expr(p):
'''statement : expression
print p[1]
def p_expr_num(p):
'''expression : NUMBER'''
p[0] = p[1]
if "__main__" == __name__:
parser = yacc.yacc(tabmodule="parser_main")
import time
t = time.time()
for i in range(1):
result = parser.parse("1+1 \n 2+2", debug=debug)
# print time.time() - t
# print result
Through PLY to achieve the "1+1 \n 2+2" result analysis, I think it is two irrelevant statements, but PLY has reduced them, how to make them irrelevant
PLY: PARSE DEBUG START State : 0 Stack : . LexToken(NUMBER,1,1,0) Action : Shift and goto state 3 State : 3 Stack : NUMBER . LexToken(ADD,'+',1,1) Action : Reduce rule [expression -> NUMBER] with [1] and goto state 5 Result : (1) State : 5 Stack : expression . LexToken(ADD,'+',1,1) Action : Shift and goto state 9 State : 9 Stack : expression ADD . LexToken(NUMBER,1,1,2) Action : Shift and goto state 3 State : 3 Stack : expression ADD NUMBER . LexToken(NUMBER,2,2,6) ERROR: Error : expression ADD NUMBER . LexToken(NUMBER,2,2,6)
When 2+2 is reported, how can I implement multi-line statement execution and automatically execute the following code after execution?
Ply has not done anything with the second expression.
Your grammar matches exactly one statement, assuming you are showing it all. Ply expects the input to terminate at that point, but it doesn't so Ply complains about an unexpected number.

Vi: how to automatically insert spaces

I'm trying to write a nice feature for crazy people like me who like there lines to be perfectly aligned.
I often write some file in which the format is "key = value".
Since the key may contain an indeterminate number of character, one have to manually align the "=" symbols which is not cool.
Is there a way to tell vi "when someone type the equal character, then insert as spaces as necessary to go to the column 25, then write an the equal symbol"?
The second step will be to define a shortcut to apply this format to an entire file.
Any help would be appreciated.
Ben.
Map the behavior of = in Insert Mode.
Next code will add spaces until column 24 from current cursor position and will add an equal sign after it. If there were characters after cursor position (suppose in a middle of a word), those characters will be moved after column 25. Add it to your vimrc file and try.
"" If length of the line is more or equal to 24, add an equal sign at the end.
"" Otherwise insert spaces from current position of cursor until column 24
"" and an equal sign, moving characters after it.
function My_align()
let line_len = strlen( getline('.') )
if line_len >= 24
s/$/=/
return
endif
let col_pos = col('.')
exe 's/\%#\(.\|$\)/\=submatch(1) . printf( "%' . (24 - col_pos) . 's%s", " ", "=" )/'
endfunction
inoremap = <Esc>:call My_align()<CR>A
For second step, use the multiple repeats command, check for an equal sign and insert spaces until column 25 just before it. Won't work if equal sign is after column 25 before executing it, but you get the idea.
:g/=/exe 's/=/\=printf( "%' . ( 24 - stridx( getline('.'), "=" ) ) . 's", " " ) . submatch(0)/'

"TypeError: bad operand type for unary ~: 'float'" not down to NA (not available)?

I'm trying to filter a pandas data frame. Following #jezrael's answer here I can use the following to count up the rows I will be removing:
mask= ((analytic_events['section']==2) &
~(analytic_events['identifier'].str[0].str.isdigit()))
print (mask.sum())
However when I run this on my data I get the following error:
TypeError Traceback (most recent call last)
in
1 mask= ((analytic_events['section']==2) &
----> 2 ~(analytic_events['identifier'].str[0].str.isdigit()))
3
4 print (mask.sum())
c:\program files\python37\lib\site-packages\pandas\core\generic.py in invert(self)
1454 def invert(self): 1455 try:
-> 1456 arr = operator.inv(com.values_from_object(self))
1457 return self.array_wrap(arr)
1458 except Exception:
TypeError: bad operand type for unary ~: 'float'
The accepted wisdom for that error, bad operand type for unary ~: 'float', is that the unary operator encountered a NA value (for example, see this answer)
The problem is that I do not have any such missing data. Here's my analysis. Running
analytic_events[analytic_events['section']==2]['identifier'].str[0].value_counts(dropna=False)
gives the results:
2 1207791
3 39289
1 533
. 56
Or running
analytic_events[analytic_events['section']==2]['identifier'].str[0].str.isdigit().value_counts(dropna=False)
gives the results
True 1247613
False 56
(Note that the amounts above sum to the total number of rows, i.e. there are none missing.)
Using the more direct method suggested in #jezrael's answer below
analytic_events[analytic_events['section']==2]['identifier'].isnull().sum()
analytic_events[analytic_events['section']==2]['identifier'].str[0].isnull().sum()
both produce the output zero. So there are no NA (not available) values.
Why am I getting the error
TypeError: bad operand type for unary ~: 'float'
from the code at the start of this post?
I believe you need filter by first condition and then again in filtered values:
m1 = analytic_events['section']==2
mask = ~analytic_events.loc[m1, 'identifier'].str[0].str.isdigit()
print (mask.sum())