Coverage for lode / models / individual.py: 86%

14 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-11-22 15:54 +0000

1"""Individual: an OWL named individual.""" 

2from .resource import Resource 

3 

4class Individual(Resource): 

5 """ 

6 Represents an individual instance of a class (owl:NamedIndividual). 

7 Extends Resource with the relations specific to OWL individuals. 

8 """ 

9 

10 def __init__(self, **kwargs): 

11 """Create an individual with empty is_same_as and is_different_from lists.""" 

12 super().__init__(**kwargs) 

13 

14 # Relations with Individual 

15 self.is_same_as = [] # 0..* 

16 self.is_different_from = [] # 0..* 

17 # Relations with Concept (inherited but made explicit here, because the cardinality changes) 

18 # self.has_type = [] # 1..*  

19 

20 # def get_has_type(self): 

21 # return list(self.has_type) 

22 

23 # def set_has_type(self, concept): 

24 # self.has_type.append(concept) 

25 

26 def get_is_same_as(self): 

27 """Return a copy of is_same_as [0..*].""" 

28 return list(self.is_same_as) 

29 

30 def set_is_same_as(self, individual): 

31 """Add an individual to is_same_as [0..*].""" 

32 self.is_same_as.append(individual) 

33 

34 def get_is_different_from(self): 

35 """Return a copy of is_different_from [0..*].""" 

36 return list(self.is_different_from) 

37 

38 def set_is_different_from(self, individual): 

39 """Add an individual to is_different_from [0..*].""" 

40 self.is_different_from.append(individual)