Skip to content

Commit

Permalink
Merge pull request #95 from ngoldbaum/nep-renames
Browse files Browse the repository at this point in the history
Updates to match the NEP
  • Loading branch information
ngoldbaum authored Nov 20, 2023
2 parents da64667 + 5110e5d commit 01b2245
Show file tree
Hide file tree
Showing 10 changed files with 700 additions and 648 deletions.
36 changes: 28 additions & 8 deletions stringdtype/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# A dtype that stores pointers to strings

This is a simple proof-of-concept dtype using the (as of early 2023) experimental
[new dtype
implementation](https://numpy.org/neps/nep-0041-improved-dtype-support.html) in
NumPy.
This is the prototype implementation of the variable-width UTF-8 string DType
described in [NEP 55](https://numpy.org/neps/nep-0055-string_dtype.html).

See the NEP for implementation details and usage examples. Full
documentation will be written as before this code is merged into NumPy.

## Building

Ensure Meson and NumPy are installed in the python environment you would like to use:

```
$ python3 -m pip install meson meson-python build patchelf
$ python3 -m pip install meson meson-python
```

It is important to have the latest development version of numpy installed.
Expand All @@ -20,16 +21,35 @@ Nightly wheels work well for this purpose, and can be installed easily:
$ pip install -i https://pypi.anaconda.org/scientific-python-nightly-wheels/simple numpy
```

Build with meson, create a wheel, and install it.
You can install with `pip` directly, taking care to disable build isolation so
the numpy nightly gets picked up at build time:

```bash
$ pip install -v . --no-build-isolation
```

If you want to work on the `stringdtype` code, you can build with meson,
create a wheel, and install it.

```bash
$ rm -r dist/
$ meson build
$ python -m build --wheel -Cbuilddir=build
$ python -m pip install dist/path-to-wheel-file.whl
```

Or simply install directly, taking care to install without build isolation:
## Usage

The dtype will not import unless you run python executable with
the `NUMPY_EXPERIMENTAL_DTYPE_API` environment variable set:

```bash
$ pip install -v . --no-build-isolation
$ NUMPY_EXPERIMENTAL_DTYPE_API=1 python
Python 3.11.3 (main, May 2 2023, 11:36:22) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from stringdtype import StringDType
>>> import numpy as np
>>> arr = np.array(["hello", "world"], dtype=StringDType())
>>> arr
array(['hello', 'world'], dtype=StringDType())
```
544 changes: 260 additions & 284 deletions stringdtype/stringdtype/src/casts.c

Large diffs are not rendered by default.

Loading

0 comments on commit 01b2245

Please sign in to comment.