Skip to content

Commit

Permalink
Reimplement ArchiveBase using ArrayStore (#399)
Browse files Browse the repository at this point in the history
## Description

<!-- Provide a brief description of the PR's purpose here. -->

This PR refactors the ArchiveBase to place data in ArrayStore rather
than in separate NumPy arrays. This should make the archive more
flexible and easier to extend in the future.

While flexibility is the end goal, note that this PR is only a refactor;
thus, no API changes are being made. As a result, tests will mostly
remain the same.

The exception is the creation of a private `ribs.archives._transforms`
module, for which we do introduce new tests. This module should be
considered unstable for now, but once it seems more stable, we can make
it public.

## TODO

<!-- Notable points that this PR has either accomplished or will
accomplish. -->

- [x] Modify ArchiveBase
- [x] Update SlidingBoundariesArchive
- [x] Create private transforms module
- [x] Test transforms
- [x] Fix ArchiveBase tests where appropriate

## Questions

<!-- Any concerns or points of confusion? -->

## Status

- [x] I have read the guidelines in

[CONTRIBUTING.md](https://github.com/icaros-usc/pyribs/blob/master/CONTRIBUTING.md)
- [x] I have formatted my code using `yapf`
- [x] I have tested my code by running `pytest`
- [x] I have linted my code with `pylint`
- [x] I have added a one-line description of my change to the changelog
in
      `HISTORY.md`
- [x] This PR is ready to go
  • Loading branch information
btjanaka authored Nov 7, 2023
1 parent 57a54bf commit cc7051c
Show file tree
Hide file tree
Showing 8 changed files with 569 additions and 595 deletions.
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#### Improvements

- Reimplement ArchiveBase using ArrayStore ({pr}`399`)
- Use chunk computation in CVT brute force calculation to reduce memory usage
({pr}`394`)
- Test pyribs installation in tutorials ({pr}`384`)
Expand Down
21 changes: 21 additions & 0 deletions ribs/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@
import numpy as np


def parse_float_dtype(dtype):
"""Parses a floating point dtype.
Returns:
np.float32 or np.float64
Raises:
ValueError: There is an error in the bounds configuration.
"""
# First convert str dtype's to np.dtype.
if isinstance(dtype, str):
dtype = np.dtype(dtype)

# np.dtype is not np.float32 or np.float64, but it compares equal.
if dtype == np.float32:
return np.float32
if dtype == np.float64:
return np.float64

raise ValueError("Unsupported dtype. Must be np.float32 or np.float64")


def check_finite(x, name):
"""Checks that x is finite (i.e. not infinity or NaN).
Expand Down
Loading

0 comments on commit cc7051c

Please sign in to comment.