diff --git a/docs/pyerrors/correlators.html b/docs/pyerrors/correlators.html index 9a380d5d..aa01d708 100644 --- a/docs/pyerrors/correlators.html +++ b/docs/pyerrors/correlators.html @@ -783,7 +783,7 @@ 540 on the configurations in obs[i].idl. 541 """ 542 if self.N != 1: - 543 raise Exception("Reweighting only implemented for one-dimensional correlators.") + 543 raise ValueError("Reweighting only implemented for one-dimensional correlators.") 544 new_content = [] 545 for t_slice in self.content: 546 if _check_for_none(self, t_slice): @@ -803,11 +803,11 @@ 560 Parity quantum number of the correlator, can be +1 or -1 561 """ 562 if self.N != 1: - 563 raise Exception("T_symmetry only implemented for one-dimensional correlators.") + 563 raise ValueError("T_symmetry only implemented for one-dimensional correlators.") 564 if not isinstance(partner, Corr): - 565 raise Exception("T partner has to be a Corr object.") + 565 raise TypeError("T partner has to be a Corr object.") 566 if parity not in [+1, -1]: - 567 raise Exception("Parity has to be +1 or -1.") + 567 raise ValueError("Parity has to be +1 or -1.") 568 T_partner = parity * partner.reverse() 569 570 t_slices = [] @@ -966,7 +966,7 @@ 723 guess for the root finder, only relevant for the root variant 724 """ 725 if self.N != 1: - 726 raise Exception('Correlator must be projected before getting m_eff') + 726 raise ValueError('Correlator must be projected before getting m_eff') 727 if variant == 'log': 728 newcontent = [] 729 for t in range(self.T - 1): @@ -1087,7 +1087,7 @@ 844 if self.prange: 845 plateau_range = self.prange 846 else: - 847 raise Exception("no plateau range provided") + 847 raise ValueError("no plateau range provided") 848 if self.N != 1: 849 raise ValueError("Correlator must be projected before getting a plateau.") 850 if (all([self.content[t] is None for t in range(plateau_range[0], plateau_range[1] + 1)])): @@ -2305,7 +2305,7 @@ 541 on the configurations in obs[i].idl. 542 """ 543 if self.N != 1: - 544 raise Exception("Reweighting only implemented for one-dimensional correlators.") + 544 raise ValueError("Reweighting only implemented for one-dimensional correlators.") 545 new_content = [] 546 for t_slice in self.content: 547 if _check_for_none(self, t_slice): @@ -2325,11 +2325,11 @@ 561 Parity quantum number of the correlator, can be +1 or -1 562 """ 563 if self.N != 1: - 564 raise Exception("T_symmetry only implemented for one-dimensional correlators.") + 564 raise ValueError("T_symmetry only implemented for one-dimensional correlators.") 565 if not isinstance(partner, Corr): - 566 raise Exception("T partner has to be a Corr object.") + 566 raise TypeError("T partner has to be a Corr object.") 567 if parity not in [+1, -1]: - 568 raise Exception("Parity has to be +1 or -1.") + 568 raise ValueError("Parity has to be +1 or -1.") 569 T_partner = parity * partner.reverse() 570 571 t_slices = [] @@ -2488,7 +2488,7 @@ 724 guess for the root finder, only relevant for the root variant 725 """ 726 if self.N != 1: - 727 raise Exception('Correlator must be projected before getting m_eff') + 727 raise ValueError('Correlator must be projected before getting m_eff') 728 if variant == 'log': 729 newcontent = [] 730 for t in range(self.T - 1): @@ -2609,7 +2609,7 @@ 845 if self.prange: 846 plateau_range = self.prange 847 else: - 848 raise Exception("no plateau range provided") + 848 raise ValueError("no plateau range provided") 849 if self.N != 1: 850 raise ValueError("Correlator must be projected before getting a plateau.") 851 if (all([self.content[t] is None for t in range(plateau_range[0], plateau_range[1] + 1)])): @@ -4231,7 +4231,7 @@ correlator or a Corr of same length. 541 on the configurations in obs[i].idl. 542 """ 543 if self.N != 1: -544 raise Exception("Reweighting only implemented for one-dimensional correlators.") +544 raise ValueError("Reweighting only implemented for one-dimensional correlators.") 545 new_content = [] 546 for t_slice in self.content: 547 if _check_for_none(self, t_slice): @@ -4281,11 +4281,11 @@ on the configurations in obs[i].idl. 561 Parity quantum number of the correlator, can be +1 or -1 562 """ 563 if self.N != 1: -564 raise Exception("T_symmetry only implemented for one-dimensional correlators.") +564 raise ValueError("T_symmetry only implemented for one-dimensional correlators.") 565 if not isinstance(partner, Corr): -566 raise Exception("T partner has to be a Corr object.") +566 raise TypeError("T partner has to be a Corr object.") 567 if parity not in [+1, -1]: -568 raise Exception("Parity has to be +1 or -1.") +568 raise ValueError("Parity has to be +1 or -1.") 569 T_partner = parity * partner.reverse() 570 571 t_slices = [] @@ -4531,7 +4531,7 @@ Available choice: 724 guess for the root finder, only relevant for the root variant 725 """ 726 if self.N != 1: -727 raise Exception('Correlator must be projected before getting m_eff') +727 raise ValueError('Correlator must be projected before getting m_eff') 728 if variant == 'log': 729 newcontent = [] 730 for t in range(self.T - 1): @@ -4716,7 +4716,7 @@ Decides whether output is printed to the standard output. 845 if self.prange: 846 plateau_range = self.prange 847 else: -848 raise Exception("no plateau range provided") +848 raise ValueError("no plateau range provided") 849 if self.N != 1: 850 raise ValueError("Correlator must be projected before getting a plateau.") 851 if (all([self.content[t] is None for t in range(plateau_range[0], plateau_range[1] + 1)])): diff --git a/docs/pyerrors/covobs.html b/docs/pyerrors/covobs.html index 652426a1..f76720aa 100644 --- a/docs/pyerrors/covobs.html +++ b/docs/pyerrors/covobs.html @@ -121,17 +121,17 @@ 22 """ 23 self._set_cov(cov) 24 if '|' in name: - 25 raise Exception("Covobs name must not contain replica separator '|'.") + 25 raise ValueError("Covobs name must not contain replica separator '|'.") 26 self.name = name 27 if grad is None: 28 if pos is None: 29 if self.N == 1: 30 pos = 0 31 else: - 32 raise Exception('Have to specify position of cov-element belonging to mean!') + 32 raise ValueError('Have to specify position of cov-element belonging to mean!') 33 else: 34 if pos > self.N: - 35 raise Exception(f'pos {pos} too large for covariance matrix with dimension {self.N}x{self.N}!') + 35 raise ValueError(f'pos {pos} too large for covariance matrix with dimension {self.N}x{self.N}!') 36 self._grad = np.zeros((self.N, 1)) 37 self._grad[pos] = 1. 38 else: @@ -164,19 +164,19 @@ 65 elif self._cov.ndim == 2: 66 self.N = self._cov.shape[0] 67 if self._cov.shape[1] != self.N: - 68 raise Exception('Covariance matrix has to be a square matrix!') + 68 raise ValueError('Covariance matrix has to be a square matrix!') 69 else: - 70 raise Exception('Covariance matrix has to be a 2 dimensional square matrix!') + 70 raise ValueError('Covariance matrix has to be a 2 dimensional square matrix!') 71 72 for i in range(self.N): 73 for j in range(i): 74 if not self._cov[i][j] == self._cov[j][i]: - 75 raise Exception(f'Covariance matrix is non-symmetric for ({i}, {j})') + 75 raise ValueError(f'Covariance matrix is non-symmetric for ({i}, {j})') 76 77 evals = np.linalg.eigvalsh(self._cov) 78 for ev in evals: 79 if ev < 0: - 80 raise Exception('Covariance matrix is not positive-semidefinite!') + 80 raise ValueError('Covariance matrix is not positive-semidefinite!') 81 82 def _set_grad(self, grad): 83 """ Set the gradient of the covobs @@ -192,7 +192,7 @@ 93 if self._grad.ndim in [0, 1]: 94 self._grad = np.reshape(self._grad, (self.N, 1)) 95 elif self._grad.ndim != 2: - 96 raise Exception('Invalid dimension of grad!') + 96 raise ValueError('Invalid dimension of grad!') 97 98 @property 99 def cov(self): @@ -237,17 +237,17 @@ 23 """ 24 self._set_cov(cov) 25 if '|' in name: - 26 raise Exception("Covobs name must not contain replica separator '|'.") + 26 raise ValueError("Covobs name must not contain replica separator '|'.") 27 self.name = name 28 if grad is None: 29 if pos is None: 30 if self.N == 1: 31 pos = 0 32 else: - 33 raise Exception('Have to specify position of cov-element belonging to mean!') + 33 raise ValueError('Have to specify position of cov-element belonging to mean!') 34 else: 35 if pos > self.N: - 36 raise Exception(f'pos {pos} too large for covariance matrix with dimension {self.N}x{self.N}!') + 36 raise ValueError(f'pos {pos} too large for covariance matrix with dimension {self.N}x{self.N}!') 37 self._grad = np.zeros((self.N, 1)) 38 self._grad[pos] = 1. 39 else: @@ -280,19 +280,19 @@ 66 elif self._cov.ndim == 2: 67 self.N = self._cov.shape[0] 68 if self._cov.shape[1] != self.N: - 69 raise Exception('Covariance matrix has to be a square matrix!') + 69 raise ValueError('Covariance matrix has to be a square matrix!') 70 else: - 71 raise Exception('Covariance matrix has to be a 2 dimensional square matrix!') + 71 raise ValueError('Covariance matrix has to be a 2 dimensional square matrix!') 72 73 for i in range(self.N): 74 for j in range(i): 75 if not self._cov[i][j] == self._cov[j][i]: - 76 raise Exception(f'Covariance matrix is non-symmetric for ({i}, {j})') + 76 raise ValueError(f'Covariance matrix is non-symmetric for ({i}, {j})') 77 78 evals = np.linalg.eigvalsh(self._cov) 79 for ev in evals: 80 if ev < 0: - 81 raise Exception('Covariance matrix is not positive-semidefinite!') + 81 raise ValueError('Covariance matrix is not positive-semidefinite!') 82 83 def _set_grad(self, grad): 84 """ Set the gradient of the covobs @@ -308,7 +308,7 @@ 94 if self._grad.ndim in [0, 1]: 95 self._grad = np.reshape(self._grad, (self.N, 1)) 96 elif self._grad.ndim != 2: - 97 raise Exception('Invalid dimension of grad!') + 97 raise ValueError('Invalid dimension of grad!') 98 99 @property 100 def cov(self): @@ -351,17 +351,17 @@ 23 """ 24 self._set_cov(cov) 25 if '|' in name: -26 raise Exception("Covobs name must not contain replica separator '|'.") +26 raise ValueError("Covobs name must not contain replica separator '|'.") 27 self.name = name 28 if grad is None: 29 if pos is None: 30 if self.N == 1: 31 pos = 0 32 else: -33 raise Exception('Have to specify position of cov-element belonging to mean!') +33 raise ValueError('Have to specify position of cov-element belonging to mean!') 34 else: 35 if pos > self.N: -36 raise Exception(f'pos {pos} too large for covariance matrix with dimension {self.N}x{self.N}!') +36 raise ValueError(f'pos {pos} too large for covariance matrix with dimension {self.N}x{self.N}!') 37 self._grad = np.zeros((self.N, 1)) 38 self._grad[pos] = 1. 39 else: diff --git a/docs/pyerrors/fits.html b/docs/pyerrors/fits.html index 98bdb6f8..5dfbafc5 100644 --- a/docs/pyerrors/fits.html +++ b/docs/pyerrors/fits.html @@ -749,7 +749,7 @@ 638 if 'initial_guess' in kwargs: 639 x0 = np.asarray(kwargs.get('initial_guess'), dtype=np.float64) 640 if len(x0) != n_parms: -641 raise Exception(f'Initial guess does not have the correct length: {len(x0)} vs. {n_parms}') +641 raise ValueError(f'Initial guess does not have the correct length: {len(x0)} vs. {n_parms}') 642 else: 643 x0 = np.ones(n_parms, dtype=np.float64) 644 @@ -1957,7 +1957,7 @@ Parameters and information on the fitted result. 639 if 'initial_guess' in kwargs: 640 x0 = np.asarray(kwargs.get('initial_guess'), dtype=np.float64) 641 if len(x0) != n_parms: -642 raise Exception(f'Initial guess does not have the correct length: {len(x0)} vs. {n_parms}') +642 raise ValueError(f'Initial guess does not have the correct length: {len(x0)} vs. {n_parms}') 643 else: 644 x0 = np.ones(n_parms, dtype=np.float64) 645 diff --git a/docs/pyerrors/input/dobs.html b/docs/pyerrors/input/dobs.html index 99bd99a2..fe96e44e 100644 --- a/docs/pyerrors/input/dobs.html +++ b/docs/pyerrors/input/dobs.html @@ -157,9 +157,9 @@ 61 elif not d[k]: 62 return '\n' 63 else: - 64 raise Exception('Type', type(d[k]), 'not supported in export!') + 64 raise TypeError(f'Type {type(d[k]).__name__} not supported in export!') 65 else: - 66 raise Exception('Type', type(d), 'not supported in export!') + 66 raise TypeError(f'Type {type(d).__name__} not supported in export!') 67 return iters 68 69 @@ -220,11 +220,11 @@ 124 onames = [name.replace('|', '') for name in names] 125 for o in obsl: 126 if len(o.e_names) != 1: -127 raise Exception('You try to export dobs to obs!') +127 raise ValueError('You try to export dobs to obs!') 128 if o.e_names[0] != ename: -129 raise Exception('You try to export dobs to obs!') +129 raise ValueError('You try to export dobs to obs!') 130 if len(o.deltas.keys()) != nr: -131 raise Exception('Incompatible obses in list') +131 raise ValueError('Incompatible obses in list') 132 od['observables'] = {} 133 od['observables']['schema'] = {'name': 'lattobs', 'version': '1.0'} 134 od['observables']['origin'] = { @@ -239,7 +239,7 @@ 143 pd['name'] = name 144 if enstag: 145 if not isinstance(enstag, str): -146 raise Exception('enstag has to be a string!') +146 raise TypeError('enstag has to be a string!') 147 pd['enstag'] = enstag 148 else: 149 pd['enstag'] = ename @@ -247,9 +247,9 @@ 151 pd['array'] = [] 152 osymbol = 'cfg' 153 if not isinstance(symbol, list): -154 raise Exception('Symbol has to be a list!') +154 raise TypeError('Symbol has to be a list!') 155 if not (len(symbol) == 0 or len(symbol) == len(obsl)): -156 raise Exception(f'Symbol has to be a list of lenght 0 or {len(obsl)}!') +156 raise ValueError(f'Symbol has to be a list of length 0 or {len(obsl)}!') 157 for s in symbol: 158 osymbol += f' {s}' 159 for r in range(nr): @@ -461,7 +461,7 @@ 365 elif isinstance(separator_insertion, str): 366 name = name.replace(separator_insertion, f"|{separator_insertion}") 367 else: -368 raise Exception("separator_insertion has to be string or int, is ", type(separator_insertion)) +368 raise TypeError(f"separator_insertion has to be string or int, is {type(separator_insertion).__name__}") 369 names.append(name) 370 idl.append(idx) 371 res = [Obs([d[i] for d in deltas], names, idl=idl) for i in range(len(deltas[0]))] @@ -581,7 +581,7 @@ 485 elif isinstance(separator_insertion, str): 486 rname = rname.replace(separator_insertion, f"|{separator_insertion}") 487 else: -488 raise Exception("separator_insertion has to be string or int, is ", type(separator_insertion)) +488 raise TypeError(f"separator_insertion has to be string or int, is {type(separator_insertion).__name__}") 489 if '|' in rname: 490 new_ename = rname[:rname.index('|')] 491 else: @@ -753,9 +753,9 @@ 657 elif not d[k]: 658 return '\n' 659 else: -660 raise Exception('Type', type(d[k]), 'not supported in export!') +660 raise TypeError(f'Type {type(d[k]).__name__} not supported in export!') 661 else: -662 raise Exception('Type', type(d), 'not supported in export!') +662 raise TypeError(f'Type {type(d).__name__} not supported in export!') 663 return iters 664 665 @@ -848,9 +848,9 @@ 752 osymbol = '' 753 if symbol: 754 if not isinstance(symbol, list): -755 raise Exception('Symbol has to be a list!') +755 raise TypeError('Symbol has to be a list!') 756 if not (len(symbol) == 0 or len(symbol) == len(obsl)): -757 raise Exception(f'Symbol has to be a list of lenght 0 or {len(obsl)}!') +757 raise ValueError(f'Symbol has to be a list of length 0 or {len(obsl)}!') 758 osymbol = symbol[0] 759 for s in symbol[1:]: 760 osymbol += f' {s}' @@ -1074,11 +1074,11 @@ 125 onames = [name.replace('|', '') for name in names] 126 for o in obsl: 127 if len(o.e_names) != 1: -128 raise Exception('You try to export dobs to obs!') +128 raise ValueError('You try to export dobs to obs!') 129 if o.e_names[0] != ename: -130 raise Exception('You try to export dobs to obs!') +130 raise ValueError('You try to export dobs to obs!') 131 if len(o.deltas.keys()) != nr: -132 raise Exception('Incompatible obses in list') +132 raise ValueError('Incompatible obses in list') 133 od['observables'] = {} 134 od['observables']['schema'] = {'name': 'lattobs', 'version': '1.0'} 135 od['observables']['origin'] = { @@ -1093,7 +1093,7 @@ 144 pd['name'] = name 145 if enstag: 146 if not isinstance(enstag, str): -147 raise Exception('enstag has to be a string!') +147 raise TypeError('enstag has to be a string!') 148 pd['enstag'] = enstag 149 else: 150 pd['enstag'] = ename @@ -1101,9 +1101,9 @@ 152 pd['array'] = [] 153 osymbol = 'cfg' 154 if not isinstance(symbol, list): -155 raise Exception('Symbol has to be a list!') +155 raise TypeError('Symbol has to be a list!') 156 if not (len(symbol) == 0 or len(symbol) == len(obsl)): -157 raise Exception(f'Symbol has to be a list of lenght 0 or {len(obsl)}!') +157 raise ValueError(f'Symbol has to be a list of length 0 or {len(obsl)}!') 158 for s in symbol: 159 osymbol += f' {s}' 160 for r in range(nr): @@ -1334,7 +1334,7 @@ If True, the output is a gzipped xml. If False, the output is an xml file. 366 elif isinstance(separator_insertion, str): 367 name = name.replace(separator_insertion, f"|{separator_insertion}") 368 else: -369 raise Exception("separator_insertion has to be string or int, is ", type(separator_insertion)) +369 raise TypeError(f"separator_insertion has to be string or int, is {type(separator_insertion).__name__}") 370 names.append(name) 371 idl.append(idx) 372 res = [Obs([d[i] for d in deltas], names, idl=idl) for i in range(len(deltas[0]))] @@ -1497,7 +1497,7 @@ Imported data and meta-data 486 elif isinstance(separator_insertion, str): 487 rname = rname.replace(separator_insertion, f"|{separator_insertion}") 488 else: -489 raise Exception("separator_insertion has to be string or int, is ", type(separator_insertion)) +489 raise TypeError(f"separator_insertion has to be string or int, is {type(separator_insertion).__name__}") 490 if '|' in rname: 491 new_ename = rname[:rname.index('|')] 492 else: @@ -1799,9 +1799,9 @@ Imported data and meta-data 753 osymbol = '' 754 if symbol: 755 if not isinstance(symbol, list): -756 raise Exception('Symbol has to be a list!') +756 raise TypeError('Symbol has to be a list!') 757 if not (len(symbol) == 0 or len(symbol) == len(obsl)): -758 raise Exception(f'Symbol has to be a list of lenght 0 or {len(obsl)}!') +758 raise ValueError(f'Symbol has to be a list of length 0 or {len(obsl)}!') 759 osymbol = symbol[0] 760 for s in symbol[1:]: 761 osymbol += f' {s}' diff --git a/docs/pyerrors/input/hadrons.html b/docs/pyerrors/input/hadrons.html index 095defa3..abede1ee 100644 --- a/docs/pyerrors/input/hadrons.html +++ b/docs/pyerrors/input/hadrons.html @@ -123,7 +123,7 @@ 18 files = list(filter(lambda x: x.startswith(filestem + "."), ls)) 19 20 if not files: - 21 raise Exception('No files starting with', filestem, 'in folder', path) + 21 raise FileNotFoundError(f'No files starting with {filestem} in folder {path}') 22 23 def get_cnfg_number(n): 24 return int(n.replace(".h5", "")[len(filestem) + 1:]) # From python 3.9 onward the safer 'removesuffix' method can be used. @@ -403,7 +403,7 @@ 298 299 if n_file == 0: 300 if h5file["DistillationContraction/Metadata"].attrs.get("TimeSources")[0].decode() != "0...": -301 raise Exception("Routine is only implemented for files containing inversions on all timeslices.") +301 raise NotImplementedError("Routine is only implemented for files containing inversions on all timeslices.") 302 303 Nt = h5file["DistillationContraction/Metadata"].attrs.get("Nt")[0] 304 @@ -1100,7 +1100,7 @@ If true, the fit for the extraction of t0 is shown together with the data. 299 300 if n_file == 0: 301 if h5file["DistillationContraction/Metadata"].attrs.get("TimeSources")[0].decode() != "0...": -302 raise Exception("Routine is only implemented for files containing inversions on all timeslices.") +302 raise NotImplementedError("Routine is only implemented for files containing inversions on all timeslices.") 303 304 Nt = h5file["DistillationContraction/Metadata"].attrs.get("Nt")[0] 305 diff --git a/docs/pyerrors/input/json.html b/docs/pyerrors/input/json.html index 4377c9be..9d1c9606 100644 --- a/docs/pyerrors/input/json.html +++ b/docs/pyerrors/input/json.html @@ -661,7 +661,7 @@ 568 obstypes = (Obs, Corr, np.ndarray) 569 570 if not reps.isalnum(): -571 raise Exception('Placeholder string has to be alphanumeric!') +571 raise ValueError('Placeholder string has to be alphanumeric!') 572 ol = [] 573 counter = 0 574 @@ -681,7 +681,7 @@ 588 counter += 1 589 elif isinstance(v, str): 590 if bool(re.match(rf'{reps}[0-9]+', v)): -591 raise Exception(f'Dict contains string {v} that matches the placeholder! {reps} Cannot be safely exported.') +591 raise ValueError(f'Dict contains string {v} that matches the placeholder! {reps} Cannot be safely exported.') 592 x[k] = v 593 return x 594 @@ -701,7 +701,7 @@ 608 counter += 1 609 elif isinstance(e, str): 610 if bool(re.match(rf'{reps}[0-9]+', e)): -611 raise Exception(f'Dict contains string {e} that matches the placeholder! {reps} Cannot be safely exported.') +611 raise ValueError(f'Dict contains string {e} that matches the placeholder! {reps} Cannot be safely exported.') 612 x.append(e) 613 return x 614 @@ -748,7 +748,7 @@ 655 """ 656 657 if not isinstance(od, dict): -658 raise Exception('od has to be a dictionary. Did you want to use dump_to_json?') +658 raise TypeError('od has to be a dictionary. Did you want to use dump_to_json?') 659 660 infostring = ('This JSON file contains a python dictionary that has been parsed to a list of structures. ' 661 'OBSDICT contains the dictionary, where Obs or other structures have been replaced by ' @@ -780,7 +780,7 @@ 687 Specify the structure of the placeholder in imported dict to be reps[0-9]+. 688 """ 689 if not reps.isalnum(): -690 raise Exception('Placeholder string has to be alphanumeric!') +690 raise ValueError('Placeholder string has to be alphanumeric!') 691 692 counter = 0 693 @@ -817,7 +817,7 @@ 724 nd = dict_replace_string(ind) 725 726 if counter == 0: -727 raise Exception('No placeholder has been replaced! Check if reps is set correctly.') +727 raise ValueError('No placeholder has been replaced! Check if reps is set correctly.') 728 729 return nd 730 @@ -1396,7 +1396,7 @@ if full_output=True 656 """ 657 658 if not isinstance(od, dict): -659 raise Exception('od has to be a dictionary. Did you want to use dump_to_json?') +659 raise TypeError('od has to be a dictionary. Did you want to use dump_to_json?') 660 661 infostring = ('This JSON file contains a python dictionary that has been parsed to a list of structures. ' 662 'OBSDICT contains the dictionary, where Obs or other structures have been replaced by ' diff --git a/docs/pyerrors/input/misc.html b/docs/pyerrors/input/misc.html index 66051087..ea9c377e 100644 --- a/docs/pyerrors/input/misc.html +++ b/docs/pyerrors/input/misc.html @@ -202,7 +202,7 @@ 121 break 122 123 if not ls: -124 raise Exception('Error, directory not found') +124 raise FileNotFoundError('Error, directory not found') 125 126 # Exclude files with different names 127 for exc in ls: @@ -215,7 +215,7 @@ 134 if 'r_start' in kwargs: 135 r_start = kwargs.get('r_start') 136 if len(r_start) != replica: -137 raise Exception('r_start does not match number of replicas') +137 raise ValueError('r_start does not match number of replicas') 138 # Adjust Configuration numbering to python index 139 r_start = [o - 1 if o else None for o in r_start] 140 else: @@ -224,7 +224,7 @@ 143 if 'r_stop' in kwargs: 144 r_stop = kwargs.get('r_stop') 145 if len(r_stop) != replica: -146 raise Exception('r_stop does not match number of replicas') +146 raise ValueError('r_stop does not match number of replicas') 147 else: 148 r_stop = [None] * replica 149 @@ -471,7 +471,7 @@ The root of the data series. 122 break 123 124 if not ls: -125 raise Exception('Error, directory not found') +125 raise FileNotFoundError('Error, directory not found') 126 127 # Exclude files with different names 128 for exc in ls: @@ -484,7 +484,7 @@ The root of the data series. 135 if 'r_start' in kwargs: 136 r_start = kwargs.get('r_start') 137 if len(r_start) != replica: -138 raise Exception('r_start does not match number of replicas') +138 raise ValueError('r_start does not match number of replicas') 139 # Adjust Configuration numbering to python index 140 r_start = [o - 1 if o else None for o in r_start] 141 else: @@ -493,7 +493,7 @@ The root of the data series. 144 if 'r_stop' in kwargs: 145 r_stop = kwargs.get('r_stop') 146 if len(r_stop) != replica: -147 raise Exception('r_stop does not match number of replicas') +147 raise ValueError('r_stop does not match number of replicas') 148 else: 149 r_stop = [None] * replica 150 diff --git a/docs/pyerrors/input/openQCD.html b/docs/pyerrors/input/openQCD.html index 2a1166f8..7e34d7ef 100644 --- a/docs/pyerrors/input/openQCD.html +++ b/docs/pyerrors/input/openQCD.html @@ -148,7 +148,7 @@ 49 """ 50 known_oqcd_versions = ['1.4', '1.6', '2.0'] 51 if version not in known_oqcd_versions: - 52 raise Exception('Unknown openQCD version defined!') + 52 raise ValueError('Unknown openQCD version defined!') 53 print("Working with openQCD version " + version) 54 if 'postfix' in kwargs: 55 postfix = kwargs.get('postfix') @@ -167,7 +167,7 @@ 68 if 'r_start' in kwargs: 69 r_start = kwargs.get('r_start') 70 if len(r_start) != replica: - 71 raise Exception('r_start does not match number of replicas') + 71 raise ValueError('r_start does not match number of replicas') 72 r_start = [o if o else None for o in r_start] 73 else: 74 r_start = [None] * replica @@ -175,7 +175,7 @@ 76 if 'r_stop' in kwargs: 77 r_stop = kwargs.get('r_stop') 78 if len(r_stop) != replica: - 79 raise Exception('r_stop does not match number of replicas') + 79 raise ValueError('r_stop does not match number of replicas') 80 else: 81 r_stop = [None] * replica 82 @@ -400,7 +400,7 @@ 301 if 'r_start' in kwargs: 302 r_start = kwargs.get('r_start') 303 if len(r_start) != replica: - 304 raise Exception('r_start does not match number of replicas') + 304 raise ValueError('r_start does not match number of replicas') 305 r_start = [o if o else None for o in r_start] 306 else: 307 r_start = [None] * replica @@ -408,7 +408,7 @@ 309 if 'r_stop' in kwargs: 310 r_stop = kwargs.get('r_stop') 311 if len(r_stop) != replica: - 312 raise Exception('r_stop does not match number of replicas') + 312 raise ValueError('r_stop does not match number of replicas') 313 else: 314 r_stop = [None] * replica 315 @@ -740,7 +740,7 @@ 641 files.append(f) 642 643 if files == []: - 644 raise Exception("No files found after pattern filter!") + 644 raise FileNotFoundError("No files found after pattern filter!") 645 646 files = sort_names(files) 647 return files @@ -864,7 +864,7 @@ 765 """ 766 767 if c != 0.3: - 768 raise Exception("The required lattice norm is only implemented for c=0.3 at the moment.") + 768 raise NotImplementedError("The required lattice norm is only implemented for c=0.3 at the moment.") 769 770 plaq = _read_flow_obs(path, prefix, c, dtr_cnfg=dtr_cnfg, version="sfqcd", obspos=6, sum_t=False, Zeuthen_flow=Zeuthen_flow, integer_charge=False, **kwargs) 771 C2x1 = _read_flow_obs(path, prefix, c, dtr_cnfg=dtr_cnfg, version="sfqcd", obspos=7, sum_t=False, Zeuthen_flow=Zeuthen_flow, integer_charge=False, **kwargs) @@ -872,10 +872,10 @@ 773 T = plaq.tag["T"] 774 775 if T != L: - 776 raise Exception("The required lattice norm is only implemented for T=L at the moment.") + 776 raise NotImplementedError("The required lattice norm is only implemented for T=L at the moment.") 777 778 if Zeuthen_flow is not True: - 779 raise Exception("The required lattice norm is only implemented for the Zeuthen flow at the moment.") + 779 raise NotImplementedError("The required lattice norm is only implemented for the Zeuthen flow at the moment.") 780 781 t = (c * L) ** 2 / 8 782 @@ -953,7 +953,7 @@ 854 known_versions = ["openQCD", "sfqcd"] 855 856 if version not in known_versions: - 857 raise Exception("Unknown openQCD version.") + 857 raise ValueError("Unknown openQCD version.") 858 if "steps" in kwargs: 859 steps = kwargs.get("steps") 860 if version == "sfqcd": @@ -964,7 +964,7 @@ 865 postfix = "gfms" 866 else: 867 if "L" not in kwargs: - 868 raise Exception("This version of openQCD needs you to provide the spatial length of the lattice as parameter 'L'.") + 868 raise ValueError("This version of openQCD needs you to provide the spatial length of the lattice as parameter 'L'.") 869 else: 870 L = kwargs.get("L") 871 postfix = "ms" @@ -982,7 +982,7 @@ 883 if 'r_start' in kwargs: 884 r_start = kwargs.get('r_start') 885 if len(r_start) != len(files): - 886 raise Exception('r_start does not match number of replicas') + 886 raise ValueError('r_start does not match number of replicas') 887 r_start = [o if o else None for o in r_start] 888 else: 889 r_start = [None] * len(files) @@ -990,14 +990,14 @@ 891 if 'r_stop' in kwargs: 892 r_stop = kwargs.get('r_stop') 893 if len(r_stop) != len(files): - 894 raise Exception('r_stop does not match number of replicas') + 894 raise ValueError('r_stop does not match number of replicas') 895 else: 896 r_stop = [None] * len(files) 897 rep_names = [] 898 899 zeuthen = kwargs.get('Zeuthen_flow', False) 900 if zeuthen and version not in ['sfqcd']: - 901 raise Exception('Zeuthen flow can only be used for version==sfqcd') + 901 raise ValueError('Zeuthen flow can only be used for version==sfqcd') 902 903 r_start_index = [] 904 r_stop_index = [] @@ -1186,7 +1186,7 @@ 1087 projection to the topological charge sector defined by target 1088 """ 1089 if qtop.reweighted: -1090 raise Exception('You can not use a reweighted observable for reweighting!') +1090 raise ValueError('You can not use a reweighted observable for reweighting!') 1091 1092 proj_qtop = [] 1093 for n in qtop.deltas: @@ -1246,7 +1246,7 @@ 1147 """ 1148 1149 if not isinstance(target, int): -1150 raise Exception("'target' has to be an integer.") +1150 raise TypeError("'target' has to be an integer.") 1151 1152 kwargs['integer_charge'] = True 1153 qtop = read_qtop(path, prefix, c, **kwargs) @@ -1302,10 +1302,10 @@ 1203 1204 # test if the input is correct 1205 if qc not in ['dd', 'ud', 'du', 'uu']: -1206 raise Exception("Unknown quark conbination!") +1206 raise ValueError("Unknown quark combination!") 1207 1208 if corr not in ["gS", "gP", "gA", "gV", "gVt", "lA", "lV", "lVt", "lT", "lTt", "g1", "l1"]: -1209 raise Exception("Unknown correlator!") +1209 raise ValueError("Unknown correlator!") 1210 1211 if "files" in kwargs: 1212 known_files = kwargs.get("files") @@ -1473,7 +1473,7 @@ 50 """ 51 known_oqcd_versions = ['1.4', '1.6', '2.0'] 52 if version not in known_oqcd_versions: - 53 raise Exception('Unknown openQCD version defined!') + 53 raise ValueError('Unknown openQCD version defined!') 54 print("Working with openQCD version " + version) 55 if 'postfix' in kwargs: 56 postfix = kwargs.get('postfix') @@ -1492,7 +1492,7 @@ 69 if 'r_start' in kwargs: 70 r_start = kwargs.get('r_start') 71 if len(r_start) != replica: - 72 raise Exception('r_start does not match number of replicas') + 72 raise ValueError('r_start does not match number of replicas') 73 r_start = [o if o else None for o in r_start] 74 else: 75 r_start = [None] * replica @@ -1500,7 +1500,7 @@ 77 if 'r_stop' in kwargs: 78 r_stop = kwargs.get('r_stop') 79 if len(r_stop) != replica: - 80 raise Exception('r_stop does not match number of replicas') + 80 raise ValueError('r_stop does not match number of replicas') 81 else: 82 r_stop = [None] * replica 83 @@ -2190,7 +2190,7 @@ Read topological charge 766 """ 767 768 if c != 0.3: -769 raise Exception("The required lattice norm is only implemented for c=0.3 at the moment.") +769 raise NotImplementedError("The required lattice norm is only implemented for c=0.3 at the moment.") 770 771 plaq = _read_flow_obs(path, prefix, c, dtr_cnfg=dtr_cnfg, version="sfqcd", obspos=6, sum_t=False, Zeuthen_flow=Zeuthen_flow, integer_charge=False, **kwargs) 772 C2x1 = _read_flow_obs(path, prefix, c, dtr_cnfg=dtr_cnfg, version="sfqcd", obspos=7, sum_t=False, Zeuthen_flow=Zeuthen_flow, integer_charge=False, **kwargs) @@ -2198,10 +2198,10 @@ Read topological charge 774 T = plaq.tag["T"] 775 776 if T != L: -777 raise Exception("The required lattice norm is only implemented for T=L at the moment.") +777 raise NotImplementedError("The required lattice norm is only implemented for T=L at the moment.") 778 779 if Zeuthen_flow is not True: -780 raise Exception("The required lattice norm is only implemented for the Zeuthen flow at the moment.") +780 raise NotImplementedError("The required lattice norm is only implemented for the Zeuthen flow at the moment.") 781 782 t = (c * L) ** 2 / 8 783 @@ -2292,7 +2292,7 @@ postfix of the file to read, e.g. '.gfms.dat' for openQCD-files 1088 projection to the topological charge sector defined by target 1089 """ 1090 if qtop.reweighted: -1091 raise Exception('You can not use a reweighted observable for reweighting!') +1091 raise ValueError('You can not use a reweighted observable for reweighting!') 1092 1093 proj_qtop = [] 1094 for n in qtop.deltas: @@ -2385,7 +2385,7 @@ projection to the topological charge sector defined by target 1148 """ 1149 1150 if not isinstance(target, int): -1151 raise Exception("'target' has to be an integer.") +1151 raise TypeError("'target' has to be an integer.") 1152 1153 kwargs['integer_charge'] = True 1154 qtop = read_qtop(path, prefix, c, **kwargs) @@ -2507,10 +2507,10 @@ projection to the topological charge sector defined by target 1204 1205 # test if the input is correct 1206 if qc not in ['dd', 'ud', 'du', 'uu']: -1207 raise Exception("Unknown quark conbination!") +1207 raise ValueError("Unknown quark combination!") 1208 1209 if corr not in ["gS", "gP", "gA", "gV", "gVt", "lA", "lV", "lVt", "lT", "lTt", "g1", "l1"]: -1210 raise Exception("Unknown correlator!") +1210 raise ValueError("Unknown correlator!") 1211 1212 if "files" in kwargs: 1213 known_files = kwargs.get("files") diff --git a/docs/pyerrors/input/sfcf.html b/docs/pyerrors/input/sfcf.html index 5a8675d2..2c156d83 100644 --- a/docs/pyerrors/input/sfcf.html +++ b/docs/pyerrors/input/sfcf.html @@ -247,7 +247,7 @@ 163 known_versions = ["0.0", "1.0", "2.0", "1.0c", "2.0c", "1.0a", "2.0a"] 164 165 if version not in known_versions: -166 raise Exception("This version is not known!") +166 raise ValueError("This version is not known!") 167 if (version[-1] == "c"): 168 appended = False 169 compact = True @@ -270,7 +270,7 @@ 186 ls.extend(filenames) 187 break 188 if not ls: -189 raise Exception('Error, directory not found') +189 raise FileNotFoundError('Error, directory not found') 190 # Exclude folders with different names 191 for exc in ls: 192 if not fnmatch.fnmatch(exc, prefix + '*'): @@ -283,16 +283,16 @@ 199 else: 200 replica = len([file.split(".")[-1] for file in ls]) // len(set([file.split(".")[-1] for file in ls])) 201 if replica == 0: -202 raise Exception('No replica found in directory') +202 raise FileNotFoundError('No replica found in directory') 203 if not silent: 204 print('Read', part, 'part of', name_list, 'from', prefix[:-1], ',', replica, 'replica') 205 206 if 'names' in kwargs: 207 new_names = kwargs.get('names') 208 if len(new_names) != len(set(new_names)): -209 raise Exception("names are not unique!") +209 raise ValueError("names are not unique!") 210 if len(new_names) != replica: -211 raise Exception('names should have the length', replica) +211 raise ValueError(f'names should have the length {replica}') 212 213 else: 214 ens_name = kwargs.get("ens_name") @@ -472,7 +472,7 @@ 388 print("Checking for missing configs...") 389 che = kwargs.get("check_configs") 390 if not (len(che) == len(idl)): -391 raise Exception("check_configs has to be the same length as replica!") +391 raise ValueError("check_configs has to be the same length as replica!") 392 for r in range(len(idl)): 393 if not silent: 394 print("checking " + new_names[r]) @@ -1083,7 +1083,7 @@ bb-type correlators have length 1. 164 known_versions = ["0.0", "1.0", "2.0", "1.0c", "2.0c", "1.0a", "2.0a"] 165 166 if version not in known_versions: -167 raise Exception("This version is not known!") +167 raise ValueError("This version is not known!") 168 if (version[-1] == "c"): 169 appended = False 170 compact = True @@ -1106,7 +1106,7 @@ bb-type correlators have length 1. 187 ls.extend(filenames) 188 break 189 if not ls: -190 raise Exception('Error, directory not found') +190 raise FileNotFoundError('Error, directory not found') 191 # Exclude folders with different names 192 for exc in ls: 193 if not fnmatch.fnmatch(exc, prefix + '*'): @@ -1119,16 +1119,16 @@ bb-type correlators have length 1. 200 else: 201 replica = len([file.split(".")[-1] for file in ls]) // len(set([file.split(".")[-1] for file in ls])) 202 if replica == 0: -203 raise Exception('No replica found in directory') +203 raise FileNotFoundError('No replica found in directory') 204 if not silent: 205 print('Read', part, 'part of', name_list, 'from', prefix[:-1], ',', replica, 'replica') 206 207 if 'names' in kwargs: 208 new_names = kwargs.get('names') 209 if len(new_names) != len(set(new_names)): -210 raise Exception("names are not unique!") +210 raise ValueError("names are not unique!") 211 if len(new_names) != replica: -212 raise Exception('names should have the length', replica) +212 raise ValueError(f'names should have the length {replica}') 213 214 else: 215 ens_name = kwargs.get("ens_name") @@ -1308,7 +1308,7 @@ bb-type correlators have length 1. 389 print("Checking for missing configs...") 390 che = kwargs.get("check_configs") 391 if not (len(che) == len(idl)): -392 raise Exception("check_configs has to be the same length as replica!") +392 raise ValueError("check_configs has to be the same length as replica!") 393 for r in range(len(idl)): 394 if not silent: 395 print("checking " + new_names[r]) diff --git a/docs/pyerrors/input/utils.html b/docs/pyerrors/input/utils.html index ff38e720..4dbcb327 100644 --- a/docs/pyerrors/input/utils.html +++ b/docs/pyerrors/input/utils.html @@ -194,7 +194,7 @@ 108 ls.extend(dirnames) 109 break 110 if not ls: -111 raise Exception('Error, directory not found') +111 raise FileNotFoundError('Error, directory not found') 112 # Exclude folders with different names 113 for exc in ls: 114 if not fnmatch.fnmatch(exc, prefix + '*'): @@ -412,7 +412,7 @@ string with integers of which idls are missing 109 ls.extend(dirnames) 110 break 111 if not ls: -112 raise Exception('Error, directory not found') +112 raise FileNotFoundError('Error, directory not found') 113 # Exclude folders with different names 114 for exc in ls: 115 if not fnmatch.fnmatch(exc, prefix + '*'): diff --git a/docs/pyerrors/linalg.html b/docs/pyerrors/linalg.html index 8c5bff0c..f9189195 100644 --- a/docs/pyerrors/linalg.html +++ b/docs/pyerrors/linalg.html @@ -311,7 +311,7 @@ 203def cholesky(x): 204 """Cholesky decomposition of Obs valued matrices.""" 205 if any(isinstance(o, CObs) for o in x.ravel()): -206 raise Exception("Cholesky decomposition is not implemented for CObs.") +206 raise NotImplementedError("Cholesky decomposition is not implemented for CObs.") 207 return _mat_mat_op(anp.linalg.cholesky, x) 208 209 @@ -707,7 +707,7 @@ Obs valued.
204def cholesky(x):
 205    """Cholesky decomposition of Obs valued matrices."""
 206    if any(isinstance(o, CObs) for o in x.ravel()):
-207        raise Exception("Cholesky decomposition is not implemented for CObs.")
+207        raise NotImplementedError("Cholesky decomposition is not implemented for CObs.")
 208    return _mat_mat_op(anp.linalg.cholesky, x)
 
diff --git a/docs/pyerrors/misc.html b/docs/pyerrors/misc.html index cfacc211..c6e99c87 100644 --- a/docs/pyerrors/misc.html +++ b/docs/pyerrors/misc.html @@ -253,7 +253,7 @@
160 assert len(means) == cov.shape[-1] 161 tau = np.asarray(tau) 162 if np.min(tau) < 0.5: -163 raise Exception('All integrated autocorrelations have to be >= 0.5.') +163 raise ValueError('All integrated autocorrelations have to be >= 0.5.') 164 165 a = (2 * tau - 1) / (2 * tau + 1) 166 rand = np.random.multivariate_normal(np.zeros_like(means), cov * samples, samples) # noqa: NPY002 @@ -273,11 +273,11 @@ 180 otype = type(ol[0]) 181 for o in ol[1:]: 182 if not isinstance(o, otype): -183 raise Exception("Wrong data type in list.") +183 raise TypeError("Wrong data type in list.") 184 for attr in ["reweighted", "e_content", "idl"]: 185 if hasattr(ol[0], attr): 186 if not getattr(ol[0], attr) == getattr(o, attr): -187 raise Exception(f"All Obs in list have to have the same state '{attr}'.") +187 raise ValueError(f"All Obs in list have to have the same state '{attr}'.") @@ -589,7 +589,7 @@ Generated Observable 161 assert len(means) == cov.shape[-1] 162 tau = np.asarray(tau) 163 if np.min(tau) < 0.5: -164 raise Exception('All integrated autocorrelations have to be >= 0.5.') +164 raise ValueError('All integrated autocorrelations have to be >= 0.5.') 165 166 a = (2 * tau - 1) / (2 * tau + 1) 167 rand = np.random.multivariate_normal(np.zeros_like(means), cov * samples, samples) # noqa: NPY002 diff --git a/docs/pyerrors/mpm.html b/docs/pyerrors/mpm.html index 2ae95e77..d33e3c2f 100644 --- a/docs/pyerrors/mpm.html +++ b/docs/pyerrors/mpm.html @@ -113,7 +113,7 @@ 35 36 lengths = [len(d) for d in data] 37 if lengths.count(lengths[0]) != len(lengths): -38 raise Exception('All datasets have to have the same length.') +38 raise ValueError('All datasets have to have the same length.') 39 40 data_sets = len(data) 41 n_data = len(data[0]) @@ -121,9 +121,9 @@ 43 if p is None: 44 p = max(n_data // 2, k) 45 if n_data <= p: -46 raise Exception('The pencil p has to be smaller than the number of data samples.') +46 raise ValueError('The pencil p has to be smaller than the number of data samples.') 47 if p < k or n_data - p < k: -48 raise Exception('Cannot extract', k, 'energy levels with p=', p, 'and N-p=', n_data - p) +48 raise ValueError(f'Cannot extract {k} energy levels with p={p} and N-p={n_data - p}') 49 50 # Construct the hankel matrices 51 matrix = [] @@ -185,7 +185,7 @@ 36 37 lengths = [len(d) for d in data] 38 if lengths.count(lengths[0]) != len(lengths): -39 raise Exception('All datasets have to have the same length.') +39 raise ValueError('All datasets have to have the same length.') 40 41 data_sets = len(data) 42 n_data = len(data[0]) @@ -193,9 +193,9 @@ 44 if p is None: 45 p = max(n_data // 2, k) 46 if n_data <= p: -47 raise Exception('The pencil p has to be smaller than the number of data samples.') +47 raise ValueError('The pencil p has to be smaller than the number of data samples.') 48 if p < k or n_data - p < k: -49 raise Exception('Cannot extract', k, 'energy levels with p=', p, 'and N-p=', n_data - p) +49 raise ValueError(f'Cannot extract {k} energy levels with p={p} and N-p={n_data - p}') 50 51 # Construct the hankel matrices 52 matrix = [] diff --git a/docs/pyerrors/obs.html b/docs/pyerrors/obs.html index 63becad6..df71bb85 100644 --- a/docs/pyerrors/obs.html +++ b/docs/pyerrors/obs.html @@ -1635,7 +1635,7 @@ 1299 raise ValueError('Manual derivative does not have correct shape.') 1300 elif kwargs.get('num_grad') is True: 1301 if multi > 0: -1302 raise Exception('Multi mode currently not supported for numerical derivative') +1302 raise NotImplementedError('Multi mode currently not supported for numerical derivative') 1303 options = { 1304 'base_step': 0.1, 1305 'step_ratio': 2.5} @@ -5557,7 +5557,7 @@ should agree with samples from a full bootstrap analysis up to O(1/N). 1300 raise ValueError('Manual derivative does not have correct shape.') 1301 elif kwargs.get('num_grad') is True: 1302 if multi > 0: -1303 raise Exception('Multi mode currently not supported for numerical derivative') +1303 raise NotImplementedError('Multi mode currently not supported for numerical derivative') 1304 options = { 1305 'base_step': 0.1, 1306 'step_ratio': 2.5}