Skip to content

Commit

Permalink
Merge branch 'master' of github.com:i2mint/chromadol
Browse files Browse the repository at this point in the history
  • Loading branch information
thorwhalen committed Jan 3, 2024
2 parents fc76032 + f4fcbdc commit ae231a9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
4 changes: 1 addition & 3 deletions chromadol/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,7 @@ def clear(self):
... del chroma_client_instance[k]
"""
raise NotImplementedError("Disabled for safety reasons.")


raise NotImplementedError('Disabled for safety reasons.')


def int_string(x):
Expand Down
2 changes: 1 addition & 1 deletion chromadol/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""chromadol tests."""
"""chromadol tests."""
39 changes: 21 additions & 18 deletions chromadol/tests/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
def test_simple():
"""A simple test of the ChromaClient and ChromaCollection classes."""


import tempfile, os
import tempfile, os

with tempfile.TemporaryDirectory() as temp_dir:
tempdir = os.path.join(temp_dir, "chromadol_test")
tempdir = os.path.join(temp_dir, 'chromadol_test')
os.makedirs(tempdir)
client = ChromaClient(tempdir)

Expand Down Expand Up @@ -39,27 +39,31 @@ def test_simple():

assert sorted(collection) == ['of', 'piece']

assert collection['piece'] == {'ids': ['piece'],
'embeddings': None,
'metadatas': [{'author': 'me'}],
'documents': ['contents for piece'],
'uris': None,
'data': None}
assert collection['piece'] == {
'ids': ['piece'],
'embeddings': None,
'metadatas': [{'author': 'me'}],
'documents': ['contents for piece'],
'uris': None,
'data': None,
}

assert collection['of'] == {'ids': ['of'],
'embeddings': None,
'metadatas': [{'author': 'you'}],
'documents': ['contents for of'],
'uris': None,
'data': None}
assert collection['of'] == {
'ids': ['of'],
'embeddings': None,
'metadatas': [{'author': 'you'}],
'documents': ['contents for of'],
'uris': None,
'data': None,
}

# You can also read multiple documents at once.
# But note that the order of the documents is not guaranteed.
assert collection[['piece', 'of']] == collection[['of', 'piece']]

# But you can read or write one document at a time too.
collection['cake'] = {
"documents": "contents for cake",
'documents': 'contents for cake',
}
assert set(collection) == {'piece', 'of', 'cake'}
assert collection['cake'] == {
Expand All @@ -82,10 +86,9 @@ def test_simple():
'data': None,
}

# The `collection` instance is not only dict-like, but also list-like in the
# The `collection` instance is not only dict-like, but also list-like in the
# sense that it has an `.append` and an `.extend` method.

assert len(collection) == 3
collection.extend(['two documents', 'specified without keys'])
assert len(collection) == 5

2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
root_url = https://github.com/i2mint/
license = mit
author = OtoSense
version = 0.0.1
version = 0.1.0
description = Data Object Layer for ChromaDB
description_file = README.md
long_description = file:README.md
Expand Down

0 comments on commit ae231a9

Please sign in to comment.