Skip to content

Commit dde572d

Browse files
[BUG] Fix Laplace energy_self calculation and docstring typos (#720)
#### Reference Issues/PRs Fixes #719 #### What does this implement/fix? Explain your changes. 1. **Bug fix in `Laplace._energy_self`**: The 1.5 multiplier for self-energy was incorrectly placed inside the array dimension check, causing scalar Laplace distributions to return wrong energy values. Moved the multiplier to apply unconditionally before the dimension check. 2. **Docstring convention fixes**: Changed `Parameter` → `Parameters` and `Return` → `Returns` to follow NumPy docstring conventions in: - exponential.py - _base.py - evaluate.py - _show_versions.py 3. **Input validation in `evaluate()`**: Added a check that `X` and `y` have the same length, providing a clear error message instead of cryptic failures downstream. #### Does your contribution introduce a new dependency? If yes, which one? No. #### What should a reviewer concentrate their feedback on? - Verify the mathematical correctness of the Laplace energy fix - Confirm the input validation message is appropriate
1 parent 1022484 commit dde572d

File tree

6 files changed

+33
-21
lines changed

6 files changed

+33
-21
lines changed

.all-contributorsrc

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@
6161
"avatar_url": "https://avatars.githubusercontent.com/u/2273226?v=4",
6262
"profile": "https://github.com/iwitaly",
6363
"contributions": [
64-
"code",
65-
"doc",
66-
"maintenance",
67-
"review"
64+
"code",
65+
"doc",
66+
"maintenance",
67+
"review"
6868
]
6969
},
7070
{
@@ -73,8 +73,8 @@
7373
"avatar_url": "https://avatars.githubusercontent.com/u/39331844?v=4",
7474
"profile": "https://github.com/yarnabrina",
7575
"contributions": [
76-
"code",
77-
"maintenance"
76+
"code",
77+
"maintenance"
7878
]
7979
},
8080
{
@@ -127,8 +127,8 @@
127127
"avatar_url": "https://avatars.githubusercontent.com/u/120820143?s=400&v=4",
128128
"profile": "https://github.com/ShreeshaM07",
129129
"contributions": [
130-
"code",
131-
"doc"
130+
"code",
131+
"doc"
132132
]
133133
},
134134
{
@@ -212,15 +212,24 @@
212212
"profile": "https://github.com/tingiskhan",
213213
"contributions": [
214214
"code",
215-
"bug",
215+
"bug"
216216
]
217217
},
218218
{
219219
"login": "joshdunnlime",
220220
"name": "Josh Dunn",
221221
"profile": "https://github.com/joshdunnlime",
222+
"contributions": [
223+
"code"
224+
]
225+
},
226+
{
227+
"login": "Ashish-Kumar-Dash",
228+
"name": "Ashish Kumar Dash",
229+
"profile": "https://github.com/Ashish-Kumar-Dash",
222230
"contributions": [
223231
"code",
232+
"bug"
224233
]
225234
}
226235
]

skpro/benchmarking/evaluate.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,11 @@ def evaluate(
194194
"but dask is not present in the python environment"
195195
)
196196

197-
# todo: input checks and coercions
198-
# cv = check_cv(cv, enforce_start_with_window=True)
197+
if len(X) != len(y):
198+
raise ValueError(
199+
f"X and y must have the same number of rows, "
200+
f"but found len(X)={len(X)} and len(y)={len(y)}"
201+
)
199202

200203
scoring = _check_scores(scoring)
201204

@@ -408,8 +411,8 @@ def _check_scores(metrics):
408411
----------
409412
metrics : skpro accepted metrics object or a list of them or None
410413
411-
Return
412-
------
414+
Returns
415+
-------
413416
metrics_type : Dict
414417
The key is metric types and its value is a list of its corresponding metrics.
415418
"""

skpro/distributions/exponential.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class Exponential(_ScipyAdapter):
2222
2323
The rate :math:`\lambda` is represented by the parameter ``rate``,
2424
25-
Parameter
26-
---------
25+
Parameters
26+
----------
2727
rate : float or array of float (1D or 2D)
2828
rate of the distribution
2929
rate = 1/scale

skpro/distributions/laplace.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ def _energy_self(self):
6969
2D np.ndarray, same shape as ``self``
7070
energy values w.r.t. the given points
7171
"""
72-
energy_arr = self._bc_params["scale"]
72+
energy_arr = self._bc_params["scale"] * 1.5
7373
if energy_arr.ndim > 0:
74-
energy_arr = np.sum(energy_arr, axis=1) * 1.5
74+
energy_arr = np.sum(energy_arr, axis=1)
7575
return energy_arr
7676

7777
def _energy_x(self, x):

skpro/regression/base/_base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -933,8 +933,8 @@ def _get_columns(self, method="predict", **kwargs):
933933
Primarily used as helper for probabilistic predict-like methods.
934934
Assumes that _check_X_y has been called, and self._y_metadata set.
935935
936-
Parameter
937-
---------
936+
Parameters
937+
----------
938938
method : str, optional (default="predict")
939939
method for which to return column names
940940
one of "predict", "predict_interval", "predict_quantiles", "predict_var"

skpro/utils/_maint/_show_versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
def _get_sys_info():
1818
"""System information.
1919
20-
Return
21-
------
20+
Returns
21+
-------
2222
sys_info : dict
2323
system and Python version information
2424
"""

0 commit comments

Comments
 (0)