Skip to content

Commit

Permalink
amend
Browse files Browse the repository at this point in the history
  • Loading branch information
vmoens committed Dec 5, 2023
1 parent a1cf922 commit 259b151
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions tensordict/memmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,16 +133,18 @@ def from_tensor(
"""
if isinstance(input, MemoryMappedTensor):
if (
(filename is None and input._filename is None)
or (input._filename is not None and filename is not None and Path(filename).absolute() == Path(input.filename).absolute())
if filename is None or (
input._filename is not None
and filename is not None
and Path(filename).absolute() == Path(input.filename).absolute()
):
# either location was not specified, or memmap is already in the
# correct location, so just return the MemmapTensor unmodified
return input
elif (
not copy_existing
and (input._filename is not None and filename is not None and Path(filename).absolute() != Path(input.filename).absolute())
elif not copy_existing and (
input._filename is not None
and filename is not None
and Path(filename).absolute() != Path(input.filename).absolute()
):
raise RuntimeError(
f"A filename was provided but the tensor already has a file associated "
Expand Down

0 comments on commit 259b151

Please sign in to comment.