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

Restructure query operators #132

Merged
merged 10 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading