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

Fix ThetaRZGrid ring/pos bug and update ring/pos docs. #205

Merged
merged 5 commits into from
Nov 10, 2020

Conversation

onufer
Copy link
Member

@onufer onufer commented Nov 10, 2020

Update doc strings for getLocatorFromRingAndPos.
When it is hex geometry 0-based indices are not expected.

These are not indexes when in hex:

 @staticmethod
    def _indicesAndEdgeFromRingAndPos(ring, position):
        ring = ring - 1
        pos = position - 1

        if ring == 0:
            if pos != 0:
                raise ValueError(f"Position in center ring must be 1, not {pos}")
            return 0, 0, 0
@onufer onufer requested a review from ntouran November 10, 2020 03:20
@onufer onufer changed the title Update grids.py Update getLocationFromRingAndPos Docs. Nov 10, 2020
@@ -923,9 +923,9 @@ def getLocatorFromRingAndPos(self, ring, pos, k=0):
Parameters
----------
ring : int
Ring index
Ring index (or number starting at 1 for hex)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ring and position are always 1-based

Copy link
Contributor

Choose a reason for hiding this comment

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

...and if this is inconsistent in any geometry, then they are wrong

Copy link
Member Author

Choose a reason for hiding this comment

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

rzTheta seems to be wrong then:

    def getRingPos(self, indices):
        return (indices[1] + 1, indices[0] + 1)

    @staticmethod
    def getIndicesFromRingAndPos(ring, pos):
        return (pos, ring)

We are coding in python, so non-zero based indexing is surprising. Also the argument k is clearly zero based indexing, so I thought it would be helpful to point out that this is 1 based.

It is unclear from your feedback what actions you would like me to take. Can you give me some actionable feedback, or let me know if you are okay with these changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not really sure what you wanted, so I guessed. Let me know if this satisfies your concerns.

Copy link
Contributor

Choose a reason for hiding this comment

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

rzTheta is wrong. 100% agree that ring and position being 1-based is surprising, but it is 1-based. The greater sin is to be inconsistent within ring/pos. Could you fix rzTheta?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought I did.

@@ -1610,7 +1610,7 @@ def getRingPos(self, indices):

@staticmethod
def getIndicesFromRingAndPos(ring, pos):
return (pos, ring)
return (pos - 1, ring - 1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Great, awesome! Thanks!

@onufer onufer changed the title Update getLocationFromRingAndPos Docs. Fix ThetaRZGrid ring/pos bug and update ring/pos docs. Nov 10, 2020
Not implemented for Cartesian-see getRingPos notes.
"""
raise NotImplementedError(
"Cartesian should not need need ring/pos, use x, y coordinates."
Copy link
Contributor

Choose a reason for hiding this comment

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

"use (i, j) indices instead"

Notes
-----
This is needed to support GUI, but should not often be used.
x, y (0-based) indices are much more useful. For example:
Copy link
Contributor

Choose a reason for hiding this comment

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

i, j

This is needed to support GUI, but should not often be used.
x, y (0-based) indices are much more useful. For example:

>>> indices = core.spatialGrid[x, y, 0] # 3rd index is 0 for assembly
Copy link
Contributor

Choose a reason for hiding this comment

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

i, j

>>> indices = core.spatialGrid[x, y, 0] # 3rd index is 0 for assembly
>>> a = core.childrenByLocator[indices]

>>> a = core.childrenByLocator[core.spatialGrid[x, y, 0] # one liner
Copy link
Contributor

Choose a reason for hiding this comment

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

i, j

Copy link
Contributor

Choose a reason for hiding this comment

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

also, missing closing ]

This is needed to support GUI, but should not often be used.
i, j (0-based) indices are much more useful. For example:

>>> indices = core.spatialGrid[i, j, 0] # 3rd index is 0 for assembly
Copy link
Contributor

Choose a reason for hiding this comment

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

locator may be better than indices

Copy link
Member Author

Choose a reason for hiding this comment

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

done. will push when build completes

Copy link
Contributor

@youngmit youngmit left a comment

Choose a reason for hiding this comment

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

consider changing indices -> locator in your example. Indices throughout grids.py mean a tuple of (i, j, k)

Comment on lines 1250 to 1252
( 0, 1) ( 1, 0)
(-1, 1) (0, 0) (1,-1)
(-1, 0) ( 0,-1)
Copy link
Contributor

Choose a reason for hiding this comment

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

dig this!

@onufer onufer merged commit 0117fd0 into master Nov 10, 2020
@onufer onufer deleted the updateRingPositionDocs branch November 10, 2020 22:40
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