Skip to content

Commit 95d76d4

Browse files
committed
move version to mellon/version.py
1 parent b8c2c71 commit 95d76d4

File tree

5 files changed

+51
-12
lines changed

5 files changed

+51
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
- use [PyNNDescent](https://github.com/lmcinnes/pynndescent) for faster nearest neighbor distance computation
44
- update deprecated `tol` argument of `jax.numpy.linalg.matrix_rank` to `rtol`
55
- forward random state to k-means to compute landmarks
6-
- modernize build system using pyproject.toml instead of setup.py
6+
- modernize build system using `pyproject.toml` instead of setup.py
7+
- centralize version in `mellon/version.py` with dynamic versioning in pyproject.toml
78

89
# v1.5.0
910

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def get_version(rel_path):
3535
author = "Setty Lab"
3636

3737
# The full version, including alpha/beta/rc tags
38-
release = get_version("../../mellon/__init__.py")
38+
release = get_version("../../mellon/version.py")
3939

4040

4141
# -- General configuration ---------------------------------------------------

mellon/__init__.py

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@
1818
from . import _conditional as conditional
1919
from . import _derivatives as derivatives
2020
from . import validation
21-
22-
__version__ = "1.6.0"
21+
from .version import __version__
2322

2423
__all__ = [
2524
"DensityEstimator",
@@ -37,13 +36,30 @@
3736
"decomposition",
3837
"derivatives",
3938
"__version__",
39+
"setup_jax",
40+
"setup_logging",
4041
]
4142

42-
# Set default configuration at import time
43-
jaxconfig.update("jax_enable_x64", True)
44-
jaxconfig.update("jax_platform_name", "cpu")
4543

46-
# configure logging
44+
def setup_jax(enable_x64=True, platform="cpu"):
45+
"""Set up JAX configuration.
46+
47+
Parameters
48+
----------
49+
enable_x64 : bool, default=True
50+
Whether to enable 64-bit precision.
51+
platform : str, default="cpu"
52+
Platform to use for JAX computation.
53+
"""
54+
jaxconfig.update("jax_enable_x64", enable_x64)
55+
jaxconfig.update("jax_platform_name", platform)
56+
57+
58+
# Default JAX configuration
59+
setup_jax()
60+
61+
62+
# Logging configuration
4763
LOGGING_CONFIG = {
4864
"version": 1,
4965
"disable_existing_loggers": False,
@@ -69,5 +85,21 @@
6985
},
7086
}
7187

72-
logging.config.dictConfig(LOGGING_CONFIG)
73-
logger = logging.getLogger("mellon")
88+
89+
def setup_logging(config=None):
90+
"""Set up logging configuration.
91+
92+
Parameters
93+
----------
94+
config : dict, optional
95+
Logging configuration dictionary. If None, the default
96+
configuration is used.
97+
"""
98+
if config is None:
99+
config = LOGGING_CONFIG
100+
logging.config.dictConfig(config)
101+
return logging.getLogger("mellon")
102+
103+
104+
# Configure default logging
105+
logger = setup_logging()

mellon/version.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""Version information."""
2+
3+
__version__ = "1.6.0"

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["setuptools>=42", "wheel"]
2+
requires = ["setuptools>=61.0", "wheel"]
33
build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "mellon"
7-
version = "1.6.0"
7+
dynamic = ["version"]
88
description = "Non-parametric density estimator."
99
authors = [
1010
{name = "Setty Lab", email = "dominik.otto@gmail.com"}
@@ -29,6 +29,9 @@ Homepage = "https://github.com/settylab/mellon"
2929
[tool.setuptools]
3030
packages = ["mellon"]
3131

32+
[tool.setuptools.dynamic]
33+
version = {attr = "mellon.version.__version__"}
34+
3235
[project.optional-dependencies]
3336
dev = [
3437
"black",

0 commit comments

Comments
 (0)