geometallurgy 0.4.15__py3-none-any.whl → 0.4.17__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.
@@ -32,4 +32,8 @@ MC:
32
32
  recovery: 'rec'
33
33
  difference: 'diff'
34
34
  divide: 'ur'
35
+ flowsheet:
36
+ operation:
37
+ tol_abs: 1.0e-4
38
+ tol_rel: 1.0e-6
35
39
 
@@ -264,6 +264,8 @@ class Flowsheet:
264
264
  records.columns = [f"{col[0]}_{col[1]}" for col in records.columns]
265
265
 
266
266
  result = unhealthy_data.merge(records, left_index=True, right_index=True, how='left')
267
+ # add stream to the index
268
+ result.set_index('stream', append=True, inplace=True)
267
269
  return result
268
270
 
269
271
  def unhealthy_node_records(self) -> pd.DataFrame:
@@ -278,9 +280,9 @@ class Flowsheet:
278
280
  'mc'].is_balanced]
279
281
  unhealthy_data: pd.DataFrame = pd.concat(
280
282
  [self.graph.nodes[n]['mc'].unbalanced_records.assign(node=self.graph.nodes[n]['mc'].name) for n in
281
- unhealthy_nodes], axis=1)
282
- # move the last column to the front
283
- unhealthy_data = unhealthy_data[[unhealthy_data.columns[-1]] + list(unhealthy_data.columns[:-1])]
283
+ unhealthy_nodes], axis=0)
284
+ # add the node to the index
285
+ unhealthy_data = unhealthy_data.set_index('node', append=True)
284
286
 
285
287
  # todo: append the streams around the node
286
288
 
@@ -1,10 +1,12 @@
1
1
  from copy import copy
2
2
  from enum import Enum
3
3
  from functools import reduce
4
+ from pathlib import Path
4
5
  from typing import Optional, TypeVar, TYPE_CHECKING
5
6
 
6
7
  import numpy as np
7
8
  import pandas as pd
9
+ import yaml
8
10
 
9
11
  from elphick.geomet.base import MC
10
12
  from elphick.geomet.flowsheet.stream import Stream
@@ -25,13 +27,22 @@ class NodeType(Enum):
25
27
 
26
28
 
27
29
  class Operation:
28
- def __init__(self, name):
30
+ def __init__(self, name, config_file: Optional[Path] = None):
29
31
  self.name = name
30
32
  self._inputs = []
31
33
  self._outputs = []
32
34
  self._is_balanced: Optional[bool] = None
33
35
  self._unbalanced_records: Optional[pd.DataFrame] = None
34
36
 
37
+ # Load configuration
38
+ if config_file is None:
39
+ config_file = Path(__file__).parent / '.././config/mc_config.yml'
40
+
41
+ with open(config_file, 'r') as file:
42
+ config = yaml.safe_load(file)
43
+ self.tol_abs = config['flowsheet']['operation'].get('tol_abs', 1e-6)
44
+ self.tol_rel = config['flowsheet']['operation'].get('tol_rel', 1e-6)
45
+
35
46
  @property
36
47
  def has_empty_input(self) -> bool:
37
48
  return None in self.inputs
@@ -102,9 +113,9 @@ class Operation:
102
113
  return None
103
114
 
104
115
  input_mass, output_mass = self.get_input_mass(), self.get_output_mass()
105
- is_balanced = np.all(np.isclose(input_mass.fillna(0.0), output_mass.fillna(0.0)))
106
- self._unbalanced_records = (input_mass - output_mass).loc[~np.isclose(input_mass, output_mass).any(axis=1)]
107
- self._is_balanced = is_balanced
116
+ mask = ~np.isclose(input_mass, output_mass, atol=self.tol_abs, rtol=self.tol_rel)
117
+ self._unbalanced_records = (input_mass - output_mass).loc[mask.any(axis=1)]
118
+ self._is_balanced = self._unbalanced_records.shape[0] == 0
108
119
 
109
120
  @property
110
121
  def is_balanced(self) -> Optional[bool]:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: geometallurgy
3
- Version: 0.4.15
3
+ Version: 0.4.17
4
4
  Summary: Tools for the geometallurgist
5
5
  Home-page: https://github.com/elphick/geometallurgy
6
6
  Author: Greg
@@ -5,7 +5,7 @@ elphick/geomet/config/__init__.py,sha256=F94hbxN3KzSaljbElIGVhdEwX0FKmHxST4jJ7rN
5
5
  elphick/geomet/config/config_read.py,sha256=frRwfRwUXpgxwMNCiBVFUw1-yPbBHs3h2KjmzXImvxY,1396
6
6
  elphick/geomet/config/flowsheet_example_partition.yaml,sha256=85vrhOotQHhaKkYN-0QQA7ed03EMRkyaKZc-GtXMKro,716
7
7
  elphick/geomet/config/flowsheet_example_simple.yaml,sha256=u4sM2gkyyHXnOlqW3TvwBjRdl4x34zGeZS7YGNmdfC4,428
8
- elphick/geomet/config/mc_config.yml,sha256=6eUGCJlU5Aw9M5Rn6Xuezf8_bShxwxZ1g5XB8P5iLWc,913
8
+ elphick/geomet/config/mc_config.yml,sha256=5sUQXOmXIcqEp_Thwj8yBoHWC_JMDSpYL_uIlEHWkbI,977
9
9
  elphick/geomet/data/downloader.py,sha256=x_107mTNCaG9YwEO54mBx7l3KaqOavCi93uZjPdC5GU,1621
10
10
  elphick/geomet/data/register.csv,sha256=-N3F6L0097C-I79axINi_ewFAxiqbT_SOSW3-XtPkI4,3046
11
11
  elphick/geomet/datasets/__init__.py,sha256=7CX648YFMv39FchI1_oEF28zF52v4gX0lnqomPwkcvU,59
@@ -15,9 +15,9 @@ elphick/geomet/datasets/register.csv,sha256=-N3F6L0097C-I79axINi_ewFAxiqbT_SOSW3
15
15
  elphick/geomet/datasets/sample_data.py,sha256=jt5DWxdMmPbZGDuon2s8Q2wlX3cEegB0dSmRKF4pz4I,7684
16
16
  elphick/geomet/extras.py,sha256=UMkAYp72X-30ckaZ-2ENffUUZ7k7JBTdtgsVdgxxYAk,1164
17
17
  elphick/geomet/flowsheet/__init__.py,sha256=-lxSLPZNQfiLXKZ2qqS5XbbhrZA2ABi3ppx0LaHnNEI,33
18
- elphick/geomet/flowsheet/flowsheet.py,sha256=__kgowBIyWfvXcdPWCFihoEUdOqTj7KszSbKGF1AkBo,52032
18
+ elphick/geomet/flowsheet/flowsheet.py,sha256=det02WllI-Bt4ILvg5MmVCEdynhobWBh5cJsubzQnD8,52085
19
19
  elphick/geomet/flowsheet/loader.py,sha256=8nd9Vqbg1de35iuoc4mdRFxrUsIBZed0ivXIAu80jBk,4756
20
- elphick/geomet/flowsheet/operation.py,sha256=f8k0-Gr_Uy2SlEp8bwAaG4yeBa3DU0HoPn9wyWhYipE,9720
20
+ elphick/geomet/flowsheet/operation.py,sha256=bsT3ZZNhOXSeONjHAzSmex2CAOOWxG7tDcxmMUaFwTg,10170
21
21
  elphick/geomet/flowsheet/stream.py,sha256=NOXcYeZLSmOSoSRFc7M36Jc8c1ARgjiCvtRuixYfuqA,1370
22
22
  elphick/geomet/interval_sample.py,sha256=fhcWBTA01TqvCBsJv7dzWZHRBpw_4W2Ahawks5SPj28,31320
23
23
  elphick/geomet/io.py,sha256=tZsX_getGxL07dPlF3Ozyzvt2tFHE5OdgPM5pc5xL68,15709
@@ -41,8 +41,8 @@ elphick/geomet/utils/size.py,sha256=EmV_sv2bOImQN3s7TWCniU_y83HNJEPtZH7fMMkYTcc,
41
41
  elphick/geomet/utils/timer.py,sha256=8WNKLFcINRsZ3IsKtOIZ77YbKtqczyOOTEWY9h9Uxxw,3112
42
42
  elphick/geomet/utils/viz.py,sha256=M0CnfDXBHtYb8aak1Sfz6XLvRSmkzX3ybIDllEmDR8A,1718
43
43
  elphick/geomet/validate.py.hide,sha256=qAWJlgq0jp19UakVV0dEU_AsqV_JctUn1QTHn8cCRw0,6738
44
- geometallurgy-0.4.15.dist-info/LICENSE,sha256=GrSVdcGtNbGvAYC_tIjLHBrIVPyg-Ksfe7ZGr087yCI,1069
45
- geometallurgy-0.4.15.dist-info/METADATA,sha256=YW9b1XuvYaxff2WQK1NcydFmPXSQf2VTNgxn0sav2Iw,4469
46
- geometallurgy-0.4.15.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
47
- geometallurgy-0.4.15.dist-info/entry_points.txt,sha256=aQI-8kmaba_c9ZGOFkJgWl0MWBke5BQLNyPSVcbS7EU,58
48
- geometallurgy-0.4.15.dist-info/RECORD,,
44
+ geometallurgy-0.4.17.dist-info/LICENSE,sha256=GrSVdcGtNbGvAYC_tIjLHBrIVPyg-Ksfe7ZGr087yCI,1069
45
+ geometallurgy-0.4.17.dist-info/METADATA,sha256=tOckk944ZdykLolkklkfOsDi9Ff0pQcdxWiLzQbZKZ4,4469
46
+ geometallurgy-0.4.17.dist-info/WHEEL,sha256=WGfLGfLX43Ei_YORXSnT54hxFygu34kMpcQdmgmEwCQ,88
47
+ geometallurgy-0.4.17.dist-info/entry_points.txt,sha256=aQI-8kmaba_c9ZGOFkJgWl0MWBke5BQLNyPSVcbS7EU,58
48
+ geometallurgy-0.4.17.dist-info/RECORD,,