-
Notifications
You must be signed in to change notification settings - Fork 51
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
[ENH] refactor datatypes
mtypes - checkers, converters
#392
Conversation
Question : does that mean something like |
Yes.
The intuition is that conversions are indexed by ordered pairs of mtypes, and extensibility. "ordered pairs" If you want to put the conversions into classes, you have two "reasonable" options that I can see:
The first choice has some odd implications, e.g., do you put it in the "from" or "to" class? You also suddenly end up coupling dependencies, e.g., where do you put ta conversion between mtypes with two different soft dependencies? You now have code that uses soft dependency 2 in a class that has main soft dependency 1, etc. Sounds unpleasant and difficult to maintain to me. "extensibility" Not all conversions are directly implemented, as they grow combinatorially and "exotic" data types are rarely converted to each other. Sometimes developers add direct conversions without modifying the original mtypes. If a conversion is its own class, it is possible to add this without modifying anything else - like with the estimator classes, a new class is added, no class or register is modified. But, please let me know if you have pertinent ideas, or see designs that I haven't. |
Right - so if each conversion is its own class, i.e from Follow up question: could you give an example of how a |
As a follow up point, I looked at some of So as part of the I'll edit the design doc to highlight that soon |
fully worked examples can be found in sktime/sktime#6033 |
datatypes
mtypesdatatypes
mtypes - checkers
FYI @julian-fong, this should be ready now |
datatypes
mtypes - checkersdatatypes
mtypes - checkers, converters
@julian-fong, the design for converters is implemented - and two classes, one which contains a single conversion, and one which contains multiple. Review appreciated, before moving to translating the entire module. |
Failure is due to inconsistent handling of soft dependencies in checkers and converter dictionaries - this needs to be looked at, likely arising from the |
any idea why this is failing on 3.12? |
i checked the soft deps for 3.12[all-extras] i think its because |
self_params = self.get_params() | ||
|
||
need_check = [k for k in self_params if self_params[k] is not None] | ||
self_dict = {k: self_params[k] for k in need_check} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick question - what is this code used for exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's a feature, where you instantiate the type with arguments. This defines a subtype, e.g., "numpy 2D without nans", and then checks against the subtype, rather than just the overall type.
Would we need extension templates for users to contribute new |
Yes, of course! Once the design is final, I'd say. Also, in the final verison we should add precise specifications for each mtype in the docstring, and list them on an API reference page. |
Maybe we should include what types of specifications needs to be written for each mtype in a separate issue, along with any other new information that could be written inside the documentation of |
agree! do you want to open it? |
This PR refactors the data type specifications and converters to classes.
Implements sktime/sktime#3512, related to sktime/sktime#2957.
Contains:
BaseDatatype
, to replace the more ad-hoc dictionary designTable
mtype submodule to this interfaceBaseConverter
, also replacing a dictionary based designTable
related converters to this interfacecheck
andconvert
logic, indatatypes
, to allow extensibility with this designPartial mirror in
skpro
of sktime/sktime#6033