You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have confirmed this bug exists on the latest version of valor.
Reproducible Example
fromvalorimportconnect, Client, Dataset, Model, Datum, Annotation, GroundTruth, Prediction, Labelfromvalor.schemasimportBoxfromvalor.enumsimportTaskTypeconnect("https://valor.striveworks.com/api/v1", username=..., password=...)
client=Client()
pscope_test_dataset=Dataset.get("PlanetScope 1.2 Test")
sample_gt=pscope_test_dataset.get_groundtruth('')
sample_annotations=sample_gt.annotationssample_labels=sample_annotations[0].labelsprint(f"sample_labels = {sample_labels}")
print(f"sample_labels[0].value == 'some' => {sample_labels[0].value=='some'}")
print(f"sample_labels[0].value == 'thing' => {sample_labels[0].value=='thing'}")
print(f"[label for label in sample_labels if label.value == 'some'] = {[labelforlabelinsample_labelsiflabel.value=='some']}")
print(f"[label for label in sample_labels if str(label.value) == 'some'] = {[labelforlabelinsample_labelsifstr(label.value) =='some']}")
Issue Description
I am getting unexpected behavior when filtering valor objects with list comprehensions, specifically that the filtering does not work unless I apply “str()” to the value to filter on. The following code snippet demonstrates the issue (“username” and “password” need to be provided to the connect() call):
from valor import connect, Client, Dataset, Model, Datum, Annotation, GroundTruth, Prediction, Label
from valor.schemas import Box
from valor.enums import TaskType
connect("https://valor.striveworks.com/api/v1", username=..., password=...)
client = Client()
pscope_test_dataset = Dataset.get("PlanetScope 1.2 Test")
sample_gt = pscope_test_dataset.get_groundtruth('')
sample_annotations = sample_gt.annotations
sample_labels = sample_annotations[0].labels
print(f"sample_labels = {sample_labels}")
print(f"sample_labels[0].value == 'some' => {sample_labels[0].value == 'some'}")
print(f"sample_labels[0].value == 'thing' => {sample_labels[0].value == 'thing'}")
print(f"[label for label in sample_labels if label.value == 'some'] = {[label for label in sample_labels if label.value == 'some']}")
print(f"[label for label in sample_labels if str(label.value) == 'some'] = {[label for label in sample_labels if str(label.value) == 'some']}")
output
sample_labels = [{'key': 'class_label', 'value': 'thing', 'score': None}]
sample_labels[0].value == 'some' => False
sample_labels[0].value == 'thing' => True
[label for label in sample_labels if label.value == 'some'] = [{'key': 'class_label', 'value': 'thing', 'score': None}]
[label for label in sample_labels if str(label.value) == 'some'] = []
Lines 2 and 3 here show that the value equality returns as expected, but line 4 shows it does not work as part of a list comprehension. Here, I would have expected the returned list to be empty, or an exception to be thrown if the two values were not comparable due to type mismatch. Line 5 shows that the list comprehension will work if str() is applied to the value.
Expected Behavior
expect it to work.
The text was updated successfully, but these errors were encountered:
valor version checks
Reproducible Example
Issue Description
I am getting unexpected behavior when filtering valor objects with list comprehensions, specifically that the filtering does not work unless I apply “str()” to the value to filter on. The following code snippet demonstrates the issue (“username” and “password” need to be provided to the connect() call):
output
Lines 2 and 3 here show that the value equality returns as expected, but line 4 shows it does not work as part of a list comprehension. Here, I would have expected the returned list to be empty, or an exception to be thrown if the two values were not comparable due to type mismatch. Line 5 shows that the list comprehension will work if str() is applied to the value.
Expected Behavior
expect it to work.
The text was updated successfully, but these errors were encountered: