Popular New Releases in Learning
leetcode
新书出版
wtfjs
v1.22.1
intro.js
v5.1.0
algorithms
v0.1.4
LeetCode-Go
1.7.0
Popular Libraries in Learning
by freeCodeCamp javascript
344419 BSD-3-Clause
freeCodeCamp.org's open-source codebase and curriculum. Learn to code for free.
by trekhleb javascript
138596 MIT
📝 Algorithms and data structures implemented in JavaScript with explanations and links to further readings
by CyC2018 java
137910
:books: 技术面试必备基础知识、Leetcode、计算机操作系统、计算机网络、系统设计
by TheAlgorithms python
117097 MIT
All Algorithms implemented in Python
by kdn251 java
53816 MIT
Everything you need to know to get the job.
by resume javascript
49535
Resumes generated using the GitHub informations
by TheAlgorithms java
45287 MIT
All Algorithms implemented in Java
by microsoft javascript
44908 MIT
24 Lessons, 12 Weeks, Get Started as a Web Developer
by azl397985856 javascript
43986 NOASSERTION
LeetCode Solutions: A Record of My Problem Solving Journey.( leetcode题解,记录自己的leetcode解题之路。)
Trending New libraries in Learning
by microsoft javascript
44908 MIT
24 Lessons, 12 Weeks, Get Started as a Web Developer
by geekxh java
29811
🌍 针对小白的算法训练 | 包括四部分:①.算法基础 ②.力扣图解 ③.大厂面经 ④.CS_汇总 | 附:1、千本开源电子书 2、百张技术思维导图(项目花了上百小时,希望可以点 star 支持,🌹感谢~)
by greyireland go
12016
算法模板,最科学的刷题方式,最快速的刷题路径,你值得拥有~
by chefyuan java
8824 MIT
专门为刚开始刷题的同学准备的算法基地,没有最细只有更细,立志用动画将晦涩难懂的算法说的通俗易懂!
by coding-horror csharp
8118 Unlicense
An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common MEMORY SAFE, SCRIPTING programming languages. See https://coding-horror.github.io/basic-computer-games/
by AkashSingh3031 jupyter notebook
7378 MIT
This repository contains all the DSA (Data-Structures, Algorithms, 450 DSA by Love Babbar Bhaiya, FAANG Questions), Technical Subjects (OS + DBMS + SQL + CN + OOPs) Theory+Questions, FAANG Interview questions, and Miscellaneous Stuff (Programming MCQs, Puzzles, Aptitude, Reasoning). The Programming languages used for demonstration are C++, Python, and Java.
by Dhghomon shell
6065 MIT
Rust explained using easy English
by yuanguangxin java
5890
LeetCode刷题记录与面试整理
by mdn html
4840 NOASSERTION
The content behind MDN Web Docs
Top Authors in Learning
1
126 Libraries
4879
2
90 Libraries
1933
3
54 Libraries
23695
4
48 Libraries
67554
5
35 Libraries
463
6
35 Libraries
2030
7
33 Libraries
12103
8
33 Libraries
25961
9
30 Libraries
594
10
29 Libraries
4333
1
126 Libraries
4879
2
90 Libraries
1933
3
54 Libraries
23695
4
48 Libraries
67554
5
35 Libraries
463
6
35 Libraries
2030
7
33 Libraries
12103
8
33 Libraries
25961
9
30 Libraries
594
10
29 Libraries
4333
Trending Kits in Learning
JavaScript libraries are collections of pre-written code that can be used to create web applications. They provide functions, features, and resources.
It makes the development process faster and easier They often create dynamic, interactive experiences on websites and applications. JavaScript libraries are used for various tasks, such as DOM manipulation, AJAX requests, data analysis and visualization, client-side storage, and more. It includes Creating Interactive Tours, Enhancing Customer Experience, Creating Interactive Tutorials, and Improving User Onboarding.
Let us look at some of these famous libraries.
webpack
- Offers advanced features such as code-splitting, hot module replacement (HMR), tree-shaking, and dynamic loading.
- Provides plugins and loaders that can be used to customize how code is transformed and bundled.
- Allows to combine multiple modules into a single bundle.
mocha
- Provides an asynchronous testing interface.
- Supports a wide variety of testing styles with its flexible syntax.
- Allows developers to create custom test interfaces and reporters.
intro.js
- Supports auto-scroll and scroll-hijacking.
- Allows developers to create custom tours in any language.
- Provides a modern and lightweight interface, with a minimalistic design.
bower
- Supports versioning and resolution of dependencies.
- Provides command line interface making it easy to instantly search, install, and manage packages in a project.
- Allows to manage both front-end and back-end packages.
grunt
- Provides wide range of plugins and third-party integrations.
- Provides built-in support for popular frameworks and libraries.
- Allows developers to easily configure and create tasks for automating common development workflows.
knockout
- Provides an easy-to-use two-way data-binding system.
- Provides a powerful templating system that makes it easy to display complex data structures.
- Provides a declarative binding syntax that simplifies linking the data to the HTML elements on the page.
shepherd
- Allows developers to create step-by-step product tours and walkthroughs intuitively.
- Provides options for targeting specific users, including localization and different themes.
- Supports integration with other libraries and frameworks, such as React and Vue.
mixitup
- Provides built-in support for powerful animation effects.
- Allows developers to create custom sorting and filtering rules.
- Supports integration with external API's, allowing pulling in data from other sources.
hopscotch
- Is highly accessible, i.e., it is easy for people with disabilities to use.
- Offers comprehensive documentation, making it easy for developers to get up and running quickly.
- Is device-agnostic, meaning it works across different devices and browsers.
joyride
- Provides a built-in feature called “Progress Indicator,” which allows the user to see their progress through the tour.
- A built-in analytics system provides valuable insights into how users interact with the tour.
- Allows developers to easily add triggers and custom CSS to enhance the user experience.
class Question:
def __init__(self, prompt, options, correct_option):
self.prompt = prompt
self.options = options
self.correct_option = correct_option
def ask_question(self):
print(self.prompt)
for i, option in enumerate(self.options, 1):
print(f"{i}. {option}")
user_answer = input("Enter the number of your answer: ")
return int(user_answer) == self.correct_option
def run_quiz(questions):
score = 0
for question in questions:
if question.ask_question():
print("Correct!\n")
score += 1
else:
print("Incorrect. The correct answer was option", question.correct_option, "\n")
print("You got", score, "out of", len(questions), "questions correct.")
# Define your questions here
question1 = Question("What is the capital of France?", ["Paris", "Rome", "Berlin", "Madrid"], 1)
question2 = Question("What is the largest planet in our solar system?", ["Jupiter", "Mars", "Venus", "Saturn"], 1)
question3 = Question("What is 2 + 2?", ["3", "4", "5", "6"], 2)
# Add more questions if desired
questions = [question1, question2, question3]
# Run the quiz
run_quiz(questions)
The Primary School Leaving Examination (PSLE) is a significant milestone in the academic journey of Singaporean students. Among its various components, the PSLE English Oral examination stands out as a crucial assessment of students' proficiency in spoken English. This article aims to provide a comprehensive guide to mastering the PSLE English Oral examination, offering insights into its format, importance, preparation strategies, and tips for success.
Importance of PSLE English Oral Examination
The PSLE English Oral examination holds considerable weight in evaluating a student's language proficiency. It assesses not only their ability to articulate thoughts and express ideas coherently but also their fluency, pronunciation, and intonation. A strong performance in the oral component can significantly impact the overall English grade, underscoring its importance in the PSLE assessment framework.
Understanding the Format of PSLE English Oral Examination
Types of Questions
The PSLE English Oral examination typically includes various question types designed to test different aspects of oral communication skills. These may include reading passages, picture descriptions, situational dialogues, and personal opinion questions. Students are expected to respond effectively to each question type, demonstrating comprehension, critical thinking, and linguistic accuracy.
Evaluation Criteria
To excel in the PSLE English Oral examination, students must meet specific evaluation criteria set by assessors. These criteria often include pronunciation, intonation, articulation, fluency, clarity, coherence, and relevance of responses. Assessors also look for evidence of engagement, creativity, and depth of understanding in students' oral communication.
Tips for Preparation
1. Enhancing Communication Skills
Effective communication is the cornerstone of success in the PSLE English Oral examination. Students should focus on improving their speaking and listening skills through regular practice and exposure to diverse language contexts. Engaging in conversations, reading aloud, and listening to audio recordings can help develop fluency and confidence in spoken English.
2. Practicing Pronunciation and Intonation
Accurate pronunciation and intonation are essential for conveying meaning effectively. Students should practice enunciating words clearly and expressing emotions through variations in pitch and tone. Tongue twisters, phonetic exercises, and mimicking native speakers can aid in improving pronunciation and intonation skills.
3. Building Confidence
Confidence plays a crucial role in oral communication. Encourage students to participate in speaking activities, such as debates, presentations, and role-plays, to boost their self-assurance and poise. Positive reinforcement, supportive feedback, and acknowledging their progress can help build students' confidence in expressing themselves orally.
Strategies for Excelling in PSLE English Oral
1. Effective Time Management
Time management is paramount during the PSLE English Oral examination. Students must allocate sufficient time for each question and ensure they cover all aspects of the prompt within the allotted time. Practicing timed speaking exercises and developing a strategy for organizing thoughts coherently can aid in effective time management.
2. Structuring Responses
Structured responses demonstrate clarity of thought and organization. Encourage students to outline their answers before speaking, incorporating an introduction, body, and conclusion for coherence and cohesion. Emphasize the importance of addressing the question directly, providing relevant examples or evidence to support their points.
3. Handling Nervousness
Nervousness is natural before any examination. Teach students relaxation techniques, such as deep breathing and positive visualization, to manage anxiety and perform optimally during the oral assessment. Encourage them to focus on their preparation, trust in their abilities, and maintain a positive mindset throughout the examination.
Resources for Practice
To prepare for the PSLE English Oral examination, students can utilize various resources to enhance their skills and confidence:
- Practice Papers: Accessing sample questions and practice papers can familiarize students with the format and types of questions asked in the examination. Practicing responses to different prompts can help them refine their oral communication skills and develop effective strategies for tackling each question type.
- Online Tutorials: Online tutorials and instructional videos provide valuable insights, tips, and techniques for mastering oral communication skills. Platforms such as educational websites, YouTube channels, and language learning apps offer a wealth of resources that complement classroom instruction and self-study efforts.
- Language Enrichment Programs: Enrolling in language enrichment programs or extracurricular activities can provide additional support and opportunities for practicing spoken English. Language centers, community organizations, and school-based initiatives offer workshops, seminars, and clubs focused on improving oral communication skills in English.
Conclusion
Mastering the PSLE English Oral examination requires diligent preparation, effective communication skills, and confidence. By understanding the format, focusing on key evaluation criteria, and implementing proven strategies, students can excel in this essential component of the PSLE. With dedication, practice, and access to resources, success in the English Oral examination is achievable for every student.
Trending Discussions on Learning
How do purely functional languages handle index-based algorithms?
How can I fix this : Warning: the fonts "Times" and "Times" are not available for the Java logical font "Serif"
Keras AttributeError: 'Sequential' object has no attribute 'predict_classes'
How do I fix CLIENT_MISSING_INTENTS error?
Getting error 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED'
Vue 3 passing array warning: Extraneous non-props attributes were passed to component but could not be automatically inherited
TypeError: match.loader.options.plugins is not a function
Group and create three new columns by condition [Low, Hit, High]
What should the result be when assigning a variable to a reference to itself, in-between modified and then returned by a function call?
Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated
QUESTION
How do purely functional languages handle index-based algorithms?
Asked 2022-Apr-05 at 12:51I have been trying to learn about functional programming, but I still struggle with thinking like a functional programmer. One such hangup is how one would implement index-heavy operations which rely strongly on loops/order-of-execution.
For example, consider the following Java code:
1public class Main {
2 public static void main(String[] args) {
3 List<Integer> nums = Arrays.asList(1,2,3,4,5,6,7,8,9);
4 System.out.println("Nums:\t"+ nums);
5 System.out.println("Prefix:\t"+prefixList(nums));
6 }
7
8 private static List<Integer> prefixList(List<Integer> nums){
9 List<Integer> prefix = new ArrayList<>(nums);
10 for(int i = 1; i < prefix.size(); ++i)
11 prefix.set(i, prefix.get(i) + prefix.get(i-1));
12 return prefix;
13 }
14}
15/*
16System.out:
17Nums: [1, 2, 3, 4, 5, 6, 7, 8, 9]
18Prefix: [1, 3, 6, 10, 15, 21, 28, 36, 45]
19*/
20
Here, in the prefixList
function, the nums list is first cloned, but then there is the iterative operation performed on it, where the value on index i relies on index i-1 (i.e. order of execution is required). Then this value is returned.
What would this look like in a functional language (Haskell, Lisp, etc.)? I have been learning about monads and think they may be relevant here, but my understanding is still not great.
ANSWER
Answered 2022-Mar-07 at 21:17This is not an index-heavy operation, in fact you can do this with a one-liner with scanl1 :: (a -> a -> a) -> [a] -> [a]
:
1public class Main {
2 public static void main(String[] args) {
3 List<Integer> nums = Arrays.asList(1,2,3,4,5,6,7,8,9);
4 System.out.println("Nums:\t"+ nums);
5 System.out.println("Prefix:\t"+prefixList(nums));
6 }
7
8 private static List<Integer> prefixList(List<Integer> nums){
9 List<Integer> prefix = new ArrayList<>(nums);
10 for(int i = 1; i < prefix.size(); ++i)
11 prefix.set(i, prefix.get(i) + prefix.get(i-1));
12 return prefix;
13 }
14}
15/*
16System.out:
17Nums: [1, 2, 3, 4, 5, 6, 7, 8, 9]
18Prefix: [1, 3, 6, 10, 15, 21, 28, 36, 45]
19*/
20prefixList = scanl1 (+)
21
indeed, for the list of Nums
, we get:
1public class Main {
2 public static void main(String[] args) {
3 List<Integer> nums = Arrays.asList(1,2,3,4,5,6,7,8,9);
4 System.out.println("Nums:\t"+ nums);
5 System.out.println("Prefix:\t"+prefixList(nums));
6 }
7
8 private static List<Integer> prefixList(List<Integer> nums){
9 List<Integer> prefix = new ArrayList<>(nums);
10 for(int i = 1; i < prefix.size(); ++i)
11 prefix.set(i, prefix.get(i) + prefix.get(i-1));
12 return prefix;
13 }
14}
15/*
16System.out:
17Nums: [1, 2, 3, 4, 5, 6, 7, 8, 9]
18Prefix: [1, 3, 6, 10, 15, 21, 28, 36, 45]
19*/
20prefixList = scanl1 (+)
21Prelude> prefixList [1 .. 9]
22[1,3,6,10,15,21,28,36,45]
23
scanl1
takes the first item of the original list as initial value for the accumulator, and yields that. Then each time it takes the accumulator and the next item of the given list, and sums these up as new accumulator, and yields the new accumulator value.
Often one does not need indexing, but enumerating over the list is sufficient. Imperative programming languages often work with for
loops with indexes, but in many cases these can be replaced by foreach
loops that thus do not take the index into account. In Haskell this also often helps to make algorithms more lazy.
If you really need random access lookups, you can work with data structures such as defined in the array
and vector
packages.
QUESTION
How can I fix this : Warning: the fonts "Times" and "Times" are not available for the Java logical font "Serif"
Asked 2022-Mar-27 at 13:54system:Mac OS software:AnyLogic 8 Personal Learning Edition 8.7.6 language: Java
When I run my model, the console print this info:
Warning: the fonts "Times" and "Times" are not available for the Java logical font "Serif", which may have unexpected appearance or behavior. Re-enable the "Times" font to remove this warning.
ANSWER
Answered 2021-Aug-01 at 11:11We also recently had this issue on a mac running the latest public beta of Monterey.
For some reason the Times font was no longer installed or active on the Mac.
You can check in FontBook
You can simply reinstall it
I struggled to find a source online - her is one suggestion - https://www.freebestfonts.com/timr45w-font
QUESTION
Keras AttributeError: 'Sequential' object has no attribute 'predict_classes'
Asked 2022-Mar-23 at 04:30Im attempting to find model performance metrics (F1 score, accuracy, recall) following this guide https://machinelearningmastery.com/how-to-calculate-precision-recall-f1-and-more-for-deep-learning-models/
This exact code was working a few months ago but now returning all sorts of errors, very confusing since i havent changed one character of this code. Maybe a package update has changed things?
I fit the sequential model with model.fit, then used model.evaluate to find test accuracy. Now i am attempting to use model.predict_classes to make class predictions (model is a multi-class classifier). Code shown below:
1model = Sequential()
2model.add(Dense(24, input_dim=13, activation='relu'))
3model.add(Dense(18, activation='relu'))
4model.add(Dense(6, activation='softmax'))
5model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
6
7-
8
9history = model.fit(X_train, y_train, batch_size = 256, epochs = 10, verbose = 2, validation_split = 0.2)
10
11-
12
13score, acc = model.evaluate(X_test, y_test,verbose=2, batch_size= 256)
14print('test accuracy:', acc)
15
16-
17
18yhat_classes = model.predict_classes(X_test)
19
20
last line returns error "AttributeError: 'Sequential' object has no attribute 'predict_classes'"
This exact code was working not long ago so struggling a bit, thanks for any help
ANSWER
Answered 2021-Aug-19 at 03:49This function were removed in TensorFlow version 2.6. According to the keras in rstudio reference
update to
1model = Sequential()
2model.add(Dense(24, input_dim=13, activation='relu'))
3model.add(Dense(18, activation='relu'))
4model.add(Dense(6, activation='softmax'))
5model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
6
7-
8
9history = model.fit(X_train, y_train, batch_size = 256, epochs = 10, verbose = 2, validation_split = 0.2)
10
11-
12
13score, acc = model.evaluate(X_test, y_test,verbose=2, batch_size= 256)
14print('test accuracy:', acc)
15
16-
17
18yhat_classes = model.predict_classes(X_test)
19
20predict_x=model.predict(X_test)
21classes_x=np.argmax(predict_x,axis=1)
22
Or use TensorFlow 2.5 or later.
If you are using TensorFlow version 2.5, you will receive the following warning:
tensorflow\python\keras\engine\sequential.py:455: UserWarning:
model.predict_classes()
is deprecated and will be removed after 2021-01-01. Please use instead:*np.argmax(model.predict(x), axis=-1)
, if your model does multi-class classification (e.g. if it uses asoftmax
last-layer activation).*(model.predict(x) > 0.5).astype("int32")
, if your model does binary classification (e.g. if it uses asigmoid
last-layer activation).
QUESTION
How do I fix CLIENT_MISSING_INTENTS error?
Asked 2022-Mar-11 at 10:51I started learning about discord.js but now I am facing this issue. I tried some googling but couldn't manage to fix it.
1const Discord = require('discord.js');
2// const Discord = require('discord.js');
3
4// using Intents class
5const client = new Discord.Client();
6
7client.on('message', (msg) => {
8 // Send back a reply when the specific command has been written by a user.
9 if (msg.content === '!hello') {
10 msg.reply('Hello World!');
11 }
12});
13
14client.login('my_token');
15
16
ANSWER
Answered 2021-Aug-07 at 16:34You need to specify the events which you want your bot to receive using gateway intents.
Instead of
const client = new Discord.Client();
Use
const client = new Discord.Client({ intents: [Enter intents here] })
For example
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
Here's another useful link: https://discord.com/developers/docs/topics/gateway
QUESTION
Getting error 'digital envelope routines', reason: 'unsupported', code: 'ERR_OSSL_EVP_UNSUPPORTED'
Asked 2022-Mar-05 at 09:54I got this error when learning Next.js, using npx create-next-app
command according to site documentation here https://nextjs.org/docs/api-reference/create-next-app. Everything works until I start the server,
Error stack:
1$ npm run dev
2
3> devto-clone@0.1.0 dev
4> next dev
5
6ready - started server on 0.0.0.0:3000, url: http://localhost:3000
7info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
8Error: error:0308010C:digital envelope routines::unsupported
9 at new Hash (node:internal/crypto/hash:67:19)
10 at Object.createHash (node:crypto:130:10)
11 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
12 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
13 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
14 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
15 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
16 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
17 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
18 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
19Error: error:0308010C:digital envelope routines::unsupported
20 at new Hash (node:internal/crypto/hash:67:19)
21 at Object.createHash (node:crypto:130:10)
22 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
23 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
24 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
25 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
26 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
27 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
28 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
29 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
30node:internal/crypto/hash:67
31 this[kHandle] = new _Hash(algorithm, xofLen);
32 ^
33
34Error: error:0308010C:digital envelope routines::unsupported
35 at new Hash (node:internal/crypto/hash:67:19)
36 at Object.createHash (node:crypto:130:10)
37 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
38 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
39 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
40 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
41 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
42 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
43 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
44 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5 {
45 opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
46 library: 'digital envelope routines',
47 reason: 'unsupported',
48 code: 'ERR_OSSL_EVP_UNSUPPORTED'
49}
50
51Node.js v17.0.1
52
package.json :
1$ npm run dev
2
3> devto-clone@0.1.0 dev
4> next dev
5
6ready - started server on 0.0.0.0:3000, url: http://localhost:3000
7info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
8Error: error:0308010C:digital envelope routines::unsupported
9 at new Hash (node:internal/crypto/hash:67:19)
10 at Object.createHash (node:crypto:130:10)
11 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
12 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
13 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
14 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
15 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
16 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
17 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
18 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
19Error: error:0308010C:digital envelope routines::unsupported
20 at new Hash (node:internal/crypto/hash:67:19)
21 at Object.createHash (node:crypto:130:10)
22 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
23 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
24 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
25 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
26 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
27 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
28 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
29 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
30node:internal/crypto/hash:67
31 this[kHandle] = new _Hash(algorithm, xofLen);
32 ^
33
34Error: error:0308010C:digital envelope routines::unsupported
35 at new Hash (node:internal/crypto/hash:67:19)
36 at Object.createHash (node:crypto:130:10)
37 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
38 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
39 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
40 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
41 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
42 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
43 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
44 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5 {
45 opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
46 library: 'digital envelope routines',
47 reason: 'unsupported',
48 code: 'ERR_OSSL_EVP_UNSUPPORTED'
49}
50
51Node.js v17.0.1
52{
53 "name": "devto-clone",
54 "version": "0.1.0",
55 "private": true,
56 "scripts": {
57 "dev": "next dev",
58 "build": "next build",
59 "start": "next start",
60 "lint": "next lint"
61 },
62 "dependencies": {
63 "next": "11.1.2",
64 "react": "17.0.2",
65 "react-dom": "17.0.2"
66 },
67 "devDependencies": {
68 "eslint": "7.32.0",
69 "eslint-config-next": "11.1.2"
70 }
71}
72
ANSWER
Answered 2021-Nov-24 at 21:38I found this solution https://github.com/webpack/webpack/issues/14532
if using bash just run
NODE_OPTIONS=--openssl-legacy-provider
before any commandadding
NODE_OPTIONS=--openssl-legacy-provider
to package.json
1$ npm run dev
2
3> devto-clone@0.1.0 dev
4> next dev
5
6ready - started server on 0.0.0.0:3000, url: http://localhost:3000
7info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
8Error: error:0308010C:digital envelope routines::unsupported
9 at new Hash (node:internal/crypto/hash:67:19)
10 at Object.createHash (node:crypto:130:10)
11 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
12 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
13 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
14 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
15 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
16 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
17 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
18 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
19Error: error:0308010C:digital envelope routines::unsupported
20 at new Hash (node:internal/crypto/hash:67:19)
21 at Object.createHash (node:crypto:130:10)
22 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
23 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
24 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
25 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
26 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
27 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
28 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
29 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5
30node:internal/crypto/hash:67
31 this[kHandle] = new _Hash(algorithm, xofLen);
32 ^
33
34Error: error:0308010C:digital envelope routines::unsupported
35 at new Hash (node:internal/crypto/hash:67:19)
36 at Object.createHash (node:crypto:130:10)
37 at BulkUpdateDecorator.hashFactory (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138971:18)
38 at BulkUpdateDecorator.update (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:138872:50)
39 at OriginalSource.updateHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack-sources3\index.js:1:10264)
40 at NormalModule._initBuildHash (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68468:17)
41 at handleParseResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68534:10)
42 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68628:4
43 at processResult (C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68343:11)
44 at C:\xampp\htdocs\devto-clone\node_modules\next\dist\compiled\webpack\bundle5.js:68407:5 {
45 opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
46 library: 'digital envelope routines',
47 reason: 'unsupported',
48 code: 'ERR_OSSL_EVP_UNSUPPORTED'
49}
50
51Node.js v17.0.1
52{
53 "name": "devto-clone",
54 "version": "0.1.0",
55 "private": true,
56 "scripts": {
57 "dev": "next dev",
58 "build": "next build",
59 "start": "next start",
60 "lint": "next lint"
61 },
62 "dependencies": {
63 "next": "11.1.2",
64 "react": "17.0.2",
65 "react-dom": "17.0.2"
66 },
67 "devDependencies": {
68 "eslint": "7.32.0",
69 "eslint-config-next": "11.1.2"
70 }
71}
72"scripts": {
73 "start": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
74 "build": "SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"
75 },
76
Edit
In my case, I'm using Nodejs 17.0.1 version and causing this error.
Firstly I'm using this command export NODE_OPTIONS=--openssl-legacy-provider
before any command in GitBash Windows to fix this issue.
But, I think it's not an efficient way, so what I do is :
- Uninstall Nodejs 17.0.1
- Install it again Nodejs 16.13.0 version
- I'm facing error another error when I start the server using "yarn serve" (another of my exiting Vuejs project), I don't remember what is this, but after I run "yarn" and "yarn serve", everything works now as I accept
QUESTION
Vue 3 passing array warning: Extraneous non-props attributes were passed to component but could not be automatically inherited
Asked 2022-Feb-26 at 21:48please, I'm learning a VueJS 3 and I have probably begineer problem. I have warn in browser developer console like this one:
The Message is:
1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2
I'm passing array of objects to the child Component. In my parent views/Home.vue
compoment I have this implemenation:
1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15 components: {
16 ItemDescription,
17 },
18 setup() {
19 const items = ref(data)
20
21 return {
22 items,
23 }
24 },
25</script>
26
In child compoment components/ItemProperties.vue
I have this code:
1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15 components: {
16 ItemDescription,
17 },
18 setup() {
19 const items = ref(data)
20
21 return {
22 items,
23 }
24 },
25</script>
26<template>
27 <div class="infobox-item-property" v-for="(object, index) in info" :key="index">
28 <span class="infobox-item-title">{{ object.name }}:</span>
29 <span v-if="object.type === 'rating'">
30 <span v-for="(v, k) in object.value" :key="k">{{ object.icon }}</span>
31 </span>
32 <span v-else>
33 <span>{{ object.value }}</span>
34 </span>
35 </div>
36</template>
37
38<script>
39export default {
40 props: {
41 info: {
42 type: Array,
43 required: false,
44 default: () => [
45 {
46 name: '',
47 value: '',
48 type: 'string',
49 icon: '',
50 },
51 ],
52 },
53 },
54}
55</script>
56
It doesn't matter if I have default()
function or not. Also doesn't matter if I have v-if
condition or not. If I have cycle in the Array, I got this warning
Data are in data.js
file. The part of file is here:
1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15 components: {
16 ItemDescription,
17 },
18 setup() {
19 const items = ref(data)
20
21 return {
22 items,
23 }
24 },
25</script>
26<template>
27 <div class="infobox-item-property" v-for="(object, index) in info" :key="index">
28 <span class="infobox-item-title">{{ object.name }}:</span>
29 <span v-if="object.type === 'rating'">
30 <span v-for="(v, k) in object.value" :key="k">{{ object.icon }}</span>
31 </span>
32 <span v-else>
33 <span>{{ object.value }}</span>
34 </span>
35 </div>
36</template>
37
38<script>
39export default {
40 props: {
41 info: {
42 type: Array,
43 required: false,
44 default: () => [
45 {
46 name: '',
47 value: '',
48 type: 'string',
49 icon: '',
50 },
51 ],
52 },
53 },
54}
55</script>
56export const data = [
57 {
58 title: 'White shirt',
59 properties: [
60 { name: 'Material', value: 'Cotton', type: 'string', icon: '' },
61 { name: 'Size', value: 'M', type: 'string', icon: '' },
62 { name: 'Count', value: 4, type: 'number', icon: '' },
63 { name: 'Absorption', value: 4, type: 'rating', icon: '💧' },
64 { name: 'Rating', value: 2, type: 'rating', icon: '⭐️' },
65 { name: 'Confort', value: 2, type: 'rating', icon: '🛏' },
66 { name: 'Sleeves', value: 'Short', type: 'string', icon: '' },
67 { name: 'Color', value: 'White', type: 'string', icon: '' },
68 ],
69 },
70]
71
PS: Application works but I'm afraid about that warning. What can I do please like right way?
I will be glad for any advice. Thank you very much.
ANSWER
Answered 2021-Aug-16 at 13:32The ItemProperties
component has multiple root nodes because it renders a list in the root with v-for
.
Based on the class name (infobox-item-properties
), I think you want the class to be applied to a container element, so a simple solution is to just add that element (e.g., a div
) in your component at the root:
1[Vue warn]: Extraneous non-props attributes (class) were passed to component but could not be automatically inherited because component renders fragment or text root nodes.
2<template>
3 <div class="wrapper">
4 <section v-for="(item, index) in items" :key="index" class="box">
5 <ItemProperties class="infobox-item-properties" :info="item.properties" />
6 </section>
7 </div>
8</template>
9<script>
10import { ref } from 'vue'
11import { data } from '@/data.js'
12import ItemProperties from '@/components/ItemProperties.vue'
13
14export default {
15 components: {
16 ItemDescription,
17 },
18 setup() {
19 const items = ref(data)
20
21 return {
22 items,
23 }
24 },
25</script>
26<template>
27 <div class="infobox-item-property" v-for="(object, index) in info" :key="index">
28 <span class="infobox-item-title">{{ object.name }}:</span>
29 <span v-if="object.type === 'rating'">
30 <span v-for="(v, k) in object.value" :key="k">{{ object.icon }}</span>
31 </span>
32 <span v-else>
33 <span>{{ object.value }}</span>
34 </span>
35 </div>
36</template>
37
38<script>
39export default {
40 props: {
41 info: {
42 type: Array,
43 required: false,
44 default: () => [
45 {
46 name: '',
47 value: '',
48 type: 'string',
49 icon: '',
50 },
51 ],
52 },
53 },
54}
55</script>
56export const data = [
57 {
58 title: 'White shirt',
59 properties: [
60 { name: 'Material', value: 'Cotton', type: 'string', icon: '' },
61 { name: 'Size', value: 'M', type: 'string', icon: '' },
62 { name: 'Count', value: 4, type: 'number', icon: '' },
63 { name: 'Absorption', value: 4, type: 'rating', icon: '💧' },
64 { name: 'Rating', value: 2, type: 'rating', icon: '⭐️' },
65 { name: 'Confort', value: 2, type: 'rating', icon: '🛏' },
66 { name: 'Sleeves', value: 'Short', type: 'string', icon: '' },
67 { name: 'Color', value: 'White', type: 'string', icon: '' },
68 ],
69 },
70]
71// ItemProperties.vue
72<template>
73 <div>
74 <section v-for="(item, index) in items" :key="index" class="box">
75 ...
76 </section>
77 </div>
78</template>
79
QUESTION
TypeError: match.loader.options.plugins is not a function
Asked 2022-Feb-24 at 05:03I am trying to use tailwindCSS in a ReactJS app
These are the scripts commands in package.json
file
1 "scripts": {
2 "start": "craco start",
3 "build": "craco build",
4 "test": "craco test",
5 "eject": "react-scripts eject"
6 }
7
This is my craco.config.js
1 "scripts": {
2 "start": "craco start",
3 "build": "craco build",
4 "test": "craco test",
5 "eject": "react-scripts eject"
6 }
7module.exports = {
8 style: {
9 postcss: {
10 plugins: [
11 require('tailwindcss'),
12 require('autoprefixer'),
13 ],
14 },
15 },
16}
17
When I am used npm run start
command, I am facing this error
1 "scripts": {
2 "start": "craco start",
3 "build": "craco build",
4 "test": "craco test",
5 "eject": "react-scripts eject"
6 }
7module.exports = {
8 style: {
9 postcss: {
10 plugins: [
11 require('tailwindcss'),
12 require('autoprefixer'),
13 ],
14 },
15 },
16}
17TypeError: match.loader.options.plugins is not a function
18 at extendsPostcss (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:54:51)
19 at overrideLoader (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:97:9)
20 at C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:118:13
21 at Array.forEach (<anonymous>)
22 at overridePostcss (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:117:17)
23 at overrideStyle (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\style.js:9:25)
24 at mergeWebpackConfig (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\merge-webpack-config.js:77:30)
25 at overrideWebpackDev (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\override.js:11:36)
26 at C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\scripts\start.js:27:5
27
Things that I have tried :
- Reinstall
node_modules
Got this error, when I tried to do that
1 "scripts": {
2 "start": "craco start",
3 "build": "craco build",
4 "test": "craco test",
5 "eject": "react-scripts eject"
6 }
7module.exports = {
8 style: {
9 postcss: {
10 plugins: [
11 require('tailwindcss'),
12 require('autoprefixer'),
13 ],
14 },
15 },
16}
17TypeError: match.loader.options.plugins is not a function
18 at extendsPostcss (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:54:51)
19 at overrideLoader (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:97:9)
20 at C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:118:13
21 at Array.forEach (<anonymous>)
22 at overridePostcss (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\postcss.js:117:17)
23 at overrideStyle (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\style\style.js:9:25)
24 at mergeWebpackConfig (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\merge-webpack-config.js:77:30)
25 at overrideWebpackDev (C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\lib\features\webpack\override.js:11:36)
26 at C:\Development\Open Source\Learning Hub\react\node_modules\@craco\craco\scripts\start.js:27:5
27$ npm i @craco/craco
28npm ERR! code ERESOLVE
29npm ERR! ERESOLVE unable to resolve dependency tree
30npm ERR!
31npm ERR! While resolving: first-react-app@0.1.0
32npm ERR! Found: react-scripts@5.0.0
33npm ERR! node_modules/react-scripts
34npm ERR! react-scripts@"5.0.0" from the root project
35npm ERR!
36npm ERR! Could not resolve dependency:
37npm ERR! peer react-scripts@"^4.0.0" from @craco/craco@6.4.3
38npm ERR! node_modules/@craco/craco
39npm ERR! @craco/craco@"*" from the root project
40npm ERR!
41npm ERR! Fix the upstream dependency conflict, or retry
42npm ERR! this command with --force, or --legacy-peer-deps
43npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
44
ANSWER
Answered 2021-Dec-18 at 22:00It looks like the Tailwind configuration from CRACO is not needed anymore.
https://github.com/facebook/create-react-app/issues/11771#issuecomment-997217680
Look at Tailwind 3.0 install steps: https://tailwindcss.com/docs/guides/create-react-app
QUESTION
Group and create three new columns by condition [Low, Hit, High]
Asked 2022-Feb-10 at 16:22I have a large dataset (~5 Mio rows) with results from a Machine Learning training. Now I want to check to see if the results hit the "target range" or not. Lets say this range contains all values between -0.25
and +0.25
. If it's inside this range, it's a Hit
, if it's below Low
and on the other side High
.
I now would create this three columns Hit, Low, High and calculate for each row which condition applies and put a 1
into this col, the other two would become 0
. After that I would group the values and sum them up. But I suspect there must be a better and faster way, such as calculate it directly while grouping. I'm happy for any idea.
Data
1import pandas as pd
2
3df = pd.DataFrame({"Type":["RF", "RF", "RF", "MLP", "MLP", "MLP"], "Value":[-1.5,-0.1,1.7,0.2,-0.7,-0.6]})
4
5+----+--------+---------+
6| | Type | Value |
7|----+--------+---------|
8| 0 | RF | -1.5 | <- Low
9| 1 | RF | -0.1 | <- Hit
10| 2 | RF | 1.7 | <- High
11| 3 | MLP | 0.2 | <- Hit
12| 4 | MLP | -0.7 | <- Low
13| 5 | MLP | -0.6 | <- Low
14+----+--------+---------+
15
Expected Output
1import pandas as pd
2
3df = pd.DataFrame({"Type":["RF", "RF", "RF", "MLP", "MLP", "MLP"], "Value":[-1.5,-0.1,1.7,0.2,-0.7,-0.6]})
4
5+----+--------+---------+
6| | Type | Value |
7|----+--------+---------|
8| 0 | RF | -1.5 | <- Low
9| 1 | RF | -0.1 | <- Hit
10| 2 | RF | 1.7 | <- High
11| 3 | MLP | 0.2 | <- Hit
12| 4 | MLP | -0.7 | <- Low
13| 5 | MLP | -0.6 | <- Low
14+----+--------+---------+
15pd.DataFrame({"Type":["RF", "MLP"], "Low":[1,2], "Hit":[1,1], "High":[1,0]})
16
17+----+--------+-------+-------+--------+
18| | Type | Low | Hit | High |
19|----+--------+-------+-------+--------|
20| 0 | RF | 1 | 1 | 1 |
21| 1 | MLP | 2 | 1 | 0 |
22+----+--------+-------+-------+--------+
23
ANSWER
Answered 2022-Feb-10 at 16:13You could use cut
to define the groups and pivot_table
to reshape:
1import pandas as pd
2
3df = pd.DataFrame({"Type":["RF", "RF", "RF", "MLP", "MLP", "MLP"], "Value":[-1.5,-0.1,1.7,0.2,-0.7,-0.6]})
4
5+----+--------+---------+
6| | Type | Value |
7|----+--------+---------|
8| 0 | RF | -1.5 | <- Low
9| 1 | RF | -0.1 | <- Hit
10| 2 | RF | 1.7 | <- High
11| 3 | MLP | 0.2 | <- Hit
12| 4 | MLP | -0.7 | <- Low
13| 5 | MLP | -0.6 | <- Low
14+----+--------+---------+
15pd.DataFrame({"Type":["RF", "MLP"], "Low":[1,2], "Hit":[1,1], "High":[1,0]})
16
17+----+--------+-------+-------+--------+
18| | Type | Low | Hit | High |
19|----+--------+-------+-------+--------|
20| 0 | RF | 1 | 1 | 1 |
21| 1 | MLP | 2 | 1 | 0 |
22+----+--------+-------+-------+--------+
23(df.assign(group=pd.cut(df['Value'],
24 [float('-inf'), -0.25, 0.25, float('inf')],
25 labels=['Low', 'Hit', 'High']))
26 .pivot_table(index='Type', columns='group', values='Value', aggfunc='count')
27 .reset_index()
28 .rename_axis(None, axis=1)
29)
30
Or crosstab
:
1import pandas as pd
2
3df = pd.DataFrame({"Type":["RF", "RF", "RF", "MLP", "MLP", "MLP"], "Value":[-1.5,-0.1,1.7,0.2,-0.7,-0.6]})
4
5+----+--------+---------+
6| | Type | Value |
7|----+--------+---------|
8| 0 | RF | -1.5 | <- Low
9| 1 | RF | -0.1 | <- Hit
10| 2 | RF | 1.7 | <- High
11| 3 | MLP | 0.2 | <- Hit
12| 4 | MLP | -0.7 | <- Low
13| 5 | MLP | -0.6 | <- Low
14+----+--------+---------+
15pd.DataFrame({"Type":["RF", "MLP"], "Low":[1,2], "Hit":[1,1], "High":[1,0]})
16
17+----+--------+-------+-------+--------+
18| | Type | Low | Hit | High |
19|----+--------+-------+-------+--------|
20| 0 | RF | 1 | 1 | 1 |
21| 1 | MLP | 2 | 1 | 0 |
22+----+--------+-------+-------+--------+
23(df.assign(group=pd.cut(df['Value'],
24 [float('-inf'), -0.25, 0.25, float('inf')],
25 labels=['Low', 'Hit', 'High']))
26 .pivot_table(index='Type', columns='group', values='Value', aggfunc='count')
27 .reset_index()
28 .rename_axis(None, axis=1)
29)
30(pd.crosstab(df['Type'],
31 pd.cut(df['Value'],
32 [float('-inf'), -0.25, 0.25, float('inf')],
33 labels=['Low', 'Hit', 'High'])
34 )
35 .reset_index().rename_axis(None, axis=1)
36 )
37
output:
1import pandas as pd
2
3df = pd.DataFrame({"Type":["RF", "RF", "RF", "MLP", "MLP", "MLP"], "Value":[-1.5,-0.1,1.7,0.2,-0.7,-0.6]})
4
5+----+--------+---------+
6| | Type | Value |
7|----+--------+---------|
8| 0 | RF | -1.5 | <- Low
9| 1 | RF | -0.1 | <- Hit
10| 2 | RF | 1.7 | <- High
11| 3 | MLP | 0.2 | <- Hit
12| 4 | MLP | -0.7 | <- Low
13| 5 | MLP | -0.6 | <- Low
14+----+--------+---------+
15pd.DataFrame({"Type":["RF", "MLP"], "Low":[1,2], "Hit":[1,1], "High":[1,0]})
16
17+----+--------+-------+-------+--------+
18| | Type | Low | Hit | High |
19|----+--------+-------+-------+--------|
20| 0 | RF | 1 | 1 | 1 |
21| 1 | MLP | 2 | 1 | 0 |
22+----+--------+-------+-------+--------+
23(df.assign(group=pd.cut(df['Value'],
24 [float('-inf'), -0.25, 0.25, float('inf')],
25 labels=['Low', 'Hit', 'High']))
26 .pivot_table(index='Type', columns='group', values='Value', aggfunc='count')
27 .reset_index()
28 .rename_axis(None, axis=1)
29)
30(pd.crosstab(df['Type'],
31 pd.cut(df['Value'],
32 [float('-inf'), -0.25, 0.25, float('inf')],
33 labels=['Low', 'Hit', 'High'])
34 )
35 .reset_index().rename_axis(None, axis=1)
36 )
37 Type Low Hit High
380 MLP 2 1 0
391 RF 1 1 1
40
QUESTION
What should the result be when assigning a variable to a reference to itself, in-between modified and then returned by a function call?
Asked 2022-Feb-02 at 00:421#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15
I'm currently in the middle of learning about lvalues and rvalues and was experimenting a bit, and made this which seems to be getting conflicting results. https://godbolt.org/z/KqsGz3Toe produces an out put of "5 6", as does Clion and Visual Studio, however https://www.onlinegdb.com/49mUC7x8U produces a result of "6 7"
I would think that because addOne
is calling x
as a reference, it would explicitly change the value of x
to 6 despite being called as an lvalue. What should the correct result be?
ANSWER
Answered 2022-Feb-02 at 00:42Since C++17 the order of evaluation is specified such that the operands of =
are evaluated right-to-left and those of <<
are evaluated left-to-right, matching the associativity of these operators. (But this doesn't apply to all operators, e.g. +
and other arithmetic operators.)
So in
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16
first the value of the right-hand side is evaluated, yielding 5
. Then the function addOne
is called and it doesn't matter what it does with x
since it returns a reference to it, to which the right-hand value 5
is assigned.
Formally, evaluating the right-hand side first means that we replace the lvalue x
by the (pr)value it holds (lvalue-to-rvalue conversion). Then we call addOne(x)
to modify the object that the lvalue x
refers to.
So, imagining temporary variables to hold the results of the individual evaluations, the line is equivalent to (except for extra copies introduced by the new variables, which don't matter in the case of int
):
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19
Then in the line
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19std::cout << x << ' ' << addOne(x);
20
we first evaluate and output x
, resulting in 5
, and then call addOne
, resulting in 6
.
So the line is equivalent to (simplified, knowing that operator<<
will return std::cout
again):
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19std::cout << x << ' ' << addOne(x);
20int t1 = x;
21std::cout << t1 << ' ';
22int t2 = addOne(x);
23std::cout << t2;
24
The output 5 6
is the only correct one since C++17.
Before C++17, the evaluation order of the two sides of the assignment operator was unsequenced.
Having a scalar modification unsequenced with a value computation on the same scalar (on the right-hand side of your assignment) causes undefined behavior normally.
But since you put the increment of x
into a function, an additional rule saying that the execution of a function body is merely indeterminately sequenced with other evaluations in the calling context saves this. It means that the line wont have undefined behavior anymore, but the order in which the evaluations of the two sides of the assignment happen could be either left-first or right-first.
This means we won't know whether x
is evaluated first and then addOne(x)
or the other way around.
Therefore after the line, x
may be 5
or 6
.
6
would be obtained if the evaluation happened equivalently to
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19std::cout << x << ' ' << addOne(x);
20int t1 = x;
21std::cout << t1 << ' ';
22int t2 = addOne(x);
23std::cout << t2;
24int& y = addOne(x);
25int t = x;
26y = t;
27
Then in the line
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19std::cout << x << ' ' << addOne(x);
20int t1 = x;
21std::cout << t1 << ' ';
22int t2 = addOne(x);
23std::cout << t2;
24int& y = addOne(x);
25int t = x;
26y = t;
27std::cout << x << ' ' << addOne(x);
28
pre-C++17 the same issue applied. The evaluations of the arguments to <<
were indeterminately sequenced, rather than left-to-right and so addOne(x)
could be evaluated before the left-hand x
, i.e. in addition to the previous order, the evaluation could also be equivalent to
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19std::cout << x << ' ' << addOne(x);
20int t1 = x;
21std::cout << t1 << ' ';
22int t2 = addOne(x);
23std::cout << t2;
24int& y = addOne(x);
25int t = x;
26y = t;
27std::cout << x << ' ' << addOne(x);
28int t2 = addOne(x);
29int t1 = x;
30std::cout << t1 << ' ' << t2;
31
In this case x
is first incremented and then its new value is printed twice.
Therefore possible program output could be either of the following:
1#include <iostream>
2
3int& addOne(int& x)
4{
5 x += 1;
6 return x;
7}
8
9int main()
10{
11 int x {5};
12 addOne(x) = x;
13 std::cout << x << ' ' << addOne(x);
14}
15addOne(x) = x;
16int t = x;
17int& y = addOne(x);
18y = t; // same as x = t, because y will refer to x
19std::cout << x << ' ' << addOne(x);
20int t1 = x;
21std::cout << t1 << ' ';
22int t2 = addOne(x);
23std::cout << t2;
24int& y = addOne(x);
25int t = x;
26y = t;
27std::cout << x << ' ' << addOne(x);
28int t2 = addOne(x);
29int t1 = x;
30std::cout << t1 << ' ' << t2;
315 6
326 6
336 7
347 7
35
(Technically the int t2 = addOne(x)
are two evaluations: One call to addOne
returning a reference and then the lvalue-to-rvalue conversion. These could happen interleaved with the other evaluations, but this doesn't give any new program outputs.)
You can specify to use C++17 (or newer versions like C++20) with the -std=c++17
flag to the compiler if you are using GCC or Clang and /std:c++17
if you are using MSVC. Which standard version is chosen by-default depends on the compiler and compiler version.
QUESTION
Flutter (2.5) - A splash screen was provided to Flutter, but this is deprecated
Asked 2022-Jan-19 at 05:24I am new to flutter and recently tried to develop a test app for learning sake with latest version Flutter 2.5. By looking at some tutorial online, I have added flutter_native_splash: ^1.2.3
package for splash screen. And works fine.
However, when I launch app for the first time, it shows following debug message
W/FlutterActivityAndFragmentDelegate(18569): A splash screen was provided to Flutter, but this is deprecated. See flutter.dev/go/android-splash-migration for migration steps.
After visiting the above link, I am not able to understand much what is supposed to be done.
Code in pubspec.yaml
1flutter_native_splash:
2 color: "#FFFFFF"
3 color_dark: "#000000"
4 image: assets/images/splash_720.png
5 android: true
6 ios: true
7 android12: true
8
Also, compileSdkVersion and targetSdkVersion is set to 31 in build.gradle
Please help. Thanks in advance.
ANSWER
Answered 2022-Jan-19 at 05:24AndroidManifest.xml
file.
Previously, Android Flutter apps would either set
io.flutter.embedding.android.SplashScreenDrawable
in their application manifest, or implementprovideSplashScreen
within their Flutter Activity. This would be shown momentarily in between the time after the Android launch screen is shown and when Flutter has drawn the first frame. This is no longer needed and is deprecated – Flutter now automatically keeps the Android launch screen displayed until Flutter has drawn the first frame. Developers should instead remove the usage of these APIs. - source
UPDATE (FLUTTER 2.8.0)
As per the flutter 2.8.0 update, The newly created project doesn't have this warning.
They removed unused API from Androidmanifest.yml
but still have belove mentioned code.
Community Discussions contain sources that include Stack Exchange Network
Tutorials and Learning Resources in Learning
Tutorials and Learning Resources are not available at this moment for Learning