Skip to content

Commit 681bfeb

Browse files
committed
docstrings added for public API #52
1 parent ac49d11 commit 681bfeb

File tree

8 files changed

+48
-2
lines changed

8 files changed

+48
-2
lines changed

objectbox/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@
6868

6969
# Python binding version
7070
version = Version(4, 0, 0)
71-
71+
"""ObjectBox Python version"""
7272

7373
def version_info():
74+
"""Returns a string with Python and core version information."""
7475
return "ObjectBox Python version " + str(version) + " using dynamic library version " + str(version_core)

objectbox/box.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222

2323
class Box:
24+
"""Interface to Entities"""
2425
def __init__(self, store: Store, entity: _Entity):
2526
if not isinstance(entity, _Entity):
2627
raise Exception("Given type is not an Entity")

objectbox/builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from warnings import warn
2121

2222
class Builder:
23+
"""*Deprecated Interface*"""
2324
def __init__(self):
2425
"""This throws a deprecation warning on initialization."""
2526
warn(f'Using {self.__class__.__name__} is deprecated, please use Store(model=, directory= ...) from objectbox.store.', DeprecationWarning, stacklevel=2)

objectbox/model/model.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121

2222

2323
class Model:
24+
"""
25+
Database schema
26+
27+
A model specifies available entities in the database. Amongst others it uses this information to supports migration over time.
28+
"""
2429
def __init__(self):
2530
self.entities: List[_Entity] = []
2631

objectbox/model/properties.py

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ class IndexType(IntEnum):
8080

8181

8282
class Index:
83+
"""Property Index"""
84+
8385
# TODO HNSW isn't a `type` but HASH and HASH64 are, remove type member and make HashIndex and Hash64Index classes?
8486

8587
def __init__(self, type: IndexType = IndexType.VALUE, uid: int = 0):
@@ -136,8 +138,8 @@ class VectorDistanceType(IntEnum):
136138
Value range: 0.0 - 2.0 (nonlinear; 0.0: nearest, 1.0: orthogonal, 2.0: farthest)
137139
"""
138140

139-
140141
class HnswIndex:
142+
"""HNSW Index for Vector-Search"""
141143
def __init__(self,
142144
dimensions: int,
143145
neighbors_per_node: Optional[int] = None,
@@ -290,16 +292,19 @@ def not_equals(self, value) -> PropertyQueryCondition:
290292

291293
# ID property (primary key)
292294
class Id(_IntProperty):
295+
"""Id Property"""
293296
def __init__(self, id : int = 0, uid : int = 0, py_type: type = int):
294297
super(Id, self).__init__(py_type, id=id, uid=uid)
295298

296299
# Bool property
297300
class Bool(_IntProperty):
301+
"""Boolean Property"""
298302
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
299303
super(Bool, self).__init__(bool, type=PropertyType.bool, id=id, uid=uid, **kwargs)
300304

301305
# String property with starts/ends_with
302306
class String(Property):
307+
"""String Property"""
303308
def __init__(self, id: int = 0, uid : int = 0, **kwargs):
304309
super(String, self).__init__(str, type=PropertyType.string, id=id, uid=uid, **kwargs)
305310

@@ -352,38 +357,47 @@ def less_or_equal(self, value, case_sensitive: bool = True) -> PropertyQueryCond
352357

353358
# Signed Integer Numeric Properties
354359
class Int8(_IntProperty):
360+
"""Integer 8-bit Property"""
355361
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
356362
super(Int8, self).__init__(int, type=PropertyType.byte, id=id, uid=uid, **kwargs)
357363
class Int16(_IntProperty):
364+
"""Integer 16-bit Property"""
358365
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
359366
super(Int16, self).__init__(int, type=PropertyType.short, id=id, uid=uid, **kwargs)
360367
class Int32(_IntProperty):
368+
"""Integer 32-bit Property"""
361369
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
362370
super(Int32, self).__init__(int, type=PropertyType.int, id=id, uid=uid, **kwargs)
363371
class Int64(_IntProperty):
372+
"""Integer 64-bit Property"""
364373
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
365374
super(Int64, self).__init__(int, type=PropertyType.long, id=id, uid=uid, **kwargs)
366375

367376
# Floating-Point Numeric Properties
368377
class Float32(_NumericProperty):
378+
"""Floating-point 32-bit Property"""
369379
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
370380
super(Float32, self).__init__(float, type=PropertyType.float, id=id, uid=uid, **kwargs)
371381

372382
class Float64(_NumericProperty):
383+
"""Floating-point 64-bit Property"""
373384
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
374385
super(Float64, self).__init__(float, type=PropertyType.double, id=id, uid=uid, **kwargs)
375386

376387
# Date Properties
377388
class Date(_IntProperty):
389+
"""Date Property"""
378390
def __init__(self, py_type = datetime, id : int = 0, uid : int = 0, **kwargs):
379391
super(Date, self).__init__(py_type, type=PropertyType.date, id=id, uid=uid, **kwargs)
380392

381393
class DateNano(_IntProperty):
394+
"""Date (nano-second resolution) Property"""
382395
def __init__(self, py_type = datetime, id : int = 0, uid : int = 0, **kwargs):
383396
super(DateNano, self).__init__(py_type, type=PropertyType.dateNano, id=id, uid=uid, **kwargs)
384397

385398
# Bytes Property
386399
class Bytes(_NumericProperty):
400+
"""Bytes blob Property"""
387401
def __init__(self, id: int = 0, uid : int = 0, **kwargs):
388402
super(Bytes, self).__init__(bytes, type=PropertyType.byteVector, id=id, uid=uid, **kwargs)
389403

@@ -414,6 +428,7 @@ def less_or_equal(self, value) -> PropertyQueryCondition:
414428

415429
# Flex Property
416430
class Flex(Property):
431+
"""Flex dictionary-compatible Property"""
417432
def __init__(self, id : int = 0, uid : int = 0, **kwargs):
418433
super(Flex, self).__init__(Generic, type=PropertyType.flex, id=id, uid=uid, **kwargs)
419434
def contains_key_value(self, key: str, value: str, case_sensitive: bool = True) -> PropertyQueryCondition:
@@ -426,29 +441,36 @@ def __init__(self, py_type : Type, **kwargs):
426441
super(_VectorProperty, self).__init__(py_type, **kwargs)
427442

428443
class BoolVector(_VectorProperty):
444+
"""Boolean Vector Property"""
429445
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
430446
super(BoolVector, self).__init__(np.ndarray, type=PropertyType.boolVector, id=id, uid=uid, **kwargs)
431447
class Int8Vector(_VectorProperty):
448+
"""Integer 8-bit Vector Property"""
432449
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
433450
super(Int8Vector, self).__init__(bytes, type=PropertyType.byteVector, id=id, uid=uid, **kwargs)
434451

435452
class Int16Vector(_VectorProperty):
453+
"""Integer 16-bit Vector Property"""
436454
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
437455
super(Int16Vector, self).__init__(np.ndarray, type=PropertyType.shortVector, id=id, uid=uid, **kwargs)
438456

439457
class CharVector(_VectorProperty):
458+
"""Char 16-bit Vector Property"""
440459
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
441460
super(CharVector, self).__init__(np.ndarray, type=PropertyType.charVector, id=id, uid=uid, **kwargs)
442461

443462
class Int32Vector(_VectorProperty):
463+
"""Integer 32-bit Vector Property"""
444464
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
445465
super(Int32Vector, self).__init__(np.ndarray, type=PropertyType.intVector, id=id, uid=uid, **kwargs)
446466

447467
class Int64Vector(_VectorProperty):
468+
"""Integer 64-bit Vector Property"""
448469
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
449470
super(Int64Vector, self).__init__(np.ndarray, type=PropertyType.longVector, id=id, uid=uid, **kwargs)
450471

451472
class Float32Vector(_VectorProperty):
473+
"""Floating-point 32-bit Vector Property"""
452474
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
453475
super(Float32Vector, self).__init__(np.ndarray, type=PropertyType.floatVector, id=id, uid=uid, **kwargs)
454476
def nearest_neighbor(self, query_vector, element_count: int) -> PropertyQueryCondition:
@@ -457,6 +479,7 @@ def nearest_neighbor(self, query_vector, element_count: int) -> PropertyQueryCon
457479
return PropertyQueryCondition(self.id, PropertyQueryConditionOp.NEAREST_NEIGHBOR, args)
458480

459481
class Float64Vector(_VectorProperty):
482+
"""Floating-point 64-bit Vector Property"""
460483
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
461484
super(Float64Vector, self).__init__(np.ndarray, type=PropertyType.doubleVector, id=id, uid=uid, **kwargs)
462485

@@ -465,33 +488,41 @@ def __init__(self, **kwargs):
465488
super(_ListProperty, self).__init__(list, **kwargs)
466489

467490
class BoolList(_ListProperty):
491+
"""Boolean List Property"""
468492
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
469493
super(BoolList, self).__init__(type=PropertyType.boolVector, id=id, uid=uid, **kwargs)
470494

471495
class Int8List(_ListProperty):
496+
"""Integer 8-bit List Property"""
472497
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
473498
super(Int8List, self).__init__(type=PropertyType.byteVector, id=id, uid=uid, **kwargs)
474499

475500
class Int16List(_ListProperty):
501+
"""Integer 16-bit List Property"""
476502
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
477503
super(Int16List, self).__init__(type=PropertyType.shortVector, id=id, uid=uid, **kwargs)
478504

479505
class Int32List(_ListProperty):
506+
"""Integer 32-bit List Property"""
480507
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
481508
super(Int32List, self).__init__(type=PropertyType.intVector, id=id, uid=uid, **kwargs)
482509

483510
class Int64List(_ListProperty):
511+
"""Integer 64-bit List Property"""
484512
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
485513
super(Int64List, self).__init__(type=PropertyType.longVector, id=id, uid=uid, **kwargs)
486514

487515
class Float32List(_ListProperty):
516+
"""Floating-point 32-bit List Property"""
488517
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
489518
super(Float32List, self).__init__(type=PropertyType.floatVector, id=id, uid=uid, **kwargs)
490519

491520
class Float64List(_ListProperty):
521+
"""Floating-point 64-bit List Property"""
492522
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
493523
super(Float64List, self).__init__(type=PropertyType.doubleVector, id=id, uid=uid, **kwargs)
494524

495525
class CharList(_ListProperty):
526+
"""Char 16-bit List Property"""
496527
def __init__(self, id: int = 0, uid: int = 0, **kwargs):
497528
super(CharList, self).__init__(type=PropertyType.charVector, id=id, uid=uid, **kwargs)

objectbox/objectbox.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from warnings import warn
1818

1919
class ObjectBox(objectbox.store.Store):
20+
"""*Deprecated Interface*"""
2021
def __init__(self, c_store):
2122
"""This throws a deprecation warning on initialization."""
2223
warn(f'{self.__class__.__name__} will be deprecated, use Store from objectbox.store.', DeprecationWarning, stacklevel=2)

objectbox/store.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929

3030
class Store:
31+
"""ObjectBox Database"""
3132
def __init__(self,
3233
model: Optional[Union[Model, str]] = "default",
3334
model_json_file: Optional[str] = None,
@@ -238,6 +239,7 @@ def json_file_inside_module_path(module: Optional[ModuleType]) -> Optional[str]:
238239
return model_json_file
239240

240241
def __del__(self):
242+
"""Destructor closes database."""
241243
self.close()
242244

243245
def box(self, entity: _Entity) -> 'objectbox.Box':
@@ -250,12 +252,15 @@ def box(self, entity: _Entity) -> 'objectbox.Box':
250252
return objectbox.Box(self, entity)
251253

252254
def read_tx(self):
255+
"""Returns a read-only transaction."""
253256
return objectbox.transaction.read(self)
254257

255258
def write_tx(self):
259+
"""Returns a write transaction."""
256260
return objectbox.transaction.write(self)
257261

258262
def close(self):
263+
"""Close database."""
259264
c_store_to_close = self._c_store
260265
if c_store_to_close:
261266
self._c_store = None

objectbox/version.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717

1818
class Version:
19+
"""Version"""
1920
def __init__(self, major: int, minor: int, patch: int,
2021
alpha: Optional[int] = None,
2122
beta: Optional[int] = None,

0 commit comments

Comments
 (0)