Skip to content

Commit

Permalink
Fixes for issues #22 and #23 (#24)
Browse files Browse the repository at this point in the history
* Fix for AxisError with numpy 1.18

FFN fails with
`numpy.AxisError: axis 4 is out of bounds for array of dimension 4`

when numpy 1.18 is used.

See the 1.18 note for numpy.expand_dims at
https://numpy.org/doc/stable/reference/generated/numpy.expand_dims.html
```
axis int or tuple of ints
Position in the expanded axes where the new axis (or axes) is placed.

Deprecated since version 1.13.0: Passing an axis where axis > a.ndim will be treated as axis == a.ndim, and passing axis < -a.ndim - 1 will be treated as axis == 0. This behavior is deprecated.

Changed in version 1.18.0: A tuple of axes is now supported. Out of range axes as described above are now forbidden and raise an AxisError.
```

* Fix import error

Training fails since Optional was not imported
  • Loading branch information
keceli authored Sep 21, 2020
1 parent 7610abe commit e3f9c28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ffn/training/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def _load_from_numpylike(coord, volname):
if data.ndim == 4:
data = np.rollaxis(data, 0, start=4)
else:
data = np.expand_dims(data, 4)
data = np.expand_dims(data, data.ndim)

# Add flat batch dim and return.
data = np.expand_dims(data, 0)
Expand Down
1 change: 1 addition & 0 deletions ffn/utils/bounding_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from . import bounding_box_pb2
from . import geom_utils

from typing import Optional

class BoundingBox(object):
"""BoundingBox built on Numpy, interoperable with bounding_box_pb2."""
Expand Down

0 comments on commit e3f9c28

Please sign in to comment.