def test_last(self): # base functionality arr = [1, 2, 3, 4] got = last(arr) expected = 4 self.assertEqual(got, expected)
def dropLastArray(key: str): parts = key.split('.') # if the last part of the dict path is an element in an array # then just drop that part if re.match(r'\[\d+\]', last(parts)): return '.'.join(parts[:-1]) return '.'.join(parts)
def fillRest(self, value: Any, steps: int): for k in self.run_data: arr = self.run_data[k] l = last(arr) v = value if not np.isscalar(l): v = np.zeros_like(l) v.fill(value) fillRest(arr, v, steps)
def fileName(path): parts = path.split('/') f = last(parts) return f
def fileName(path: str): parts = split(path) f = last(parts) return f