issue_comments
7 rows where issue = 280899335 sorted by updated_at descending
This data as json, CSV (advanced)
Suggested facets: created_at (date), updated_at (date)
issue 1
- Use of Xarray instead of np.meshgrid · 7 ✖
id | html_url | issue_url | node_id | user | created_at | updated_at ▲ | author_association | body | reactions | performed_via_github_app | issue |
---|---|---|---|---|---|---|---|---|---|---|---|
350974418 | https://github.com/pydata/xarray/issues/1773#issuecomment-350974418 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDk3NDQxOA== | GProtoZeroW 11997114 | 2017-12-12T08:03:07Z | 2017-12-12T08:03:07Z | NONE | @shoyer I saw where you were going with this and here is the result I got. The trick was to preseed the dataset with an array of dtype 'object' ``` MasterShape=SimDataSet['CoorSpace'].shape; MasterShape dealing with the non broadcasting functionSimDataSet['vector']=(['x', 'y', 'z', 't'], np.zeros(MasterShape, dtype=object)) for i in Iter.product(SimDataSet.indexes.values(), repeat=1): #print(i, vector_funcN(i)) SimDataSet['vector'].loc[dict(x=i[0], y=i[1], z=i[2], t=i[3])]=vector_funcN(*i)
scale_func = lambda x, y, z, t: np.cos(1x+2y+3z-4t) scale_func(1,1,1,1) x, y, z, t=symbols('x, y, z, t') xDirVec=Matrix([1,0,0]) vector_func=cos(1x+2y+3z-4t)*xDirVec vector_func vector_funcN=lambdify((x, y, z, t), vector_func, dummify=False) data point testvector_funcN(1,1,1,1) DomainSpaceTimeSize = 5 # using cartesian 4D SpaceTimeDensity = [10, 5] # 100 divisions in space 5 in time x_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) y_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) z_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) t_coord = np.linspace(0, +DomainSpaceTimeSize, SpaceTimeDensity[1]) dx=xr.DataArray(x_coord, dims='x') dy=xr.DataArray(y_coord, dims='y') dz=xr.DataArray(z_coord, dims='z') dt=xr.DataArray(t_coord, dims='t') CoorEnterFunc = lambda x, y, z, t: 1+0x+0y+0z+0t SimDataSet = xr.Dataset({'CoorSpace':(['x', 'y', 'z', 't'], CoorData)}, coords={'x':x_coord, 'y':y_coord, 'z':z_coord, 't':t_coord}) MasterShape=SimDataSet['CoorSpace'].shape; MasterShape SimDataSet['Scaler']=(['x', 'y', 'z', 't'],scale_func(*np.meshgrid(x_coord, y_coord, z_coord, t_coord)) ) dealing with the non broadcasting functionSimDataSet['vector']=(['x', 'y', 'z', 't'], np.zeros(MasterShape, dtype=object)) for i in Iter.product(SimDataSet.indexes.values(), repeat=1): #print(i, vector_funcN(i)) SimDataSet['vector'].loc[dict(x=i[0], y=i[1], z=i[2], t=i[3])]=vector_funcN(*i) SimDataSet.info() ``` I think there is definitely room for improvement. But I am now going to start implementing said EM example and y'alls help should get me to step 4. I step 5 should be interesting (I am not jinxing myself here) and will let y'all know when I get started on step 6 (I have done it before but very ad-hoc to say the least ) . I know |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 | |
350879291 | https://github.com/pydata/xarray/issues/1773#issuecomment-350879291 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDg3OTI5MQ== | shoyer 1217238 | 2017-12-11T22:27:58Z | 2017-12-11T22:27:58Z | MEMBER | It seems that sympy functions returned by lambdfy may not work on arbitrary dimensional inputs, or might not follow broadcasting rules. The workaround might be something like: ```python def vector_func_wrapper(dx, dy, dz, dt): dx, dy, dz, dt = np.broadcast_arrays(dx, dy, dz, dt) # explicitly broadcast args = [a.ravel() for a in [dx, dy, dz, dt]] # convert everything to a vector return vector_funcN(*args).reshape(dx.shape) xarray.apply_ufunc(vector_func_wrapper, dx, dy, dz, dt) ``` |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 | |
350840130 | https://github.com/pydata/xarray/issues/1773#issuecomment-350840130 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDg0MDEzMA== | GProtoZeroW 11997114 | 2017-12-11T19:59:20Z | 2017-12-11T19:59:20Z | NONE | @shoyer the
long story short on lambdfy, it tries to convert a sympy expression to a string then does a bunch of string mappings from the expression string to numpy (and starting to come online scipy) functions then tags on a lambda to the front of that and passes it back to the user via the black magic of So, in theory, there should not be this issue at hand with using lambdfy but in practice, its treating the [1:] parts of the passed in matrix as So back to the code at hand. I tried So first off would I want to apply the So just so we're all on the same page.
1. Define the individual spacetime comp domain axis and there ranges/step size
2. Bind the individual domain axis dominions in one xarray datacube to create one coherent spacetime grid stored in a xarray datacube
3. pass the xarray spacetime grid into other functions such as scaler, vector, tensor functions (with names and units) as new Find ways to minimize np.meshgrid since there are times when that does not work and instead use So if I am working with an Electromagnetic example the workflow would be 1. define the extent and step size in x, y, z, t 2. bind individual dimensions into cohesive computing domain stored in basis xarray datacube 3. define a the scaler electrical potential function and the vector magnetic function (let's just say we are going to try to do this in sympy and then convert it with lambdfy 4. find the numerical values of the electric and magnetic potential in the spacetime grid and bind them with the coordinates into a xarray.dataset (to keep things simple where working in free space, but if material domains are present this would be the perfect use of xarray to store that information in the dataset parral to the potentials and fields 5. find the electric and magnetic fields from the potentials and add them to the dataset 6. pass final dataset over to yt for volumetric rendering 7. review output with an expansive drink in hand because that would have cost a mint to do in certain proprietary "languages" |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 | |
350821050 | https://github.com/pydata/xarray/issues/1773#issuecomment-350821050 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDgyMTA1MA== | shoyer 1217238 | 2017-12-11T18:54:03Z | 2017-12-11T18:54:03Z | MEMBER | Broadcast allows a variadic number of arguments, so you can write something like:
I'm not very familiar with sympy's lambdify, but I think something like |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 | |
350818717 | https://github.com/pydata/xarray/issues/1773#issuecomment-350818717 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDgxODcxNw== | GProtoZeroW 11997114 | 2017-12-11T18:46:12Z | 2017-12-11T18:46:12Z | NONE | @fmaussion Thank you, that's going to help with a lot of my problems for my computational work @shoyer I am looking at the docs for ``` import numpy as np import xarray as xr DomainSpaceTimeSize = 5 # using cartesian 4D SpaceTimeDensity = [100, 5] # 100 divisions in space 5 in time x_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) y_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) z_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) t_coord = np.linspace(0, +DomainSpaceTimeSize, SpaceTimeDensity[1]) dx=xr.DataArray(x_coord, dims='x') dy=xr.DataArray(y_coord, dims='y') dz=xr.DataArray(z_coord, dims='z') dt=xr.DataArray(t_coord, dims='t') ds, =xr.broadcast(dx, dy)
ds, =xr.broadcast(ds, dz)
ds, _=xr.broadcast(ds, dt)
ds
``` from sympy import * init_printing() x, y, z, t=symbols('x, y, z, t') xDirVec=Matrix([1,0,0]) vector_func=cos(1x+2y+3z-4t)*xDirVec vector_func vector_funcN=lambdify((x, y, z, t), vector_func, dummify=False) data point testvector_funcN(1,1,1,1) target compersionvector_func_npRef=lambda x, y, z, t: np.array([np.cos(1x+2y+3z-4t), 0, 0]) point testvector_funcN(1,1,1,1) point test match test: passnp_SpaceResult=vector_func_npRef(np.meshgrid(x_coord, y_coord, z_coord, t_coord)).shape sp_SpaceResult=vector_funcN(np.meshgrid(x_coord, y_coord, z_coord, t_coord)).shape and as can be seen the two shapes dont match
|
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 | |
350806352 | https://github.com/pydata/xarray/issues/1773#issuecomment-350806352 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDgwNjM1Mg== | shoyer 1217238 | 2017-12-11T18:02:39Z | 2017-12-11T18:02:39Z | MEMBER | If you make each of your arrays |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 | |
350666998 | https://github.com/pydata/xarray/issues/1773#issuecomment-350666998 | https://api.github.com/repos/pydata/xarray/issues/1773 | MDEyOklzc3VlQ29tbWVudDM1MDY2Njk5OA== | fmaussion 10050469 | 2017-12-11T09:23:00Z | 2017-12-11T09:23:00Z | MEMBER | Is this what you want? ```python import numpy as np import xarray as xr DomainSpaceTimeSize = 5 # using cartesian 4D SpaceTimeDensity = [100, 5] # 100 divisions in space 5 in time x_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) y_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) z_coord = np.linspace(-DomainSpaceTimeSize, +DomainSpaceTimeSize, SpaceTimeDensity[0]) t_coord = np.linspace(0, +DomainSpaceTimeSize, SpaceTimeDensity[1]) scale_func = lambda x, y, z, t: np.cos(1x+2y+3z-4t) data = scale_func(*np.meshgrid(x_coord, y_coord, z_coord, t_coord)) da = xr.DataArray(data, dims=['x', 'y', 'z', 't'], coords={'x':x_coord, 'y':y_coord, 'z':z_coord, 't':t_coord}) da.sel(x=0.0, y=1.0, z=0.0, t=3.0, method='nearest') <xarray.DataArray ()> array(-0.8039436986070311) Coordinates: x float64 0.05051 z float64 0.05051 t float64 2.5 y float64 0.9596 ``` |
{ "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
Use of Xarray instead of np.meshgrid 280899335 |
Advanced export
JSON shape: default, array, newline-delimited, object
CREATE TABLE [issue_comments] ( [html_url] TEXT, [issue_url] TEXT, [id] INTEGER PRIMARY KEY, [node_id] TEXT, [user] INTEGER REFERENCES [users]([id]), [created_at] TEXT, [updated_at] TEXT, [author_association] TEXT, [body] TEXT, [reactions] TEXT, [performed_via_github_app] TEXT, [issue] INTEGER REFERENCES [issues]([id]) ); CREATE INDEX [idx_issue_comments_issue] ON [issue_comments] ([issue]); CREATE INDEX [idx_issue_comments_user] ON [issue_comments] ([user]);
user 3