Skip to content

Commit

Permalink
Merge pull request #182 from MarkBlyth/develop
Browse files Browse the repository at this point in the history
Allow square-brackets access to dataset objects
  • Loading branch information
BradyPlanden authored Feb 19, 2024
2 parents e9fb74c + b459cec commit b625ae3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@

## Bug Fixes

- [#182](https://github.com/pybop-team/PyBOP/pull/182) - Allow square-brackets indexing of Dataset

# [v23.11](https://github.com/pybop-team/PyBOP/releases/tag/v23.11)
- Initial release
- Adds Pints, NLOpt, and SciPy optimisers
Expand Down
3 changes: 3 additions & 0 deletions pybop/_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def __init__(self, data_dictionary):
self.data = data_dictionary
self.names = self.data.keys()

def __getitem__(self, key):
return self.data[key]

def __repr__(self):
"""
Return a string representation of the Dataset instance.
Expand Down
1 change: 1 addition & 0 deletions tests/unit/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def test_dataset(self):

# Test data structure
assert dataset.data == data_dictionary
assert np.all(dataset["Time [s]"] == solution["Time [s]"].data)

# Test exception for non-dictionary inputs
with pytest.raises(ValueError):
Expand Down

0 comments on commit b625ae3

Please sign in to comment.