Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]
max-line-length = 120
exclude = docs/src, build, dist
ignore = F811,E121,E123,E126,E226,E24,E704,W503,W504,E203
per-file-ignores =
test/examples/test_sensor_fusion.py:E128
funsor/ops/__init__.py:F401,F403
funsor/jax/distributions.py:F821
funsor/torch/distributions.py:F821
test/conftest.py:E402
2 changes: 1 addition & 1 deletion funsor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
testing,
)

__version__ = "0.4.7" # mirrored in setup.py
__version__ = "0.4.7" # used by pyproject.toml

__all__ = [
"__version__",
Expand Down
2 changes: 1 addition & 1 deletion funsor/adjoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def adjoint_contract_generic(
sum_op,
prod_op,
reduced_vars,
*terms
*terms,
)


Expand Down
6 changes: 3 additions & 3 deletions funsor/cnf.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _sample(self, sampled_vars, sample_inputs, rng_key):
self.red_op,
self.bin_op,
self.reduced_vars,
*(terms + sampled_terms)
*(terms + sampled_terms),
)
else:
raise NotImplementedError(
Expand Down Expand Up @@ -431,7 +431,7 @@ def normalize_contraction_commute_joint(red_op, bin_op, reduced_vars, mixture, o
mixture.red_op if red_op is ops.null else red_op,
bin_op,
reduced_vars | mixture.reduced_vars,
*(mixture.terms + (other,))
*(mixture.terms + (other,)),
)


Expand All @@ -443,7 +443,7 @@ def normalize_contraction_commute_joint(red_op, bin_op, reduced_vars, other, mix
mixture.red_op if red_op is ops.null else red_op,
bin_op,
reduced_vars | mixture.reduced_vars,
*(mixture.terms + (other,))
*(mixture.terms + (other,)),
)


Expand Down
2 changes: 1 addition & 1 deletion funsor/optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def unfold_contraction_generic_tuple(red_op, bin_op, reduced_vars, terms):
v.red_op,
bin_op,
v.reduced_vars,
*(terms[:i] + (vt,) + terms[i + 1 :])
*(terms[:i] + (vt,) + terms[i + 1 :]),
)
for vt in v.terms
)
Expand Down
107 changes: 107 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
[build-system]
requires = ["setuptools>=77"]
build-backend = "setuptools.build_meta"

[project]
name = "funsor"
description = "A tensor-like library for functions and distributions"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.10"
license = "Apache-2.0"
license-files = ["LICENSE.md"]
dynamic = ["version"]
authors = [
{ name = "Uber AI Labs" },
]
keywords = ["probabilistic", "machine learning", "bayesian statistics", "pytorch", "jax"]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Education",
"Intended Audience :: Science/Research",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
]
dependencies = [
"makefun",
"multipledispatch",
"numpy>=1.7",
"opt_einsum>=2.3.2",
"typing_extensions",
]

[project.optional-dependencies]
torch = [
"pyro-ppl>=1.8.0",
"torch>=1.11.0",
"torchvision>=0.12.0",
]
jax = [
"numpyro>=0.7.0",
"jax>=0.2.21",
"jaxlib>=0.1.71",
]
test = [
"black",
"flake8",
"isort>=5.0",
"pandas",
"pyro-api>=0.1.2",
"pytest>=7",
"pytest-xdist>=3",
"requests",
"scipy",
]
dev = [
"black",
"flake8",
"isort>=5.0",
"nbsphinx",
"pandas",
"pytest>=7",
"pytest-xdist>=3",
"scipy",
"sphinx>=2.0",
"sphinx-gallery",
"sphinx_rtd_theme",
"torchvision>=0.12.0",
]

[project.urls]
Homepage = "https://github.com/pyro-ppl/funsor"
Documentation = "https://funsor.pyro.ai"
Repository = "https://github.com/pyro-ppl/funsor"
Issues = "https://github.com/pyro-ppl/funsor/issues"

[tool.setuptools.dynamic]
version = { attr = "funsor.__version__" }

[tool.setuptools.packages.find]
include = ["funsor", "funsor.*"]

[tool.isort]
profile = "black"
known_first_party = ["funsor", "test"]
known_third_party = ["opt_einsum", "pyro", "pyroapi", "torch", "torchvision"]

[tool.pytest.ini_options]
filterwarnings = [
"error",
"ignore:numpy.ufunc size changed:RuntimeWarning",
"ignore:numpy.dtype size changed:RuntimeWarning",
"ignore:Mixed memory format:UserWarning",
"ignore:Cannot memoize Op:UserWarning",
"ignore::DeprecationWarning",
"ignore:CUDA initialization:UserWarning",
"ignore:floor_divide is deprecated:UserWarning",
"ignore:__floordiv__ is deprecated:UserWarning",
"ignore:__rfloordiv__ is deprecated:UserWarning",
"ignore:torch.cholesky is deprecated:UserWarning",
"ignore:torch.symeig is deprecated:UserWarning",
"once::DeprecationWarning",
]
doctest_optionflags = "ELLIPSIS NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL"
36 changes: 0 additions & 36 deletions setup.cfg

This file was deleted.

93 changes: 0 additions & 93 deletions setup.py

This file was deleted.

7 changes: 4 additions & 3 deletions test/test_distribution_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,9 +778,10 @@ def test_generic_stats(case, statistic):
raw_dist, output=funsor.Real, dim_to_name=dim_to_name
)

with xfail_if_not_implemented(
msg="entropy not implemented for some distributions"
), xfail_if_not_found(msg="stats not implemented yet for TransformedDist"):
with (
xfail_if_not_implemented(msg="entropy not implemented for some distributions"),
xfail_if_not_found(msg="stats not implemented yet for TransformedDist"),
):
actual_stat = getattr(funsor_dist, statistic)()

with xfail_if_not_implemented():
Expand Down
4 changes: 2 additions & 2 deletions test/test_memoize.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ def test_nested_einsum_complete_sharing(
output2_1 = einsum_impl2(
outputs1[0] + "," + eqn2,
*([output1_1] + funsor_operands2),
backend=backend2
backend=backend2,
)

output1_2 = einsum_impl1(eqn1, *funsor_operands1, backend=backend1)
output2_2 = einsum_impl2(
outputs1[0] + "," + eqn2,
*([output1_2] + funsor_operands2),
backend=backend2
backend=backend2,
)

assert output1_1 is output1_2
Expand Down
2 changes: 1 addition & 1 deletion test/test_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def test_nested_einsum(
outputs1[0] + "," + eqn2,
*([expected1] + operands2),
backend=backend2,
modulo_total=True
modulo_total=True,
)[0]

with normalize:
Expand Down
Loading