Open in app

Sign In

Write

Sign In

Saisankar Gochhayat
Saisankar Gochhayat

92 Followers

Home

About

Mar 16

Dealing with mutable arguments in Unit Tests

If you pass a mutable argument and then try to unittest it with .assert_called_with(), you might run into problems. This issue can be confusing since it might seem like there is a bug with the testing framework (such as pytest), and many people have been led down that path. After digging deeper, I found the following article that explains the problem: https://docs.python.org/3/library/unittest.mock-examples.html#coping-with-mutable-arguments

Python

1 min read

Python

1 min read


Oct 31, 2020

Find the intersection of two lists in Python with Duplicates.

>>> from collections import Counter >>> a = Counter([1,2,3,4,5]) >>> b = Counter([1,3,5,6]) >>> a &= b >>> list(a.elements()) [1, 3, 5]

Python

1 min read

Python

1 min read


Mar 14, 2020

Leetcode 34

This is an interesting problem involving Binary search. Here is the link to the problem — https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array/ class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: gLow, gHigh = 0, 0 low…

Leetcode

1 min read

Leetcode

1 min read


Feb 28, 2020

Let's talk about Union Find.

Union Find is a very interesting data-structure that makes a lot of graph problems easy to solve. — Let’s say, you have a set of N elements that are partitioned into further subsets, and you have to keep track of connectivity of each element in a particular subset or connectivity of subsets with each other. To do this operation efficiently, you can use the Union-Find Data Structure. There…

Algorithms

2 min read

Algorithms

2 min read


Oct 10, 2019

Leetcode 934 Shortest Bridge

Shortest Bridge - LeetCode In a given 2D binary array A, there are two islands. (An island is a 4-directionally connected group of 1 s not…leetcode.com Here is one of the solutions I understood, I am putting it here for future reference. I have added comments to make it easier to understand. # Start with picking the first 1 you can find. # Pick that point and start dfs to all all the edges for that…

Programming

2 min read

Programming

2 min read


Nov 28, 2018

Changing the swap size on Ubuntu 18.04.

So one fine evening I find my budget laptop freezing up due to Chrome hogging up all the memory. Upon checking my RAM usage I figured that out of my 6.8GB of usable ram barely 500mb was left unused. By default ubuntu had set up a 2GB swap space, I…

Ubuntu

1 min read

Changing the swap size on Ubuntu 18.04.
Changing the swap size on Ubuntu 18.04.
Ubuntu

1 min read

Saisankar Gochhayat

Saisankar Gochhayat

92 Followers

Software Developer

Following
  • Santa Nibedita

    Santa Nibedita

  • Amitosh Swain Mahapatra

    Amitosh Swain Mahapatra

  • Pratick Roy

    Pratick Roy

  • Manaswini Das

    Manaswini Das

  • melissa mcewen

    melissa mcewen

See all (97)

Help

Status

Writers

Blog

Careers

Privacy

Terms

About

Text to speech

Teams