Skip to content

MLE-12345 - Refactors vector utility functions #113

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2025

Conversation

BillFarber
Copy link
Contributor

Refactors the vector encoding and decoding functions to be standalone functions instead of methods within a class.

This change improves code organization and potentially simplifies usage by removing the need to instantiate a utility class.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the vector encoding/decoding utilities by extracting static methods from the VectorUtil class into standalone functions and updating tests to call those functions directly.

  • Removed the VectorUtil class and turned its methods into base64_encode/base64_decode top-level functions.
  • Updated imports and calls in tests to use the new functions.
  • Adjusted module structure and imports in marklogic/vectors.py.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_vectors.py Replaced VectorUtil.base64_encode/decode calls with direct imports of base64_encode and base64_decode.
marklogic/vectors.py Removed VectorUtil class, added module-level docstring, and defined base64_encode and base64_decode as standalone functions.
Comments suppressed due to low confidence (4)

marklogic/vectors.py:1

  • [nitpick] The module-level docstring was originally for the VectorUtil class; consider updating it to reflect that these are module-level functions rather than a class.
"""

marklogic/vectors.py:11

  • Removing the VectorUtil class is a breaking change for consumers who used VectorUtil.base64_encode/decode; consider adding a deprecated VectorUtil alias or updating documentation to guide consumers through this change.
def base64_encode(vector: List[float]) -> str:

tests/test_vectors.py:22

  • There aren't tests covering error paths such as invalid version or insufficient buffer length in base64_decode; consider adding tests for these error cases to improve coverage.
    decoded = base64_decode(EXPECTED_BASE64)

marklogic/vectors.py:19

  • [nitpick] The variable name 'buffer' shadows the built-in buffer type; consider renaming it to 'data_buffer' or 'buf' for clarity.
    )

@BillFarber BillFarber merged commit 70b5c32 into marklogic:develop Jul 14, 2025
1 of 2 checks passed
@BillFarber BillFarber deleted the task/refactorVectors branch July 14, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants