Skip to content

Commit

Permalink
Merge pull request #4 from ajcr/toml-packaging
Browse files Browse the repository at this point in the history
Toml packaging
  • Loading branch information
ajcr authored Nov 2, 2023
2 parents 53df532 + 3a29db0 commit e4e6a09
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 60 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/python-package.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.10", "3.11", "3.12"]

steps:
- uses: actions/checkout@v3
Expand All @@ -29,9 +29,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r dev_requirements.txt
python -m pip install -r requirements.txt
python -m pip install .
python -m pip install .[dev]
- name: Check with ruff
run: ruff check .
- name: Check types
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include grammar.lark
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ By default, the computation assumes that draws are made without replacement. Thi

Let's look at some examples.

<p align="center">
<img src="https://raw.githubusercontent.com/ajcr/urn/main/assets/rbg_draw_1.png" alt="constraints using AND"/>
</p>

Suppose we want to draw _without replacement_ from an urn containing coloured marbles. We want to see the probability that we see _at least_ 2 red and _at most_ 5 blue:
```
urn> probability draw from red = 5, blue = 7, green = 3 where red >= 2 and blue <= 5;
Expand Down Expand Up @@ -121,10 +117,6 @@ urn> probability draw 2..13 with replacement
```

Finally, we can use `OR` to specify any number of alternative constraints on our draw.
<p align="center">
<img src="https://raw.githubusercontent.com/ajcr/urn/main/assets/rbg_draw_2.png" alt="constraints using OR"/>
</p>

```
urn> probability draw 1..10 from red=5, blue=7, green=3
... where red >= 2 and blue <= 3
Expand Down
2 changes: 0 additions & 2 deletions dev_requirements.txt

This file was deleted.

File renamed without changes.
45 changes: 45 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "urn-calculator"
version = "0.0.1"
description = "Multivariate hypergeometric command line calculator."
readme = "README.md"
authors = [{ name = "Alex Riley" }]
license = { file = "LICENSE" }
classifiers = [
"Development Status :: 3 - Alpha",
"Topic :: Scientific/Engineering :: Mathematics",
"Topic :: Scientific/Engineering :: Visualization",
"Topic :: Utilities",
"Typing :: Typed",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
keywords = ["calculator", "probability", "count", "draw", "random", "sample", "hypergeometric"]
dependencies = [
"lark >= 1.1.5",
"sympy >= 1.12",
"tabulate >= 0.9.0",
"uniplot >= 0.10.0",
]
requires-python = ">=3.10"

[project.optional-dependencies]
dev = ["pytest", "ruff"]

[project.urls]
Homepage = "https://github.com/ajcr/urn"

[project.scripts]
urn = "urn.cli:main"

[tool.pytest.ini_options]
pythonpath = [
"."
]
4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

37 changes: 0 additions & 37 deletions setup.py

This file was deleted.

File renamed without changes.
4 changes: 2 additions & 2 deletions urn/cli.py → src/urn/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from urn import __version__

DESCRIPTION = "Draw odds calculator."
DESCRIPTION = "Multivariate hypergeometric calculator."


def parse_args() -> argparse.Namespace:
Expand All @@ -30,7 +30,7 @@ def main() -> None:
from urn.shell import run_shell
from urn.evaluation import process_query

command_parser = lark.Lark.open("grammar.lark", rel_to=__file__)
command_parser = lark.Lark.open("grammar.lark", rel_to=__package__)

if args.command or args.filename:

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file removed tests/__init__.py
Empty file.
5 changes: 2 additions & 3 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@


@pytest.fixture(scope="session")
def parser(request):
rel_to = request.config.rootdir.join("urn").join("urn")
return lark.Lark.open("grammar.lark", rel_to=str(rel_to))
def parser():
return lark.Lark.open("grammar.lark")


@pytest.mark.parametrize(
Expand Down

0 comments on commit e4e6a09

Please sign in to comment.