Giter VIP home page Giter VIP logo

elixir-bimap's People

Contributors

ckampfe avatar dependabot-preview[bot] avatar dependabot[bot] avatar mat-hek avatar mkaput avatar nulloranje avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

elixir-bimap's Issues

Enumerable.slice/1 is not implemented

If you try to use bimap 1.0.0, the following warnings are shown during compilation:

==> bimap
Compiling 2 files (.ex)
warning: function slice/1 required by protocol Enumerable is not implemented (in module Enumerable.BiMap)
  lib/bimap.ex:465

warning: function slice/1 required by protocol Enumerable is not implemented (in module Enumerable.BiMultiMap)
  lib/bimultimap.ex:544

Generated bimap app

Dialyzer warnings when BiMap is used as a module attribute

When BiMap is used as a module attribute, e.g.

defmodule Example do
  @attr BiMap.new(%{1 => :a})
end

the dialyzer complains about the use of opaque type. Although it is correct (if both the implementation of new and the internal representation change, until recompilation the beam file will contain the old representation) it hinders the usability.

One way to solve that would be to follow Elixir's steps with MapSet elixir-lang/elixir#11917 making the top-level struct keys public and limit "opaqueness" to the values. WDYT about it?

property it puts items into bimaps (BiMapPropertiesTest) failed

  1) property it puts items into bimaps (BiMapPropertiesTest)
     test/bimap_properties_test.exs:56
     Failed with generated values (after 2 successful runs):
     
         * Clause:    key_set <- nonempty(uniq_list_of(term()))
           Generated: [%{false => -0.5, #Reference<0.0.1.69648> => "}", "" => -1}, {:N2}]
         
         * Clause:    value_set <- uniq_list_of(term(), length: Enum.count(key_set))
           Generated: [7.5, -1]
         
         * Clause:    random_key <- term()
           Generated: 9.0
         
         * Clause:    random_value <- term()
           Generated: -1.0
     
     Expected truthy, got false
     code: assert BiMap.equal?(put_bimap, BiMap.new(put_regular_map))
     stacktrace:
       test/bimap_properties_test.exs:72: anonymous fn/5 in BiMapPropertiesTest."property it puts items into bimaps"/1
       (stream_data) lib/stream_data.ex:2148: StreamData.shrink_failure/6
       (stream_data) lib/stream_data.ex:2108: StreamData.check_all/7
       test/bimap_properties_test.exs:57: (test)

ref: https://travis-ci.com/github/mkaput/elixir-bimap/jobs/493002978

BiMap.put/3 leaves old mappings

When inserting a key/value pair into a BiMap where the key and value are already defined, the updated BiMap leaves old mappings in place, and thus the BiMap is no longer bijective. An example is below:

iex(1)> m = BiMap.new([a: 1, b: 2])
#BiMap<[a: 1, b: 2]>
iex(2)> test = BiMap.put(m, :a, 2)
#BiMap<[a: 2, b: 2]>
iex(3)> BiMap.size(m)  
2
iex(4)> BiMap.size(test)
2     # Wouldn't this be 1?
iex(5)> BiMap.left(m)
%{a: 1, b: 2}
iex(6)> BiMap.left(test)
%{a: 2, b: 2}
iex(7)> BiMap.right(m)
%{1 => :a, 2 => :b}
iex(8)> BiMap.right(test)
%{1 => :a, 2 => :a}
iex(9)> BiMap.fetch_key(test, 1)
{:ok, :a}
iex(10)> BiMap.fetch_key(test, 2)
{:ok, :a}
iex(11)> BiMap.get(test, :a)
2
iex(12)> BiMap.get(test, :b)
2

In this example, the size of the map should be reduced from 2 elements to 1 element. I suspect that the old mappings should be dropped from the internal maps before updating.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.