Skip to content

Commit 9fbfb90

Browse files
MNT add rng seed for profile-narx (#159)
1 parent 48cc650 commit 9fbfb90

File tree

4 files changed

+3
-8
lines changed

4 files changed

+3
-8
lines changed

fastcan/narx/_base.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
from sklearn.base import BaseEstimator, MultiOutputMixin, RegressorMixin
1414
from sklearn.linear_model import LinearRegression
1515
from sklearn.utils import check_array, check_consistent_length, column_or_1d
16-
from sklearn.utils._openmp_helpers import _openmp_effective_n_threads
1716
from sklearn.utils._param_validation import Interval, StrOptions, validate_params
1817
from sklearn.utils.validation import (
1918
_check_sample_weight,
@@ -493,9 +492,9 @@ def _grad(
493492
else:
494493
n_x = n_coefs
495494
y_ids = output_ids
495+
496496
dydx = np.zeros((n_samples, n_outputs, n_x), dtype=float)
497497
dcf = np.zeros((max_delay, n_outputs, n_outputs), dtype=float)
498-
n_threads = _openmp_effective_n_threads()
499498

500499
_update_dydx(
501500
X,
@@ -510,7 +509,6 @@ def _grad(
510509
grad_feat_ids,
511510
dydx,
512511
dcf,
513-
n_threads,
514512
)
515513

516514
mask_valid = mask_missing_values(y, y_hat, sample_weight_sqrt, return_mask=True)

fastcan/narx/_narx_fast.pyx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ cdef inline void _update_terms(
2020
const int[:, ::1] feat_ids, # IN
2121
const int[:, ::1] delay_ids, # IN
2222
const int k, # IN
23-
const int num_threads, # IN
2423
) noexcept nogil:
2524
"""
2625
Evaluate all terms for the given features and delays at timestep k.
@@ -195,7 +194,6 @@ cpdef void _update_dydx(
195194
const int[:, ::1] grad_feat_ids,
196195
double[:, :, ::1] dydx, # OUT
197196
double[:, :, ::1] dcf, # OUT
198-
const int num_threads, # IN
199197
) noexcept nogil:
200198
"""
201199
Computation of the Jacobian matrix dydx.
@@ -245,7 +243,6 @@ cpdef void _update_dydx(
245243
feat_ids,
246244
delay_ids,
247245
k,
248-
num_threads,
249246
)
250247

251248
# Update constant terms of Jacobian

pixi.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ time-h = "python -m timeit -n 5 -s 'import numpy as np; from fastcan import Fast
116116
time-eta = "python -m timeit -n 5 -s 'import numpy as np; from fastcan import FastCan; X = np.random.rand(3000, 100); y = np.random.rand(3000, 20)' 's = FastCan(100, eta=True, verbose=0).fit(X, y)'"
117117
profile-minibatch = { cmd = '''python -c "import cProfile; import numpy as np; from fastcan import minibatch; X = np.random.rand(100, 3000); y = np.random.rand(100, 20); cProfile.run('minibatch(X, y, 1000, 10, verbose=0)', sort='$SORT')"''', env = { SORT = "cumtime" } }
118118
time-narx = '''python -m timeit -n 1 -s "import numpy as np; from fastcan.narx import make_narx; rng = np.random.default_rng(5); X = rng.random((1000, 10)); y = rng.random((1000, 2)); m = make_narx(X, y, 10, max_delay=2, poly_degree=2, verbose=0)" "m.fit(X, y, coef_init='one_step_ahead', verbose=1)"'''
119-
profile-narx = { cmd = '''python -c "import cProfile; import numpy as np; from fastcan.narx import make_narx; X = np.random.rand(3000, 3); y = np.random.rand(3000, 3); m = make_narx(X, y, 10, max_delay=10, poly_degree=2, verbose=0); cProfile.run('m.fit(X, y, coef_init=[0]*33)', sort='$SORT')"''', env = { SORT = "tottime" } }
119+
profile-narx = { cmd = '''python -c "import cProfile; import numpy as np; from fastcan.narx import make_narx; rng = np.random.default_rng(8); X = rng.random((3000, 3)); y = rng.random((3000, 3)); m = make_narx(X, y, 10, max_delay=10, poly_degree=2, verbose=0); cProfile.run('m.fit(X, y, coef_init=[0]*33)', sort='$SORT')"''', env = { SORT = "tottime" } }
120120

121121
[tool.pixi.feature.asv.tasks]
122122
asv-build = { cmd = "python -m asv machine --machine $MACHINE --yes && python -m asv run --show-stderr -v --machine $MACHINE $EXTRA_ARGS", cwd = "asv_benchmarks", env = { MACHINE = "MacOS-M1", EXTRA_ARGS = "" } }

0 commit comments

Comments
 (0)