Skip to content

Improve AdvancedSubtensor and AdvancedIncSubtensor#1910

Open
aman-coder03 wants to merge 6 commits intopymc-devs:mainfrom
aman-coder03:enh-advanced-subtensor-repr
Open

Improve AdvancedSubtensor and AdvancedIncSubtensor#1910
aman-coder03 wants to merge 6 commits intopymc-devs:mainfrom
aman-coder03:enh-advanced-subtensor-repr

Conversation

@aman-coder03
Copy link

@aman-coder03 aman-coder03 commented Feb 23, 2026

Description

Improves the string representation of AdvancedSubtensor and AdvancedIncSubtensor to include their index information, making debug output more consistent with Subtensor
Previously, calling dprint() on advanced indexing operations would display only the operator name (e.g., AdvancedSubtensor) without showing the indices used. This made debugging and graph inspection harder

this PR,
adds a __str__ implementation to AdvancedSubtensor that formats indices using Subtensor.str_from_indices
updates AdvancedIncSubtensor.__str__ to include formatted indices
keeps behavior consistent with existing Subtensor representations

Related Issue

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

def __str__(self):
return f"{self.__class__.__name__}{{{Subtensor.str_from_indices(self.idx_list)}}}"
return (
f"{self.__class__.__name__}{{{Subtensor.str_from_indices(self.idx_list)}}}"
Copy link
Member

Choose a reason for hiding this comment

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

you can move str_from_indices to BaseSubtensor

def __str__(self):
name = "SetSubtensor" if self.set_instead_of_inc else "IncSubtensor"
return f"{name}{{{Subtensor.str_from_indices(self.idx_list)}}}"
return f"{name}{{{BaseSubtensor.str_from_indices(self.idx_list)}}}"
Copy link
Member

Choose a reason for hiding this comment

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

You can use super() now

Copy link
Author

Choose a reason for hiding this comment

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

done, updated to use super() instead

Copy link
Member

Choose a reason for hiding this comment

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

I think you're missing a couple more

Copy link
Author

Choose a reason for hiding this comment

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

yeah was updating them too! sorry for the confusion!

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.

Advanced(Inc)Subtensor test representation

2 participants