Closed drewj-tp closed 1 month ago
I like this idea!
I would be happy with:
assem = r.core[0]
assem.p.where(lambda pd: pd.hasCategory("neutronics"))
The original idea I had something like:
assem.p.where(categories, locations)
# or
assem.p.where(categories, locations, names)
where we just allow people to add (optional/empty) sets/lists of all three. Your idea is more flexible. If the ONLY things people ever used were categories and locations, I think the second version would be better. Less flexible though.
(I'm just a chatting. I'm not planning on dying on any hills today.)
(Pulling a discussion out of https://github.com/terrapower/armi/pull/1877#discussion_r1769233599)
We have a lot of parameters. Not all of them are used in every location. For example, in working on
HexBlock.rotate
, lots of things needs to be rotated. Two cases areParamLocation.CORNERS
)ParamLocation.CHILDREN
)For parameters meeting condition 1, we have
https://github.com/terrapower/armi/blob/3dd2763535f0a5694215a0f1f876db49eea3a11c/armi/reactor/blocks.py#L2041-L2042
ParameterDefinitions.atLocation
involves iterating over all parameters, making an intermediateParameterDefinitionCollection
, extending to it, twice (once for corners, once for edges). And then iterate again over the combined names.In #1877, I added a helper onto
HexBlock
that allowed a pattern likeThis allowed for one iteration over all the parameters and used
filter
to only produce parameters that met the condition.This seems more generally useful so let's add it.
Where?
I don't think it should be added to a composite. Those already have too many methods.
I'm thinking a
ParameterCollection
so you can do something likeThere could be some confusion about
where
needing a condition for the values of the parameter collection, not so much their definitions. The same waynumpy.where
andpandas.where
behave.So maybe a
ParameterDefinitionCollection
? Then you'd need to dothat feels a bit better? Grabbing parameters where their definition meets a certain category. Yeah, I think I like that better