Pymatgen XRD Plot - pymatgen

I am following the XRD plot tutorial and as it told in this tutorial I imported
from pymatgen import Lattice, Structure
from pymatgen.analysis.diffraction.xrd import XRDCalculator
from IPython.display import Image, display
%matplotlib inline
And after defining the structure I try to plot it with these commands
c = XRDCalculator()
c.show_xrd_plot(structure)
But I bump into this error: 'no attribute 'show_xrd_plot'
AttributeError: 'XRDCalculator' object has no attribute 'show_xrd_plot'
What should I do to make it work, many thanks in advance,
Happy Thanksgiving

The XRD tutorial of pymatgen is updated and xrd_show_plot it changed to
c.show_plot(structure)

Related

I can't work out how to tree shake chartjs with vue3

I'm trying to tree shale chart.js with vue3 but dont know what i'm doing, I currently import the whole chart.js using: import Chart from 'chart.js/auto' but how can i import only the needed bits , so as to make ny build smaller?
as stated in the docs here you need to import and register all the elements you are using:
import {Chart, DoughnutController, ArcElement} from 'chart.js';
Chart.register(DoughnutController, ArcElement)
Instead of importing the DoughnutController and ArcElement you need to import and register the elements you are using.

"export 'default' (imported as 'Chart') was not found in 'chart.js'

Hi im getting this issue and can't quite figure why its saying it. im using vue3 with tailwind.
""export 'default' (imported as 'Chart') was not found in 'chart.js'"
Guess you are trying to import chart.js like this import Chart from 'chart.js', since chart.js v3 chart.js is treeshakable so you will have to import and register all the components you want to use or import and register everything with the auto import like this: import Chart from 'chart.js/auto'
Docs: https://www.chartjs.org/docs/master/getting-started/integration.html#bundlers-webpack-rollup-etc
For me, I just had to downgrade from chart.js#3.x to chart.js#2.9.4

import error when organizing django models in sperate files

Following the django docu I wanted to seperate my models into different files model1.py and model2.py. I also imported both of them in the __init__.py. But because they have a relationship, I need to import each of them in the other file. Now I get an error for from .model1 import Model1 that says
ImportError: cannot import name 'Model1'
is there a problem because I want to import within model2.py a class from model1.py that itself is importing from model2.py?
You might say, separating each model in a different file is normally not done in django. But I think it would be much better arranged when you have one file for one model.
This caused because of circular imports. from a import b and from b import a!. Please remove that by splitting the models properly.

Only in py.test file, usage of a nested(word?) imported variable/function fails with NameError

I have a python structure like this:
mymodule/
globalconfig.py # variables to set environment, etc
work.py # has: from mymodule.globalconfig import *
__init__.py
tests/
testspart1/
test_work.py # has: from mymodule.work import *
From inside work.py, all is well and I can access my global config variables and functions.
From inside test_work.py, I cannot access those variables, even if I add a second import,
from mymodule.globalconfig import *
Why is this? I wanted to use the same syntax as used in my modules.
thank you!
I am using py2.7 and, to get nice rspec-style outputs and verbose diffs,
pytest --spec -vv
Ref;
1.This answer reminded me I could use another format of import. If there are no other answers I will post my workaround. how to share a variable across modules for all tests in py.test
The import syntax that worked for me was directly importing the nested python file in addition to importing the file under test.
from mymodule.work import *
import mymodule.globalconfig as myconfigs
I assume it's a name clash or import circularity issue, but I could not figure out what the problem was. It took me a while so I wanted to be sure to post the solution for future me and others.

How to integrate in Python inside For loop

I would like to use scipy's integrate.simps to get a integrated function from a data sample.
Data sample is getting calculated inside For loop (variable fx).
In the same step I store integrated values in the variable intfx.
import numpy as np
import pylab as pl
from scipy import integrate
t=np.arange(0,10.01,0.01)
fx=[]
intfx=[]
counter=0
for i in t:
counter+=1
fx.append(np.sin(i))
intfx.append(fx[-1]+integrate.trapz(fx[-2:], dx=0.1))
pl.plot(t,fx)
pl.plot(t,intfx)
pl.show()
On plots it can be seen that the two functions are very similar, which is obviously wrong.
Can anyone help me with this?
Made a stupid mistake.
Line:
intfx.append(fx[-1]+integrate.trapz(fx[-2:], dx=0.1))
should look like this:
intfx.append(intfx[-1]+integrate.trapz(fx[-2:], dx=0.1))