GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Create a Proxy subclass that we use for our Graphic classes · Issue #161 · fastplotlib/fastplotlib

Create a Proxy subclass that we use for our Graphic classes #161

New issue
Copy link
New issue
Copy link
Closed
#546
Closed
Create a Proxy subclass that we use for our Graphic classes#161
#546
Copy link
Assignees
clewis7

Description

@kushalkolar
kushalkolar
opened on Apr 4, 2023
Issue body actions

the purpose of this is having useful __repr__ etc.

Activity

  1. kushalkolar
    assigned
    clewis7
    on Apr 4, 2023
  2. clewis7 commented on Apr 11, 2023

    @clewis7
    clewis7
    on Apr 11, 2023
    Member
    More actions

    just to clarify....

    currently adding a graphic to a plot returns a __repr__ that looks like this:

    <weakproxy at 0x7f28437e11d0 to ImageGraphic at 0x7f27f87d4610>

    but we want to return __repr__ as they were before?

    ImageGraphic @ 0x7fbb681a1360

  3. kushalkolar commented on Apr 11, 2023

    @kushalkolar
    kushalkolar
    on Apr 11, 2023
    MemberAuthor
    More actions

    yup, along with name etc.

    I just noticed that the real repr prints if you check a Plot or Subplot so this is actually not too important for now. If it takes > 30 mins to figure out let's skip this for now.

  4. clewis7 commented on Apr 11, 2023

    @clewis7
    clewis7
    on Apr 11, 2023
    Member
    More actions

    yes, and if you call __repr__ on the proxy object that gets returned it will also give the correct __repr__ for a graphic

  5. clewis7 commented on Apr 11, 2023

    @clewis7
    clewis7
    on Apr 11, 2023
    Member
    More actions

    so maybe just overriding the __repr__ method for the proxy so that it actually returns the __repr__ of what the proxy is pointing to as opposed to the current __repr__ it returns?

  6. kushalkolar commented on Apr 11, 2023

    @kushalkolar
    kushalkolar
    on Apr 11, 2023
    MemberAuthor
    More actions

    so maybe just overriding the __repr__ method for the proxy so that it actually returns the __repr__ of what the proxy is pointing to as opposed to the current __repr__ it returns?

    if it's that simple, but I don't know

  7. almarklein commented on Mar 12, 2024

    @almarklein
    almarklein
    on Mar 12, 2024
    Collaborator
    More actions

    I briefly looked at this. I initially thought that the proxy was a custom object, but it's a weakref.proxy object, which is builtin and cannot be subclassed. So basically there's no way to change the repr. You technically can implement your own custom varianf of weakref.proxy ... but that's probably a rabbit-hole.

    An alternative solution is that the Graphics object becomes the proxy. That makes sense, I think, because it already plays the role of a proxy, projection fpl features onto pygfx world objects. In terms of code, this'd mean that the graphics instance holds a weakref (weakref.ref() or weakref.proxy()) to the WorldObject ... and that should be about it.

  8. kushalkolar commented on Mar 13, 2024

    @kushalkolar
    kushalkolar
    on Mar 13, 2024
    MemberAuthor
    More actions

    Thanks for looking into it!

    Each Graphic uses a weakref to the pygfx.WorldObject, however this was not sufficient for complete garbage collection. Since we have the various GraphicFeatures that wrap pygfx.Buffer (ex. ColorFeature) , and these can also hold event handlers of other graphics, it was necessary to have Graphic as a weakref as well to ensure both VRAM and system RAM get freed. This specifically traces back to this commit: 5e9f544#diff-87b8787e6cc96514902d278266d644006041f56cb59a1c3487193f564ea71afdL130-R150

    Since the repr is typically useful in ipython or notebooks I think we'll just implement #428 for now.

  9. clewis7
    closed this as completedin #546on Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @clewis7
    clewis7

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.