import re


def is_dimensionless_standard_name(xml_tree, standard_name):
    """
    Returns True if the units for the associated standard name are
    dimensionless.  Dimensionless standard names include those that have no
    units and units that are defined as constant units in the CF standard name
    table i.e. '1', or '1e-3'.
    """
    # standard_name must be string, so if it is not, it is *wrong* by default
    if not isinstance(standard_name, str):
        return False
    found_standard_name = xml_tree.find(".//entry[@id='{}']".format(standard_name))
    if found_standard_name is not None:
        canonical_units = found_standard_name.find("canonical_units")
        # so far, standard name XML table includes
        # 1 and 1e-3 for constant units, but expanding to valid udunits
        # prefixes to be on the safe side
        # taken from CF Table 3.1 of valid UDUnits prefixes
        dimless_units = r"1(?:e-?(?:1|2|3|6|9|12|15|18|21|24))?$"
        return canonical_units is None or re.match(dimless_units, canonical_units.text)
    # if the standard name is not found, assume we need units for the time being
    else:
        return False