Skip to content
This repository was archived by the owner on Jun 27, 2025. It is now read-only.

Commit 7fe65ad

Browse files
committed
updated metadata
1 parent 47fc1d0 commit 7fe65ad

2 files changed

Lines changed: 3 additions & 101 deletions

File tree

README.md

Lines changed: 1 addition & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,105 +2,7 @@
22
arraymap
33
============
44

5-
`arraymap` provides Dictionary-like lookup from NumPy array values to integer position.
5+
The ArrayMap library provides dictionary-like lookup from NumPy array values to their integer positions. The hash table design and C implementation is based on [AutoMap](https://github.com/brandtbucher/automap), with extensive additions for direct support of NumPy arrays.
66

77

8-
Examples
9-
--------
10-
11-
`arraymap` objects are sort of like "inverse sequences". They come in two
12-
variants:
13-
14-
### FrozenAutoMap
15-
16-
```py
17-
>>> from arraymap import FrozenAutoMap
18-
```
19-
20-
`FrozenAutoMap` objects are immutable. They can be constructed from any iterable
21-
of hashable, unique keys.
22-
23-
24-
```py
25-
>>> a = FrozenAutoMap("AAA")
26-
Traceback (most recent call last):
27-
File "<stdin>", line 1, in <module>
28-
ValueError: 'A'
29-
>>> a = FrozenAutoMap("ABC")
30-
>>> a
31-
arraymap.FrozenAutoMap(['A', 'B', 'C'])
32-
```
33-
34-
The values are integers, incrementing according to the order of the original
35-
keys:
36-
37-
```py
38-
>>> a["A"]
39-
0
40-
>>> a["C"]
41-
2
42-
>>> a["X"]
43-
Traceback (most recent call last):
44-
File "<stdin>", line 1, in <module>
45-
KeyError: 'X'
46-
```
47-
48-
The full `Mapping` interface is provided:
49-
50-
```py
51-
>>> [*a.keys()]
52-
['A', 'B', 'C']
53-
>>> [*a.values()]
54-
[0, 1, 2]
55-
>>> [*a.items()]
56-
[('A', 0), ('B', 1), ('C', 2)]
57-
>>> a.get("X", 42)
58-
42
59-
>>> "B" in a
60-
True
61-
>>> [*a]
62-
['A', 'B', 'C']
63-
```
64-
65-
They may also be combined with each other using the `|` operator:
66-
67-
```py
68-
>>> b = FrozenAutoMap(range(5))
69-
>>> c = FrozenAutoMap(range(5, 10))
70-
>>> b | c
71-
arraymap.FrozenAutoMap([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
72-
>>> b |= c # Note that b is reassigned, not mutated!
73-
>>> b
74-
arraymap.FrozenAutoMap([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
75-
```
76-
77-
### AutoMap
78-
79-
```py
80-
>>> from arraymap import AutoMap
81-
```
82-
83-
Unlike `FrozenAutoMap` objects, `AutoMap` objects can grow; new keys may be
84-
added, but existing ones may not be deleted or changed.
85-
86-
```py
87-
>>> d = AutoMap("ABC")
88-
>>> d
89-
arraymap.AutoMap(['A', 'B', 'C'])
90-
>>> d |= "DEF" # Here, d *is* mutated!
91-
>>> d
92-
arraymap.AutoMap(['A', 'B', 'C', 'D', 'E', 'F'])
93-
```
94-
95-
They also have `add` and `update` methods for adding new keys:
96-
97-
```py
98-
>>> e = AutoMap(["I", "II", "III"])
99-
>>> e.add("IV")
100-
>>> e
101-
arraymap.AutoMap(['I', 'II', 'III', 'IV'])
102-
>>> e.update(["V", "VI", "VII"])
103-
>>> e
104-
arraymap.AutoMap(['I', 'II', 'III', 'IV', 'V', 'VI', 'VII'])
105-
```
1068

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def get_ext_dir(*components: tp.Iterable[str]) -> tp.Sequence[str]:
2626

2727

2828
setuptools.setup(
29-
author="Brandt Bucher, Christopher Ariza",
30-
description="Dictionary-like lookup from NumPy array values to integer positions",
29+
author="Christopher Ariza, Brandt Bucher",
30+
description="Dictionary-like lookup from NumPy array values to their integer positions",
3131
ext_modules=[extension],
3232
license="MIT",
3333
long_description=LONG_DESCRIPTION,

0 commit comments

Comments
 (0)