BUG: `IndexError` when `hidden_layer_sizes` is a scalar
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- python
- Domain
- machine-learning
Research direction
The reproduction imports GFDLRegressor from gfdl.model, so start in the gfdl/model.py fit path where hidden_layer_sizes is indexed; the issue says it becomes a 0-dim array via np.asarray. Run the snippet from the issue to confirm the IndexError. Done means a scalar hidden_layer_sizes is wrapped into a list, as sklearn's MLPRegressor does, and both estimators fit without error.
Written by the indexing model from the issue text.
Description
Describe the bug
IndexError when fitting GFDLRegressor with hidden_layer_sizes=100 (a scalar)
The closest analog in sklearn is MLPRegressor, which handles the input of a scalar hidden_layer_sizes by the following.
def _fit(self, X, y, sample_weight=None, incremental=False):
# Make sure self.hidden_layer_sizes is a list
hidden_layer_sizes = self.hidden_layer_sizes
if not hasattr(hidden_layer_sizes, "__iter__"):
hidden_layer_sizes = [hidden_layer_sizes]
hidden_layer_sizes = list(hidden_layer_sizes)
We use hidden_layer_sizes = np.asarray(self.hidden_layer_sizes) which leads to a 0-dim array. Then, when you invoke hidden_layer_sizes[0] you received the IndexError.
Steps to reproduce
from gfdl.model import GFDLRegressor
from sklearn.datasets import make_regression
from sklearn.neural_network import MLPRegressor
X, y = make_regression()
hidden_layer_sizes = 100
est = GFDLRegressor(hidden_layer_sizes=hidden_layer_sizes)
est_nn = GFDLRegressor(hidden_layer_sizes=hidden_layer_sizes)
est_nn.fit(X, y)
est.fit(X, y)
Expected result
Both estimators are fit without problem.
Actual result
IndexError: too many indices for array: array is 0-dimensional, but 1 were indexed
Version
This happens on main as of October 14, 2026.
https://github.com/lanl/GFDL/commit/0efa7a6048d0c759636c860c96c040bd23e32a9e
Interest in fixing the bug
I could do this. It's not the highest priority.
- Dominant language
- Python
- Stars
- 3
- Forks
- 5
- Avg merge
- 3h 26m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lanl/GFDL
-
maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 1/5 Under an hour Newbie friendliness 84/100
-
maintenance
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
-
enhancement
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 35/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
huggingface/sentence-transformers#4186 ·
Maintainers usually reply within 5 days
-
documentation good first issue
Difficulty 2/5 Half a day Newbie friendliness 72/100
sujithputta02/Esapay#13 ·
-
bot-triaged module: correctness (silent) module: mps module: NaNs and Infs triage review
Difficulty 2/5 Half a day Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
SCIInstitute/SCIRun#2842 ·
Maintainers usually reply within 3 days