Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminpkane committed Sep 24, 2024
1 parent cb4c614 commit cf088ad
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
4 changes: 2 additions & 2 deletions app/packages/looker/src/elements/common/bubbles.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const TEST_SCHEMA: Schema = {
info: null,
name: "detections",
subfield: "fiftyone.core.fields.EmbeddedDocumentField",
path: "ground_truth.detections",
path: "predictions_field.detections",
},
},
ftype: "fiftyone.core.fields.EmbeddedDocumentField",
Expand Down Expand Up @@ -126,7 +126,7 @@ const TEST_SCHEMA: Schema = {
info: null,
name: "detections",
subfield: "fiftyone.core.fields.EmbeddedDocumentField",
path: "ground_truth.detections",
path: "predictions.detections",
},
},
ftype: "fiftyone.core.fields.EmbeddedDocumentField",
Expand Down
9 changes: 4 additions & 5 deletions app/packages/looker/src/elements/common/bubbles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ export const getBubbles = (
export const getField = (keys: string[], schema: Schema) => {
let field: Field = schema[keys[0]];
for (const key of keys.slice(1, -1)) {
const next = field.fields[key];
const next = field.fields?.[key];
if (!next?.fields) {
return null;
}

field = next;
}

return field.fields[keys[keys.length - 1]];
return field.fields?.[keys[keys.length - 1]];
};

export const parseSample = (keys: string[], sample: Data, schema: Schema) => {
Expand All @@ -109,9 +109,8 @@ export const parseSample = (keys: string[], sample: Data, schema: Schema) => {

export const unwind = (name: string, value: Data | Data[], depth = 0) => {
if (Array.isArray(value)) {
return depth < 2
? value.map((val) => unwind(name, val), depth + 1).flat(3)
: [];
const next = depth + 1;
return depth < 2 ? value.map((val) => unwind(name, val), next).flat(3) : [];
}

const v = value[name];
Expand Down
6 changes: 2 additions & 4 deletions app/packages/utilities/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,7 @@ export const formatPrimitive = ({
timeZone: string;
value: unknown;
}) => {
if (value === undefined) return value;

if (value === null) return;
if (value === null || value === undefined) return undefined;

switch (ftype) {
case FRAME_SUPPORT_FIELD:
Expand All @@ -644,7 +642,7 @@ export const formatPrimitive = ({
value = formatDateTime(value.datetime as number, timeZone);
}

return prettify(value as string);
return prettify(String(value));
};

export const makePseudoField = (path: string): Field => ({
Expand Down
5 changes: 1 addition & 4 deletions fiftyone/server/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,7 @@ def _iter_paths(

if label_types is not None:
_is_label = _is_label_type(parent_field)
if label_types and not _is_label:
continue

elif not label_types and _is_label:
if label_types != _is_label:
continue

yield path, parent_path, filters[path]
Expand Down
8 changes: 6 additions & 2 deletions tests/unittests/server_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@ def test_filter_embedded_documents(self):
)
dataset.add_dynamic_sample_fields()

# match and filter
view = fosv.get_view(
dataset.name,
filters={
Expand All @@ -890,6 +891,7 @@ def test_filter_embedded_documents(self):
self.assertEqual(len(sample.documents), 1)
self.assertEqual(sample.documents[0].value, "two")

# matching
view = fosv.get_view(
dataset.name,
filters={
Expand All @@ -904,6 +906,7 @@ def test_filter_embedded_documents(self):
sample = view.first()
self.assertEqual(len(sample.documents), 2)

# excluded matching
view = fosv.get_view(
dataset.name,
filters={
Expand All @@ -922,19 +925,20 @@ def test_filter_embedded_documents(self):
"documents.value": {
"values": ["other"],
"exclude": True,
"isMatching": False,
"isMatching": True,
}
},
)
self.assertEqual(len(view), 1)

# excluded filtering
view = fosv.get_view(
dataset.name,
filters={
"documents.value": {
"values": ["other"],
"exclude": True,
"isMatching": True,
"isMatching": False,
}
},
)
Expand Down

0 comments on commit cf088ad

Please sign in to comment.