Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

BUG: `IndexError` when `hidden_layer_sizes` is a scalar

Open Beginner friendly
#136 0 comments 0 reactions 0 assignees View on GitHub

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

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

bug

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lanl/GFDL

All issues in lanl/GFDL

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.