Skip to content

Commit c31ba4c

Browse files
authored
Merge pull request #704 from usc-isi-i2/dev
Fix for thinc version errors
2 parents dec3738 + 61dfa56 commit c31ba4c

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

kgtk/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '1.5.3'
1+
__version__ = '1.5.4'

kgtk/cli/calc.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def parser():
7676
MIN_OP: str = "min"
7777
MINUS_OP: str = "minus" # (column1 - column2) or (column - value)
7878
MOD_OP: str = "mod" # (column mod column) or (column mod value)
79+
MULTIPLY_OP: str = "multiply" # (column x column) or (column x value)
7980
NEGATE_OP: str = "negate" # (column, ...)
8081
NUMBER_OP: str = "number" # Get a number or the numeric part of a quantity.
8182
PERCENTAGE_OP: str = "percentage"
@@ -1855,6 +1856,27 @@ def mod_op()->bool:
18551856
return True
18561857
opfunc = mod_op
18571858

1859+
elif operation == MULTIPLY_OP:
1860+
if not ((len(sources) == 2 and len(values) == 0) or (len(sources) == 1 and len(values) == 1)):
1861+
raise KGTKException("Multiply needs two sources or one source and one value, got %d sources and %d values" % (len(sources), len(values)))
1862+
if len(into_column_idxs) != 1:
1863+
raise KGTKException("Multiply needs 1 destination columns, got %d" % len(into_column_idxs))
1864+
1865+
def multiply_2_op()->bool:
1866+
# TODO: support quantities.
1867+
output_row[into_column_idx] = str(float(row[sources[0]]) * float(row[sources[1]]))
1868+
return True
1869+
1870+
def multiply_1op()->bool:
1871+
# TODO: support quantities.
1872+
output_row[into_column_idx] = str(float(row[sources[0]]) * float(values[0]))
1873+
return True
1874+
1875+
if len(sources) == 2:
1876+
opfunc = multiply_2_op
1877+
else:
1878+
opfunc = multiply_1_op
1879+
18581880
elif operation == NAND_OP:
18591881
if len(sources) == 0:
18601882
raise KGTKException("Nand needs at least one source, got %d" % len(sources))

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ rdflib==6.1.1
88
rdflib-jsonld==0.6.2
99
pyshacl>=0.19.0
1010
rfc3986
11-
thinc==7.4.0
11+
thinc
1212
plac==1.1.3
1313
parsley>=1.3
1414
peewee>=3.14.10

0 commit comments

Comments
 (0)