This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hello_user(name): | |
return f'Welcome {name} and thank you for using our calculator!' | |
def addition(a,b): | |
return a+b | |
def subtraction(a,b): | |
return a-b | |
def division(a,b): | |
return a/b | |
def multiplication(a,b): | |
return a*b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install --upgrade pip | |
pip install upgrade jupyterlab | |
pip install autopep8 | |
pip install --upgrade jupyterlab-git | |
venv_root_dir=${PWD##*/} | |
python -m ipykernel install --user --name=$venv_root_dir | |
pip install ipywidgets | |
jupyter nbextension enable --py widgetsnbextension --sys-prefix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _Segment(Dict, ABC): | |
segment_id: Union[int, str] | |
output_array: np.ndarray | |
doppler_burst: np.ndarray | |
target_type: np.ndarray | |
segment_count: int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create_track_objects(self): | |
df = self.data_df | |
df = self.split_train_val_as_pd(data=df, ratio=self.config.get('valratio', 6)) | |
df.sort_values(by=['track_id', 'segment_id'], inplace=True) | |
df.replace({'animal': 0, 'human': 1}, inplace=True) | |
df['target_type'] = df['target_type'].astype(int) | |
# validating that each track consists of segments with same values in following columns | |
columns_to_check = ['geolocation_type', 'geolocation_id', 'sensor_id', 'snr_type', 'date_index', 'target_type'] | |
# creating boolean matrix for np.select | |
conditions = [(df.groupby('track_id')[col].shift(0) == df.groupby('track_id')[col].shift(1).bfill()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split_Nd_array(array: np.ndarray, nsplits: int) -> List[np.ndarray]: | |
if array.ndim == 1: | |
indices = range(0, len(array) - 31, nsplits) | |
segments = [np.take(array, np.arange(i, i + 32), axis=0).copy() for i in indices] | |
else: | |
indices = range(0, array.shape[1] - 31, nsplits) | |
segments = [np.take(array, np.arange(i, i + 32), axis=1).copy() for i in indices] | |
return segments | |
def create_new_segments_from_splits(segment: _Segment, nsplits: int) -> List[_Segment]: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def segments_generator(self, segment_list: _Segment) -> None: | |
""" | |
Generates original and augmented segments from a track. | |
""" | |
if self.config.get('get_shifts'): | |
segment_list = create_new_segments_from_splits(segment_list, nsplits=self.config['shift_segment']) | |
else: | |
segment_list = create_new_segments_from_splits(segment_list, nsplits=32) | |
if self.config.get('get_vertical_flip'): |