Skip to content

Commit f6c890c

Browse files
committed
🎨 Standarize code ./scripts directory
1 parent 85ea86d commit f6c890c

File tree

2 files changed

+84
-91
lines changed

2 files changed

+84
-91
lines changed

scripts/switch_lapack_ubuntu.rb

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ def run(cmd)
1919
system cmd
2020
end
2121

22-
2322
run "update-alternatives --set liblapack.so.3 #{lapack_prefix}/liblapack.so.3"
2423
run "update-alternatives --set liblapack.so #{lapack_prefix}/liblapack.so"
2524
run "update-alternatives --set libblas.so.3 #{blas_prefix}/libblas.so.3"

scripts/ttable_helper.rb

+84-90
Original file line numberDiff line numberDiff line change
@@ -3,113 +3,107 @@
33
# A helper file for generating and maintaining template tables.
44

55
DTYPES = [
6-
:uint8_t,
7-
:int8_t,
8-
:int16_t,
9-
:int32_t,
10-
:int64_t,
11-
:float32_t,
12-
:float64_t,
13-
:'nm::Complex64',
14-
:'nm::Complex128',
15-
:'nm::RubyObject'
16-
]
6+
:uint8_t,
7+
:int8_t,
8+
:int16_t,
9+
:int32_t,
10+
:int64_t,
11+
:float32_t,
12+
:float64_t,
13+
:'nm::Complex64',
14+
:'nm::Complex128',
15+
:'nm::RubyObject',
16+
]
1717

1818
def nullify(disabled = []) #:nodoc:
19-
DTYPES.map { |t| if disabled.include?(t) then :NULL else t end }
19+
DTYPES.map { |t| disabled.include?(t) ? :NULL : t }
2020
end
2121

2222
ITYPES = [
23-
:uint8_t,
24-
:uint16_t,
25-
:uint32_t,
26-
:uint64_t
27-
]
23+
:uint8_t,
24+
:uint16_t,
25+
:uint32_t,
26+
:uint64_t,
27+
]
2828

2929
EWOPS = [
30-
:'nm::EW_ADD',
31-
:'nm::EW_SUB',
32-
:'nm::EW_MUL',
33-
:'nm::EW_DIV',
34-
:'nm::EW_POW',
35-
:'nm::EW_MOD',
36-
:'nm::EW_EQEQ',
37-
:'nm::EW_NEQ',
38-
:'nm::EW_LT',
39-
:'nm::EW_GT',
40-
:'nm::EW_LEQ',
41-
:'nm::EW_GEQ'
42-
]
30+
:'nm::EW_ADD',
31+
:'nm::EW_SUB',
32+
:'nm::EW_MUL',
33+
:'nm::EW_DIV',
34+
:'nm::EW_POW',
35+
:'nm::EW_MOD',
36+
:'nm::EW_EQEQ',
37+
:'nm::EW_NEQ',
38+
:'nm::EW_LT',
39+
:'nm::EW_GT',
40+
:'nm::EW_LEQ',
41+
:'nm::EW_GEQ',
42+
]
4343

4444
LR_ALLOWED = {
45-
:uint8_t => DTYPES,
46-
:int8_t => DTYPES,
47-
:int16_t => DTYPES,
48-
:int32_t => DTYPES,
49-
:int64_t => DTYPES,
50-
:float32_t => DTYPES,
51-
:float64_t => DTYPES,
52-
:'nm::Complex64' => DTYPES,
53-
:'nm::Complex128' => DTYPES,
54-
:'nm::RubyObject' => DTYPES
45+
uint8_t: DTYPES,
46+
int8_t: DTYPES,
47+
int16_t: DTYPES,
48+
int32_t: DTYPES,
49+
int64_t: DTYPES,
50+
float32_t: DTYPES,
51+
float64_t: DTYPES,
52+
'nm::Complex64': DTYPES,
53+
'nm::Complex128': DTYPES,
54+
'nm::RubyObject': DTYPES,
5555
}
5656

5757
lines =
5858
case ARGV[0]
59-
when 'OPLR'
60-
'{' +
61-
EWOPS.map do |op|
62-
63-
'{' +
64-
DTYPES.map do |l_dtype|
65-
66-
'{' +
67-
LR_ALLOWED[l_dtype].map do |r_dtype|
68-
if r_dtype == :NULL
69-
'NULL'
70-
else
71-
"fun<#{op}, #{l_dtype}, #{r_dtype}>"
72-
end
73-
end.join(', ') +
74-
'}'
75-
76-
end.join(",\n") +
77-
'}'
78-
79-
end.join(",\n") +
80-
'}'
81-
82-
when 'OPID'
83-
'{' +
84-
EWOPS.map do |op|
85-
'{' +
86-
ITYPES.map do |itype|
87-
'{' +
88-
DTYPES.map do |dtype|
89-
90-
if dtype == :NULL
91-
'NULL'
92-
else
93-
"fun<#{op}, #{itype}, #{dtype}>"
94-
end
95-
96-
end.join(",") +
97-
'}'
98-
end.join(",\\\n") +
99-
'}'
100-
end.join(",\\\n") +
101-
'}'
102-
103-
when 'LR'
104-
'{' + DTYPES.map do |l_dtype|
105-
'{' + LR_ALLOWED[l_dtype].map do |r_dtype|
59+
when "OPLR"
60+
"{" +
61+
EWOPS.map { |op|
62+
"{" +
63+
DTYPES.map { |l_dtype|
64+
"{" +
65+
LR_ALLOWED[l_dtype].map { |r_dtype|
66+
if r_dtype == :NULL
67+
"NULL"
68+
else
69+
"fun<#{op}, #{l_dtype}, #{r_dtype}>"
70+
end
71+
}.join(", ") +
72+
"}"
73+
}.join(",\n") +
74+
"}"
75+
}.join(",\n") +
76+
"}"
77+
78+
when "OPID"
79+
"{" +
80+
EWOPS.map { |op|
81+
"{" +
82+
ITYPES.map { |itype|
83+
"{" +
84+
DTYPES.map { |dtype|
85+
if dtype == :NULL
86+
"NULL"
87+
else
88+
"fun<#{op}, #{itype}, #{dtype}>"
89+
end
90+
}.join(",") +
91+
"}"
92+
}.join(",\\\n") +
93+
"}"
94+
}.join(",\\\n") +
95+
"}"
96+
97+
when "LR"
98+
"{" + DTYPES.map { |l_dtype|
99+
"{" + LR_ALLOWED[l_dtype].map { |r_dtype|
106100
if r_dtype == :NULL
107-
'NULL'
101+
"NULL"
108102
else
109103
"fun<#{l_dtype}, #{r_dtype}>"
110104
end
111-
end.join(', ') + '}'
112-
end.join(",\n") + '}'
105+
}.join(", ") + "}"
106+
}.join(",\n") + "}"
113107
end
114108

115109
puts lines

0 commit comments

Comments
 (0)