sharjeelyunus/github-issues-dataset huggingface dataset:
Repository: opencv
Issue: Ill-defined distortion model found by calibrateCamera
Labels: category: calib3d

Hi everyone,

The calibrateCamera() function can return distortion coefficients `k1, k2... k6` that lead to a distortion model that is ill-defined. The denominator of the radial distortion part `(1 + k4 r^2 + k5 r^4 + k6 r^6)` can have roots `r_i` such that `r_i^2 = ((u-cx)/fx)^2 + ((v-cy)/fy)^2` for some real-valued image points coordinates `(u, v)` within the image boundaries.

As a consequence, all image points located in the vicinity of this ellipsis may be attributed an incorrect value by the remap function, as the rectification maps will contain invalid coordinates.

This was observed after calibrating with a set of images in which the chessboard was placed mostly near the image center, so my guess is that the lack of constraints further from the center could explain why the optimization could converge towards such a solution. A work around is to check at the end of the calibration process that the radial distortion model is well-defined for every image pixel coordinates − i.e. compute the roots of the polynomial at the denominator.

My question is: when the rational distortion model is used, shouldn't the optimization be constrained in a way that prevents convergence towards such ill-defined sets of coefficients?

Here are the parameters found:

```
	fx:530.416 fy:530.429 cx:511.626 cy:383.541
	k1:22.4427 k2:-18.5172 p1:0.000102929 p2:0.000468845 k3:-4.44312 k4:22.8537 k5:-10.515 k6:-12.7093
	width:1024 height:768
```

![roots](https://user-images.githubusercontent.com/4275716/65494074-716d9f80-deb4-11e9-8494-463b3fedf529.png)


##### Steps to reproduce

I can provide calibration images upon request.

##### System information (version)
- OpenCV => 4.1.0
- Operating System / Platform => Linux 64 Bit
- Compiler => GCC 8.3.1
Repository: svelte
Issue: Passing values from slot to parent
Labels: feature request

From the documentation of slots it seems it should be possible to bind values of a component to a slot:

> Slots can be rendered zero or more times, and can pass values back to the parent using props. The parent exposes the values to the slot template using the `let:` directive.

but it seems that the real situation is different: this [REPL](https://svelte.dev/repl/21a2324cc6be46348e514db137353ce8?version=3.12.1) triggers the error `Cannot bind to a variable declared with the let: directive (10:32)`.

**Expected behavior**
Binding a variable in a slot, which is bound to a variable in the parent component, should work normally as it would if I manually substituted the slot content inside the container.

**Severity**
This underpins the possibility of developing a lot of components that take care of boilerplate code for my application, so in my case this effectively blocks my usage of Svelte for the project.
Repository: react
Issue: [eslint-plugin-react-hooks] allow configuring custom hooks as "static"
Labels: Type: Enhancement,Component: ESLint Rules

<!--
  Note: if the issue is about documentation or the website, please file it at:
  https://github.com/reactjs/reactjs.org/issues/new
-->

**Do you want to request a *feature* or report a *bug*?**

Feature/enhancement

**What is the current behavior?**

Currently the eslint plugin is unable to understand when the **return value** of a custom hook is static.

Example:

```jsx
import React from 'react'

function useToggle(init = false) {
  const [state, setState] = React.useState(init)
  const toggleState = React.useCallback(() => { setState(v => !v) }, [])
  return [state, toggleState]
}

function MyComponent({someProp}) {
  const [enabled, toggleEnabled] = useToggle()

  const handler = React.useCallback(() => {
    toggleEnabled()
    doSomethingWithTheProp(someProp)
  }, [someProp]) // exhaustive-deps warning for toggleEnabled

  return <button onClick={handler}>Do something</button>
}
```

**What is the expected behavior?**

I would like to configure `eslint-plugin-react-hooks` to tell it that `toggleEnabled` is static and doesn't need to be included in a dependency array. This isn't a huge deal but more of an ergonomic papercut that discourages writing/using custom hooks.

As for how/where to configure it, I would be happy to add something like this to my .eslintrc:

```js
{
  "staticHooks": {
    "useToggle": [false, true],  // first return value is not stable, second is
    "useForm": true,             // entire return value is stable 
  }
}
```

Then the plugin could have an additional check [after these 2 checks](https://github.com/facebook/react/blob/8b580a89d6dbbde8a3ed69475899addef1751116/packages/eslint-plugin-react-hooks/src/ExhaustiveDeps.js#L228-L231) that tests for custom names.

**Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?**

All versions of eslint-plugin-react-hooks have the same deficiency.

## Please read my first comment below and try my fork if you are interested in this feature!
Repository: TypeScript
Issue: compilerOptions support TDZ error option
Labels: Suggestion,Awaiting More Feedback

According to the PR of #32221 , to prevent such problem like: 

```typescript
(function () {
    function cleanup() {
        console.log(A); // throw error
    }

    cleanup();
    const A = 1;
}());
```

this snippet will compile into:

```javascript
(function () {
    function cleanup() {
        console.log(A); // log undefined
    }
    cleanup();
    var A = 1;
}());
```

Error in the first snippet will be ignored, and cause TDZ error. Can `tsc` support TDZ error enabled option like [babel-plugin-transform-block-scoping](https://babeljs.io/docs/en/next/babel-plugin-transform-block-scoping.html) ? It will notify peoples who write such pattern to prevent further weird problems.

## Checklist

My suggestion meets these guidelines:

* [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
* [ ] This wouldn't change the runtime behavior of existing JavaScript code
* [x] This could be implemented without emitting different JS based on the types of the expressions
* [ ] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
* [x] This feature would agree with the rest of [TypeScript's Design Goals](https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals).
Repository: electron
Issue: sendInputEvent doesn't work for iframe/webview
Labels: platform/windows,platform/macOS,bug :beetle:,status/confirmed,5-0-x,6-1-x,10-x-y,component/webcontents,25-x-y,26-x-y

I'm trying to interact with an embedded video _using manual mouse input_ via `webContents.sendInputEvent` api. It stopped working in 5-0-x. 

### Issue Details

* **Electron Version:**
  * 5-0-x, 6-0-x
* **Operating System:**
  * Win10 (1903), macOS 10.14.6
* **Last Known Working Electron version:**
  * 4.2.10

### Expected Behavior
`sendInputEvent` should produce the same effects as OS input

### Actual Behavior
`sendInputEvent` doesn't interact with `<iframe>` or `<webview>`

### To Reproduce

```js
const { app, BrowserWindow } = require('electron')
// Fails with 5.0.10
// Works with 4.2.10

app.once('ready', () => {
  const { webContents: wc } = new BrowserWindow({
    width: 800,
    height: 600
  })
  wc.once('did-finish-load', () => {
    setTimeout(() => {
      wc.sendInputEvent({ type: 'mouseMove', x: 600, y: 300 })
    }, 1000)
    setTimeout(() => {
      wc.sendInputEvent({ type: 'mouseDown', x: 600, y: 300, button: 'right' })
    }, 2000)
    setTimeout(() => {
      wc.sendInputEvent({ type: 'mouseUp', x: 600, y: 300, button: 'right' })
    }, 2100)
  })
  wc.on('context-menu', (event, params) => {
    console.log(params)
  })
  wc.loadURL('https://www.w3schools.com/html/tryit.asp?filename=tryhtml_youtubeiframe')
})
```

### Additional Information
The test above manually triggers a right click on the embedded video, which should
- activate iframe for the first mouse move
- open the _youtube context menu_ instead of main frame's
Repository: pytorch
Issue: [jit] Bad error when instantiating TorchScript class with incorrect types
Labels: oncall: jit,triaged,jit-backlog

If the Python object has a different type for an attribute than the TorchScript class, then the error is a pybind miscast:

in `__init__` of a module:
```python
self.x = BalancedPositiveNegativeSampler(1, 2)
```

```python
@torch.jit.script
class BalancedPositiveNegativeSampler(object):
    """
    This class samples batches, ensuring that they contain a fixed proportion of positives
    """

    def __init__(self, batch_size_per_image, positive_fraction):
        # type: (int, float)
        """
        Arguments:
            batch_size_per_image (int): number of elements to be selected per image
            positive_fraction (float): percentace of positive elements per batch
        """
        self.batch_size_per_image = batch_size_per_image
        self.positive_fraction = positive_fraction
```

```
RuntimeError: Unable to cast Python instance of type <class 'int'> to C++ type 'torch::autograd::Variable'
```



cc @suo
Repository: neovim
Issue: :terminal output slows down editor when handling large output
Labels: enhancement,performance,terminal

<!-- Before reporting: search existing issues and check the FAQ. -->

- `nvim --version`: v0.5.0-dev
- Operating system/version: Ubuntu 19.04
- Terminal name/version: gnome-terminal
- `$TERM`: xterm-256color

### Steps to reproduce using `nvim -u NORC`

```
nvim -u NORC
:vs | term
i yes

```

### Actual behaviour
Other neovim buffers slow down (navigation, editing, etc.)

### Expected behaviour
Other neovim buffers work as usual

### Suggestion
Would it be to add an option to limit the rate of buffer stdout and stderr? Similar to piping all output through [pv](https://linux.die.net/man/1/pv) -qL [rate]
Repository: go
Issue: proposal: net: add BufferedPipe (buffered Pipe)
Labels: Proposal,Proposal-Hold

If one wants to connect two Go libraries which use the `net` interfaces, the only cross platform way to do it with the standard library is to use the loopback. The only in-process way to do it is to create a socket pair with syscall.Socketpair and go from FD -> `*os.File` -> `net.Conn`. This is a fairly manual process, and while local to the machine and fully in-memory, does use a non-cross-platform kernel feature to do the heavy lifting.

A native Go transport would be more ideal, but expecting users to implement their own is maybe not reasonable as the net.Conn and net.Listener interfaces are difficult to implement correctly. I propose that we add a canonical and cross-platform in-memory transport in either `net` or `x/net`.

Further, I propose the following interface:
```go
func NewConnPair(addr1, addr1 net.Addr) (net.Conn, net.Conn)
```
```go
func NewPacketConnPair(addr1, addr1 net.Addr) (net.PacketConn, net.PacketConn)
```
```go
func NewDialerListenerPair(dialAddr, listenAddr net.Addr) (func(context.Context) (net.Conn, error), net.Listener)
```

Maybe it would be better to create new exported types and return those instead of the interfaces (e.g. `MemoryConn`, `MemoryPacketConn`, and `MemoryListener`)? That seems like it would be more consistent with the `net` package.

CC @rsc
Repository: pytorch
Issue: [jit] Default args don't work with TorchScript classes
Labels: oncall: jit,triaged,jit-backlog

```python
import torch

@torch.jit.script
class X(object):
    def __init__(self, a=2, y=3):
        self.a = a
        self.y = y

@torch.jit.script
def fn():
    return X()
```
```
__init__(ClassType<X> self, Tensor a, Tensor y) -> (None):
Argument a not provided.
:
at ../test.py:11:11
@torch.jit.script
def fn():
    return X()
           ~ <--- HERE

```

cc @suo
Repository: opencv
Issue: Make OpenCV an Official Emscripten Port
Labels: priority: low,category: javascript (js)

Hello,
OpenCVJS should be added to the [Emscripten port list]( https://github.com/emscripten-ports) so there will be official support for using OpenCV in C++ when compiling C++ to WASM using Emscripten.
From the [emscripten page]( https://emscripten.org/docs/compiling/Building-Projects.html#building-projects) here is what we need to do to get an official build:


> Adding more ports is fairly easy. Basically, the steps are
> • Make sure the port is open source and has a suitable license.
> • Add it to emscripten-ports on github. The ports maintainers can create the repo and add the relevant developers to a team for that repo, so they have write access.
> • Add a script to handle it under tools/ports/ (see existing code for examples) and use it in tools/ports/__init__.py.
> • Add testing in the test suite.
> Build system issues
> Build system self-execution
> Some large projects generate executables and run them in order to generate input for later parts of the build process (for example, a parser may be built and then run on a grammar, which then generates C/C++ code that implements that grammar). This sort of build process causes problems when using Emscripten because you cannot directly run the code you are generating.
> The simplest solution is usually to build the project twice: once natively, and once to JavaScript. When the JavaScript build procedure fails because a generated executable is not present, you can then copy that executable from the native build, and continue to build normally. This approach was successfully used for compiling Python (see tests/python/readme.md for more details).
> In some cases it makes sense to modify the build scripts so that they build the generated executable natively. For example, this can be done by specifying two compilers in the build scripts, emcc and gcc, and using gcc just for generated executables. However, this can be more complicated than the previous solution because you need to modify the project build scripts, and you may have to work around cases where code is compiled and used both for the final result and for a generated executable.
Repository: rust
Issue: Parallel rustc spends a lot of time creating threads
Labels: C-enhancement,I-compiletime,T-compiler,WG-compiler-parallel

[After some discussion on zulip](https://rust-lang.zulipchat.com/#narrow/stream/187679-t-compiler.2Fwg-parallel-rustc/topic/slowdown.20compiling.20Cargo/near/176509042) it looks like `rayon` will immediately spawn all threads for the thread pool on startup, but this isn't neessarily suitable for rustc's use case. In a profile I captured of compiling Cargo the first set of crates being compiled spent a huge amount of time just spawning threads.

I ran `perf` at the start of `cargo build` and killed it after a second or so, and the profile output of this (cleaned up) aggregated across all builds was:

<img width="277" alt="Capture" src="https://user-images.githubusercontent.com/64996/65552706-b3193d00-deea-11e9-9576-87469103d327.PNG">

I think that roughly means that 80% of the cpu time was spent transitively spawning threads/processes near the start of the build, and that seems a bit excessive!

cc @Mark-Simulacrum @Zoxc
Repository: go
Issue: proposal: x/sync: pass errgroup.WithContext's derived context directly
Labels: Proposal

Since API changes are something that is now possible to do with module versions, I thought it would be worth mentioning one that gnaws at me pretty frequently.

We use contexts heavily in my code-base, and it comes up moderately often that we want a cancellable or deadline-respecting `sync.WaitGroup`, and for this purpose authors tend to turn to `x/sync/errgroup`.  This often works out fine as long as the scope of the `errgroup.Group` is confined to a single function, but it also regularly will be used with something somewhat stateful.  These frequently follow a certain pattern, the core elements of which are exemplified by this contrived example:

```go
type ServerRunner struct {
  group   *errgroup.Group // *Group as a field
  groupCtx context.Context // context as a field (heavily discouraged)
}

func (sr *ServiceRunner) Run(server *servers.Server) {
  sr.Group.Go(func() error { return server.Run(sr.groupCtx) }) // wrapper that calls Go
}

func (sr *ServiceRunner) Wait(ctx context.Context) {
  select {
  case <-ctx.Done():
    return ctx.Err()
  case <-sr.groupCtx.Done():
    sr.groupCtx.Wait() // wrapper that calls wait and/or ctx.Done
    return sr.groupCtx.Err()
  }
}
```

I assert (without evidence) that this boilerplate is pretty common among context-respecting code that interacts with `errgroup.Group`, and in fact the above could be almost directly converted into a utility package, but then we would have ContextGroup wrapping errgroup wrapping WaitGroup... which feels excessive.

I have also observed that the context returned by `WithContext` is occasionally misused for code other than the goroutines spawned by `Go`, in some cases by directly shadowing the `ctx` variable, which often results in spooky action at a distance where one failure causes code in another part of the application to have its context cancelled.

So, I propose that the API for errgroup split out the context- and non-context APIs:

```go
type Group struct { /* ... */ }
func (Group) Go(func() error) { /* ... */ }
func (Group) Wait() error { /* ... */ }

type ContextGroup struct { /* ... */ }
func WithContext(ctx context.Context) *ContextGroup { /* ... */ }
func (ContextGroup) Go(func(context.Context) error) { /* ... */ }
func (ContextGroup) Wait(context.Context) error { /* ... */ }
```

Unfortunately, this is definitely a backward-incompatible change, and one for which there is probably little chance for a mechanical rewrite unless ContextGroup had a mechanism for retrieving its context.
Repository: go
Issue: net/http: Client round-robin across persistent connections
Labels: NeedsInvestigation,FeatureRequest

When connecting directly to a service spread across multiple hosts with DNS "load-balancing" it would be ideal if `http.Client` could round-robin requests over persistent connections to the multiple hosts listed in the A record.

Right now, if you want to ensure that load is balanced the only practical option is to disable HTTP keepalives.

One way this could be done is to have idle connection pools for each different A record, and do a DNS resolution for every request to decide which pool to use for that request.

This round-robin mode should likely be opt-in (or opt-out). When enabled, given a DNS record like the following:

```
example.local   60   IN   A   10.0.0.1
example.local   60   IN   A   10.0.0.2
```

`http.Client` would send roughly half the requests to .1 and half to .2, even when using persistent connections, and even if the client only ever sends requests serially.

---

Until this is fixed, if someone else also needs this you can take a look at https://github.com/CAFxX/balancer.
Repository: flutter
Issue: Add an ABI stability check to the embedder API.
Labels: c: new feature,team,engine,e: embedder,P3,team-engine,triaged-engine
Repository: go
Issue: proposal: spec: extended type inference for make and new
Labels: LanguageChange,Proposal,dotdotdot,LanguageChangeReview

### Rationale

Currently in Go, type inference works in one direction and one direction only: From the values of an assignment to the variable declarations. In other words, given some expression with a statically-determinable type, which is basically every expression, the type of a declaration can be omitted. This allows for a lot of the perceived lightness of Go over many statically typed languages.

However, there are a number of situations where this is _not_ possible, most of which have to do with `make()` and `new()`, both of which are unique, not including some stuff in the `unsafe` package, in that they take a type name as an argument. Normally this is a non-issue, as that type can be used to determine the return of the expression, thus allowing for inference in the normal manner:

```go
m := make(map[string]interface{})
s := make([]string, 0, 10)
p := new(int)
```

Sometimes the variable _must_ have a separately declared type, though, such as in the case of struct fields:

```go
type Example struct {
  m map[string]interface{}
}

func NewExample() *Example {
  return &Example{
    m: make(map[string]interface{}),
  }
}
```

This leads to unwanted repetition of the type name, making later alteration more awkward. In particular, I thought of this while reading through one of the many proposals about ways to make anonymous structs more useful with channels, and I realized that the following pattern could get very annoying, exacerbating the existing issue:

```go
type Example struct {
  c chan struct {
    v string
    r chan<- int
  }
}

func NewExample() *Example {
  return &Example{
    c: make(chan struct {
      v string
      r chan<- int
    },
  }
}
```

### Proposal

I propose the introduction of a new keyword, say `typeof`, which takes a variable, function name, or a struct field identifier and essentially acts as a stand-in for a standard type name, possibly with the restriction of _only_ being available as the argument to a `make()` or `new()` call. For example,

```go
return &Example{
  m: make(typeof Example.m),
}
```

This would allow a type name to be pegged to an already declared variable type elsewhere.

### Alternative

Alternatively, `make()` and `new()` could allow for the aforementioned types of identifiers directly, such as

```go
return &Example{
  m: make(Example.m),
}
```

This has the advantage of being backwards compatible, but is potentially less flexible if one wants to extend the functionality elsewhere later, such as to generics.
Repository: flutter
Issue: initialize Google maps plugin by providing API key at runtime 
Labels: c: new feature,p: maps,customer: product,package,c: proposal,team-ecosystem,P2,triaged-ecosystem

Is there anyway to provide the google maps api key from the code base rather than the manifest? I would like to be able to read the api key from our server before initializing google maps.

Thank you!
Repository: pytorch
Issue: Matrix corresponding to convolution by a 2D kernel (convmtx2)
Labels: feature,module: nn,triaged

## 🚀 Feature
A function `convmtx2` such that

    convmtx2(kernel, image.shape[1:]) @ image.flatten() == torch.nn.functional.conv2d(image[None], kernel)[0].flatten()

for any tensors `image` of shape `(in_channels, image_height, image_width)` and `kernel` of shape `(out_channels, in_channels, kernel_height, kernel_width)`.

## Motivation

Like its [MATLAB counterpart](convmtx2), `convmtx2` computes the matrix corresponding to convolution by a 2D kernel. This matrix is a doubly block [Toeplitz matrix](https://en.wikipedia.org/wiki/Toeplitz_matrix#Discrete_convolution).

This feature has been requested elsewhere. See [here](https://discuss.pytorch.org/t/obtaining-toeplitz-matrix-for-convolution/52968/3) and [here](https://stackoverflow.com/questions/56702873/is-there-an-function-in-pytorch-for-converting-convolutions-to-fully-connected-n) for example.