chore: enable singleton-comparison and cleanup (#3849)

* enable singleton-comparison

* fix triadaptive_model bug
This commit is contained in:
ZanSara 2023-01-19 10:07:41 +01:00 committed by GitHub
parent 6f5a2fb1da
commit 34b7db0209
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 10 deletions

View File

@ -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."
)

View File

@ -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

View File

@ -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)

View File

@ -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):

View File

@ -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,

View File

@ -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]

View File

@ -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: