limebit / medmodels

MedModels is a high-speed RWE framework to apply the latest methods from scientific research to medical data.
https://www.medmodels.de
BSD 3-Clause "New" or "Revised" License
4 stars 0 forks source link

feat: add type narrowing to interface #214

Closed JabobKrauskopf closed 2 months ago

JabobKrauskopf commented 2 months ago

This PR adds type narrowing operations to the interface

usability example:

Medrecord node attributes with mixed data types (non comparable)

def query(node: NodeOperand):
    node.attribute("value").max().less_than(5)

# Throws Error because of mixed data types with hint to use narrowing operation
medrecord.select_nodes(query)
def query(node: NodeOperand):
    value_attribute = node.attribute("value")
    value_attribute.is_int()
    value_attribute.max().less_than(5)

# Doesn't throw error
medrecord.select_nodes(query)

Expected tests to fail (same as in the previous PR):