geometallurgy 0.4.4__tar.gz → 0.4.6__tar.gz

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.
Files changed (45) hide show
  1. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/PKG-INFO +1 -1
  2. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/base.py +56 -1
  3. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/pyproject.toml +1 -1
  4. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/LICENSE +0 -0
  5. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/README.md +0 -0
  6. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/__init__.py +0 -0
  7. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/block_model.py +0 -0
  8. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/config/__init__.py +0 -0
  9. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/config/config_read.py +0 -0
  10. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/config/flowsheet_example.yaml +0 -0
  11. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/config/mc_config.yml +0 -0
  12. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/data/downloader.py +0 -0
  13. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/data/register.csv +0 -0
  14. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/datasets/__init__.py +0 -0
  15. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/datasets/datasets.py +0 -0
  16. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/datasets/downloader.py +0 -0
  17. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/datasets/register.csv +0 -0
  18. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/datasets/sample_data.py +0 -0
  19. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/extras.py +0 -0
  20. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/flowsheet/__init__.py +0 -0
  21. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/flowsheet/flowsheet.py +0 -0
  22. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/flowsheet/loader.py +0 -0
  23. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/flowsheet/operation.py +0 -0
  24. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/flowsheet/stream.py +0 -0
  25. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/interval_sample.py +0 -0
  26. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/io.py +0 -0
  27. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/plot.py +0 -0
  28. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/profile.py +0 -0
  29. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/sample.py +0 -0
  30. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/__init__.py +0 -0
  31. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/amenability.py +0 -0
  32. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/block_model_converter.py +0 -0
  33. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/components.py +0 -0
  34. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/data.py +0 -0
  35. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/interp.py +0 -0
  36. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/layout.py +0 -0
  37. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/moisture.py +0 -0
  38. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/pandas.py +0 -0
  39. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/parallel.py +0 -0
  40. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/partition.py +0 -0
  41. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/sampling.py +0 -0
  42. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/size.py +0 -0
  43. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/timer.py +0 -0
  44. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/utils/viz.py +0 -0
  45. {geometallurgy-0.4.4 → geometallurgy-0.4.6}/elphick/geomet/validate.py.hide +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geometallurgy
3
- Version: 0.4.4
3
+ Version: 0.4.6
4
4
  Summary: Tools for the geometallurgist
5
5
  Home-page: https://github.com/elphick/geometallurgy
6
6
  Author: Greg
@@ -213,6 +213,61 @@ class MassComposition(ABC):
213
213
  (self.mass_columns + [self.moisture_column] + self.composition_columns + self.supplementary_columns) if
214
214
  col is not None]
215
215
 
216
+ def balance_composition(self) -> MC:
217
+ """Balance the composition data
218
+
219
+ For records where the component mass exceeds the dry mass, the component masses are reduced proportionally
220
+ to equal the dry mass. Records where the component mass is less than the dry mass are left unchanged.
221
+
222
+ """
223
+ if self._mass_data is not None:
224
+ # calculate the ratio of the sum of the components to the dry mass
225
+ ratio = self._mass_data[self.composition_columns].sum(axis=1) / self._mass_data[self.mass_dry_var]
226
+ if ratio.max() <= 1.0:
227
+ return self
228
+ epsilon = 1e-6
229
+ # add a small value to the ratio to avoid component sums marginally over 100.0
230
+ ratio[ratio > 1.0] = ratio[ratio > 1.0] + epsilon
231
+ # to avoid reducing compliant records, clip the ratio at the lower side to 1.0
232
+ ratio = ratio.clip(lower=1.0)
233
+ # apply the ratio to the components
234
+ self._mass_data[self.composition_columns] = self._mass_data[self.composition_columns].div(ratio, axis=0)
235
+
236
+ return self
237
+
238
+ def set_moisture(self, moisture: Union[pd.Series, float, int], mass_to_adjust: Literal['wet', 'dry'] = 'wet') -> MC:
239
+ """Set the moisture to the specified value
240
+
241
+ A convenience method for an mc object that modifies the concrete mass to deliver the specified moisture.
242
+
243
+ Args:
244
+ moisture: The moisture value to set. Can be a constant or series.
245
+ mass_to_adjust: The mass to adjust, either 'wet' or 'dry'.
246
+
247
+ Returns:
248
+
249
+ """
250
+
251
+ if not self.moisture_in_scope:
252
+ raise AssertionError("This method is not applicable unless moisture_in_scope property is True.")
253
+
254
+ if isinstance(moisture, float) or isinstance(moisture, int):
255
+ # create a series with the same index as the mass data
256
+ moisture = pd.Series(float(moisture), index=self._mass_data.index)
257
+ elif not isinstance(moisture, pd.Series):
258
+ raise TypeError(f"moisture must be a float or a pd.Series, not {type(moisture)}")
259
+
260
+ if mass_to_adjust == 'wet':
261
+ self._mass_data[self.mass_wet_var] = solve_mass_moisture(mass_dry=self._mass_data[self.mass_dry_var],
262
+ moisture=moisture)
263
+ elif mass_to_adjust == 'dry':
264
+ self._mass_data[self.mass_dry_var] = solve_mass_moisture(mass_wet=self._mass_data[self.mass_wet_var],
265
+ moisture=moisture)
266
+ else:
267
+ raise ValueError(f"mass_to_adjust must be 'wet' or 'dry', not {mass_to_adjust}")
268
+
269
+ return self
270
+
216
271
  def plot_parallel(self, color: Optional[str] = None,
217
272
  vars_include: Optional[list[str]] = None,
218
273
  vars_exclude: Optional[list[str]] = None,
@@ -696,7 +751,7 @@ class MassComposition(ABC):
696
751
  moisture_column_name: Optional[str] = None,
697
752
  component_columns: Optional[list[str]] = None,
698
753
  composition_units: Literal['%', 'ppm', 'ppb'] = '%',
699
- **kwargs):
754
+ **kwargs) -> MC:
700
755
  """
701
756
  Class method to create a MassComposition object from a mass dataframe.
702
757
 
@@ -1,7 +1,7 @@
1
1
  [tool.poetry]
2
2
  name = "geometallurgy"
3
3
  packages = [{ include = "elphick/geomet" }]
4
- version = "0.4.4"
4
+ version = "0.4.6"
5
5
  description = "Tools for the geometallurgist"
6
6
  authors = ["Greg <11791585+elphick@users.noreply.github.com>"]
7
7
  repository = "https://github.com/elphick/geometallurgy"
File without changes
File without changes