Skip to content

yt 4.1.0

Compare
Choose a tag to compare
@neutrinoceros neutrinoceros released this 07 Oct 14:11
· 1418 commits to main since this release
f8efdf6

Summary

This is the first feature release in the yt 4.x series.
It contains about a year of work by many contributors, with many new features and improvements to the code base. It is also the first release to officially support Python 3.11
Some deprecations from yt < 4 are now expired, some minor backwards incompatibilities are expected. Anything broken on purpose in this version should correspond to a warning in yt 4.0.x, anything beyond that should be considered a regression; please report any unexpected breaking change.

How to upgrade

To upgrade from PyPI, run

python -m pip install --upgrade yt

or, with conda

conda update --channel conda-forge yt

Note that binaries for Python 3.11 are only available via pip.

🌟 Highlights

Newly supported data formats

yt 4.1 ships with 3 brand new frontends !

Improved loading for "ambiguous" data formats

yt.load sometimes raises YTAmbiguousDataType when more than one data format appears to be valid. Ideally this should never happen, but in some cases it is very frequent, in particular with BoxLib data, for which we support many hard-to-distinguish flavours.
In order to mitigate this issue, yt.load now accepts a hint keyword argument. For instance

yt.load("det_x_plt00000", hint="castro")

Stretched grid support

yt now has experimental support for "stretched" grid schemes (grids with arbitrarily varying cell width).
It is currently not compatible with AMR.

The following contains a non-exhaustive list of changes

🐛 Bug fixes

#2538 Combining set_zlim and set_unit methods doesn't work as expected (fixed in #3849, by @neutrinoceros )
#3901 Cannot plot data containing both finite and infinite values and use set_zlim (fixed in #3849, by @neutrinoceros)
#3986 Restore and fix flexible linear threshold guessing in symmetric logarithmic plots, by @chrishavlin (issue #3944)
#4021 Fix multiple issues with magnetic field derived fields definitions, by @neutrinoceros
#4075 Fix scaling in off-axis projections of filtered gas particles, by @jzuhone
#4098 Correcting deceptive typo in an error message, by @chummels
#4149 Fix a bug in the computation of metallicity for the generation of X-ray emission fields, by @geoyuqiu

🚀 New features

#3346 Allow to set units from config file, by @cphyc
#3421 Allow stream frontends to accept callables, by @matthewturk
#3443 Directly open compressed files1, by @cphyc
#3640 Add swap_axes, flip_horizontal and flip_vertical plot modifier methods, by @chrishavlin
#3666 Implement hint keyword argument for yt.load to help lifting ambiguities in data formats, by @neutrinoceros (issues #3510 by @mameehan5 and #3005 by @zingale)
#3686 Allow 'factor' argument in plot annotation methods to accept 2-tuples to distinguish x/y resolutions, by @neutrinoceros
#3756 Expose FRB filtering API, by @cphyc and @neutrinoceros
#3812 Allow for different normalizations of magnetic fields in CGS2, by @jzuhone (issue #3471 by @forrestglines)
#3822 Add support for varying colors in quiver annotations, by @neutrinoceros
#3940 Add "min" method to ProjectionPlot, by @rjfarber
#3489 yt.ProjectionPlot can now perform off-axis projections3, by @neutrinoceros (also #3723 and #3737)
#3817 Add support for VelocityCallback and MagFieldCallBack in spherical coordinates, by @neutrinoceros
#3989 Add support for projecting a field's standard deviation, by @jzuhone
#4063 Add data_source argument to covering grid, by @chrishavlin
#4119 Allow passing a dataset as a data source to ParticlePhasePlot, by @neutrinoceros
#4121 Add public API render methods to PlotContainer and FixedResolutionBuffer, by @neutrinoceros
#4142 ENH: add API to switch raytracing engine at runtime, by @neutrinoceros

experimental features

#2567 First cut at showing multiple transfer functions on VR, by @zingale
#2998 Enable variable cell widths for grid datasets #2998, by @matthewturk
#3849 Add ability to use colorbar norms other than linear, log and symlog, by @neutrinoceros (issue #3840)

♻️ Optimisations and refactors

Performance optimisations

#2416 Stop preallocating particles, by @matthewturk and @chrishavlin, issue #2383 by @zhafen
#3439 Cache _determine_fields for a given dataset by @Xarthisius
#3469 Optimise memory layout for particle oct container, by @themousepotato
#4029 Only compute field suggestions if YTFieldNotFound isn't caught, by @neutrinoceros
#3935 Import optional dependencies lazily4, by @neutrinoceros
#4025 Optimise startup time, by @neutrinoceros
#4037 First steps toward utilizing the octree infrastructure as an engine for block-structured data, by @BolunThompson
#4071 Optimise some grid selection operations by skipping unnecessary symbolic unit computations, by @yipihey
#4079 Optimise radius calculation, by @yipihey (+ #4091 by @brittonsmith)

User experience and developer experience improvements

#3065 Make Scene.save less verbose, by @neutrinoceros
#3436 Improve clarity of error message for region slicing with 2D dataset, by @neutrinoceros
#3495 Warn in case a Dataset subclass is redefined, by @neutrinoceros
#3519 Improve user input validation for PLViewerMPL._setup_origin, by @neutrinoceros
#3525 Allow direct dataset instantiation using the user path '~' glyph, consistently with yt.load, by @neutrinoceros
#3527 Improve formatting for YTUnidentifiedDataType exception, by @neutrinoceros
#3621 Improve verbosity of yt.enable_parallelism in case of error, by @neutrinoceros

Quality improvements and refactors

#3526 Particle reader cleanup, by @matthewturk
#3546 Setup basic type checking and fix existing type errors, by @neutrinoceros
#3617 Factorise coordinate handler, by @cphyc
#3624 Factorise code in halo containers, by @cphyc
#3626 Decouple yt.config from initialisation5, by @neutrinoceros
#3772 Avoid storing relative paths in Dataset attributes, by @neutrinoceros
#3920 Improve formatting consistency in YTException error messages, by @neutrinoceros
#3957 Refactor plot callbacks registration, by @neutrinoceros (issue #3945)
#3998 Update to fields used in Enzo answer testing, by @jwise77
#4116 Avoid subclassing builtin dict, by @neutrinoceros
#4057 Cleanup dead attribute Dataset.file_style, by @neutrinoceros
#4125 Stop using deprecated np.int, by @neutrinoceros
#4143 Updating Firefly-dependent areas to match API changes and PyPI packaging, by @mtryan83

📚 Documentation

#3395 and #3412 Avoid using pylab in docs, by @neutrinoceros
#3608 Document how Dataset._is_valid works, by @neutrinoceros (issue #1018 by @ngoldbaum)
#3627 Remove a false statement from yt.funcs.rootonly's docstring, by @neutrinoceros (issue #2054 by @DTHaydon)
#3642 Fix a broken example (change of api in the Athena frontend), by @neutrinoceros (issue #3641)
#3813 Update contribution guidelines, by @neutrinoceros (issue #2554 by @munkm)
#3926 Update broken link to re-licensing blog post, by @tracykteal
#3982 Fix broken annotate_particles example, by @chrishavlin (issue #3968 by @neutrinoceros)
#4080 Document plot callbacks extensibility, by @neutrinoceros (issue #4072)
#4124 Update instructions and redirections for installing cartopy, by @neutrinoceros
#4148 Add more info to magnetic fields documentation, by @jzuhone

🤖 Frontends

Frontend-specific improvements and bug fixes

[AMRVAC]
#3508 Optimise reading speed, by @neutrinoceros

[AREPO]
#3815 Add three new derived fields, by @jzuhone
#3258 New fields for Arepo and Gadget frontends, by @jzuhone
#4120 Add Arepo stellar photometric fields , by @jzuhone

[BoxLib]
#3515 Add a missing close statement, by @mameehan5
#4112 allow reading of 1D particle data, by @dpgrote

[Enzo-E]
#3914 Update Enzo-E particle mass/density distinction, by @brittonsmith
#4097 Store the Enzo-E version number in parameters attribute of EnzoEDataset, by @mabruzzo
#4099 Improved Enzo-E frontend's determination of fluid properties, by @mabruzzo

[Gadget]
#3258 New fields for Arepo and Gadget frontends, by @jzuhone
#3455 Make sure we add the Parameters group to hvals if it's present, by @jzuhone

[GAMER]
#4070 Use lookback time in cosmological simulation, by @koarakawaii

[RAMSES]
#3332 Allow user customization of RAMSES field loading, by @cphyc

💣 Deprecations

Expired deprecations and known-breaking changes

#3240 Deprecation cycle (4.0 -> 4.1), by @neutrinoceros
#3957 Deprecate dict argument plot_args in annotate_* methods where a **kwargs is sufficient, by @neutrinoceros
#3970 Turn ambiguous fields warnings into errors6, by @neutrinoceros (issues #3416, and #3235 by @cphyc)

#4142 changed the default ray tracing engine from "embree" to "yt" (builtin engine). Previous versions of yt would switch to embree at startup if pyembree was installed. This version requires that embree be explicitly required, either with configuration file:

[yt]
ray_tracing_engine = "embree"

or at runtime

from yt.visualization.volume_rendering.api import set_raytracing_engine
set_raytracing_engine("embree")

New deprecations

#3278 Deprecate yt.mods, by @neutrinoceros (issue #3090)
#3418 Deprecate iyt, by @neutrinoceros
#3567 Deprecate annotate_halos7, by @neutrinoceros (issue #3566 by @brittonsmith)
#3773 Deprecate yt.testing.run_nose and wrap it in the yt namespace8, by @neutrinoceros (issue #3771 by @brittonsmith)
#4021 Deprecate some ambiguous field aliases, by @neutrinoceros

Prolonged deprecations

#3836 Complete existing deprecation warnings' metadata, by @neutrinoceros

🧩 Requirements

  • Python 3.7 or newer is now required
  • numpy 1.14.5 or newer is now required
  • matplotlib 3.1 or newer is now required
  • typing-extensions is a new dependency, required only on Python 3.7
  • importlib-metadata is a new dependency, required only on Python 3.7
  • tomli is now only required for Python 3.10 and older

Notes for downstream packagers and developers

We've started adding type hints to yt ! yt now ships a py.typed marker file, enableing type checking code which uses yt as a dependency via mypy. This initiative has a limited scope for now (we're far from having a completely typed code base), and there may be rough edges, feedback from downstream is extremely welcome !

We've also added a yt.version_info named tuple (#3761 by @neutrinoceros). This tuple is analogous to sys.version_info, and can be used to check yt's version at runtime, and write version-dependent code like so

import yt

if yt.version_info >= (4, 1):
    ...
else:
    ...

Of course for now only yt 4.1.0 has this tuple, so it is not going to be useful right away, but you can rely on it when you drop support for versions older than 4.1.0

Previous versions also incorrectly prevented compilation with Python 3.12 and above, this limitation has been lifted.

#3526 by @matthewturk -> Although considered a refactor, this is a breaking change for any third party particle frontends. We do not know of one, please let us know if you're developing such a frontend.

🏅 special thanks to

footnotes

  1. this feature requires ratarmount as an optional dependency to yt, currently only Linux is supported, see #3749

  2. at the moment this is only used in Athena and Athena++ frontends

  3. yt.SlicePlot is now a class (previously it was a function). Instantiating OffAxisProjectionPlot (resp OffAxisSlicePlot) directly is now unnecessary (but still supported)

  4. with the exception of netCDF4, which is still imported at startup time if available

  5. a consequence of this patch is that yt will no longer create configuration files on startup if it can't find one

  6. this is nuanced by #3948 and #3949 (both PRs by @neutrinoceros)

  7. this method is now being defined in the yt_astro_analysis extension package, which was required already, so it should continue to work seamlessly with sufficiently recent versions of the extension

  8. a side effect of this patch is that importing yt doesn't load the yt.testing module by default, this change may break downstream code using yt.testing without an explicit import