fix: SC_apply() The selected columns were offset.#43
Merged
dfm88 merged 1 commit intodagghe:mainfrom Dec 23, 2025
Merged
Conversation
There was a problem hiding this comment.
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
mathmodule import to support the new calculation usingceil()andfloor()functions
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
|
@shota109-eng thank for your PR, makes sense to me, just asking a confirm to @dagghe for merging |
Contributor
Author
|
Thanks! |
Collaborator
|
great all tests have passed, think we can merge this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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