def run_test(): zplus = kvector_t(0.0, 0.0, 1.0) zmin = kvector_t(0.0, 0.0, -1.0) # IntensityDataIOFactory.writeIntensityData(getSimulationIntensity(zplus, 1.0), 'polmagcylinders2_reference_00.int') # IntensityDataIOFactory.writeIntensityData(getSimulationIntensity(zplus, -1.0), 'polmagcylinders2_reference_01.int') # IntensityDataIOFactory.writeIntensityData(getSimulationIntensity(zmin, 1.0), 'polmagcylinders2_reference_10.int') # IntensityDataIOFactory.writeIntensityData(getSimulationIntensity(zmin, -1.0), 'polmagcylinders2_reference_11.int') diff = 0.0 diff += get_difference( getSimulationIntensity(zplus, 1.0).array(), get_reference_data('polmagcylinders2_reference_00.int.gz').getArray()) diff += get_difference( getSimulationIntensity(zplus, -1.0).array(), get_reference_data('polmagcylinders2_reference_01.int.gz').getArray()) diff += get_difference( getSimulationIntensity(zmin, 1.0).array(), get_reference_data('polmagcylinders2_reference_10.int.gz').getArray()) diff += get_difference( getSimulationIntensity(zmin, -1.0).array(), get_reference_data('polmagcylinders2_reference_11.int.gz').getArray()) diff /= 4.0 status = "OK" if diff > 2e-10: status = "FAILED" return "PolarizedDWBAZeroMag", "functional test: polarized DWBA with non-zero magnetic field", diff, status
def run_test(): result = runSimulation() # ba.IntensityDataIOFactory.writeIntensityData(result, 'polmagcylinders1_reference.int') reference = utils.get_reference_data('polmagcylinders1_reference.int.gz') diff = utils.get_difference(result.array(), reference.getArray()) status = "OK" if diff > 2e-10: status = "FAILED" return "PolarizedDWBAZeroMag", "Polarized DWBA with zero magnetic field", diff, status
def _create_bins(num_of_bins: int, diff: pd.DataFrame) -> [float]: labels = diff.index.values.tolist() # get list of all differences all_diff = [] # create buckets for i in range(len(labels)): for j in range(i): all_diff.append(utils.get_difference(labels[i], labels[j], diff)) # create bins _, bins = pd.qcut(all_diff, num_of_bins, retbins=True) bins = list(bins) return bins
def get_feature_from_bin(label_of_feature: int, bins: bs.EquisizedBins, diff: pd.DataFrame): feature = [0] * bins.get_number_of_bins() labels = utils.get_row_labels(diff) for other_label in labels: if other_label == label_of_feature: continue category = bins.get_category( utils.get_difference(label_of_feature, other_label, diff)) feature[category] += 1 # normalise feature = list(map(lambda x: float(x) / len(labels), feature)) return feature