Skip to content

Commit

Permalink
Merge a7baba0 into 693df28
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonwillard committed Jul 11, 2022
2 parents 693df28 + a7baba0 commit 90e4108
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pypi.yml
Expand Up @@ -2,10 +2,10 @@ name: PyPI
on:
push:
branches:
- master
- main
- auto-release
pull_request:
branches: [master]
branches: [main]
release:
types: [published]

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Expand Up @@ -3,10 +3,10 @@ name: Tests
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
changes:
Expand Down
13 changes: 10 additions & 3 deletions README.md
Expand Up @@ -25,21 +25,28 @@ make check

## Examples

`unification` has built-in support for most Python data types:
`unification` has built-in support for unifying most Python data types via the function `unify`:

```python
>>> from unification import *
>>> unify(1, 1)
{}
>>> unify(1, 2)
False
>>> x = var('x')
>>> x = var()
>>> unify((1, x), (1, 2))
{~x: 2}
>>> unify((x, x), (1, 2))
False
```

Unifiable objects containing logic variables can also be reified using `reify`:

```python
>>> reify((1, x), {x: 2})
(1, 2)
```

And most Python data structures:

``` python
Expand All @@ -48,7 +55,7 @@ And most Python data structures:
>>> unify({"a": 1, "b": 2}, {"a": x, "b": 2, "c": 3})
False
>>> from collections import namedtuples
>>> ntuple = namedtuple("ntuple", ("a", "b"))
>>> ntuple = namedtuple("ntuple", ("a", "b"))
>>> unify(ntuple(1, 2), ntuple(x, 2))
{~x: 1}
```
Expand Down
8 changes: 4 additions & 4 deletions unification/core.py
Expand Up @@ -25,11 +25,11 @@ def assoc(s, u, v):


def stream_eval(z, res_filter=None):
"""Evaluate a stream of `_reify`/`_unify` results.
r"""Evaluate a stream of `_reify`/`_unify` results.
This implementation consists of a deque that simulates an evaluation stack
of `_reify`/`_unify`-produced generators. We're able to overcome
`RecursionError`s this way.
`RecursionError`\s this way.
"""

if not isinstance(z, Generator):
Expand Down Expand Up @@ -79,7 +79,7 @@ def _reify_Var(o, s):


def _reify_Iterable_ctor(ctor, t, s):
"""Create a generator that yields _reify generators.
"""Create a generator that yields `_reify` generators.
The yielded generators need to be evaluated by the caller and the fully
reified results "sent" back to this generator so that it can finish
Expand Down Expand Up @@ -237,7 +237,7 @@ def _unify_slice(u, v, s):

@dispatch(object, object, Mapping)
def unify(u, v, s):
"""Find substitution so that u == v while satisfying s.
"""Find substitution so that ``u == v`` while satisfying `s`.
>>> x = var('x')
>>> unify((1, x), (1, 2), {})
Expand Down

0 comments on commit 90e4108

Please sign in to comment.