WhereIsAI/github-issue-similarity huggingface dataset:
Issue 1:
I'm writing a model in jax/flax and I use pytorch utils.data.DataLoader for multiprocessed data loading. The dataset functions however do not use pytorch tensors but numpy and jax, because some of the code I use for my model is also relevant for data preprocessing (various 3d geometry routines). This works with just CPU but when I run it on a GPU server I run into

2021-12-09 14:23:32.808066: F external/org_tensorflow/tensorflow/stream_executor/cuda/cuda_driver.cc:153] Failed setting context: CUDA_ERROR_NOT_INITIALIZED: initialization error

which I believe to be because of spawning multiple CUDA-using processes. If I duplicate the geometry-related functions to use np instead of jnp, everything works fine. Ideally, I would like to have a way to instruct jax to execute all instructions in some context on CPU and avoid the code duplication. I envision it as something like

class Dataset:
...
def _getitem_impl(self, index):
# uses np and jnp code intermixed
return data_item

def __getitem__(self, index):
with jax.default_device_placement('cpu'):
return self._getitem_impl(index)

I saw that there are other issues asking about similar features, however in my case jax.device_put won't really cut it because of the intermixing of jax and numpy code, which would force me to add device_put at every API boundary. It is also not something that can be solved with global flags because I still want the model in the main process to run on GPU. Would it be difficult to add such a feature?

Issue 2:
JAX detects my GPUs correctly and I am able to put data and parameters on the GPU, however, when I run my code, the GPU seems to idle (1% GPU utility) while the CPU is utilized at 140%.

Is this behavior intended?

from flax import linen as nn
from flax import optim
import jax.numpy as jnp
import jax

import numpy as np

def load_data():
data = np.load('mnist.npz')
x_train = data['x_train']
x_train = (x_train-128.0)/128.0
x_train = np.reshape(x_train,(60000, 28**2))
y_train = data['y_train'][:,None]

return x_train, y_train

class fnet(nn.Module):

@nn.compact
def __call__(self, x):
x = nn.Dense(features=25)(x)
for i in range(10):
x = nn.relu(nn.Dense(features=25)(x))
return nn.Dense(features=1)(x)

def initialize(self, key, x):
return fn.init(key, x)

def loss(self, x, y):
def loss_fn(params):
yhat = self.apply(params, x)
loss = jnp.mean((yhat-y)**2)
return loss
return jax.jit(loss_fn)

def train_epoch(net, x_train, y_train, optimizer):

#for i in range(len(x_train)//32):
for i in range(300):

x_tr = x_train[i*32:(i+1)*32]
y_tr = y_train[i*32:(i+1)*32]

loss = net.loss(x_tr, y_tr)

v_grad = jax.value_and_grad(loss)
val, grad = v_grad(optimizer.target)

print(i, val)
optimizer = optimizer.apply_gradient(grad)

return optimizer

fn = fnet()
key = jax.random.PRNGKey(1)
params = fn.initialize(key, jnp.zeros((32,28**2)))

jax.tree_map(lambda x: print(x.device_buffer.device()), params)

x_train, y_train = load_data()

rp = optim.Adam(0.0005).create(params)
x,y = jnp.array(x_train), jnp.array(y_train)

print(x.device_buffer.device(), y.device_buffer.device())
opt = train_epoch(fn, x, y, rp)

(I am aware that using MSE loss is stupid)
Issue 1:
fn main() {
// Both asserts give:
// 'assertion failed: `(left == right)` (left: `-2`, right: `-3`)'
assert_eq!( -2.4_f32.floor(), (-2.4_f32).floor() );
assert_eq!( -2.4_f64.floor(), (-2.4_f64).floor() );
}

rustc 1.2.0 (082e476 2015-08-03)

binary: rustc

commit-hash: 082e476

commit-date: 2015-08-03

host: x86_64-unknown-linux-gnu

release: 1.2.0

Issue 2:
Right now, methods on negative literals take precedence over the unary operator:

1.32.abs(): 1
-1.32.abs(): -1
pos.abs(): 1
neg.abs(): 1
-pos.abs(): -1
-neg.abs(): -1

Playpen: http://is.gd/0YgB1E

While that might make sense from a mathematical point of view, I think it's rather unintuitive.

I see two ways to improve this issue:

According to someone in the #rust channel, "ruby treats -3.abs as (-3).abs and -x.abs as -(x.abs)". I find that quite intuitive.

The compiler could generate a warning if a method is called on a negative literal without using parentheses to make things more explicit. Otherwise this might cause subtle bugs.

Is a change related to precedence even possible now that 1.0 is stable?
Issue 1:
I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

We should have documented as an example how to use the new next-css plugin

Current Behavior

We have a few examples to import .css files which are mostly hacks to make it work.

Context

With the release of Next.js v5 the current examples of importing CSS are outdated and can be simplified with the new next-css plugin.

Issue 2:
I have been contracted to work on an SPA, and some of it is using forms. The problem is the forms action goes to a custom route. My current solution is:

<form
action="/page"
method="get"
onSubmit={e => {
e.preventDefault()
Router.push(`/search/${this.state.hashedSearch}`);
}}
>

The problem is this forces the page to do a full reload. I'm a little jealous that with links, we can easily do <Link href="/search" as={/search?id=${this.state.someValueFromForm}} /> but there isn't a nice <form> equivalent. We're trying to keep a certain A11y standard, so using real forms and form validation is very important.

On the server-side, I have:

const routes = [
{ to: '/search', matcher: route('/search/:hash') },
// ...
];

// ...
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true);
const { pathname, query } = parsedUrl;
for (let r of routes) {
const params = r.matcher(pathname);
if (params !== false) {
return app.render(req, res, r.to, Object.assign({}, params, query));
}
}
handle(req, res, parsedUrl);
});
});

To me, it seems like this shouldn't be doing a full page reload when I submit my form, since I'm using import Router from 'next/router'; and the Router.push method.

I should mention that the page with the form is /search, and the form should take you to /search/magicHashFromForm.

I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Page shouldn't do a full page reload.

Current Behavior

Page unmounts all components, and reloads the page.

Context

I'm aiming for restful routes, so it's not uncomm

Your Environment

Tech
Version

next
5.0.0

node
8.9.4

OS
OSX 10.12.6

browser
Chrome 64.0.3282.186
Issue 1:
The following bug happens with "es6.spec.blockScoping" turned on.

Possible code generated

var _temporalUndefined = {};
// ...
UserSettings.prototype.initArray = function (key) {
var key = _temporalUndefined;
key = arguments.length <= 0 || arguments[0] === undefined ? undefined : arguments[0];
// ...
}

settings.initArray('foo');

In IE 9, causing the code to fail with a TDZ error:

arguments[0] === _temporalUndefined;

otherwise:

arguments[0] === 'foo';

Cause: IE 9 mutates the arguments property when changing key, other browsers including newer IE versions and Edge don't.

Possible Fix: To fix this the parameter list has to be emptied, then a "new" variable gets created instead of mutating the function parameter.

Issue 2:
Accidentally discovered because we weren't running some of our code in strict mode when we thought we were. I'll just be fixing the "use strict" usage so not a huge priority for us. Just wanted to let you know.

Example input: Compiled without strict but with blockScopingTDZ

(function fn(arg, arg2='arg2'){
console.log(arg, arg2);
})('arg')

results in

var _temporalAssertDefined = function (val, name, undef) { if (val === undef) { throw new ReferenceError(name + " is not defined - temporal dead zone"); } return true; };

var _temporalUndefined = {};
(function fn(arg) {
var arg = _temporalUndefined;
var arg2 = _temporalUndefined;
arg = arguments[0] === undefined ? undefined : arguments[0];
arg2 = arguments[1] === undefined ? "arg2" : arguments[1];
console.log(_temporalAssertDefined(arg, "arg", _temporalUndefined) && arg, _temporalAssertDefined(arg2, "arg2", _temporalUndefined) && arg2);
})("arg");

In non-strict mode, that var arg = _temporalUndefined also changes arguments[0] because arg is a live binding to arguments[0]. So arg = arguments[0] === undefined ? undefined : arguments[0]; ends up actually being arg = _temporalUndefined === undefined ? undefined : _temporalUndefined; and therefore is a no-op.

It doesn't seem like arg needed to be processed by TDZ anyway, so perhaps only processing TDZ on arg2 is the real fix here?
Issue 1:
Consider the following plot, which I created with version 1.5.dev1 (cloned and built in late January 2015):

import numpy as np
import matplotlib.pyplot as plt
data = np.arange(6).reshape(2, 3)
fig, sub = plt.subplots(1, 1, figsize=(4, 4))
bars = plt.bar(data[0], data[1])
_ = sub.set_ylim(1)
plt.savefig('test.svg')

If I open this SVG plot in firefox or in inkscape/inkview, it looks as expected. If I open it in the default Ubuntu image viewer (Eye of Gnome) or ImageMagick display, the bars are not properly clipped below the x-axis:

When using hatching patterns the problems multiply. This screenshot shows Firefox and Inkview in the top row, and ImageMagick and Eye of Gnome in the bottom row:

I examined the SVG source, and found that in both cases there were one or more svg:defs nodes at the end of the document (i.e., after the svg:g node containing the main components of the figure). If I manually move those svg:defs nodes up so that they occur before the main figure svg:g node, then both files now display normally in all four viewers (only the second example file is shown here):

I don't know much about the SVG specification, so I don't actually know if this is a case where matplotlib is following the rules and the viewers are to blame, or whether there is genuinely something wrong with the way matplotlib is generating the SVG, and some viewers (but not all) are clever enough to compensate for it. Regardless, it seems like reordering nodes before writing out the file might (?) be a fairly easy change to make, and would improve compatibility of matplotlib-authored SVGs.

I don't know if this last bit of information is relevant, but the problems with the unmodified SVGs persist if they are converted to EPS and then inserted into PDFs via LaTeX (when doing the conversion either with inkscape -f test.svg -E test.eps, or cairosvg test.svg -o test.ps; ps2eps -f -q -B test.ps). Again, some viewers (e.g., Adobe Reader on Windows) will display them correctly, but others (e.g., evince or muPDF) will not.

Issue 2:
See my stackoverflow post: http://stackoverflow.com/questions/29616764/matplotlib-savefig-produces-incorrect-svg-image-for-bar-chart-with-log-scaled-y

A potential solution to the issue is described here: ipython/ipython#8133 (comment)
Issue 1:
Migrated issue, originally created by Thijs Damsma (@tdamsma)

I am having difficulty using sqlalchemy to setup queries for JSON fields, specifically the issue I mentioned in the following stack-overflow question

Of course this is also a not so subtle attempt to draw some attention to my question, but more in general I found the documentation for using JSON/JSONB and sqlalchemy very limited. It would be of great help if there were some more examples for doing less trivial querying and manipulation

Thanks!

Issue 2:
Migrated issue, originally created by Michael Bayer (@zzzeek)

that is, all the functions in http://www.postgresql.org/docs/9.4/static/functions-json.html need to be possible without building subclasses of functions.
Issue 1:
Uncaught Error: EEXIST, file already exists '/Users/Frolko/.atom/storage'

Atom Version: 0.162.0

System: Mac OS X 10.10.1

Thrown From: Atom Core

Steps To Reproduce

...

...

Stack Trace

At /Applications/Atom.app/Contents/Resources/app/node_modules/mkdirp/index.js:74

undefined

Issue 2:
[Enter steps to reproduce below:]

...

...

Atom Version: 0.165.0

System: Mac OS X 10.10.1

Thrown From: Atom Core

Stack Trace

Uncaught Error: EEXIST, file already exists '/Users/812studio/.atom/storage'

At /Applications/Atom.app/Contents/Resources/app/node_modules/mkdirp/index.js:74

undefined

Commands

-0:02.4 project-manager:toggle (input.hidden-input)
-0:00.0 core:confirm (input.hidden-input)

Config

{
"core": {
"themes": [
"brownerd-ui",
"brownerd-syntax"
],
"ignoredNames": [
".git",
".svn",
".DS_Store"
],
"disabledPackages": [
"term",
"linter-scss-lint",
"linter-tidy",
"linter-jshint",
"autocomplete-plus",
"linter-csslint"
]
},
"editor": {
"showIndentGuide": true,
"fontFamily": "Source Code Pro",
"lineHeight": 1.5,
"fontSize": 14,
"softWrap": true
}
}

Installed Packages

# User
ScssBundle, v0.4.0
Stylus, v0.4.0
auto-update-packages, v0.2.1
brownerd-syntax, v0.1.0
brownerd-ui, v0.1.0
color-picker, v1.2.6
editorconfig, v0.2.2
emmet, v2.3.0
less-autocompile, v0.3.3
linter, v0.9.0
linter-js-yaml, v0.1.3
minimap, v3.4.9
project-manager, v1.14.1
tabs-to-spaces, v0.8.0
terminal, v0.28.0

# Dev
No dev packages
Issue 1:
The documentation for numpy.any() states that it

Returns single boolean unless axis is not None

Calling numpy.any() on an array of strings (dtype=object) returns the first string in the array

Reproducing code example:

import numpy as np
example_array = np.array(['a', 'b', 'c'], dtype=object)
example_array.any()

Returns 'a' (using all() returns 'c')

Numpy/Python version information:

1.15.2 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)]

Issue 2:
Currently in 1.9-devel

In [45]: type(np.any(np.ones(2,dtype='O')))
Out[45]: int

In [46]: type(np.all(np.ones(2,dtype='O')))
Out[46]: int
Issue 1:
in my form builder I do:

$builder
->add('debugDate', DateType::class, array(
'label' => 'label.debug_date',
'widget' => 'single_text',
'required' => false,
'empty_data' => null,
'attr' => array('data-datepicker'=>1),
))
->add('debugNumber', NumberType::class, array(
'label' => 'label.debug_number',
'required' => false,
'empty_data' => null,
'scale' => 2));

Enttiy Code:

/**
* @var \DateTime
* @ORM\Column(name="debug_date", type="datetime", nullable=true)
*/
private $debugDate;
/**
* @var \DateTime
* @ORM\Column(name="debug_number", type="datetime", nullable=true)
*/
private $debugNumber;

Apparently 'empty_data' => null does not work as expected, since vars.value outputs an empty strring. Why is that?

Is there a wworkaround for this issue? My project deadline is in a couple of days:(

I'm reporting this code in a simplified way, real fields are all in embedded forms, if that is of any matter.

Symfony version 3.0.3

Issue 2:
This one is a bit hard to explain, but I'll try my best.

PR#3239 brought proper handling of collections, but it doesn't work as expected. I've traced this only for blank collection, but this is probably the same or similar when you go and edit existing one.

My collection object is having duplicates. And if I take a look at the memory addresses of those duplicates with the debugger, I can see that the same objects are added twice as they reside on the same address.

It seems, that the data is bind to the collection twice, first in the form's bind() method and then once again in MergeCollectionListener.

Looking at the $originalData when onBindNormData is called in

https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php#L142

I can see, that $originalData already contains the whole collection that came in through the request.

Later down the code calls add* method and adds the same objects.

Now the problem is not visible if all you do with the data is just call $em->persist($form->getData()

as doctrine will silently handle this, but if you need to traverse the collection and do some calculations

on it before persisting, then you have the problem as you'll do the whatever you want to do twice.
Issue 1:
.d.tsx files should probably be treated as .d.ts files, or cause a warning telling the user that .d.tsx doesn't work, and that they should rename the file to .d.ts.

Issue 2:
Moving over request from here: https://typescript.codeplex.com/workitem/2464

Proposed Solution:

class A {
[index: number]: A; // <- since you can already do this
(...args): A; // <- why not allow this also?
constructor(...args) { }
}
Issue 1:
Why do I get Network error message?

axios.defaults.headers.post['Content-Type'] = 'application/json';
axios({
method: 'post',
url: url,
data: pages
}).then(response => {
this.setState({
pages: response.data
})
}).catch(function (error) {
console.log(error);
});

Issue 2:
Calling from a react app the BE with axios and got this error:

TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in this context.

Do you have any idea what is wrong?

axios.defaults.headers.post['Content-Type'] = 'application/json';
axios({
method: 'post',
url: url,
data: pages
}).then(function (response) {
this.setState({
pages: response.data
});
}).catch(function (error) {
console.log(error);
});
Issue 1:
Go version: 1.4

The following code works on Windows 7:

package main
import "fmt"
import "net"
func main() {
ifs, _ := net.Interfaces()
for _, i := range ifs {
fmt.Println(i.Flags)
}
}

Tried both "run as administrator" and "compatibility mode" to see whether this was a side effect but never saw any flags when running on Windows 8.

Issue 2:
by tom.walsh@expresshosting.net:

The following code returns different results based on the platform:

package main

import (
"fmt"
"net"
)

func main() {
addrs, _ := net.InterfaceAddrs()
for _, addr := range addrs {
fmt.Println(addr.String())
}
}

On Linux it produces:

127.0.0.1/8
192.168.1.10/24
::1/128
fe80::21b:21ff:fe14:3bd3/64

On Windows it produces:

192.168.11.71
0.0.0.0
192.168.1.107
192.168.56.1

Please note the lack of CIDR netmasks

What is the expected output?
Consistent output no matter which platform. I think that including the CIDR is a better
option (Linux has it right, Windows has it wrong)

What do you see instead?
Linux includes the CIDR with the address. Windows omits the CIDR notation.

Which compiler are you using (5g, 6g, 8g, gccgo)?
6g on both platforms

Which operating system are you using?
Linux and Windows

Which version are you using? (run 'go version')
Windows is 1.1rc1 (also tested with 1.0.2 with the same results), Linux 1.0.3

Please provide any additional information below.
Issue 1:
Environment

Windows build number: 10.0.18362.0
Windows Terminal version (if applicable): 0.6.2951.0

Display setup:
Left: Surface Book 1, 3000x2000 @ 200%
Right: Ultrawide, 3440x1440 @ 100%

Steps to reproduce

Launch Terminal, move to right display

Maximize on right display with Win+Up

Set to left half of right display with Win+Left

Expected behavior

The Terminal window should be completely contained within the left half of the right display.

Actual behavior

The Terminal window will have the left-most chrome border and some of the console output on the left screen.

A screenshot of this is tough, but notice that the border is overlapping the adjacent scroll bar that is maximized on the left display here.

Workaround hack

Once the window is consuming half the screen, you can send it to the other displays left half with Win+Shift+Left/+Right. Then, sending it back to the original, right display with Win+Shift+Left/+Right will cause it to fit where expected.

Here is that same section of adjacent windows after the workaround, showing no overlap on the scrollbar.

Issue 2:
Environment

Windows build number: [run `[Environment]::OSVersion` for powershell, or `ver` for cmd]
Windows Terminal version (if applicable):

Any other software?

Steps to reproduce

Expected behavior

Actual behavior
Issue 1:
Write a Component

import imageFile from "./happy-image.svg";
export default ()=> <img src={imageFile} alt="happy image" />;

obs.: Image does exist and it is on the same directory

next.config.js

module.exports = {
webpack: (config, { dev }) => {

config.resolve = config.resolve || {};
config.resolve.symlinks = false;

config.module.rules.push(
{
test: /\.(gif|svg)(\?.*)?$/i,
use: [
{
loader: "emit-file-loader",
options: {
name: "dist/[path][name].[ext]",
},
},
{
loader: "file-loader",
options: {
limit: 1000,
},
},
],
});
}
}

[x ] I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior

Component get rendered with correct image url

Current Behavior

Error: ReferenceError: __webpack_public_path__ is not defined

SVG file was emited to .next/[hash].svg

There is a module in .next/build/components_folder/happy-image.svg with contents:

module.exports = __webpack_public_path__ + "[hash].svg";

*.note __webpack_public_path__ was not defined anywhere

Steps to Reproduce (for bugs)

write code described above

Your Environment

Tech
Version

next
v2.4.9

node
v8.2.0

OS
OSX SIERRA

Issue 2:
I have searched the issues of this repository and believe that this is not a duplicate.

I want to use a decorator to refer to the router, but there is a problem with type checking in TypeScript. (Does not affect its work, only type checking error)

@types/next/router.d.ts

export function withRouter<T extends {}>(
Component: React.ComponentType<T & { router: SingletonRouter }>
): React.ComponentType<T>;

First of all, I think a little problem in the type definition, I think router property should be optional.

Because router property is injected from withRouter does not require passing this property when I refer to the component.

export function withRouter<T extends {}>(
- Component: React.ComponentType<T & { router: SingletonRouter }>
+ Component: React.ComponentType<T & { router?: SingletonRouter }>
): React.ComponentType<T>;

There is no problem using function injection

import * as React from 'react'
import { withRouter, SingletonRouter } from 'next/router'

interface Props {
router?: SingletonRouter
}

class SiderMenu extends React.Component<Props> { }
export default withRouter(SiderMenu)

There was an error using the decorator

import * as React from 'react'
import { withRouter, SingletonRouter } from 'next/router'

interface Props {
router?: SingletonRouter
}

@withRouter
export default class SiderMenu extends React.Component<Props> { }

TS Error

@withRouter
^^^
[ts]
Unable to resolve signature of class decorator when called as an expression.
Type 'ComponentClass<Props>' is not assignable to type 'void | typeof SiderMenu'.
Type 'ComponentClass<Props>' is not assignable to type 'typeof SiderMenu'.
Type 'Component<Props, ComponentState>' is not assignable to type 'SiderMenu'.
Types of property 'render' are incompatible.
Type '() => ReactNode' is not assignable to type '() => Element'.
Type 'ReactNode' is not assignable to type 'Element'.
Type 'string' is not assignable to type 'Element'.
Issue 1:
Related to #9056

It's true that most of the heavy lifting in Wayland compatibility will happen when Chromium adds Wayland support, but there are also X11 odds-and-ends that will need to be addressed in Electron itself.

In several places our USE_X11 ifdef really just means OS_*NIX, but there are several places where we're calling XShapeCombineRectangles, XSetTransientForHint, XChangeProperty, et al. These cases will all need Wayland support as well

Issue 2:
Preflight Checklist

I have read the Contributing Guidelines for this project.

I agree to follow the Code of Conduct that this project adheres to.

I have searched the issue tracker for a feature request that matches the one I want to file, without success.

Electron Version

13.0.0

What operating system are you using?

Windows

Operating System Version

windows 20H2

What arch are you using?

x64

Last Known Working Electron version

10

Expected Behavior

After closing the BrowserWindow, need to close or destroy the embedded BrowserView.

Actual Behavior

The BrowserView cannot be closed using the following code either

browser.removeBrowserView(view);
browser.setBrowserView(null);
view = null;
browser.close();

browserView does not provide a close()or destroy() method

browserView.webContents also does not provide a close() or destroy() method

When I open and close BrowserWindow several times, the electron.exe process is added infinitely in the system task manager

Testcase Gist URL

No response

Additional Information

No response