Skip to content

Commit

Permalink
[CLN] Run prettier to make linter happy (#2081)
Browse files Browse the repository at this point in the history
## Description of changes

*Summarize the changes made by this PR.*
 - Improvements & Bug fixes
	 - Ran prettier to fix breakage lint rule breakge in #2044
 - New functionality
	 - ...

## Test plan
*How are these changes tested?*
Lint CI failed, this is a fix
- [x] Tests pass locally with `pytest` for python, `yarn test` for js,
`cargo test` for rust

## Documentation Changes
*Are all docstrings for user-facing APIs updated if required? Do we need
to make documentation changes in the [docs
repository](https://github.com/chroma-core/docs)?*
  • Loading branch information
HammadB authored Apr 30, 2024
1 parent c46ea2a commit 4b6a958
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
14 changes: 7 additions & 7 deletions clients/js/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ type WhereOperator = "$gt" | "$gte" | "$lt" | "$lte" | "$ne" | "$eq";

type OperatorExpression = {
[key in WhereOperator | InclusionOperator | LogicalOperator]?:
| LiteralValue
| ListLiteralValue;
| LiteralValue
| ListLiteralValue;
};

type BaseWhere = {
Expand All @@ -50,9 +50,9 @@ type WhereDocumentOperator = "$contains" | "$not_contains" | LogicalOperator;

export type WhereDocument = {
[key in WhereDocumentOperator]?:
| LiteralValue
| LiteralNumber
| WhereDocument[];
| LiteralValue
| LiteralNumber
| WhereDocument[];
};

export type CollectionType = {
Expand All @@ -67,7 +67,7 @@ export type GetResponse = {
documents: (null | Document)[];
metadatas: (null | Metadata)[];
error: null | string;
included: IncludeEnum[]
included: IncludeEnum[];
};

export type QueryResponse = {
Expand All @@ -76,7 +76,7 @@ export type QueryResponse = {
documents: (null | Document)[][];
metadatas: (null | Metadata)[][];
distances: null | number[][];
included: IncludeEnum[]
included: IncludeEnum[];
};

export type AddResponse = {
Expand Down
4 changes: 3 additions & 1 deletion clients/js/test/get.collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ test("it should get a collection", async () => {
expect(results.ids.length).toBe(1);
expect(["test1"]).toEqual(expect.arrayContaining(results.ids));
expect(["test2"]).not.toEqual(expect.arrayContaining(results.ids));
expect(results.included).toEqual(expect.arrayContaining(["metadatas", "documents"]))
expect(results.included).toEqual(
expect.arrayContaining(["metadatas", "documents"]),
);

const results2 = await collection.get({ where: { test: "test1" } });
expect(results2).toBeDefined();
Expand Down
8 changes: 5 additions & 3 deletions clients/js/test/query.collection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { EMBEDDINGS, IDS, METADATAS, DOCUMENTS } from "./data";
import { IEmbeddingFunction } from "../src/embeddings/IEmbeddingFunction";

export class TestEmbeddingFunction implements IEmbeddingFunction {
constructor() { }
constructor() {}

public async generate(texts: string[]): Promise<number[][]> {
let embeddings: number[][] = [];
Expand All @@ -29,7 +29,9 @@ test("it should query a collection", async () => {
expect(results).toBeInstanceOf(Object);
expect(["test1", "test2"]).toEqual(expect.arrayContaining(results.ids[0]));
expect(["test3"]).not.toEqual(expect.arrayContaining(results.ids[0]));
expect(results.included).toEqual(expect.arrayContaining(["metadatas", "documents"]))
expect(results.included).toEqual(
expect.arrayContaining(["metadatas", "documents"]),
);
});

// test where_document
Expand Down Expand Up @@ -69,7 +71,7 @@ test("it should get embedding with matching documents", async () => {
// expect(results2.embeddings[0][0]).toBeInstanceOf(Array);
expect(results2.embeddings![0].length).toBe(1);
expect(results2.embeddings![0][0]).toEqual([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
expect(results2.included).toEqual(expect.arrayContaining(["embeddings"]))
expect(results2.included).toEqual(expect.arrayContaining(["embeddings"]));
});

test("it should exclude documents matching - not_contains", async () => {
Expand Down

0 comments on commit 4b6a958

Please sign in to comment.