MCPcopy Create free account
hub / github.com/bsomps/OpenGeoPlotter / select_isolate

Method select_isolate

OGP_v11.py:1164–1216  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1162 self.plot() # Replot with contours
1163
1164 def select_isolate(self):
1165 # Use the currently active attribute column
1166 active_column = self.attribute_column
1167
1168 # Create a custom dialog
1169 dialog = QDialog(self)
1170 dialog.setWindowTitle("Data Isolate")
1171 layout = QVBoxLayout(dialog)
1172
1173 # Determine if the column is numerical or categorical and add appropriate widgets
1174 if pd.api.types.is_numeric_dtype(self.data[active_column]):
1175 # Display a label for numerical data
1176 range_label = QLabel("Select Data Range to Isolate")
1177 layout.addWidget(range_label)
1178
1179 # If column is numerical, add range selectors
1180 min_value = self.data[active_column].min()
1181 max_value = self.data[active_column].max()
1182 self.min_range_input = QLineEdit(dialog)
1183 self.min_range_input.setPlaceholderText(f"Min ({min_value})")
1184 layout.addWidget(self.min_range_input)
1185
1186 self.max_range_input = QLineEdit(dialog)
1187 self.max_range_input.setPlaceholderText(f"Max ({max_value})")
1188 layout.addWidget(self.max_range_input)
1189 else:
1190 # Display a label for categorical data
1191 name_label = QLabel("Select Name to Isolate")
1192 layout.addWidget(name_label)
1193
1194 # If column is categorical, add a dropdown with unique values
1195 unique_values = self.data[active_column].unique()
1196 self.category_combo = QComboBox(dialog)
1197 self.category_combo.addItems(unique_values.astype(str))
1198 layout.addWidget(self.category_combo)
1199
1200 # OK and Cancel buttons
1201 buttons = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel, dialog)
1202 layout.addWidget(buttons)
1203 buttons.accepted.connect(dialog.accept)
1204 buttons.rejected.connect(dialog.reject)
1205
1206 dialog.exec_()
1207
1208 # Handle dialog acceptance
1209 if dialog.result() == QDialog.Accepted:
1210 if pd.api.types.is_numeric_dtype(self.data[active_column]):
1211 self.isolate_range = (float(self.min_range_input.text()), float(self.max_range_input.text()))
1212 else:
1213 self.isolate_value = self.category_combo.currentText()
1214 self.isolate_column = active_column
1215 self.isolate_flag = True
1216 self.plot() # Replot
1217
1218 def isolate(self):
1219 self.select_isolate()

Callers 1

isolateMethod · 0.95

Calls 1

plotMethod · 0.95

Tested by

no test coverage detected