What’s new#
Next release#
Improve
Computer.visualize()
; see the example usage and output (PR #92).
v1.17.1 (2023-05-30)#
Adjust for changed exception types in Pint 0.22 (PR #90).
v1.17.0 (2023-05-15)#
Bug fix: genno v1.16.1 (PR #85) introduced
ValueError
for some usages ofcomputations.sum()
(PR #88).Provide typed signatures for
Quantity.bfill()
,cumprod()
,ffill()
for the benefit of downstream applications (PR #88).Ensure and test that
Quantity.name
andunits
pass through allcomputations
, in particularaggregate()
,convert_units()
, andsum()
(PR #88).Simplify arithmetic operations (
div()
,mul()
,pow()
) so they are agnostic as to theQuantity
class in use (PR #88).Ensure
AttrSeries.index
is alwayspandas.MultiIndex
(PR #88).
v1.16.1 (2023-05-13)#
Bug fix:
select()
raisedKeyError
if the indexers contained values not appearing in the coords of theQuantity
(PR #85). This occurred with pandas 2.x, but not with earlier versions. The documentation now states explicitly that extraneous values are silently ignored.All
computations
are type hinted for the benefit of downstream code (PR #85).Implement
AttrSeries.shape
(PR #85).Bug fix:
Computer.add()
now correctly handles positional-only keyword arguments to computations that specify these (PR #85).
v1.16.0 (2023-04-29)#
genno supports and is tested on Python 3.11 (PR #83).
Update dependencies (PR #83):
General:
importlib_resources
(the independent backport ofimportlib.resources
) is added for Python 3.9 and earlier.genno[sparse]
: new set of optional dependencies, includingsparse
. Install this set in order to useSparseDataArray
forQuantity
.Note that sparse depends on
numba
, and thusllvmlite
, and both of these package can lag new Python versions by several months. For example, as of this release, they do not yet support Python 3.11, and thussparse
andgenno.SparseDataArray
can only be used with Python 3.10 and earlier.genno[tests]
:ixmp
is removed;jupyter
andnbclient
are added. Testing utilities ingenno.testing.jupyter
are duplicated fromixmp.testing.jupyter
.
Adjust
AttrSeries.interp()
for compatibility with pandas 2.0.0 (released 2023-04-03) (PR #81).
v1.15.0 (2023-04-02)#
dask.core.quote()
is now re-exported bygenno
for convenience (PR #79):from genno import quote
Add new computations
drop_vars()
,round()
(PR #79).Improve existing computation
div()
to accept a scalar numerator. (PR #79):Improve
AttrSeries
(PR #79):Handle
dim=None
incumprod()
.Handle 1-D quantities in
shift()
.Preserve
AttrSeries.name
in more operations.
Computer.configure()
can accept adict
instead of keyword arguments (PR #79).Adjust for compatibility with pyam 1.7 (released 2022-12-19) (PR #78).
v1.14.1 (2022-10-28)#
Fix
cumprod()
for 1-dimensionalAttrSeries
(PR #74).Adjust for compatibility with pint 0.20 (released 2022-10-25) (PR #74).
v1.14.0 (2022-09-27)#
Add new computations
assign_units()
andconvert_units()
. These have simpler behaviour thanapply_units()
and should be preferred in most situations (PR #72).Following pandas (v1.4.0, released 2022-01-22) and xarray (v0.21.0, released 2022-01-27), support for Python 3.7 is dropped (PR #72). genno supports and is tested on Python 3.8 and newer.
v1.13.0 (2022-08-17)#
1-dimensional quantities are handled in
relabel()
and as weights insum()
(PR #68).load_file()
will read a header comment like# Units: kg / s
and apply the indicated units to the resulting quantity (PR #68).div()
andmul()
become the canonical names, matchingoperator
and other parts of the Python standard library (PR #68).ratio()
andproduct()
are retained as aliases, for compatibility.Ensure data passed to
Plot.generate()
has a “value” column; use short units format by default (PR #68).
v1.12.0 (2022-07-18)#
New computation
index_to()
(PR #65).general: configuration items are more flexible (PR #65).
comp: null
or omitted allows to specify a simple collection of other computations.A bare string
key:
is left as-is; only keys with (a) dimension(s) and/or tag are parsed toKey
.
Bug fix:
Computer.convert_pyam()
handles its tag argument correctly, generating keys likefoo:x-y-z:iamc
orbar::iamc
when applied to existing keys likefoo:x-y-z
orbar
(PR #65). Previously the generated keys would be e.g.bar:iamc
, which incorrectly treats “iamc” as a (sole) dimension rather than a tag.Computer.require_compat()
can handle arbitrary module names as strings, as well as module objects (PR #63).
v1.11.0 (2022-04-20)#
Migration notes#
The index keyword argument to Computer.add_single()
/ add()
is deprecated (PR #60) and will be removed in or after v3.0.0.
Indexing behaviour changes slightly: Computer.full_key()
always returns the Key
which matches its arguments and has the greatest number of dimensions.
For instance:
c.add_product("foo", "bar:a-b-c", "baz:x-y-z", sums=True)
…will generate a key <foo:a-b-c-x-y-z>
and all partial sums over subsets of its dimensions; c.full_key("foo")
will return this key.
Care should be taken to avoid adding 2+ keys with the same name, tag, and number of dimensions:
c.add("foo:a-b-c", ...)
c.add("foo:l-m-n", ...)
c.add("foo:x-y-z", ...)
This situation is ambiguous and the behaviour of Computer.full_key()
is undefined.
Instead, add a tag
to disambiguate.
All changes#
Key.product()
acceptsstr
arguments (PR #60).New class method
Key.bare_name()
(PR #60).Infer dimensions for e.g.
X:*:tag
in general: configuration items (PR #60).Handle the fail argument to
Computer.aggregate()
through aggregate: configuration items (PR #60).New computations
relabel()
andrename_dims()
(PR #60).Improve perfomance for adding large number of computations to
Computer
(PR #60).
v1.10.0 (2022-03-31)#
Add
testing.assert_units()
(PR #58).
v1.9.2 (2022-03-03)#
Silence
collect_units()
when units are explicitly “”, rather thanNone
(PR #56).Add explicit implementations of
__radd__()
,__rmul__()
,__rsub__()
and__rtruediv__()
for e.g.4.2 * Quantity(...)
(PR #55)Improve typing of
Quantity.shift()
(PR #55)
v1.9.1 (2022-01-27)#
Note that installing genno[pyam]
(including via genno[compat]
) currently forces the installation of an old version of pint
; version 0.17 or earlier.
Users wishing to use genno.compat.pyam
should first install genno[pyam]
, then pip install --upgrade pint
to restore a recent version of pint (0.18 or newer) that is usable with genno.
v1.9.0 (2021-11-23)#
Fix error messages raised by
AttrSeries.sel()
on incorrect usage (PR #52).genno
no longer supports Python 3.6 or earlier, followingxarray
(PR #52).
v1.8.1 (2021-07-27)#
Bug fixes#
v1.8.0 (2021-07-27)#
Improve caching (PR #50):
Handle a lambda functions in
cache()
-decorated code.Add
Encoder.register()
andEncoder.ignore()
for downstream code to extend hashing of function arguments into cache keys.Expand docs.
v1.7.0 (2021-07-22)#
Add
computations.interpolate()
and supportingAttrSeries.interp()
(PR #48). This code works around issues pandas#25460 and pandas#31949.Computer.cache()
now also invalidates cache if the compiled bytecode of the decorated function changes (PR #48).Separate and expand docs of Caching to show how to check modification time and/or contents of files (#49, PR #48).
Add
Quantity.units
attribute for access to units (PR #48).AttrSeries.dims
andAttrSeries.coords
behave likeDataArray
for 1-D quantities (PR #48)
v1.6.0 (2021-07-07)#
v1.5.2 (2021-07-06)#
v1.5.1 (2021-07-01)#
Bug fix:
infer_keys()
raisesAttributeError
under some circumstances (PR #45).
v1.5.0 (2021-06-27)#
Adjust
test_assign_coords()
for xarray 0.18.2 (PR #43).Make
Key.dims
order-insensitive so thatKey("foo", "ab") == Key("foo", "ba")
(PR #42); make corresponding changes toComputer
(PR #44).Fix “
AttributeError
: ‘COO’ object has no attribute ‘item’” onSparseDataArray.item()
(PR #41).
v1.4.0 (2021-04-26)#
plotnine.Plot.save()
automatically converts inputs (specified withPlot.inputs
) fromQuantity
toDataFrame
, but others (e.g. basic Python types) are passed through unchanged (PR #40).plotnine.Plot.save()
generates no output file ifgenerate()
returnsNone
/emptylist
.Quote
dict
argument toComputer.aggregrate()
(for grouped aggregation) to avoid collisions between its contents and other graph keys.
v1.3.0 (2021-03-22)#
Bump minimum version of
sparse
from 0.10 to 0.12 and adjust to changes in this version (PR #39)Remove
SparseDataArray.equals()
, obviated by improvements insparse
.
Improve
AttrSeries
(PR #39)Implement
drop_vars()
andexpand_dims()
.assign_coords()
can relabel an entire dimension.sel()
can acceptDataArray
indexers and rename/combine dimensions.
v1.2.1 (2021-03-08)#
Bug fix: Provide abstract
Quantity.to_series
method for type checking in packages that depend ongenno
.
v1.2.0 (2021-03-08)#
Quantity
becomes an actual class, rather than a factory function;AttrSeries
andSparseDataArray
are subclasses (PR #37).AttrSeries
gains methodsbfill()
,cumprod()
,ffill()
, andshift()
(PR #37)computations.load_file()
uses the skipinitialspace parameter topandas.read_csv()
; extra dimensions not mentioned in the dims parameter are preserved (PR #37).AttrSeries.sel()
acceptsxarray.DataArray
for xarray-style indexing (PR #37).
v1.1.1 (2021-02-22)#
Bug fix:
Computer.add_single()
incorrectly callscheck_keys()
on iterables (e.g.pandas.DataFrame
) that are not computations (PR #36).
v1.1.0 (2021-02-16)#
computations.add()
transforms compatible units, and raises an exception for incompatible units (PR #31).Improve handling of scalar quantities (PR #31).
Plot
is fault-tolerant: if any of the input quantities are missing, it becomes a no-op (PR #31).Computer.configure()
accepts a fail argument, allowing partial handling of configuration data/files, with errors logged but not raised (PR #31).New
computations.pow()
(PR #31).
v1.0.0 (2021-02-13)#
Adjust for usage by
ixmp.reporting
andmessage_ix.reporting
(PR #28):Reduce minimum Python version to 3.6. This is lower than the minimum version for xarray (3.7), but matches ixmp, etc.
Remove
compat.ixmp
; this code has been moved toixmp.reporting
, replacing what was there. Likewise, removecompat.message_ix
.Simplify the form & parsing of
iamc:
section entries in configuration files:Remove unused feature to add
group_sum()
to the chain of tasks.Keys now conform more closely to the arguments of
Computer.convert_pyam()
.
Move argument-checking from
as_pyam()
toconvert_pyam()
.- Simplify semantics of
genno.config.handles()
decorator. Remove
CALLBACKS
feature, for now.
- Simplify semantics of
Computer.get_comp()
andrequire_compat()
are now public methods.Expand tests.
Protect
Computer
configuration fromdask.optimization.cull()
; this prevents infinite recursion if the configuration contains strings matching keys in the graph. Addunquote()
(#25, PR #26).Simplify
collect_units()
and improve unit handling inratio()
(#25, PR #26).Add file-based caching via
Computer.cache()
andgenno.caching
(#20, PR #24).
v0.4.0 and earlier#
v0.4.0 (2021-02-07)#
Add file-based configuration in
genno.config
and associated documentation (#8, PR #16).
v0.3.0 (2021-02-05)#
Add Plotnine (compat.plotnine) compatibility (PR #15).
Add a Concepts and usage overview to the documentation (PR #13).
v0.2.0 (2021-01-18)#
Increase test coverage to 100% (PR #12).
Port code from
message_ix.reporting
(PR #11).Add
compat.pyam
.Add a name parameter to
load_file()
.
v0.1.0 (2021-01-10)#
Initial code port from
ixmp.reporting
.