What can cause an Assertion Error while running in Ursina? - assertion

I'm pretty new to programming with Python and am starting to learn how to use Ursina Game Engine...
Currently I'm running Python 3.9.4 through IDLE. I looked up a YouTube playlist that goes through different activities using Ursina. However I hit a snag with one of the videos. I keep receiving an Assertion Error even though I copied the code exactly as it is shown in the video.
Here is the complete Error I'm receiving:
= RESTART: C:/Users/Charbel/Desktop/Ursina Tutorials/smooth follow - flying dragon.py
package_folder: C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\ursina
asset_folder: C:\Users\Charbel\Desktop\Ursina Tutorials
blender_paths:
{'2.7': WindowsPath('C:/Program Files/Blender Foundation/Blender/blender.exe'),
'2.8': WindowsPath('C:/Program Files/Blender Foundation/Blender 2.83/blender.exe'),
'default': WindowsPath('C:/Program Files/Blender Foundation/Blender 2.83/blender.exe')}
screen resolution: (1366, 768)
size; LVector2f(1092, 614)
render mode: default
development mode: True
application successfully started
Traceback (most recent call last):
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\showbase\ShowBase.py", line 2153, in __igLoop
self.graphicsEngine.renderFrame()
AssertionError: !mat.is_nan() at line 322 of c:\buildslave\sdk-windows-amd64\build\panda\src\pgraph\transformState.cxx
Traceback (most recent call last):
File "C:/Users/Charbel/Desktop/Ursina Tutorials/smooth follow - flying dragon.py", line 22, in <module>
app.run()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\ursina\main.py", line 238, in run
super().run()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\showbase\ShowBase.py", line 3325, in run
self.taskMgr.run()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\task\Task.py", line 546, in run
self.step()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\task\Task.py", line 500, in step
self.mgr.poll()
File "C:\Users\Charbel\AppData\Roaming\Python\Python39\site-packages\direct\showbase\ShowBase.py", line 2153, in __igLoop
self.graphicsEngine.renderFrame()
AssertionError: !mat.is_nan() at line 322 of c:\buildslave\sdk-windows-amd64\build\panda\src\pgraph\transformState.cxx
Here's a copy of my entire code:
from ursina import *
def update():
global dy
player.y += dy
if abs(player.y)>= 3:
dy = -dy
app = Ursina()
player = Entity(model='quad', scale=1, x = -4.5, texture = 'dragon_head.png')
e = [None]*50
e[0] = Entity(model='circle', scale = .2, color = color.green)
e[0].add_script(SmoothFollow(target = player, offset=(.3, 0, 0)))
dy =.08
for i in range(1,50):
e[i] = Entity(model='circle', scale = .2, color = color.green)
e[i].add_script(SmoothFollow(target = e[i-1], offset=(.2, 0, 0)))
app.run()
It appears that the error has something to do with the e[i-1] from my investigation. Has anyone else run into a similar issue or know if there's a bug in the Ursina language that causes this?
Thanks in advance
Charbel

My app just run to this error either.I think it is a rendering error caused by insufficient GPU computing power of the graphics.I reduce it to 44 and it works.

I'd assume either your computer or engine cannot handle it. I tried making a cube's rotation_z multiplied by an absurdly large number (100000000000000000000000000000000000000 to be exact) and it ran fine, but when I added an extra zero to the number, the engine broke.

Related

WARNING: NEOS is temporarily unavailable. - Pyomo

I'm trying to learn how to send an optimization problem to NEOS Server to solve it with BARON, but I'm receiving an error which says NEOS is currently unavailable even though I've been trying it for some time. I've seen that there exists another question with the same error code, but it has not been resolved and people suspect it to be caused by using a proxy (Which I do not) therefore I opened another question.
from pyomo.environ import *
model = ConcreteModel()
model.x = Var(initialize=1.5)
model.y = Var(initialize=1.5)
def rosenbrock(model):
return (1.0-model.x)**2 + 100.0*(model.y - model.x**2)**2
model.obj = Objective(rule=rosenbrock, sense=minimize)
solver_manager = SolverManagerFactory('neos')
results = solver_manager.solve(model, opt='baron')
results.write()
And the output is:
WARNING: NEOS is temporarily unavailable.
Traceback (most recent call last):
File "/Users/dorukeski/untitled/sa.py", line 15, in <module>
results = solver_manager.solve(model, opt='baron')
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-
packages/pyomo/opt/parallel/async_solver.py", line 28, in solve
return self.execute(*args, **kwds)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-
packages/pyomo/opt/parallel/manager.py", line 119, in execute
ah = self.queue(*args, **kwds)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-
packages/pyomo/opt/parallel/manager.py", line 134, in queue
return self._perform_queue(ah, *args, **kwds)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-
packages/pyomo/neos/plugins/kestrel_plugin.py", line 128, in _perform_queue
raise ActionManagerError(
pyomo.opt.parallel.manager.ActionManagerError: Solver 'baron' is not recognized by NEOS.
Solver names recognized:
[]
Though this post is an old post.
I see someone suggested the fix in this link, https://github.com/Pyomo/pyomo/issues/2162
solution 1:
pip install --upgrade certifi
solution 2 if solution 1 not working:
1 - Open Internet Explorer as an Administrator (i.e., right-click on Internet Explorer and choose "Run as administrator")
2 - Navigate to https://neos-server.org
3 - Click on the lock icon
Click to view the image
4 - Click "View Certificate"
5 - Click "Install certificate..."
6 - Choose user or local machine, whatever is appropriate
7 - Select "Place all certificates in the following store" and choose "Trusted Root
8 - Certification Authorities"

pyomo mindtpy example program when run becomes unfeasible for binary variable

So I installed pyomo, glpk, and ipopt with anaconda,
When I run the example code here: https://pyomo.readthedocs.io/en/stable/contributed_packages/mindtpy.html
from pyomo.environ import *
model = ConcreteModel()
model.x = Var(bounds=(1.0,10.0),initialize=5.0)
model.y = Var(within=Binary)
model.c1 = Constraint(expr=(model.x-3.0)**2 <= 50.0*(1-model.y))
model.c2 = Constraint(expr=model.x*log(model.x)+5.0 <= 50.0*(model.y))
model.objective = Objective(expr=model.x, sense=minimize)
SolverFactory('mindtpy').solve(model, mip_solver='glpk', nlp_solver='ipopt',tee=True)
model.objective.display()
model.display()
model.pprint()
I get the output that the binary variable has apparently become infeasible:
python minlpex.py
INFO: ---Starting MindtPy---
INFO: Original model has 2 constraints (2 nonlinear) and 0 disjunctions, with
2 variables, of which 1 are binary, 0 are integer, and 1 are continuous.
INFO: NLP 1: Solve relaxed integrality
INFO: NLP 1: OBJ: 1.0 LB: 1.0 UB: inf
INFO: ---MindtPy Master Iteration 0---
INFO: MIP 1: Solve master problem.
WARNING: Empty constraint block written in LP format - solver may error
Traceback (most recent call last):
File "minlpex.py", line 13, in <module>
op.SolverFactory('mindtpy').solve(model, mip_solver='glpk', nlp_solver='ipopt',tee=True)
File "/anaconda3/envs/py36/lib/python3.6/site-packages/pyomo/contrib/mindtpy/MindtPy.py", line 370, in solve
MindtPy_iteration_loop(solve_data, config)
File "/anaconda3/envs/py36/lib/python3.6/site-packages/pyomo/contrib/mindtpy/iterate.py", line 30, in MindtPy_iteration_loop
handle_master_mip_optimal(master_mip, solve_data, config)
File "/anaconda3/envs/py36/lib/python3.6/site-packages/pyomo/contrib/mindtpy/mip_solve.py", line 62, in handle_master_mip_optimal
config)
File "/anaconda3/envs/py36/lib/python3.6/site-packages/pyomo/contrib/gdpopt/util.py", line 199, in copy_var_list_values
v_to.set_value(value(v_from, exception=False))
File "/anaconda3/envs/py36/lib/python3.6/site-packages/pyomo/core/base/var.py", line 173, in set_value
if valid or self._valid_value(val):
File "/anaconda3/envs/py36/lib/python3.6/site-packages/pyomo/core/base/var.py", line 185, in _valid_value
"domain %s" % (val, type(val), self.domain))
ValueError: Numeric value `0.22709088987977885` (<class 'float'>) is not in domain Binary
So I was a little confused, since this was a code provided, I would not expect it to error like this. So I feel like I'm messing something up or I am missing some required library?
Thanks a lot.
Looks like something must be wrong with the conda pyomo install or ipopt install.
When I reinstalled using pip for ipopt and compiling pyomo from github source everything works fine.

Trying to create an animated graph, am getting AttributeError: 'list' object has no attribute 'set_animated' error

I'm trying to plot the voltage/current coming out of a device, with these being written to a file and then displayed on the same plot, which updates in real time. Currently the code does this, but it pops up with an error message each time the graph updates which seems to be slowing the pace at which the program takes measurements.
The error seems to be occurring each time the graph updates i.e. when plt.draw() is executed within the While loop, making me think that it occurs in def animate_readings(i), though I've included all pertinent pieces of code just in case.
plt.ion()
...
fig = plt.figure()
ax1 = fig.add_subplot(1,1,1)
ax1.clear()
ax2 = ax1.twinx()
ax2.clear()
plt.xlim(-7,3)
ax1.set_ylabel('Voltage V')
ax2.set_ylabel('Current mA')
ax1.set_ylim(-0.5,27)
ax2.set_ylim(-5, 400, 10)
Vpatch = mpatches.Patch(color='blue', label='Voltage')
Cpatch = mpatches.Patch(color='red', label='Current')
plt.legend(handles=[Vpatch, Cpatch])
plt.draw()
plt.pause(0.1)
"Is used to assign properties to the graph used in FuncAnimation"
def animate_readings(i):
plt.xlim(c-8,c+2)
ax1.plot(AVdata, color='b')
ax2.plot(ACdata, color='r')
Artists = namedtuple ('Artists', ('AVdata', 'ACdata'))
returnable = Artists(
ax1.plot(AVdata, color='b'),
ax2.plot(ACdata, color='r')
)
return returnable
...
while 1:
print 1
"Below if statement names and creates file at beginning of operation"
ani = animation.FuncAnimation(fig, animate_readings, interval=200, blit=True)
...
if c % 1 == 0:
print "2b"
try:
plt.draw()
plt.pause(0.1)
print "2c"
except :
pass
print 2
c = c + 1
The error which pops up after print "2b" executes is as follows. Nominally the loop should be running ~3x a second but, due to the error it only runs every 3 seconds and, in a recent extended test, only recorded readings every 30 seconds.
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook/__init__.py", line 388, in process
proxy(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook/__init__.py", line 228, in __call__
return mtd(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 1026, in _start
self._init_draw()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 1750, in _init_draw
self._draw_frame(next(self.new_frame_seq()))
File "/usr/local/lib/python2.7/dist-packages/matplotlib/animation.py", line 1778, in _draw_frame
a.set_animated(self._blit)
AttributeError: 'list' object has no attribute 'set_animated'

Selenium stopped working with Firefox, works with Safari

I've been using Selenium with Python 3 for a while. Yesterday it stopped working. I've tried uninstalling and reinstalling everything, but it hasn't worked. I enabled the driver for Safari, and that works, but I don't know what changed. I tried going to a different project that I haven't used in a while but functioned, thinking my code threw it off, but it doesn't work either. I know there are other posts out there similar to this, but they haven't been helpful and I wasn't sure if I should contact Mozilla/Selenium about this issue. Here are my details:
Python 3.7.1
Django 2.1
Firefox 64
Selenium 3.141.0
Geckodriver 0.23.0
I am running these in a virtual environment. Any more questions, let me know. Really confused as to what broke.
This is all of the code related to launching the browser:
class FunctionalTest(StaticLiveServerTestCase):
def setUp(self):
self.browser = webdriver.Firefox()
def get_page(self, url_extention, window=None):
window_size = [900, 700]
if window == 'xs':
window_size = [500, 700]
elif window == 'sm':
window_size = [700, 500]
elif window == 'md':
window_size = [900, 700]
elif window == 'lg':
window_size = [1024, 768]
elif window == 'xl':
window_size = [1400, 800]
return (
self.browser.get(
self.live_server_url + url_extention
),
self.browser.set_window_size(
window_size[0],
window_size[1]
)
)
class PageFunctionTest(FunctionalTest):
def test_customer_page(self):
self.get_page('/customer/profile/1/', window='xs')
# I also tried this just to check:
self.browser.get(self.live_server_url)
Basically the browser opens, throws an error and then quits. This is what shows in the browser window:
address bar: http//localhost:59905/customer/profile/1/
browser error: Firefox can’t establish a connection to the server at localhost:59905.
And this is the traceback:
Traceback (most recent call last): File
"tests/functional_tests/test_function_profile_update_phone_number.py",
line 21, in test_update_profile_phone_number
self.get_page(f'/customer/profile/1/', window='xs') File "/base_tests/base_FunctionalTest.py", line 70, in get_page
self.live_server_url + url_extention File "/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 333, in get
self.execute(Command.GET, {'url': url}) File "/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py",
line 321, in execute
self.error_handler.check_response(response) File "/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py",
line 242, in check_response
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: Reached error
page:
about:neterror?e=connectionFailure&u=http%3A//localhost%3A59905/customer/profile/1/&c=UTF-8&f=regular&d=Firefox%20can%E2%80%99t%20establish%20a%20connection%20to%20the%20server%20at%20localhost%3A59905.

Windows Error using XGBoost with python

So I'm tackling this machine-learning problem (from a previous Kaggle competition for practice: https://www.kaggle.com/c/nyc-taxi-trip-duration) and I'm trying to use XGBoost but getting an error which I have no clue how to tackle. I searched on google and stack overflow but couldn't find anyone with a similar problem.
I'm using python 2.7 with the Spyder IDE through Anaconda and I'm on Windows 10. I did have some trouble installing the xgboost package so I won't completely erase the idea that it could be an installation error. However I'm also doing a Udemy course on ML and I was able to use xgboost just fine with a small dataset and I'm using the same functions.
Code
The code is pretty simple:
... import libraries
# import dataset
dataset = pd.read_csv('data/merged.csv')
y = dataset['trip_duration'].values
del dataset['trip_duration'], dataset["id"], dataset['distance']
X = dataset.values
# Split dataset into training and test sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.25)
# fit XGBoost to training set
classifier = XGBClassifier()
classifier.fit(X_train, y_train)
Output
However it spits out the following error:
In [1]: classifier.fit(X_train, y_train)
Traceback (most recent call last):
File "<ipython-input-44-f44724590846>", line 1, in <module>
classifier.fit(X_train, y_train)
File "C:\Users\MortZ\Anaconda3\lib\site-packages\xgboost\sklearn.py", line 464, in fit
verbose_eval=verbose)
File "C:\Users\MortZ\Anaconda3\lib\site-packages\xgboost\training.py", line 204, in train
xgb_model=xgb_model, callbacks=callbacks)
File "C:\Users\MortZ\Anaconda3\lib\site-packages\xgboost\training.py", line 74, in _train_internal
bst.update(dtrain, i, obj)
File "C:\Users\MortZ\Anaconda3\lib\site-packages\xgboost\core.py", line 819, in update
_check_call(_LIB.XGBoosterUpdateOneIter(self.handle, iteration, dtrain.handle))
WindowsError: [Error -529697949] Windows Error 0xE06D7363
I don't really know how to interpret this so any help would be very appreciated.
Thanks in advance
MortZ
Well after struggling for a few days I managed to find a solution.
A friend of mine told xgboost is known to have problems with python 2.7 so I upgraded it to 3.6 This didn't entirely solve my problem but gave me a knew error:
OSError: [WinError 541541187] Windows Error 0x20474343
After some digging I found a solution to this. The fit function I was trying to use was the source of the problem (although it did work on a different dataset so I'm not entirely sure why..).
Solution
change
classifier = XGBClassifier()
classifier.fit(X_train, y_train)
to
dtrain = xgb.DMatrix(X_train, label=y_train)
dtest = xgb.DMatrix(X_test, label=y_test)
watchlist = [(dtrain, 'train'), (dtest, 'test')]
xgb_pars = {'min_child_weight': 1, 'eta': 0.5, 'colsample_bytree': 0.9,
'max_depth': 6, 'subsample': 0.9, 'lambda': 1., 'nthread': -1, 'booster' : 'gbtree', 'silent': 1, 'eval_metric': 'rmse', 'objective': 'reg:linear'}
model = xgb.train(xgb_pars, dtrain, 10, watchlist, early_stopping_rounds=2, maximize=False, verbose_eval=1)
print('Modeling RMSLE %.5f' % model.best_score)
I guess the error is because you are using XGBClassfier instead of XGBRegressor for a regression problem.