Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Core: Add reference #69

Merged
merged 14 commits into from
Sep 23, 2024

Conversation

mawildoer
Copy link
Contributor

@mawildoer mawildoer commented Sep 20, 2024

The graph is the correct way to draw references between Nodes, however, it's a PITA.

PR adds magic_pointer to make it easy to appropriately point at other Nodes

Checklist

Please read and execute the following:

  • My code follows the coding guidelines of this project
  • My PR title is following the contribution guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works (if applicable)
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I ran Black to format my code

Code of Conduct

By submitting this issue, you agree to follow our Code of Conduct:

@mawildoer mawildoer force-pushed the mawildoer/magic_pointers branch from 63a190d to c0358cf Compare September 20, 2024 13:27
@@ -145,6 +155,14 @@ def __init__(self, node: "Node", other: "Node", *args: object) -> None:
class NodeNoParent(NodeException): ...


class InitVar(dataclass_InitVar):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this belong in Node?

@@ -709,3 +743,48 @@ def zip_children_by_name_with[N: Node](
@staticmethod
def with_names[N: Node](nodes: Iterable[N]) -> dict[str, N]:
return {n.get_name(): n for n in nodes}


def magic_pointer[O: Node](out_type: type[O] | None = None) -> O:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does this belong in Node? It'd be the only classmethod a dev would typically touch in it, but it's also fewer imports and precisely node-related, so maybe 🤷‍♂️

@mawildoer mawildoer force-pushed the mawildoer/magic_pointers branch from c0358cf to 4fbc245 Compare September 22, 2024 16:46
@mawildoer mawildoer changed the base branch from main to mawildoer/constraint-params September 22, 2024 16:46
@mawildoer mawildoer changed the base branch from mawildoer/constraint-params to mawildoer/reduced-trait-verbosity September 22, 2024 16:49
@mawildoer mawildoer changed the title Core: Add megic_pointer to generate convenient references Library: Add Reference Sep 22, 2024
@mawildoer mawildoer changed the title Library: Add Reference Core: Add reference Sep 22, 2024
Copy link
Contributor

@iopapamanoglou iopapamanoglou left a comment

Choose a reason for hiding this comment

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

Amazing! Love the Pointer and better test_basic.

@mawildoer mawildoer merged commit 4fe88ff into mawildoer/reduced-trait-verbosity Sep 23, 2024
2 checks passed
@mawildoer mawildoer mentioned this pull request Sep 23, 2024
mawildoer added a commit that referenced this pull request Sep 23, 2024
Additionally, simplify the trait impl implementation and extend trait testing

* Core: Add `reference` (#69)

* Core: Add megic_pointer to generate convenient references

* Library: Move Reference to library and add some polish

* Library: Add has_reference trait

* Get the references passing pre-commit

* Test: refactor test_basic.py to work as a pytest properly

* Library: Move reference back to core. Apparently library doesn't like it

* Test: Refactor test_basic with clear criteria

* Improved basic test; use type_pair

* graphinterface connect tying

* Address incidious underlying properties

* Add check to ensure properties aren't instantiated as instance attributes during node construction

* Reinstate better errors on field construction

* Add util to check debugging

* pre-commit

---------

Co-authored-by: iopapamanoglou <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants