anon-iclr-submission/benchname-bug-localization huggingface dataset:
Repository: pykale/pykale
Issue: [Bug] Digits DA example failed, likely due to updates

# 🐛 Bug

Digits DA example failed, likely due to updated torchvision (or PL)

## To reproduce

Run https://colab.research.google.com/github/pykale/pykale/blob/main/examples/digits_dann_lightn/tutorial.ipynb#scrollTo=DiEqCANrpAy1

** Stack trace/error message **
```
import logging
import os

from config import get_cfg_defaults
import numpy as np
import pytorch_lightning as pl
import torch
from torch.utils.data import DataLoader
from torch.utils.data import SequentialSampler
import torchvision

from model import get_model
from pytorch_lightning.callbacks import ModelCheckpoint
from pytorch_lightning.loggers import TensorBoardLogger

from kale.loaddata.image_access import DigitDataset
from kale.loaddata.multi_domain import MultiDomainDatasets
from kale.utils.seed import set_seed

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-76f9aafdc93d> in <module>()
     10 import torchvision
     11 
---> 12 from model import get_model
     13 from pytorch_lightning.callbacks import ModelCheckpoint
     14 from pytorch_lightning.loggers import TensorBoardLogger

2 frames
/usr/local/lib/python3.7/dist-packages/kale/embed/video_i3d.py in <module>()
     12 import torch.nn as nn
     13 import torch.nn.functional as F
---> 14 from torchvision.models.utils import load_state_dict_from_url
     15 
     16 model_urls = {

ModuleNotFoundError: No module named 'torchvision.models.utils'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
```

Changed files:
kale/embed/video_i3d.py

diff --git a/kale/embed/video_i3d.py b/kale/embed/video_i3d.py
index 69f42fc..be9a445 100644
--- a/kale/embed/video_i3d.py
+++ b/kale/embed/video_i3d.py
@@ -11,7 +11,7 @@ https://github.com/deepmind/kinetics-i3d/blob/master/i3d.py
 import torch
 import torch.nn as nn
 import torch.nn.functional as F
-from torchvision.models.utils import load_state_dict_from_url
+from torch.hub import load_state_dict_from_url
 
 model_urls = {
     "rgb_imagenet": "https://github.com/XianyuanLiu/pytorch-i3d/raw/master/models/rgb_imagenet.pt",
Repository: munkireport/munkireport-php
Issue: displays.py Exception handling

displays.py is not handling exceptions correctly, therefore it is preventing munki from running ok when an exception occurs.

I have a 10.6.8 client that chokes on line 42:

``` sh
/usr/local/munki/preflight.d/displays.py                                                                                                
Traceback (most recent call last):
  File "/usr/local/munki/preflight.d/displays.py", line 42, in <module>
    elif display['_spdisplays_display-vendor-id'] != "610":
KeyError: '_spdisplays_display-vendor-id'
```


Changed files:
app/modules/displays_info/scripts/displays.py

diff --git a/app/modules/displays_info/scripts/displays.py b/app/modules/displays_info/scripts/displays.py
index e5d80bba..b4bb1141 100755
--- a/app/modules/displays_info/scripts/displays.py
+++ b/app/modules/displays_info/scripts/displays.py
@@ -35,15 +35,19 @@ for vga in plist[0]['_items']:
     #loop within each display
     for display in vga['spdisplays_ndrvs']:
 
-      #Serial and Type sections
+      #Type section
+      try:
+        if display['_spdisplays_display-vendor-id'] == "610":
+          result += 'Type = Internal'
+        else:
+          result += 'Type = External'
+      except KeyError as error: #this catches errors in headless Xserve and minis
+          result += 'Type = Internal'
+
+      #Serial section
       if display.get('spdisplays_display-serial-number', None):
-        result += 'Type = External'
         result += '\\nSerial = ' + str(display['spdisplays_display-serial-number'])
-      elif display['_spdisplays_display-vendor-id'] != "610":
-        result += 'Type = External'
-        result += '\\nSerial = n/a'
       else:
-        result += 'Type = Internal'
         result += '\\nSerial = n/a'
 
       try:
Repository: adafruit/adafruit_blinka
Issue: Error initializing PWMOut object (sysfs_pwmout)

Board: Google Coral
Blinka 1.3.3
Platform Detect 1.0.3

```
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import board
>>> import pulseio
>>> led = pulseio.PWMOut(board.PWM3, frequency=5000, duty_cycle=0)
OSError: [Errno 22] Invalid argument

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py", line 55, in __init__
    self._open(pin, duty_cycle, frequency, variable_frequency)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py", line 93, in _open
    self._set_enabled(False)
  File "/usr/local/lib/python3.5/dist-packages/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py", line 256, in _set_enabled
    self._write_pin_attr(self._pin_enable_path, "1" if value else "0")
  File "/usr/local/lib/python3.5/dist-packages/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py", line 130, in _write_pin_attr
    f_attr.write(value + "\\n")
OSError: [Errno 22] Invalid argument
```

Changed files:
src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py

diff --git a/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py b/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py
index 6266fbb..89e0cbb 100644
--- a/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py
+++ b/src/adafruit_blinka/microcontroller/generic_linux/sysfs_pwmout.py
@@ -90,12 +90,12 @@ class PWMOut(object):
         except IOError as e:
             raise PWMError(e.errno, "Exporting PWM pin: " + e.strerror)
 
-        self._set_enabled(False)
-        
+        #self._set_enabled(False) # This line causes a write error when trying to enable
+                
         # Look up the period, for fast duty cycle updates
         self._period = self._get_period()
 
-        self.duty_cycle = 0
+        #self.duty_cycle = 0  # This line causes a write error when trying to enable
 
         # set frequency
         self.frequency = freq
Repository: adafruit/adafruit_blinka
Issue: Pin numbers for Rock 4C Plus not available

I am using the library on a Rock 4C Plus. I am trying to use GPIO 73 and 74 (pin 31 and 29) 

Blinka version = '8.15.2'
Python version = 3.8.10
OS = Ubuntu 20.04 arm64

```
>>> board.board_id
'ROCK_PI_4C+'
```

Pin assignment:
```
outPin = board.B1
AttributeError: module 'board' has no attribute 'B1'
```

As I understand the mapping is available here:
https://github.com/adafruit/Adafruit_Blinka/blob/main/src/adafruit_blinka/microcontroller/rockchip/rk3399/pin.py#L24-L25

My assumption is that I need to use pin board.B1 and board.B2, but they don't show up. All available pins are shown below:

```
board.ADC_IN0   board.D27       board.D8        board.SDA7
board.CS        board.D28       board.I2C(      board.SPI(
board.D10       board.D29       board.MISO      board.UART2_RX
board.D11       board.D3        board.MOSI      board.UART2_TX
board.D12       board.D31       board.PWM0      board.UART4_RX
board.D13       board.D32       board.SCK       board.UART4_TX
board.D15       board.D33       board.SCL       board.UART_RX
board.D16       board.D35       board.SCL2      board.UART_TX
board.D18       board.D36       board.SCL6      board.ap_board
board.D19       board.D37       board.SCL7      board.board_id
board.D21       board.D38       board.SCLK      board.detector
board.D22       board.D40       board.SDA       board.pin
board.D23       board.D5        board.SDA2      board.sys
board.D24       board.D7        board.SDA6

board.pin
<module 'adafruit_blinka.microcontroller.rockchip.rk3399_t.pin' from '/home/rock/.local/lib/python3.8/site-packages/adafruit_blinka/microcontroller/rockchip/rk3399_t/pin.py'
```


@wgroeneveld Tagging you if you don't mind. Do you happen to know what the problem is?

Changed files:
src/adafruit_blinka/board/radxa/rockpi4.py

diff --git a/src/adafruit_blinka/board/radxa/rockpi4.py b/src/adafruit_blinka/board/radxa/rockpi4.py
index 9fdccbc..c8070ed 100644
--- a/src/adafruit_blinka/board/radxa/rockpi4.py
+++ b/src/adafruit_blinka/board/radxa/rockpi4.py
@@ -46,9 +46,9 @@ SCL7 = D5
 SDA = SDA2
 SCL = SCL2
 
-SCLK = D19
-MOSI = D21
-MISO = D23
+SCLK = D23
+MOSI = D19
+MISO = D21
 CS = D24
 SCK = SCLK
Repository: pmeal/openpnm
Issue: Change default solver to scipy's spsolve if pypardiso is not found

Currently, the default solver is `pypardiso`, which relies on MKL, and installing MKL using `pip` seems to be not so straightforward.

Changed files:
openpnm/algorithms/GenericTransport.py

diff --git a/openpnm/algorithms/GenericTransport.py b/openpnm/algorithms/GenericTransport.py
index ef8440c11..adea405ea 100644
--- a/openpnm/algorithms/GenericTransport.py
+++ b/openpnm/algorithms/GenericTransport.py
@@ -669,11 +669,23 @@ class GenericTransport(GenericAlgorithm):
                 return x
         # PyPardiso
         elif self.settings['solver_family'] == 'pypardiso':
+            try:
+                import pypardiso
+            except ModuleNotFoundError:
+                if self.Np <= 8000:
+                    logger.critical("Pardiso not found, reverting to much "
+                                    + "slower spsolve.  Install pardiso with: "
+                                    + "conda install -c conda-forge pardiso4py")
+                    self.settings['solver_family'] = 'scipy'
+                    return self._get_solver()
+                else:
+                    raise Exception("Pardiso not found. Install it with: "
+                                    + "conda install -c conda-forge pardiso4py")
+
             def solver(A, b, **kwargs):
                 r"""
                 Wrapper method for PyPardiso sparse linear solver.
                 """
-                import pypardiso
                 x = pypardiso.spsolve(A=A, b=b)
                 return x
         else:
Repository: pmeal/openpnm
Issue: set_variable_props 'merge' does not remove duplicates

The set_variable_props method does not remove duplicates using mode='merge'. The docstring says it will but it doesn't. I checked the set_source method and that method no longer uses 'merge' as a mode. Instead it uses 'add' but does delete duplicate propnames in self.settings['sources']. Although, the docstring in set_source does not say add means delete duplicates. Should we update docstring here as well?


Changed files:
openpnm/algorithms/_reactive_transport.py, openpnm/algorithms/_generic_transport.py

diff --git a/openpnm/algorithms/_generic_transport.py b/openpnm/algorithms/_generic_transport.py
index 7dcf7a3d1..7920958ed 100644
--- a/openpnm/algorithms/_generic_transport.py
+++ b/openpnm/algorithms/_generic_transport.py
@@ -5,7 +5,7 @@ from openpnm.topotools import is_fully_connected
 from openpnm.algorithms import GenericAlgorithm
 from openpnm.algorithms import BCsMixin
 from openpnm.utils import logging, prettify_logger_message
-from openpnm.utils import Docorator, SettingsAttr
+from openpnm.utils import Docorator, SettingsAttr, TypedSet
 from openpnm.solvers import PardisoSpsolve
 from ._solution import SteadyStateSolution
 docstr = Docorator()
@@ -38,7 +38,7 @@ class GenericTransportSettings:
     quantity = ''
     conductance = ''
     cache = True
-    variable_props = []
+    variable_props = TypedSet()
 
 
 @docstr.get_sections(base='GenericTransport', sections=['Parameters'])
@@ -492,8 +492,8 @@ class GenericTransport(GenericAlgorithm, BCsMixin):
         # Handle mode
         mode = self._parse_mode(mode, allowed=['merge', 'overwrite'], single=True)
         if mode == 'overwrite':
-            self.settings['variable_props'] = []
+            self.settings['variable_props'] = TypedSet()
         # parse each propname and append to variable_props in settings
         for variable_prop in variable_props:
             variable_prop = self._parse_prop(variable_prop, 'pore')
-            self.settings['variable_props'].append(variable_prop)
+            self.settings['variable_props'].add(variable_prop)
diff --git a/openpnm/algorithms/_reactive_transport.py b/openpnm/algorithms/_reactive_transport.py
index bc39cc1da..3e207f1c8 100644
--- a/openpnm/algorithms/_reactive_transport.py
+++ b/openpnm/algorithms/_reactive_transport.py
@@ -298,7 +298,9 @@ class ReactiveTransport(GenericTransport):
         # Generate global dependency graph
         dg = nx.compose_all([x.models.dependency_graph(deep=True)
                              for x in [phase, *geometries, *physics]])
-        base = [self.settings["quantity"]] + self.settings["variable_props"]
+        variable_props = self.settings["variable_props"].copy()
+        variable_props.add(self.settings["quantity"])
+        base = list(variable_props)
         # Find all props downstream that depend on base props
         dg = nx.DiGraph(nx.edge_dfs(dg, source=base))
         if len(dg.nodes) == 0:
Repository: pmeal/openpnm
Issue: Better error when unknown filetype is passed to Project.export_data

Currently if `filetype` is not part of `openpnm.io` module, it returns:
```bash
AttributeError: 'NoneType' object has no attribute 'export_data'
```
which is a bit obscure.

Changed files:
tests/unit/utils/ProjectTest.py, openpnm/utils/_project.py

diff --git a/openpnm/utils/_project.py b/openpnm/utils/_project.py
index 59e736312..b22dcf083 100644
--- a/openpnm/utils/_project.py
+++ b/openpnm/utils/_project.py
@@ -594,7 +594,12 @@ class Project(list):
                     filetype = temp[filetype]
             else:
                 raise Exception('File type not given')
-
+        else:
+            temp2 = {"hdf5", "xdmf", "vtk", "pickle", "csv", "mat"}
+            if filetype in temp2:
+                print('filetype is supported')
+            else:
+                raise Exception('File type is not supported')
         # Fetch correct io class, using case insensitive look-up
         def igetattr(obj, attr):
             for a in dir(obj):
diff --git a/tests/unit/utils/ProjectTest.py b/tests/unit/utils/ProjectTest.py
index ae57ed1f6..487e27afa 100644
--- a/tests/unit/utils/ProjectTest.py
+++ b/tests/unit/utils/ProjectTest.py
@@ -383,6 +383,11 @@ class ProjectTest:
         self.proj.export_data(phases=self.phase1, filename=fname,
                               filetype='mat')
         os.remove(fname+'.mat')
+        
+        with pytest.raises(Exception):
+            self.proj.export_data(phases=self.phase1, filename=fname,
+                                  filetype='blah')
+            
 
     def test_inspect_pores_and_throats(self):
         df = self.proj.inspect_locations(element='pores', indices=[0, 2, 3])
Repository: pmeal/openpnm
Issue: Transient Ionic Conductance does not pass phase through super().__init__

Transient Ionic Conductance inherits from transient reactive transport. The __init__ method of transient reactive transport takes in a phase object now. But I guess transient ionic conductance which calls that same __init__ method does not pass phase.  See [line 26](https://github.com/PMEAL/OpenPNM/blob/607328919fbc2049920de7a1986547b449016634/openpnm/algorithms/_transient_ionic_conduction.py#L26)


Changed files:
openpnm/algorithms/_transient_ionic_conduction.py

diff --git a/openpnm/algorithms/_transient_ionic_conduction.py b/openpnm/algorithms/_transient_ionic_conduction.py
index 79823cac1..48d522bbd 100644
--- a/openpnm/algorithms/_transient_ionic_conduction.py
+++ b/openpnm/algorithms/_transient_ionic_conduction.py
@@ -21,7 +21,6 @@ class TransientIonicConduction(TransientReactiveTransport,
     of pure diffusion and advection-diffusion problems.
     """
 
-    def __init__(self, phase, settings=None, **kwargs):
+    def __init__(self, settings=None, **kwargs):
         self.settings = SettingsAttr(TransientIonicConductionSettings, settings)
         super().__init__(settings=self.settings, **kwargs)
-        self.settings['phase'] = phase.name
Repository: pmeal/openpnm
Issue: Explicit mode in transient solver throws error


When using t_scheme = 'explicit' in transient advection-diffusion, it complains that variable f2 is not assigned.


Changed files:
openpnm/algorithms/TransientReactiveTransport.py

diff --git a/openpnm/algorithms/TransientReactiveTransport.py b/openpnm/algorithms/TransientReactiveTransport.py
index 57ad27f21..a411c47a8 100644
--- a/openpnm/algorithms/TransientReactiveTransport.py
+++ b/openpnm/algorithms/TransientReactiveTransport.py
@@ -500,10 +500,7 @@ class TransientReactiveTransport(ReactiveTransport):
         Correction (built for transient simulations) depends on the time scheme
 
         """
-        if self.settings['t_scheme'] == 'cranknicolson':
-            f1 = 0.5
-        else:
-            f1 = 1.0
+        f1, f2, f3 = self._get_f1_f2_f3()
         phase = self.project.phases()[self.settings['phase']]
         for item in self.settings['sources']:
             Ps = self.pores(item)
Repository: pmeal/openpnm
Issue: Multiple identical calls to set_source method creates duplicate source terms

```
rxn.set_source(propname='pore.2nd_order_rxn', pores=Ps)
print(rxn.settings["sources"])
rxn.set_source(propname='pore.2nd_order_rxn', pores=Ps)
print(rxn.settings["sources"])

['pore.2nd_order_rxn']
['pore.2nd_order_rxn', 'pore.2nd_order_rxn']
```
`set_source` must check for duplicate `propname`, and ignore those.

Changed files:
openpnm/algorithms/ReactiveTransport.py, tests/unit/algorithms/ReactiveTransportTest.py

diff --git a/openpnm/algorithms/ReactiveTransport.py b/openpnm/algorithms/ReactiveTransport.py
index 4edd1ca73..33ea931e3 100644
--- a/openpnm/algorithms/ReactiveTransport.py
+++ b/openpnm/algorithms/ReactiveTransport.py
@@ -154,7 +154,9 @@ class ReactiveTransport(GenericTransport):
                             + 'pores, cannot also assign source terms')
         # Set source term
         self[propname] = locs
-        self.settings['sources'].append(propname)
+        # Check if propname already in source term list
+        if propname not in self.settings['sources']:
+            self.settings['sources'].append(propname)
         # Add source term as an iterative prop
         self.set_iterative_props(propname)
 
diff --git a/tests/unit/algorithms/ReactiveTransportTest.py b/tests/unit/algorithms/ReactiveTransportTest.py
index 3f5975481..6968e92be 100644
--- a/tests/unit/algorithms/ReactiveTransportTest.py
+++ b/tests/unit/algorithms/ReactiveTransportTest.py
@@ -23,6 +23,20 @@ class ReactiveTransportTest:
                             quantity='pore.concentration',
                             regen_mode='deferred')
 
+    def test_multiple_set_source_with_same_name_should_only_keep_one(self):
+        rt = op.algorithms.ReactiveTransport(network=self.net,
+                                             phase=self.phase)
+        rt.settings.update({'conductance': 'throat.diffusive_conductance',
+                            'quantity': 'pore.concentration'})
+        rt.set_source(pores=self.net.pores('bottom'), propname='pore.reaction')
+        rt.set_source(pores=self.net.pores('bottom'), propname='pore.reaction')
+        rt.set_source(pores=self.net.pores('bottom'), propname='pore.reaction')
+        rt.set_value_BC(pores=self.net.pores('top'), values=1.0)
+        rt.run()
+        c_mean_desired = 0.648268
+        c_mean = rt['pore.concentration'].mean()
+        assert_allclose(c_mean, c_mean_desired, rtol=1e-6)
+
     def test_one_value_one_source(self):
         rt = op.algorithms.ReactiveTransport(network=self.net,
                                              phase=self.phase)
Repository: pmeal/openpnm
Issue: Error using target.name in ad_dif_mig conductance model?

Is this [line 65](https://github.com/PMEAL/OpenPNM/blob/c9514b858d1361b2090b2f9579280cbcd476c9b0/openpnm/models/physics/ad_dif_mig_conductance.py#L65) an error? Can this actually work? Because this line is giving me errors when I use phys.add_model. I get a KeyError back.

Changed files:
openpnm/models/physics/ad_dif_mig_conductance.py, openpnm/models/physics/hydraulic_conductance.py

diff --git a/openpnm/models/physics/ad_dif_mig_conductance.py b/openpnm/models/physics/ad_dif_mig_conductance.py
index 0e50620a8..9ac057eb9 100644
--- a/openpnm/models/physics/ad_dif_mig_conductance.py
+++ b/openpnm/models/physics/ad_dif_mig_conductance.py
@@ -62,7 +62,8 @@ def ad_dif_mig(target,
     throat_valence = throat_valence + "." + ion
 
     network = target.project.network
-    throats = network.throats(target.name)
+    domain = target._domain
+    throats = domain.throats(target.name)
     phase = target.project.find_phase(target)
     cn = network["throat.conns"][throats]
     T = phase[throat_temperature][throats]
diff --git a/openpnm/models/physics/hydraulic_conductance.py b/openpnm/models/physics/hydraulic_conductance.py
index 0e1153452..aef0ecbc7 100644
--- a/openpnm/models/physics/hydraulic_conductance.py
+++ b/openpnm/models/physics/hydraulic_conductance.py
@@ -138,7 +138,8 @@ def hagen_poiseuille_power_law(
     """
     # Fetch GenericPhysicss
     network = target.project.network
-    throats = network.throats(target.name)
+    domain = target._domain
+    throats = domain.throats(target.name)
     phase = target.project.find_phase(target)
     cn = network.conns[throats]
Repository: pmeal/openpnm
Issue: Capitalization of README.md is a problem

I guess it used to be readme.md, now its all caps.  This is causing problems with some incoming links. 

While we're at it, this readme does not render on PyPI, which we should fix.  We cannot change to the file to rst, since there are many inbound links to the md file, so we should figure out how to make PyPI work for md files.

Changed files:
setup.py

diff --git a/setup.py b/setup.py
index 7b2690876..22162ac90 100644
--- a/setup.py
+++ b/setup.py
@@ -15,10 +15,17 @@ with open(ver_path) as f:
         if line.startswith('__version__'):
             exec(line, main_)
 
+# Read the contents of README file
+this_directory = os.path.abspath(os.path.dirname(__file__))
+with open(os.path.join(this_directory, 'README.md'), encoding='utf-8') as f:
+    long_description = f.read()
+
 setup(
     name='openpnm',
     description='A framework for conducting pore network modeling simulations '
     + 'of multiphase transport in porous materials',
+    long_description=long_description,
+    long_description_content_type='text/markdown',
     version=main_['__version__'],
     zip_safe=False,
     classifiers=[
Repository: pmeal/openpnm
Issue: GenericTransport should accept solver instance, not the class

https://github.com/PMEAL/OpenPNM/blob/007c521a4cb93d45beb26cb878b9b1ee1762a4f8/openpnm/algorithms/_generic_transport.py#L222-L224

Line 224 should be removed, and `getattr(solvers, ws.settings.default_solver)` needs a `()` at the end.

Changed files:
openpnm/algorithms/_generic_transport.py

diff --git a/openpnm/algorithms/_generic_transport.py b/openpnm/algorithms/_generic_transport.py
index 45fe89a1d..dda484128 100644
--- a/openpnm/algorithms/_generic_transport.py
+++ b/openpnm/algorithms/_generic_transport.py
@@ -219,9 +219,8 @@ class GenericTransport(GenericAlgorithm, BCsMixin):
 
         """
         logger.info('Running GenericTransport')
-        solver = getattr(solvers, ws.settings.default_solver) \\
-            if solver is None else solver
-        solver = solver()  # Instantiate the fetched solver class
+        if solver is None:
+            solver = getattr(solvers, ws.settings.default_solver)()
         # Perform pre-solve validations
         self._validate_settings()
         self._validate_data_health()
Repository: probabilistic-numerics/probnum
Issue: Tests in diffeq are failing for optimization methods

Currently many tests for optimization methods in `probnum.optim` fail in the `diffeq` branch. This should be fixed so that proposed changes are built by Travis and properly tested.

Changed files:
src/probnum/optim/stoppingcriterion/stoppingcriterion.py

diff --git a/src/probnum/optim/stoppingcriterion/stoppingcriterion.py b/src/probnum/optim/stoppingcriterion/stoppingcriterion.py
index ab1e3cb..f00d928 100644
--- a/src/probnum/optim/stoppingcriterion/stoppingcriterion.py
+++ b/src/probnum/optim/stoppingcriterion/stoppingcriterion.py
@@ -39,7 +39,7 @@ class NormOfGradient(StoppingCriterion):
     def __init__(self, tol):
         """
         """
-        if tol >= 0:
+        if tol < 0:
             raise ValueError("Please enter nonnegative atol.")
         self._tol = tol
 
@@ -60,7 +60,7 @@ class NormOfGradient(StoppingCriterion):
         """
         not_fulfilling = np.inf
         output = Eval(None, None, not_fulfilling, None)
-        if self.fulfilled(curriter, output) is False:
+        if self.fulfilled(output, curriter):
             raise RuntimeError("Could not initialize the StoppingCriterion.")
         return output
 
@@ -72,7 +72,7 @@ class DiffOfFctValues(StoppingCriterion):
     def __init__(self, tol):
         """
         """
-        if tol >= 0:
+        if tol < 0:
             raise ValueError("Please enter nonnegative rtol.")
         self._tol = tol
 
@@ -90,6 +90,6 @@ class DiffOfFctValues(StoppingCriterion):
         """
         """
         output = Eval(None, curriter.fx + 10 * self._tol, None, None)
-        if self.fulfilled(curriter, output) is False:
+        if self.fulfilled(curriter, output):
             raise RuntimeError("Could not initialize the StoppingCriterion")
         return output
Repository: betcode-org/betfair
Issue: Streaming Best Available Bug

Found an issue where the following became present in MarketBook:

{'size': 0, 'price': 0}

Tried to recreate but I can't looks like it was due to receiving an update to delete a price when it was not present in the cache.

Changed files:
betfairlightweight/utils.py, tests/test_utils.py, betfairlightweight/__init__.py

diff --git a/betfairlightweight/__init__.py b/betfairlightweight/__init__.py
index d9a6b0c..43a81be 100644
--- a/betfairlightweight/__init__.py
+++ b/betfairlightweight/__init__.py
@@ -5,5 +5,5 @@ from .filters import MarketFilter, StreamingMarketFilter, StreamingMarketDataFil
 
 
 __title__ = 'betfairlightweight'
-__version__ = '0.9.9'
+__version__ = '0.9.10'
 __author__ = 'Liam Pauling'
diff --git a/betfairlightweight/utils.py b/betfairlightweight/utils.py
index b69d7b1..041460d 100644
--- a/betfairlightweight/utils.py
+++ b/betfairlightweight/utils.py
@@ -102,5 +102,6 @@ def update_available(available, book_update, deletion_select):
                     updated = True
                     break
 
-        if not updated:
+        if not updated and book[deletion_select] != 0:
+            # handles betfair bug, http://forum.bdp.betfair.com/showthread.php?t=3351
             available.append(book)
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 392858b..f21b9e3 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -144,6 +144,14 @@ class UtilsTestUpdateAvailable(unittest.TestCase):
         update_available(current, book_update, 2)
         assert current == expected
 
+        # tests handling of betfair bug, http://forum.bdp.betfair.com/showthread.php?t=3351
+        book_update = [[2, 0, 0], [1, 1.01, 9835.74], [0, 1.02, 1126.22]]
+        current = [[1, 1.01, 9835.74], [0, 1.02, 1126.22]]
+        expected = [[1, 1.01, 9835.74], [0, 1.02, 1126.22]]
+
+        update_available(current, book_update, 2)
+        assert current == expected
+
     def test_update_available_new_remove(self):
         book_update = [[27, 0]]
         current = [[27, 0.95], [13, 28.01], [1.02, 1157.21]]
Repository: jazzband/wagtailmenus
Issue: Import error on pip install

When installing in a new environment (say in docker on deploy), the pip install will fail with `ImportError: No module named 'django'`.

This happens because setup.py does a `from wagtailmenus import __version__` which loads `__init__.py` which in itself imports django. It should not assume, however, django is already built and installed during a `pip install -r requirements.txt`.

Changed files:
wagtailmenus/__init__.py

diff --git a/wagtailmenus/__init__.py b/wagtailmenus/__init__.py
index 22af1b5..6eb9631 100644
--- a/wagtailmenus/__init__.py
+++ b/wagtailmenus/__init__.py
@@ -1,5 +1,4 @@
 from __future__ import absolute_import, unicode_literals
-from django.core.exceptions import ImproperlyConfigured
 from .app_settings import Settings
 
 __version__ = '2.1.0'
@@ -35,6 +34,8 @@ def get_main_menu_model():
     if no custom model is defined.
     """
     from django.apps import apps
+    from django.core.exceptions import ImproperlyConfigured
+
     model_string = get_main_menu_model_string()
     try:
         return apps.get_model(model_string)
@@ -57,6 +58,8 @@ def get_flat_menu_model():
     if no custom model is defined.
     """
     from django.apps import apps
+    from django.core.exceptions import ImproperlyConfigured
+
     model_string = get_flat_menu_model_string()
     try:
         return apps.get_model(model_string)
Repository: jazzband/wagtailmenus
Issue: Travis builds are no longer failing when tests fail

Not sure of the cause here, but since the following commit, builds in Travis have been passing, even though the django tests themselves are failing:

https://github.com/rkhleics/wagtailmenus/commit/674a7ba935bb21c5640120f09ef69284884d7803

Build results for this PR can be found at:
https://travis-ci.org/rkhleics/wagtailmenus/builds/266977121

Changed files:
runtests.py

diff --git a/runtests.py b/runtests.py
index 20de41a..2a293fa 100644
--- a/runtests.py
+++ b/runtests.py
@@ -42,10 +42,7 @@ def runtests():
         pass
 
     argv = [sys.argv[0], 'test']
-    try:
-        execute_from_command_line(argv)
-    except:
-        pass
-
+    return execute_from_command_line(argv)
+    
 if __name__ == '__main__':
-    runtests()
+    sys.exit(runtests())