Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve #47 #48

Merged
merged 2 commits into from
Feb 5, 2021
Merged

Resolve #47 #48

merged 2 commits into from
Feb 5, 2021

Conversation

carshadi
Copy link
Member

@carshadi carshadi commented Feb 4, 2021

Resolve #47

  • ensure parentStructure attribute is initialized by calling AllenCompartment.getTreePath()
  • fix bug in AllenCompartment.getChildren(final int level)
  • set pre-computed volume for mouse brain root OBJMesh
  • AllenUtils.getOntologies() returns List instead of Collection
  • create tests for AllenCompartment and AllenUtils
  • misc code cleanup

pinging @tferr

- ensure parentStructure attribute is initialized by calling AllenCompartment.getTreePath()
- fix bug in AllenCompartment.getChildren()
- set pre-computed volume for mouse brain root OBJMesh
- AllenUtils.getOntologies() returns List instead of Collection
- create tests for AllenCompartment and AllenUtils
- misc code cleanup
Copy link
Member

@tferr tferr left a comment

Choose a reason for hiding this comment

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

Nice! the tests are going to be super important

@@ -340,7 +336,7 @@ public OBJMesh getMesh() {
*/
@Override
public boolean isParentOf(final BrainAnnotation childCompartment) {
if (childCompartment == null || !(childCompartment instanceof AllenCompartment))
Copy link
Member

@tferr tferr Feb 5, 2021

Choose a reason for hiding this comment

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

@carshadi , won't you get a NPE here if the childCompartment being tested is null? nodes in a reconstruction can be associated with a null compartment, e.g., isParentOf((AllenCompartment)null); Why remove the null check?

Copy link
Member Author

@carshadi carshadi Feb 5, 2021

Choose a reason for hiding this comment

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

IntelliJ suggested that the null check was not necessary, apparently instanceof returns false if the operand is null
https://stackoverflow.com/questions/2950319/is-null-check-needed-before-calling-instanceof

Copy link
Member

Choose a reason for hiding this comment

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

I did not know that! good to know. Oh boy. I should adopt IntelliJ. I have never be warned in Eclipse, and have been doing null checks from day one!

@@ -258,33 +259,29 @@ public AllenCompartment getAncestor(final int level) {
final ArrayList<AllenCompartment> children = new ArrayList<>();
final Collection<AllenCompartment> allCompartments = AllenUtils.getOntologies();
for (AllenCompartment c : allCompartments) {
if (isChildOf(c) && c.getTreePath().size() <= maxLevel)
if (c.isChildOf(this) && c.getTreePath().size() <= maxLevel)
Copy link
Member

Choose a reason for hiding this comment

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

nice! quite embarrassing how this war wrong

@tferr tferr merged commit 48bf974 into master Feb 5, 2021
@carshadi carshadi deleted the 47-allen-fixes branch February 5, 2021 04:59
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.

java.lang.NullPointerException when trying to access AllenUtils.getOntologies().getAncestors()
2 participants