Repository navigation
Conversation
…F5 I/O Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe your changes
gala.potential.potential.io.load()andOrbit.from_hdf5()previously parsed YAML withyaml.load(..., Loader=yaml.Loader), which constructs arbitrary Python objects from!!python/object/apply,!!python/object/new, and!!python/nametags.save()andOrbit.to_hdf5()also usedyaml.dump(...).Who hits this:
galausers loading.ymlpotential definitions or.hdf5orbit files shared from external sources viagala.potential.load(...)orOrbit.from_hdf5(...)(#687).Changes:
src/gala/potential/potential/io.py&src/gala/dynamics/orbit.py:load()(both path and file-like branches) andOrbit.from_hdf5()fromyaml.load(..., Loader=yaml.Loader)toyaml.safe_load(...).save()andOrbit.to_hdf5()fromyaml.dump(...)toyaml.safe_dump(...)._to_plain_str()and_to_yaml_safe()inio.pysoto_dict()emits plain YAML-safe Python types (handlingnumpy.str_catalog labels, NumPy scalars/arrays, tuples,OrderedDict, and(str, Enum)component names without calling overridden__str__), raisesValueErrorloudly if two distinct keys collapse to the same normalized name instead of silently overwriting a component, and still fails fast on unexpectedQuantityobjects rather than stripping units.tests/potential/potential/lm10.yml&tests/potential/potential/ccomposite.yml:!!python/object/apply:collections.OrderedDicttags in these two fixtures to plain YAML mappings matching currentsave()output (a loader-only swap breakstest_read_lm10). Note: pre-2020OrderedDict-tagged YAML files are intentionally no longer accepted byyaml.safe_load.tests/potential/potential/test_io.py&tests/dynamics/test_orbit.py:ConstructorErrorrejection of!!python/object/apply,!!python/object/new, and!!python/nametags acrossload(path),load(StringIO), andOrbit.from_hdf5(), plus round-trip and collision-guard tests forMilkyWayPotential,CompositePotential,CCompositePotential,np.str_/(str, Enum)/str-subclass component names, andOrbitHDF5 I/O.Verification:
lm10.ymlloads anLM10Potentialwith identical class, component order, all 11 parameter values and units, energies, and gradients asmain.1,277 passedvs1,244onmain,+33new tests,0regressions) along withruff checkandruff format --check.SafeLoaderrejection,lm10.ymlfidelity, round-trip/collision guards, and full test suite before this PR.Fixes #687
Checklist
CHANGES.rst)🤖 Generated with Claude Code
https://claude.ai/code/session_01LKxc9GKLwnyeV2jaZBxH9N