Skip to content

Commit

Permalink
Merge pull request #704 from usc-isi-i2/dev
Browse files Browse the repository at this point in the history
Fix for thinc version errors
  • Loading branch information
saggu authored Jun 29, 2023
2 parents dec3738 + 61dfa56 commit c31ba4c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kgtk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.5.3'
__version__ = '1.5.4'
22 changes: 22 additions & 0 deletions kgtk/cli/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def parser():
MIN_OP: str = "min"
MINUS_OP: str = "minus" # (column1 - column2) or (column - value)
MOD_OP: str = "mod" # (column mod column) or (column mod value)
MULTIPLY_OP: str = "multiply" # (column x column) or (column x value)
NEGATE_OP: str = "negate" # (column, ...)
NUMBER_OP: str = "number" # Get a number or the numeric part of a quantity.
PERCENTAGE_OP: str = "percentage"
Expand Down Expand Up @@ -1855,6 +1856,27 @@ def mod_op()->bool:
return True
opfunc = mod_op

elif operation == MULTIPLY_OP:
if not ((len(sources) == 2 and len(values) == 0) or (len(sources) == 1 and len(values) == 1)):
raise KGTKException("Multiply needs two sources or one source and one value, got %d sources and %d values" % (len(sources), len(values)))
if len(into_column_idxs) != 1:
raise KGTKException("Multiply needs 1 destination columns, got %d" % len(into_column_idxs))

def multiply_2_op()->bool:
# TODO: support quantities.
output_row[into_column_idx] = str(float(row[sources[0]]) * float(row[sources[1]]))
return True

def multiply_1op()->bool:
# TODO: support quantities.
output_row[into_column_idx] = str(float(row[sources[0]]) * float(values[0]))
return True

if len(sources) == 2:
opfunc = multiply_2_op
else:
opfunc = multiply_1_op

elif operation == NAND_OP:
if len(sources) == 0:
raise KGTKException("Nand needs at least one source, got %d" % len(sources))
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rdflib==6.1.1
rdflib-jsonld==0.6.2
pyshacl>=0.19.0
rfc3986
thinc==7.4.0
thinc
plac==1.1.3
parsley>=1.3
peewee>=3.14.10
Expand Down

0 comments on commit c31ba4c

Please sign in to comment.