-
Notifications
You must be signed in to change notification settings - Fork 14
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
Proposal: Map
object
#282
Comments
I like the idea of having "limited scope, defined content" objects that can be used to simplify the maintenance of certain code. Big picture, I think something like My main design concern is with regard to subclassing
This could look something like this, and we can also provide : class Map:
millers : n x 3 np array
amplitudes : n np array
phases : n np array
uncertainties : None or n np array
cell : gemmi.UnitCell
spacegroup : gemmi.SpaceGroup
...
class Map:
_dataset : rs.DataSet
...
def getters/setters
... I think these sorts of implementations will be easier to maintain than starting with a general-purpose object and restricting its use. I'm not sure of all the intended uses (and I haven't yet dug into much of the |
Jack is correct in that it is much easier to maintain classes that have a Now the question becomes whether the overhead from subclassing is worth it in this case. I can't quite answer that without knowing more about the use cases for
|
Hi guys, First, some examples of why this is useful. Just check out these clean call signatures, which don't need to refer to any column labels: If you check out those functions, you can see the I think @JBGreisman has convinced me to give a "non-inheriting" implementation a go, where I'd just store the underlying My plan is to experiment with that, perhaps with the code in |
In
meteor
, we found it very useful to implement aMap
class. I actually tried to avoid doing this, but eventually found it necessary to keep the rest of the code clean/sane. Otherwise, you start to pass around a huge number of column labels, and the entire thing becomes a crazy bookkeeping exercise.We have an implementation that should be considered a functional prototype, not a final version:
https://github.com/rs-station/meteor/blob/main/meteor/rsmap.py
The current implementation has a good interface, but the implementation is sub-optimal. It is basically a subclass of
rs.DataSet
that restricts the columns, only allowing amplitudes, phases, uncertainties, and H/K/L. This has a big downside in that it can affect inheritedpandas.DataFrame
orrs.DataSet
methods in unexpected ways, making for a less than ideal user and developer experience.That said, such a class could be generally useful to
rs
users, so it would be great to push a better version of this "upstream" intors
, and havemeteor
simply use that implementation.what is a
Map
?We can conceptualize it as a special case of an
rs.DataSet
, where you flag specific columns as:And you can only have ONE of each of these special columns. This opens up a lot of nice logic: converting to real space and back, comparing two map objects (think of a scaling function:
scale(map1, map2)
), etc. The simple big feature is that by declaring which columns are amplitudes/phases at the time of instantiation, you get around having to keep track of column label names.what decisions do we face?
First, feedback would be appreciated as to if we want to implement a
Map
object inrs
. I am a yes vote on this. But obviously we need some consensus before proceeding.If we decide to do it, we need to decide on a general implementation strategy. Here are the possibilities as I see them -- if I didn't have the imagination to come up with a good option, please speak up!
rs.DataSet
and simply annotate what columns are amplitudes, phases, uncertainties. Place dtype requirements on these columns. The instance, though, can have other, unrelated columns (this differs from current implementation). This is probably the simplest model to implement.rs.DataSet
, be strict about what columns are allowed. Aggressively test inherited methods to ensure they work.These appear in my order of preference. Each model has advantages and disadvantages, though. Feedback wanted.
@JBGreisman @kmdalton @alisiafadini
The text was updated successfully, but these errors were encountered: