Skip to content

fix: SC_apply() The selected columns were offset.#43

Merged
dfm88 merged 1 commit intodagghe:mainfrom
shota109-eng:feature/SC_apply_column_offset
Dec 23, 2025
Merged

fix: SC_apply() The selected columns were offset.#43
dfm88 merged 1 commit intodagghe:mainfrom
shota109-eng:feature/SC_apply_column_offset

Conversation

@shota109-eng
Copy link
Contributor

@shota109-eng shota109-eng commented Dec 22, 2025

Hello, I'm a university student using pyOMEA2 for my study and gratefull for your works!

I found a bug in pyoma2.functions.gen.SC_apply().

The following shows what my PR changes the current condition.


import numpy as np
import math

ordmin = 2
ordmax = 28
step = 3

#model orders
arr = np.arange(0, int(ordmax / step + 1)) * step

print(arr)
#[ 0 3 6 9 12 15 18 21 24 27]

#old
for oo in range(ordmin, ordmax + 1, step):
o = int(oo / step - 1)
print(arr[o])
#0 0 3 6 9 12 15 18 21

#new
for o in range(math.ceil(ordmin / step), math.floor(ordmax / step) + 1):
print(arr[o])
#3 6 9 12 15 18 21 24 27


import numpy as np
import math

ordmin = 0
ordmax = 5
step = 1

#model orders
arr = np.arange(0, int(ordmax / step + 1)) * step

print(arr)
#[0 1 2 3 4 5]

#old
for oo in range(ordmin, ordmax + 1, step):
o = int(oo / step - 1)
print(arr[o])
#5 0 1 2 3 4

#new
for o in range(math.ceil(ordmin / step), math.floor(ordmax / step) + 1):
print(arr[o])
#0 1 2 3 4 5

@shota109-eng shota109-eng changed the title fix: The selected columns were offset. fix: SC_apply() The selected columns were offset. Dec 22, 2025
@dfm88 dfm88 requested a review from Copilot December 22, 2025 08:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a critical bug in the SC_apply() function where array column indices were incorrectly calculated, causing the function to access wrong columns when processing model orders. The fix replaces the flawed index calculation with a mathematically correct approach that properly maps model orders to array column indices.

Key Changes:

  • Corrected the loop iteration logic to properly calculate array column indices from model orders
  • Added the math module import to support the new calculation using ceil() and floor() functions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dfm88
Copy link
Collaborator

dfm88 commented Dec 22, 2025

@shota109-eng thank for your PR, makes sense to me, just asking a confirm to @dagghe for merging

@shota109-eng
Copy link
Contributor Author

Thanks!

@dfm88 dfm88 merged commit 6966410 into dagghe:main Dec 23, 2025
21 checks passed
@dfm88
Copy link
Collaborator

dfm88 commented Dec 23, 2025

great all tests have passed, think we can merge this!

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.

2 participants