Skip to content

Commit

Permalink
remove need for .rna
Browse files Browse the repository at this point in the history
  • Loading branch information
briangu committed Dec 21, 2023
1 parent df1988e commit f08334e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
5 changes: 3 additions & 2 deletions examples/faiss/1-flat.kg
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
:" KlongPy varaint of 1-flat.py "

.pyf("faiss";"IndexFlatL2")
.pyf("numpy";"random");rna::.pya(random;"random")

d::64 :" dimension "
nb::100000 :" database size "
nq::10000 :" nb of queries "
.rns(1234) :" make reproducible "

xb::.rna(nb,d)
xq::.rna(nq,d)
xb::rna(nb,d)
xq::rna(nq,d)

index::IndexFlatL2(d);add::.pya(index;"add");search::.pya(index;"search")
.p(.pya(index,"is_trained"))
Expand Down
20 changes: 9 additions & 11 deletions klongpy/sys_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,20 +361,18 @@ def _handle_import(item):
# example: datetime(year, month, day[, hour[, minute[, second[, microsecond[,tzinfo]]]]])
# be sure to count the args before the first optional args starting with "["
# if there are kwargs, then .pyc() must be used to call this function to override them
signature_line = item.__doc__.split("\n")[0]
args = signature_line.split("[")[0].split("(")[1].split(",")
n_args = len(args)
if n_args <= len(reserved_fn_args):
item = KGLambda(item, args=reserved_fn_args[:n_args])
lines = [x.strip() for x in item.__doc__.split("\n") if x.strip()]
if lines:
signature_line = lines[0]
args = signature_line.split("[")[0].split("(")[1].split(",")
n_args = len(args)
if n_args <= len(reserved_fn_args):
item = KGLambda(item, args=reserved_fn_args[:n_args])
else:
raise
else:
raise

# if n_args > len(reserved_fn_args):
# # TODO: this should be logged
# print(f".py: {name} - too many paramters: use .pyc() to call this function")
# klong[name] = lambda x,y: item(*x,**y)
# else:
# klong[name] = item
if n_args > len(reserved_fn_args):
# TODO: this should be logged
# print(f".py: {name} - too many paramters: use .pyc() to call this function")
Expand Down

0 comments on commit f08334e

Please sign in to comment.