well-log-toolkit 0.1.115__py3-none-any.whl → 0.1.116__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2539,9 +2539,10 @@ class WellDataManager:
2539
2539
  dict with keys: type, line_color, line_width, line_style, line_alpha, x_range.
2540
2540
  Default: None
2541
2541
  regression_by_color : str or dict, optional
2542
- Regression type to apply separately for each color group. Creates separate
2543
- regression lines for each unique color value. Accepts string or dict format.
2544
- Default: None
2542
+ Regression type to apply separately for each color group in the plot. Creates
2543
+ separate regression lines based on what determines colors in the visualization:
2544
+ explicit color mapping if specified, otherwise shape groups (e.g., wells when
2545
+ shape='well'). Accepts string or dict format. Default: None
2545
2546
  regression_by_group : str or dict, optional
2546
2547
  Regression type to apply separately for each well. Creates separate
2547
2548
  regression lines for each well. Accepts string or dict format.
@@ -2827,9 +2827,10 @@ class Crossplot:
2827
2827
  dict with keys: type, line_color, line_width, line_style, line_alpha, x_range.
2828
2828
  Default: None
2829
2829
  regression_by_color : str or dict, optional
2830
- Regression type to apply separately for each color group. Creates separate
2831
- regression lines for each unique color value. Accepts string or dict format.
2832
- Default: None
2830
+ Regression type to apply separately for each color group in the plot. Creates
2831
+ separate regression lines based on what determines colors in the visualization:
2832
+ explicit color mapping if specified, otherwise shape groups (e.g., wells when
2833
+ shape='well'). Accepts string or dict format. Default: None
2833
2834
  regression_by_group : str or dict, optional
2834
2835
  Regression type to apply separately for each group (well or shape). Creates
2835
2836
  separate regression lines for each well or shape category. Accepts string or dict.
@@ -3162,53 +3163,70 @@ class Crossplot:
3162
3163
  config = self._parse_regression_config(self.regression_by_color)
3163
3164
  reg_type = config['type']
3164
3165
 
3165
- if not self.color:
3166
- warnings.warn("regression_by_color specified but no color mapping defined, skipping")
3166
+ # Determine grouping column based on what's being used for colors in the plot
3167
+ group_column = None
3168
+ group_label = None
3169
+
3170
+ if self.color and 'color_val' in data.columns:
3171
+ # User specified explicit color mapping
3172
+ group_column = 'color_val'
3173
+ group_label = self.color
3174
+ elif self.shape == "well" and 'well' in data.columns:
3175
+ # When shape="well", each well gets a different color in the plot
3176
+ group_column = 'well'
3177
+ group_label = 'well'
3178
+ elif self.shape and self.shape != "well" and 'shape_val' in data.columns:
3179
+ # When shape is a property, each shape group gets a different color
3180
+ group_column = 'shape_val'
3181
+ group_label = self.shape
3182
+
3183
+ if group_column is None:
3184
+ warnings.warn(
3185
+ "regression_by_color specified but no color grouping detected in plot. "
3186
+ "Use color=<property>, shape='well', or shape=<property> parameter."
3187
+ )
3167
3188
  else:
3168
- # Get unique color groups
3169
- if 'color_val' in data.columns:
3170
- # For continuous color values, we need to bin them or use unique values
3171
- # Check if color is categorical (well, shape) or continuous
3172
- if self.color == 'depth' or pd.api.types.is_numeric_dtype(data['color_val']):
3173
- # For continuous values, we can't create separate regressions
3174
- warnings.warn(
3175
- f"regression_by_color requires categorical color mapping, "
3176
- f"but '{self.color}' is continuous. Use regression_by_group instead."
3189
+ # Check if color is categorical (not continuous like depth)
3190
+ if group_column == 'color_val' and (self.color == 'depth' or pd.api.types.is_numeric_dtype(data[group_column])):
3191
+ # For continuous values, we can't create separate regressions
3192
+ warnings.warn(
3193
+ f"regression_by_color requires categorical color mapping, "
3194
+ f"but '{self.color}' is continuous. Use regression_by_group instead."
3195
+ )
3196
+ else:
3197
+ # Categorical values - group and create regressions
3198
+ color_groups = data.groupby(group_column)
3199
+ n_groups = len(color_groups)
3200
+
3201
+ # Validate regression count
3202
+ if regression_count + n_groups > total_points / 2:
3203
+ raise ValueError(
3204
+ f"Too many regression lines requested: {regression_count + n_groups} lines "
3205
+ f"for {total_points} data points (average < 2 points per line). "
3206
+ f"Reduce the number of groups or use a different regression strategy."
3177
3207
  )
3178
- else:
3179
- # Categorical color values
3180
- color_groups = data.groupby('color_val')
3181
- n_groups = len(color_groups)
3182
-
3183
- # Validate regression count
3184
- if regression_count + n_groups > total_points / 2:
3185
- raise ValueError(
3186
- f"Too many regression lines requested: {regression_count + n_groups} lines "
3187
- f"for {total_points} data points (average < 2 points per line). "
3188
- f"Reduce the number of groups or use a different regression strategy."
3189
- )
3190
3208
 
3191
- for idx, (group_name, group_data) in enumerate(color_groups):
3192
- x_vals = group_data['x'].values
3193
- y_vals = group_data['y'].values
3194
- mask = np.isfinite(x_vals) & np.isfinite(y_vals)
3195
- if np.sum(mask) >= 2:
3196
- # Copy config and set default line color if not specified
3197
- group_config = config.copy()
3198
- if 'line_color' not in group_config:
3199
- group_config['line_color'] = regression_colors[color_idx % len(regression_colors)]
3200
-
3201
- # Skip legend update for all but last regression
3202
- is_last = (idx == n_groups - 1)
3203
- self._add_group_regression(
3204
- x_vals[mask], y_vals[mask],
3205
- reg_type,
3206
- name=f"{self.color}={group_name}",
3207
- config=group_config,
3208
- update_legend=is_last
3209
- )
3210
- regression_count += 1
3211
- color_idx += 1
3209
+ for idx, (group_name, group_data) in enumerate(color_groups):
3210
+ x_vals = group_data['x'].values
3211
+ y_vals = group_data['y'].values
3212
+ mask = np.isfinite(x_vals) & np.isfinite(y_vals)
3213
+ if np.sum(mask) >= 2:
3214
+ # Copy config and set default line color if not specified
3215
+ group_config = config.copy()
3216
+ if 'line_color' not in group_config:
3217
+ group_config['line_color'] = regression_colors[color_idx % len(regression_colors)]
3218
+
3219
+ # Skip legend update for all but last regression
3220
+ is_last = (idx == n_groups - 1)
3221
+ self._add_group_regression(
3222
+ x_vals[mask], y_vals[mask],
3223
+ reg_type,
3224
+ name=f"{group_label}={group_name}",
3225
+ config=group_config,
3226
+ update_legend=is_last
3227
+ )
3228
+ regression_count += 1
3229
+ color_idx += 1
3212
3230
 
3213
3231
  # Add regression by groups (well or shape)
3214
3232
  if self.regression_by_group:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: well-log-toolkit
3
- Version: 0.1.115
3
+ Version: 0.1.116
4
4
  Summary: Fast LAS file processing with lazy loading and filtering for well log analysis
5
5
  Author-email: Kristian dF Kollsgård <kkollsg@gmail.com>
6
6
  License: MIT
@@ -1,15 +1,15 @@
1
1
  well_log_toolkit/__init__.py,sha256=ilJAIIhh68pYfD9I3V53juTEJpoMN8oHpcpEFNpuXAQ,3793
2
2
  well_log_toolkit/exceptions.py,sha256=X_fzC7d4yaBFO9Vx74dEIB6xmI9Agi6_bTU3MPxn6ko,985
3
3
  well_log_toolkit/las_file.py,sha256=yRCIiVbdoqFzoXKRKfx7Lt11INmwB_bXdpHpwVaNpjk,52156
4
- well_log_toolkit/manager.py,sha256=gajHbQc1zI7L0gSmcZOUg1_aSje4SZoqSff3uu3C7Hg,101585
4
+ well_log_toolkit/manager.py,sha256=DvBOk9iLItcLKnx4IQA2AlPeqVafOgyDa4M1xMTE_6k,101727
5
5
  well_log_toolkit/operations.py,sha256=z8j8fGBOwoJGUQFy-Vawjq9nm3OD_dUt0oaNh8yuG7o,18515
6
6
  well_log_toolkit/property.py,sha256=WOzoNQcmHCQ8moIKsnSyLgVC8s4LBu2x5IBXtFzmMe8,76236
7
7
  well_log_toolkit/regression.py,sha256=19wpiQQdGxuyIbjfzIY_yLzUUGT_ampWE_km1bg3o3c,24527
8
8
  well_log_toolkit/statistics.py,sha256=_huPMbv2H3o9ezunjEM94mJknX5wPK8V4nDv2lIZZRw,16814
9
9
  well_log_toolkit/utils.py,sha256=O2KPq4htIoUlL74V2zKftdqqTjRfezU9M-568zPLme0,6866
10
- well_log_toolkit/visualization.py,sha256=GlSR8KeYQED21bn2SmhHUj9zfnDb1ePgFIJBD-1XF5Q,147956
10
+ well_log_toolkit/visualization.py,sha256=vmRhigawQyowH2mhTWs7kG5quJV0kB5_mU8S29EAcFA,148788
11
11
  well_log_toolkit/well.py,sha256=jv8xPQi-y5dLRQ7WIyBsr8DIMIAiFt4UJ9Rum7xTx7o,90170
12
- well_log_toolkit-0.1.115.dist-info/METADATA,sha256=22pPqzD7QtvbX526X79rCUM7tkTvv3jYvSOv4YjG-xc,59737
13
- well_log_toolkit-0.1.115.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- well_log_toolkit-0.1.115.dist-info/top_level.txt,sha256=BMOo7OKLcZEnjo0wOLMclwzwTbYKYh31I8RGDOGSBdE,17
15
- well_log_toolkit-0.1.115.dist-info/RECORD,,
12
+ well_log_toolkit-0.1.116.dist-info/METADATA,sha256=nahOX_H_Oq0rh5xniTlPGGrUp4jS6Y-6m_Iyp92g77g,59737
13
+ well_log_toolkit-0.1.116.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
+ well_log_toolkit-0.1.116.dist-info/top_level.txt,sha256=BMOo7OKLcZEnjo0wOLMclwzwTbYKYh31I8RGDOGSBdE,17
15
+ well_log_toolkit-0.1.116.dist-info/RECORD,,