-
Notifications
You must be signed in to change notification settings - Fork 90
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
Clean up asciimaps #436
Comments
@davis8dd think you'd be interested? |
While pondering this problem, it's always wise to click around on this unbelievable hexagon page. They even have an implementation guide in many languages, including python! That said, the basic requirements of this kind of system would be to convert various 2-D geometrical grids to and from a compact ASCII-based representation losslessly, including:
The mapping is preferred to be whitespace delimited but multi-character. We sometimes back things like Note that this messes with brains a bit because while matrix nomenclature usually have an 'origin' at the top left, spatial coordinates usually have the origin in the bottom left. So we have to decide in advance which one we want. In other words, we have to pick a specific mapping style for each and make a diagram describing it. Example:
might lead to {
(0,0): "C",
(0,1): "D",
(1,0): "A",
(1,1): "B"
} or 4 or more other possible mappings. Thus, we should explicitly specify these in advance for each geometry option with a graphical example and then once we all agree on what the mappings should look like, then we can implement. That's effectively what we have done in test_asciimaps.py to a degree but it could be better. |
Question -- I'm considering using dataclasses as an implementation detail (since However, since setup.py says Line 49 in b94744f
So can I assume the user has python |
I think it's a fair assumption that most users have Python 3.7+ internally at TerraPower, but I cannot speak for all external users. Right now the installation docs do state Python 3.6+ even though the setup.py is broken. |
It seems, then, that either release v0.2 should be tested on python 3.6 (since it seems like it currently isn't), or that setup.py and the release doc should be updated to say it requires >=3.7 ? I think dropping python 3.6 support might not be a terrible idea -- if someone is using python 3.6, they could depend on the previous release. Since release v0.2 was only 5 days ago, it seems unlikely that anyone is relying on it yet. This could be a good opportunity to drop python 3.6 support -- otherwise you might have to wait till the next major release to do so :( The reason why I'm hoping that python 3.6 support can be dropped is that, besides dataclasses, python 3.7 also brings types and generics, which would make refactorings and cleanups so much easier. Perhaps some subclasses of |
@john-science - maybe we can hot patch the v0.2 release to enforce 3.7+? I don't see a reason why we need to support 3.6 at this time. |
@jakehader @scottyak My preference is to only support Python 3.7-3.9, as those are really the only versions that we test for seriously. And while I'm generally a fan of supporting a wide breadth of versions for an importable library... I don't know, I think for a scientific modeling framework I'm more in favor of constraining the versions to be better tested. Let me ask around, and see if anyone depends on 3.6. |
@jakehader @scottyak It looks like no one is using Python 3.6 anyway. Nick is hesitant to drop support for 3.10, so I think saying we support Python 3.7+ is a pretty safe bet for everyone. |
@sdow1ll Is taking this ticket! Thanks Silba! (I just assigned it to myself so no one else would grab it.) |
Sorry for leaving this one assigned for so long! |
Hi @john-science I have a working Jupyter Notebook of the asciimaps.py file that basically has the converted functions from the asciimap class, but one thing that I got stuck on was that I noticed at the end of the asciimaps.py file, there is a code block of the following: def asciiMapFromGeomAndSym(geomType: str, symmetry: str):
"""Get a ascii map class from a geometry type."""
from armi.reactor import geometry
MAP_FROM_GEOM = {
(geometry.HEX, geometry.THIRD_CORE): AsciiMapHexThird,
(geometry.HEX, geometry.FULL_CORE): AsciiMapHexFullTipsUp,
(geometry.CARTESIAN, None): AsciiMapCartesian,
(geometry.CARTESIAN, geometry.FULL_CORE): AsciiMapCartesian,
}
return MAP_FROM_GEOM[(geomType, symmetry)] Is this something that I should try to edit as well? When looking at this, I notice that the MAP_FROM_GEOM dictionary relies on the original classes. Are the functions I wrote basically an additional feature to this file, and that I should not touch the following code block above? |
The only two references to that function are here: armi/armi/reactor/blueprints/gridBlueprint.py Line 410 in 6a546dd
armi/armi/reactor/blueprints/gridBlueprint.py Line 567 in 6a546dd
So, refactoring those two use-cases will be necessary to do your refactoring of the asciimaps utils. (Sorry for the long delay.) |
The functionality in utils/asciimaps.py has been pretty brittle, and difficult to extend and debug, and frankly pretty error prone to use. We've been talking for a while about perhaps taking another stab at the problem, so I am making this ticket to get it out there as a thing to do. I think a lot of the complexity stems from modelling the problem with a bunch of classes, which have pretty abstract state that needs to be ushered through a handful of methods that are subclassed in pretty nuanced and difficult to understand ways. I think the problem of mapping from a structured text grid to a dictionary of i,j indices -> specifier would better be suited to straight-up functions (e.g.,
fullHexFlatsUpToAscii(d)
and its inversefullHexFlatsUpToDict(text)
. We can still provide a sort of pseudo-factory, which returns the appropriate functions given a provided geom and symmetry condition. If whoever tackles this feels like the use of some private classes would ease implementation of these functions, they are more than welcome to do so, or even try using the classes that we already have to get a fist-cut implementation of the functional interface, but I suspect that the class approach is more complicated than it needs to be.In summary:
The text was updated successfully, but these errors were encountered: