Skip to content
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

Overload "equivalent" units methods to return info if required #548

Open
kerimoyle opened this issue Feb 20, 2020 · 9 comments
Open

Overload "equivalent" units methods to return info if required #548

kerimoyle opened this issue Feb 20, 2020 · 9 comments

Comments

@kerimoyle
Copy link
Contributor

Currently we only return true/false from the Units::equivalent family of methods. I think it would be really useful to overload these to return the error message via the argument list so that people can import units and test them for equivalence without having to first create a model, assign connected variables etc etc just in order to get the mismatch information message. Thoughts?

@agarny
Copy link
Contributor

agarny commented Feb 20, 2020

I guess it could be useful to some, so sure.

@hsorby
Copy link
Contributor

hsorby commented Feb 20, 2020

I think it would be more in keeping with the way things are working to have a tool that reported on the equivalence of two units, without recourse to using a model.

@agarny
Copy link
Contributor

agarny commented Feb 20, 2020

What do you mean by tool?

@kerimoyle
Copy link
Contributor Author

Here's what I'm imagining:

bool Units::equivalent(const UnitsPtr &units1, const UnitsPtr &units2) {
// current function
}

bool Units::equivalent(const UnitsPtr &units1, const UnitsPtr &units2, std::string &hints) {
// current functionality but also returns the hints string (as from the validator) so the user can 
// access it without needing the model and validator ... 
}

@hsorby
Copy link
Contributor

hsorby commented Feb 20, 2020

A class like the Validator that will perform some function.

@kerimoyle
Copy link
Contributor Author

I guess this is related to our phone conversation @hsorby ? A more generic Checker/Debugger/Helper/Validator class that would test things as needed, with strict validation against the specification as a subset of its functionality. Have you dreamt up a name for it yet, or are you happy to leave it as Validator?

@kerimoyle
Copy link
Contributor Author

Hmm ... would the current Units::equivalent(...) function move to be Validator::unitsAreEquivalent() ? or would we rather keep two very similar functions in two different classes?

@hsorby
Copy link
Contributor

hsorby commented Feb 20, 2020

I'm definitely not happy to leave it as Validator for me that is the name of the tool that validates against the CellML 2.0 specification. Other tools need their own names.

@hsorby
Copy link
Contributor

hsorby commented Feb 20, 2020

No I don't have a good name for such a tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants