Skip to content

Commit

Permalink
Merge pull request #132 from pyscal/restructure_query_operators
Browse files Browse the repository at this point in the history
Restructure query operators
  • Loading branch information
srmnitc authored Jun 27, 2024
2 parents ba90072 + 6c462b0 commit ea53920
Show file tree
Hide file tree
Showing 16 changed files with 1,579 additions and 104 deletions.
2 changes: 1 addition & 1 deletion atomrdf/network/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ def create_query(self, source, destinations, enforce_types=True):
#iterate through the list, if they have condition parents, add them explicitely
for destination in destinations:
for parent in destination._condition_parents:
if parent.name not in [d.name for d in destinations]:
if parent.variable_name not in [d.variable_name for d in destinations]:
destinations.append(parent)

#all names are now collected, in a list of lists
Expand Down
1 change: 1 addition & 0 deletions atomrdf/network/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,6 @@ def read_ontology():
combo.add_path(("asmo:InteratomicPotential", "cmso:hasReference", "string"))
combo.add_path(("asmo:InteratomicPotential", "rdfs:label", "string"))


# return
return combo
15 changes: 10 additions & 5 deletions atomrdf/network/term.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,15 @@ def _is_data_node(self):


def _create_condition_string(self, condition, val):
return f'(?{self.query_name}{condition}"{val}"^^xsd:{self._clean_datatype(self.range[0])})'
return f'(?{self.variable_name}{condition}"{val}"^^xsd:{self._clean_datatype(self.range[0])})'

# overloading operators
def __eq__(self, val):
"""
=
"""
# self._is_number(val)
#print("eq")
#print(f'lhs {self} rhs {val}')
self._is_data_node()
item = copy.deepcopy(self)
item._condition = item._create_condition_string("=", val)
Expand Down Expand Up @@ -316,6 +317,8 @@ def __ge__(self, val):
return item

def __gt__(self, val):
#print("gt")
#print(f'lhs {self} rhs {val}')
self._is_number(val)
self._is_data_node()
item = copy.deepcopy(self)
Expand Down Expand Up @@ -358,9 +361,11 @@ def __or__(self, term):
def or_(self, term):
self.__or__(term)

def __rshift__(self, term):
item = copy.deepcopy(term)
item._parents.append(copy.deepcopy(self))
def __matmul__(self, term):
#print("matmul")
#print(f'lhs {self} rhs {term}')
item = copy.deepcopy(self)
item._parents.append(copy.deepcopy(term))
return item

def refresh_condition(self):
Expand Down
2 changes: 1 addition & 1 deletion examples/01_getting_started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3589,7 +3589,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/02_grain_boundaries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1617,7 +1617,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/03_point_defects.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5214,7 +5214,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/05_interstitials.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2517,7 +2517,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/07_dislocation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2733,7 +2733,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion examples/09_structure_modification.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8482,7 +8482,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
"version": "3.1.-1"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit ea53920

Please sign in to comment.