-
Notifications
You must be signed in to change notification settings - Fork 33
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
__repr__ not working for SymmetryOperation #7
Comments
Hi I tried to reproduce this, but failed, using the following:
results in:
The SymmetryOperation.type field comes from the ctype and is an enum:
which, given your result, indicates uninitialised memory. generateSymmetryOperations uses calloc so that should not cause this issue (although e.g. sorting could mess that up) so more likely the memory has been reused (memory freed?). Could you provide operating system and c compiler info? And in case you can consistently reproduce this, what are the values of:
|
Is it possible for you to use conda for managing virtual environments? The bug appears, if one is working outside the context manager. ENV=chemcoord_libmsym
TEST_DIR=$(pwd)/$ENV
conda create -y --name $ENV
source activate $ENV
mkdir $TEST_DIR
cd $TEST_DIR
git clone https://github.com/mcocdawc/chemcoord.git
git clone https://github.com/mcodev31/libmsym.git
conda install -y numpy scipy pandas numba sortedcontainers sympy six
cd $TEST_DIR/libmsym
mkdir build
cd build
cmake -DMSYM_BUILD_PYTHON:BOOL=ON -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_INSTALL_PREFIX=$TEST_DIR/libmsym ../.
make install
cd bindings/python
pip install .
cd $TEST_DIR/chemcoord
pip install .
cd $TEST_DIR
cat > bug1.py<<EOF
import chemcoord as cc
import libmsym as msym
molecule = cc.Cartesian.read_xyz('chemcoord/tests/structures/MIL53_small.xyz', start_index=1)
def give_elements(molecule):
return [msym.Element(name=molecule.loc[i, 'atom'], coordinates=molecule.loc[i, ['x', 'y', 'z']])
for i in molecule.index]
with msym.Context(elements=give_elements(molecule)) as ctx:
ctx.find_symmetry()
symmetry_operations = ctx.symmetry_operations
print(symmetry_operations[0].__class__.__name__)
print(symmetry_operations[0]._names)
print(symmetry_operations[0].type)
print(ctx.point_group)
for sop in symmetry_operations:
print(sop)
EOF
python bug1.py
cat > bug2.py<<EOF
import chemcoord as cc
import libmsym as msym
molecule = cc.Cartesian.read_xyz('chemcoord/tests/structures/MIL53_small.xyz', start_index=1)
def give_elements(molecule):
return [msym.Element(name=molecule.loc[i, 'atom'], coordinates=molecule.loc[i, ['x', 'y', 'z']])
for i in molecule.index]
with msym.Context(elements=give_elements(molecule)) as ctx:
ctx.find_symmetry()
symmetry_operations = ctx.symmetry_operations
print(symmetry_operations[0].__class__.__name__)
print(symmetry_operations[0]._names)
print(symmetry_operations[0].type)
print(ctx.point_group)
for sop in symmetry_operations:
print(sop)
EOF
python bug2.py
cat > bug3.py<<EOF
import chemcoord as cc
import libmsym as msym
molecule = cc.Cartesian.read_xyz('chemcoord/tests/structures/MIL53_small.xyz', start_index=1)
def give_elements(molecule):
return [msym.Element(name=molecule.loc[i, 'atom'], coordinates=molecule.loc[i, ['x', 'y', 'z']])
for i in molecule.index]
with msym.Context(elements=give_elements(molecule)) as ctx:
ctx.find_symmetry()
symmetry_operations = ctx.symmetry_operations
print(symmetry_operations[0].__class__.__name__)
print(symmetry_operations[0]._names)
print(symmetry_operations[0].type)
print(ctx.point_group)
print(symmetry_operations[0].order)
print(symmetry_operations[0].power)
print(symmetry_operations[0].orientation)
print(symmetry_operations[0].conjugacy_class)
EOF
python bug3.py
source activate
conda remove -y --name $ENV --all The outpot of bug1.py
The outpot of bug2.py
The outpot of bug3.py
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
No LSB modules are available. Python 3.6.1 :: Anaconda custom (64-bit) |
Thanks, that helped. I can't use conda on my current machine (need my current setup for work), but I'll set up a VM if needed. I reproduced the bug by calling Turns out simple fields of This is annoying, but makes sense I guess. This affects more than just the Also have some thoughts on reimplementing a version completely in python that can use some more interesting algorithms cumbersome to implement in C. |
Glad it helped and thanks for the workaround. |
Ok now another possible solution. What is your opininion about making copies, when setting the attributes of
|
Yeah, that's what I meant with
But it doesn't just apply to symmetry operations (basis functions, character table etc.) |
Hej Marcus,
I try to use your library for detecting pointgroups in my python module chemcoord.
There is a bug in
__repr__
of your SymmetryOperation class which can be reproduced with this code:The command
symmetry_operations[0]._names[symmetry_operations[0].type]
raises now anIndexError
, which leads to the bug in__repr__
. I gues that some byte offset from you C-code has to be calculated into symmetry_operations[0].type.The text was updated successfully, but these errors were encountered: