mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-09-21 22:23:23 +00:00
chore: enable singleton-comparison
and cleanup (#3849)
* enable singleton-comparison * fix triadaptive_model bug
This commit is contained in:
parent
6f5a2fb1da
commit
34b7db0209
@ -444,7 +444,7 @@ class BaseDocumentStore(BaseComponent):
|
||||
f"Split by sentence not supported.\n"
|
||||
f"Please set 'split_by' to either 'word' or 'passage' in the supplied PreProcessor."
|
||||
)
|
||||
assert preprocessor.split_respect_sentence_boundary == False, (
|
||||
assert preprocessor.split_respect_sentence_boundary is False, (
|
||||
f"split_respect_sentence_boundary not supported yet.\n"
|
||||
f"Please set 'split_respect_sentence_boundary' to False in the supplied PreProcessor."
|
||||
)
|
||||
@ -452,15 +452,15 @@ class BaseDocumentStore(BaseComponent):
|
||||
f"Overlapping documents are currently not supported when adding eval data.\n"
|
||||
f"Please set 'split_overlap=0' in the supplied PreProcessor."
|
||||
)
|
||||
assert preprocessor.clean_empty_lines == False, (
|
||||
assert preprocessor.clean_empty_lines is False, (
|
||||
f"clean_empty_lines currently not supported when adding eval data.\n"
|
||||
f"Please set 'clean_empty_lines=False' in the supplied PreProcessor."
|
||||
)
|
||||
assert preprocessor.clean_whitespace == False, (
|
||||
assert preprocessor.clean_whitespace is False, (
|
||||
f"clean_whitespace is currently not supported when adding eval data.\n"
|
||||
f"Please set 'clean_whitespace=False' in the supplied PreProcessor."
|
||||
)
|
||||
assert preprocessor.clean_header_footer == False, (
|
||||
assert preprocessor.clean_header_footer is False, (
|
||||
f"clean_header_footer is currently not supported when adding eval data.\n"
|
||||
f"Please set 'clean_header_footer=False' in the supplied PreProcessor."
|
||||
)
|
||||
|
@ -1359,7 +1359,7 @@ class PineconeDocumentStore(BaseDocumentStore):
|
||||
# Explode dict of dicts into single flattened dict
|
||||
for key, value in meta.items():
|
||||
# Replace any None values with empty strings
|
||||
if value == None:
|
||||
if value is None:
|
||||
value = ""
|
||||
# format key
|
||||
new_key = f"{parent_key}.{key}" if parent_key else key
|
||||
|
@ -103,7 +103,7 @@ class Inferencer:
|
||||
|
||||
# TODO add support for multiple prediction heads
|
||||
|
||||
self.name = name if name != None else f"anonymous-{self.task_type}"
|
||||
self.name = name if name is not None else f"anonymous-{self.task_type}"
|
||||
self.return_class_probs = return_class_probs
|
||||
|
||||
model.connect_heads_with_processor(processor.tasks, require_labels=False)
|
||||
|
@ -305,7 +305,7 @@ class TriAdaptiveModel(nn.Module):
|
||||
|
||||
# Forward pass for text passages and tables
|
||||
if "passage_input_ids" in kwargs.keys():
|
||||
table_mask = torch.flatten(kwargs["is_table"]) == True
|
||||
table_mask = torch.flatten(kwargs["is_table"]) == 1
|
||||
|
||||
# Current batch consists of only tables
|
||||
if all(table_mask):
|
||||
|
@ -1089,7 +1089,7 @@ class FARMReader(BaseReader):
|
||||
# create new one
|
||||
else:
|
||||
# We don't need to create an answer dict if is_impossible / no_answer
|
||||
if label.no_answer == True:
|
||||
if label.no_answer is True:
|
||||
aggregated_per_question[aggregation_key] = {
|
||||
"id": str(hash(str(doc_id) + label.query)),
|
||||
"question": label.query,
|
||||
|
@ -669,7 +669,7 @@ class MultiLabel:
|
||||
if drop_negative_labels:
|
||||
labels = [l for l in labels if is_positive_label(l)]
|
||||
if drop_no_answers:
|
||||
labels = [l for l in labels if l.no_answer == False]
|
||||
labels = [l for l in labels if l.no_answer is False]
|
||||
|
||||
self._labels = labels
|
||||
self._query = self._aggregate_labels(key="query", must_be_single_value=True)[0]
|
||||
|
@ -51,7 +51,7 @@ def aggregate_labels(
|
||||
|
||||
# drop no_answers in order to not create empty MultiLabels
|
||||
if drop_no_answers:
|
||||
labels = [label for label in labels if label.no_answer == False]
|
||||
labels = [label for label in labels if label.no_answer is False]
|
||||
|
||||
# add filters for closed domain and dynamic metadata aggregation
|
||||
for l in labels:
|
||||
|
Loading…
x
Reference in New Issue
Block a user