Skip to content

fix: elliptic_func returns NaN when input has 1 element (affects F17, F29 at 10D)#46

Open
Ahmedman60 wants to merge 1 commit intothieu1995:masterfrom
Ahmedman60:Ahmedman60-patch-1
Open

fix: elliptic_func returns NaN when input has 1 element (affects F17, F29 at 10D)#46
Ahmedman60 wants to merge 1 commit intothieu1995:masterfrom
Ahmedman60:Ahmedman60-patch-1

Conversation

@Ahmedman60
Copy link

Closes #

📋 Description

elliptic_func in opfunu/utils/operator.py computes 6.0 * idx / (ndim - 1),
which causes division by zero when the input array has 1 element (ndim - 1 = 0),
returning NaN.

This affects:

  • F172017 at 10D — p[0] = 0.1 gives ceil(0.1 × 10) = 1 element passed to elliptic_func
  • F292017 at 10D — embeds F172017 as a sub-component, NaN propagates up

Both functions list 10D in dim_supported, making this a supported-but-broken case.

✅ Checks

  • My pull request adheres to the code style of this project
  • My code does not require changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

💻 Additional Information

Fix: added a guard for the 1-element case, returning x[0] ** 2 directly
(equivalent to the function with exponent scale = 10^0 = 1).

Verified: NaN → valid float at 10D for both F17 and F29.
30D results unchanged. Tested via monkey-patch before modifying source.

…ng F17 and F29 10D)

When ndim=1, the expression 6.0 * idx / (ndim - 1) causes division
by zero returning NaN. This affects F172017 and F292017 at 10D,
both listed in dim_supported.

Fix: guard for 1-element case, returns x[0]**2 directly.
Verified at 10D and 30D.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant