Comments (3)
I managed to get slices working locally by modifying PyObject.proxy
and using strings:
// ✅ Passes
Deno.test("slice", () => {
const array = [1, 2, 3];
const list = python.list(array);
assertEquals(list["1:"].valueOf(), [2, 3]);
assertEquals(list["1:2"].valueOf(), [2]);
assertEquals(list[":2"].valueOf(), [1, 2]);
assertEquals(list["0:3:2"].valueOf(), [1, 3]);
assertEquals(list["-2:"].valueOf(), [2, 3]);
});
// ✅ Passes
Deno.test("multidimensional slice", () => {
const np = python.import("numpy");
const slice = np.arange(15).reshape(3, 5);
slice["1:, ::2"] = -99;
assertEquals(slice.tolist().valueOf(), [
[0, 1, 2, 3, 4],
[-99, 6, -99, 8, -99],
[-99, 11, -99, 13, -99],
]);
});
It's pretty neat, but I'm wondering if it's the right approach.
from deno_python.
Did you use the PySlice_* APIs? I think that's the right way to do it. If you have worked on it you're most welcome to PR, otherwise I can try looking into it this weekend (and review your other PR as well, sorry for delay I'm just really busy with school 😓)
from deno_python.
Did you use the PySlice_* APIs?
Yes. PySlice_New
for creating the slice, then PyObject_Get/SetItem
.
For multidimensional slices, PySlice_New
for each slice, then merge them using PyTuple_Pack
, then PyObject_Get/SetItem
.
sorry for delay I'm just really busy with school
No worries! I should be studying for finals too 😅 instead I'm procrastinating and doing this.
I already worked on it, I'll clean up my code and try to open a PR before the end of the week. No need to review it immediately.
from deno_python.
Related Issues (20)
- python_dono ?! HOT 2
- Working with spacy segmentation fault HOT 1
- PythonError type name is lost HOT 1
- problem with javascript unicode characters sent as arguments to python HOT 1
- pyenv support
- buffer support
- Synchronous Python & async JavaScript? HOT 1
- Leaking semaphore HOT 1
- Python wiki entry
- error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'packages_distributions') HOT 2
- Warnings when running pip.import more than once HOT 1
- How to pass kwargs HOT 1
- Jupyter rich content output
- Uncaught TypeError: Unsupported type: function HOT 3
- errors when setting properties on a class that extends python class HOT 3
- TypeError: 'builtin_function_or_method' object does not support vectorcall HOT 5
- should void also be added to PythonConvertible HOT 1
- variables have unexpected type HOT 5
- warnings dont't show up HOT 1
- Could bunpy be updated along with deno_python?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno_python.