def test_dust_mass(self): """ This function ... :return: """ # Inform the user log.info("Testing the dust mass ...") ndigits = 4 nbits = numbers.binary_digits_for_significant_figures(ndigits) print(str(nbits) + " bits for " + str(ndigits) + " digits") mass_range = parsing.quantity_range("1500000.0 Msun > 300000000.0 Msun") unit = "Msun" minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value value = parse_quantity("1.5e7 Msun").to(unit).value # Test : ROUNDING IN TEST BUT NOT IN BETWEEN CONVERSION!! if light_test_from_number_rounding(value, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed")
def test_dust_mass(self): """ This function ... :return: """ # Inform the user log.info("Testing the dust mass ...") ndigits = 4 nbits = numbers.binary_digits_for_significant_figures(ndigits) print(str(nbits) + " bits for " + str(ndigits) + " digits") mass_range = parsing.quantity_range( "1500000.0 Msun > 300000000.0 Msun") unit = "Msun" minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value value = parse_quantity("1.5e7 Msun").to(unit).value # Test : ROUNDING IN TEST BUT NOT IN BETWEEN CONVERSION!! if light_test_from_number_rounding(value, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed")
def test_dust_mass_second(self): """ This function ... :return: """ # Inform the user log.info("Second dust mass test ...") ndigits = 4 genome = [1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0] check = [1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] nbits = len(genome) print(nbits) unit = "Msun" mass_range = parsing.quantity_range( "1500000.0 Msun > 300000000.0 Msun") minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value if test_from_binary_string_rounding(genome, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") if test_from_binary_string_rounding(check, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") genome_mass = numbers.binary_string_to_float(genome, low, high, nbits) rounded_genome_mass = numbers.round_to_n_significant_digits( genome_mass, ndigits) genome_mass_to_binary = numbers.float_to_binary_string( genome_mass, low, high, nbits) rounded_genome_mass_to_binary = numbers.float_to_binary_string( rounded_genome_mass, low, high, nbits) print("original:", genome_mass) print("rounded:", rounded_genome_mass) print("genome:", genome) print("original to binary:", genome_mass_to_binary) print("rounded to binary: ", rounded_genome_mass_to_binary) print("check: ", check)
def test_gray_conversion_dynamic(self): """ This function ... :return: """ # Inform the user log.info("Testing the Gray code conversions (dynamic nbits) ...") max_number = 15 if check_gray_conversion(max_number): log.success("Test succeeded") else: log.error("Test failed")
def test_dust_mass_with_rounding(self): """ This fucntion ... :return: """ # Inform the user log.info("Testing dust mass with rounding ...") ndigits = 4 nbits = numbers.binary_digits_for_significant_figures(ndigits) #print(str(nbits) + " bits for " + str(ndigits) + " digits") mass_range = parsing.quantity_range( "1500000.0 Msun > 300000000.0 Msun") unit = "Msun" minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value # (FROM ERROR RESULTS IN MODELING:) # WITH ROUNDING: binary_string_a = [1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1] binary_string_b = [1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0] if test_from_binary_string_rounding(binary_string_a, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") if test_from_binary_string_rounding(binary_string_b, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") # Convert to numbers number_a = numbers.binary_string_to_float(binary_string_a, low, high, nbits) number_b = numbers.binary_string_to_float(binary_string_b, low, high, nbits) if test_from_number_rounding(number_a, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") if test_from_number_rounding(number_b, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed")
def test_gray_generation(self): """ This function ... :return: """ #n = int(raw_input()) # Inform the user log.info("Testing the generation of Gray code ...") n = 14 if check_gray_generation(n): log.success("Test succeeded") else: log.error("Test failed")
def test_dust_mass_second(self): """ This function ... :return: """ # Inform the user log.info("Second dust mass test ...") ndigits = 4 genome = [1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0] check = [1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0] nbits = len(genome) print(nbits) unit = "Msun" mass_range = parsing.quantity_range("1500000.0 Msun > 300000000.0 Msun") minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value if test_from_binary_string_rounding(genome, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") if test_from_binary_string_rounding(check, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") genome_mass = numbers.binary_string_to_float(genome, low, high, nbits) rounded_genome_mass = numbers.round_to_n_significant_digits(genome_mass, ndigits) genome_mass_to_binary = numbers.float_to_binary_string(genome_mass, low, high, nbits) rounded_genome_mass_to_binary = numbers.float_to_binary_string(rounded_genome_mass, low, high, nbits) print("original:", genome_mass) print("rounded:", rounded_genome_mass) print("genome:", genome) print("original to binary:", genome_mass_to_binary) print("rounded to binary: ", rounded_genome_mass_to_binary) print("check: ", check)
def test_gray_conversion_fixed(self): """ This function ... :return: """ # Inform the user log.info("Testing the Gray code conversions (fixed nbits) ...") max_number = 15 nbits = numbers.nbits_for_integer(max_number) if check_gray_conversion(max_number, nbits): log.success("Test succeeded") else: log.error("Test failed")
def test_speed_of_light_experimental(self): """ This function ... :return: """ # Inform the user log.info("Testing speed of light ...") ndigits = 3 #nbits = numbers.nbits_for_ndigits(ndigits) minimum = 0.01 * speed_of_light maximum = speed_of_light unit = "km/s" # Convert value to binary value = (0.333 * speed_of_light).to(unit).value low = minimum.to(unit).value high = maximum.to(unit).value nbits = numbers.nbits_for_ndigits_experimental(ndigits, low, high) print(str(nbits) + " bits for " + str(ndigits) + " digits") # Test without rounding IN CONVERSION, BUT FOR COMPARISON THERE IS ROUNDING if light_test_from_number_rounding(value, low, high, ndigits, experimental=True): log.success("Test succeeded") else: log.error("Test failed") # With rounding if test_from_number_rounding(value, low, high, ndigits, experimental=True): log.success("Test succeeded") else: log.error("Test failed")
def test_speed_of_light(self): """ This function ... :return: """ # Inform the user log.info("Testing speed of light ...") ndigits = 3 nbits = numbers.nbits_for_ndigits(ndigits) print(str(nbits) + " bits for " + str(ndigits) + " digits") minimum = 0.01 * speed_of_light maximum = speed_of_light unit = "km/s" # Convert value to binary value = (0.333 * speed_of_light).to(unit).value low = minimum.to(unit).value high = maximum.to(unit).value #print(value) #print(low) #print(high) # Test without rounding IN CONVERSION, BUT FOR COMPARISON THERE IS ROUNDING if light_test_from_number_rounding(value, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") # With rounding if test_from_number_rounding(value, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed")
def test_dust_mass_with_rounding(self): """ This fucntion ... :return: """ # Inform the user log.info("Testing dust mass with rounding ...") ndigits = 4 nbits = numbers.binary_digits_for_significant_figures(ndigits) #print(str(nbits) + " bits for " + str(ndigits) + " digits") mass_range = parsing.quantity_range("1500000.0 Msun > 300000000.0 Msun") unit = "Msun" minimum = mass_range.min maximum = mass_range.max low = minimum.to(unit).value high = maximum.to(unit).value # (FROM ERROR RESULTS IN MODELING:) # WITH ROUNDING: binary_string_a = [1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1] binary_string_b = [1, 0, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0] if test_from_binary_string_rounding(binary_string_a, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") if test_from_binary_string_rounding(binary_string_b, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") # Convert to numbers number_a = numbers.binary_string_to_float(binary_string_a, low, high, nbits) number_b = numbers.binary_string_to_float(binary_string_b, low, high, nbits) if test_from_number_rounding(number_a, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed") if test_from_number_rounding(number_b, low, high, ndigits): log.success("Test succeeded") else: log.error("Test failed")
for path, name in fs.files_in_path(host_run_path, extension="sim", returns=["path", "name"], sort=int): # Skip if config.ids is not None and int(name) not in config.ids: continue # Inform the user log.info("Removing simulation " + name + " ...") # Fully clear if config.full: # Debugging log.debug("Removing the remote files and directories ...") # Load the simulation simulation = RemoteSimulation.from_file(path) # Remove the simulation from the remote simulation.remove_from_remote(remote, full=True) # Debugging log.debug("Removing the simulation file ...") # Remove the file fs.remove_file(path) # Success log.success("All cleared for host '" + host_id + "'") # -----------------------------------------------------------------
if fs.is_file(local_path): log.warning( "The '" + name + "' remotely cached image is still present locally. Keeping this file and throwing the remote file away." ) continue else: # Infomr log.info("Downloading the '" + name + "' file to [" + origin_path + "] ...") # Download remote.download_file_to(path, origin_path, remove=True) # Success log.success("Succesfully retrieved the '" + name + "' image ...") # Inform the user log.info("Clearing the remote data structure ...") # Clear the entire data structure now remote.clear_directory(remote_data_path) # ----------------------------------------------------------------- # Get the image paths paths, error_paths = get_data_image_and_error_paths(modeling_path) # ----------------------------------------------------------------- # Get the initial dataset
local_version = None # Check present and version remotely if dependency in remote_packages: remotely_present = True remote_version = remote_packages[dependency] else: # Check again for present by importing remotely_present = remote_python.is_present_package(dependency) remote_version = None # If present both locally and remotely if locally_present and remotely_present: if config.versions: if local_version is None and remote_version is not None: log.warning(dependency + ": local version unknown") elif remote_version is None and local_version is not None: log.warning(dependency + ": remote version unknown") elif remote_version is None and local_version is None: log.warning(dependency + ": local and remote version unknown") elif local_version == remote_version: log.success(dependency + ": OK") else: log.warning(dependency + ": version " + local_version + " locally and version " + remote_version + " remotely") else: log.success(dependency + ": OK") # Not present on at least one system elif remotely_present and not locally_present: log.error(dependency + ": not present on this system") elif locally_present and not remotely_present: log.error(dependency + ": not present on remote '" + config.remote + "'") else: log.error(dependency + ": not present on either this sytem or remote '" + config.remote + "'") # -----------------------------------------------------------------
remotely_present = rmeote_python.is_present_package(dependency) remote_version = None # If present both locally and remotely if locally_present and remotely_present: if config.versions: if local_version is None and remote_version is not None: log.warning(dependency + ": local version unknown") elif remote_version is None and local_version is not None: log.warning(dependency + ": remote version unknown") elif remote_version is None and local_version is None: log.warning(dependency + ": local and remote version unknown") elif local_version == remote_version: log.success(dependency + ": OK") else: log.warning(dependency + ": version " + local_version + " locally and version " + remote_version + " remotely") else: log.success(dependency + ": OK") # Not present on at least one system elif remotely_present and not locally_present: log.error(dependency + ": not present on this system") elif locally_present and not remotely_present: log.error(dependency + ": not present on remote '" + config.remote + "'") else:
sort=int): # Skip if config.ids is not None and int(name) not in config.ids: continue # Inform the user log.info("Removing simulation " + name + " ...") # Fully clear if config.full: # Debugging log.debug("Removing the remote files and directories ...") # Load the simulation simulation = RemoteSimulation.from_file(path) # Remove the simulation from the remote simulation.remove_from_remote(remote, full=True) # Debugging log.debug("Removing the simulation file ...") # Remove the file fs.remove_file(path) # Success log.success("All cleared for host '" + host_id + "'") # -----------------------------------------------------------------
if fs.is_file(backup_filepath): # already corrected # Check corrected = Frame.from_file(path) backup = Frame.from_file(backup_filepath) ratio = corrected / backup ratios = ratio[np.isfinite(ratio)] if not np.all(np.isclose(ratios, factor)): raise RuntimeError("Correction was not OK for " + prep_name + " after the " + step + " step: mean ratio of " + str(np.mean(ratios))) log.success("The " + prep_name + " image after the " + step + " step has already been corrected (locally)") continue else: pass # continue below (do correction) else: # remote if remote.is_file(backup_filepath): # already corrected # Check? log.success("The " + prep_name + " image after the " + step + " step has already been corrected (remotely)") continue