Skip to content

Commit

Permalink
Remove double-broadcasting, move examples/ to tests, refactoring
Browse files Browse the repository at this point in the history
API:
* Removed automatic "double broadcasting" from cross-track distance; users can do it themselves now.

Docs:
* Moved examples/ into the test suite for now.
* Updated developer instructions in Readme.

Refactoring:
* Refactored usage of _validate() and _promote_shape().
* Used internal helper functions in more places instead of "raw" Numpy funcs.
* Removed unnecessary keepdims=True usage in normalize().
* Improved normalize() performance with in-place operations, and optional inplace= kwarg.
  (TODO: convert to Numpy convention out= instead).
* Improved type hints.
* Renamed _dot_1d() to _dot_1d_scalar() and replaced np.dot() with less-ambiguous np.inner().

Dev:
* Added more Hatch helper scripts.
* Added an IPython startup script with hot reloading.
  • Loading branch information
gwerbin committed Dec 21, 2024
1 parent 2814b32 commit e7eff5e
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 272 deletions.
35 changes: 23 additions & 12 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ library.
This is also useful for SQL-like database/query engines that support
batched/vectorized Python UDFs, such as PySpark, DuckDB, and Snowflake.


== Installation

I will set up PyPI publishing and a stable versioning scheme eventually.
Expand All @@ -36,31 +37,41 @@ For now, install https://pip.pypa.io/en/stable/topics/vcs-support/#git[directly
pip install git+https://github.com/gwerbin/nvector-lite
----


== Usage

=== Examples

Refer to the test suite, especially any test called `+test_example+`.


== Development

Development requires https://hatch.pypa.io/[Hatch].

First, clone the Git repository.
Then, just clone the Git repository. Hatch will automatically set up the project environment
when you run a command for the first time.

Then, set up our Hatch environments:
Run tests:

[,shell]
----
hatch python install all
hatch env create dev
hatch run dev:pytest
----

Technically this is optional and will be done automatically by `+hatch run+`.
But it's nice to have everything set up and ready to avoid a long wait for the
first command.

Run tests:
Run an interactive Python console with hot-reloading enabled:

[,shell]
----
hatch run dev:pytest
hatch run dev:repl
----

== Examples
Run any other command (e.g. Python) in the dev environment:

See `+examples/+`
[,shell]
----
hatch run dev:python ...
hatch run dev:python -m pdb ...
hatch run dev:/bin/sh ...
watch -n 60 hatch run dev:pytest -k test_example
----
168 changes: 0 additions & 168 deletions examples/cross_track_distance.py

This file was deleted.

6 changes: 6 additions & 0 deletions ipython_startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from IPython import get_ipython

ipython = get_ipython()
ipython.run_line_magic("reload_ext", "autoreload")
ipython.run_line_magic("aimport", "nvector_lite")
ipython.run_line_magic("autoreload", "2")
Loading

0 comments on commit e7eff5e

Please sign in to comment.