Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Implementlastindex for ragged arrays#501

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
JoshuaLampert wants to merge6 commits intoSciML:master
base:master
Choose a base branch
Loading
fromJoshuaLampert:lastindex-ragged

Conversation

@JoshuaLampert
Copy link
Contributor

@JoshuaLampertJoshuaLampert commentedDec 16, 2025
edited
Loading

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular theSciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

This is an AI-generated solution to allowing the use ofend for raggedVectorOfArrays//heterogeneous inner array sizes. As also noted in#454 (comment), previously this could either give wrong results or give aBoundsError.

Closes#267.

returnlastindex(VA.u)
elseif d<ndims(VA)
isempty(VA.u)&&return0
return_is_ragged_dim(VA, d)?RaggedEnd{d}():size(VA.u[1], d)

Choose a reason for hiding this comment

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

Does this not give inference issues?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Hm yes, might be. As I said, this was AI-generated. I'll see if I can fix that.

Choose a reason for hiding this comment

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

instead of using types if it's runtime, so enum then I think the strategy is fine.

JoshuaLampert reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I'm not sure I understand.RaggedEnd should be anenum instead of a struct? If yes, what would be the values?

Choose a reason for hiding this comment

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

or just 0 and interpret what zero means.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

To be honest, I only understand half of what is going on here, but aren't we loosing information (thed) when we return 0 instead ofRaggedEnd{d}()? I tried making it work with the help of Claude, but there were always tests failing.

Choose a reason for hiding this comment

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

yeah I see. The point though is to just make it be some kind of runtime value instead of a compile time value. So instead of a type with d, just like a tuple (true, d) for ragged true/false.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Ok, thanks for the clarification! So, shouldBase.lastindex always return a tuple then? Also in the non-ragged case?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I made a suggestion in36561a0. This uses runtime values, but still returnsRaggedEnd. As far as I understand we cannot return tuples because we need to overload+ and- for that, which we obviously do not want to do for a general tuple.

Comment on lines +410 to +412
returnRaggedEnd(Int(d))
else
return1

Choose a reason for hiding this comment

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

type unstable, add JET testing to this

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ChrisRackauckasChrisRackauckasChrisRackauckas left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@JoshuaLampert@ChrisRackauckas

[8]ページ先頭

©2009-2025 Movatter.jp