aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-01-16 20:54:25 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-01-16 20:54:25 +0100
commitbffe6bb52d00e60665b4e8e2144ab91e4465173e (patch)
tree2580b048da72cf37dfe744b8cdb37a7d382e0293
parentafd165000c1661a9cca117a4844ad3f89d926fdb (diff)
downloadbsie-bffe6bb52d00e60665b4e8e2144ab91e4465173e.tar.gz
bsie-bffe6bb52d00e60665b4e8e2144ab91e4465173e.tar.bz2
bsie-bffe6bb52d00e60665b4e8e2144ab91e4465173e.zip
minor bugfixes
-rw-r--r--bsie/apps/index.py4
-rw-r--r--bsie/extractor/base.py1
-rw-r--r--bsie/extractor/image/colors_spatial.py8
3 files changed, 7 insertions, 6 deletions
diff --git a/bsie/apps/index.py b/bsie/apps/index.py
index 0c6296f..7cf94d3 100644
--- a/bsie/apps/index.py
+++ b/bsie/apps/index.py
@@ -82,7 +82,9 @@ def main(argv):
# index input paths
for path in args.input_file:
- if os.path.isdir(path) and args.recursive:
+ if not os.path.exists(path):
+ pass # FIXME: notify the user
+ elif os.path.isdir(path) and args.recursive:
for dirpath, _, filenames in os.walk(path, topdown=True, followlinks=args.follow):
for filename in filenames:
for node, pred, value in bsie.from_file(os.path.join(dirpath, filename)):
diff --git a/bsie/extractor/base.py b/bsie/extractor/base.py
index 8ab1124..7401244 100644
--- a/bsie/extractor/base.py
+++ b/bsie/extractor/base.py
@@ -108,5 +108,6 @@ class Extractor(abc.ABC):
principals: typing.Iterable[bsfs.schema.Predicate],
) -> typing.Iterator[typing.Tuple[node.Node, bsfs.schema.Predicate, typing.Any]]:
"""Return (node, predicate, value) triples."""
+ # FIXME: type annotation could be more strict: value is Hashable
## EOF ##
diff --git a/bsie/extractor/image/colors_spatial.py b/bsie/extractor/image/colors_spatial.py
index fa31ea7..38f1db4 100644
--- a/bsie/extractor/image/colors_spatial.py
+++ b/bsie/extractor/image/colors_spatial.py
@@ -121,7 +121,7 @@ class ColorsSpatial(base.Extractor):
subject: node.Node,
content: PIL.Image,
principals: typing.Iterable[bsfs.schema.Predicate],
- ) -> typing.Iterator[typing.Tuple[node.Node, bsfs.schema.Predicate, typing.List[float]]]:
+ ) -> typing.Iterator[typing.Tuple[node.Node, bsfs.schema.Predicate, typing.Any]]:
# check principals
if self.schema.predicate(self._predicate_name) not in principals:
# nothing to do; abort
@@ -145,10 +145,8 @@ class ColorsSpatial(base.Extractor):
width = int(np.floor(width / self.exp))
height = int(np.floor(height / self.exp))
- # combine features
- value = np.vstack(features)
- # convert features
- value = value.reshape(-1).tolist() # several bands
+ # combine bands and convert features to tuple
+ value = tuple(np.vstack(features).reshape(-1))
# return triple with feature vector as value
yield subject, self.schema.predicate(self._predicate_name), value