Skip to content

Commit

Permalink
Autodetermine Temporal position when calling .temporal()
Browse files Browse the repository at this point in the history
  • Loading branch information
ragier committed Nov 17, 2022
1 parent fd8e8c9 commit 036c689
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions aloscene/tensors/spatial_augmented_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,14 @@ def relative_to_absolute(self, x, dim, assert_integer=False):
assert x.is_integer(), f"relative coordinates {x} have produced non-integer absolute coordinates"
return round(x)

def temporal(self, dim=0):
def temporal(self, dim=None):
"""Add a temporal dimension on the tensor
Parameters
----------
dim : int
The dim on which to add the temporal dimension. Can be 0 or 1
dim : int or None
The dim on which to add the temporal dimension. Can be 0 or 1 or None.
None automatically determine position of T dim in respect of convention.
Returns
-------
Expand All @@ -222,6 +223,16 @@ def temporal(self, dim=0):
if "T" in self.names: # Already a temporal frame
return self

if dim is None:
if self.names[0] == "B":
dim = 1
elif "B" in self.names:
raise Exception(
"Cannot autodetermine temporal dimension position : tensor doesn't follow convention (B, T, ...) )"
)
else:
dim = 0

def set_n_names(names):
pass

Expand Down

0 comments on commit 036c689

Please sign in to comment.