Skip to content

modify group_by_class behaviour of get_connected_neurons_by_type#276

Merged
Robbie1977 merged 1 commit into
masterfrom
class-connectivity
May 7, 2026
Merged

modify group_by_class behaviour of get_connected_neurons_by_type#276
Robbie1977 merged 1 commit into
masterfrom
class-connectivity

Conversation

@Clare72
Copy link
Copy Markdown
Contributor

@Clare72 Clare72 commented May 5, 2026

Instances count towards every relevant class-class pair up to the upstream and downstream types specified

@Clare72 Clare72 requested review from Robbie1977 May 6, 2026 12:30
@Robbie1977
Copy link
Copy Markdown
Contributor

@Clare72 are you sure you want the excludeDB behaviour as it is:

Review of PR 276

What changed

  • Only one file is affected: cross_server_tools.py
  • The change is inside VfbConnect.get_connected_neurons_by_type(...)
  • It reworks the group_by_class=True path to fetch individual connections first and then aggregate by ancestor class in Python

Key issues found

  1. exclude_dbs is not applied in the group_by_class=True path

    • The new branch removes the earlier Cypher exclusion filter from the first connection query.
    • Later, it applies exclude_dbs only to the upstream total count query.
    • Result: excluded sources may still contribute to matched connections, causing incorrect results and inconsistent percent_connected.
  2. average_weight uses integer division

    • The new code computes:
      • average_weight: tw // pw if pw else 0
    • The previous Cypher behavior was total_weight/pairwise_connections, i.e. float division.
    • This changes the reported average weight semantics.
  3. Behavior/formatting concerns

    • verbose=True diagnostics use print(...) instead of a logger.
    • from collections import defaultdict is imported inside the method.
    • The method can still return False when no results are returned, which is inconsistent with the normal return types (DataFrame/list).

Other observations

  • The PR adds docstring clarifications for weight and verbose, which is good.
  • The PR file parses cleanly (python3 -m py_compile passed).
  • Existing tests cover group_by_class=True, but do not cover exclude_dbs in that path.

Recommendation

  • Fix exclude_dbs filtering in the group-by-class branch by applying the same exclusion criteria to the initial connection query.
  • Change average_weight to use float division if the intent is to preserve prior semantics.
  • Optionally, replace print debug output with a logging or verbose-controlled logger call.

@Clare72
Copy link
Copy Markdown
Contributor Author

Clare72 commented May 7, 2026

exclude_dbs is not applied in the group_by_class=True path

Not true, the db exclusion is added to the query independently of group_by_class

average_weight uses integer division

total weight and pairwise connections are both integers...

@Robbie1977 Robbie1977 merged commit 7d72ce4 into master May 7, 2026
45 of 49 checks passed
@Clare72 Clare72 deleted the class-connectivity branch May 7, 2026 12:06
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.

2 participants