Class: ActiveRecord::Associations::CollectionProxy
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
::ActiveRecord::Relation
|
|
|
Instance Chain:
|
|
| Inherits: |
ActiveRecord::Relation
|
| Defined in: | activerecord/lib/active_record/associations/collection_proxy.rb |
Overview
Association
proxies in Active Record are middlemen between the object that holds the association, known as the @owner
, and the actual associated object, known as the @target
. The kind of association any proxy is about is available in @reflection
. That’s an instance of the class ::ActiveRecord::Reflection::AssociationReflection
.
For example, given
class Blog < ActiveRecord::Base
has_many :posts
end
blog = Blog.first
the association proxy in blog.posts
has the object in blog
as @owner
, the collection of its posts as @target
, and the @reflection
object represents a :has_many
macro.
This class delegates unknown methods to @target
via method_missing
.
The @target
object is not loaded until needed. For example,
blog.posts.count
is computed directly through SQL and does not trigger by itself the instantiation of the actual post records.
Constant Summary
::ActiveRecord::Batches
- Included
::ActiveRecord::QueryMethods
- Included
DEFAULT_VALUES, FROZEN_EMPTY_ARRAY, FROZEN_EMPTY_HASH, STRUCTURAL_OR_METHODS, VALID_UNSCOPING_VALUES
::ActiveRecord::FinderMethods
- Included
::ActiveRecord::Relation
- Inherited
CLAUSE_METHODS, INVALID_METHODS_FOR_DELETE_ALL, MULTI_VALUE_METHODS, SINGLE_VALUE_METHODS, VALUE_METHODS
Class Method Summary
::ActiveRecord::Relation
- Inherited
Instance Attribute Summary
-
#empty? ⇒ Boolean
readonly
Returns
true
if the collection is empty. -
#loaded? ⇒ Boolean
readonly
Returns
true
if the association has been loaded, otherwisefalse
.
::ActiveRecord::Relation
- Inherited
| #any? | Returns true if there are any records. |
| #blank? | Returns true if relation is blank. |
| #eager_loading? | Returns true if relation needs eager loading. |
| #empty? | Returns true if there are no records. |
| #klass, | |
| #loaded? | Alias for Relation#loaded. |
| #many? | Returns true if there is more than one record. |
| #model | Alias for Relation#klass. |
| #none? | Returns true if there are no records. |
| #one? | Returns true if there is exactly one record. |
| #predicate_builder, #table |
::Enumerable
- Included
| #many? | Returns |
Instance Method Summary
-
#<<(*records)
(also: #push, #append, #concat)
Adds one or more #records to the collection by setting their foreign keys to the association’s primary key.
-
#==(other)
Equivalent to
Array#==
. -
#any?
Returns
true
if the collection is not empty. -
#append(*records)
Alias for #<<.
-
#build(attributes = {}, &block)
(also: #new)
Returns a new object of the collection type that has been instantiated with
attributes
and linked to this object, but have not yet been saved. -
#calculate(operation, column_name)
–.
-
#clear
Equivalent to #delete_all.
-
#concat(*records)
Alias for #<<.
-
#count(column_name = nil, &block)
Count all records.
-
#create(attributes = {}, &block)
Returns a new object of the collection type that has been instantiated with attributes, linked to this object and that has already been saved (if it passes the validations).
-
#create!(attributes = {}, &block)
Like #create, except that if the record is invalid, raises an exception.
-
#delete(*records)
Deletes the #records supplied from the collection according to the strategy specified by the
:dependent
option. -
#delete_all(dependent = nil)
Deletes all the records from the collection according to the strategy specified by the
:dependent
option. -
#destroy(*records)
Destroys the #records supplied and removes them from the collection.
-
#destroy_all
Deletes the records of the collection directly from the database ignoring the
:dependent
option. -
#distinct(value = true)
Specifies whether the records should be unique or not.
-
#fifth
Same as #first except returns only the fifth record.
-
#find(*args)
Finds an object in the collection responding to the
id
. -
#first(limit = nil)
Returns the first record, or the first
n
records, from the collection. -
#forty_two
Same as #first except returns only the forty second record.
-
#fourth
Same as #first except returns only the fourth record.
-
#include?(record) ⇒ Boolean
Returns
true
if the givenrecord
is present in the collection. -
#last(limit = nil)
Returns the last record, or the last
n
records, from the collection. -
#length
Returns the size of the collection calling #size on the target.
- #load_target
-
#many?
Returns true if the collection has more than one record.
-
#new(attributes = {}, &block)
Alias for #build.
- #pluck(*column_names)
- #prepend(*args)
- #proxy_association
-
#push(*records)
Alias for #<<.
-
#reload
Reloads the collection from the database.
-
#replace(other_array)
Replaces this collection with
other_array
. -
#reset
Unloads the association.
-
#scope
Returns a
::ActiveRecord::Relation
object for the records in this association. -
#second
Same as #first except returns only the second record.
-
#second_to_last
Same as #first except returns only the second-to-last record.
-
#select(*fields, &block)
Works in two ways.
-
#size
Returns the size of the collection.
-
#take(limit = nil)
Gives a record (or N records if a parameter is supplied) from the collection using the same rules as
ActiveRecord::Base.take
. - #target
-
#third
Same as #first except returns only the third record.
-
#third_to_last
Same as #first except returns only the third-to-last record.
-
#to_ary ⇒ ?
Returns a new array of objects from the collection.
::ActiveRecord::Relation
- Inherited
| #== | Compares two relations for equality. |
| #build | Alias for Relation#new. |
| #cache_key | Returns a cache key that can be used to identify the records fetched by this query. |
| #create | Tries to create a new record with the same scoped attributes defined in the relation. |
| #create! | |
| #delete_all | Deletes the records without instantiating the records first, and hence not calling the #destroy method nor invoking callbacks. |
| #destroy_all | Destroys the records by instantiating each record and calling its #destroy method. |
| #encode_with | Serializes the relation objects |
| #explain | Runs EXPLAIN on the query or queries triggered by this relation and returns the result as a string. |
| #find_or_create_by | Finds the first record with the given attributes, or creates a record with the attributes if one is not found: |
| #find_or_create_by! | Like |
| #find_or_initialize_by | Like |
| #initialize_copy, #inspect, | |
| #joined_includes_values | Joins that are also marked for preloading. |
| #load | Causes the records to be loaded from the database if they have not been loaded already. |
| #loaded, #locked?, | |
| #new | Initializes new record from relation while maintaining the current scope. |
| #pretty_print, | |
| #reload | Forces reloading of relation. |
| #reset, #scope_for_create, | |
| #scoping | Scope all queries to the current scope. |
| #size | Returns size of the records. |
| #to_a | Alias for Relation#to_ary. |
| #to_ary | Converts relation objects to |
| #to_sql | Returns sql statement for the relation. |
| #update_all | Updates all records in the current relation with details given. |
| #values, | |
| #where_values_hash | Returns a hash of where conditions. |
::ActiveRecord::FinderMethods
- Included
| #exists? | Returns true if a record exists in the table that matches the |
| #fifth | Find the fifth record. |
| #fifth! | Same as #fifth but raises |
| #find | Find by id - This can either be a specific id (1), a list of ids (1, 5, 6), or an array of ids ([5, 6, 10]). |
| #find_by | Finds the first record matching the specified conditions. |
| #find_by! | Like |
| #first | Find the first record (or first N records if a parameter is supplied). |
| #first! | Same as #first but raises |
| #forty_two | Find the forty-second record. |
| #forty_two! | Same as #forty_two but raises |
| #fourth | Find the fourth record. |
| #fourth! | Same as #fourth but raises |
| #last | Find the last record (or last N records if a parameter is supplied). |
| #last! | Same as #last but raises |
| #second | Find the second record. |
| #second! | Same as #second but raises |
| #second_to_last | Find the second-to-last record. |
| #second_to_last! | Same as #second_to_last but raises |
| #take | Gives a record (or N records if a parameter is supplied) without any implied order. |
| #take! | Same as #take but raises |
| #third | Find the third record. |
| #third! | Same as #third but raises |
| #third_to_last | Find the third-to-last record. |
| #third_to_last! | Same as #third_to_last but raises |
::ActiveRecord::Calculations
- Included
| #average | Calculates the average value on a given column. |
| #calculate | This calculates aggregate values in the given column. |
| #count | Count the records. |
| #ids | Pluck all the ID’s for the relation using the table’s primary key. |
| #maximum | Calculates the maximum value on a given column. |
| #minimum | Calculates the minimum value on a given column. |
| #pluck | Use #pluck as a shortcut to select one or more attributes without loading a bunch of records just to grab the attributes you want. |
| #sum | Calculates the sum of values on a given column. |
::ActiveRecord::SpawnMethods
- Included
| #except | Removes from the query the condition(s) specified in |
| #merge | Merges in the conditions from |
| #only | Removes any condition from the query other than the one(s) specified in |
::ActiveRecord::QueryMethods
- Included
| #create_with | Sets attributes to be used when creating new records from a relation object. |
| #distinct | Specifies whether the records should be unique or not. |
| #eager_load | Forces eager loading by performing a LEFT OUTER JOIN on |
| #extending | Used to extend a scope with additional methods, either through a module or through a block provided. |
| #extensions, | |
| #from | Specifies table from which the records will be fetched. |
| #group | Allows to specify a group attribute: |
| #having | Allows to specify a HAVING clause. |
| #includes | Specify relationships to be included in the result set. |
| #joins | Performs a joins on |
| #left_joins | Alias for QueryMethods#left_outer_joins. |
| #left_outer_joins | Performs a left outer joins on |
| #limit | Specifies a limit for the number of records to retrieve. |
| #lock | Specifies locking settings (default to |
| #none | Returns a chainable relation with zero records. |
| #offset | Specifies the number of rows to skip before returning rows. |
| #or | Returns a new relation, which is the logical union of this relation and the one passed as an argument. |
| #order | Allows to specify an order attribute: |
| #preload | Allows preloading of |
| #readonly | Sets readonly attributes for the returned relation. |
| #references | Use to indicate that the given |
| #reorder | Replaces any existing order defined on the relation with the specified order. |
| #reverse_order | Reverse the existing order clause on the relation. |
| #rewhere | Allows you to change a previously set where condition for a given attribute, instead of appending to that condition. |
| #select | Works in two unique ways. |
| #unscope | Removes an unwanted relation that is already defined on a chain of relations. |
| #where | Returns a new relation, which is the result of filtering the current relation according to the conditions in the arguments. |
::ActiveRecord::Batches
- Included
| #find_each | Looping through a collection of records from the database (using the |
| #find_in_batches | Yields each batch of records that was found by the find options as an array. |
| #in_batches | Yields |
::Enumerable
- Included
Constructor Details
This class inherits a constructor from ActiveRecord::Relation
Instance Attribute Details
#empty? ⇒ Boolean
(readonly)
Returns true
if the collection is empty. If the collection has been loaded it is equivalent to collection.size.zero?
. If the collection has not been loaded, it is equivalent to !collection.exists?
. If the collection has not already been loaded and you are going to fetch the records anyway it is better to check collection.length.zero?
.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.count # => 1
person.pets.empty? # => false
person.pets.delete_all
person.pets.count # => 0
person.pets.empty? # => true
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 831
def empty? @association.empty? end
#loaded? ⇒ Boolean
(readonly)
Returns true
if the association has been loaded, otherwise false
.
person.pets.loaded? # => false
person.pets
person.pets.loaded? # => true
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 54
def loaded? @association.loaded? end
Instance Method Details
#<<(*records) Also known as: #push, #append, #concat
Adds one or more #records to the collection by setting their foreign keys to the association’s primary key. Since <<
flattens its argument list and inserts each record, #push and #concat behave identically. Returns self
so several appends may be chained together.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.size # => 0
person.pets << Pet.new(name: 'Fancy-Fancy')
person.pets << [Pet.new(name: 'Spook'), Pet.new(name: 'Choo-Choo')]
person.pets.size # => 3
person.id # => 1
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1028
def <<(*records) proxy_association.concat(records) && self end
#==(other)
Equivalent to Array#==
. Returns true
if the two arrays contain the same number of elements and if each element is equal to the corresponding element in the other
array, otherwise returns false
.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>
# ]
other = person.pets.to_ary
person.pets == other
# => true
other = [Pet.new(id: 1), Pet.new(id: 2)]
person.pets == other
# => false
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 959
def ==(other) load_target == other end
#any?
Returns true
if the collection is not empty.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.count # => 0
person.pets.any? # => false
person.pets << Pet.new(name: 'Snoop')
person.pets.count # => 1
person.pets.any? # => true
You can also pass a block
to define criteria. The behavior is the same, it returns true if the collection based on the criteria is not empty.
person.pets
# => [#<Pet name: "Snoop", group: "dogs">]
person.pets.any? do |pet|
pet.group == 'cats'
end
# => false
person.pets.any? do |pet|
pet.group == 'dogs'
end
# => true
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 836
rdoc_method :method: any?
#append(*records)
Alias for #<<.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1032
alias_method :append, :<<
#build(attributes = {}, &block) Also known as: #new
Returns a new object of the collection type that has been instantiated with attributes
and linked to this object, but have not yet been saved. You can pass an array of attributes hashes, this will return an array with the new objects.
class Person
has_many :pets
end
person.pets.build
# => #<Pet id: nil, name: nil, person_id: 1>
person.pets.build(name: 'Fancy-Fancy')
# => #<Pet id: nil, name: "Fancy-Fancy", person_id: 1>
person.pets.build([{name: 'Spook'}, {name: 'Choo-Choo'}, {name: 'Brain'}])
# => [
# #<Pet id: nil, name: "Spook", person_id: 1>,
# #<Pet id: nil, name: "Choo-Choo", person_id: 1>,
# #<Pet id: nil, name: "Brain", person_id: 1>
# ]
person.pets.size # => 5 # size of the collection
person.pets.count # => 0 # count from database
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 318
def build(attributes = {}, &block) @association.build(attributes, &block) end
#calculate(operation, column_name)
–
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 724
def calculate(operation, column_name) null_scope? ? scope.calculate(operation, column_name) : super end
#clear
Equivalent to #delete_all. The difference is that returns self
, instead of an array with the deleted objects, so methods can be chained. See #delete_all for more information. Note that because #delete_all removes records by directly running an SQL query into the database, the updated_at
column of the object is not changed.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1045
def clear delete_all self end
#concat(*records)
Alias for #<<.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1033
alias_method :concat, :<<
#count(column_name = nil, &block)
Count all records.
class Person < ActiveRecord::Base
has_many :pets
end
# This will perform the count using SQL.
person.pets.count # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
Passing a block will select all of a person’s pets in SQL and then perform the count using Ruby.
person.pets.count { |pet| pet.name.include?('-') } # => 2
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 733
rdoc_method :method: count
#create(attributes = {}, &block)
Returns a new object of the collection type that has been instantiated with attributes, linked to this object and that has already been saved (if it passes the validations).
class Person
has_many :pets
end
person.pets.create(name: 'Fancy-Fancy')
# => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>
person.pets.create([{name: 'Spook'}, {name: 'Choo-Choo'}])
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.size # => 3
person.pets.count # => 3
person.pets.find(1, 2, 3)
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 349
def create(attributes = {}, &block) @association.create(attributes, &block) end
#create!(attributes = {}, &block)
Like #create, except that if the record is invalid, raises an exception.
class Person
has_many :pets
end
class Pet
validates :name, presence: true
end
person.pets.create!(name: nil)
# => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 365
def create!(attributes = {}, &block) @association.create!(attributes, &block) end
#delete(*records)
Deletes the #records supplied from the collection according to the strategy specified by the :dependent
option. If no :dependent
option is given, then it will follow the default strategy. Returns an array with the deleted records.
For has_many :through
associations, the default deletion strategy is :delete_all
.
For has_many
associations, the default deletion strategy is :nullify
. This sets the foreign keys to NULL
.
class Person < ActiveRecord::Base
has_many :pets # dependent: :nullify option by default
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete(Pet.find(1))
# => [#<Pet id: 1, name: "Fancy-Fancy", person_id: 1>]
person.pets.size # => 2
person.pets
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
Pet.find(1)
# => #<Pet id: 1, name: "Fancy-Fancy", person_id: nil>
If it is set to :destroy
all the #records are removed by calling their #destroy method. See #destroy for more information.
class Person < ActiveRecord::Base
has_many :pets, dependent: :destroy
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete(Pet.find(1), Pet.find(3))
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.size # => 1
person.pets
# => [#<Pet id: 2, name: "Spook", person_id: 1>]
Pet.find(1, 3)
# => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (1, 3)
If it is set to :delete_all
, all the #records are deleted without calling their #destroy method.
class Person < ActiveRecord::Base
has_many :pets, dependent: :delete_all
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete(Pet.find(1))
# => [#<Pet id: 1, name: "Fancy-Fancy", person_id: 1>]
person.pets.size # => 2
person.pets
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
Pet.find(1)
# => ActiveRecord::RecordNotFound: Couldn't find Pet with 'id'=1
You can pass ::Integer
or ::String
values, it finds the records responding to the id
and executes delete on them.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete("1")
# => [#<Pet id: 1, name: "Fancy-Fancy", person_id: 1>]
person.pets.delete(2, 3)
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 620
def delete(*records) @association.delete(*records).tap { reset_scope } end
#delete_all(dependent = nil)
Deletes all the records from the collection according to the strategy specified by the :dependent
option. If no :dependent
option is given, then it will follow the default strategy.
For has_many :through
associations, the default deletion strategy is :delete_all
.
For has_many
associations, the default deletion strategy is :nullify
. This sets the foreign keys to NULL
.
class Person < ActiveRecord::Base
has_many :pets # dependent: :nullify option by default
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete_all
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.size # => 0
person.pets # => []
Pet.find(1, 2, 3)
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: nil>,
# #<Pet id: 2, name: "Spook", person_id: nil>,
# #<Pet id: 3, name: "Choo-Choo", person_id: nil>
# ]
Both has_many
and has_many :through
dependencies default to the :delete_all
strategy if the :dependent
option is set to :destroy
. Records are not instantiated and callbacks will not be fired.
class Person < ActiveRecord::Base
has_many :pets, dependent: :destroy
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete_all
Pet.find(1, 2, 3)
# => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (1, 2, 3)
If it is set to :delete_all
, all the objects are deleted without calling their #destroy method.
class Person < ActiveRecord::Base
has_many :pets, dependent: :delete_all
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.delete_all
Pet.find(1, 2, 3)
# => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (1, 2, 3)
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 474
def delete_all(dependent = nil) @association.delete_all(dependent).tap { reset_scope } end
#destroy(*records)
Destroys the #records supplied and removes them from the collection. This method will always remove record from the database ignoring the :dependent
option. Returns an array with the removed records.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.destroy(Pet.find(1))
# => [#<Pet id: 1, name: "Fancy-Fancy", person_id: 1>]
person.pets.size # => 2
person.pets
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.destroy(Pet.find(2), Pet.find(3))
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.size # => 0
person.pets # => []
Pet.find(1, 2, 3) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (1, 2, 3)
You can pass ::Integer
or ::String
values, it finds the records responding to the id
and then deletes them from the database.
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 4, name: "Benny", person_id: 1>,
# #<Pet id: 5, name: "Brain", person_id: 1>,
# #<Pet id: 6, name: "Boss", person_id: 1>
# ]
person.pets.destroy("4")
# => #<Pet id: 4, name: "Benny", person_id: 1>
person.pets.size # => 2
person.pets
# => [
# #<Pet id: 5, name: "Brain", person_id: 1>,
# #<Pet id: 6, name: "Boss", person_id: 1>
# ]
person.pets.destroy(5, 6)
# => [
# #<Pet id: 5, name: "Brain", person_id: 1>,
# #<Pet id: 6, name: "Boss", person_id: 1>
# ]
person.pets.size # => 0
person.pets # => []
Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with 'id': (4, 5, 6)
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 692
def destroy(*records) @association.destroy(*records).tap { reset_scope } end
#destroy_all
Deletes the records of the collection directly from the database ignoring the :dependent
option. Records are instantiated and it invokes before_remove
, after_remove
, before_destroy
and after_destroy
callbacks.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.size # => 3
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.destroy_all
person.pets.size # => 0
person.pets # => []
Pet.find(1) # => Couldn't find Pet with id=1
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 501
def destroy_all @association.destroy_all.tap { reset_scope } end
#distinct(value = true)
Specifies whether the records should be unique or not.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.select(:name)
# => [
# #<Pet name: "Fancy-Fancy">,
# #<Pet name: "Fancy-Fancy">
# ]
person.pets.select(:name).distinct
# => [#<Pet name: "Fancy-Fancy">]
person.pets.select(:name).distinct.distinct(false)
# => [
# #<Pet name: "Fancy-Fancy">,
# #<Pet name: "Fancy-Fancy">
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 697
rdoc_method :method: distinct
#fifth
Same as #first except returns only the fifth record.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 201
rdoc_method :method: fifth
#find(*args)
Finds an object in the collection responding to the id
. Uses the same rules as ActiveRecord::Base.find
. Returns ::ActiveRecord::RecordNotFound
error if the object cannot be found.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.find(1) # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>
person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with 'id'=4
person.pets.find(2) { |pet| pet.name.downcase! }
# => #<Pet id: 2, name: "fancy-fancy", person_id: 1>
person.pets.find(2, 3)
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 138
def find(*args) return super if block_given? @association.find(*args) end
#first(limit = nil)
Returns the first record, or the first n
records, from the collection. If the collection is empty, the first form returns nil
, and the second form returns an empty array.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.first # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>
person.pets.first(2)
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>
# ]
another_person_without.pets # => []
another_person_without.pets.first # => nil
another_person_without.pets.first(3) # => []
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 144
rdoc_method :method: first
#forty_two
Same as #first except returns only the forty second record. Also known as accessing “the reddit”.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 209
rdoc_method :method: forty_two
#fourth
Same as #first except returns only the fourth record.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 193
rdoc_method :method: fourth
#include?(record) ⇒ Boolean
Returns true
if the given record
is present in the collection.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets # => [#<Pet id: 20, name: "Snoop">]
person.pets.include?(Pet.find(20)) # => true
person.pets.include?(Pet.find(21)) # => false
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 922
def include?(record) !!@association.include?(record) end
#last(limit = nil)
Returns the last record, or the last n
records, from the collection. If the collection is empty, the first form returns nil
, and the second form returns an empty array.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.last # => #<Pet id: 3, name: "Choo-Choo", person_id: 1>
person.pets.last(2)
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
another_person_without.pets # => []
another_person_without.pets.last # => nil
another_person_without.pets.last(3) # => []
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 259
def last(limit = nil) load_target if find_from_target? super end
#length
Returns the size of the collection calling #size on the target. If the collection has been already loaded, length
and #size are equivalent. If not and you are going to need the records anyway this method will take one less query. Otherwise #size is more efficient.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.length # => 3
# executes something like SELECT "pets".* FROM "pets" WHERE "pets"."person_id" = 1
# Because the collection is loaded, you can
# call the collection with no additional queries:
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 787
rdoc_method :method: length
#load_target
[ GitHub ]# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 45
def load_target @association.load_target end
#many?
Returns true if the collection has more than one record. Equivalent to collection.size > 1
.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.count # => 1
person.pets.many? # => false
person.pets << Pet.new(name: 'Snoopy')
person.pets.count # => 2
person.pets.many? # => true
You can also pass a block
to define criteria. The behavior is the same, it returns true if the collection based on the criteria has more than one record.
person.pets
# => [
# #<Pet name: "Gorby", group: "cats">,
# #<Pet name: "Puff", group: "cats">,
# #<Pet name: "Snoop", group: "dogs">
# ]
person.pets.many? do |pet|
pet.group == 'dogs'
end
# => false
person.pets.many? do |pet|
pet.group == 'cats'
end
# => true
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 872
rdoc_method :method: many?
#new(attributes = {}, &block)
Alias for #build.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 321
alias_method :new, :build
#pluck(*column_names)
[ GitHub ]# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 728
def pluck(*column_names) null_scope? ? scope.pluck(*column_names) : super end
#prepend(*args)
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1035
def prepend(*args) raise NoMethodError, "prepend on association is not defined. Please use <<, push or append" end
#proxy_association
[ GitHub ]# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 926
def proxy_association @association end
#push(*records)
Alias for #<<.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1031
alias_method :push, :<<
#reload
Reloads the collection from the database. Returns self
.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets # fetches pets from the database
# => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
person.pets # uses the pets cache
# => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
person.pets.reload # fetches pets from the database
# => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1064
def reload proxy_association.reload reset_scope end
#replace(other_array)
Replaces this collection with other_array
. This will perform a diff and delete/add only records that have changed.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [#<Pet id: 1, name: "Gorby", group: "cats", person_id: 1>]
other_pets = [Pet.new(name: 'Puff', group: 'celebrities']
person.pets.replace(other_pets)
person.pets
# => [#<Pet id: 2, name: "Puff", group: "celebrities", person_id: 1>]
If the supplied array has an incorrect association type, it raises an ::ActiveRecord::AssociationTypeMismatch
error:
person.pets.replace(["doo", "ggie", "gaga"])
# => ActiveRecord::AssociationTypeMismatch: Pet expected, got String
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 391
def replace(other_array) @association.replace(other_array) end
#reset
Unloads the association. Returns self
.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets # fetches pets from the database
# => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
person.pets # uses the pets cache
# => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
person.pets.reset # clears the pets cache
person.pets # fetches pets from the database
# => [#<Pet id: 1, name: "Snoop", group: "dogs", person_id: 1>]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1085
def reset proxy_association.reset proxy_association.reset_scope reset_scope end
#scope
Returns a ::ActiveRecord::Relation
object for the records in this association
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 931
def scope @scope ||= @association.scope end
#second
Same as #first except returns only the second record.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 177
rdoc_method :method: second
#second_to_last
Same as #first except returns only the second-to-last record.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 226
rdoc_method :method: second_to_last
#select(*fields, &block)
Works in two ways.
First: Specify a subset of fields to be selected from the result set.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.select(:name)
# => [
# #<Pet id: nil, name: "Fancy-Fancy">,
# #<Pet id: nil, name: "Spook">,
# #<Pet id: nil, name: "Choo-Choo">
# ]
person.pets.select(:id, :name)
# => [
# #<Pet id: 1, name: "Fancy-Fancy">,
# #<Pet id: 2, name: "Spook">,
# #<Pet id: 3, name: "Choo-Choo">
# ]
Be careful because this also means you’re initializing a model object with only the fields that you’ve selected. If you attempt to access a field except id
that is not in the initialized record you’ll receive:
person.pets.select(:name).first.person_id
# => ActiveModel::MissingAttributeError: missing attribute: person_id
Second: You can pass a block so it can be used just like Array#select
. This builds an array of objects from the database for the scope, converting them into an array and iterating through them using Array#select
.
person.pets.select { |pet| pet.name =~ /oo/ }
# => [
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 59
rdoc_method :method: select
#size
Returns the size of the collection. If the collection hasn’t been loaded, it executes a SELECT COUNT(*)
query. Else it calls collection.size
.
If the collection has been already loaded size
and #length are equivalent. If not and you are going to need the records anyway #length will take one less query. Otherwise size
is more efficient.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets.size # => 3
# executes something like SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" = 1
person.pets # This will execute a SELECT * FROM query
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.size # => 3
# Because the collection is already loaded, this will behave like
# collection.size and no SQL count query is executed.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 782
def size @association.size end
#take(limit = nil)
Gives a record (or N records if a parameter is supplied) from the collection using the same rules as ActiveRecord::Base.take
.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>,
# #<Pet id: 3, name: "Choo-Choo", person_id: 1>
# ]
person.pets.take # => #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>
person.pets.take(2)
# => [
# #<Pet id: 1, name: "Fancy-Fancy", person_id: 1>,
# #<Pet id: 2, name: "Spook", person_id: 1>
# ]
another_person_without.pets # => []
another_person_without.pets.take # => nil
another_person_without.pets.take(2) # => []
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 289
def take(limit = nil) load_target if find_from_target? super end
#target
[ GitHub ]# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 41
def target @association.target end
#third
Same as #first except returns only the third record.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 185
rdoc_method :method: third
#third_to_last
Same as #first except returns only the third-to-last record.
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 218
rdoc_method :method: third_to_last
#to_ary ⇒ ?
Returns a new array of objects from the collection. If the collection hasn’t been loaded, it fetches the records from the database.
class Person < ActiveRecord::Base
has_many :pets
end
person.pets
# => [
# #<Pet id: 4, name: "Benny", person_id: 1>,
# #<Pet id: 5, name: "Brain", person_id: 1>,
# #<Pet id: 6, name: "Boss", person_id: 1>
# ]
other_pets = person.pets.to_ary
# => [
# #<Pet id: 4, name: "Benny", person_id: 1>,
# #<Pet id: 5, name: "Brain", person_id: 1>,
# #<Pet id: 6, name: "Boss", person_id: 1>
# ]
other_pets.replace([Pet.new(name: 'BooGoo')])
other_pets
# => [#<Pet id: nil, name: "BooGoo", person_id: 1>]
person.pets
# This is not affected by replace
# => [
# #<Pet id: 4, name: "Benny", person_id: 1>,
# #<Pet id: 5, name: "Brain", person_id: 1>,
# #<Pet id: 6, name: "Boss", person_id: 1>
# ]
# File 'activerecord/lib/active_record/associations/collection_proxy.rb', line 1003
RDoc directive :method: to_ary


Mediumish Template for Jekyll
This website is built with Jekyll and Mediumish template for Jekyll. It is meant for demonstration purposes, no real content can be found. Mediumish template for Jekyll is compatible with Github pages, in fact even this demo is created with Github Pages and hosted with Github. This page in example shows a page layout.
Features
- Built for Jekyll
- Compatible with Github pages
- Featured Posts
- Index Pagination
- Post Share
- Post Categories
- Prev/Next Link
- Category Archives (this is not yet compatible with github pages though)
- Jumbotron Categories
- Integrations:
- Disqus Comments
- Google Analaytics
- Mailchimp Integration
- Design Features:
- Bootstrap v4.x
- Font Awesome
- Masonry
- Layouts:
- Default
- Post
- Page
- Archive
How to Use
If you aren’t familiar with Jekyll yet, you should know that it is a static site generator. It will transform your plain text into static websites and blogs. No more databases, slow loading websites, risk of being hacked…just your content. And not only that, with Jekyll you get free hosting with GitHub Pages! This page itself is free hosted on Github with the help of Jekyll and Mediumish template that you’re currently previewing. If you are a beginner we recommend you start with Jekyll’s Docs. Now if you know how to use Jekyll, let’s move on to using Mediumish template in Jekyll:
Using Mediumish
Download or Fork Mediumish for Jekyll.
- In your local project, open
_config.yml
. If your site is in root, forbaseurl
, make sure this is set tobaseurl: /
. Also, change your Google Analytics code, disqus username, authors, Mailchimp list etc. - Mediumish requires 2 plugins:
$ gem install jekyll-paginate
$ gem install jekyll-archives
.
- Edit the menu and footer copyrights in
default.html
- Start by adding your .md files in
_posts
. Mediumish already has a few as an example. - YAML front matter
- featured post -
featured:true
- exclude featured post from “All stories” loop to avoid duplicated posts -
hidden:true
- post image -
image: assets/images/mypic.jpg
- page comments -
comments:true
- meta description (optional) -
description: "this is my meta description"
- featured post -
YAML Post Example:
--- layout: post title: "We all wait for summer" author: john categories: [ Jekyll, tutorial ] image: assets/images/5.jpg featured: true ---
YAML Page Example
--- layout: page title: Mediumish Template for Jekyll comments: true ---
Contribute
- Clone the repo.
- Create a branch off of master and give it a meaningful name (e.g. my-new-mediumish-feature).
- Open a pull request on GitHub and describe the feature or fix.


Success Isn't always about greatness . It's about hardwork and consistency
Explore Now ➝Rs.999
Rs.499
Rs.200
Rs.1800
Rs.599
Rs.799
Rs.899
Rs.1299
EXCLUSIVELY AVAILABLE HERE
Our main aim is to provide good quality of content to You.
Our main aim is to provide good quality of content to You.
Our main aim is to provide good quality of content to You.


Version 3.2.1 is backward compatible to version 3.2, that is models developed with versions 3.0, 3.0.1, 3.1, or 3.2 will work without any changes also with version 3.2.1. This version is a "clean-up" with major emphasis on quality improvement and tool compatibility. The goal is that all Modelica tools will support this package and will interpret it in the same way. Short Overview:
This release of package Modelica, and the accompanying ModelicaTest, has been tested with the following tools (the tools are listed alphabetically. At the time of the test, some of the tools might not yet supported the complete Modelica package):
The following Modelica packages have been tested that they work together with this release of package Modelica (alphabetical list):
The new open source tables have been tested by T. Beutlich (ITI):
The exact difference between package Modelica version 3.2 and version 3.2.1 is summarized in a comparison table.
About 400 trac tickets have been fixed for this release. An overview is given here. Clicking on a ticket gives all information about it.
The following new
components have been added to existing libraries:
| Modelica.Blocks.Logical. | |
| RSFlipFlop | Basic RS flip flop |
| Modelica.Blocks.Math. | |
| MinMax | Output the minimum and the maximum element of the input vector |
| LinearDependency | Output a linear combination of the two inputs |
| Modelica.Blocks.Nonlinear. | |
| SlewRateLimiter | Limit the slew rate of a signal |
| Modelica.Electrical.Digital.Memories | |
| DLATRAM | Level sensitive Random Access Memory |
| DLATROM | Level sensitive Read Only Memory |
| Modelica.Electrical.Digital.Multiplexers | |
| MUX2x1 | A two inputs MULTIPLEXER for multiple value logic (2 data inputs, 1 select input, 1 output) |
| Modelica.Electrical.Machines.Examples.AsynchronousInductionMachines. | |
| AIMC_Initialize | Steady-State Initialization example of AsynchronousInductionMachineSquirrelCage |
| Modelica.Electrical.Machines.Examples.SynchronousInductionMachines. | |
| SMPM_VoltageSource | PermanentMagnetSynchronousInductionMachine example fed by FOC |
| Modelica.Electrical.MultiPhase.Examples. | |
| TestSensors | Example for multiphase quasiRMS sensors: A sinusoidal source feeds a load consisting of resistor and inductor |
| Modelica.Electrical.MultiPhase.Sensors. | |
| VoltageQuasiRMSSensor | Continuous quasi voltage RMS sensor for multi phase system |
| CurrentQuasiRMSSensor | Continuous quasi current RMS sensor for multi phase system |
| Modelica.Electrical.MultiPhase.Blocks. | |
| QuasiRMS | Determine quasi RMS value of a multi-phase system |
| Modelica.Electrical.MultiPhase.Functions. | |
| quasiRMS | Calculate continuous quasi RMS value of input |
| activePower | Calculate active power of voltage and current input |
| symmetricOrientation | Orientations of the resulting fundamental wave field phasors |
| Modelica.Electrical.Spice3.Examples. | |
| CoupledInductors CascodeCircuit Spice3BenchmarkDifferentialPair Spice3BenchmarkMosfetCharacterization Spice3BenchmarkRtlInverter Spice3BenchmarkFourBitBinaryAdder |
Spice3 examples and benchmarks from the SPICE3 Version e3 User's Manual |
| Modelica.Electrical.Spice3.Basic. | |
| K_CoupledInductors | Inductive coupling via coupling factor K |
| Modelica.Electrical.Spice3.Semiconductors. | |
| M_NMOS2 M_PMOS2 ModelcardMOS2 |
N/P channel MOSFET transistor with fixed level 2 |
| J_NJFJFE J_PJFJFE ModelcardJFET |
N/P-channel junction field-effect transistor |
| C_Capacitor ModelcardCAPACITOR |
Semiconductor capacitor model |
| Modelica.Magnetic.FundamentalWave.Examples.BasicMachines. | |
| AIMC_DOL_MultiPhase AIMS_Start_MultiPhase SMPM_Inverter_MultiPhase SMEE_Generator_MultiPhase SMR_Inverter_MultiPhase |
Multi-phase machine examples |
| Modelica.Fluid.Sensors. | |
| MassFractions MassFractionsTwoPort |
Ideal mass fraction sensors |
| Modelica.Media. | |
| R134a | R134a (Tetrafluoroethane) medium model in the range (0.0039 bar .. 700 bar, 169.85 K .. 455 K) |
| Modelica.Media.Air. | |
| ReferenceAir | Detailed dry air model with a large operating range (130 ... 2000 K, 0 ... 2000 MPa) based on Helmholtz equations of state |
| ReferenceMoistAir | Detailed moist air model (143.15 ... 2000 K) |
| MoistAir | Temperature range of functions of MoistAir medium enlarged from 240 - 400 K to 190 - 647 K. |
| Modelica.Media.Air.MoistAir. | |
| velocityOfSound isobaricExpansionCoefficient isothermalCompressibility density_derp_h density_derh_p density_derp_T density_derT_p density_derX molarMass T_psX setState_psX s_pTX s_pTX_der isentropicEnthalpy |
Functions returning additional properties of the moist air medium model |
| Modelica.Thermal.HeatTransfer.Components. | |
| ThermalResistor | Lumped thermal element transporting heat without storing it (dT = R*Q_flow) |
| ConvectiveResistor | Lumped thermal element for heat convection (dT = Rc*Q_flow) |
| Modelica.MultiBody.Examples.Constraints. | |
| PrismaticConstraint RevoluteConstraint SphericalConstraint UniversalConstraint |
Demonstrates the use of the new Joints.Constraints joints by comparing them with the standard joints. |
| Modelica.MultiBody.Joints.Constraints. | |
| Prismatic Revolute Spherical Universal |
Joint elements formulated as kinematic constraints. These elements are designed to break kinematic loops and result usually in numerically more efficient and reliable loop handling as the (standard) automatic handling. |
| Modelica.Mechanics.Rotational. | |
| MultiSensor | Ideal sensor to measure the torque and power between two flanges and the absolute angular velocity |
| Modelica.Mechanics.Translational. | |
| MultiSensor | Ideal sensor to measure the absolute velocity, force and power between two flanges |
| Modelica.Math. | |
| isPowerOf2 | Determine if the integer input is a power of 2 |
| Modelica.Math.Vectors. | |
| normalizedWithAssert | Return normalized vector such that length = 1 (trigger an assert for zero vector) |
| Modelica.Math.BooleanVectors. | |
| countTrue | Returns the number of true entries in a Boolean vector |
| enumerate | Enumerates the true entries in a Boolean vector (0 for false entries) |
| index | Returns the indices of the true entries of a Boolean vector |
| Modelica.Utilities.Files. | |
| loadResource | Return the absolute path name of a URI or local file name |
| Modelica.SIunits. | |
| PressureDifference MolarDensity MolarEnergy MolarEnthalpy TimeAging ChargeAging PerUnit DerPressureByDensity DerPressureByTemperature |
New SI unit types |


ws.save()
ws.assign_permissions()
for wsi in ws.workstationimage_set.all():
wsi.assign_permissions()
class Migration(migrations.Migration):
dependencies = [("workstations", "0002_auto_20190809_0839")]
ws.editors_group = Group.objects.create(
name=f"workstations_workstation_{ws.pk}_editors"
)
ws.users_group = Group.objects.create(
name=f"workstations_workstation_{ws.pk}_users"
)
ws.save()
class Migration(migrations.Migration):


--- layout: default ---
For this assignment, please find a discussion in the course Slack in which a fellow student is "#blocked" and asking for help on the project, and take a bit of some time to investigate the issue and help out (or otherwise participate in the discussion to help narrow down the solution to unblock).
For example you could say things like:
Please paste your comment in Slack as the Canvas submission. Thank you!


Mobile
Emergency
911
for emergencies only
UCSF Police Non-Emergency
(415) 476-1414
UCSF Medical Center Security
(415) 885-7890
Campus Emergency Information Hotline
(415) 502-4000
Back-up Campus Emergency Hotline
1<PHONE_NUMBER>
UCSF Medical Center Information Hotline
(415) 885-7828


Charters are the ultimate in privacy with your family, friends, company or organization. They are available from 1 day to 5 days and 4 nights. The best value (what you pay vs. what you get) is a full charter of 30-35 passengers depending on the boat selected. Also available for about 40% less is a half-full boat of 15-17 passengers.
(note: please visit our store for pricing or keep reading for more information)
For those looking for single day charters, there are adventure specific dives to the outer islands (San Miguel and Santa Rosa), the largest and most serene island (Santa Cruz), the oil rigs in the middle of the Santa Barbara Channel with their “natural” reefs and wreck dives up the coast from Santa Barbara.
Not included in the prices are trips to more distant locales including San Clemente Island, San Nicolas Island, Santa Barbara Island, Santa Catalina Island and the Cortes Bank.
Meals, snacks, non-alcoholic beverages and air fills are included in the price. The typical number of dives is four but can be more or less depending on conditions.
Click on the dropdown menu from the adventures tab at the top of the page to see details about the Channel Islands as well as each of the adventures offered through Shoreline Summit Adventures.


{% extends 'layouts/default/page.html' %} {% block content %}
You have successfully cancelled your subscription. Your subscription will not renew after this period.
You will be redirected to the license management page.


ei_connect
C Library
Library Summary
Description
This module enables C-programs to communicate with Erlang nodes, using the Erlang distribution over TCP/IP.
A C-node appears to Erlang as a hidden node. That is, Erlang processes that know the name of the C-node can communicate with it in a normal manner, but the node name is not shown in the listing provided by erlang:nodes/0 in ERTS.
The environment variable ERL_EPMD_PORT can be used to indicate which logical cluster a C-node belongs to.
Time-Out Functions
Most functions appear in a version with the suffix _tmo appended to the function name. Those functions take an extra argument, a time-out in milliseconds. The semantics is this: for each communication primitive involved in the operation, if the primitive does not complete within the time specified, the function returns an error and erl_errno is set to ETIMEDOUT. With communication primitive is meant an operation on the socket, like connect, accept, recv, or send.
Clearly the time-outs are for implementing fault tolerance, not to keep hard real-time promises. The _tmo functions are for detecting non-responsive peers and to avoid blocking on socket operations.
A time-out value of 0 (zero) means that time-outs are disabled. Calling a _tmo function with the last argument as 0 is therefore the same thing as calling the function without the _tmo suffix.
As with all other functions starting with ei_, you are not expected to put the socket in non-blocking mode yourself in the program. Every use of non-blocking mode is embedded inside the time-out functions. The socket will always be back in blocking mode after the operations are completed (regardless of the result). To avoid problems, leave the socket options alone. ei handles any socket options that need modification.
In all other senses, the _tmo functions inherit all the return values and the semantics from the functions without the _tmo suffix.
Exports
struct hostent *ei_gethostbyaddr(const char *addr, int len, int type)
struct hostent *ei_gethostbyaddr_r(const char *addr, int length, int type, struct hostent *hostp, char *buffer, int buflen, int *h_errnop)
struct hostent *ei_gethostbyname(const char *name)
struct hostent *ei_gethostbyname_r(const char *name, struct hostent *hostp, char *buffer, int buflen, int *h_errnop)
Convenience functions for some common name lookup functions.
int ei_accept(ei_cnode *ec, int listensock, ErlConnect *conp)
Used by a server process to accept a connection from a client process.
-
ec is the C-node structure.
-
listensock is an open socket descriptor on which listen() has previously been called.
-
conp is a pointer to an ErlConnect struct, described as follows:
typedef struct { char ipadr[4]; char nodename[MAXNODELEN]; } ErlConnect;
On success, conp is filled in with the address and node name of the connecting client and a file descriptor is returned. On failure, ERL_ERROR is returned and erl_errno is set to EIO.
int ei_accept_tmo(ei_cnode *ec, int listensock, ErlConnect *conp, unsigned timeout_ms)
Equivalent to ei_accept with an optional time-out argument, see the description at the beginning of this manual page.
int ei_connect(ei_cnode* ec, char *nodename)
int ei_xconnect(ei_cnode* ec, Erl_IpAddr adr, char *alivename)
Sets up a connection to an Erlang node.
ei_xconnect() requires the IP address of the remote host and the alive name of the remote node to be specified. ei_connect() provides an alternative interface and determines the information from the node name provided.
- addr is the 32-bit IP address of the remote host.
- alive is the alivename of the remote node.
- node is the name of the remote node.
These functions return an open file descriptor on success, or a negative value indicating that an error occurred. In the latter case they set erl_errno to one of the following:
- EHOSTUNREACH
- The remote host node is unreachable.
- ENOMEM
- No more memory is available.
- EIO
- I/O error.
Also, errno values from socket(2) and connect(2) system calls may be propagated into erl_errno.
Example:
#define NODE<EMAIL_ADDRESS>#define ALIVE "madonna" #define IP_ADDR "<IP_ADDRESS>" /*** Variant 1 ***/ int fd = ei_connect(&ec, NODE); /*** Variant 2 ***/ struct in_addr addr; addr.s_addr = inet_addr(IP_ADDR); fd = ei_xconnect(&ec, &addr, ALIVE);
int ei_connect_init(ei_cnode* ec, const char* this_node_name, const char *cookie, short creation)
int ei_connect_xinit(ei_cnode* ec, const char *thishostname, const char *thisalivename, const char *thisnodename, Erl_IpAddr thisipaddr, const char *cookie, short creation)
Initializes the ec structure, to identify the node name and cookie of the server. One of them must be called before other functions that works on the ei_cnode type or a file descriptor associated with a connection to another node is used.
-
ec is a structure containing information about the C-node. It is used in other ei functions for connecting and receiving data.
-
this_node_name is the registered name of the process (the name before '@').
-
cookie is the cookie for the node.
-
creation identifies a specific instance of a C-node. It can help prevent the node from receiving messages sent to an earlier process with the same registered name.
-
thishostname is the name of the machine we are running on. If long names are to be used, they are to be fully qualified (that is, durin.erix.ericsson.se instead of durin).
-
thisalivename is the registered name of the process.
-
thisnodename is the full name of the node, that is, einode@durin.
-
thispaddr if the IP address of the host.
A C-node acting as a server is assigned a creation number when it calls ei_publish().
A connection is closed by simply closing the socket. For information about how to close the socket gracefully (when there are outgoing packets before close), see the relevant system documentation.
These functions return a negative value indicating that an error occurred.
Example 1:
int n = 0; struct in_addr addr; ei_cnode ec; addr.s_addr = inet_addr("<IP_ADDRESS>"); if (ei_connect_xinit(&ec, "chivas", "madonna"<EMAIL_ADDRESS>&addr; "cookie...", n++) < 0) { fprintf(stderr,"ERROR when initializing: %d",erl_errno); exit(-1); }
Example 2:
if (ei_connect_init(&ec, "madonna", "cookie...", n++) < 0) { fprintf(stderr,"ERROR when initializing: %d",erl_errno); exit(-1); }
int ei_connect_tmo(ei_cnode* ec, char *nodename, unsigned timeout_ms)
int ei_xconnect_tmo(ei_cnode* ec, Erl_IpAddr adr, char *alivename, unsigned timeout_ms)
Equivalent to ei_connect and ei_xconnect with an optional time-out argument, see the description at the beginning of this manual page.
int ei_get_tracelevel(void)
void ei_set_tracelevel(int level)
Used to set tracing on the distribution. The levels are different verbosity levels. A higher level means more information. See also section Debug Information.
These functions are not thread safe.
int ei_publish(ei_cnode *ec, int port)
Used by a server process to register with the local name server EPMD, thereby allowing other processes to send messages by using the registered name. Before calling either of these functions, the process should have called bind() and listen() on an open socket.
-
ec is the C-node structure.
-
port is the local name to register, and is to be the same as the port number that was previously bound to the socket.
-
addr is the 32-bit IP address of the local host.
To unregister with EPMD, simply close the returned descriptor. Do not use ei_unpublish(), which is deprecated anyway.
On success, the function returns a descriptor connecting the calling process to EPMD. On failure, -1 is returned and erl_errno is set to EIO.
Also, errno values from socket(2) and connect(2) system calls may be propagated into erl_errno.
int ei_publish_tmo(ei_cnode *ec, int port, unsigned timeout_ms)
Equivalent to ei_publish with an optional time-out argument, see the description at the beginning of this manual page.
int ei_receive(int fd, unsigned char* bufp, int bufsize)
Receives a message consisting of a sequence of bytes in the Erlang external format.
-
fd is an open descriptor to an Erlang connection. It is obtained from a previous ei_connect or ei_accept.
-
bufp is a buffer large enough to hold the expected message.
-
bufsize indicates the size of bufp.
If a tick occurs, that is, the Erlang node on the other end of the connection has polled this node to see if it is still alive, the function returns ERL_TICK and no message is placed in the buffer. Also, erl_errno is set to EAGAIN.
On success, the message is placed in the specified buffer and the function returns the number of bytes actually read. On failure, the function returns ERL_ERROR and sets erl_errno to one of the following:
- EAGAIN
- Temporary error: Try again.
- EMSGSIZE
- Buffer is too small.
- EIO
- I/O error.
int ei_receive_encoded(int fd, char **mbufp, int *bufsz, erlang_msg *msg, int *msglen)
This function is retained for compatibility with code generated by the interface compiler and with code following examples in the same application.
In essence, the function performs the same operation as ei_xreceive_msg, but instead of using an ei_x_buff, the function expects a pointer to a character pointer (mbufp), where the character pointer is to point to a memory area allocated by malloc. Argument bufsz is to be a pointer to an integer containing the exact size (in bytes) of the memory area. The function may reallocate the memory area and will in such cases put the new size in *bufsz and update *mbufp.
Returns either ERL_TICK or the msgtype field of the erlang_msg *msg. The length of the message is put in *msglen. On error a value < 0 is returned.
It is recommended to use ei_xreceive_msg instead when possible, for the sake of readability. However, the function will be retained in the interface for compatibility and will not be removed in future releases without prior notice.
Equivalent to ei_receive_encoded with an optional time-out argument, see the description at the beginning of this manual page.
int ei_receive_msg(int fd, erlang_msg* msg, ei_x_buff* x)
int ei_xreceive_msg(int fd, erlang_msg* msg, ei_x_buff* x)
Receives a message to the buffer in x. ei_xreceive_msg allows the buffer in x to grow, but ei_receive_msg fails if the message is larger than the pre-allocated buffer in x.
- fd is an open descriptor to an Erlang connection.
- msg is a pointer to an erlang_msg structure and contains information on the message received.
- x is buffer obtained from ei_x_new.
On success, the functions return ERL_MSG and the msg struct is initialized. erlang_msg is defined as follows:
typedef struct { long msgtype; erlang_pid from; erlang_pid to; char toname[MAXATOMLEN+1]; char cookie[MAXATOMLEN+1]; erlang_trace token; } erlang_msg;
msgtype identifies the type of message, and is one of the following:
- ERL_SEND
-
Indicates that an ordinary send operation has occurred. msg->to contains the pid of the recipient (the C-node).
- ERL_REG_SEND
-
A registered send operation occurred. msg->from contains the pid of the sender.
- ERL_LINK or ERL_UNLINK
-
msg->to and msg->from contain the pids of the sender and recipient of the link or unlink.
- ERL_EXIT
-
Indicates a broken link. msg->to and msg->from contain the pids of the linked processes.
The return value is the same as for ei_receive.
int ei_receive_msg_tmo(int fd, erlang_msg* msg, ei_x_buff* x, unsigned imeout_ms)
int ei_xreceive_msg_tmo(int fd, erlang_msg* msg, ei_x_buff* x, unsigned timeout_ms)
Equivalent to ei_receive_msg and ei_xreceive_msg with an optional time-out argument, see the description at the beginning of this manual page.
int ei_receive_tmo(int fd, unsigned char* bufp, int bufsize, unsigned timeout_ms)
Equivalent to ei_receive with an optional time-out argument, see the description at the beginning of this manual page.
int ei_reg_send(ei_cnode* ec, int fd, char* server_name, char* buf, int len)
Sends an Erlang term to a registered process.
-
fd is an open descriptor to an Erlang connection.
- server_name is the registered name of the intended recipient.
- buf is the buffer containing the term in binary format.
- len is the length of the message in bytes.
Returns 0 if successful, otherwise -1. In the latter case it sets erl_errno to EIO.
Example:
Send the atom "ok" to the process "worker":
ei_x_buff x; ei_x_new_with_version(&x); ei_x_encode_atom(&x, "ok"); if (ei_reg_send(&ec, fd, x.buff, x.index) < 0) handle_error();
Equivalent to ei_reg_send with an optional time-out argument, see the description at the beginning of this manual page.
int ei_rpc(ei_cnode *ec, int fd, char *mod, char *fun, const char *argbuf, int argbuflen, ei_x_buff *x)
int ei_rpc_to(ei_cnode *ec, int fd, char *mod, char *fun, const char *argbuf, int argbuflen)
int ei_rpc_from(ei_cnode *ec, int fd, int timeout, erlang_msg *msg, ei_x_buff *x)
Supports calling Erlang functions on remote nodes. ei_rpc_to() sends an RPC request to a remote node and ei_rpc_from() receives the results of such a call. ei_rpc() combines the functionality of these two functions by sending an RPC request and waiting for the results. See also rpc:call/4 in Kernel.
-
ec is the C-node structure previously initiated by a call to ei_connect_init() or ei_connect_xinit().
-
fd is an open descriptor to an Erlang connection.
-
timeout is the maximum time (in milliseconds) to wait for results. Specify ERL_NO_TIMEOUT to wait forever. ei_rpc() waits infinitely for the answer, that is, the call will never time out.
-
mod is the name of the module containing the function to be run on the remote node.
-
fun is the name of the function to run.
-
argbuf is a pointer to a buffer with an encoded Erlang list, without a version magic number, containing the arguments to be passed to the function.
-
argbuflen is the length of the buffer containing the encoded Erlang list.
-
msg is structure of type erlang_msg and contains information on the message received. For a description of the erlang_msg format, see ei_receive_msg.
-
x points to the dynamic buffer that receives the result. For ei_rpc() this is the result without the version magic number. For ei_rpc_from() the result returns a version magic number and a 2-tuple {rex,Reply}.
ei_rpc() returns the number of bytes in the result on success and -1 on failure. ei_rpc_from() returns the number of bytes, otherwise one of ERL_TICK, ERL_TIMEOUT, and ERL_ERROR. When failing, all three functions set erl_errno to one of the following:
- EIO
- I/O error.
- ETIMEDOUT
- Time-out expired.
- EAGAIN
- Temporary error: Try again.
Example:
Check to see if an Erlang process is alive:
int index = 0, is_alive; ei_x_buff args, result; ei_x_new(&result); ei_x_new(&args); ei_x_encode_list_header(&args, 1); ei_x_encode_pid(&args, &check_pid); ei_x_encode_empty_list(&args); if (ei_rpc(&ec, fd, "erlang", "is_process_alive", args.buff, args.index, &result) < 0) handle_error(); if (ei_decode_version(result.buff, &index) < 0 || ei_decode_bool(result.buff, &index, &is_alive) < 0) handle_error();
erlang_pid *ei_self(ei_cnode *ec)
Retrieves the pid of the C-node. Every C-node has a (pseudo) pid used in ei_send_reg, ei_rpc, and others. This is contained in a field in the ec structure. It will be safe for a long time to fetch this field directly from the ei_cnode structure.
int ei_send(int fd, erlang_pid* to, char* buf, int len)
Sends an Erlang term to a process.
- fd is an open descriptor to an Erlang connection.
- to is the pid of the intended recipient of the message.
- buf is the buffer containing the term in binary format.
- len is the length of the message in bytes.
Returns 0 if successful, otherwise -1. In the latter case it sets erl_errno to EIO.
int ei_send_encoded(int fd, erlang_pid* to, char* buf, int len)
Works exactly as ei_send, the alternative name is retained for backward compatibility. The function will not be removed without prior notice.
int ei_send_encoded_tmo(int fd, erlang_pid* to, char* buf, int len, unsigned timeout_ms)
Equivalent to ei_send_encoded with an optional time-out argument, see the description at the beginning of this manual page.
int ei_send_reg_encoded(int fd, const erlang_pid *from, const char *to, const char *buf, int len)
This function is retained for compatibility with code generated by the interface compiler and with code following examples in the same application.
The function works as ei_reg_send with one exception. Instead of taking ei_cnode as first argument, it takes a second argument, an erlang_pid, which is to be the process identifier of the sending process (in the Erlang distribution protocol).
A suitable erlang_pid can be constructed from the ei_cnode structure by the following example code:
ei_cnode ec; erlang_pid *self; int fd; /* the connection fd */ ... self = ei_self(&ec); self->num = fd;
Equivalent to ei_send_reg_encoded with an optional time-out argument, see the description at the beginning of this manual page.
int ei_send_tmo(int fd, erlang_pid* to, char* buf, int len, unsigned timeout_ms)
Equivalent to ei_send with an optional time-out argument, see the description at the beginning of this manual page.
const char *ei_thisnodename(ei_cnode *ec)
const char *ei_thishostname(ei_cnode *ec)
const char *ei_thisalivename(ei_cnode *ec)
Can be used to retrieve information about the C-node. These values are initially set with ei_connect_init() or ei_connect_xinit().
These function simply fetch the appropriate field from the ec structure. Read the field directly will probably be safe for a long time, so these functions are not really needed.
int ei_unpublish(ei_cnode *ec)
Can be called by a process to unregister a specified node from EPMD on the local host. This is, however, usually not allowed, unless EPMD was started with flag -relaxed_command_check, which it normally is not.
To unregister a node you have published, you should close the descriptor that was returned by ei_publish().
This function is deprecated and will be removed in a future release.
ec is the node structure of the node to unregister.
If the node was successfully unregistered from EPMD, the function returns 0. Otherwise, -1 is returned and erl_errno is set to EIO.
int ei_unpublish_tmo(ei_cnode *ec, unsigned timeout_ms)
Equivalent to ei_unpublish with an optional time-out argument, see the description at the beginning of this manual page.
Debug Information
If a connection attempt fails, the following can be checked:
- erl_errno.
- That the correct cookie was used
- That EPMD is running
- That the remote Erlang node on the other side is running the same version of Erlang as the ei library
- That environment variable ERL_EPMD_PORT is set correctly
The connection attempt can be traced by setting a trace level by either using ei_set_tracelevel or by setting environment variable EI_TRACELEVEL. The trace levels have the following messages:
- 1: Verbose error messages
- 2: Above messages and verbose warning messages
- 3: Above messages and progress reports for connection handling
- 4: Above messages and progress reports for communication
- 5: Above messages and progress reports for data conversion


Search Tools and Databases
Even though the Museum at the Getty Center reopens on May 25, 2021, the Getty Library remains temporarily closed to the public and most staff as we prepare to welcome readers back safely to the library and the Special Collections Reading Room.
If you are a library reader and wish to visit the Museum, you must reserve free timed-entry tickets. Your reader badge will not give you on-site access or parking validation.
Please subscribe to the Getty Library blog for information and updates about the library reopening.
Library Catalog #
Begin your research with the Library Catalog.
Discover Research Library resources and more.
Open Content Program
Free images for downloading without restriction.
Getty Research Portal™
Access to complete digital copies of art history texts, rare books, and related literature.
Collection Inventories and Finding Aids
Detailed guides to the contents of selected archival collections.
Research Guides and Bibliographies
Overviews of Research Institute collections and specialized areas of research.
Abstracts of International Conservation Literature (AATA)
Over 100,000 abstracts related to the preservation and conservation of cultural heritage material.
Digital Collections
High-resolution images and scans of books and archival papers, available through the Library Catalog.
Article and Subscription Databases
A-Z list of subscription and Getty proprietary databases.
Collecting and Provenance Research
Databases of archival documents, sales catalogs, and public collections.
Photo Archive
An inventory of nearly two million study photographs of art and architecture.
Bibliography of the History of Art (BHA) and Répertoire international de la littérature de l'art (RILA)
European and American visual arts material published between 1975 and 2007.
Getty Search Gateway
Multiple Getty resources, including images from the Open Content Program, accessible through one search tool.
Getty Vocabularies
The Getty vocabularies contain structured terminology for fine art, architecture, decorative arts, archival materials, and other material culture.
The Getty Thesaurus of Geographic Names (TGN)®
London or Londinium? TGN contains names, variant names, and hierarchical context for current and historical cities, towns, nations, empires, physical features, and archaeological sites.
The Art & Architecture Thesaurus (AAT)®
Catherine wheel or rose window? AAT contains terms, synonyms, definitions, and relationships for objects, styles, materials, and other topics related to art, architecture, and other material culture.
The Union List of Artist Names (ULAN)®
Titian or Tiziano Vecellio? ULAN contains names, variant names, and biographical information for artists, architects, studios, firms, and repositories of art.
Cultural Objects Name Authority (CONA)®
Mona Lisa or La Gioconda? CONA, a new vocabulary now accepting contributions, includes titles, attributions, and other information for art and architecture.


monthly
Plan
Basic
Standard
Premium
Quantity
First Name
Last Name
Address
Address 2
City
State
Country
United States
Great Britain
Card Number
Month
Year
CVV
Coupon
Subscribe


contains the signal processing functionality
More...
contains the signal processing functionality
| def sigproc.deframesig |
( |
|
frames, |
|
|
|
siglen, |
|
|
|
frame_len, |
|
|
|
frame_step, |
|
|
|
winfunc = lambda x:numpy.ones((x,) |
|
) |
| |
Does overlap-add procedure to undo the action of framesig.
- Parameters
-
| frames | the array of frames. |
| siglen | the length of the desired signal, use 0 if unknown. Output will be truncated to siglen samples. |
| frame_len | length of each frame measured in samples. |
| frame_step | number of samples after the start of the previous frame that the next frame should begin. |
| winfunc | the analysis window to apply to each frame. By default no window is applied. |
- Returns
- a 1-D signal.
| def sigproc.framesig |
( |
|
sig, |
|
|
|
frame_len, |
|
|
|
frame_step, |
|
|
|
winfunc = lambda x:numpy.ones((x,) |
|
) |
| |
Frame a signal into overlapping frames.
- Parameters
-
| sig | the audio signal to frame. |
| frame_len | length of each frame measured in samples. |
| frame_step | number of samples after the start of the previous frame that the next frame should begin. |
| winfunc | the analysis window to apply to each frame. By default no window is applied. |
- Returns
- an array of frames. Size is NUMFRAMES by frame_len.
| def sigproc.logpowspec |
( |
|
frames, |
|
|
|
NFFT, |
|
|
|
norm = 1 |
|
) |
| |
Compute the log power spectrum of each frame in frames.
If frames is an NxD matrix, output will be NxNFFT.
- Parameters
-
| frames | the array of frames. Each row is a frame. |
| NFFT | the FFT length to use. If NFFT > frame_len, the frames are zero-padded. |
| norm | If norm=1, the log power spectrum is normalised so that the max value (across all frames) is 1. |
- Returns
- If frames is an NxD matrix, output will be NxNFFT. Each row will be the log power spectrum of the corresponding frame.
| def sigproc.magspec |
( |
|
frames, |
|
|
|
NFFT |
|
) |
| |
Compute the magnitude spectrum of each frame in frames.
If frames is an NxD matrix, output will be NxNFFT.
- Parameters
-
| frames | the array of frames. Each row is a frame. |
| NFFT | the FFT length to use. If NFFT > frame_len, the frames are zero-padded. |
- Returns
- If frames is an NxD matrix, output will be NxNFFT. Each row will be the magnitude spectrum of the corresponding frame.
| def sigproc.powspec |
( |
|
frames, |
|
|
|
NFFT |
|
) |
| |
Compute the power spectrum of each frame in frames.
If frames is an NxD matrix, output will be NxNFFT.
- Parameters
-
| frames | the array of frames. Each row is a frame. |
| NFFT | the FFT length to use. If NFFT > frame_len, the frames are zero-padded. |
- Returns
- If frames is an NxD matrix, output will be NxNFFT. Each row will be the power spectrum of the corresponding frame.
| def sigproc.preemphasis |
( |
|
signal, |
|
|
|
coeff = 0.95 |
|
) |
| |
perform preemphasis on the input signal.
- Parameters
-
| signal | The signal to filter. |
| coeff | The preemphasis coefficient. 0 is no filter, default is 0.95. |
- Returns
- the filtered signal.


La Min Ko
A Dev.
null
null
https://laminko.com
Myanmar
Available for hire
Work.
lycan
A simple load testing script which uses YAML as taskset.
Python
1
0
fb_accountkit
A python module for Facebook's AccountKit
Python
1
1
madmac
madmac: MAC address generator
Python
1
0
mongonet
A simple MongoDB image with network utilities (ping, ifconfig, traceroute, etc).
Shell
0
0
mango
A wrapper module for simple MongoDb operations.
Python
1
0
jsonquery
JSON Query for Web2py
Python
1
1
dummy_languages
Dummy source files for color scheme maker.
Shell
0
0
classic-bright-syntax
Classic bright syntax. Actually, it is dark syntax theme inspired from IDLE, XCODE, VS.
CSS
0
0
pydirmerge
Automatically exported from code.google.com/p/pydirmerge
Python
0
0
Forks.
Blog.


{% extends 'admin/master.html' %} {% macro checkbox(field) %}
These placeholders are replaced when the email is sent:


Corporate Profile
※Notification: Address has been changed from April 2020
Profile
| Company Name | New Bridge IT Co. ,Ltd. |
|---|---|
| Address | House D15 (Borey One Park), Sraschork, Beong Kok 1, Doun Penh, Phnom Penh, Cambodia. GoogleMap |
| Establishment | June 14, 2016 |
| Capital | US$ 50,000 |
| Officer | Neang Sophanna |
| Business |
|
| Affiliated Company |


--- layout: moviri-release title: Demos - D3 Table Integration recline-deps: true root: ../../ ---
Loading...


#442 Rizal Avenue, Puerto Princesa City, Palawan
Mobile No.:<PHONE_NUMBER>3
Email<EMAIL_ADDRESS>Pursuing opportunity which will allow me to grow professionally, while effectively
utilizing my versatile skill set to help promote your corporate mission and exceed team goals
Holy Trinity University(2006-2012)
Holy Trinity University(2012-2016)
Palawan State University(2016-2018)
Palawan State University(2018-2021)
Interests
Skills
Experience


Every week, I spend ~5h reading my favorite newsletters on data science (eg, Data Science Roundup, Data Elixir, Jack Clark, Daniel Meissner). My most recent project prevented me from catching up on these articles for a few months - so I took a few days to catch up and synthesize what I had been seeing. That summary can be found below.
Key takeaways
Most of the interesting articles were saying the same things:
- Role definition is still happening, but there is alignment that hybrid models in business are useful
- Businesses are continuing to invest in these initiatives, more understanding that it is not “magic”
- Platforms and cloud tooling continue to enforce the imperative for DS to be able to own models “end to end” - the DS needs to write clean code and launch to production; can be on platforms built by SWE & DE
I didn’t see very much interesting on actual techniques (besides a very interesting post on transfer learning as deep feature extraction), but have shared some below. Lots of talk on ethics, some talk on RL and all of the NLP stuff (Bert & ELMo, etc – great summary of this as an ImageNet moment here).
Role of a Data Engineer
Do I need a data engineer? Here is a second article, distinguishing between DE and an “Analytics Engineer.” Suggests using stitch, fivetran, dbt as data engineering tools in lieu of Airflow. Natural migration (in startups at least) is to do PoCs, early builds on Airflow and then migrate to a more resilient tool like those listed. Super critical role (and primary responsibilities of our principal data engineers on a project), should be responsible for:
- Managing and optimizing core data infrastructure,
- Building and maintaining custom ingestion pipelines,
- Supporting data team resources with design and performance optimization (think 1 DE for 3 DS) and
- Building non-SQL transformation pipelines (PySpark ETL (maybe), geo enrichment)
I thought the idea of removing Airflow for SQL transformations was an interesting trend. I haven’t ever used the three “pipeline-as-a-service” products. For my own projects, the above responsibilities were good to have for our primary data engineer, with a separate, proper SW developer as the code master.
More on role definition. “The Kinds of a Data Scientist.”
- The VP, DS of Instacart split the key types of work into “Decision Science” vs. “Data Products” to identify skills required. I thought the Decision Science example was pretty interesting.
*At LinkedIn, the executive team used decision science to make a critical business decision about the visibility of member profiles in search results. Historically, only paid users could see full profiles for everyone in their extended (third-degree) network. The visibility rules were complex, and LinkedIn wanted to simplify them — but not in a way that would undermine its revenue. The stakes were enormous.
The proposed visibility model was a monthly use limit for unpaid users, with a cut-off based on usage. LinkedIn’s decision scientists simulated the effects of this change, using historical behavior to predict the impact on revenue and engagement. The analysis had to extrapolate past behavior on one model to forecast behavior on a radically different one. Nonetheless, the analysis was sufficient to move forward.*
- “Code as Configuration”. Article written by an experienced DS outlining how DS & SWE/DE should think about working together.
Project management.
- Doing Agile in Data Science. Google. Particular focus on taking the scientific method and breaking it down into “less rigorous hypotheses” that can be (1) time bound and (2) better inform the LT hypotheses you want to prove or disprove in an experiment.
- Divergent and convergent thinking in data analysis. An okay article, on a great concept. With the article above, how do we coach projects to (1) generate good hypotheses with the associated code “spikes”, (2) then fit that into design patterns, etc. that allow us to grow code safely? This can also be very useful for identifying product/project/pilot requirements with business users. I’ve received feedback in projects that “divergent thinking is very uncomfortable” but the decisions it can lead to are almost always of higher value than what a convergent path would provide.
- Design for Continuous Experimentation. Etsy. How Etsy learned to build stage gates into their product development process and use A/B tests to enable stage gate decisions (!!!) I liked how the Principal Engineer framed the way they used their learning from things that did not go well for future projects
- How much should managers code? Wrong question. Where to write code? Coursera. Emphasizes being invested in small bug fixes, code reviews, and JIRA to develop a manager’s empathy for the team’s work and foster better outcomes.
- The State of Data Product Management Roles. Insight Data Science. Highlights 5 domain areas: Infrastructure, Analytics, Applied ML/AI, Platforms, Standardization & Discovery. Note that Analytics and Applied AI/ML roles map well to the two different “kinds of data scientists” outlined above, and the other 3 are DevOps-y in nature.
Experimentation.
- Guidelines for AB Testing at Etsy. Advocates for frequentists methods and to establish measurement up front first. Great anecdote on how more measurement up front changed their delivery process for new features. Many, many links for follow on reads.
- Is Bayesian Testing Immune to Peeking? Not Exactly. Stack Overflow (the company). Less about the Bayesian approach, I thought this was a great way of showing how to use simulation to trust the data behind your decisions (and how p-values can change over time). I fell into a small rabbit hole reading about AB testing from these articles; a theme for me was many different teams using simulation to “shore up” questions around experiment design.
- Analyzing Experiment Outcomes: Beyond ATEs. Uber. Walks through a metric called Quantile Treatment Effect (QTE) that allows for understanding heterogeneity in treatment effects. Cool.
- Experimentation & Measurement for SEO. Airbnb. Useful case study of when to use differences-in-differences and some of the idiosyncrasies to account for.
Data / infrastructure engineering.
- Capturing data evolution in a SOA. Airbnb
- Putting the power of Kafka into the hands of data scientists. Stitch Fix
- Future of Data Warehousing. Cloudera/PNC. Short, 5 min video outlining some challenges standing up a distributed system – seen these challenges at all projects and would expect our DE to work with and help the client set up these processes.
Techniques, Tools, & Interesting reads.
- Contextual bandits for content outreach. Stitch Fix
- How to write clean code and conduct code reviews.
- Forecast sales in retail. A good reference for establishing a baseline and packages/methods
- 3 facts about time-series analyses that can surprise ML people. (eg, “The uncertainty of the forecast is just as important as, or even more so, than the forecast itself.”)
- 11 classical time series forecasting methods in Python. Related: Forecasting at Uber. Interesting to see Uber’s built-in backtesting system.
- A short history of prediction serving systems. RISE Lab. Discusses the architecture of RISE’s Clipper system, and has an interesting paper from LinkedIn on managing the tradeoff between accuracy and serving latency.
- Papermill. Parametric, scheduled Jupyter notebooks with the option for aggregate summaries. Used a lot at Netflix.
- Convoys. PyPI package for time-lagged conversion rates (eg, telco churn..)