Skip to content

Commit

Permalink
Merge pull request #37 from openweathermap/fix/writeable
Browse files Browse the repository at this point in the history
Fix/writeable
  • Loading branch information
matveyvarg authored Jul 5, 2024
2 parents 4fb9c38 + 5d2845c commit cd77f16
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion deker_server_adapters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ def read_data(
message=f"Timeout on {self.type.name} read {array}",
)

numpy_array = np.frombuffer(response.read(), dtype=array.dtype) # type: ignore[call-overload]
numpy_array = np.frombuffer(bytearray(response.read()), dtype=array.dtype) # type: ignore[call-overload]
shape = array[bounds].shape
if not shape and numpy_array.size:
return numpy_array[0]
Expand Down
10 changes: 10 additions & 0 deletions tests/test_cases/test_common/test_array_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,13 @@ def test_read_data_single_number(
data = np.zeros(shape=(1,))
httpx_mock.add_response(content=data.tobytes(), url=re.compile(r".*array.*"))
assert server_array_adapter.read_data(array, np.index_exp[0]) == data[0]


def test_read_data_single_number(
array: Array, httpx_mock: HTTPXMock, server_array_adapter: ServerArrayAdapter, collection: Collection, mock_status
):
data = np.zeros(shape=(1,))
httpx_mock.add_response(content=data.tobytes(), url=re.compile(r".*array.*"))
read_data = server_array_adapter.read_data(array, np.index_exp[:])
read_data[0] = 0
assert read_data[0] == 0

0 comments on commit cd77f16

Please sign in to comment.