I have a problem with executing the function processing.results() in oemof.
It was working before, but after an update it didn't work any more.
Does anyone know how to fix it or which interpreter I need for oemof - oemof test says all is installed correct. Or is my code wrong?
Code:
64/# OPTIMIZATION MODEL
65/equipmentList = (electricity_bus, heat_bus, electricity_grid, electricity_supply,
electricity_storage, heat_supply, heat_storage, heat_pump, photovoltaics, excess_electricity)
66/for item in equipmentList:
67/ optimizationSystem.add(item)
68/model = solph.Model(optimizationSystem)
69/model.write('optimizationSystem_model.lp', io_options={'symbolic_solver_labels': True})
70/model.solve(solver='gurobi', solve_kwargs={'tee': True})
71/results = solph.processing.results(model)
Failure-Message:
Traceback (most recent call last):
File "C:/Users/TKurz/Desktop/NEFI Hackathon/Main.py", line 71, in <module>
results = solph.processing.results(model)
File "C:\Users\TKurz\AppData\Local\Programs\Python\Python38\lib\site-packages\oemof\solph\processing.py", line 125, in results
df = create_dataframe(om)
File "C:\Users\TKurz\AppData\Local\Programs\Python\Python38\lib\site-packages\oemof\solph\processing.py", line 89, in create_dataframe
for i in getattr(bv, "_index"):
AttributeError: 'IndexedVar' object has no attribute '_index'
THX for any help!
Yours Thomas
Related
Please help me solve this, I tried many solution but it doesn't work. In the Jupyter Notebook the Output I want are getting display but in Streamlit its getting error. I am newbie practicing ML.
`
df = pd.read_csv("book1.csv")
corrMatrix = df.corr(method='pearson')
corrMatrix.head(17)
def get_similar(question, rating):
similar_ratings = corrMatrix[question] * (rating - 2.5)
similar_ratings = similar_ratings.sort_values(ascending=False)
return similar_ratings
ratings = [(q1), (q2), (q3), (q4), (q5), (q6), (q7), (q8), (q9), (q10),
(q11), (q12), (q13), (q14), (q15), (q16), (q17)]
similar = pd.DataFrame()
for question, rating in ratings:
similar.append(get_similar(question, rating), ignore_index=True)
similar.head(10)
similars = similar.sum().sort_values(ascending=False).head(3)
df1 = pd.DataFrame(similar)
st.write(df1)`
This is the Error I get.
Traceback (most recent call last):
File "c:\users\admin\desktop\thesissys\venv\lib\site-
packages\streamlit\scriptrunner\script_runner.py", line 554, in _run_script
exec(code, module.__dict__)
File "C:\Users\admin\Desktop\ThesisSys\venv\app.py", line 71, in <module>
show_predict()
File "C:\Users\admin\Desktop\ML\venv\predict_page.py", line 386, in show_predict
for question, rating in ratings:
TypeError: cannot unpack non-iterable int object
I am trying to run a simple example using sbmltoodepy and I am receiving the following error.
Traceback (most recent call last):
File "C:\Users\AppData\Roaming\JetBrains\PyCharm2021.2\scratches\scratch_79.py", line 8, in
ParseAndCreateModel(inputFilePath)#, jsonFilePath=None, outputFilePath=None)#, className="SBMLmodel")
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\sbmltoodepy\utilities.py", line 66, in ParseAndCreateModel
modelData = ParseSBMLFile(inputFilePath)
File "C:\Users\AppData\Roaming\Python\Python39\site-packages\sbmltoodepy\parse.py", line 284, in ParseSBMLFile
assert(doc.getNumErrors() == 0)
AssertionError
Here is the code that I used.
import sbmltoodepy
from sbmltoodepy import ParseAndCreateModel
inputFilePath = "E:/Borisov2009_insulin_EGF.xml"
ParseAndCreateModel(inputFilePath, jsonFilePath=None, outputFilePath=None, className="SBMLmodel")
model = sbmltoodepy.SBMLmodel()
model.RunSimulation(1, absoluteTolerance = 1e-12, relativeTolerance = 1e-6)
Thank you in advance for your time.
While running the AutoEncoder model in PyTorch, I found a strange error.
My code:
model = AutoEncoder(num_items, args.inner_layers, num_items, da=args.num_attention, dropout_rate=args.dropout_rate)
item_vector = self.linear1.weight[:, T.LongTensor(batch_item_index[0].astype(np.int32))]
inner_product = item_vector.t().mm(self.linear4.weight.t())
I tried to make the index start from 0 after seeing the explanation that the cause of the batch index was -1 among little similar problems(https://github.com/jwyang/faster-rcnn.pytorch/issues/311), but it did not work.
This is the first time I haven't had a similar question on Stack Overflow, what am I doing wrong?
Traceback (most recent call last):
File "run.py", line 155, in <module>
main()
File "run.py", line 151, in main
train_autoencoder(train_matrix, test_set)
File "run.py", line 86, in train_autoencoder
y_pred = model(batch_item_index, place_correlation)
File "C:\Users\user\anaconda3\envs\saenad\lib\site-packages\torch\nn\modules\module.py", line 491, in __call__
result = self.forward(*input, **kwargs)
File "C:\Users\user\saenad\model.py", line 58, in forward
inner_product = item_vector.t().mm(self.linear4.weight.t())
RuntimeError: invalid argument 1: out of range at c:\programdata\miniconda3\conda-bld\pytorch_1524543037166\work\aten\src\th\generic/THTensor.cpp:454**
I found the item_vector is empty tensor([[]])!
So I added the code to handle an exception if item_vector.Size is 0 with below code.
if item_vector.shape == torch.Size([0]):
continue
<-- it works.
Hope this helps someone with the same error.:)
code:-
import wolframalpha
wolframappid = wolframalpha.Client("XXXXXX-XXXXXXXXXX")
res = wolframappid.query('temperature in mumbai')
answer = next(res.results).text
print(answer)
result:-
Traceback (most recent call last):
File "c:/Users/Harsh/Desktop/Harsh Python Projects/Test.py", line 5, in <module>
answer = next(res.results).text
File "C:\Users\Harsh\AppData\Roaming\Python\Python36\site-packages\wolframalpha\__init__.py", line 166, in text
return next(iter(self.subpod)).plaintext
ValueError: dictionary update sequence element #0 has length 1; 2 is required
any ideas how to solve this issue? i have also tried next(res.results).plaintext but another error pops up..
code:-
import wolframalpha
wolframappid = wolframalpha.Client("XXXXXX-XXXXXXXXXX")
res = wolframappid.query('temperature in mumbai')
answer = next(res.results).plaintext
print(answer)
result:-
Traceback (most recent call last):
File "C:\Users\Harsh\AppData\Roaming\Python\Python36\site-packages\wolframalpha\__init__.py", line 86, in __getattr__
val = self[name] if name in self else self[attr_name]
KeyError: '#plaintext'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:/Users/Harsh/Desktop/Harsh Python Projects/Test.py", line 5, in <module>
answer = next(res.results).plaintext
File "C:\Users\Harsh\AppData\Roaming\Python\Python36\site-packages\wolframalpha\__init__.py", line 88, in __getattr__
raise AttributeError(name)
AttributeError: plaintext
thanks in advance...
I am getting
TypeError: unhashable type: 'list'
when I try to run the example from the boto documentation:
results = mytable.batch_get(keys=[{'username':'johndoe'},{'username':'jane'},{'username':'fred'},])
for res in results:
print res['username']
I don't see anything I could have done wrong, but obviously there is something.
Any suggestions?
edit, adding stacktrace:
Traceback (most recent call last):
File "testdynamolocal.py.bak", line 25, in <module>
for res in results:
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/boto/dynamodb2/results.py", line 62, in __next__
self.fetch_more()
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/dynamodb2/results.py", line 183, in fetch_more
results = self.the_callable(*args, **kwargs)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/boto/dynamodb2/table.py", line 1337, in _batch_get
'Keys': [],
TypeError: unhashable type: 'list'
Turned out to be a mistake in getting 'mytable', posting here in case anyone else has a similar bad time:
I was doing this:
for table in tables.values():
mytable = Table(table, connection=conn)
results = mytable.batch_get(keys=[{'username':'johndoe'},{'username':'jane'},{'username':'fred'},])
...
But 'table' was getting a list instead of a string from tables.values(), so this works:
mytable = Table(table[0], connection=conn)
I am not thrilled with where the error was actually surfacing, but totally a problem I should have seen earlier.