Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
gaoqiong
lm-evaluation-harness
Commits
88ec855d
Commit
88ec855d
authored
Feb 03, 2021
by
Leo Gao
Browse files
Deprecate utils_stream and remove unused code
parent
778e0f91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
135 deletions
+1
-135
lm_eval/utils_stream.py
lm_eval/utils_stream.py
+1
-135
No files found.
lm_eval/utils_stream.py
View file @
88ec855d
...
...
@@ -4,31 +4,7 @@ import operator
from
tqdm
import
tqdm
import
json
class
ExitCodeError
(
Exception
):
pass
def
sh
(
x
):
if
os
.
system
(
x
):
raise
ExitCodeError
()
def
ls
(
x
):
return
[
x
+
'/'
+
fn
for
fn
in
os
.
listdir
(
x
)]
def
lsr
(
x
):
if
os
.
path
.
isdir
(
x
):
return
reduce
(
operator
.
add
,
map
(
lsr
,
ls
(
x
)),
[])
else
:
return
[
x
]
def
fwrite
(
fname
,
content
):
with
open
(
fname
,
'w'
)
as
fh
:
fh
.
write
(
content
)
def
fread
(
fname
):
with
open
(
fname
)
as
fh
:
return
fh
.
read
()
# TODO: phase out utils_stream
class
each
:
def
__init__
(
self
,
f
):
...
...
@@ -50,113 +26,3 @@ class apply:
def
__rrshift__
(
self
,
other
):
return
self
.
f
(
other
)
class
one
:
def
__rrshift__
(
self
,
other
):
try
:
if
isinstance
(
other
,
list
):
assert
len
(
other
)
==
1
return
other
[
0
]
return
next
(
other
)
except
:
return
None
class
join
:
def
__init__
(
self
,
sep
):
self
.
sep
=
sep
def
__rrshift__
(
self
,
other
):
if
other
is
None
:
return
try
:
return
self
.
sep
.
join
(
other
)
except
:
return
None
Y
=
object
()
def
id
(
x
):
return
x
class
Reflective
:
def
__getattribute__
(
self
,
f
):
def
_fn
(
*
args
,
**
kwargs
):
return
lambda
x
:
x
.
__getattribute__
(
f
)(
*
args
,
**
kwargs
)
return
_fn
def
__getitem__
(
self
,
a
):
return
lambda
x
:
x
[
a
]
def
__mul__
(
self
,
other
):
if
other
==
Y
:
def
_f
(
x
,
y
=
None
):
if
y
==
None
:
x
,
y
=
x
return
x
*
y
return
_f
return
lambda
x
:
x
*
other
def
__rmul__
(
self
,
other
):
if
other
==
Y
:
def
_f
(
x
,
y
=
None
):
if
y
==
None
:
x
,
y
=
x
return
y
*
x
return
_f
return
lambda
x
:
other
*
x
def
__add__
(
self
,
other
):
if
other
==
Y
:
def
_f
(
x
,
y
=
None
):
if
y
==
None
:
x
,
y
=
x
return
x
+
y
return
_f
return
lambda
x
:
x
+
other
def
__radd__
(
self
,
other
):
if
other
==
Y
:
def
_f
(
x
,
y
=
None
):
if
y
==
None
:
x
,
y
=
x
return
y
+
x
return
_f
return
lambda
x
:
other
+
x
# (b -> a -> b) -> b -> [a] -> b
def
foldl
(
f
,
init
,
arr
):
curr
=
init
for
elem
in
arr
:
curr
=
f
(
curr
,
elem
)
return
curr
# (a -> b -> b) -> b -> [a] -> b
def
foldr
(
f
,
init
,
arr
):
curr
=
init
for
elem
in
arr
[::
-
1
]:
curr
=
f
(
elem
,
curr
)
return
curr
def
comp
(
*
fs
):
if
len
(
fs
)
==
1
:
return
fs
[
0
]
def
_f
(
x
):
for
f
in
fs
[::
-
1
]:
x
=
f
(
x
)
return
x
return
_f
X
=
Reflective
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment