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

Fix delete bug #73

Merged
merged 4 commits into from
Apr 5, 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 .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.5
current_version = 0.2.6
commit = True
tag = False

Expand Down
16 changes: 4 additions & 12 deletions pyscal_rdf/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def delete(self, ids=None, indices=None, condition=None, selection=False):
masks = self.atoms._generate_bool_list(ids=ids, indices=indices, condition=condition, selection=selection)
delete_list = [masks[self.atoms["head"][x]] for x in range(self.atoms.ntotal)]
delete_ids = [x for x in range(self.atoms.ntotal) if delete_list[x]]
actual_natoms = self.natoms
self.atoms._delete_atoms(delete_ids)

if self.graph is not None:
Expand All @@ -257,7 +258,7 @@ def delete(self, ids=None, indices=None, condition=None, selection=False):
self.add_vacancy(c, number=val)
#now we need to re-add atoms, so at to remove
self.graph.graph.remove((self.sample, CMSO.hasNumberOfAtoms, None))
self.graph.graph.add((self.sample, CMSO.hasNumberOfAtoms, Literal(self.natoms-val, datatype=XSD.integer)))
self.graph.graph.add((self.sample, CMSO.hasNumberOfAtoms, Literal(actual_natoms-val, datatype=XSD.integer)))
#revamp composition
#remove existing chem composution
chemical_species = self.graph.graph.value(self.sample, CMSO.hasSpecies)
Expand Down Expand Up @@ -288,23 +289,14 @@ def delete(self, ids=None, indices=None, condition=None, selection=False):
position_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Position'), CMSO.hasIdentifier).toPython()
species_identifier = self.graph.graph.value(URIRef(f'{self.sample}_Species'), CMSO.hasIdentifier).toPython()

#open the file for reading
with open(filepath, 'r') as fin:
data = json.load(fin)
positions = data[position_identifier]['value']
species = data[species_identifier]['value']

#clean up items
positions = [pos for count, pos in enumerate(positions) if count not in delete_ids]
species = [pos for count, pos in enumerate(species) if count not in delete_ids]

datadict = {
position_identifier:{
"value": positions,
"value": self.schema.atom_attribute.position(),
"label": "position",
},
species_identifier:{
"value": species,
"value": self.schema.atom_attribute.species(),
"label": "species",
},
}
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='pyscal_rdf',
version='0.2.5',
version='0.2.6',
author='Abril Azocar Guzman, Sarath Menon',
author_email='[email protected]',
description='Ontology based structural manipulation and quering',
Expand Down
Loading