Вот как я решил проблему для меня, переписанную так же, как приведенный выше пример.
Основная идея заключается в создании вспомогательного массива с индексами с использованием arange
и reshape
.
In [1]: import numpy as np
In [2]: A = np.random.rand(3,4,2)
In [3]: A
Out[3]:
array([[[ 0.79341698, 0.55131024],
[ 0.29294586, 0.22209375],
[ 0.11514749, 0.15150307],
[ 0.71399288, 0.11229617]],
[[ 0.74384776, 0.96777714],
[ 0.1122338 , 0.23915265],
[ 0.28324322, 0.7536933 ],
[ 0.29788946, 0.54770654]],
[[ 0.13496253, 0.24959013],
[ 0.36350264, 0.00438861],
[ 0.77178808, 0.66411135],
[ 0.26756112, 0.54042292]]])
In [4]: helper = np.arange(3*4*2)
In [5]: helper
Out[5]:
array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
17, 18, 19, 20, 21, 22, 23])
In [6]: helper = helper.reshape([3,4,2])
In [7]: helper
Out[7]:
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7]],
[[ 8, 9],
[10, 11],
[12, 13],
[14, 15]],
[[16, 17],
[18, 19],
[20, 21],
[22, 23]]])
In [8]: linear_index = helper[1,0,1]
In [9]: linear_index
Out[9]: 9
Обратите внимание, что:
Эта ошибка возникает, если вы слишком часто запускаете запрос в DataBase в течение короткого периода времени.
EndPointNotFound: EndPointNotFound: it was impossible to connect with the endpoint in that address, check if it is correct.
Response:
b'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">\n<html>\n <head>\n <title>Error HTTP/1.1 404 File not found</title>\n </head>\n <body>\n <h3>Error HTTP/1.1 404 File not found</h3><pre>\nThe requested URL was not found URI = \'/sparql\'\n </pre></body></html>\n'
Добавьте в код python следующее:
import time
time.sleep(2)
Где 2 - время в секундах.