Skip to content

Commit

Permalink
Revert "Revert everything to last successful build"
Browse files Browse the repository at this point in the history
This reverts commit 49d13cf.
  • Loading branch information
stanmart committed Jan 29, 2025
1 parent 49d13cf commit 4d18ae8
Show file tree
Hide file tree
Showing 21 changed files with 10,260 additions and 12,441 deletions.
14 changes: 14 additions & 0 deletions .ci_support/linux_64_python3.13_default.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
c_compiler:
- gcc
c_compiler_version:
- '12'
cxx_compiler:
- gxx
cxx_compiler_version:
- '12'
numpy:
- '2.1'
python:
- 3.13.* *_cp313
target_platform:
- linux-64
19 changes: 19 additions & 0 deletions .ci_support/osx_64_python3.13_default.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
xMACOSX_DEPLOYMENT_TARGET:
- '10.9'
c_compiler:
- clang
c_compiler_version:
- '17'
cxx_compiler:
- clangxx
cxx_compiler_version:
- '17'
macos_machine:
- x86_64-apple-darwin13.4.0
numpy:
- '2.1'
python:
- 3.13.* *_cp313
target_platform:
- osx-64

18 changes: 18 additions & 0 deletions .ci_support/osx_arm64_python3.13.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MACOSX_DEPLOYMENT_TARGET:
- '11.0'
c_compiler:
- clang
c_compiler_version:
- '17'
cxx_compiler:
- clangxx
cxx_compiler_version:
- '17'
macos_machine:
- arm64-apple-darwin20.0.0
numpy:
- '2.1'
python:
- 3.13.* *_cp313
target_platform:
- osx-arm64
10 changes: 10 additions & 0 deletions .ci_support/win_64_python3.13.____cpython.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
c_compiler:
- vs2019
cxx_compiler:
- vs2019
numpy:
- '2.1'
python:
- 3.13.* *_cp313
target_platform:
- win-64
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
* @MarcAntoineSchmidtQC @xhochy @jtilly @lbittarello
* @MarcAntoineSchmidtQC @jtilly @lbittarello @stanmart
2 changes: 1 addition & 1 deletion .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build:
tools:
python: mambaforge-4.10
commands:
- mamba install -c conda-forge -c nodefaults pixi==0.27.0
- mamba install -c conda-forge -c nodefaults pixi==0.39.4
- pixi run -e docs postinstall
- pixi run readthedocs
sphinx:
Expand Down
14 changes: 12 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,18 @@
Changelog
=========

Unreleased
----------
4.1.1 - 2025-01-29
------------------

**Bug fix:**

- A more robust :meth:`DenseMatrix._get_col_stds` results in more accurate :meth:`StandardizedMatrix.sandwich` results.

**Other changes:**

- Build wheel for pypi on python 3.13.
- Build and test with python 3.13 in CI.


4.1.0 - 2024-11-07
------------------
Expand Down
11 changes: 0 additions & 11 deletions build_tools/prepare_macos_wheel.sh

This file was deleted.

2 changes: 2 additions & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
tabmat package
========================

.. autofunction:: tabmat.from_df

.. autofunction:: tabmat.from_pandas

.. autofunction:: tabmat.from_csc
Expand Down
22,429 changes: 10,062 additions & 12,367 deletions pixi.lock

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ test = "pytest tests --doctest-modules src"

[feature.docs.tasks]
make-docs = "cd docs && make html"
serve-docs = { cmd = "python -m http.server --directory docs/_build/html", depends_on = ["make-docs"] }
readthedocs = { cmd = "rm -rf $READTHEDOCS_OUTPUT/html && cp -r docs/_build/html $READTHEDOCS_OUTPUT/html", depends_on = ["make-docs"] }
serve-docs = { cmd = "python -m http.server --directory docs/_build/html", depends-on = ["make-docs"] }
readthedocs = { cmd = "rm -rf $READTHEDOCS_OUTPUT/html && cp -r docs/_build/html $READTHEDOCS_OUTPUT/html", depends-on = ["make-docs"] }

[feature.benchmark.tasks.benchmark-generate-matrices]
cmd = "python src/tabmat/benchmark/generate_matrices.py"
Expand All @@ -38,7 +38,7 @@ outputs = [
]
[feature.benchmark.tasks.benchmark-run]
cmd = "python src/tabmat/benchmark/main.py --include_baseline --bench_memory --n_iterations 100"
depends_on = ["benchmark-generate-matrices"]
depends-on = ["benchmark-generate-matrices"]
inputs = [
"src/tabmat/benchmark/main.py",
"benchmark/data/dense_cat_data.pkl",
Expand All @@ -62,7 +62,7 @@ outputs = [
]
[feature.benchmark.tasks.benchmark-visualize]
cmd = "python src/tabmat/benchmark/visualize_benchmarks.py"
depends_on = ["benchmark-run"]
depends-on = ["benchmark-run"]
inputs = [
"src/tabmat/benchmark/visualize_benchmarks.py",
"benchmark/data/dense_cat_bench.csv",
Expand Down Expand Up @@ -94,6 +94,8 @@ jemalloc-local = "*"
[host-dependencies]
python = ">=3.9"
pip = "*"
setuptools = "*"
wheel = "*"

[dependencies]
formulaic = ">=0.6.4"
Expand Down Expand Up @@ -146,15 +148,17 @@ python = "3.10.*"
python = "3.11.*"
[feature.py312.dependencies]
python = "3.12.*"
[feature.py313.dependencies]
python = "3.13.*"

[feature.oldies.dependencies]
setuptools = "62.*"
python = "3.9.19"
numpy = "1.24.0"
pandas = "1.4.4"
scipy = "1.7.3"
formulaic = "0.6.4"
narwhals = "1.4.1"
python = "=3.9.19"
numpy = "=1.24.0"
pandas = "=1.4.4"
scipy = "=1.7.3"
formulaic = "=0.6.4"
narwhals = "=1.4.1"

[environments]
default = ["dev", "test"]
Expand All @@ -164,6 +168,7 @@ py39 = ["py39", "test"]
py310 = ["py310", "test"]
py311 = ["py311", "test"]
py312 = ["py312", "test"]
py313 = ["py313", "test"]
oldies = ["oldies", "test"]
lint = { features = ["lint"], no-default-feature = true}
nightly = ["py312", "test"]
nightly = ["py313", "test"]
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,20 @@ skip = [
"cp36*",
"cp37*",
"cp38*",
"cp313-*",
]
test-requires = ["pytest", "pytest-xdist"]
test-command = "pytest {package}/tests/test_matrices.py"
# note: ARCHS_LINUX defined in build_wheels.yml file.

[tool.cibuildwheel.macos]
before-build = [
"bash build_tools/prepare_macos_wheel.sh",
"/Users/runner/micromamba-bin/micromamba create -y -p $MAMBA_ROOT_PREFIX/envs/build -c conda-forge jemalloc-local \"xsimd<11|>12.1\" llvm-openmp",
]

[tool.cibuildwheel.macos.environment]
LDFLAGS="-Wl,-rpath,$CONDA/envs/build/lib -L$CONDA/envs/build/lib -headerpad_max_install_names"
CFLAGS="-I$CONDA/envs/build/include"
CXXFLAGS="-I$CONDA/envs/build/include"
LDFLAGS="-Wl,-rpath,$MAMBA_ROOT_PREFIX/envs/build/lib -L$MAMBA_ROOT_PREFIX/envs/build/lib -headerpad_max_install_names"
CFLAGS="-I$MAMBA_ROOT_PREFIX/envs/build/include"
CXXFLAGS="-I$MAMBA_ROOT_PREFIX/envs/build/include"
CXX="/usr/bin/clang++"
CC="/usr/bin/clang"
JE_INSTALL_SUFFIX="local"
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
],
package_dir={"": "src"},
packages=find_packages(where="src"),
Expand Down
3 changes: 2 additions & 1 deletion src/tabmat/categorical_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def matvec(mat, vec):

import narwhals.stable.v1 as nw
import numpy as np
import numpy.typing
from scipy import sparse as sps

from .dense_matrix import DenseMatrix
Expand Down Expand Up @@ -339,7 +340,7 @@ def __init__(
cat_vec,
categories: Optional[np.ndarray] = None,
drop_first: bool = False,
dtype: np.dtype = np.float64,
dtype: numpy.typing.DTypeLike = np.float64,
column_name: Optional[str] = None,
term_name: Optional[str] = None,
column_name_format: str = "{name}[{category}]",
Expand Down
7 changes: 4 additions & 3 deletions src/tabmat/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import narwhals.stable.v1 as nw
import numpy as np
import numpy.typing
from formulaic import Formula, ModelSpec
from formulaic.materializers.types import NAAction
from formulaic.parser import DefaultFormulaParser
Expand All @@ -28,7 +29,7 @@
@nw.narwhalify(eager_only=True)
def from_df(
df,
dtype: np.dtype = np.float64,
dtype: numpy.typing.DTypeLike = np.float64,
sparse_threshold: float = 0.1,
cat_threshold: int = 4,
object_as_cat: bool = False,
Expand Down Expand Up @@ -207,7 +208,7 @@ def from_df(

def from_pandas(
df,
dtype: np.dtype = np.float64,
dtype: numpy.typing.DTypeLike = np.float64,
sparse_threshold: float = 0.1,
cat_threshold: int = 4,
object_as_cat: bool = False,
Expand Down Expand Up @@ -300,7 +301,7 @@ def from_formula(
data,
ensure_full_rank: bool = False,
na_action: Union[str, NAAction] = NAAction.IGNORE,
dtype: np.dtype = np.float64,
dtype: numpy.typing.DTypeLike = np.float64,
sparse_threshold: float = 0.1,
cat_threshold: int = 4,
interaction_separator: str = ":",
Expand Down
4 changes: 2 additions & 2 deletions src/tabmat/dense_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ def _cross_sandwich(
raise TypeError

def _get_col_stds(self, weights: np.ndarray, col_means: np.ndarray) -> np.ndarray:
"""Get standard deviations of columns."""
sqrt_arg = transpose_square_dot_weights(self._array, weights) - col_means**2
"""Get standard deviations of columns using weights `weights`."""
sqrt_arg = transpose_square_dot_weights(self._array, weights, col_means)
# Minor floating point errors above can result in a very slightly
# negative sqrt_arg (e.g. -5e-16). We just set those values equal to
# zero.
Expand Down
6 changes: 3 additions & 3 deletions src/tabmat/ext/dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def dense_matvec(np.ndarray X, floating[:] v, int[:] rows, int[:] cols):
raise Exception("The matrix X is not contiguous.")
return out

def transpose_square_dot_weights(np.ndarray X, floating[:] weights):
def transpose_square_dot_weights(np.ndarray X, floating[:] weights, floating[:] shift):
cdef floating* Xp = <floating*>X.data
cdef int nrows = weights.shape[0]
cdef int ncols = X.shape[1]
Expand All @@ -112,11 +112,11 @@ def transpose_square_dot_weights(np.ndarray X, floating[:] weights):
if X.flags["C_CONTIGUOUS"]:
for j in prange(ncols, nogil=True):
for i in range(nrows):
outp[j] = outp[j] + weights[i] * (Xp[i * ncols + j] ** 2)
outp[j] = outp[j] + weights[i] * ((Xp[i * ncols + j] - shift[j]) ** 2)
elif X.flags["F_CONTIGUOUS"]:
for j in prange(ncols, nogil=True):
for i in range(nrows):
outp[j] = outp[j] + weights[i] * (Xp[j * nrows + i] ** 2)
outp[j] = outp[j] + weights[i] * ((Xp[j * nrows + i] - shift[j]) ** 2)
else:
raise Exception("The matrix X is not contiguous.")
return out
Loading

0 comments on commit 4d18ae8

Please sign in to comment.