You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To better improve the design and checks for the higher-level classes, specifically the Converter class, would like to explore the idea of a Function class that acts like a factory.
The idea of the class would be something like:
sq=Function(x, y, error=e, "S(Q)") # x,y,e are the Q, S(Q), and E[S(Q)], respectivelydcs=sq.to_DCS()
gr=sq.to_GofR(r) # r is the real space domain
Yet, the initial issue I see is that this requires both the capabilities of the Converter and Transformer into one class.
The text was updated successfully, but these errors were encountered:
I think a better approach will be to do a modified Translator pattern mixed with borrowing from ASE's functional approach to I/O.
I would like to have a high-level function convert instead of a class of functions (i.e. Converter).
An example would be:
importnumpyasnpfrompystogimportconvertq=np.arange(0., 10.0, 0.1)
sq=np.random.rand(100)
q, dcs=convert(q, sq, from="S(Q)", to="DCS(Q)")
Behind the scenes, the from and to arguments would belong to dictionaries for the different function types.
Something similar in ASE is the define_io_format that maps strings to module names. (this fills in the ioformats dictionary in ASE)
Each module of ours will be real functions with to_gofr and from_gofr function and reciprocal functions with to_sofq and from_sofq (similarly to the read_* and write_* functions in ASE; see xyz example)
Based on the from and to we can:
Figure out if they exist in the real space or reciprocal space dictionary of patterns supported
Make sure they come from the same dictionary / function space
Get the module to load for the from conversion to either G(r) (to_gofr function) or S(Q) (to_sofq function)
Get the module to load for the to conversion from either G(r) (from_gofr function) or S(Q) (from_sofq function)
All the files under the functions directory are the top-level G(r) and S(Q) followed by real and reciprocal space sub sets that hold these from_* and to_*.
Thus, we have a translator pattern using G(R) and S(Q) as our "common objects"
To better improve the design and checks for the higher-level classes, specifically the
Converter
class, would like to explore the idea of aFunction
class that acts like a factory.The idea of the class would be something like:
Yet, the initial issue I see is that this requires both the capabilities of the
Converter
andTransformer
into one class.The text was updated successfully, but these errors were encountered: