Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHould be able to deal with the is operator #224

Open
gordonwatts opened this issue Mar 20, 2024 · 0 comments
Open

SHould be able to deal with the is operator #224

gordonwatts opened this issue Mar 20, 2024 · 0 comments

Comments

@gordonwatts
Copy link
Member

In the following, at the very end, we should be able to do is True - right now we have to do == True

@pytest.mark.skipif(not run_long_running_tests, reason="Skipping long running test")
def test_class_enum_use_inline():
    """Use a enum as part of the actual query"""

    # Define the calo clusters return
    from func_adl_xAOD.atlas.xaod.event_collections import (
        atlas_xaod_collections,
    )

    atlas_xaod_collections.append(
        EventCollectionSpecification(
            "atlas",
            "CaloClusters",
            ["xAODCaloEvent/CaloClusterContainer.h"],
            atlas_xaod_event_collection_collection(
                "xAOD::CaloClusterContainer", "xAOD::CaloCluster"
            ),
            ["xAODCaloEvent"],
        ),
    )

    # Define the num class for future reference
    class xAOD:
        class CaloCluster_v1:
            class ClusterSize(Enum):
                SW_55ele = 1
                SW_35ele = 2
                SW_37ele = 3
                SW_55gam = 4
                SW_35gam = 5
                SW_37gam = 6
                SW_55Econv = 7
                SW_35Econv = 8
                SW_37Econv = 9
                SW_softe = 10
                Topo_420 = 11
                Topo_633 = 12
                SW_7_11 = 13
                SuperCluster = 14
                Tower_01_01 = 15
                Tower_005_005 = 16
                Tower_fixed_area = 17
                CSize_Unknown = 99

    # Declare the enum class
    ctyp.define_enum(
        "xAOD.CaloCluster_v1",
        "ClusterSize",
        [e.name for e in xAOD.CaloCluster_v1.ClusterSize],
    )

    # Define the `getConstituentsSignalState` method
    ctyp.add_method_type_info(
        "xAOD::CaloCluster_v1",
        "clusterSize",
        ctyp.terminal("xAOD::CaloCluster_v1::ClusterSize", tree_type="int"),
    )

    # fmt: off
    training_df = as_pandas(
        f_exot_15.SelectMany(lambda e: e.CaloClusters("egammaClusters"))
        .Select(lambda c: c.clusterSize() == xAOD.CaloCluster_v1.ClusterSize.SuperCluster)
    )
    # fmt: on

    assert len(training_df) > 0
    print(training_df.col1)
    assert all(training_df.col1 is True)
    ```
    
<!-- Edit the body of your new issue then click the"Create Issue" button in the top right of the editor. The first line will be the issue title. Assignees and Labels follow after a blank line. Leave an empty line before beginning the body of the issue. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant