Skip to content

Fixes #258: Support colon indexing in function calls in generators - #289

Open
jsphchoi wants to merge 1 commit into
madsuite-org:mainfrom
jsphchoi:jc/colon-indexing
Open

Fixes #258: Support colon indexing in function calls in generators#289
jsphchoi wants to merge 1 commit into
madsuite-org:mainfrom
jsphchoi:jc/colon-indexing

Conversation

@jsphchoi

@jsphchoi jsphchoi commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Fixes #258 z[:,i,k] previously returns MethodError: -(::Colon, ::Int64). Colon : now expands to a tuple of the entries along that dimension, so it can be splatted (f(z[:,i,k]...)) or passed whole (g(z[:,i,k])) when used as function inputs in a generator

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.86%. Comparing base (6f15038) to head (9ee26dd).
⚠️ Report is 44 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #289       +/-   ##
===========================================
- Coverage   80.80%   55.86%   -24.94%     
===========================================
  Files          20       25        +5     
  Lines        2021     4015     +1994     
===========================================
+ Hits         1633     2243      +610     
- Misses        388     1772     +1384     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Benchmark Results


Relative timing: current / main  (values < 1.0 are improvements)

================================================================================
  backend-instance-param          |      obj     cons     grad      jac     hess
================================================================================
  CUDA-OPF-case1354               |    1.005    1.029    1.007    1.045    1.027
  CUDA-OPF-case14                 |    0.998    1.014    1.008    1.035    1.003
  CUDA-OPF-case30000              |    1.005    1.014    1.004    1.044    1.021
  CUDA-chain-10                   |    1.005    1.003    1.003    0.981    1.000
  CUDA-chain-100                  |    1.003    1.015    1.012    0.995    0.994
  CUDA-chain-1000                 |    1.014    1.010    1.008    0.988    0.994
  CUDA-elec-10                    |    1.003    0.992    0.986    1.014    1.022
  CUDA-elec-100                   |    1.015    0.992    0.986    1.007    1.014
  CUDA-elec-1000                  |    1.011    0.994   33.189    1.013    0.101
  CUDA-rosenrock-1000             |    0.987    1.004    1.010    0.992    0.990
  CUDA-rosenrock-10000            |    1.001    1.024    1.008    1.002    1.000
  CUDA-rosenrock-100000           |    0.993    1.031    1.011    1.000    1.007
--------------------------------------------------------------------------------
  AMDGPU-OPF-case1354             |    0.552    0.916    0.887    0.910    0.946
  AMDGPU-OPF-case14               |    0.930    1.012    1.057    0.904    0.903
  AMDGPU-OPF-case30000            |    0.592    0.905    0.910    0.870    0.912
  AMDGPU-chain-10                 |    0.900    0.926    0.999    0.843    0.992
  AMDGPU-chain-100                |    0.999    1.004    0.983    1.002    1.029
  AMDGPU-chain-1000               |    0.947    1.024    0.960    0.929    0.949
  AMDGPU-elec-10                  |    0.871    0.825    0.878    0.832    0.809
  AMDGPU-elec-100                 |    1.041    0.794    0.850    0.867    0.833
  AMDGPU-elec-1000                |    0.970    0.851    0.989    0.845    0.894
  AMDGPU-rosenrock-1000           |    0.674    0.839    0.849    0.861    0.849
  AMDGPU-rosenrock-10000          |    0.571    0.807    0.830    0.822    0.844
  AMDGPU-rosenrock-100000         |    0.956    0.966    0.984    0.982    1.027
--------------------------------------------------------------------------------
  oneAPI-OPF-case1354             |    1.004    0.981    1.015    0.998    0.993
  oneAPI-OPF-case14               |    0.973    1.097    1.076    1.042    1.075
  oneAPI-OPF-case30000            |    0.986    0.988    0.972    0.995    0.994
  oneAPI-chain-10                 |    1.008    0.995    0.986    1.020    1.020
  oneAPI-chain-100                |    1.033    0.996    1.009    1.023    1.034
  oneAPI-chain-1000               |    1.054    1.015    0.964    1.021    1.022
  oneAPI-elec-10                  |    0.990    1.006    1.001    0.959    1.012
  oneAPI-elec-100                 |    0.976    1.018    1.030    0.957    1.013
  oneAPI-elec-1000                |    1.003    1.003    1.001    1.007    1.013
  oneAPI-rosenrock-1000           |    0.925    1.063    0.966    0.948    0.912
  oneAPI-rosenrock-10000          |    1.006    1.041    0.968    0.895    0.901
  oneAPI-rosenrock-100000         |    1.022    0.996    1.027    0.953    0.895
--------------------------------------------------------------------------------
  nothing-OPF-case1354            |    0.938    1.151    1.010    0.991    0.741
  nothing-OPF-case14              |    1.029    0.998    1.004    1.058    1.005
  nothing-OPF-case30000           |    0.994    0.994    0.924    0.986    1.004
  nothing-chain-10                |    1.703    1.005    1.001    0.987    1.002
  nothing-chain-100               |    1.783    1.005    0.998    0.922    1.002
  nothing-chain-1000              |    1.823    0.996    0.993    0.914    1.190
  nothing-elec-10                 |    1.020    0.957    0.992    1.008    0.993
  nothing-elec-100                |    1.000    1.011    0.994    0.991    0.995
  nothing-elec-1000               |    0.999    0.854    0.997    0.999    1.000
  nothing-rosenrock-1000          |    1.009    1.119    1.436    0.995    0.823
  nothing-rosenrock-10000         |    0.997    1.001    1.076    0.999    1.423
  nothing-rosenrock-100000        |    1.001    1.012    1.046    0.995    0.996
================================================================================

@jsphchoi jsphchoi changed the title Fixes #258: Support slice indexing in function calls in generators Fixes #258: Support colon indexing in function calls in generators Aug 3, 2026
Fixes madsuite-org#258. `x[:, i]` expands each colon axis to the tuple of its entries,
column-major as in Base, so it can be splatted (`f(z[:, i, k]...)`) or passed
whole (`g(z[:, i, k])`) inside a generator. `x[:]` linearizes. Previously
Variable and Parameter threw `MethodError: -(::Colon, ::Int64)` and Expression
silently treated `:` as a symbolic index.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

function calls with splatted variables not working within constraint()

1 participant