-
Notifications
You must be signed in to change notification settings - Fork 114
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
Incorrect semantics in Platform, TimeSeries, Scenario #113
Comments
Thanks @khaeru for your (as always) very keen observations! Agree with most of them, except for two.
Note that there is a distinction between input data (sets, parameters), raw output (variables and equations) and timeseries in the IAMC format. All of those can be considered "data".
Disagree - cloning within a platform is the most common use case. |
Okay, I'm open to alternate ideas on names. To expand: the confusion arises because there are two things called by the same name: (1) "time series data" in the generic sense, i.e. array data in which one of the dimensions is a time dimension; and then (2) the
That's true. However, if cloning within a platform, I imagine the user will not explicit supply the
|
Copied from #108.
Methods in the wrong place
For a clean class hierarchy, since TimeSeries is the parent of Scenario, then TimeSeries methods and code should not depend on things implemented in Scenario.
Done in Test using in-memory databases and other clean-ups #270.TimeSeries.checkout()
(1) callsScenario.has_solution()
and (2) raises an exception with the text "This Scenario…"—but it is the parent class of Scenario.Fixed with Clone scenario: check and fix (#109) #120.TimeSeries.add_timeseries()
docstring references "MESSAGE-Scheme scenarios".TimeSeries data has a 'year' dimension by default; the existence (or not) of set(s) that correspond to years in a model/Scenario is distinct.TimeSeries.timeseries()
takes kwargsregions
,units
,years
. AFAICT e.g. 'years' is not necessarily a set in an ixmp model; only in MESSAGEix.Pythonic semantics
Platform.scenarios_list()
→list_scenarios()
. Methods should be named "[verb] [noun]"; only attributes/properties should have "[noun]" names.TimeSeries.add_timeseries()
→add_data()
. Repeating the class name is confusing; this makes the user imagine doingts1, ts2 = TimeSeries(), TimeSeries(); ts1.add_timeseries(ts2)
.Scenario.add_set()
is a misnomer: this method "adds elements to an existing set"; it does not "add a new set". On the other hand,Scenario.init_set()
actually "adds a new set" to the Scenario definition. I'd propose:Scenario.add_set()
= add a new set.Scenario.add_set_elements()
= add elements to an existing set.Removed with the implementation of the Backend API.Scenario.item()
,.element()
→ rename to._item()
,._element()
. The docstrings state these are "internal function"s; Python convention is to indicate this with leading_
on the name.Scenario.add_par()
will operate fine if given onlykey
, and notval
. In this case, the values are actually contained inkey
→ rename this argument tokey_or_val
.Ease-of-use:
Done in Ensure Java garbage collection #298.Platform.__del__()
should invokeclose_db()
when necessary.Scenario.clone()
should raise a warning ifplatform==self.platform
; the user might think they are cloning elsewhere, but have made a coding error (see also Document expected usage ofdefault
characteristic of scenarios, especially in use withclone()
#101, Clone across platforms (database instances) not operational #109).Scenario.solve()
: the 'model' keyword is required, but it could be inferred.The text was updated successfully, but these errors were encountered: